/* ============================================================================
 * x.ERP UI Design Tokens & Primitives — v3.5 (2026-04-20)
 * Izvor istine: source/xerp/tokens.css + izmjene iz arhitektonske revizije v3.5
 *
 * Pravila (vidi 01-DESIGN-SYSTEM.md):
 *   1. Boje isključivo preko var(--*) — nikad hardkodirani hex u komponentama.
 *   2. Svi iznosi (KM), JIB/PDV, IBAN, konta, datumi nose klasu .num (IBM Plex Mono, tabular-nums).
 *   3. Navy #00203F nikad nije pozadina u Light temi — samo akcent i tekst.
 *   4. #FC6735 (Safety Orange) nosi samo 1 primarni CTA po ekranu + fokus prsten + aktivna kartica.
 *   5. Nema tirkizne palete (#017E84, #714B67, #00A09D su zabranjeni).
 *   6. Nema emoji znakova — samo linijski SVG (16×16, 1.6px) i 3D izometrijske pločice (64×64).
 * ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root,
:root[data-theme="light"],
.x {
  /* --- Površine (Light = 92% Warm Alabaster) ----------------------------- */
  --bg:     #F6F5F1;   /* Warm Alabaster — podloga cijele aplikacije */
  --surf:   #FFFFFF;   /* Čista bijela — kartica, tabela, forma, modal */
  --elev:   #EFECE6;   /* Warm Stone — zaglavlje tabele, chip, sekundarno dugme */
  --hover:  #F3F0EA;   /* Red tabele pod kursorom */
  --sel:    #FFF3EC;   /* Selektovani red / aktivna stavka (Safety Orange 8% tint) */

  /* --- Tekst (4 nivoa hijerarhije) -------------------------------------- */
  --ink:    #0F172A;   /* Primarni tekst — naslovi, nazivi firmi, iznosi */
  --main:   #1E293B;   /* Tijelo teksta — opisi, ćelije tabele */
  --muted:  #526077;   /* Sekundarni tekst — labele polja, podnaslovi (WCAG AA 5.9:1) */
  --mono:   #7A8699;   /* Meta / tehničke oznake — skraćenice, kbd, neaktivni čipovi */

  /* --- Linije (1px, nikad 2px osim fokusa i aktivnog taba) -------------- */
  --line:   #E6E2DA;   /* Standardna ivica kartice, reda i polja */
  --line2:  #D5CFC3;   /* Naglašena ivica (hover, aktivni input prije fokusa) */

  /* --- Akcent i brend (8% akcent budžeta) ------------------------------- */
  --acc:    #FC6735;   /* Safety Orange — JEDINI primarni CTA na ekranu */
  --acch:   #E55525;   /* Safety Orange hover */
  --accbg:  rgba(252, 103, 53, 0.10); /* Blagi tint za aktivnu karticu / fokus */
  --onAcc:  #00203F;   /* Tamni navy tekst NA narandžastoj podlozi (WCAG AA 5.58:1) */
  --navy:   #00203F;   /* Deep Navy — korporativni identitet (tekst/ikona u Light) */
  --icon:   #6E6A63;   /* Neutralna boja linijskih SVG ikona (16×16) */

  /* --- Semantički statusi (WCAG AA 4.5:1 na svojim *bg podlogama) ------- */
  --ok:     #16A34A;
  --okbg:   #DCFCE7;
  --oktx:   #15803D;

  --warn:   #D97706;
  --warnbg: #FEF3C7;
  --warntx: #B45309;

  --err:    #DC2626;
  --errbg:  #FEE2E2;
  --errtx:  #B91C1C;

  --info:   #0284C7;
  --infobg: #E0F2FE;
  --infotx: #0369A1;

  /* --- Tipografija ------------------------------------------------------ */
  --f-ui:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --f-disp: 'Plus Jakarta Sans', 'Inter', sans-serif;
  --f-mono: 'IBM Plex Mono', 'JetBrains Mono', Consolas, monospace;

  /* --- Dimenzije i radijusi -------------------------------------------- */
  --r-xs:   4px;
  --r-sm:   6px;
  --r-md:   8px;
  --r-lg:   10px;
  --r-xl:   12px;

  --h-nav:  46px;
  --h-cp:   56px;
  --h-sbar: 26px;
  --h-row:  34px;      /* Kompaktna gustina tabele (32–36px) */
  --h-btn:  30px;
  --h-inp:  32px;
  --w-rail-collapsed: 48px;
  --w-rail-expanded:  220px;
  --w-slideover:      480px;
  --w-palette:        620px;

  /* --- Sjene (minimalne — oslanjamo se na 1px --line ivice) ------------- */
  --sh-pop: 0 12px 32px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);
  --sh-so:  -12px 0 32px rgba(15, 23, 42, 0.10);
  --sh-pal: 0 24px 60px rgba(15, 23, 42, 0.22);
}

