/*
 * Spoločná téma HUB-u: farby (tmavá + Solarized Light), stavový riadok dole,
 * hlásenia a dialóg. Používajú ju Financie, Stav systémov, Firmy, prihlásenie
 * aj hlavná stránka.
 */
:root{
  --font-mono:"JetBrains Mono",ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  --sb-h:26px;
  --ov:1 0 0;
  --bg:oklch(0.185 0.013 258);
  --bg-pop:oklch(0.16 0.014 258);
  --fg:oklch(0.88 0.01 260);
  --fg-strong:oklch(0.96 0.01 260);
  --fg-mute:oklch(0.68 0.01 260);
  --accent:oklch(0.74 0.16 var(--hue,178));
  --on-accent:oklch(0.17 0.02 258);
  --primary-bg:oklch(0.3 0.1 var(--hue,178)/.5);
  --primary-fg:oklch(0.97 0.05 var(--hue,178));
  --dim:oklch(var(--ov) / .54);
  --dim2:oklch(var(--ov) / .68);
  --line:oklch(var(--ov) / .12);
  --ok:oklch(0.72 0.17 145);
  --bad:oklch(0.66 0.19 25);
  --warn:oklch(0.75 0.14 70);
  --firma-mosi:oklch(0.74 0.12 165);
  --firma-vmfin:oklch(0.8 0.1 90);
  --typ-cp:oklch(0.72 0.14 300);
  --typ-dl:oklch(0.74 0.1 235);
  color-scheme:dark;
}
/* Solarized Light */
:root[data-theme="light"]{
  --ov:0 0 0;
  --bg:#fdf6e3;
  --bg-pop:#eee8d5;
  --fg:#586e75;
  --fg-strong:#073642;
  --fg-mute:#5f7478;
  --accent:oklch(0.55 0.11 var(--hue,178));
  --on-accent:#fdf6e3;
  --primary-bg:oklch(0.92 0.05 var(--hue,178));
  --primary-fg:oklch(0.36 0.08 var(--hue,178));
  --dim:oklch(var(--ov) / .6);
  --dim2:oklch(var(--ov) / .74);
  --line:oklch(var(--ov) / .13);
  --ok:#859900;
  --bad:#dc322f;
  --warn:#b58900;
  --firma-mosi:oklch(0.52 0.1 170);
  --firma-vmfin:oklch(0.58 0.12 85);
  --typ-cp:#6c71c4;
  --typ-dl:#268bd2;
  color-scheme:light;
}
:root[data-theme="light"] input[type=date]::-webkit-calendar-picker-indicator{ filter:none; }

/* ── stavový riadok dole (ako vim / tmux) ── */
.statusbar{
  position:fixed; left:0; right:0; bottom:0; z-index:40; height:var(--sb-h);
  display:flex; align-items:stretch; background:var(--bg-pop); border-top:1px solid var(--line);
  font-size:11px; color:var(--dim2); white-space:nowrap; overflow-x:auto; scrollbar-width:none;
}
.statusbar::-webkit-scrollbar{ display:none; }
.statusbar .sb-item, .statusbar a.sb-item:visited{
  font:inherit; display:flex; align-items:center; height:100%; padding:0 12px; margin:0; border:0; border-right:1px solid var(--line);
  color:inherit; text-decoration:none; background:none; flex:none; line-height:1; white-space:pre;
}
.statusbar a.sb-item:hover, .statusbar button.sb-item:hover{ color:var(--fg-strong); background:oklch(var(--ov) / .05); cursor:pointer; }
.statusbar .sb-mode{ background:var(--accent); color:var(--on-accent); font-weight:700; letter-spacing:.03em; }
.statusbar .sb-spacer{ flex:1; border-right:0; }
.statusbar .sb-clock{ border-right:0; font-variant-numeric:tabular-nums; color:var(--fg-strong); }
.statusbar .sb-logout:hover{ color:var(--bad) !important; }
.statusbar .sb-ico{ width:11px; height:11px; display:block; margin-right:6px; }
@media (max-width:640px){ .statusbar .sb-user, .statusbar [data-date], .statusbar .sb-opt{ display:none; } }
.sb-ok{ color:var(--ok); } .sb-warn{ color:var(--warn); } .sb-bad{ color:var(--bad); }

