:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #17202a;
    --muted: #5d6b7a;
    --line: #dde3e9;
    --primary: #0f6e6a;
    --primary-ink: #ffffff;
    --primary-soft: #e3f2f1;
    --err: #c62828;
    --err-soft: #fdecec;
    --warn: #9a6400;
    --warn-soft: #fff6e0;
    --ok: #1d7a3a;
    --ok-soft: #e7f5ec;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1418; --surface: #182027; --text: #e6edf2; --muted: #93a2b0; --line: #2a353f;
        --primary: #3fb8ae; --primary-ink: #04201e; --primary-soft: #16302e;
        --err: #ff8a80; --err-soft: #3a1d1d; --warn: #f2c36b; --warn-soft: #362c16;
        --ok: #7fd69a; --ok-soft: #173023;
        color-scheme: dark;
    }
    .foot .ta img { filter: invert(1); }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--primary); }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 24px; padding-bottom: 40px; }
[hidden] { display: none !important; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none; padding: 8px 0; }
.brand-mark { color: var(--primary); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 38px; height: 38px; display: block; }
.brand-name { display: block; font-weight: 750; font-size: 1.2rem; letter-spacing: -.01em; line-height: 1.1; }
.brand-tagline { display: block; color: var(--muted); font-size: .82rem; line-height: 1.3; }
.session { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.session form { margin: 0; }
.session-email { color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* header s glavnom porukom (početna stranica) */
.top.with-hero {
    position: relative; overflow: hidden; border-bottom: 0; color: #fff;
    background:
        radial-gradient(1200px 400px at 85% -10%, rgba(255, 255, 255, .14), transparent 60%),
        linear-gradient(135deg, #0b5552 0%, #0f6e6a 45%, #12877f 100%);
}
.top.with-hero::after {   /* diskretni "barkod" motiv u pozadini */
    content: ""; position: absolute; right: -40px; bottom: -30px; width: 340px; height: 220px;
    transform: rotate(-12deg); opacity: .09; pointer-events: none;
    background: repeating-linear-gradient(90deg, #fff 0 3px, transparent 3px 6px, #fff 6px 7px, transparent 7px 11px, #fff 11px 15px, transparent 15px 17px);
}
.top.with-hero .brand { color: #fff; }
.top.with-hero .brand-mark { color: #fff; }
.top.with-hero .brand-tagline, .top.with-hero .session-email { color: rgba(255, 255, 255, .78); }
.top.with-hero .link-btn { color: #fff; }
.hero { position: relative; z-index: 1; padding-top: 18px; padding-bottom: 70px; max-width: 1180px; }
.hero-title { font-size: clamp(1.75rem, 1.2rem + 2.6vw, 2.9rem); line-height: 1.12; margin: 0 0 12px; letter-spacing: -.02em; font-weight: 800; max-width: 760px; }
.hero { text-align: center; }
.hero-title, .hero-sub { margin-left: auto; margin-right: auto; }
.hero-title .hl { color: #ffd66b; white-space: nowrap; }
.hero-sub { margin-bottom: 18px; margin-top: 0; font-size: clamp(1rem, .95rem + .3vw, 1.15rem); color: rgba(255, 255, 255, .88); max-width: 640px; }
.hero-flow { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.hero-flow li:not(.arrow) {
    display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px 7px 10px; border-radius: 999px;
    background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22); font-weight: 600; font-size: .92rem;
}
.hero-flow svg { width: 18px; height: 18px; }
.hero-flow .arrow { color: rgba(255, 255, 255, .6); font-weight: 700; }
body:not([data-view="upload"]) .hero { display: none; }
body[data-view="upload"] .top.with-hero + main .upload-card { margin-top: -50px; position: relative; }
/* obavijest iznad kartice preuzima podvlačenje pod header, kartica ide ispod nje */
#view-upload > .notice { max-width: 620px; margin-left: auto; margin-right: auto; position: relative; }
body[data-view="upload"] .top.with-hero + main #view-upload > .notice:first-child { margin-top: -50px; }
body[data-view="upload"] .top.with-hero + main #view-upload > .notice ~ .upload-card { margin-top: 0; }

/* footer */
.foot { border-top: 1px solid var(--line); background: var(--surface); font-size: .9rem; }
.foot-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.foot .ta { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 600; }
.foot nav { display: flex; gap: 16px; flex-wrap: wrap; }
.dev-link { color: var(--warn); }

/* osnovni elementi */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.narrow { max-width: 760px; margin: 0 auto; }
h1 { font-size: 1.5rem; margin: 0 0 12px; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { font-size: .95rem; margin: 0 0 8px; color: var(--muted); }
.fine { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }
.opt { color: var(--muted); font-weight: 400; font-size: .85em; font-style: normal; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid transparent; border-radius: 10px; padding: 11px 18px; min-height: 44px;
    font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: filter .15s, background .15s;
}
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--primary-soft); }
.btn-wide { width: 100%; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn.danger { color: var(--err); }
.pill { display: inline-block; font-size: .78rem; padding: 2px 10px; border-radius: 999px; text-decoration: none; font-weight: 600; }
.pill-admin { background: var(--warn-soft); color: var(--warn); }
.pill-blocked { background: var(--err-soft); color: var(--err); }
.pill-link { background: var(--primary-soft); color: var(--primary); }

.notice { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: .92rem; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.error { background: var(--err-soft); color: var(--err); }
.notice.info { background: var(--primary-soft); color: var(--text); }
.form-error { color: var(--err); font-size: .9rem; margin: 10px 0 0; }

/* upload */
.upload-card { max-width: 620px; margin: 0 auto; display: grid; gap: 14px; }
.drop {
    position: relative; display: grid; justify-items: center; gap: 6px; text-align: center;
    border: 2px dashed var(--line); border-radius: 12px; padding: 34px 16px; cursor: pointer;
    transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop-icon { color: var(--primary); }
.drop-title { font-weight: 700; font-size: 1.1rem; }
.drop-sub { color: var(--muted); font-size: .88rem; }
.upload-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.camera-btn { position: relative; overflow: hidden; }
.camera-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.or { color: var(--muted); font-size: .88rem; }

/* obrada */
.processing-card { max-width: 560px; margin: 0 auto; text-align: center; display: grid; gap: 14px; justify-items: center; }
.scan-anim { position: relative; width: 120px; height: 150px; margin: 10px auto 0; }
.paper { position: absolute; inset: 0; background: var(--surface); border: 2px solid var(--line); border-radius: 8px; padding: 22px 16px; display: grid; gap: 10px; align-content: start; }
.paper i { display: block; height: 7px; border-radius: 4px; background: var(--line); }
.paper i.short { width: 55%; }
.beam { position: absolute; left: -10px; right: -10px; height: 3px; background: var(--primary); box-shadow: 0 0 14px 3px var(--primary); border-radius: 3px; animation: scan 1.8s ease-in-out infinite; }
@keyframes scan { 0%, 100% { top: 6px; } 50% { top: 140px; } }
@media (prefers-reduced-motion: reduce) { .beam { animation: none; top: 70px; } }
.ready-badge {
    position: absolute; right: -12px; bottom: -12px; width: 40px; height: 40px; border-radius: 50%;
    background: var(--ok); color: #fff; display: none; place-items: center; box-shadow: var(--shadow);
}
.scan-anim.stopped .beam { display: none; }
.scan-anim.stopped .ready-badge { display: grid; }
.processing-text { font-weight: 600; margin: 0; }
.verify-text { font-weight: 600; margin: 0 0 10px; }
.verify-form { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.verify-form input { flex: 1 1 220px; }
.sent-title { margin: 0; }
#verify-box, #sent-box { width: 100%; }

/* forme */
input[type=email], input[type=number], .field input {
    width: 100%; font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; min-height: 44px;
}
input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.field { display: grid; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field label, .field > span { font-size: .85rem; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.field .count { font-weight: 400; font-variant-numeric: tabular-nums; }
.field .count.over { color: var(--err); font-weight: 700; }
.field .hint { color: var(--muted); font-size: .78rem; }
.field.has-error input { border-color: var(--err); background: var(--err-soft); }
.field.has-warning input { border-color: var(--warn); background: var(--warn-soft); }
.msgs { display: grid; gap: 2px; }
.msg { font-size: .84rem; }
.msg.error { color: var(--err); }
.msg.warning { color: var(--warn); }
.msg button { margin-left: 6px; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 14px 0 4px; min-width: 0; }
legend { font-weight: 700; padding: 0 8px 0 0; }
.row { display: flex; gap: 12px; }
.row .field { flex: 1; }
.row .field:has(.short) { flex: 0 0 110px; }
.legend-err { color: var(--err); font-weight: 600; }
.legend-warn { color: var(--warn); font-weight: 600; }
.confirm { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-soft); color: var(--text); border-radius: 10px; padding: 12px; margin: 8px 0; font-size: .92rem; }
.confirm input { width: 20px; height: 20px; flex: none; margin: 0; }
.form-actions { display: grid; gap: 10px; justify-items: center; margin-top: 12px; }

/* pregled */
.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px); gap: 18px; align-items: start; }
.doc-pane { position: sticky; top: 12px; padding: 14px; }
.doc-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 10px; }
.doc-view { background: var(--bg); border-radius: 10px; overflow: auto; max-height: calc(100vh - 140px); min-height: 300px; }
.doc-view img { display: block; width: 100%; height: auto; margin-bottom: 6px; }
.doc-view iframe { display: block; width: 100%; height: calc(100vh - 150px); min-height: 480px; border: 0; }
.doc-fallback { padding: 30px 16px; text-align: center; }
.result { margin-top: 18px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.barcode-frame { background: #fff; padding: 16px; border-radius: 10px; border: 1px solid var(--line); max-width: 100%; }
.barcode-frame img { display: block; max-width: 100%; height: auto; image-rendering: pixelated; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.result details { width: 100%; max-width: 520px; text-align: left; }
.result pre { background: var(--bg); padding: 12px; border-radius: 8px; overflow: auto; font-size: .85rem; }

/* privacy */
.prose h2 { margin-top: 22px; }
.prose li { margin-bottom: 4px; }

/* admin */
.admin { display: grid; gap: 18px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; }
.admin-head h1 { margin: 0; }
.admin-head form { margin: 0; }
.segmented { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.segmented label { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.segmented label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.limits { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.limits .field input { max-width: 160px; }
.admin-settings .btn { margin-top: 12px; }
.table-scroll { overflow-x: auto; margin-top: 10px; }
table.accounts { width: 100%; border-collapse: collapse; font-size: .9rem; }
.accounts th, .accounts td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.accounts th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.accounts .num { text-align: right; font-variant-numeric: tabular-nums; }
.accounts tr.blocked td { color: var(--muted); }
.accounts form { margin: 0; }
.accounts tr.day th { color: var(--text); font-size: .85rem; background: var(--primary-soft); }

@media (max-width: 860px) {
    .review { grid-template-columns: 1fr; }
    .doc-pane { position: static; }
    .doc-view { max-height: 60vh; }
    .doc-view iframe { height: 60vh; min-height: 360px; }
    .limits { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .card { padding: 16px; }
    .brand-tagline { font-size: .76rem; }
    .row { flex-wrap: wrap; }
    .row .field, .row .field:has(.short) { flex: 1 1 100%; }
}
.key-limit { display: flex; gap: 6px; align-items: center; }
.key-limit input { width: 92px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: var(--surface); color: var(--text); }
.cost-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 6px 0 10px; }
.cost-stats div { display: flex; flex-direction: column; gap: 2px; }
.cost-stats strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }

/* --- dialog modul (assets/dialog.js, normativ ui--dialozi) --------------------------------- */
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover { filter: brightness(1.07); }
.dlg-shade { position: fixed; inset: 0; z-index: 1000; background: rgba(10, 16, 22, .45); display: grid; place-items: center; padding: 16px; }
.dlg {
    width: min(440px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden;
    background: var(--surface); color: var(--text); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    border-top: 5px solid var(--dlg-accent);
}
.dlg--info { --dlg-accent: var(--primary); }
.dlg--success { --dlg-accent: var(--ok); }
.dlg--warning { --dlg-accent: var(--warn); }
.dlg--error { --dlg-accent: var(--err); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; flex: none; }
.dlg-head svg { width: 24px; height: 24px; flex: none; fill: none; stroke: var(--dlg-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dlg-head h2 { margin: 0; font-size: 1.08rem; }
.dlg-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 10px 20px 4px; }
.dlg-msg { margin: 0; white-space: pre-line; }
.dlg-input { width: 100%; margin-top: 10px; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font: inherit; background: var(--surface); color: var(--text); }
.dlg-foot { flex: none; display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px 18px; }

/* --- MOM (More Options meni, normativ ui--more-options-meni) ---------------------------------- */
.mom-trigger {
    display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid transparent; border-radius: 8px;
    background: none; color: var(--muted); cursor: pointer;
}
.mom-trigger:hover, .mom-trigger[aria-expanded="true"] { background: var(--primary-soft); color: var(--primary); }
.mom-trigger svg { width: 18px; height: 18px; fill: currentColor; }
.mom-menu {
    position: fixed; z-index: 900; min-width: 190px; padding: 6px; background: var(--surface);
    border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(16, 24, 40, .16);
}
.mom-menu form { margin: 0; }
.mom-item {
    display: block; width: 100%; text-align: left; padding: 8px 12px; border: 0; border-radius: 7px;
    background: none; color: var(--text); font: inherit; font-size: .92rem; cursor: pointer;
}
.mom-item:hover:not(:disabled) { background: var(--primary-soft); }
.mom-item.danger { color: var(--err); }
.mom-item.danger:hover:not(:disabled) { background: var(--err-soft); }
.mom-item:disabled { color: var(--muted); opacity: .55; cursor: not-allowed; }
.mom-sep { height: 1px; margin: 5px 4px; background: var(--line); }