/* ============================================================================
 * DARK TEMA — Deep Navy Slate (aktivira se sa [data-theme="dark"] ili .x.dark)
 * ============================================================================ */
:root[data-theme="dark"],
.x.dark {
  --bg:     #091423;
  --surf:   #0F2138;
  --elev:   #152B47;
  --hover:  #1B3556;
  --sel:    #26231F;

  --ink:    #F4F6FA;
  --main:   #CBD5E1;
  --muted:  #94A3B8;
  --mono:   #7889A4;

  --line:   #1F3654;
  --line2:  #2C4A70;

  --acc:    #FC6735;
  --acch:   #FF7B4D;
  --accbg:  rgba(252, 103, 53, 0.16);
  --onAcc:  #00203F;
  --navy:   #F4F6FA;
  --icon:   #94A3B8;

  --ok:     #22C55E;
  --okbg:   rgba(34, 197, 94, 0.15);
  --oktx:   #6EE7A0;

  --warn:   #F59E0B;
  --warnbg: rgba(245, 158, 11, 0.16);
  --warntx: #FCD34D;

  --err:    #EF4444;
  --errbg:  rgba(239, 68, 68, 0.16);
  --errtx:  #FF8C8C;

  --info:   #38BDF8;
  --infobg: rgba(56, 189, 248, 0.16);
  --infotx: #7DD3FC;

  --sh-pop: 0 14px 36px rgba(0, 0, 0, 0.45);
  --sh-so:  -12px 0 32px rgba(0, 0, 0, 0.45);
  --sh-pal: 0 24px 60px rgba(0, 0, 0, 0.60);
}

/* ============================================================================
 * OSNOVNI RESET I TIPOGRAFSKE KLASE
 * ============================================================================ */
.x,
[data-theme] body {
  font-family: var(--f-ui);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
}

.x *,
.x *::before,
.x *::after {
  box-sizing: border-box;
}

/* OBAVEZNO za sve brojeve, KM iznose, procente, JIB/PDV, IBAN, konta, datume */
.num,
.mono {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
}

