/* =====================================================================
   Pudar — Kućni Rashodi
   Tokeni, teme, layout, print.
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ---------------------------------------------------------------
   TEME
   Kategorijske boje su tokeni jer ih JS čita preko getComputedStyle
   pri svakom renderu grafova. Nema hardkodovanih hex vrijednosti u JS-u.
   --------------------------------------------------------------- */

:root,
[data-theme="dark"] {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #18181f;
  --surface3: #1f1f28;
  --border: #ffffff12;
  --border-strong: #ffffff20;
  --text: #f0ede8;
  --text-muted: #8a8890;
  --text-dim: #4d4c54;

  --accent: #c8ff57;          /* ispuna */
  --accent-text: #c8ff57;     /* akcenat kao boja teksta */
  --accent-fg: #0a0a0f;       /* tekst NA akcentu */
  --accent-soft: #c8ff5714;
  --accent-hover: #b8ef47;

  --ok: #00d4aa;
  --warn: #ffd166;
  --err: #ff3d71;
  --ok-soft: #00d4aa1f;
  --warn-soft: #ffd1661a;
  --err-soft: #ff3d711a;

  --cat-struja: #ff6b35;
  --cat-infostan: #7b61ff;
  --cat-zgrada: #00d4aa;
  --cat-a1: #4aa8ff;
  --cat-mts: #c8ff57;
  --cat-fallback: #8a8890;

  --grid-line: rgba(200, 255, 87, 0.02);
  --shadow: 0 1px 2px #0006, 0 8px 24px #0003;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3f3ef;
  --surface: #ffffff;
  --surface2: #f7f7f3;
  --surface3: #eeeee8;
  --border: #00000014;
  --border-strong: #00000024;
  --text: #17171b;
  --text-muted: #66656c;
  --text-dim: #a5a4ab;

  --accent: #c8ff57;
  --accent-text: #4a6b00;
  --accent-fg: #0a0a0f;
  --accent-soft: #c8ff5740;
  --accent-hover: #b8ef47;

  --ok: #00806b;
  --warn: #9a6b00;
  --err: #d1104a;
  --ok-soft: #00806b14;
  --warn-soft: #9a6b0014;
  --err-soft: #d1104a12;

  --cat-struja: #d2521a;
  --cat-infostan: #5b41d6;
  --cat-zgrada: #00806b;
  --cat-a1: #1f6fd0;
  --cat-mts: #6f8a00;
  --cat-fallback: #66656c;

  --grid-line: rgba(0, 0, 0, 0.025);
  --shadow: 0 1px 2px #0000000a, 0 8px 24px #00000008;
  color-scheme: light;
}

/* Tipografska skala */
:root {
  --fs-micro: 10px;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 26px;
  --fs-2xl: 34px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px;

  --font-display: 'DM Serif Display', Georgia, serif;
  --font-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.2s, color 0.2s;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------------------------------------------------------
   LOADING / SKELETON
   --------------------------------------------------------------- */

.loading-screen {
  position: fixed; inset: 0; z-index: 999;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--sp-4);
}
.loading-screen[hidden] { display: none; }
.spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent-text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-size: var(--fs-xs); color: var(--text-muted); letter-spacing: 0.1em;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-card { height: 96px; }
.skeleton-row { height: 44px; margin-bottom: 1px; }
.skeleton-chart { height: 180px; }

/* ---------------------------------------------------------------
   LAYOUT
   --------------------------------------------------------------- */

.wrap {
  position: relative; z-index: 1;
  max-width: 1200px; margin: 0 auto;
  padding: 0 var(--sp-6) 60px;
}

