/* ════════════════════════════════════════════════════════════
   Vigilo · LTO module shared design-system stylesheet
   Tokens + base components reused across LTO1–LTO8.
   Loaded BEFORE each page's own <style>. Sidebar is rebuilt by
   _shared/vigilo-nav.js so we only define the .app grid + topbar.
   ════════════════════════════════════════════════════════════ */
:root {
  --paper: oklch(0.985 0.003 60); --surface: white;
  --ink-50: oklch(0.985 0.003 60); --ink-75: oklch(0.972 0.004 60);
  --ink-100: oklch(0.955 0.005 60); --ink-150: oklch(0.930 0.006 60);
  --ink-200: oklch(0.900 0.007 60); --ink-300: oklch(0.830 0.008 60);
  --ink-400: oklch(0.700 0.010 60); --ink-500: oklch(0.580 0.011 60);
  --ink-600: oklch(0.460 0.012 60); --ink-700: oklch(0.340 0.013 60);
  --ink-800: oklch(0.240 0.014 60); --ink-900: oklch(0.160 0.015 60);
  --ink-950: oklch(0.110 0.015 60);
  --red: oklch(0.590 0.215 25); --red-bg: oklch(0.972 0.012 25); --red-700: oklch(0.450 0.190 25);
  --success: oklch(0.620 0.155 152); --success-bg: oklch(0.960 0.030 152); --success-fg: oklch(0.36 0.15 152);
  --warning: oklch(0.745 0.150 70); --warning-bg: oklch(0.970 0.035 80); --warning-fg: oklch(0.40 0.15 70);
  --info: oklch(0.580 0.155 245); --info-bg: oklch(0.965 0.025 245); --info-fg: oklch(0.40 0.155 245);
  --purple: oklch(0.55 0.18 285); --purple-bg: oklch(0.95 0.025 285); --purple-fg: oklch(0.4 0.16 285);
  /* LTO entity coding (from W17) */
  --lto-akter: oklch(0.45 0.18 25);    --lto-akter-bg: oklch(0.97 0.025 25);
  --lto-fenomen: oklch(0.42 0.16 70);  --lto-fenomen-bg: oklch(0.97 0.04 80);
  --lto-lokacija: oklch(0.4 0.13 152); --lto-lokacija-bg: oklch(0.95 0.025 152);
  --lto-tema: oklch(0.42 0.15 245);    --lto-tema-bg: oklch(0.96 0.025 245);
  --lto-grupa: oklch(0.45 0.16 285);   --lto-grupa-bg: oklch(0.96 0.025 285);
  /* cluster */
  --k1: oklch(0.59 0.215 25); --k2: oklch(0.55 0.18 285); --k3: oklch(0.62 0.155 245); --k4: oklch(0.7 0.15 70);
  --font: "Geist", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { background: var(--paper); height: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink-900); -webkit-font-smoothing: antialiased; overflow: hidden; }

/* ── App shell ── */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }
.main { background: var(--paper); display: flex; flex-direction: column; min-width: 0; }

/* ── Topbar + role switcher ── */
.topbar { height: 56px; border-bottom: 1px solid var(--ink-200); background: white; display: flex; align-items: center; padding: 0 22px; gap: 14px; flex-shrink: 0; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-500); min-width: 0; }
.breadcrumb .current { color: var(--ink-900); font-weight: 500; }
.breadcrumb .sep { color: var(--ink-300); padding: 0 2px; }
.top-spacer { flex: 1; }
.top-icon-btn { width: 32px; height: 32px; border-radius: 8px; background: var(--ink-75); border: 1px solid var(--ink-200); display: grid; place-items: center; color: var(--ink-700); cursor: pointer; flex-shrink: 0; }
.top-icon-btn svg { width: 15px; height: 15px; }
.top-icon-btn .ind { position: absolute; }

.role-switch { display: inline-flex; align-items: center; gap: 0; padding: 3px; background: var(--ink-100); border-radius: 9px; }
.role-switch .rs-label { font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-400); font-weight: 600; padding: 0 8px 0 6px; }
.role-switch button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; background: transparent; border: 0; cursor: pointer; font-family: inherit; font-size: 12.5px; font-weight: 500; color: var(--ink-600); border-radius: 6px; }
.role-switch button svg { width: 13px; height: 13px; }
.role-switch button.on { background: white; color: var(--ink-950); box-shadow: 0 1px 2px oklch(0 0 0 / 0.06); }
.role-switch button.on.r-posmatrac { color: var(--success-fg); }
.role-switch button.on.r-analiticar { color: var(--info-fg); }
.role-switch button.on.r-supervizor { color: var(--purple-fg); }
.role-switch button.on.r-pravnik { color: var(--red-700); }

