:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  /* stav dňa: aktuálne / čiastočne / neaktualizované */
  --fresh: #2a78d6;
  --partial: #86b6ef;
  --stale: #c3c2b7;
  --stale-wash: rgba(137, 135, 129, 0.10);
  --hover-wash: rgba(11, 11, 11, 0.05);
  --sel-wash: rgba(42, 120, 214, 0.12);
  --good: #006300;
  --critical: #d03b3b;
  --warning: #8a5a00;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --raised: #222220;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --fresh: #3987e5;
    --partial: #1c5cab;
    --stale: #52514e;
    --stale-wash: rgba(195, 194, 183, 0.07);
    --hover-wash: rgba(255, 255, 255, 0.06);
    --sel-wash: rgba(57, 135, 229, 0.18);
    --good: #0ca30c;
    --critical: #e66767;
    --warning: #fab219;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 var(--font);
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}
a { color: var(--accent-ink); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- hlavička / pätička ---------- */
.top, main, .foot { max-width: 1120px; margin: 0 auto; padding-inline: 20px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 18px 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
  background-image: linear-gradient(to top, #fff 0 0), linear-gradient(to top, #fff 0 0), linear-gradient(to top, #fff 0 0);
  background-size: 3px 9px, 3px 15px, 3px 11px; background-position: 6px 17px, 12px 11px, 18px 15px; background-repeat: no-repeat; }
.brand-sub { font-weight: 400; font-size: 14px; color: var(--muted); }
.top-nav { display: flex; gap: 18px; font-size: 14px; }
.top-nav a { color: var(--text-2); text-decoration: none; }
.top-nav a:hover, .top-nav a[aria-current] { color: var(--text); }
.foot { display: flex; flex-wrap: wrap; gap: 8px 20px; padding-block: 32px 40px; color: var(--muted); font-size: 13px; }
.foot a { color: var(--text-2); }

/* ---------- všeobecné ---------- */
main { padding-block: 8px 0; min-height: 60vh; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-top: 16px; }
.card h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sub { color: var(--text-2); font-size: 13px; margin: 2px 0 0; }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.error { color: var(--critical); }
.btn {
  border: 1px solid var(--border); background: var(--raised); border-radius: 8px; padding: 6px 12px;
  cursor: pointer; font-size: 14px; white-space: nowrap;
}
.btn:hover { border-color: var(--axis); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--critical); }
.btn.armed { background: var(--critical); border-color: var(--critical); color: #fff; }
input[type=text], input[type=password] {
  border: 1px solid var(--border); background: var(--raised); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
input:focus-visible, .btn:focus-visible, .seg button:focus-visible, .chip:focus-visible, .plot-hit:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- výber účtu ---------- */
.picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-size: 14px;
}
.chip[aria-current] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip .v { color: var(--muted); font-size: 12px; }

/* ---------- KPI ---------- */
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 20px; margin-top: 24px; }
.head h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -0.01em; }
.head h1 a { color: inherit; text-decoration: none; }
.head h1 .handle { color: var(--muted); font-weight: 400; font-size: 18px; margin-left: 6px; }
.kpis { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 12px; margin-top: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi .label { font-size: 13px; color: var(--text-2); }
.kpi .value { font-size: 30px; font-weight: 600; line-height: 1.15; margin-top: 4px; }
.kpi.hero .value { font-size: 48px; }
.kpi .note { font-size: 12px; color: var(--muted); margin-top: 4px; }
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .kpi.hero { grid-column: 1 / -1; }
  .kpi { padding: 12px; }
  .kpi .label { font-size: 12px; }
  .kpi .value { font-size: 22px; }
}

