/* Solvio web — stil sučelja (docs/llm/FRONTEND_WEB.md §5).
   Tri stila (data-theme: nordic | emerald | indigo) × svijetli/tamni (data-scheme, razrješava skripta u base.html iz
   data-mode). Komponente koriste samo semantičke tokene ispod; novi stil = novi blok tokena. */

/* ---------- Tokeni: Nordic Navy & Slate (zadano) ---------- */
:root {
  --font: "Inter", "InterVariable", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f8fafc; --surface: #ffffff; --surface-2: #f1f5f9; --fg: #0f172a; --fg-2: #1e293b; --muted: #64748b;
  --line: #e2e8f0; --line-strong: #cbd5e1;
  --brand: #0f172a;                       /* naslovi, KPI vrijednosti, tamni grafovi */
  --accent: #2563eb; --accent-hover: #1d4ed8; --accent-soft: #dbeafe; --accent-fg: #1d4ed8; --on-accent: #ffffff;
  --focus: rgba(37, 99, 235, 0.18);
  --nav-bg: #0f172a; --nav-fg: #94a3b8; --nav-fg-hover: #e2e8f0; --nav-active-bg: #1e293b; --nav-active-fg: #ffffff;
  --nav-indicator: #3b82f6; --nav-heading: #64748b; --nav-card: #1e293b; --nav-brand: #ffffff;
  --ok: #065f46; --ok-bg: #d1fae5; --ok-strong: #10b981;
  --warn: #92400e; --warn-bg: #fef3c7; --warn-strong: #f59e0b;
  --bad: #991b1b; --bad-bg: #fee2e2; --bad-strong: #ef4444;
  --info: #1e40af; --info-bg: #dbeafe;
  --violet: #5b21b6; --violet-bg: #ede9fe;
  --chart-1: #0f172a; --chart-2: #2563eb; --track: #e2e8f0;
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.05), 0 1px 2px -1px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
  --scrim: rgba(15, 23, 42, 0.4);
  --radius: 6px; --radius-lg: 8px;
  color-scheme: light;
}
[data-scheme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #172238; --fg: #e2e8f0; --fg-2: #cbd5e1; --muted: #94a3b8;
  --line: #1f2b42; --line-strong: #334155;
  --brand: #f1f5f9;
  --accent: #3b82f6; --accent-hover: #60a5fa; --accent-soft: #172554; --accent-fg: #93c5fd; --on-accent: #ffffff;
  --focus: rgba(59, 130, 246, 0.3);
  --nav-bg: #070c18; --nav-active-bg: #172238; --nav-card: #111a2e;
  --ok: #6ee7b7; --ok-bg: #063527; --warn: #fcd34d; --warn-bg: #3b2a07; --bad: #fca5a5; --bad-bg: #3f1416;
  --info: #93c5fd; --info-bg: #172554; --violet: #c4b5fd; --violet-bg: #2e1065;
  --chart-1: #94a3b8; --chart-2: #3b82f6; --track: #1f2b42;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.45); --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.55);
  --scrim: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* ---------- Modern Emerald & Forest ---------- */
[data-theme="emerald"] {
  --bg: #f3faf6; --surface: #ffffff; --surface-2: #ecf7f1; --fg: #052e22; --fg-2: #064e3b; --muted: #5b7268;
  --line: #d8ece2; --line-strong: #b9dccb;
  --brand: #064e3b;
  --accent: #059669; --accent-hover: #047857; --accent-soft: #d1fae5; --accent-fg: #047857; --on-accent: #ffffff;
  --focus: rgba(5, 150, 105, 0.2);
  --nav-bg: #064e3b; --nav-fg: #a7d7c2; --nav-fg-hover: #ecfdf5; --nav-active-bg: #059669; --nav-active-fg: #ffffff;
  --nav-indicator: #6ee7b7; --nav-heading: #6fb39a; --nav-card: #065f46; --nav-brand: #ffffff;
  --info: #075985; --info-bg: #e0f2fe;
  --chart-1: #064e3b; --chart-2: #10b981; --track: #d8ece2;
  --shadow-sm: 0 1px 3px 0 rgba(6, 78, 59, 0.06), 0 1px 2px -1px rgba(6, 78, 59, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(6, 78, 59, 0.09), 0 2px 4px -2px rgba(6, 78, 59, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(6, 78, 59, 0.12), 0 8px 10px -6px rgba(6, 78, 59, 0.05);
  --scrim: rgba(6, 46, 34, 0.45);
}
[data-theme="emerald"][data-scheme="dark"] {
  --bg: #06140f; --surface: #0b2019; --surface-2: #10291f; --fg: #e3f4ec; --fg-2: #c3e6d6; --muted: #8fb3a2;
  --line: #173a2d; --line-strong: #23523f;
  --brand: #d1fae5;
  --accent: #10b981; --accent-hover: #34d399; --accent-soft: #053d2c; --accent-fg: #6ee7b7; --on-accent: #022c1f;
  --focus: rgba(16, 185, 129, 0.3);
  --nav-bg: #03110c; --nav-fg: #8fb3a2; --nav-active-bg: #0d3b2b; --nav-card: #0b2019;
  --ok: #6ee7b7; --ok-bg: #063527; --warn: #fcd34d; --warn-bg: #3b2a07; --bad: #fca5a5; --bad-bg: #3f1416;
  --info: #7dd3fc; --info-bg: #0c2f45; --violet: #c4b5fd; --violet-bg: #2e1065;
  --chart-1: #8fb3a2; --chart-2: #10b981; --track: #173a2d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.45); --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.55);
  --scrim: rgba(0, 0, 0, 0.55);
}

/* ---------- Clean Indigo & Off-White (svijetli izbornik) ---------- */
[data-theme="indigo"] {
  --bg: #f8fafc; --surface: #ffffff; --surface-2: #f5f6fb; --fg: #1e1b4b; --fg-2: #312e81; --muted: #64748b;
  --line: #e5e7f0; --line-strong: #cfd3e3;
  --brand: #1e1b4b;
  --accent: #4f46e5; --accent-hover: #4338ca; --accent-soft: #e0e7ff; --accent-fg: #4338ca; --on-accent: #ffffff;
  --focus: rgba(79, 70, 229, 0.18);
  --nav-bg: #ffffff; --nav-fg: #475569; --nav-fg-hover: #1e1b4b; --nav-active-bg: #eef2ff; --nav-active-fg: #4338ca;
  --nav-indicator: #4f46e5; --nav-heading: #94a3b8; --nav-card: #f5f6fb; --nav-brand: #4f46e5;
  --chart-1: #1e1b4b; --chart-2: #6366f1; --track: #e5e7f0;
  --shadow-sm: 0 1px 3px 0 rgba(30, 27, 75, 0.05), 0 1px 2px -1px rgba(30, 27, 75, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(30, 27, 75, 0.08), 0 2px 4px -2px rgba(30, 27, 75, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(30, 27, 75, 0.1), 0 8px 10px -6px rgba(30, 27, 75, 0.05);
  --scrim: rgba(30, 27, 75, 0.35);
}
[data-theme="indigo"][data-scheme="dark"] {
  --bg: #0e0d1a; --surface: #16152a; --surface-2: #1d1b37; --fg: #e8e9ff; --fg-2: #c7d2fe; --muted: #a0a3c4;
  --line: #282650; --line-strong: #3a3870;
  --brand: #e0e7ff;
  --accent: #818cf8; --accent-hover: #a5b4fc; --accent-soft: #2a2766; --accent-fg: #c7d2fe; --on-accent: #0e0d1a;
  --focus: rgba(129, 140, 248, 0.3);
  --nav-bg: #121126; --nav-fg: #a0a3c4; --nav-fg-hover: #e8e9ff; --nav-active-bg: #24224a; --nav-active-fg: #c7d2fe;
  --nav-indicator: #818cf8; --nav-heading: #6f71a0; --nav-card: #1d1b37; --nav-brand: #c7d2fe;
  --ok: #6ee7b7; --ok-bg: #063527; --warn: #fcd34d; --warn-bg: #3b2a07; --bad: #fca5a5; --bad-bg: #3f1416;
  --info: #a5b4fc; --info-bg: #23215a; --violet: #d8b4fe; --violet-bg: #3b0764;
  --chart-1: #a0a3c4; --chart-2: #818cf8; --track: #282650;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.45); --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.55);
  --scrim: rgba(0, 0, 0, 0.55);
}

/* ---------- Stilovi uz predloške računa (palete iz documents/default_templates/designs.py) ---------- */
/* Ocean Blue — Jedro plavi, Obala tamnoplavi */
[data-theme="ocean"] {
  --bg: #f5f8fb; --surface: #ffffff; --surface-2: #eef3f8; --fg: #12263d; --fg-2: #1e3a5f; --muted: #5b6b7b;
  --line: #dce5ee; --line-strong: #c3d2e0; --brand: #1e3a5f;
  --accent: #1e5a8a; --accent-hover: #184a72; --accent-soft: #e8f1f8; --accent-fg: #1e5a8a; --on-accent: #ffffff; --focus: rgba(30, 90, 138, 0.2);
  --nav-bg: #1e3a5f; --nav-fg: #a9bed4; --nav-fg-hover: #ffffff; --nav-active-bg: #2a4c74; --nav-active-fg: #ffffff;
  --nav-indicator: #7fb3e0; --nav-heading: #7f97b0; --nav-card: #24476f; --nav-brand: #ffffff;
  --chart-1: #1e3a5f; --chart-2: #3b82c4; --track: #dce5ee;
}
[data-theme="ocean"][data-scheme="dark"] {
  --bg: #0a1320; --surface: #0f1c2e; --surface-2: #15253a; --fg: #e3ecf5; --fg-2: #c6d6e6; --muted: #93a7bc;
  --line: #1d2f45; --line-strong: #2c4561; --brand: #e8f1f8;
  --accent: #4e95d0; --accent-hover: #6aaae0; --accent-soft: #12324f; --accent-fg: #9cc7ec; --on-accent: #ffffff; --focus: rgba(78, 149, 208, 0.3);
  --nav-bg: #07101b; --nav-fg: #93a7bc; --nav-active-bg: #15253a; --nav-card: #0f1c2e;
  --chart-1: #93a7bc; --chart-2: #4e95d0; --track: #1d2f45;
}
/* Teal Lagoon — Jedro tirkizni */
[data-theme="teal"] {
  --bg: #f4faf9; --surface: #ffffff; --surface-2: #ebf5f4; --fg: #0d2f31; --fg-2: #12464a; --muted: #587271;
  --line: #d6e9e7; --line-strong: #b7d6d3; --brand: #12464a;
  --accent: #0f7c80; --accent-hover: #0b6467; --accent-soft: #e3f3f2; --accent-fg: #0b6467; --on-accent: #ffffff; --focus: rgba(15, 124, 128, 0.2);
  --nav-bg: #12464a; --nav-fg: #9fcfcb; --nav-fg-hover: #ffffff; --nav-active-bg: #0f7c80; --nav-active-fg: #ffffff;
  --nav-indicator: #5fd3cb; --nav-heading: #6fa9a5; --nav-card: #175a5e; --nav-brand: #ffffff;
  --chart-1: #12464a; --chart-2: #14a3a8; --track: #d6e9e7;
}
[data-theme="teal"][data-scheme="dark"] {
  --bg: #061314; --surface: #0b1f21; --surface-2: #10292b; --fg: #e1f2f1; --fg-2: #bfe2df; --muted: #8db1af;
  --line: #173a3c; --line-strong: #235357; --brand: #d5f0ee;
  --accent: #22b5ba; --accent-hover: #46c9cd; --accent-soft: #083a3c; --accent-fg: #7fdcdf; --on-accent: #031617; --focus: rgba(34, 181, 186, 0.3);
  --nav-bg: #031011; --nav-fg: #8db1af; --nav-active-bg: #0e3437; --nav-card: #0b1f21;
  --chart-1: #8db1af; --chart-2: #22b5ba; --track: #173a3c;
}
/* Terracotta Orange — Jedro i Obala narančasti */
[data-theme="orange"] {
  --bg: #fbf8f5; --surface: #ffffff; --surface-2: #f6efe9; --fg: #2a1d15; --fg-2: #3b2a20; --muted: #75645a;
  --line: #eadfd6; --line-strong: #d9c8bb; --brand: #3b2a20;
  --accent: #c2410c; --accent-hover: #9a3412; --accent-soft: #fbeee5; --accent-fg: #9a3412; --on-accent: #ffffff; --focus: rgba(194, 65, 12, 0.18);
  --nav-bg: #3b2a20; --nav-fg: #cdb8a9; --nav-fg-hover: #ffffff; --nav-active-bg: #56402f; --nav-active-fg: #ffffff;
  --nav-indicator: #f97316; --nav-heading: #9c8576; --nav-card: #4a3628; --nav-brand: #ffffff;
  --chart-1: #3b2a20; --chart-2: #e8590c; --track: #eadfd6;
}
[data-theme="orange"][data-scheme="dark"] {
  --bg: #140e0a; --surface: #1e1611; --surface-2: #281d16; --fg: #f3e9e1; --fg-2: #e2d2c6; --muted: #b5a194;
  --line: #362a21; --line-strong: #4d3c30; --brand: #fbeee5;
  --accent: #f97316; --accent-hover: #fb8a3c; --accent-soft: #4a230e; --accent-fg: #fdba8c; --on-accent: #1a0c04; --focus: rgba(249, 115, 22, 0.3);
  --nav-bg: #0e0906; --nav-fg: #b5a194; --nav-active-bg: #2d2119; --nav-card: #1e1611;
  --chart-1: #b5a194; --chart-2: #f97316; --track: #362a21;
}
/* Graphite — Jedro antracit */
[data-theme="graphite"] {
  --bg: #f7f8f9; --surface: #ffffff; --surface-2: #f0f2f4; --fg: #1a2028; --fg-2: #2f3b48; --muted: #5b6670;
  --line: #e0e4e8; --line-strong: #c9cfd6; --brand: #1f2730;
  --accent: #2f3b48; --accent-hover: #1f2730; --accent-soft: #eceff2; --accent-fg: #2f3b48; --on-accent: #ffffff; --focus: rgba(47, 59, 72, 0.2);
  --nav-bg: #1f2730; --nav-fg: #a3adb8; --nav-fg-hover: #ffffff; --nav-active-bg: #36424f; --nav-active-fg: #ffffff;
  --nav-indicator: #cbd5e1; --nav-heading: #7a8591; --nav-card: #2b3540; --nav-brand: #ffffff;
  --chart-1: #2f3b48; --chart-2: #8c99a6; --track: #e0e4e8;
}
[data-theme="graphite"][data-scheme="dark"] {
  --bg: #0f1215; --surface: #171b20; --surface-2: #1e242a; --fg: #e6e9ec; --fg-2: #cfd5db; --muted: #9aa4ae;
  --line: #272e36; --line-strong: #3a434d; --brand: #f0f2f4;
  --accent: #b8c2cc; --accent-hover: #d0d7de; --accent-soft: #2a323b; --accent-fg: #d0d7de; --on-accent: #0f1215; --focus: rgba(184, 194, 204, 0.3);
  --nav-bg: #0a0c0f; --nav-fg: #9aa4ae; --nav-active-bg: #232a31; --nav-card: #171b20;
  --chart-1: #6b7682; --chart-2: #b8c2cc; --track: #272e36;
}

/* ---------- Osnova ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
h1 { font-size: 1.6rem; line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; color: var(--brand); margin: 0 0 18px; }
h2 { font-size: 1.05rem; font-weight: 600; color: var(--brand); letter-spacing: -0.01em; }
h3 { font-size: 0.95rem; font-weight: 600; color: var(--fg-2); }
a { color: var(--accent-fg); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.num, .tnum { font-variant-numeric: tabular-nums; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
code { font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- Okvir: bočni izbornik + gornja traka ---------- */
.shell { min-height: 100vh; }
.main-col { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; gap: 12px; align-items: center; min-height: 60px; padding: 10px 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar form { margin: 0; }
.topbar-spacer { flex: 1; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; color: var(--brand); text-decoration: none; }
.brand img { border-radius: 8px; }
.org { color: var(--muted); }
.topbar-cta .ico { width: 16px; height: 16px; }
.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 32px 64px; }

.sidebar { display: flex; flex-direction: column; gap: 14px; background: var(--nav-bg); color: var(--nav-fg); padding: 16px 12px;
  border-right: 1px solid color-mix(in srgb, var(--nav-fg) 14%, transparent); }
.side-brand { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; }
.side-brand .brand { color: var(--nav-brand); }
.org-card { position: relative; display: grid; gap: 1px; padding: 10px 34px 10px 12px; border-radius: var(--radius-lg); background: var(--nav-card);
  color: var(--nav-active-fg); text-decoration: none; }
[data-theme="indigo"]:not([data-scheme="dark"]) .org-card { color: var(--fg); border: 1px solid var(--line); }
.org-card:hover { color: var(--nav-active-fg); filter: brightness(1.08); }
.org-card .org-name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-card .org-oib { font-size: 0.75rem; color: var(--nav-fg); font-variant-numeric: tabular-nums; }
.org-card .ico { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--nav-fg); }
.sidenav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidenav a { position: relative; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--radius);
  color: var(--nav-fg); text-decoration: none; font-weight: 500; font-size: 0.9rem; }
.sidenav a:hover { color: var(--nav-fg-hover); background: color-mix(in srgb, var(--nav-active-bg) 60%, transparent); }
.sidenav a[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active-fg); font-weight: 600; }
.sidenav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--nav-indicator); }
.sidenav .nav-heading { padding: 16px 12px 6px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--nav-heading); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 12px 6px 4px; border-top: 1px solid color-mix(in srgb, var(--nav-fg) 16%, transparent); }
.side-user form { margin: 0 0 0 auto; }
.side-user .who { display: grid; min-width: 0; }
.side-user .name { color: var(--nav-active-fg); font-weight: 600; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-theme="indigo"]:not([data-scheme="dark"]) .side-user .name { color: var(--fg); }
.side-user .role { font-size: 0.75rem; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--accent);
  color: var(--on-accent); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--radius); background: transparent;
  color: inherit; cursor: pointer; }
