:root {
  --bg: #f3f4f5;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --line: #dde1e5;
  --line-2: #c6ccd2;
  --text: #1d2126;
  --text-2: #4c545d;
  --muted: #737c86;
  --alu: #a9b1b9;
  --alu-dark: #6f7883;
  --accent: #1f5fbf;
  --accent-ink: #ffffff;
  --accent-soft: #e6eefb;
  --ok: #1d7a46; --ok-soft: #e3f3ea;
  --warn: #9a6200; --warn-soft: #fbf0d9;
  --bad: #b3261e; --bad-soft: #fbe5e3;
  --none: #5c6670; --none-soft: #eceef0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 28, .06), 0 4px 16px rgba(20, 24, 28, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181b; --surface: #1d2125; --surface-2: #23282d; --line: #31373d; --line-2: #3d444b;
    --text: #e8eaed; --text-2: #b7bdc4; --muted: #8b939c; --alu: #59616a; --alu-dark: #8a929b;
    --accent: #5b93ea; --accent-ink: #0d1520; --accent-soft: #1d2a3d;
    --ok: #5cc68b; --ok-soft: #173225; --warn: #e2ad4b; --warn-soft: #362a12; --bad: #ef7a72; --bad-soft: #3a1c1a; --none: #a3abb3; --none-soft: #2a2f34;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15181b; --surface: #1d2125; --surface-2: #23282d; --line: #31373d; --line-2: #3d444b;
  --text: #e8eaed; --text-2: #b7bdc4; --muted: #8b939c; --alu: #59616a; --alu-dark: #8a929b;
  --accent: #5b93ea; --accent-ink: #0d1520; --accent-soft: #1d2a3d;
  --ok: #5cc68b; --ok-soft: #173225; --warn: #e2ad4b; --warn-soft: #362a12; --bad: #ef7a72; --bad-soft: #3a1c1a; --none: #a3abb3; --none-soft: #2a2f34;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 18px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- okvir ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; gap: 6px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .06em; font-size: 1.15rem; padding: 4px 8px 16px; }
.logo svg { flex: none; }
.logo small { display: block; font-weight: 500; letter-spacing: 0; font-size: .7rem; color: var(--muted); }
.nav a { display: flex; align-items: center; gap: 12px; padding: 12px 12px; border-radius: 10px; color: var(--text-2); font-weight: 600; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 22px; height: 22px; flex: none; }
.side .foot { margin-top: auto; font-size: .8rem; color: var(--muted); padding: 8px; display: grid; gap: 8px; }
.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; padding: 10px 24px; }
.search { flex: 1; max-width: 640px; position: relative; }
.search input { width: 100%; padding: 11px 14px 11px 40px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.who { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: .9rem; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--alu); display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.page { padding: 24px; max-width: 1280px; }
.bottom { display: none; }

/* ---------- elementi ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 16px; }
.card h2 { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text); }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.pri:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 34px; padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.big { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.bigbtn { min-height: 120px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: 18px; font-size: 1.1rem; font-weight: 700; cursor: pointer; text-align: left; color: var(--text); }
.bigbtn svg { width: 34px; height: 34px; color: var(--accent); }
.bigbtn span { font-size: .85rem; font-weight: 500; color: var(--muted); }
.bigbtn:hover { border-color: var(--accent); }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .85rem; }
label.f { display: grid; gap: 4px; font-size: .85rem; color: var(--text-2); font-weight: 600; }
input.i, select.i, textarea.i { width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); font-size: 1rem; font-weight: 400; color: var(--text); }
textarea.i { min-height: 90px; resize: vertical; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .wide { grid-column: 1 / -1; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; position: sticky; top: 0; background: var(--surface); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tablewrap { overflow-x: auto; max-height: 70vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--text-2); }
.tab.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--none-soft); color: var(--none); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.acc { background: var(--accent-soft); color: var(--accent); }
.list { display: grid; gap: 10px; }
.item { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.item:hover { border-color: var(--line-2); background: var(--surface-2); }
.item .t { font-weight: 700; }
.empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 12px; }
.gate { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 6px; background: var(--surface); }
.gate .st { font-weight: 800; font-size: .85rem; }
.gate.ok { border-left: 6px solid var(--ok); }
.gate.warn { border-left: 6px solid var(--warn); }
.gate.bad { border-left: 6px solid var(--bad); }
.gate.none { border-left: 6px solid var(--alu); }
.spark { width: 100%; height: 70px; display: block; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.score { display: inline-block; min-width: 38px; padding: 3px 8px; border-radius: 8px; font-weight: 800; background: var(--accent-soft); color: var(--accent); }

/* ---------- ladica zapisa ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(10, 12, 14, .35); z-index: 50; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--surface); z-index: 51; box-shadow: -8px 0 30px rgba(0,0,0,.15); display: flex; flex-direction: column; }
.drawer header { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer .body { padding: 18px; overflow-y: auto; flex: 1; }
.drawer footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Janez ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 140px); min-height: 420px; }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 12px; }
.msg { max-width: 82%; padding: 12px 16px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .meta { font-size: .72rem; opacity: .7; margin-top: 6px; }
.msg .skica { background: #fff; border-radius: 10px; margin-top: 10px; padding: 8px; }
.msg .skica svg { width: 100%; height: auto; }
.ref { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: .8em; font-weight: 700; cursor: pointer; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; min-height: 56px; max-height: 200px; }
.mic { width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--accent); color: var(--accent-ink); cursor: pointer; display: grid; place-items: center; flex: none; }
.mic.rec { background: var(--bad); animation: puls 1.2s infinite; }
@keyframes puls { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--bad) 25%, transparent); } }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.quick button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 7px 12px; cursor: pointer; font-size: .85rem; }
.fab { position: fixed; right: 22px; bottom: 22px; z-index: 30; height: 56px; padding: 0 20px 0 16px; border-radius: 28px; background: var(--accent); color: var(--accent-ink); border: none; display: flex; align-items: center; gap: 10px; font-weight: 700; box-shadow: 0 6px 20px rgba(31,95,191,.35); cursor: pointer; }

/* ---------- konfigurator ---------- */
.kfg { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.stage { position: relative; height: 560px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: linear-gradient(#e9edf1, #d5dbe1); }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage .ov { position: absolute; left: 12px; top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.stage .ov .btn { background: rgba(255,255,255,.9); color: #1d2126; }
.stage .note { position: absolute; left: 12px; bottom: 10px; right: 12px; font-size: .75rem; color: #3b434b; background: rgba(255,255,255,.85); padding: 6px 10px; border-radius: 8px; }
.panel { display: grid; gap: 12px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; min-height: 44px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .85rem; padding: 4px 8px; }
.seg button.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 40px; height: 40px; border-radius: 10px; border: 2px solid var(--line-2); cursor: pointer; }
.sw.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.sketch { background: #fff; border-radius: 10px; border: 1px solid var(--line); padding: 8px; }
.sketch svg { width: 100%; height: auto; display: block; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(420px, 100%); text-align: center; padding: 28px; }
.pin { display: flex; gap: 10px; justify-content: center; margin: 18px 0; }
.pin input { width: 200px; height: 68px; text-align: center; font-size: 2rem; font-weight: 800; letter-spacing: .5em; padding-left: .5em; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); -webkit-text-security: disc; }
.pin input::placeholder { letter-spacing: .1em; font-size: 1.1rem; font-weight: 600; color: var(--muted); }
.names { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 12px 18px; border-radius: 10px; z-index: 80; font-weight: 600; max-width: 90vw; }

@media print {
  .side, .top, .bottom, .fab, .noprint { display: none !important; }
  .app { display: block; } .page { padding: 0; } .card { box-shadow: none; border: none; }
  body { background: #fff; color: #000; }
}

@media (max-width: 1100px) {
  .g4, .big { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kfg { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .top { padding: 8px 16px; }
  .who .nm { display: none; }
  .page { padding: 16px 16px 96px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .big { grid-template-columns: 1fr 1fr; gap: 10px; }
  .bigbtn { min-height: 104px; font-size: 1rem; padding: 14px; }
  .form { grid-template-columns: 1fr; }
  .bottom { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; font-weight: 700; color: var(--muted); padding: 6px 0; min-height: 56px; justify-content: center; }
  .bottom a.on { color: var(--accent); }
  .bottom svg { width: 24px; height: 24px; }
  .fab { bottom: 84px; right: 16px; }
  .msg { max-width: 92%; }
  .chat { height: calc(100vh - 210px); }
  .stage { height: 380px; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
}
