/* Kassensturz – tokens follow the dataviz reference palette (light + selected dark steps). */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --border-solid: #e1e0d9;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-other: #c3c2b7;
  --pos: #2a78d6;
  --neg: #e34948;
  --up: #006300;
  --down: #b3261e;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #262624;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --border-solid: #383835;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #0ca30c;
    --series-7: #9085e9;
    --series-other: #5a5955;
    --pos: #3987e5;
    --neg: #e66767;
    --up: #0ca30c;
    --down: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #262624;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --border-solid: #383835;
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #0ca30c;
  --series-7: #9085e9;
  --series-other: #5a5955;
  --pos: #3987e5;
  --neg: #e66767;
  --up: #0ca30c;
  --down: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent-ink); }
button, select { font: inherit; color: inherit; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--text-muted); }

/* header */
.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: 8px; font-weight: 700; font-size: 18px; color: var(--text-primary); text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 16px; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--text-secondary); white-space: nowrap; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { color: var(--text-primary); background: var(--surface-2); font-weight: 600; }

/* view header + controls */
.view-head { margin: 28px 0 12px; }
.view-head h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.01em; }
.view-head .accent { color: var(--accent-ink); }
.lead { margin: 0; color: var(--text-secondary); max-width: 760px; }
.controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; margin: 16px 0 20px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.field > span { text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
select {
  height: 34px; padding: 0 28px 0 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23898781' fill='none' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none; font-size: 14px; color: var(--text-primary);
}
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 0 12px; height: 30px; border-radius: 7px; cursor: pointer; color: var(--text-secondary); font-size: 14px; white-space: nowrap; }
.seg button:hover:not(:disabled) { color: var(--text-primary); }
.seg button.on { background: var(--surface-1); color: var(--text-primary); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.yearpick { display: inline-flex; gap: 4px; align-items: center; }
.icon { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); cursor: pointer; font-size: 18px; line-height: 1; }
.icon:disabled { opacity: 0.35; cursor: default; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi-label { font-size: 13px; color: var(--text-secondary); }
.kpi-value { font-size: 24px; font-weight: 650; margin: 2px 0; letter-spacing: -0.01em; }
.kpi-sub { font-size: 12px; color: var(--text-muted); }
.delta { display: block; font-size: 12px; margin-top: 4px; color: var(--text-secondary); }

/* cards */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px 20px; margin-bottom: 20px; min-width: 0; }
.card h2 { font-size: 18px; margin: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.sub { color: var(--text-secondary); font-size: 13px; margin: 4px 0 12px; }
.chart-title { font-size: 14px; margin: 20px 0 4px; color: var(--text-secondary); font-weight: 600; }
.chart { width: 100%; height: 320px; }
.chart.tall { height: 400px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.grid2 .chart { height: 260px; }
.empty { color: var(--text-secondary); padding: 24px 0; }
.note { font-size: 12px; color: var(--text-muted); margin: 8px 0 0; }

/* drill-down */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; margin: 4px 0 8px; min-height: 28px; }
.crumbs .here { font-weight: 600; }
.crumbs .sep { color: var(--text-muted); }
.link { border: 0; background: none; padding: 0; color: var(--accent-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.back { margin-left: auto; border: 1px solid var(--border); background: var(--surface-1); border-radius: 8px; padding: 2px 10px; cursor: pointer; font-size: 13px; }
.drill-body { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 24px; align-items: start; }
.donut-wrap { position: sticky; top: 72px; }
.donut { width: 100%; aspect-ratio: 1; max-height: 380px; }
.ranklist { list-style: none; margin: 0; padding: 0; }
.ranklist li button {
  display: grid; grid-template-columns: 10px 1fr auto 52px 14px; grid-template-rows: auto 4px;
  column-gap: 10px; row-gap: 4px; align-items: center; width: 100%; text-align: left;
  border: 0; background: none; padding: 8px 6px; border-radius: 8px; cursor: pointer;
}
.ranklist li button:hover { background: var(--surface-2); }
.ranklist li.sel button { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.ranklist .sw { width: 10px; height: 10px; border-radius: 3px; }
.ranklist .name { font-size: 14px; line-height: 1.3; }
.ranklist .code { color: var(--text-muted); font-size: 12px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.ranklist .val { font-size: 14px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ranklist .share { font-size: 12px; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }
.ranklist .chev { grid-row: 1; grid-column: 5; color: var(--text-muted); font-size: 18px; line-height: 1; }
.ranklist .bar { grid-column: 2 / 5; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.ranklist .bar i { display: block; height: 100%; border-radius: 2px; }
.ranklist li.neg .val { color: var(--down); }
.legend { display: flex; flex-wrap: wrap; gap: 2px 4px; margin: 4px 0 6px; }
.legend button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 2px 6px; border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--text-secondary); text-align: left; }
.legend button:hover { background: var(--surface-2); }
.legend button[aria-pressed="false"] { opacity: 0.4; text-decoration: line-through; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.trend-title { font-size: 14px; margin: 24px 0 4px; font-weight: 600; }
.chart.trend { height: 300px; }

/* prose */
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 12px 0; }
.prose th, .prose td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose li { margin: 4px 0; }

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

@media (max-width: 820px) {
  .drill-body { grid-template-columns: 1fr; }
  .donut-wrap { position: static; max-width: 340px; margin: 0 auto; width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
  .view-head h1 { font-size: 23px; }
  .card { padding: 14px 14px 16px; }
  .chart { height: 280px; }
}
@media (max-width: 480px) {
  .ranklist li button { grid-template-columns: 10px 1fr auto 14px; }
  .ranklist .share { display: none; }
  .ranklist .bar { grid-column: 2 / 4; }
  .ranklist .chev { grid-column: 4; }
  .nav a { padding: 5px 7px; font-size: 13px; }
  .nav { gap: 0; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 19px; }
  .top-inner { gap: 4px 16px; padding-top: 6px; padding-bottom: 6px; }
}