.icon-btn:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.nav-scrim { display: none; }

/* Do 1024 px: izbornik je ladica (drawer) preko sadržaja. */
@media (max-width: 1023.98px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: 280px; max-width: 86vw; overflow-y: auto; transform: translateX(-100%);
    transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 30; background: var(--scrim); }
  .topbar { padding: 8px 16px; }
  .topbar-org { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-size: 0.85rem; }
  .page { padding: 20px 16px 48px; }
}
@media (max-width: 560px) {
  .topbar-cta span { display: none; }
  .topbar-cta { padding: 0 10px; }
  .topbar-org { display: none; }
  h1 { font-size: 1.35rem; }
}
@media (min-width: 1024px) {
  .shell.with-nav { display: grid; grid-template-columns: 260px minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .nav-open, .nav-close, .shell.with-nav .topbar-brand { display: none; }
}

/* ---------- Gumbi ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; font: inherit; font-weight: 500;
  padding: 6px 14px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg-2);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color 0.12s, border-color 0.12s, color 0.12s; }
.btn:hover { border-color: var(--muted); color: var(--fg); background: var(--surface-2); }
.btn-primary, button.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.danger, button.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-bg); }
.btn.disabled { opacity: 0.45; pointer-events: none; }
.btn .ico { width: 16px; height: 16px; }
button.link { background: none; border: 0; padding: 0; color: var(--accent-fg); cursor: pointer; font: inherit; }
button.link:hover { color: var(--accent); text-decoration: underline; }
.danger { color: var(--bad); }
/* Gumb bez klase unutar obrasca dobiva izgled sekundarnog gumba. */
.page form button:not([class]), .page button[type="submit"]:not([class]) {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font: inherit; font-weight: 500; padding: 6px 14px;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg-2); cursor: pointer; }
.page form button:not([class]):hover { background: var(--surface-2); border-color: var(--muted); }