header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  padding: var(--sp-8) 0 var(--sp-6);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-6);
}
.logo-label {
  font-size: var(--fs-micro); letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: var(--sp-1);
}
.logo-title { font-family: var(--font-display); font-size: var(--fs-xl); line-height: 1; }
.logo-title span { color: var(--accent-text); }
.header-right { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* Traka lokacije */
.location-bar {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); margin-bottom: var(--sp-5);
}
.location-bar[data-readonly="true"] {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}
.location-name { font-size: var(--fs-base); }
.location-name strong { color: var(--accent-text); font-weight: 500; }
.location-bar[data-readonly="true"] .location-name strong { color: var(--warn); }
.badge {
  font-size: var(--fs-micro); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px var(--sp-2); border-radius: var(--r-sm);
  background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border);
}
.badge.readonly { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.location-bar .spacer { margin-left: auto; }

.month-nav { display: flex; align-items: center; gap: var(--sp-2); }
.nav-current { font-size: var(--fs-sm); min-width: 120px; text-align: center; }

/* ---------------------------------------------------------------
   DUGMAD
   --------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px var(--sp-4); border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-mono); font-size: var(--fs-sm);
  cursor: pointer; transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent-text); color: var(--accent-text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent); color: var(--accent-fg);
  border-color: var(--accent); font-weight: 500;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover); color: var(--accent-fg); border-color: var(--accent-hover);
}
.btn-ghost { border-color: transparent; }
.btn-danger:hover:not(:disabled) { border-color: var(--err); color: var(--err); }
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  background: var(--surface2); font-size: var(--fs-md);
}
.btn-sm { padding: 6px var(--sp-3); font-size: var(--fs-xs); }

/* ---------------------------------------------------------------
   TABOVI
   --------------------------------------------------------------- */

.tabs {
  display: flex; gap: 2px; width: fit-content; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-1); margin-bottom: var(--sp-6);
  overflow-x: auto;
}
.tab {
  padding: 7px 18px; border-radius: 5px; border: 1px solid transparent;
  background: none; color: var(--text-muted);
  font-family: var(--font-mono); font-size: var(--fs-sm);
  cursor: pointer; white-space: nowrap; transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] {
  background: var(--surface2); color: var(--accent-text); border-color: var(--border-strong);
}
.panel[hidden] { display: none; }

/* ---------------------------------------------------------------
   KARTICE / STATISTIKA
   --------------------------------------------------------------- */

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--sp-3); margin-bottom: var(--sp-6);
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-5);
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: var(--accent);
}
.stat-card.c2::after { background: var(--cat-struja); }
.stat-card.c3::after { background: var(--cat-infostan); }
.stat-card.c4::after { background: var(--ok); }
.stat-label {
  font-size: var(--fs-micro); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: var(--sp-2);
}
.stat-value {
  font-family: var(--font-display); font-size: 22px;
  line-height: 1.15; margin-bottom: var(--sp-1);
  overflow-wrap: anywhere;
}
.stat-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.stat-sub.up { color: var(--err); }
.stat-sub.down { color: var(--ok); }
.stat-sub.flat { color: var(--text-muted); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-6); margin-bottom: var(--sp-5);
}
.card-title { font-family: var(--font-display); font-size: 18px; }
.card-title.sm { font-size: var(--fs-md); }
.card-subtitle { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--sp-1); }
.card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-6);
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); margin-bottom: var(--sp-5); }
.two-col > .card { margin-bottom: 0; }

/* ---------------------------------------------------------------
   GRAFOVI
   --------------------------------------------------------------- */

.chart-legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--text-muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

.bars {
  display: flex; align-items: flex-end; gap: var(--sp-2);
  height: 200px; padding-bottom: 28px; position: relative;
}
.bars::before {
  content: ''; position: absolute; bottom: 28px; left: 0; right: 0;
  height: 1px; background: var(--border);
}
.bar-group {
  flex: 1; height: 100%; position: relative;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding-bottom: 24px; gap: 2px;
}
.bar-stack { display: flex; flex-direction: column-reverse; gap: 1px; }
.bar {
  min-height: 2px; border-radius: 2px;
  transition: opacity 0.15s, transform 0.15s;
  animation: growUp 0.35s ease-out;
  transform-origin: bottom;
}
.bar-stack .bar:last-child { border-radius: 3px 3px 0 0; }
.bar-group:hover .bar { opacity: 0.75; }
@keyframes growUp { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.bar-label {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  font-size: var(--fs-micro); color: var(--text-muted); white-space: nowrap;
}
.bar-group[data-current="true"] .bar-label { color: var(--accent-text); }

.donut-wrap { position: relative; width: 168px; height: 168px; margin: 0 auto var(--sp-4); }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 8px; text-align: center;
}
.donut-total { font-family: var(--font-display); line-height: 1.1; overflow-wrap: anywhere; }
.donut-label { font-size: var(--fs-micro); color: var(--text-muted); margin-top: 2px; }

.breakdown { display: flex; flex-direction: column; gap: var(--sp-2); }
.breakdown-row { display: flex; align-items: center; gap: var(--sp-2); }
.breakdown-dot { width: 7px; height: 7px; border-radius: 2px; flex-shrink: 0; }
.breakdown-name { flex: 1; font-size: var(--fs-xs); color: var(--text-muted); }
.breakdown-track { flex: 2; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.breakdown-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }
.breakdown-val { font-size: var(--fs-xs); min-width: 88px; text-align: right; }