/* ── hlásenia v štýle logu ── */
.toasts{ position:fixed; right:16px; bottom:calc(var(--sb-h) + 14px); z-index:60; display:flex; flex-direction:column; gap:8px; max-width:min(460px, calc(100vw - 32px)); }
.toast{
  display:flex; align-items:baseline; gap:10px; padding:10px 12px; background:var(--bg-pop);
  border:1px solid var(--line); border-left:3px solid var(--ok); font-size:12.5px; color:var(--fg-strong);
  box-shadow:0 10px 30px -12px rgba(0,0,0,.6); animation:toast-in .18s ease-out;
}
.toast.err{ border-left-color:var(--bad); }
.toast .t-tag{ color:var(--ok); font-weight:700; white-space:pre; flex:none; }
.toast.err .t-tag{ color:var(--bad); }
.toast .t-msg{ flex:1; }
.toast .t-msg a{ color:inherit; }
.toast .t-x{ background:none; border:0; color:var(--dim); cursor:pointer; font:inherit; font-size:15px; line-height:1; padding:0 2px; }
.toast .t-x:hover{ color:var(--fg-strong); }
.toast.out{ opacity:0; transform:translateX(12px); transition:all .2s; }
@keyframes toast-in{ from{ opacity:0; transform:translateY(8px); } }

/* ── dialóg [y/N] ── */
.dlg-backdrop{ position:fixed; inset:0; z-index:70; background:oklch(0 0 0/.55); display:flex; align-items:center; justify-content:center; padding:16px; animation:toast-in .12s ease-out; }
.dlg{ width:min(480px, 100%); background:var(--bg-pop); border:1px solid var(--accent); box-shadow:0 20px 60px -20px rgba(0,0,0,.7); }
.dlg-head{ padding:8px 14px; font-size:11px; color:var(--accent); border-bottom:1px solid var(--line); }
.dlg-body{ padding:18px 14px 8px; font-size:13px; color:var(--fg-strong); line-height:1.6; }
.dlg-q{ color:var(--warn); font-weight:700; }
.dlg-yn{ color:var(--dim); }
.dlg-label{ display:flex; flex-direction:column; gap:5px; margin-top:14px; }
.dlg-input{ width:100%; }
.dlg-actions{ display:flex; justify-content:flex-end; gap:10px; padding:14px; }

/* ── tabuľky: sumy zarovnané (desatinné čiarky pod sebou), kurzor, prázdne stavy ── */
td.amt, th.amt{ text-align:right; white-space:nowrap; }
.diff.mut{ color:var(--dim2); }
tbody tr:not(.empty-row):hover > td:first-child{ box-shadow:inset 2px 0 0 var(--accent); }
table.items-table tbody tr:hover > td:first-child{ box-shadow:none; }
table.numbered tbody tr:not(.empty-row):hover td:first-child::before{ content:">"; color:var(--accent); font-weight:700; }
.empty-row td::before, .empty-note::before{ content:"// "; color:var(--dim); }
.empty-row td, .empty-note{ font-style:normal; }
.empty-row a{ text-decoration:none; }
.abar{ white-space:nowrap; font-size:11px; letter-spacing:-.5px; color:var(--dim); }
.abar-on{ color:var(--accent); }
.abar-off{ color:oklch(var(--ov) / .16); }


