:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --s-SV: #2a78d6;
  --s-TV: #eb6834;
  --s-KU: #1baf7a;
  --s-KF: #eda100;
  --s-CH: #e87ba4;
  --s-E1: #6250d6;
  --s-E2: #e34948;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --good-text: #0ca30c;
    --s-SV: #3987e5;
    --s-TV: #d95926;
    --s-KU: #199e70;
    --s-KF: #c98500;
    --s-CH: #d55181;
    --s-E1: #9085e9;
    --s-E2: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --ink: #f0efec; --ink-2: #c3c2b7;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --accent: #3987e5; --good-text: #0ca30c;
  --s-SV: #3987e5; --s-TV: #d95926; --s-KU: #199e70; --s-KF: #c98500; --s-CH: #d55181; --s-E1: #9085e9; --s-E2: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--plane); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 4px; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 0.95rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* hlavička */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); white-space: nowrap; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--surface-2); color: var(--ink); }
.user { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--ink-2); }
.ucet-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.ucet-link:hover, .ucet-link.active { background: var(--surface-2); text-decoration: none; }
.ucet-ikona { font-size: 0.95rem; }
.ucet-kratko { display: none; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

/* karty */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; }
.grid-tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid-2 { grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.tile .label { color: var(--ink-2); font-size: 0.85rem; display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 1.5rem; font-weight: 650; margin-top: 4px; line-height: 1.2; }
.tile .unit { font-size: 0.9rem; font-weight: 500; color: var(--ink-2); }
.tile .sub { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* tabuľky */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; font-size: 0.82rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

/* formuláre */
form.inline { display: inline; }
label { display: block; font-size: 0.85rem; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--axis); border-radius: 8px; padding: 8px 10px; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type=checkbox] { width: auto; min-height: 0; }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 0.95rem; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); align-items: end; }
.form-grid .wide { grid-column: 1 / -1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 8px 14px; min-height: 40px; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--axis); }
.btn-danger { background: transparent; color: var(--critical); border: 1px solid var(--critical); }
.btn-sm { padding: 4px 10px; min-height: 32px; font-size: 0.85rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* hlásenia */
.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; border: 1px solid var(--border); background: var(--surface); }
.flash-ok { border-left: 4px solid var(--good); }
.flash-err { border-left: 4px solid var(--critical); }
.errors { margin: 0; padding-left: 18px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.st { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.st::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.st-critical::before { background: var(--critical); }
.st-serious::before { background: var(--serious); }
.st-warning::before { background: var(--warning); }
.st-good::before { background: var(--good); }

/* filtre a grafy */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filters > div { min-width: 120px; }
.seg { display: inline-flex; border: 1px solid var(--axis); border-radius: 8px; overflow: hidden; }
.seg a { padding: 8px 12px; color: var(--ink-2); font-weight: 500; }
.seg a.on { background: var(--surface-2); color: var(--ink); }
.seg a:hover { text-decoration: none; background: var(--surface-2); }
.chart-box { position: relative; height: 280px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 0 0 8px; font-size: 0.85rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
details summary { cursor: pointer; color: var(--ink-2); font-size: 0.88rem; margin-top: 8px; }
.bar-compare { height: 8px; border-radius: 4px; background: var(--surface-2); position: relative; margin-top: 6px; }
.bar-compare i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }

/* prihlásenie */
.login-box { max-width: 380px; margin: 10vh auto 0; }
.login-box h1 { margin-bottom: 16px; }

@media (max-width: 600px) {
  .topbar { position: static; }
  .topbar-in { gap: 8px 12px; }
  .user { margin-left: auto; }
  .ucet-meno { display: none; }
  .ucet-kratko { display: inline; }
  .nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav a { white-space: nowrap; }
  .tile .value { font-size: 1.3rem; }
  .chart-box { height: 240px; }
  th, td { padding: 7px 8px; }
}
@media print {
  .topbar, .filters, .btn, form { display: none !important; }
  body { background: #fff; }
  .card { border: 0; }
}
