:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface-1: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text-primary: #191919;
  --text-secondary: #5f6368;
  --grid: #e9ebef;
  --accent: #257de0;
  --pos: #0b7a1e;
  --neg: #c62f30;
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600;
  --s5: #ee7fac; --s6: #008a17; --s7: #6a4ce2; --s8: #ec4647;
  --other: #9aa0a6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121212;
    --surface-1: #191919;
    --surface-2: #232323;
    --border: #2f2f2f;
    --text-primary: #efefef;
    --text-secondary: #a0a0a0;
    --grid: #2a2a2a;
    --accent: #338ced;
    --pos: #3ccf55;
    --neg: #ff7a7a;
    --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
    --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
    --other: #6b6b6b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121212; --surface-1: #191919; --surface-2: #232323; --border: #2f2f2f;
  --text-primary: #efefef; --text-secondary: #a0a0a0; --grid: #2a2a2a; --accent: #338ced;
  --pos: #3ccf55; --neg: #ff7a7a;
  --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
  --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263; --other: #6b6b6b;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

.top { background: var(--surface-1); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.top-inner { display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text-primary); }
.logo { background: var(--accent); color: #fff; font-weight: 800; letter-spacing: .04em; padding: 3px 8px; border-radius: 6px; font-size: 15px; }
.brand-sub { font-weight: 600; font-size: 14px; color: var(--text-secondary); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.tabs a { padding: 16px 10px; text-decoration: none; color: var(--text-secondary); font-size: 14px; white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }

.controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; margin: 20px 0 16px; }
.controls.inner { margin-top: 0; }
.ctl { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
select, input[type="text"], input:not([type]) {
  font: inherit; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; max-width: 100%;
}
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; }
.seg button { font: inherit; font-size: 13px; border: 0; background: none; color: var(--text-secondary); padding: 5px 12px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--surface-1); color: var(--text-primary); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg.small button { padding: 3px 10px; }
.fresh { font-size: 13px; color: var(--text-secondary); }

.loading, .error { padding: 40px 0; text-align: center; color: var(--text-secondary); }
.error { color: var(--neg); }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; min-width: 0; }
.card h2 { font-size: 16px; margin: 0 0 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.kpi .lbl { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.kpi .val { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }
.delta.up::before { content: "▲ "; font-size: .8em; }
.delta.down::before { content: "▼ "; font-size: .8em; }

.insight ul { margin: 0; padding-left: 18px; }
.insight li { margin-bottom: 8px; }
.insight li::marker { color: var(--accent); }

.chart { position: relative; width: 100%; }
.h320 { height: 320px; } .h360 { height: 360px; } .h260 { height: 260px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: 12px; color: var(--text-secondary); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--surface-1); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.tbl td.n, .tbl th.n { text-align: right; white-space: nowrap; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl .t1 { font-weight: 600; }
.tbl .t2 { font-size: 12px; color: var(--text-secondary); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--accent); color: #fff; margin-left: 6px; vertical-align: 1px; }

.chk { font-size: 13px; color: var(--text-secondary); display: flex; gap: 6px; align-items: center; }
.note { font-size: 12.5px; color: var(--text-secondary); margin: 10px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); padding: 3px 10px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { color: var(--text-primary); border-color: var(--text-secondary); }
.chip .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chip .x { opacity: .6; }

.search { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.search input { font-size: 16px; padding: 10px 12px; width: 100%; }

.film-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.film-head h2 { font-size: 22px; margin: 0; }
.film-head .meta { color: var(--text-secondary); font-size: 14px; }

.rel-week { margin-bottom: 18px; }
.rel-week h3 { font-size: 14px; margin: 0 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.rel-item { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.3fr); gap: 4px 12px; padding: 6px 0; border-bottom: 1px solid var(--grid); font-size: 14px; }
.rel-item .g { color: var(--text-secondary); font-size: 13px; }
@media (max-width: 640px) { .rel-item { grid-template-columns: 1fr; } }

.prose { max-width: 820px; }
.prose h3 { font-size: 15px; margin: 18px 0 6px; }
.prose li { margin-bottom: 6px; }

.foot { font-size: 12.5px; color: var(--text-secondary); padding-top: 8px; padding-bottom: 32px; }