/* ── spoločný shell: spodná navigácia (mobil), menu Viac, hľadanie, plávajúci asistent ── */
:root{ --bn-h:0px; }
.bnav{ display:none; }
.ha-fab{
  position:fixed; right:16px; bottom:calc(var(--sb-h) + 14px); z-index:45; font:inherit; font-size:12.5px; font-weight:600;
  padding:9px 14px; background:var(--bg-pop); color:var(--accent); border:1px solid var(--accent); cursor:pointer;
  box-shadow:0 8px 24px -10px rgba(0,0,0,.6);
}
.ha-fab:hover{ background:var(--primary-bg); color:var(--primary-fg); }
body.ha-open .ha-fab, body.no-fab .ha-fab{ display:none; }
.sh-sheet{ position:fixed; inset:0; z-index:80; background:oklch(0 0 0/.55); display:flex; align-items:flex-start; justify-content:center; padding:8vh 12px 12px; }
.sh-sheet[hidden], .ha-panel[hidden]{ display:none; }
.sh-sheet-in{ width:min(560px,100%); max-height:84vh; overflow:auto; background:var(--bg-pop); border:1px solid var(--accent); box-shadow:0 20px 60px -20px rgba(0,0,0,.7); }
.sh-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; padding:8px 12px; font-size:11px; color:var(--accent); border-bottom:1px solid var(--line); }
.sh-head button{ background:none; border:0; color:var(--dim2); font:inherit; font-size:12px; cursor:pointer; padding:6px 8px; min-height:32px; }
.sh-head button:hover{ color:var(--fg-strong); }
.sh-head button[data-close]{ font-size:20px; line-height:1; }
.sh-big{ display:block; width:calc(100% - 24px); margin:12px; padding:12px; font:inherit; font-size:14px; text-align:left; background:oklch(var(--ov) / .04); color:var(--fg-strong); border:1px solid var(--line); cursor:pointer; }
.sh-links{ display:grid; grid-template-columns:1fr 1fr; gap:1px; background:var(--line); border-top:1px solid var(--line); border-bottom:1px solid var(--line); }
.sh-links a{ background:var(--bg-pop); padding:14px 14px; font-size:13.5px; color:var(--fg); text-decoration:none; min-height:48px; display:flex; align-items:center; }
.sh-links a:hover, .sh-links a:active{ background:oklch(var(--ov) / .06); color:var(--accent); }
.sh-row{ display:flex; justify-content:space-between; padding:6px 12px; }
.sh-row a, .sh-row button{ font:inherit; font-size:12.5px; color:var(--dim2); background:none; border:0; text-decoration:none; padding:12px 8px; cursor:pointer; }
.sh-row a:hover, .sh-row button:hover{ color:var(--accent); }
.sh-search #sh-q{ display:block; width:calc(100% - 24px); margin:12px; padding:12px; font:inherit; font-size:16px; background:oklch(var(--ov) / .04); color:var(--fg-strong); border:1px solid var(--line); }
.sh-search #sh-q:focus{ outline:none; border-color:var(--accent); }
.sh-res{ padding:0 0 4px; }
.sh-grp{ padding:8px 14px 4px; font-size:10px; letter-spacing:.1em; text-transform:uppercase; color:var(--dim); }
.sh-res a{ display:block; padding:9px 14px; text-decoration:none; color:var(--fg); border-left:2px solid transparent; }
.sh-res a .t{ font-size:13px; color:var(--fg-strong); }
.sh-res a .p{ font-size:11px; color:var(--dim2); }
.sh-res a.sel, .sh-res a:hover{ background:oklch(var(--ov) / .06); border-left-color:var(--accent); }
.sh-none{ padding:14px; font-size:12.5px; color:var(--dim); }
.sh-hint{ padding:8px 14px; font-size:10.5px; color:var(--dim); border-top:1px solid var(--line); }
.sh-hint kbd{ font:inherit; border:1px solid var(--line); padding:0 4px; }

.ha-panel{
  position:fixed; right:0; top:0; bottom:var(--sb-h); width:min(420px,100vw); z-index:75; display:flex; flex-direction:column;
  background:var(--bg-pop); border-left:1px solid var(--accent); box-shadow:-20px 0 50px -30px rgba(0,0,0,.7);
}
.ha-log{ flex:1; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:10px; font-size:13px; line-height:1.55; }
.ha-empty{ color:var(--dim); font-size:12.5px; }
.ha-msg{ padding:9px 11px; border:1px solid var(--line); word-break:break-word; }
.ha-msg.me{ background:oklch(var(--ov) / .04); align-self:flex-end; max-width:92%; }
.ha-msg .ha-who{ display:block; font-size:10px; letter-spacing:.08em; text-transform:uppercase; color:var(--accent); margin-bottom:3px; }
.ha-msg.me .ha-who{ color:var(--dim); }
.ha-msg .dim{ color:var(--dim); } .ha-msg .bad{ color:var(--bad); } .ha-msg .ok{ color:var(--ok); }
.ha-msg a.lnk{ color:var(--accent); }
.ha-akcia{ margin-top:10px; padding:9px; border:1px solid var(--accent); background:var(--primary-bg); }
.ha-akcia .tx{ font-size:12.5px; color:var(--primary-fg); margin-bottom:8px; }
.ha-akcia button{ font:inherit; font-size:13px; padding:9px 14px; margin-right:6px; min-height:40px; background:transparent; color:var(--fg); border:1px solid var(--line); cursor:pointer; }
.ha-akcia button.ok{ border-color:var(--ok); color:var(--ok); font-weight:700; }
.ha-akcia button:disabled{ opacity:.5; }
.ha-form{ display:flex; gap:6px; padding:10px; border-top:1px solid var(--line); }
.ha-form input[type=text]{ flex:1; min-width:0; font:inherit; font-size:16px; padding:10px; background:oklch(var(--ov) / .04); color:var(--fg-strong); border:1px solid var(--line); }
.ha-form input[type=text]:focus{ outline:none; border-color:var(--accent); }
.ha-form button{ font:inherit; font-size:16px; min-width:44px; min-height:44px; background:none; color:var(--accent); border:1px solid var(--line); cursor:pointer; }
.ha-form button:disabled{ opacity:.4; }