.total-line { display: flex; align-items: baseline; gap: var(--sp-2); margin: var(--sp-2) 0 var(--sp-4); }
.total-val { font-family: var(--font-display); font-size: var(--fs-2xl); line-height: 1; overflow-wrap: anywhere; }
.total-cur { font-size: var(--fs-md); color: var(--text-muted); }

.mini-list { display: flex; flex-direction: column; }
.mini-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 7px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm);
}
.mini-row:last-child { border-bottom: none; }
.mini-rank { font-size: var(--fs-xs); color: var(--text-dim); min-width: 16px; }
.mini-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.mini-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-val { flex-shrink: 0; }
.mini-meta { font-size: var(--fs-micro); color: var(--text-dim); flex-shrink: 0; }
.mini-head {
  font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); margin-bottom: var(--sp-2);
}

.progress-row { margin-bottom: var(--sp-3); }
.progress-head { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: var(--fs-sm); }
.progress-head span:first-child { color: var(--text-muted); }
.progress-track { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }

.quick-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------------------------------------------------------------
   FILTERI
   --------------------------------------------------------------- */

.filters {
  display: flex; gap: var(--sp-2); margin-bottom: var(--sp-4);
  flex-wrap: wrap; align-items: center;
}
.field {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 8px var(--sp-3);
  color: var(--text); font-family: var(--font-mono); font-size: var(--fs-sm);
  outline: none; transition: border-color 0.15s;
}
.field:focus { border-color: var(--accent-text); }
select.field { cursor: pointer; }
select.field option { background: var(--surface2); color: var(--text); }

.search-wrap { position: relative; }
.search-wrap .field { padding-left: 30px; width: 200px; }
.search-icon {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none; font-size: var(--fs-base);
}
.filters .spacer { margin-left: auto; }
.row-count { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---------------------------------------------------------------
   TABELA — prava <table>, ne div grid
   --------------------------------------------------------------- */

.table-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
}
.table-scroll { max-height: 560px; overflow-y: auto; overflow-x: auto; }

table.bills { width: 100%; border-collapse: collapse; }
table.bills thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface2);
  padding: var(--sp-3) var(--sp-4);
  text-align: left; font-weight: 400;
  font-size: var(--fs-micro); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table.bills th button {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit;
  display: inline-flex; align-items: center; gap: 4px;
}
table.bills th button:hover { color: var(--text); }
table.bills th .sort-arrow { opacity: 0.35; }
table.bills th[aria-sort="ascending"] button,
table.bills th[aria-sort="descending"] button { color: var(--accent-text); }
table.bills th[aria-sort="ascending"] .sort-arrow,
table.bills th[aria-sort="descending"] .sort-arrow { opacity: 1; }

table.bills tbody tr { border-bottom: 1px solid var(--border); transition: background 0.12s; }
table.bills tbody tr:last-child { border-bottom: none; }
table.bills tbody tr:hover { background: var(--surface2); }
table.bills td { padding: var(--sp-3) var(--sp-4); vertical-align: middle; }

.c-num { color: var(--text-dim); font-size: var(--fs-xs); width: 44px; }
.c-name { min-width: 180px; }
.name-line { display: flex; align-items: center; gap: 9px; }
.name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-note { font-size: var(--fs-xs); color: var(--text-muted); margin-left: 15px; }
.c-amount { text-align: right; white-space: nowrap; font-weight: 500; }
.c-date { color: var(--text-muted); font-size: var(--fs-sm); white-space: nowrap; }
.c-date small { display: block; font-size: var(--fs-micro); color: var(--text-dim); }
.c-actions { width: 108px; }

.cat-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.pill {
  display: inline-flex; align-items: center; padding: 3px var(--sp-2);
  border-radius: 4px; font-size: var(--fs-micro);
  letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
  border: 1px solid transparent;
}
.pill-cat { background: var(--surface2); border-color: var(--border-strong); }
.status-btn {
  font: inherit; cursor: pointer;
  background: none; border: 1px solid transparent;
}
.status-btn:disabled { cursor: default; }
.status-paid { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-soft); }
.status-pending { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-soft); }
.status-overdue { background: var(--err-soft); color: var(--err); border-color: var(--err-soft); }

.actions { display: flex; gap: var(--sp-1); justify-content: flex-end; }
.action-btn {
  width: 28px; height: 28px; border-radius: 5px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); transition: border-color 0.12s, color 0.12s;
}
.action-btn:hover { border-color: var(--accent-text); color: var(--accent-text); }
.action-btn.del:hover { border-color: var(--err); color: var(--err); }
.action-btn.pdf:hover { border-color: var(--ok); color: var(--ok); }

