:root {
    --olive: #5b6b2f;
    --olive-dark: #3f4a1f;
    --olive-light: #eef1e4;
    --gold: #c9a227;
    --bg: #f7f6f1;
    --card: #ffffff;
    --text: #23261d;
    --muted: #6d7062;
    --line: #dedcd2;
    --red: #b3372b;
    --red-light: #fbeae8;
    --blue: #2f5f8a;
    --blue-light: #e6eff8;
    --green: #2e7d4f;
    --green-light: #e4f3ea;
    --gray-light: #efeeea;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 14px rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--olive-dark); }
h1, h2, h3 { margin: 0 0 .6em; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ── Zaglavlje ─────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: .6rem 1.2rem;
    background: var(--olive-dark);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; }
.topbar nav { display: flex; gap: .3rem; flex: 1; flex-wrap: wrap; }
.topbar nav a {
    color: #e8ead9;
    text-decoration: none;
    padding: .35rem .75rem;
    border-radius: 6px;
}
.topbar nav a:hover { background: rgba(255, 255, 255, .1); }
.topbar nav a.active { background: rgba(255, 255, 255, .18); color: #fff; }
.topbar .user { font-size: .9rem; opacity: .85; }
.topbar .user button { margin-left: .5rem; }

main { padding: 1.2rem; max-width: 1400px; margin: 0 auto; }

/* ── Elementi ─────────────────────────────────────────────── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.2rem;
    margin-bottom: 1rem;
}

button, .btn {
    font: inherit;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    padding: .45rem .9rem;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}
button:hover, .btn:hover { border-color: var(--olive); }
button:disabled { opacity: .5; cursor: default; }
button.primary, .btn.primary { background: var(--olive); border-color: var(--olive); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--olive-dark); }
button.danger { color: var(--red); border-color: #e3b5af; }
button.danger:hover { background: var(--red-light); }
button.ghost { background: transparent; border-color: transparent; color: inherit; }
button.small { padding: .2rem .55rem; font-size: .85rem; }

input, select, textarea {
    font: inherit;
    padding: .42rem .6rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(91, 107, 47, .35); border-color: var(--olive); }
textarea { resize: vertical; min-height: 3.2em; }

label.field { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { color: var(--text); font-size: 15px; }
label.check { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
.span2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--olive-light); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}
.st-booked { background: var(--blue-light); color: var(--blue); }
.st-done { background: var(--green-light); color: var(--green); }
.st-no_show { background: #fdf1d8; color: #8a5a00; }
.st-cancelled { background: var(--gray-light); color: var(--muted); text-decoration: line-through; }

/* ── Obavijesti ───────────────────────────────────────────── */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast {
    background: var(--text);
    color: #fff;
    padding: .7rem 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 380px;
    animation: fadein .2s;
}
.toast.error { background: var(--red); }
.toast.warn { background: #8a5a00; }
.toast.ok { background: var(--green); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }

/* ── Dijalozi ─────────────────────────────────────────────── */
dialog {
    border: none;
    border-radius: 10px;
    padding: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
    width: min(640px, 96vw);
    max-height: 92vh;
}
dialog::backdrop { background: rgba(30, 32, 25, .45); }
dialog .dlg-head { display: flex; align-items: center; padding: .9rem 1.2rem; border-bottom: 1px solid var(--line); }
dialog .dlg-head h2 { margin: 0; flex: 1; }
dialog .dlg-body { padding: 1rem 1.2rem; overflow: auto; }
dialog .dlg-foot { display: flex; gap: .5rem; flex-wrap: wrap; padding: .8rem 1.2rem; border-top: 1px solid var(--line); background: #fafaf7; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .7rem .9rem; margin: 0 0 .9rem; }
legend { font-size: .8rem; color: var(--muted); padding: 0 .3rem; text-transform: uppercase; letter-spacing: .04em; }

/* ── Raspored ─────────────────────────────────────────────── */
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .date-title { font-size: 1.25rem; font-weight: 600; margin: 0 .6rem; min-width: 16ch; }
.closed-banner { background: #fdf1d8; color: #8a5a00; padding: .6rem 1rem; border-radius: 8px; margin-bottom: 1rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .7rem 1rem; }
.stat .v { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.schedule { display: grid; position: relative; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.schedule .colhead {
    position: sticky; top: 0;
    background: var(--olive-light); font-weight: 600; padding: .5rem .6rem;
    border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); z-index: 2;
}
.schedule .colhead .cap { font-weight: 400; font-size: .8rem; color: var(--muted); }
.schedule .timecol { border-right: 1px solid var(--line); }
.schedule .tick { height: var(--row-h); font-size: .78rem; color: var(--muted); padding: 0 .4rem; border-top: 1px solid transparent; text-align: right; line-height: 1; padding-top: 2px; }
.schedule .lane { position: relative; border-left: 1px solid var(--line); }
.schedule .cell { height: var(--row-h); border-top: 1px dashed #ecebe4; cursor: copy; }
.schedule .cell.hour { border-top: 1px solid #dddbd0; }
.schedule .cell:hover { background: var(--olive-light); }
.schedule .cell.past { background: repeating-linear-gradient(45deg, #fafaf7, #fafaf7 6px, #f3f2ec 6px, #f3f2ec 12px); cursor: default; }

.bk {
    position: absolute; left: 4px; right: 4px;
    border-radius: 6px; padding: .25rem .5rem;
    font-size: .85rem; overflow: hidden; cursor: pointer;
    border-left: 4px solid var(--blue);
    background: var(--blue-light);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
    line-height: 1.25;
}
.bk:hover { filter: brightness(.97); box-shadow: 0 2px 6px rgba(0, 0, 0, .15); z-index: 3; }
.bk.done { border-left-color: var(--green); background: var(--green-light); }
.bk.no_show { border-left-color: #c98a00; background: #fdf1d8; }
.bk .t { font-weight: 600; }
.bk .kg { float: right; font-weight: 700; }
.bk .src { font-size: .75rem; color: var(--muted); }
.nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--red); z-index: 4; pointer-events: none; }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: .85rem; }
.chip:hover, .chip.sel { background: var(--olive); color: #fff; border-color: var(--olive); }

.timeline { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.timeline li { padding: .3rem 0; border-bottom: 1px dotted var(--line); }
.timeline li .when { color: var(--muted); margin-right: .5rem; }

/* ── Kupci ─────────────────────────────────────────────────── */
.split { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(420px, 1.2fr); gap: 1rem; align-items: start; }
.msg-log { max-height: 420px; overflow: auto; display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; }
.msg-log .m { padding: .35rem .6rem; border-radius: 8px; max-width: 85%; white-space: pre-wrap; }
.msg-log .m.in { background: #fff; border: 1px solid var(--line); align-self: flex-start; }
.msg-log .m.out { background: #dcf8c6; align-self: flex-end; }
.msg-log .m .meta { font-size: .72rem; color: var(--muted); margin-top: .15rem; }

/* ── Prijava ──────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(360px, 100%); }
.login-card h1 { text-align: center; }
.login-card form { display: flex; flex-direction: column; gap: .8rem; }
.err { color: var(--red); font-size: .9rem; min-height: 1.2em; }

/* ── Javna stranica ───────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, var(--olive-dark), var(--olive));
    color: #fff; text-align: center; padding: 3.5rem 1rem 3rem;
}
.hero h1 { font-size: 2.2rem; margin-bottom: .3rem; }
.hero p { font-size: 1.1rem; opacity: .9; margin: .3rem 0 1.5rem; }
.wa-btn {
    display: inline-flex; align-items: center; gap: .6rem;
    background: #25d366; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem;
    padding: .9rem 1.6rem; border-radius: 999px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.wa-btn:hover { background: #1ebe5b; }
.wa-btn svg { width: 26px; height: 26px; fill: #fff; }
.public { max-width: 880px; margin: -1.5rem auto 2rem; padding: 0 1rem; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.steps .n { width: 2rem; height: 2rem; border-radius: 50%; background: var(--olive); color: #fff; display: grid; place-items: center; font-weight: 700; margin-bottom: .5rem; }
.freedays { display: flex; flex-wrap: wrap; gap: .5rem; }
.freedays .d { background: var(--olive-light); border-radius: 8px; padding: .5rem .8rem; text-align: center; min-width: 90px; }
.freedays .d b { display: block; }
footer.pub { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem; }
footer.pub a { color: var(--muted); }

/* ── Simulator ────────────────────────────────────────────── */
.phone {
    width: 400px; max-width: 100%; height: 680px;
    border-radius: 28px; border: 10px solid #1f2420; background: #efe7dd;
    display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow);
}
.phone .ph-head { background: #075e54; color: #fff; padding: .7rem 1rem; font-weight: 600; }
.phone .ph-head small { display: block; font-weight: 400; opacity: .8; }
.phone .ph-chat { flex: 1; overflow-y: auto; padding: .8rem; display: flex; flex-direction: column; gap: .45rem; }
.phone .ph-input { display: flex; gap: .4rem; padding: .5rem; background: #f0f0f0; }
.phone .ph-input input { flex: 1; border-radius: 999px; }
.bubble { max-width: 85%; padding: .45rem .65rem; border-radius: 8px; font-size: .9rem; white-space: pre-wrap; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); }
.bubble.me { align-self: flex-end; background: #dcf8c6; }
.bubble.bot { align-self: flex-start; background: #fff; }
.bubble.tpl { border: 1px dashed #999; }
.bubble .wa-buttons { display: flex; flex-direction: column; gap: 1px; margin: .5rem -.65rem -.45rem; border-top: 1px solid #e5e5e5; }
.bubble .wa-buttons button { border: none; border-radius: 0; background: #fff; color: #0a7cff; justify-content: center; padding: .5rem; }
.bubble .wa-buttons button:hover { background: #f4f4f4; }
.bubble .wa-list { margin-top: .4rem; display: none; flex-direction: column; border-top: 1px solid #e5e5e5; }
.bubble .wa-list.open { display: flex; }
.bubble .wa-list button { border: none; border-bottom: 1px solid #eee; border-radius: 0; background: #fff; text-align: left; flex-direction: column; align-items: flex-start; padding: .4rem .2rem; }
.bubble .wa-list button small { color: var(--muted); }

@media (max-width: 900px) {
    .split, .grid3, .grid4, .steps { grid-template-columns: 1fr; }
    .grid2 { grid-template-columns: 1fr; }
    .span2 { grid-column: auto; }
    .topbar { flex-wrap: wrap; gap: .5rem; }
}