.num-r {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* Skraćivanje teksta u jednoj liniji (koristiti uz min-width: 0 u grid/flex) */
.trunc {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================================
 * PRIMITIVI — Kartice, Dugmad, Polja, Bedževi, Tabele, Statusni Chevron
 * ============================================================================ */

/* --- Kartica (.card) ---------------------------------------------------- */
.card {
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  min-width: 0;
}
.card.pad { padding: 14px 16px; }
.card-h {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: 12.5px;
  color: var(--ink);
  min-width: 0;
}
.card-h .sub {
  font-weight: 500;
  font-size: 11px;
  color: var(--mono);
  font-family: var(--f-mono);
}

/* --- KPI Kartica (.kpi) ------------------------------------------------- */
.kpi {
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  min-width: 0;
}
.kpi .l {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.kpi .v {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 4px;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kpi .d {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --- Dugmad (.btn) — Pravilo: max 1 .btn.p po ekranu! ------------------- */
.btn {
  height: var(--h-btn);
  padding: 0 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surf);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover:not(:disabled) {
  background: var(--elev);
  border-color: var(--line2);
}
.btn:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 1px;
}
.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
/* Primarni CTA — Safety Orange #FC6735 (SAMO 1 po ekranu!) */
.btn.p {
  background: var(--acc);
  border-color: var(--acc);
  color: #FFFFFF;
}
.btn.p:hover:not(:disabled) {
  background: var(--acch);
  border-color: var(--acch);
}
/* Opasna radnja (Storniraj / Obriši) — nikad puna crvena dok nije u dijalogu potvrde */
.btn.err {
  color: var(--errtx);
  border-color: rgba(220, 38, 38, 0.35);
  background: var(--surf);
}
.btn.err:hover:not(:disabled) {
  background: var(--errbg);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover:not(:disabled) {
  background: var(--elev);
}
.btn.sm {
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
}
.btn .k {
  font-family: var(--f-mono);
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.12);
  color: inherit;
}

/* --- Tastaturne prečice (kbd / .kbd) ------------------------------------ */
kbd,
.kbd {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--mono);
  white-space: nowrap;
  display: inline-block;
  line-height: 1.3;
}

/* --- Identitet firme u zaglavlju (.ident) ------------------------------- */
.ident,
.nav .ident,
.nav .ident b,
.nav .ident span {
  white-space: nowrap;
}

/* --- Polja forme (.inp, select.sel, .fl) --------------------------------
 * NAPOMENA v3.5: Klasa za <select> je specifično `select.sel` ili `.inp`,
 * kako se NE BI sudarala sa `.rw.sel` (selektovani red u tabeli).
 * ------------------------------------------------------------------------ */
.fl {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.fl > label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.inp,
select.sel {
  height: var(--h-inp);
  padding: 0 9px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surf);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 12.5px;
  width: 100%;
  min-width: 0;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.inp.num,
.inp.mono {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
}
.inp:hover,
select.sel:hover {
  border-color: var(--line2);
}
.inp:focus,
select.sel:focus {
  border-color: var(--acc);
  box-shadow: 0 0 0 2px var(--accbg);
}
.inp[readonly],
.inp:disabled {
  background: var(--elev);
  color: var(--muted);
}
.inp.invalid {
  border-color: var(--err);
  background: var(--errbg);
}
textarea.inp {
  height: auto;
  min-height: 68px;
  padding: 7px 9px;
  resize: vertical;
}

/* --- Semantički bedževi (.b) ------------------------------------------- */
.b {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-xs);
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: var(--elev);
  color: var(--main);
}
.b::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.b.ok   { background: var(--okbg);   color: var(--oktx); }
.b.warn { background: var(--warnbg); color: var(--warntx); }
.b.err  { background: var(--errbg);  color: var(--errtx); }
.b.info { background: var(--infobg); color: var(--infotx); }
.b.acc  { background: var(--accbg);  color: var(--acc); }
.b.dotless::before { display: none; }

/* --- Statusni Chevron tok (.stflow / .st) -------------------------------
 * Tok životnog ciklusa dokumenta: NACRT -> VERIFIKOVANO -> PROKNJIŽENO -> ZAKLJUČANO
 * Aktivni korak (.st.on ili .st.cur) koristi --onAcc (#00203F) na --acc (#FC6735) -> 5.58:1 AA.
 * ------------------------------------------------------------------------ */
.stflow {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--elev);
}
.st {
  padding: 4px 10px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--muted);
  border-right: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.st:last-child { border-right: 0; }
.st.done {
  background: var(--surf);
  color: var(--oktx);
}
.st.on,
.st.cur,
.st[aria-current="step"] {
  background: var(--acc);
  color: var(--onAcc);
}

/* --- Matematička brava u fening (.lockbar) ------------------------------ */
.lockbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-family: var(--f-mono);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--elev);
}
.lockbar.ok {
  background: var(--okbg);
  color: var(--oktx);
  border-color: rgba(22, 163, 74, 0.30);
}
.lockbar.err {
  background: var(--errbg);
  color: var(--errtx);
  border-color: rgba(220, 38, 38, 0.35);
}