@media (max-width:860px){
  :root{ --bn-h:58px; }
  body::after{ content:""; display:block; height:var(--bn-h); }
  .bnav{
    display:flex; position:fixed; left:0; right:0; bottom:var(--sb-h); height:var(--bn-h); z-index:41;
    background:var(--bg-pop); border-top:1px solid var(--line);
  }
  .bnav a, .bnav button{
    flex:1; min-width:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; position:relative;
    font:inherit; font-size:10px; color:var(--dim2); background:none; border:0; text-decoration:none; cursor:pointer; padding:4px 2px;
  }
  .bnav i{ font-style:normal; font-size:19px; line-height:1; }
  .bnav .active{ color:var(--accent); }
  .bnav .active::before{ content:""; position:absolute; top:0; left:25%; right:25%; height:2px; background:var(--accent); }
  .bn-badge{ position:absolute; top:4px; left:calc(50% + 8px); font-size:9px; font-weight:700; line-height:1; padding:2px 4px; background:var(--bad); color:#fff; border-radius:8px; }
  .bn-badge[hidden]{ display:none; }
  .ha-fab{ display:none; }
  .sh-sheet{ align-items:flex-end; padding:0; }
  .sh-sheet-in{ width:100%; max-height:88vh; border-left:0; border-right:0; border-bottom:0; }
  .sh-search{ height:88vh; }
  .ha-panel{ width:100vw; border-left:0; }
  .sidebar{ display:none !important; }
}

/* ── farebné pásiky firiem v zoznamoch ── */
tr.fr-mosi > td:first-child{ box-shadow:inset 3px 0 0 var(--firma-mosi); }
tr.fr-vmfin > td:first-child{ box-shadow:inset 3px 0 0 var(--firma-vmfin); }

/* ── dotykové ovládanie: väčšie ciele, 16 px polia (iPhone nepriblíži stránku) ── */
@media (max-width:860px), (pointer:coarse){
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea{ font-size:16px !important; }
  button.btn, a.btn{ min-height:44px; display:inline-flex; align-items:center; }
  .tab-filter a{ padding:12px 14px; }
  .date-presets a, .date-presets button{ padding:7px 2px; }
  .actions a, .actions button{ padding:9px 6px; font-size:13px; min-height:36px; display:inline-flex; align-items:center; }
}

/* ── zoznamy ako karty na mobile (tabuľky s triedou cards-m) ── */
@media (max-width:640px){
  table.cards-m{ min-width:0; }
  .cards-m thead{ display:none; }
  .cards-m tbody{ display:block; }
  .cards-m tbody tr{ display:flex; flex-wrap:wrap; align-items:baseline; gap:3px 12px; padding:13px 14px; border-bottom:1px solid var(--line); position:relative; }
  .cards-m tbody tr:last-child{ border-bottom:0; }
  .cards-m tbody tr.empty-row{ display:block; }
  .cards-m tbody tr.fr-mosi{ border-left:3px solid var(--firma-mosi); }
  .cards-m tbody tr.fr-vmfin{ border-left:3px solid var(--firma-vmfin); }
  .cards-m td, .cards-m td:first-child{ padding-left:0 !important; padding-right:0 !important; }
  .cards-m td{ display:block; border:0; padding:0; text-align:left !important; white-space:normal !important; box-shadow:none !important; font-size:13px; min-width:0; }
  .cards-m td::before, .cards-m td:first-child::before{ content:none !important; }
  .cards-m td .actions{ max-width:none; margin:0; justify-content:flex-start; gap:2px 10px; }
  .cards-m td:last-child{ flex:1 1 100%; order:9; margin-top:6px; padding-top:6px; border-top:1px dashed var(--line); }
  .cards-m .row-sub{ white-space:normal; }
  /* Doklady: partner + suma navrchu, potom číslo, typ, firma, stav */
  .cards-doklady td:nth-child(4){ order:1; flex:1 1 55%; font-weight:700; font-size:14px; color:var(--fg-strong); }
  .cards-doklady td:nth-child(5){ order:2; margin-left:auto; font-weight:700; font-size:14px; }
  .cards-doklady td:nth-child(1){ order:3; color:var(--dim2); }
  .cards-doklady td:nth-child(2){ order:4; color:var(--dim2); }
  .cards-doklady td:nth-child(3){ order:5; }
  .cards-doklady td:nth-child(6){ order:6; flex:1 1 100%; }
  /* Príjmy / Výdavky: popis + suma navrchu, dátum a firma pod tým */
  .cards-pohyby td:nth-child(3){ order:1; flex:1 1 55%; font-size:14px; color:var(--fg-strong); }
  .cards-pohyby td:nth-child(4){ order:2; margin-left:auto; font-weight:700; font-size:14px; }
  .cards-pohyby td:nth-child(1){ order:3; color:var(--dim2); }
  .cards-pohyby td:nth-child(2){ order:4; }
  /* Kontakty: názov navrchu, ostatné pod ním */
  .cards-kontakty td:nth-child(1){ order:1; flex:1 1 100%; font-weight:700; font-size:14px; color:var(--fg-strong); }
  .cards-kontakty td:nth-child(2), .cards-kontakty td:nth-child(3), .cards-kontakty td:nth-child(4){ order:2; color:var(--dim2); font-size:12px; }
}

/* ── tooltip grafov (data-tip) ── */
.hub-tip{ position:fixed; z-index:90; max-width:min(320px, calc(100vw - 16px)); padding:7px 10px; font-size:12px; line-height:1.45; background:var(--bg-pop); color:var(--fg-strong); border:1px solid var(--accent); box-shadow:0 8px 24px -10px rgba(0,0,0,.6); pointer-events:none; }
.hub-tip[hidden]{ display:none; }
.toast .t-act{ font:inherit; font-size:12.5px; font-weight:700; color:var(--accent); background:none; border:1px solid var(--accent); padding:5px 10px; cursor:pointer; white-space:nowrap; min-height:32px; }
.toast .t-act:hover{ background:var(--primary-bg); color:var(--primary-fg); }
.toast .t-act:disabled{ opacity:.5; }

/* ── hromadné akcie v zozname (výber riadkov) ── */
label.sel{ display:inline-flex; align-items:center; margin-right:8px; vertical-align:middle; cursor:pointer; }
label.sel input{ width:16px; height:16px; margin:0; accent-color:var(--accent); cursor:pointer; }
.bulkbar{
  position:fixed; left:0; right:0; bottom:calc(var(--sb-h) + var(--bn-h)); z-index:42; display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  padding:10px clamp(12px,3vw,24px); background:var(--bg-pop); border-top:1px solid var(--accent); box-shadow:0 -10px 30px -18px rgba(0,0,0,.6);
}
.bulkbar[hidden]{ display:none; }
.bulkbar .bulk-n{ font-size:12.5px; color:var(--fg-strong); margin-right:6px; }
.bulkbar select{ font:inherit; font-size:13px; padding:7px 8px; background:oklch(var(--ov) / .04); color:var(--fg); border:1px solid var(--line); max-width:200px; }
body.bulk-on .statusbar{ z-index:43; }
.bulk-menu-wrap{ position:relative; display:inline-block; }
.bulk-menu{ position:absolute; bottom:calc(100% + 6px); left:0; min-width:200px; max-height:50vh; overflow-y:auto; background:var(--bg); border:1px solid var(--line); box-shadow:0 -6px 24px oklch(0 0 0 / .35); z-index:50; display:flex; flex-direction:column; }
.bulk-menu[hidden]{ display:none; }
.bulk-menu button{ font:inherit; font-size:13px; text-align:left; padding:9px 12px; background:transparent; color:var(--fg); border:0; border-bottom:1px solid var(--line); cursor:pointer; }
.bulk-menu button:last-child{ border-bottom:0; }
.bulk-menu button:hover{ background:oklch(var(--ov) / .07); }
@media (max-width:640px){ .cards-m td .sel{ margin-right:10px; } }