.top-user { display: flex; align-items: center; gap: 8px; padding: 0 2px; flex-shrink: 0; }
.top-user .av { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.top-user .av.r-posmatrac { background: var(--success-bg); color: var(--success-fg); }
.top-user .av.r-analiticar { background: var(--info-bg); color: var(--info-fg); }
.top-user .av.r-supervizor { background: var(--purple-bg); color: var(--purple-fg); }
.top-user .av.r-pravnik { background: var(--red-bg); color: var(--red-700); }
.top-user .who { font-size: 12px; line-height: 1.2; }
.top-user .who strong { display: block; color: var(--ink-900); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.top-user .who span { color: var(--ink-500); font-size: 10px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.03em; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 7px; border: 0; background: transparent; font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn svg { width: 13px; height: 13px; }
.btn-secondary { background: white; color: var(--ink-800); box-shadow: inset 0 0 0 1px var(--ink-200); }
.btn-secondary:hover { background: var(--ink-75); }
.btn-primary { background: var(--ink-950); color: white; }
.btn-primary:hover { background: var(--ink-800); }
.btn-success { background: var(--success); color: white; }
.btn-warn { background: var(--warning); color: var(--ink-950); }
.btn-danger { background: var(--red); color: white; }
.btn-purple { background: var(--purple); color: white; }
.btn-ghost { color: var(--ink-700); }
.btn-ghost:hover { background: var(--ink-100); }
.btn-sm { height: 27px; padding: 0 9px; font-size: 11.5px; border-radius: 6px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.icon-btn { width: 28px; height: 28px; border-radius: 6px; background: transparent; border: 0; color: var(--ink-500); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--ink-100); color: var(--ink-900); }
.icon-btn svg { width: 13px; height: 13px; }
.icon-btn.success { color: var(--success-fg); } .icon-btn.success:hover { background: var(--success-bg); }
.icon-btn.danger { color: var(--red); } .icon-btn.danger:hover { background: var(--red-bg); }

/* ── LTO entity chips ── */
.lto-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1.5px 7px; border-radius: 4px; font-size: 10.5px; font-weight: 700; font-family: var(--mono); letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap; }
.lto-chip svg { width: 9px; height: 9px; flex-shrink: 0; }
.lto-chip.akter    { background: var(--lto-akter-bg);    color: var(--lto-akter); }
.lto-chip.fenomen  { background: var(--lto-fenomen-bg);  color: var(--lto-fenomen); }
.lto-chip.lokacija { background: var(--lto-lokacija-bg); color: var(--lto-lokacija); }
.lto-chip.tema     { background: var(--lto-tema-bg);     color: var(--lto-tema); }
.lto-chip.grupa    { background: var(--lto-grupa-bg);    color: var(--lto-grupa); }
.lto-chip.solid.akter    { background: var(--lto-akter);    color: white; }
.lto-chip.solid.fenomen  { background: var(--lto-fenomen);  color: white; }
.lto-chip.solid.lokacija { background: var(--lto-lokacija); color: white; }
.lto-chip.solid.tema     { background: var(--lto-tema);     color: white; }
.lto-chip.solid.grupa    { background: var(--lto-grupa);    color: white; }

/* ── Status pills (entry workflow) ── */
.status-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 4px; font-size: 10px; font-weight: 700; font-family: var(--mono); letter-spacing: 0.04em; text-transform: uppercase; }
.status-pill.new { background: var(--ink-100); color: var(--ink-700); }
.status-pill.review { background: var(--info-bg); color: var(--info-fg); }
.status-pill.published { background: var(--success-bg); color: var(--success-fg); }
.status-pill.returned { background: var(--warning-bg); color: var(--warning-fg); }
.status-pill.regular { background: var(--ink-100); color: var(--ink-600); }

/* ── Lifecycle (case) ── */
.lifecycle { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 5px; font-size: 10.5px; font-weight: 700; font-family: var(--mono); letter-spacing: 0.04em; text-transform: uppercase; }
.lifecycle .dot { width: 6px; height: 6px; border-radius: 50%; }
.lc-ongoing { background: var(--warning-bg); color: var(--warning-fg); } .lc-ongoing .dot { background: var(--warning); }
.lc-escalated { background: var(--red-bg); color: var(--red-700); } .lc-escalated .dot { background: var(--red); animation: lto-pulse 1.5s ease-in-out infinite; }
.lc-done { background: var(--success-bg); color: var(--success-fg); } .lc-done .dot { background: var(--success); }
@keyframes lto-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Cluster chip ── */
.k-chip { display: inline-flex; align-items: center; font-family: var(--mono); font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 4px; letter-spacing: 0.04em; text-transform: uppercase; color: white; }
.k-chip.k1 { background: var(--k1); } .k-chip.k2 { background: var(--k2); } .k-chip.k3 { background: var(--k3); } .k-chip.k4 { background: var(--k4); color: var(--ink-950); }

/* ── Intensity dots (analytic output) ── */
.intensity { display: inline-flex; gap: 2px; align-items: center; }
.intensity .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-200); }
.intensity .dot.on { background: var(--red); }
.intensity-l { font-family: var(--mono); font-size: 10.5px; color: var(--ink-600); margin-left: 4px; font-weight: 600; }