/* ---------- Polja ---------- */
input, select, textarea { font: inherit; color: var(--fg); }
.page input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), .page select, .page textarea {
  min-height: 36px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--fg); }
.page textarea { min-height: 72px; line-height: 1.45; }
/* Sva jednoredna polja i padajući izbornici iste visine u svim preglednicima: Safari nativni <select> i polja za
   datum/vrijeme iscrtava niže (zanemaruje min-height), pa izbornik nema nativni izgled nego vlastitu strelicu. */
.page input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), .page select:not([multiple]):not([size]) {
  height: 36px; line-height: 1.2; box-sizing: border-box; }
.page input[type="date"], .page input[type="time"], .page input[type="datetime-local"] { padding-top: 0; padding-bottom: 0; }
/* Datum kao dd.mm.gggg bez obzira na jezik preglednika (app.js: tekstualno polje + skriveni input[type=date]) */
.date-field { position: relative; display: inline-flex; align-items: center; vertical-align: middle; }
.date-field .date-text { width: 9.5em; padding-right: 32px; font-variant-numeric: tabular-nums; }
.block > .date-field .date-text { width: 100%; }  /* u formi (grid) polje je široko kao ostala polja */
.date-field .date-pick { position: absolute; right: 4px; display: inline-flex; padding: 4px; border: 0; background: none;
  color: var(--muted); cursor: pointer; border-radius: var(--radius); }