/* ---------- filtre ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 20px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed=true] { background: var(--accent); color: #fff; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-2); cursor: pointer; }

/* ---------- graf ---------- */
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); align-items: center; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.fresh { background: var(--fresh); }
.sw.partial { background: var(--partial); }
.sw.stale { background: var(--stale); }
.chart { position: relative; margin-top: 14px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar.fresh { fill: var(--fresh); }
.chart .bar.partial { fill: var(--partial); }
.chart .bar.stale { fill: var(--stale); }
.chart .hatch-line { fill: var(--surface); opacity: 0.55; }
.sw.hatched { background-image: repeating-linear-gradient(45deg, transparent 0 2px, rgba(255, 255, 255, 0.6) 2px 4px); }
.chart .stale-wash { fill: var(--stale-wash); }
.chart .wash-label { fill: var(--muted); font-size: 11px; }
.chart .hover-band { fill: var(--hover-wash); }
.chart .sel-band { fill: var(--sel-wash); }
.chart .plot-hit { fill: transparent; cursor: pointer; }
.tip {
  position: absolute; pointer-events: none; z-index: 2; min-width: 170px; max-width: 240px;
  background: var(--raised); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12); font-size: 13px; color: var(--text-2);
}
.tip strong { display: block; font-size: 20px; color: var(--text); font-weight: 600; line-height: 1.2; }
.tip .day { color: var(--text); font-weight: 500; margin-bottom: 4px; }
.chart-note { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

/* udalosti: neutrálna tmavá tinta, nie farba série ani stavu */
.chart .event-line { stroke: var(--text-2); stroke-width: 1; }
.chart .event-badge { fill: var(--text); }
.chart .event-num { fill: var(--surface); font-size: 11px; font-weight: 600; }
.events { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
.events li { display: flex; align-items: baseline; gap: 8px; }
.ev-day { color: var(--text); font-variant-numeric: tabular-nums; min-width: 82px; }
.ev-badge {
  display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: var(--text); color: var(--surface); font-size: 11px; font-weight: 600;
}
.ev-badge.small { min-width: 16px; height: 16px; font-size: 10px; margin-left: 6px; vertical-align: 1px; }
.tip-event { display: flex; gap: 6px; align-items: baseline; margin-top: 6px; color: var(--text); }
.tip-event .ev-badge.small { margin-left: 0; }

/* stav dňa: ikona + text, nikdy len farba */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status.fresh::before { background: var(--fresh); }
.status.partial::before { background: linear-gradient(90deg, var(--fresh) 50%, var(--partial) 50%); }
.status.stale::before { background: transparent; box-shadow: inset 0 0 0 2px var(--stale); }

/* ---------- tabuľky ---------- */
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
th { font-weight: 500; color: var(--muted); font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--hover-wash); }
tbody tr[aria-selected=true] { background: var(--sel-wash); }

/* ---------- detail dňa ---------- */
.day-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; align-items: baseline; }
.posts { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.posts li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.posts .likes { font-weight: 600; font-variant-numeric: tabular-nums; }
.posts .time { color: var(--muted); font-variant-numeric: tabular-nums; }
.badge { font-size: 11px; color: var(--text-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }

/* ---------- admin ---------- */
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.login { max-width: 360px; margin: 40px auto; }
.login form { display: grid; gap: 10px; margin-top: 12px; }
.stats-line { display: flex; flex-wrap: wrap; gap: 8px 28px; font-size: 14px; color: var(--text-2); }
.stats-line b { color: var(--text); font-weight: 600; }
.mode { font-weight: 600; }
.mode.live { color: var(--good); }
.mode.mock { color: var(--warning); }
.mode.off { color: var(--critical); }
.progress { margin-top: 12px; padding: 12px 14px; border-radius: 8px; background: var(--sel-wash); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
tr.sub-row td { padding-top: 0; }
tr:has(+ tr.sub-row) td { border-bottom: 0; }
.range-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 14px; color: var(--text-2); }
input[type=date] { border: 1px solid var(--border); background: var(--raised); border-radius: 8px; padding: 5px 8px; }
.plan { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; flex-basis: 100%; }
.plan b { color: var(--text); font-weight: 600; }
.prose { max-width: 720px; }
.prose h1 { font-size: 26px; margin: 24px 0 8px; }
.prose h2 { font-size: 17px; margin: 28px 0 6px; }
.prose p, .prose li { color: var(--text-2); }