/* ── Generic section card ── */
.sec { background: white; border: 1px solid var(--ink-200); border-radius: 12px; padding: 18px 20px; }
.sec-h { font-family: var(--mono); font-size: 10.5px; color: var(--ink-400); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.sec-h .iconbox { width: 22px; height: 22px; border-radius: 6px; background: var(--ink-100); color: var(--ink-700); display: grid; place-items: center; }
.sec-h .iconbox svg { width: 12px; height: 12px; }
.sec-h .end { margin-left: auto; color: var(--ink-500); text-transform: none; letter-spacing: 0; font-family: var(--font); font-weight: 500; font-size: 12px; }

/* ── AI summary / brief card ── */
.ai-summary { background: linear-gradient(135deg, var(--purple-bg) 0%, oklch(0.97 0.025 245) 100%); border: 1px solid oklch(0.88 0.05 285); border-radius: 14px; padding: 18px 20px; }
.ai-summary .ai-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-family: var(--mono); font-size: 10.5px; color: var(--purple-fg); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; flex-wrap: wrap; }
.ai-summary .ai-meta .strong { color: var(--ink-900); }
.ai-summary .head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.ai-summary .head .ic { width: 30px; height: 30px; border-radius: 8px; background: var(--purple); color: white; display: grid; place-items: center; flex-shrink: 0; }
.ai-summary .head .ic svg { width: 14px; height: 14px; }
.ai-summary .head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--purple-fg); }
.ai-summary .head .target { font-family: var(--mono); font-size: 11px; color: var(--ink-700); padding: 2px 8px; background: white; border-radius: 5px; font-weight: 600; }
.ai-summary .head .actions { margin-left: auto; display: flex; gap: 6px; }
.ai-summary .body { font-size: 14px; color: var(--ink-800); line-height: 1.65; background: white; padding: 14px 16px; border-radius: 10px; border-left: 3px solid var(--purple); }
.ai-summary .body strong { color: var(--ink-950); font-weight: 600; }
.ai-summary .body em { font-style: normal; background: var(--purple-bg); padding: 0 4px; border-radius: 3px; color: var(--purple-fg); font-weight: 500; }
.ai-source-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 7px; background: white; border: 1px solid oklch(0.88 0.05 285); border-radius: 5px; font-family: var(--mono); font-size: 10.5px; color: var(--purple-fg); font-weight: 600; }
.ai-source-chip svg { width: 10px; height: 10px; }
.ai-sources { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ── Filter strip ── */
.filter-strip { background: white; border-bottom: 1px solid var(--ink-200); padding: 10px 22px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex-shrink: 0; }
.filter-search { display: flex; align-items: center; gap: 8px; background: var(--ink-75); border: 1px solid var(--ink-200); padding: 0 12px; height: 30px; border-radius: 7px; min-width: 240px; flex: 1; max-width: 380px; }
.filter-search svg { width: 13px; height: 13px; color: var(--ink-400); }
.filter-search input { border: 0; outline: 0; background: transparent; flex: 1; font: inherit; font-size: 12.5px; }
.ftab { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; background: white; border: 1px solid var(--ink-200); border-radius: 6px; font-size: 12px; color: var(--ink-700); cursor: pointer; font-weight: 500; }
.ftab svg { width: 11px; height: 11px; }
.ftab.on { background: var(--ink-950); color: white; border-color: var(--ink-950); }
.ftab .v { font-family: var(--mono); font-size: 10px; padding: 1px 5px; background: var(--ink-100); color: var(--ink-700); border-radius: 3px; }
.ftab.on .v { background: oklch(1 0 0 / 0.15); color: white; }

/* ── Avatars ── */
.av-mini { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.av-1 { background: oklch(0.93 0.05 245); color: oklch(0.4 0.13 245); }
.av-2 { background: oklch(0.93 0.05 152); color: oklch(0.4 0.13 152); }
.av-3 { background: oklch(0.93 0.05 25);  color: oklch(0.42 0.16 25); }
.av-4 { background: oklch(0.93 0.05 285); color: oklch(0.4 0.13 285); }
.av-5 { background: oklch(0.93 0.05 80);  color: oklch(0.4 0.13 80); }
.av-6 { background: oklch(0.93 0.05 195); color: oklch(0.4 0.13 195); }
.av-7 { background: oklch(0.93 0.05 50);  color: oklch(0.4 0.13 50); }

/* ── RBAC gate (when role lacks access) ── */
.gate { flex: 1; display: grid; place-items: center; padding: 60px 24px; }
.gate-card { max-width: 440px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gate-card .ic { width: 52px; height: 52px; border-radius: 14px; background: var(--ink-100); color: var(--ink-500); display: grid; place-items: center; }
.gate-card .ic svg { width: 22px; height: 22px; }
.gate-card h2 { margin: 0; font-size: 19px; font-weight: 600; color: var(--ink-900); letter-spacing: -0.01em; }
.gate-card p { margin: 0; font-size: 13.5px; color: var(--ink-600); line-height: 1.6; }
.gate-card .roles-need { display: flex; gap: 6px; margin-top: 4px; }

/* ── Role-context banner (region/theme scoping) ── */
.scope-bar { padding: 8px 22px; display: flex; align-items: center; gap: 10px; font-size: 12.5px; flex-shrink: 0; border-bottom: 1px solid transparent; }
.scope-bar svg { width: 14px; height: 14px; flex-shrink: 0; }
.scope-bar.analiticar { background: var(--info-bg); color: var(--info-fg); border-bottom-color: oklch(0.88 0.07 245); }
.scope-bar.supervizor { background: var(--purple-bg); color: var(--purple-fg); border-bottom-color: oklch(0.88 0.05 285); }
.scope-bar.posmatrac { background: var(--success-bg); color: var(--success-fg); border-bottom-color: oklch(0.88 0.07 152); }
.scope-bar.pravnik { background: var(--red-bg); color: var(--red-700); border-bottom-color: oklch(0.85 0.07 25); }
.scope-bar strong { font-weight: 600; }
.scope-bar .end { margin-left: auto; font-family: var(--mono); font-size: 11px; opacity: 0.85; }

/* ── Scrollbar safety helpers ── */
.app, .main { min-height: 0; min-width: 0; }
.main > * { min-width: 0; }

/* ── Seen / read-unread indicator ── */
.seen-mark { width: 20px; height: 18px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; flex-shrink: 0; }
.seen-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--info); box-shadow: 0 0 0 3px var(--info-bg); }
.seen-mark.read .seen-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-300); width: 7px; height: 7px; }
.seen-mark.read:hover .seen-dot { box-shadow: inset 0 0 0 1.5px var(--ink-500); }
.seen-upd { font-family: var(--mono); font-size: 8px; font-weight: 700; color: var(--warning-fg); background: var(--warning-bg); padding: 1.5px 4px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.03em; box-shadow: 0 0 0 2px oklch(0.97 0.035 80); }
.row-unread { position: relative; }
.row-unread::after { content: ''; }

/* ── Legal (pravni) sub-status pill ── */
.legal-status { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 4px; font-size: 9.5px; font-weight: 700; font-family: var(--mono); letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap;ansform: uppercase; }
.legal-status svg { width: 9px; height: 9px; }
.legal-status.ls-wait   { background: var(--warning-bg); color: var(--warning-fg); }
.legal-status.ls-ok     { background: var(--info-bg); color: var(--info-fg); }
.legal-status.ls-rej    { background: var(--ink-100); color: var(--ink-600); }
.legal-status.ls-decline{ background: var(--ink-100); color: var(--ink-600); }
.legal-status.ls-active { background: oklch(0.95 0.04 25); color: var(--red-700); }
.legal-status.ls-done   { background: var(--success-bg); color: var(--success-fg); }
.legal-status.ls-no     { background: var(--red-bg); color: var(--red-700); }
.legal-status.ls-dismiss{ background: var(--purple-bg); color: var(--purple-fg); }

/* dual status wrapper */
.dual-status { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dual-status .arrow { color: var(--ink-300); display: flex; }
.dual-status .arrow svg { width: 11px; height: 11px; }