.date-field .date-pick:hover { color: var(--fg); }
.date-field .date-native { position: absolute; left: 0; bottom: 0; width: 1px !important; height: 1px !important; padding: 0;
  border: 0; opacity: 0; pointer-events: none; }
.page select:not([multiple]):not([size]) {
  -webkit-appearance: none; appearance: none; padding-right: 30px; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.page select:disabled { opacity: 1; }
.page input:focus, .page select:focus, .page textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.page input[readonly], .page input:disabled, .page select:disabled { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; }
.form label, .grid label { display: grid; gap: 5px; font-size: 0.85rem; font-weight: 500; color: var(--fg-2); }
.form input, .form select, .form textarea, .inline select { max-width: 100%; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; }
.grid > * { min-width: 0; }
.grid label { align-content: start; }
.grid select, .grid input:not([type="checkbox"]):not([type="radio"]) { width: 100%; max-width: 100%; min-width: 0; }
.grid .span-all { grid-column: 1 / -1; }
label:has(> input[type="checkbox"]) { display: flex !important; align-items: center; gap: 8px; }
textarea { width: 100%; }
.hint { color: var(--muted); font-size: 0.82rem; }
.small { font-size: 0.85rem; }
.block { display: grid; gap: 4px; }
ul.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: var(--bad); font-size: 0.82rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-lg); }
fieldset.ubl { background: var(--surface); padding: 14px 18px 18px; margin: 20px 0 0; box-shadow: var(--shadow-sm); }
fieldset.ubl legend { padding: 0 6px; font-weight: 600; color: var(--brand); }