/* Ispod 760px tabela postaje lista kartica.
   Nijedna kolona se ne sakriva — akcije i status ostaju dostupni. */
@media (max-width: 760px) {
  .table-scroll { max-height: none; overflow: visible; }
  table.bills thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.bills tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--sp-2) var(--sp-3);
    padding: var(--sp-4);
    align-items: center;
  }
  table.bills td { padding: 0; }
  .c-num { display: none; }
  .c-name { grid-column: 1; min-width: 0; }
  .c-amount { grid-column: 2; text-align: right; font-size: var(--fs-md); }
  .c-cat { grid-column: 1; }
  .c-date { grid-column: 2; text-align: right; }
  .c-status { grid-column: 1; }
  .c-actions { grid-column: 2; width: auto; }
  .actions { opacity: 1; }
}

/* ---------------------------------------------------------------
   PRAZNA STANJA
   --------------------------------------------------------------- */

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 56px var(--sp-5); gap: var(--sp-3); text-align: center;
}
.empty-icon { font-size: 30px; opacity: 0.35; }
.empty-title { font-family: var(--font-display); font-size: var(--fs-md); }
.empty-text { font-size: var(--fs-sm); color: var(--text-muted); max-width: 340px; }

/* ---------------------------------------------------------------
   MODALI — native <dialog>: focus trap i Escape su besplatni
   --------------------------------------------------------------- */

dialog {
  border: 1px solid var(--border-strong); border-radius: var(--r-xl);
  background: var(--surface); color: var(--text);
  padding: var(--sp-8); width: min(560px, calc(100vw - 32px));
  max-height: 90vh; box-shadow: var(--shadow);
}
dialog::backdrop { background: #0a0a0fdd; backdrop-filter: blur(6px); }
dialog[open] { animation: dialogIn 0.18s ease-out; }
@keyframes dialogIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.dialog-close {
  position: absolute; top: var(--sp-4); right: var(--sp-4);
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; font-size: var(--fs-md);
  display: inline-flex; align-items: center; justify-content: center;
}
.dialog-close:hover { border-color: var(--err); color: var(--err); }
.dialog-title { font-family: var(--font-display); font-size: 22px; margin-bottom: var(--sp-1); padding-right: 40px; }
.dialog-sub { font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--sp-6); }

#billDialog { position: relative; overflow-y: auto; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.form-group { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.form-group.full { grid-column: 1 / -1; }
.form-label {
  font-size: var(--fs-micro); letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted);
}
.form-input, .form-select, .form-textarea {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 10px 13px;
  color: var(--text); font-family: var(--font-mono); font-size: var(--fs-base);
  outline: none; width: 100%; transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-input[aria-invalid="true"] { border-color: var(--err); }
.form-textarea { resize: vertical; min-height: 68px; }
.form-error { font-size: var(--fs-xs); color: var(--err); min-height: 15px; }
.form-hint { font-size: var(--fs-xs); color: var(--text-muted); }
.date-parts { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: var(--sp-1); }
.form-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-6); }

.info-strip {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent-text) 22%, transparent);
  border-radius: var(--r-sm); padding: 9px 13px;
  font-size: var(--fs-xs); color: var(--text-muted);
  display: flex; align-items: center; gap: var(--sp-2);
}
.info-strip strong { color: var(--accent-text); font-weight: 500; }

/* Upload */
.upload-area {
  border: 1px dashed var(--border-strong); border-radius: var(--r-md);
  padding: var(--sp-5); text-align: center; cursor: pointer;
  background: var(--surface2); transition: border-color 0.15s, background 0.15s;
}
.upload-area:hover, .upload-area.drag {
  border-color: var(--accent-text); background: var(--accent-soft);
}
.upload-area input { display: none; }
.upload-icon { font-size: 24px; margin-bottom: var(--sp-2); opacity: 0.5; }
.upload-text { font-size: var(--fs-sm); color: var(--text-muted); }
.upload-text span { color: var(--accent-text); }
.file-chip {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px 14px; border-radius: var(--r-md);
  background: var(--ok-soft); border: 1px solid var(--ok-soft);
  font-size: var(--fs-sm); color: var(--ok);
}
.file-chip-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button {
  background: none; border: none; cursor: pointer;
  color: var(--err); font-size: var(--fs-md); line-height: 1; padding: 2px;
}