/* --- Tabele: .tbl (HTML <table>) i .th/.rw (CSS Grid redovi) ----------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.tbl thead th {
  height: 30px;
  padding: 0 10px;
  background: var(--elev);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.tbl thead th.r,
.tbl tbody td.r,
.tbl tfoot td.r {
  text-align: right;
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tbl tbody tr {
  height: var(--h-row);
  border-bottom: 1px solid var(--line);
  background: var(--surf);
  cursor: pointer;
}
.tbl tbody tr:nth-child(even) {
  background: rgba(239, 236, 230, 0.32);
}
:root[data-theme="dark"] .tbl tbody tr:nth-child(even),
.x.dark .tbl tbody tr:nth-child(even) {
  background: rgba(21, 43, 71, 0.35);
}
.tbl tbody tr:hover {
  background: var(--hover);
}
.tbl tbody tr.sel {
  background: var(--sel) !important;
  box-shadow: inset 3px 0 0 var(--acc);
}
.tbl tbody td {
  padding: 0 10px;
  color: var(--ink);
  vertical-align: middle;
}
.tbl tfoot td {
  height: 32px;
  padding: 0 10px;
  background: var(--elev);
  font-family: var(--f-mono);
  font-weight: 700;
  border-top: 2px solid var(--line2);
}

/* Grid-redovi (.th zaglavlje + .rw red) za guste tabele i split-screen */
.th,
.rw {
  display: grid;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-width: 0;
}
.th {
  height: 30px;
  background: var(--elev);
  border-bottom: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.rw {
  min-height: var(--h-row);
  padding-top: 5px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
  background: var(--surf);
  font-size: 12.5px;
  cursor: pointer;
}
.rw:nth-child(even) {
  background: rgba(239, 236, 230, 0.32);
}
:root[data-theme="dark"] .rw:nth-child(even),
.x.dark .rw:nth-child(even) {
  background: rgba(21, 43, 71, 0.35);
}
.rw:hover {
  background: var(--hover);
}
.rw.sel,
.rw.sel:nth-child(n) {
  background: var(--sel);
  box-shadow: inset 3px 0 0 var(--acc);
}
.rw.tot {
  background: var(--elev);
  font-family: var(--f-mono);
  font-weight: 700;
  border-top: 2px solid var(--line2);
  cursor: default;
}
.th .r,
.rw .r {
  text-align: right;
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- Sekcije i tabovi unutar ekrana ------------------------------------ */
.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  padding: 0 4px;
  overflow-x: auto;
}
.tab {
  height: 34px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--f-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.on {
  color: var(--ink);
  border-bottom-color: var(--acc);
}
.tab .cnt {
  font-family: var(--f-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: var(--r-xs);
  background: var(--elev);
  color: var(--mono);
}
.tab.on .cnt {
  background: var(--accbg);
  color: var(--acc);
}

/* ============================================================================
 * 3D IZOMETRIJSKE IKONE (64×64 viewBox) — klase slojeva za X.tileSvg()
 * ============================================================================ */
.x-tile {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 22%;
}
.t-n      { display: none; }
.t-shadow { fill: rgba(15, 23, 42, 0.14); }
:root[data-theme="dark"] .t-shadow,
.x.dark .t-shadow { fill: rgba(0, 0, 0, 0.38); }

/* 3 tona Safety Orange za 3D tijelo */
.t-top    { fill: #FF8B5E; }
.t-front  { fill: #FC6735; }
.t-side   { fill: #D94B1E; }
.t-hi     { fill: none; stroke: #FFB294; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }

/* 3 tona Warm Paper za dokumente/ekrane na ikoni */
.t-ptop   { fill: #FFFFFF; }
.t-pfront { fill: #F4EFE6; }
.t-pside  { fill: #DFD8CB; }

/* Tamni detalji i linije */
.t-ink    { fill: #0F172A; }
.t-line   { fill: none; stroke: #0F172A; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.78; }
.t-lineF  { fill: none; stroke: #FC6735; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ============================================================================
 * SHELL LAYOUT (.shell, .nav, .rail, .cp, .main, .sbar, .bnav, .pal, .so)
 * ============================================================================ */
.shell {
  display: grid;
  grid-template-rows: var(--h-nav) var(--h-cp) 1fr var(--h-sbar);
  grid-template-columns: var(--w-rail-collapsed) 1fr;
  grid-template-areas:
    "nav  nav"
    "rail cp"
    "rail main"
    "sbar sbar";
  min-height: 100vh;
}
.shell.rail-open {
  grid-template-columns: var(--w-rail-expanded) 1fr;
}

/* 1. GORNJI SYSTRAY (46px) */
.nav {
  grid-area: nav;
  background: var(--surf);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  z-index: 40;
  min-width: 0;
}
.nav .dots {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--elev);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
}
.nav .dots:hover {
  border-color: var(--acc);
  color: var(--acc);
}
.nav .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--f-disp);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
  padding-right: 10px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
  flex-shrink: 0;
}
.nav .brand .tile {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}
.nav .menu {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.nav .menu a {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.nav .menu a:hover {
  color: var(--ink);
  background: var(--elev);
}
.nav .menu a.on {
  color: var(--ink);
  font-weight: 600;
  background: var(--elev);
}
.nav .sp {
  flex: 1;
  min-width: 4px;
}

/* Identitet aktivne firme (1 instalacija = 1 firma; NEMA multi-tenant switchera) */
.nav .ident {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--elev);
  font-size: 11.5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav .ident .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}
.nav .ident b {
  font-weight: 700;
  color: var(--ink);
}
.nav .ident .jib {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--muted);
}

/* Poslovna jedinica — prikazuje se samo kad firma ima >1 PJ */
.nav .pj {
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surf);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.nav .find {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav .find:hover {
  border-color: var(--line2);
  color: var(--ink);
}
.nav .ib {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surf);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--icon);
  flex-shrink: 0;
}
.nav .ib:hover {
  color: var(--ink);
  background: var(--elev);
}
.nav .ib .cnt {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--acc);
  color: #FFFFFF;
  font-family: var(--f-mono);
  font-size: 9.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.nav .av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
:root[data-theme="dark"] .nav .av,
.x.dark .nav .av {
  background: var(--acc);
  color: var(--onAcc);
}

/* 2. LIJEVA ŠINA (.rail 48px / 220px) */
.rail {
  grid-area: rail;
  background: var(--surf);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 8px 6px;
  gap: 2px;
  z-index: 30;
  overflow-y: auto;
  overflow-x: hidden;
}
.rail .ri {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 5px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--main);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}
.rail .ri:hover {
  background: var(--elev);
  color: var(--ink);
}
.rail .ri.on {
  background: var(--sel);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--acc);
}
.rail .ri .rt {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
}
.rail .ri .rl {
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.12s;
}
.shell.rail-open .rail .ri .rl {
  opacity: 1;
}
.rail .sep {
  height: 1px;
  background: var(--line);
  margin: 6px 4px;
}
.rail .sp {
  flex: 1;
}

/* 3. UNIVERZALNI CONTROL PANEL (.cp 56px) */
.cp {
  grid-area: cp;
  background: var(--surf);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 25;
  min-width: 0;
}
.cp .crumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
}
.cp .crumb .p {
  color: var(--muted);
}
.cp .crumb .c {
  font-family: var(--f-disp);
  font-weight: 700;
  color: var(--ink);
}
.cp .srch {
  flex: 1;
  max-width: 520px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  position: relative;
  min-width: 0;
}
.cp .srch:focus-within {
  border-color: var(--acc);
  background: var(--surf);
}
.cp .fct {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--elev);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}
.cp .fct b {
  color: var(--muted);
  font-weight: 500;
}
.cp .fct i {
  font-style: normal;
  color: var(--muted);
  cursor: pointer;
  margin-left: 2px;
}
.cp .srch input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  outline: none;
  min-width: 60px;
}
.cp .dd {
  position: absolute;
  top: 36px;
  left: 0;
  right: 0;
  background: var(--surf);
  border: 1px solid var(--line2);
  border-radius: 10px;
  box-shadow: var(--sh-pop);
  padding: 12px;
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  z-index: 50;
}
.cp .srch.open .dd {
  display: grid;
}
.cp .dd h5 {
  margin: 0 0 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.cp .dd a {
  display: flex;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--main);
  cursor: pointer;
  text-decoration: none;
}
.cp .dd a:hover {
  background: var(--elev);
  color: var(--ink);
}
.cp .dd a.on {
  color: var(--acc);
  font-weight: 600;
}
.cp .pager {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.cp .vsw {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--elev);
  flex-shrink: 0;
}
.cp .vsw button,
.cp .vs {
  width: 28px;
  height: 26px;
  border: 0;
  background: transparent;
  color: var(--icon);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.cp .vsw button:hover,
.cp .vs:hover {
  color: var(--ink);
}
.cp .vsw button.on,
.cp .vs.on {
  background: var(--surf);
  color: var(--acc);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* 4. RADNI PROSTOR (.main) */
.main {
  grid-area: main;
  padding: 14px 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* 5. DONJI STATUS BAR (.sbar 26px) */
.sbar {
  grid-area: sbar;
  background: var(--surf);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 14px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
}
.sbar .ok {
  color: var(--oktx);
}
.sbar .sp {
  flex: 1;
}

/* 6. COMMAND PALETTE (Ctrl+K, 620px) */
.pal-bg {
  position: fixed;
  inset: 0;
  background: rgba(9, 20, 35, 0.48);
  backdrop-filter: blur(2px);
  display: none;
  place-items: start center;
  padding-top: 11vh;
  z-index: 90;
}
.pal-bg.open {
  display: grid;
}
.pal {
  width: min(var(--w-palette), 92vw);
  background: var(--surf);
  border: 1px solid var(--line2);
  border-radius: 12px;
  box-shadow: var(--sh-pal);
  overflow: hidden;
}
.pal .ph {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.pal .ph input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  outline: none;
}
.pal .pl {
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
}
.pal .pg {
  padding: 6px 8px 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--mono);
}
.pal .pi {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink);
  text-decoration: none;
}
.pal .pi:hover,
.pal .pi.on {
  background: var(--sel);
}
.pal .pi .pt {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}
.pal .pi .pm {
  margin-left: auto;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--muted);
}
.pal .pf {
  display: flex;
  justify-content: space-between;
  padding: 7px 12px;
  background: var(--elev);
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

/* 7. SLIDE-OVER DRAWER (.so 480px) */
.so {
  position: fixed;
  top: var(--h-nav);
  right: 0;
  bottom: var(--h-sbar);
  width: min(var(--w-slideover), 92vw);
  background: var(--surf);
  border-left: 1px solid var(--line2);
  box-shadow: var(--sh-so);
  transform: translateX(102%);
  transition: transform 0.18s ease;
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.so.open {
  transform: translateX(0);
}
.so .sh {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.so .sb {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.so .sf {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: var(--elev);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* 8. TOAST NOTIFIKACIJE */
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 38px;
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line2);
  background: var(--surf);
  color: var(--ink);
  box-shadow: var(--sh-pop);
  font-size: 12.5px;
  font-weight: 500;
}
.toast.ok   { border-left: 4px solid var(--ok); }
.toast.warn { border-left: 4px solid var(--warn); }
.toast.err  { border-left: 4px solid var(--err); }

/* ============================================================================
 * RESPONSIVE GRID KLASE — Desktop / Tablet (<=1100px) / Mobilni (<=760px)
 * Sve grid ćelije imaju min-width: 0 da spriječe horizontalno prelivanje.
 * ============================================================================ */
.rg2,
.rg3,
.rg4,
.split {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.rg2 > *,
.rg3 > *,
.rg4 > *,
.split > * {
  min-width: 0;
}
.rg2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rg3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rg4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { grid-template-columns: minmax(320px, 46%) minmax(0, 1fr); }

/* Mobilni bottom-bar (.bnav) — skriven na desktopu */
.bnav { display: none; }

@media (max-width: 1100px) {
  .rg4   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rg3   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .hide-md { display: none !important; }
}

@media (max-width: 760px) {
  .shell,
  .shell.rail-open {
    grid-template-rows: var(--h-nav) auto 1fr 54px;
    grid-template-columns: 1fr;
    grid-template-areas:
      "nav"
      "cp"
      "main"
      "bnav";
  }
  .rail,
  .sbar {
    display: none !important;
  }
  .rg4,
  .rg3,
  .rg2 {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    align-items: start;
  }
  .hide-sm { display: none !important; }
  .cp {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
  }
  .cp .srch {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
  /* Horizontalni skrol za tabove aktivne aplikacije u gornjem baru na mobilnom */
  .nav {
    overflow: hidden;
  }
  .nav .menu {
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  }
  .nav .menu::-webkit-scrollbar { display: none; }

  .bnav {
    grid-area: bnav;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: 54px;
    background: var(--surf);
    border-top: 1px solid var(--line);
    position: sticky;
    bottom: 0;
    z-index: 45;
  }
  .bnav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    min-width: 0;
  }
  .bnav a.on { color: var(--acc); }
}

/* ============================================================================
 * A4 ŠTAMPA (@media print) — čist bijeli list, crni tekst, bez UI okvira
 * ============================================================================ */
@media print {
  @page { size: A4; margin: 12mm; }
  body, .x {
    background: #FFFFFF !important;
    color: #000000 !important;
  }
  .nav, .rail, .cp, .sbar, .bnav, .so, .pal-bg, .no-print {
    display: none !important;
  }
  .main {
    padding: 0 !important;
    overflow: visible !important;
  }
  .card {
    border-color: #CCCCCC !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
}