/* ---------- Kartice, zaglavlja, raspored ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; margin: 16px 0; min-width: 0;
  box-shadow: var(--shadow-sm); }
.card h2 { font-size: 1rem; margin: 0 0 12px; }
.card > h2:first-child { display: flex; align-items: center; gap: 8px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 16px; align-items: start; }
.cols > .card { margin: 0; }
.heading { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; margin-bottom: 20px; }
.heading h1 { margin: 0; }
.heading .btn-primary { margin-left: auto; }
.heading .push-right ~ .btn-primary { margin-left: 0; }
.page-sub { margin: -12px 0 20px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--fg); min-width: 0; overflow-wrap: anywhere; }
.note { color: var(--muted); }
.list { padding-left: 18px; margin: 0; display: grid; gap: 6px; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; }
.nav a { padding: 6px 12px; border-radius: var(--radius); color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--fg); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--accent-fg); background: var(--accent-soft); font-weight: 600; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.actions form { margin: 0; }
.push-right { margin-left: auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Poruke ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; }
.msg { padding: 10px 14px; border-radius: var(--radius-lg); background: var(--info-bg); color: var(--info); border: 1px solid transparent; }
.msg-success { background: var(--ok-bg); color: var(--ok); }
.msg-warning { background: var(--warn-bg); color: var(--warn); }
.msg-error, .msg-error a { color: var(--bad); }
.msg.msg-error { background: var(--bad-bg); }
li.msg-error:not(.msg) { color: var(--bad); }

/* ---------- Tablice ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card .table-wrap { box-shadow: none; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
table.data thead th { background: var(--surface-2); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
table.data td.num { font-weight: 500; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; }
tfoot td { border-top: 2px solid var(--line); font-weight: 600; background: var(--surface-2); }
.icon-col { width: 2rem; padding-right: 0 !important; }
.doc-icon { display: inline-flex; color: var(--accent-fg); }
.doc-icon:hover, .doc-icon:focus-visible { color: var(--fg); }
a.sort { color: inherit; text-decoration: none; }
a.sort:hover { color: var(--accent); }
a.sort::after { content: "↕"; opacity: 0.35; margin-left: 4px; }
a.sort-asc::after { content: "▲"; opacity: 1; }
a.sort-desc::after { content: "▼"; opacity: 1; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }

/* ---------- Oznake statusa (kapsule) ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; font-size: 0.75rem; font-weight: 500; padding: 0 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill-paid, .pill-status-delivered, .pill-match-matched { background: var(--ok-bg); color: var(--ok); }
.pill-partial, .pill-match-suggested { background: var(--warn-bg); color: var(--warn); }
.pill-unpaid, .pill-overpaid, .pill-status-rejected, .pill-status-cancelled, .pill-match-unmatched { background: var(--bad-bg); color: var(--bad); }
.pill-voided { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.pill-status-draft, .pill-match-ignored { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill-status-issued { background: var(--info-bg); color: var(--info); }
.pill-status-signed { background: var(--violet-bg); color: var(--violet); }
.pill-status-sent { background: var(--accent-soft); color: var(--accent-fg); }

/* ---------- KPI kartice (nadzorna ploča) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.tile { position: relative; display: grid; gap: 6px; align-content: start; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); color: var(--fg); text-decoration: none; box-shadow: var(--shadow-sm); transition: border-color 0.12s, box-shadow 0.12s; }
a.tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); color: var(--fg); }
.tile .k { font-size: 0.72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; padding-right: 40px; }
.tile .v { font-size: 1.75rem; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; color: var(--brand); font-variant-numeric: tabular-nums; }
.tile .v small { font-size: 0.9rem; font-weight: 600; color: var(--muted); margin-left: 2px; }
.tile .s { font-size: 0.82rem; color: var(--muted); }
.tile-bad .v { color: var(--bad-strong); }
.tile-icon { position: absolute; top: 16px; right: 16px; display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent-fg); }
.tile-icon.ok { background: var(--ok-bg); color: var(--ok); }
.tile-icon.bad { background: var(--bad-bg); color: var(--bad); }
.tile-icon.warn { background: var(--warn-bg); color: var(--warn); }
.meter { height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.meter.ok > span { background: var(--ok-strong); }
.meter.warn > span { background: var(--warn-strong); }
.meter.bad > span { background: var(--bad-strong); }

/* ---------- Graf (stupci, čisti CSS) ---------- */
.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 8px; }
.chart-head h2 { margin: 0; }
.legend { display: flex; gap: 14px; font-size: 0.8rem; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; background: var(--chart-1); }
.legend .l2::before { background: var(--chart-2); }
.bars { display: grid; grid-template-columns: repeat(var(--cols, 12), minmax(0, 1fr)); gap: 6px; align-items: end; height: 220px; padding-top: 12px; border-bottom: 1px solid var(--line); }
.bars .m { display: flex; justify-content: center; align-items: flex-end; gap: 3px; height: 100%; position: relative; }
.bars .b { width: min(16px, 40%); min-height: 2px; border-radius: 3px 3px 0 0; background: var(--chart-1); }
.bars .b2 { background: var(--chart-2); }
.bars .m.future .b { opacity: 0.25; }
.bars .m:hover .b { filter: brightness(1.15); }
/* os iznosa (_chart_axis.html): linije preko cijele širine, oznake lijevo od grafa */
.plot { position: relative; height: 220px; margin: 12px 0 0 var(--axis-w, 56px); }
.plot .bars { height: 100%; padding-top: 0; position: relative; }
.plot .tick { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); pointer-events: none; }
.plot .tick b { position: absolute; right: calc(100% + 6px); top: 0; transform: translateY(-50%); font-size: 0.7rem; font-weight: 400;
  color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.plot ~ .bar-labels { margin-left: var(--axis-w, 56px); }
/* iznos stupca pri prelasku mišem / dodiru (data-tip, redovi odvojeni s &#10;) */
.bars .m { outline: none; border-radius: 4px 4px 0 0; }
.bars .m:hover, .bars .m:focus-visible { background: var(--surface-2); }
.bars .m[data-tip]:hover::after, .bars .m[data-tip]:focus::after { content: attr(data-tip); position: absolute; z-index: 5;
  bottom: calc(max(var(--h, 0), var(--h2, 0)) * 1% + 8px); white-space: pre; text-align: left;
  padding: 6px 9px; border-radius: var(--radius); background: var(--fg); color: var(--surface); font-size: 0.75rem; line-height: 1.45;
  font-weight: 500; font-variant-numeric: tabular-nums; box-shadow: var(--shadow-md); pointer-events: none; }
.bars .m::after { left: 50%; transform: translateX(-50%); }
.bars .m:nth-child(-n+2)::after { left: 0; transform: none; }
.bars .m:nth-last-child(-n+2)::after { left: auto; right: 0; transform: none; }
.bar-labels { display: grid; grid-template-columns: repeat(var(--cols, 12), minmax(0, 1fr)); gap: 6px; margin-top: 6px; font-size: 0.72rem; color: var(--muted); text-align: center; }
.bar-labels .now { color: var(--accent-fg); font-weight: 600; }
.chart-foot { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; padding: 12px 14px;
  background: var(--surface-2); border-radius: var(--radius); }
.chart-foot .k { font-size: 0.78rem; color: var(--muted); }
.chart-foot .v { font-weight: 600; color: var(--brand); font-variant-numeric: tabular-nums; }

/* Popis zadataka/dospjelih na ploči */
.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.task-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); }
.task-list li a { font-weight: 500; }
.task-list .amount { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--brand); white-space: nowrap; }
.task-list .sub { display: block; font-size: 0.78rem; color: var(--muted); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.dash-grid > .card { margin: 0; }
.dash-grid + .dash-grid { margin-top: 20px; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Izgled (odabir stila) ---------- */
.theme-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.theme-option { position: relative; display: block; cursor: pointer; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface);
  box-shadow: var(--shadow-sm); }
.theme-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.theme-option input { position: absolute; top: 14px; right: 14px; }
.theme-option .swatch-head { padding: 16px 18px; color: #fff; }
.theme-option .swatch-head b { display: block; font-size: 1.05rem; }
.theme-option .swatch-head small { opacity: 0.85; }
.theme-option .swatches { display: flex; gap: 6px; padding: 12px 18px 16px; }
.theme-option .swatches i { flex: 1; height: 26px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.08); }
.mode-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.mode-picker label { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font-weight: 500; }
.mode-picker label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-fg); }