/* PDF viewer */
#pdfDialog { display: none; flex-direction: column; width: min(860px, calc(100vw - 32px)); height: 88vh; }
#pdfDialog[open] { display: flex; }
.pdf-toolbar { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.pdf-frame-wrap {
  flex: 1; min-height: 0; border-radius: var(--r-md);
  overflow: hidden; background: var(--surface3);
  border: 1px solid var(--border);
}
.pdf-frame-wrap iframe { width: 100%; height: 100%; border: none; display: block; }
.pdf-fallback { padding: var(--sp-6); text-align: center; color: var(--text-muted); font-size: var(--fs-sm); }

/* Potvrda brisanja */
#confirmDialog { width: min(420px, calc(100vw - 32px)); }
#confirmDialog .dialog-sub { margin-bottom: var(--sp-5); }

/* ---------------------------------------------------------------
   ARHIVA
   --------------------------------------------------------------- */

.archive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-4); }
.archive-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-3);
  transition: border-color 0.15s, transform 0.15s;
}
.archive-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.archive-card h3 { font-family: var(--font-display); font-size: var(--fs-md); font-weight: 400; }
.archive-meta { font-size: var(--fs-xs); color: var(--text-muted); }
.archive-figures { display: flex; gap: var(--sp-5); }
.archive-figure-val { font-family: var(--font-display); font-size: var(--fs-lg); }
.archive-figure-lbl { font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
.archive-actions { display: flex; gap: var(--sp-2); margin-top: auto; padding-top: var(--sp-2); }

/* ---------------------------------------------------------------
   TOAST
   --------------------------------------------------------------- */

.toaster {
  position: fixed; bottom: var(--sp-5); right: var(--sp-5); z-index: 1000;
  display: flex; flex-direction: column; gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-left-width: 3px; border-radius: var(--r-md);
  padding: 11px var(--sp-4); font-size: var(--fs-sm);
  display: flex; align-items: center; gap: 9px;
  max-width: 320px; box-shadow: var(--shadow);
  animation: toastIn 0.2s ease; pointer-events: auto;
}
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--err); }
.toast.info { border-left-color: var(--accent); }
.toast-icon { flex-shrink: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------
   SCROLLBAR
   --------------------------------------------------------------- */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ---------------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------------- */

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .wrap { padding: 0 var(--sp-4) 60px; }
  header { padding: var(--sp-4) 0 var(--sp-5); }
  .logo-title { font-size: 22px; }
  .header-right { width: 100%; justify-content: space-between; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 7px var(--sp-2); font-size: var(--fs-xs); }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
  .stat-card { padding: var(--sp-4); }
  .stat-value { font-size: 17px; }
  .card { padding: var(--sp-4); }
  .card-header { flex-direction: column; }
  .search-wrap .field { width: 100%; }
  .search-wrap { flex: 1 1 100%; }
  .filters .spacer { margin-left: 0; flex-basis: 100%; }
  dialog { padding: var(--sp-6) var(--sp-5); }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: 1; }
  .total-val { font-size: 28px; }
  .toaster { left: var(--sp-4); right: var(--sp-4); bottom: var(--sp-4); }
  .toast { max-width: none; }
  .location-bar .spacer { margin-left: 0; flex-basis: 100%; }
}

/* ---------------------------------------------------------------
   PRINT — "Export to PDF" i "Print reports" idu kroz ovo.
   Browser Print -> Save as PDF. Bez jsPDF-a, dijakritika radi.
   --------------------------------------------------------------- */

@media print {
  @page { margin: 14mm; }

  :root, [data-theme="dark"], [data-theme="light"] {
    --bg: #fff; --surface: #fff; --surface2: #fff; --surface3: #fff;
    --text: #000; --text-muted: #444; --text-dim: #666;
    --border: #ccc; --border-strong: #999;
    --accent-text: #000; --shadow: none;
  }

  body { background: #fff; font-size: 10pt; }
  body::before { display: none; }

  header, .tabs, .filters, .actions, .quick-actions,
  .btn, .action-btn, .toaster, dialog, .archive-actions,
  .month-nav, .location-bar .spacer { display: none !important; }

  .wrap { max-width: none; padding: 0; }
  .panel[hidden] { display: none !important; }
  .card, .stat-card, .table-card { break-inside: avoid; border: 1px solid #ccc; }
  .table-scroll { max-height: none; overflow: visible; }
  table.bills thead { display: table-header-group; }
  table.bills thead th { position: static; background: #fff; }
  table.bills tbody tr { break-inside: avoid; }
  .c-actions { display: none; }

  .print-header { display: block !important; margin-bottom: 12mm; }
  .print-header h1 { font-family: var(--font-display); font-size: 18pt; }
  .print-header p { font-size: 9pt; color: #444; }
}

.print-header { display: none; }
