:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.05);
  --youtube: #2a78d6;
  --tiktok: #eb6834;
  --facebook: #1baf7a;
  --instagram: #eda100;
  --accent: #2a78d6;
  --good: #006300;
  --bad: #d03b3b;
  --seq-0: #f0efec;
  --seq-1: #cde2fb;
  --seq-2: #9ec5f4;
  --seq-3: #6da7ec;
  --seq-4: #3987e5;
  --seq-5: #256abf;
  --seq-6: #184f95;
  --div-n3: #c43c3b; --div-n2: #e3807d; --div-n1: #f3c3c0; --div-0: #ecebe6; --div-p1: #b7d3f6; --div-p2: #5598e7; --div-p3: #1c5cab; --div-ink-strong: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.06);
    --youtube: #3987e5;
    --tiktok: #d95926;
    --facebook: #199e70;
    --instagram: #c98500;
    --accent: #3987e5;
    --good: #0ca30c;
    --bad: #e66767;
    --seq-0: #262624;
    --seq-1: #104281;
    --seq-2: #184f95;
    --seq-3: #256abf;
    --seq-4: #3987e5;
    --seq-5: #6da7ec;
    --seq-6: #b7d3f6;
    --div-n3: #e66767; --div-n2: #a83f3d; --div-n1: #5c2a28; --div-0: #2c2c2a; --div-p1: #1c3f6b; --div-p2: #256abf; --div-p3: #6da7ec; --div-ink-strong: #0b0b0b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --wash: rgba(255, 255, 255, 0.06);
  --youtube: #3987e5;
  --tiktok: #d95926;
  --facebook: #199e70;
  --instagram: #c98500;
  --accent: #3987e5;
  --good: #0ca30c;
  --bad: #e66767;
  --seq-0: #262624;
  --seq-1: #104281;
  --seq-2: #184f95;
  --seq-3: #256abf;
  --seq-4: #3987e5;
  --seq-5: #6da7ec;
  --seq-6: #b7d3f6;
  --div-n3: #e66767; --div-n2: #a83f3d; --div-n1: #5c2a28; --div-0: #2c2c2a; --div-p1: #1c3f6b; --div-p2: #256abf; --div-p3: #6da7ec; --div-ink-strong: #0b0b0b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.viz-root { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 26px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 4px; }
h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 20px 0 6px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; margin: 0; max-width: 70ch; }
.top { display: flex; justify-content: space-between; align-items: end; margin-bottom: 16px; }
.top p { margin: 2px 0 0; font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; position: sticky; top: 0; z-index: 5; padding: 8px 0; background: var(--page); }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button {
  font: inherit; font-size: 13px; color: var(--ink-2); background: none; border: 0;
  padding: 5px 10px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.seg button:hover { background: var(--wash); }
.seg button.on { background: var(--ink); color: var(--surface); }
.seg button:focus-visible, .more:focus-visible, th:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .label { font-size: 13px; color: var(--ink-2); }
.tile .value { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; }
.tile .sub { font-size: 12px; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }

.accounts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 10px; }
.account { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.account .name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.account .name a { color: inherit; }
.account dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0 0; }
.account dt { color: var(--ink-2); }
.account dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.status { font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.status.err::before { content: "⚠ "; color: var(--bad); }

.advice { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 12px 0 4px; }
.advice .pick { background: var(--wash); border-radius: 10px; padding: 12px 14px; }
.advice .pick .label { font-size: 12px; color: var(--ink-2); }
.advice .pick .value { font-size: 22px; font-weight: 600; }
.advice .pick .sub { font-size: 12px; color: var(--ink-2); }
.advice .pick .value.small-value { font-size: 16px; line-height: 1.35; word-break: break-word; }
.advice .empty { color: var(--ink-2); font-size: 14px; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .ref { stroke: var(--ink-2); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .mark, .chart .mark.hover { filter: brightness(1.12); }
.chart .empty-msg { color: var(--ink-2); font-size: 14px; padding: 24px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-2); margin: 6px 0 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-note { margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); display: inline-block; }
.swatch.faint { opacity: 0.35; }

.heat-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.heat-legend i { width: 18px; height: 10px; border-radius: 2px; display: inline-block; }

input[type="search"] {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--page); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; min-width: 0; width: 220px; max-width: 100%;
}
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--grid); }
th { font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none; white-space: nowrap; }
th[aria-sort="ascending"]::after { content: " ▲"; font-size: 9px; }
th[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.title { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.title a { color: var(--ink); text-decoration: none; }
td.title a:hover { text-decoration: underline; }
td .fmt { display: block; font-size: 11px; color: var(--muted); margin-left: 14px; }
td .plat { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.more { font: inherit; font-size: 13px; margin-top: 10px; background: none; border: 1px solid var(--border); color: var(--ink); border-radius: 8px; padding: 6px 12px; cursor: pointer; }

.tooltip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: var(--surface);
  font-size: 12px; line-height: 1.4; padding: 7px 10px; border-radius: 8px; max-width: 260px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
.tooltip b { font-weight: 600; }
footer { margin-top: 8px; }

/* vahekaardid */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--grid); margin-bottom: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-2); background: none; border: 0;
  border-bottom: 2px solid transparent; padding: 10px 12px; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.filters .metric-only[hidden] { display: none; }

/* top videod */
.toplist { list-style: none; margin: 8px 0 0; padding: 0; counter-reset: top; }
.toplist li { display: grid; grid-template-columns: 22px 96px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--grid); counter-increment: top; }
.toplist li::before { content: counter(top); color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.toplist img, .toplist .noimg { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; background: var(--wash); display: block; }
.toplist .main { min-width: 0; }
.toplist .main a { color: var(--ink); text-decoration: none; font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toplist .main a:hover { text-decoration: underline; }
.toplist .meta { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.toplist .meta .dot { margin-right: 5px; vertical-align: 1px; }
.toplist .bar { height: 4px; border-radius: 2px; background: var(--wash); margin-top: 6px; }
.toplist .bar span { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.toplist .val { font-size: 16px; font-weight: 600; text-align: right; white-space: nowrap; }
.toplist .val small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }

/* tõusjad */
.rising-list { list-style: none; margin: 8px 0 0; padding: 0; }
.rising-list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.rising-list a { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rising-list .gain { color: var(--good); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* hashtagide tabel */
.score-col { min-width: 160px; }
.scorebar { display: flex; align-items: center; gap: 8px; }
.scorebar .track { position: relative; flex: 1; height: 8px; min-width: 80px; }
.scorebar .track::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; border-left: 1px solid var(--axis); }
.scorebar .fill { position: absolute; top: 0; height: 100%; border-radius: 2px; }
.scorebar .txt { width: 40px; text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
td.tag { font-weight: 600; white-space: nowrap; }
tr.thin td { color: var(--muted); }
.div-legend { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); margin-top: 8px; flex-wrap: wrap; }
.div-legend i { width: 18px; height: 10px; border-radius: 2px; display: inline-block; }

@media (max-width: 600px) {
  .toplist li { grid-template-columns: 18px 64px 1fr; }
  .toplist img, .toplist .noimg { width: 64px; height: 36px; }
  .toplist .val { grid-column: 3; text-align: left; font-size: 14px; }
  .toplist .val small { display: inline; margin-left: 6px; }
  .filters { position: static; }
  .card { padding: 14px; }
  .tile .value { font-size: 22px; }
  td.title { max-width: 180px; }
}