/* ---------- Filtri popisa ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { color: var(--fg); }
.tabs a.active { color: var(--accent-fg); border-bottom-color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 16px; }
.filter-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.filter-panel .filters { margin-bottom: 10px; align-items: flex-start; }
.filter-panel label { display: inline-flex; flex-direction: column; justify-content: flex-start; gap: 3px; font-size: 0.8rem; font-weight: 500; color: var(--muted); }
/* Naziv iznad polja kao kod <label>; sva polja filtra iste visine (Safari inače daje višlje polje za datum). */
.range-filter { display: inline-flex; flex-direction: column; gap: 3px; }
.range-filter .rf-label { font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.range-filter .rf-controls, .range-filter .range-to { display: inline-flex; gap: 4px; align-items: center; }
.range-filter .range-to[hidden] { display: none; }

/* ---------- Stavke računa i ugovora ---------- */
table.lines textarea { width: 100%; min-width: 16rem; resize: vertical; font: inherit; }
table.lines select.catalog-pick { width: 100%; margin-bottom: 4px; }
table.lines select[name=line_unit] { min-width: 4.5rem; }
table.lines input, table.lines select { width: 100%; }
table.lines td:first-child { min-width: 280px; display: grid; gap: 4px; }
table.lines input.num { text-align: right; min-width: 80px; }
.kpd-cell { min-width: 9rem; max-width: 14rem; }
.kpd-cell .kpd-input { width: 100%; }
.kpd-cell .kpd-name { display: block; line-height: 1.25; margin-top: 2px; }
label.process-custom { display: none; }
label:has(select.process-pick option[value="P99"]:checked) + label.process-custom { display: grid; }
.doc-pick select { max-width: 100%; min-width: 0; flex: 1 1 20rem; }
.attachment { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.attach-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.attach-form input[type=file] { max-width: 100%; }

/* Izvještaj o naplati: račun pa njegove uplate uvučeno ispod. */
.collection thead tr.sub th { font-weight: 400; font-size: 0.82rem; color: var(--muted); text-transform: none; letter-spacing: 0; }
.collection tbody.invoice-group { border-top: 2px solid var(--line); }
.collection tr.invoice-row td { font-weight: 600; }
.collection tr.payment-row td { font-size: 0.88rem; color: var(--muted); border-top: 0; padding-top: 2px; padding-bottom: 2px; }

/* ---------- Prijava i ostale stranice računa (allauth) ---------- */
body.entrance { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%), var(--bg); }
body.entrance .topbar { display: none; }
body.entrance .page { max-width: 420px; margin: 9vh auto 0; padding: 36px 32px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg); }
.auth-brand { display: grid; justify-items: center; gap: 4px; margin-bottom: 22px; }
.auth-brand img { width: 64px; height: auto; border-radius: 16px; }
.auth-brand span { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; color: var(--brand); }
.auth-brand small { color: var(--muted); font-size: 0.85rem; }
body.entrance h1, body.account-page h1 { font-size: 1.2rem; text-align: center; margin: 0 0 14px; }
body.entrance form, body.account-page .page form { display: grid; gap: 14px; }
body.entrance form p, body.account-page .page form p { margin: 0; display: grid; gap: 5px; }
body.entrance label, body.account-page .page label { font-size: 0.85rem; font-weight: 500; color: var(--fg-2); }
body.entrance input[type="email"], body.entrance input[type="password"], body.entrance input[type="text"],
body.account-page .page input[type="email"], body.account-page .page input[type="password"], body.account-page .page input[type="text"] { width: 100%; }
body.entrance input[type="checkbox"] { width: auto; margin-right: 6px; }
body.entrance button, body.account-page .page button[type="submit"] {
  font: inherit; min-height: 40px; padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--accent);
  color: var(--on-accent); cursor: pointer; font-weight: 600; justify-content: center; }
