:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page:           #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --series-1:       #2a78d6; /* Анимация */
  --series-2:       #008300; /* Игровое */
  --series-3:       #e87ba4; /* Документальное */
  --series-4:       #eda100; /* Золотая коллекция */
  --series-other:   #898781; /* Прочее */
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page:           #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:           #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);
    --series-1:       #3987e5;
    --series-2:       #008300;
    --series-3:       #d55181;
    --series-4:       #c98500;
    --series-other:   #6b6a65;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page:           #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --grid:           #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,0.10);
  --series-1:       #3987e5;
  --series-2:       #008300;
  --series-3:       #d55181;
  --series-4:       #c98500;
  --series-other:   #6b6a65;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
}
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 13px; }

.app { max-width: 1180px; margin: 0 auto; padding: 20px 20px 60px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.topbar-actions { display: flex; gap: 10px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 40px; height: 40px; }
.brand h1 { font-size: 20px; margin: 0 0 2px; }

.btn {
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 16px;
  font-size: 14px; cursor: pointer; background: var(--surface-1); color: var(--text-primary);
}
.btn-primary { background: var(--series-1); color: #fff; border-color: transparent; }
.btn:disabled { opacity: .6; cursor: default; }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; margin-bottom: 18px;
}
.filter-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-group label { font-size: 13px; color: var(--text-secondary); display: flex; gap: 6px; align-items: center; }
.filter-group input, .filter-group select {
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px;
  background: var(--surface-1); color: var(--text-primary); font-size: 13px;
}
.presets { border-right: 1px solid var(--border); padding-right: 16px; }
.presets button, .cat-chip {
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px;
  background: var(--surface-1); color: var(--text-secondary); font-size: 13px; cursor: pointer;
}
.presets button.active, .cat-chip.active {
  background: var(--text-primary); color: var(--surface-1); border-color: transparent;
}

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.stat-tile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px;
}
.stat-tile .value { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-tile .label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  border: none; background: none; padding: 10px 16px; font-size: 14px; cursor: pointer;
  color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--text-primary); border-bottom-color: var(--series-1); font-weight: 600; }

.tab-panel { display: flex; flex-direction: column; gap: 18px; }

.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px;
}
.card h2 { font-size: 15px; margin: 0 0 14px; color: var(--text-primary); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; font-size: 12px; color: var(--text-secondary); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--text-secondary); font-weight: 600; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface-1); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: color-mix(in srgb, var(--text-primary) 4%, transparent); }
td.total-col, th.total-col { font-weight: 600; }
tfoot td { font-weight: 600; border-top: 2px solid var(--baseline); border-bottom: none; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.bar-row .bar-label { width: 160px; flex: 0 0 auto; color: var(--text-secondary); text-align: right; }
.bar-row .bar-track { flex: 1; background: var(--grid); border-radius: 4px; height: 18px; position: relative; }
.bar-row .bar-fill { height: 100%; border-radius: 4px; }
.bar-row .bar-value { width: 110px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }

.month-chart-svg text { fill: var(--text-muted); font-size: 11px; }
.month-chart-svg .gridline { stroke: var(--grid); stroke-width: 1; }
.month-chart-svg .baseline { stroke: var(--baseline); stroke-width: 1; }
.month-bar { cursor: pointer; }
.month-bar:hover { opacity: 0.85; }

.tooltip {
  position: fixed; pointer-events: none; background: var(--text-primary); color: var(--surface-1);
  font-size: 12px; padding: 6px 10px; border-radius: 6px; z-index: 50; display: none;
  max-width: 260px; line-height: 1.4;
}
