:root {
  color-scheme: light;
}

.viz-root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);

  --series-1: #2a78d6; /* blue */
  --series-2: #eb6834; /* orange */
  --series-3: #1baf7a; /* aqua */
  --series-4: #eda100; /* yellow */
  --series-5: #e87ba4; /* magenta */
  --series-6: #008300; /* green */
  --series-7: #4a3aa7; /* violet */
  --series-other: #c3c2b7; /* "Другое" — muted, not a themed slot */

  --good: #006300;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page-plane:     #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: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-other: #383835;

    --good: #0ca30c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.viz-root { max-width: 1040px; margin: 0 auto; padding: 24px 20px 60px; }

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.page-header h1 { font-size: 26px; margin: 0; }

.filters { display: flex; gap: 8px; align-items: center; }
.filters select, .filters button {
  font: inherit;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
}
.filters button { cursor: pointer; }

.status {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.status.error { color: #d03b3b; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.tile .label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.tile .value {
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: proportional-nums;
}
.tile .sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.chart-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px 10px;
  margin-bottom: 20px;
}
.chart-card h2 { font-size: 16px; margin: 0 0 10px; color: var(--text-primary); }
.chart { position: relative; }

svg text { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
.axis-line { stroke: var(--baseline); stroke-width: 1; }
.grid-line { stroke: var(--grid); stroke-width: 1; }

.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 6px 0 14px; 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; }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.bar-label { width: 180px; flex: 0 0 auto; font-size: 14px; color: var(--text-secondary); text-align: right; }
.bar-track { flex: 1; background: var(--page-plane); border-radius: 4px; height: 18px; position: relative; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-value { font-size: 12px; color: var(--text-secondary); width: 90px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  color: var(--text-primary);
  white-space: nowrap;
  display: none;
  z-index: 5;
}

table.journal { width: 100%; border-collapse: collapse; font-size: 14px; }
table.journal th, table.journal td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--grid);
}
table.journal td.amount, table.journal th.amount { text-align: right; font-variant-numeric: tabular-nums; }
table.journal tbody tr:hover { background: var(--page-plane); }

.footnote { font-size: 12px; color: var(--text-muted); margin-top: 20px; }