body.entrance button:hover, body.account-page .page button[type="submit"]:hover { background: var(--accent-hover); }
body.entrance .page > p, body.entrance .page a { font-size: 0.9rem; }
.login-form .remember { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); }
.auth-links { text-align: center; margin: 14px 0 4px; }
.auth-note { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 0; }

/* ---------- Ispis ---------- */
@media print {
  .topbar, .sidebar, .nav-scrim, .no-print { display: none !important; }
  .shell.with-nav { display: block; }
  .page { max-width: none; padding: 0; }
  body { background: #fff; color: #000; }
  .card, .table-wrap, .tile { box-shadow: none; }
  .collection a { color: inherit; text-decoration: none; }
  .collection tbody.invoice-group { break-inside: avoid; }
}
table.data td a:not(.btn) { text-decoration: none; font-weight: 500; }
table.data td a:not(.btn):hover { text-decoration: underline; }
input[type="file"] { color: var(--muted); }
input[type="file"]::file-selector-button { font: inherit; font-weight: 500; margin-right: 10px; min-height: 34px; padding: 4px 12px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--fg-2); cursor: pointer; }
input[type="file"]::file-selector-button:hover { border-color: var(--muted); }

/* Banka: naslov odjeljka u retku s karticama (poravnato po sredini), izvodi koji se rasklapaju. */
.section-heading { margin: 24px 0 12px; }
.section-heading h2 { margin: 0; }
.section-heading .nav { margin: 0; }
.statements { display: grid; gap: 8px; }
.statement { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.statement[open] { border-color: var(--line-strong); }
.statement > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 10px 14px; cursor: pointer; list-style: none; }
.statement > summary::-webkit-details-marker { display: none; }
.statement > summary::before { content: "›"; display: inline-block; width: 10px; color: var(--muted); font-weight: 700; transition: transform 0.15s; }
.statement[open] > summary::before { transform: rotate(90deg); }
.statement > summary:hover { background: var(--surface-2); border-radius: var(--radius-lg); }
.stmt-title { font-weight: 600; color: var(--accent-fg); }
.stmt-balance { margin-left: auto; font-weight: 500; }
.stmt-body { padding: 0 14px 14px; }
.stmt-body .table-wrap { box-shadow: none; }

/* AI asistent: chat preko visine prozora — odgovori klize u svom okviru, pitanje na dnu, razgovori stupac sa strane */
.ai-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px;
  height: calc(100vh - 210px); height: calc(100dvh - 210px); min-height: 420px; }
.ai-layout.history-hidden { grid-template-columns: minmax(0, 1fr); }
.ai-layout.history-hidden .ai-history { display: none; }
.ai-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.ai-thread { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 18px 20px;
  background: var(--bg); }
.ai-empty { padding: 4px; max-width: 70ch; }
.ai-qa { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.ai-question { justify-self: end; max-width: 85%; padding: 10px 14px; border-radius: 12px 12px 2px 12px; background: var(--accent); color: var(--on-accent); }
.ai-answer { min-width: 0; overflow-wrap: anywhere; max-width: 100%; padding: 12px 16px; border-radius: 12px 12px 12px 2px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.ai-answer > :first-child { margin-top: 0; }
.ai-answer p { margin: 0 0 8px; }
.ai-answer ul, .ai-answer ol { margin: 0 0 8px; padding-left: 20px; }
.ai-answer h3 { margin: 12px 0 6px; }
.ai-answer .table-wrap { margin: 6px 0 10px; box-shadow: none; max-width: 100%; }
.ai-answer .table-wrap td, .ai-answer .table-wrap th { overflow-wrap: normal; }
.ai-answer hr { margin: 12px 0; }
.ai-history .task-list a { text-decoration: none; }
.ai-error { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.ai-meta { margin: 6px 0 0 !important; font-size: 0.75rem; color: var(--muted); }
.ai-ask { flex: none; margin: 0; padding: 6px 16px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.ai-ask-body { display: grid; gap: 10px; }
.ai-ask-toggle { display: block; margin: 0 auto 6px; padding: 2px 10px; border: 0; background: none; color: var(--muted); font: inherit;
  font-size: 0.78rem; cursor: pointer; border-radius: var(--radius); }
.ai-ask-toggle:hover { color: var(--fg); background: var(--surface-2); }
.ai-ask .when-closed, .ai-ask.collapsed .when-open { display: none; }
.ai-ask.collapsed .when-closed { display: inline; }
.ai-ask.collapsed { padding-bottom: 6px; }
.ai-ask.collapsed .ai-ask-body { display: none; }
.ai-ask.collapsed .ai-ask-toggle { margin-bottom: 0; }
.ai-history { min-height: 0; overflow-y: auto; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.ai-history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ai-history-head h2 { margin: 0; }
.ai-history .task-list li { flex-wrap: wrap; }
.ai-history .current { outline: 2px solid var(--accent); }
/* Uži ekran: razgovori su ladica preko desnog ruba okvira, zadano skrivena. */
@media (max-width: 1100px) {
  .ai-layout { grid-template-columns: minmax(0, 1fr); position: relative; }
  .ai-history { position: absolute; top: 0; right: 0; bottom: 0; width: min(320px, 90%); z-index: 5; box-shadow: var(--shadow-lg); }
}
@media (max-width: 1023.98px) { .ai-layout { height: calc(100dvh - 170px); } }
.ai-dots::after { content: "•••"; letter-spacing: 2px; animation: ai-pulse 1.2s infinite; }
@keyframes ai-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

/* Primopredajni zapisnici */
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
table.compact th, table.compact td { padding: 6px 8px; }
.ht-editor { display: grid; gap: 10px; }
.ht-columns summary { cursor: pointer; font-weight: 500; color: var(--accent-fg); margin-bottom: 8px; }
.ht-grid td { vertical-align: top; }
.ht-grid textarea { min-height: 36px; height: 36px; resize: vertical; width: 100%; min-width: 14rem; }
.ht-grid input.num { width: 7rem; text-align: right; }
.handover-body { white-space: normal; margin-bottom: 10px; }

/* Odabir tvrtke (web:home) */
.org-picker { max-width: 980px; margin: 0 auto; }
.org-picker .org-search { width: min(280px, 100%); }
.org-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.org-tile { gap: 14px; }
.org-tile.is-current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus), var(--shadow-sm); }
.org-tile-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.org-avatar { width: 42px; height: 42px; border-radius: var(--radius-lg); font-size: 0.95rem; }
.org-tile-name { display: grid; gap: 2px; min-width: 0; flex: 1; }
.org-tile-name strong { color: var(--brand); font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-tile-name .muted { font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.org-tile-go { color: var(--muted); transition: transform 0.12s; }
.org-tile:hover .org-tile-go { transform: translateX(2px); }
.org-tile[hidden] { display: none; }
.org-tile:hover .org-tile-go { color: var(--accent); }
.org-tile-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.org-tile-meta .pill .ico { width: 13px; height: 13px; }
.org-tile-kind { margin-left: auto; font-size: 0.78rem; color: var(--muted); }
.org-empty { grid-column: 1 / -1; }
.org-none { margin-top: 16px; }

/* Moj račun: QR za aplikaciju autentifikatora i rezervni kodovi */
.totp-qr { width: 200px; max-width: 100%; padding: 10px; background: #fff; border-radius: var(--radius); }
.totp-qr svg { display: block; width: 100%; height: auto; }
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 4px 16px; padding: 12px 16px;
  background: var(--surface-2); border-radius: var(--radius); font-family: ui-monospace, monospace; white-space: pre-line; }

/* Prognoza priljeva: stupac „kasni” u boji upozorenja */
.bars .m.overdue .b { background: var(--warn-strong); }

/* Samo čitanje (knjigovođa): traka i onemogućeni obrasci za unos */
.test-banner { margin: 0 0 12px; padding: 8px 12px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-strong); font-size: 0.85rem; }
.pill-test { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-strong); font-weight: 600; letter-spacing: 0.04em; }
.org-tile.is-test { border-style: dashed; border-color: var(--warn-strong); background: linear-gradient(var(--warn-bg), var(--warn-bg)) top / 100% 4px no-repeat, var(--surface); }
.read-only-banner { margin: 0 0 12px; padding: 8px 12px; border-radius: var(--radius); background: var(--info-bg); color: var(--info); font-size: 0.85rem; }
.read-only-form button, .read-only-form .btn, .read-only-action { display: none !important; }

/* Potpis kupca na zaslonu (zapisnik) */
.sign-pad { position: relative; height: 240px; max-width: 720px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: #fff; margin-bottom: 12px; }
.sign-pad canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.sign-pad .sign-hint { position: absolute; left: 16px; bottom: 12px; color: #9aa3ad; font-size: 0.8rem; pointer-events: none; }
.sign-pad.inked .sign-hint { display: none; }

/* AI asistent: prijedlog radnje koji korisnik potvrđuje */
.ai-action { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line-strong); border-left: 4px solid var(--accent); border-radius: var(--radius); background: var(--surface); }
.ai-action p { margin: 0 0 6px; }
.ai-action-done { border-left-color: var(--ok-strong, var(--ok)); }
.ai-action-rejected { opacity: 0.7; border-left-color: var(--muted); }
.ai-action-failed { border-left-color: var(--bad); }

/* ---------- Stranica računa za kupca (/r/<token>/, bez prijave) ---------- */
body.public-invoice { min-height: 100vh; background: var(--bg); }
body.public-invoice .page { max-width: 680px; }
.pi-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.pi-head img { max-height: 56px; max-width: 160px; object-fit: contain; }
.pi-seller { font-size: 1.05rem; }
.pi-status { font-weight: 600; font-size: 1.05rem; }
.pi-total { font-size: 1.3rem; font-weight: 700; }
.pi-actions { margin: 16px 0 0; }
.pi-barcode { margin: 16px 0 0; }
.pi-barcode img { display: block; width: 100%; max-width: 340px; padding: 10px; background: #fff; border-radius: var(--radius); image-rendering: pixelated; }
.pi-foot { margin-top: 24px; font-size: 0.85rem; text-align: center; }

/* AI dnevnik (Sustav → AI dnevnik): poruke, odgovor i rezultati alata kao preformatiran tekst */
.log-pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 28rem; overflow: auto; margin: 6px 0 0; padding: 10px 12px;
  background: var(--surface-2); border-radius: var(--radius); font-family: ui-monospace, monospace; font-size: 12px; }
.log-turn { margin: 0 0 14px; }
.log-turn > summary { cursor: pointer; }

/* Postavke sustava → Održavanje: poruka svima i obavijest koju korisnik može zatvoriti */
.maintenance-banner { margin: 0 0 12px; padding: 8px 12px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-strong); font-size: 0.9rem; }
.announcement { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--info-bg); color: var(--info); font-size: 0.9rem; }
.announcement p { margin: 0; flex: 1; }

/* Ponude: prikaz očišćenog HTML-a iz uređivača (docs/llm/OFFERS.md) */
.offer-body { line-height: 1.5; overflow-wrap: anywhere; }
.offer-body img { max-width: 100%; height: auto; }
.offer-body table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.offer-body th, .offer-body td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.offer-body th { background: var(--surface-2); }
.offer-body h1, .offer-body h2, .offer-body h3, .offer-body h4 { margin: 12px 0 4px; }
.offer-body ul, .offer-body ol { padding-left: 1.5em; }
.offer-body hr[data-pagebreak] { border: 0; border-top: 2px dashed var(--line); margin: 16px 0; }
.offer-body hr[data-pagebreak]::after { content: "nova stranica"; display: block; text-align: center; font-size: 11px; color: var(--muted); }
