/* DISS-Team-Cockpit – Farben als Rollen; Werte aus der validierten Referenzpalette */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --wash: rgba(42, 120, 214, 0.08);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4;
  --seq-0: #f0efec; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5;
  --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
  --good: #006300; --bad: #d03b3b; --warn-bg: #fff4d6; --warn-ink: #6b4a00;
  --luecke: rgba(137, 135, 129, 0.12);
  --m-vw: #4a86d6; --m-audi: #e2231a; --m-seat: #f2b200; --m-skoda: #39a935; --m-vwn: #17365d; --m-andere: #898781;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, 0.10); --wash: rgba(57, 135, 229, 0.14);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
    --seq-0: #262624; --seq-1: #104281; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #256abf;
    --seq-5: #3987e5; --seq-6: #6da7ec; --seq-7: #9ec5f4;
    --good: #0ca30c; --bad: #e66767; --warn-bg: #3a2f10; --warn-ink: #f3d68a;
    --luecke: rgba(137, 135, 129, 0.18);
    --m-vw: #5b95e0; --m-audi: #ec4a42; --m-seat: #e0a800; --m-skoda: #45b541; --m-vwn: #7f9fd1;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, 0.10); --wash: rgba(57, 135, 229, 0.14);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
  --seq-0: #262624; --seq-1: #104281; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #256abf;
  --seq-5: #3987e5; --seq-6: #6da7ec; --seq-7: #9ec5f4;
  --good: #0ca30c; --bad: #e66767; --warn-bg: #3a2f10; --warn-ink: #f3d68a;
  --luecke: rgba(137, 135, 129, 0.18);
  --m-vw: #5b95e0; --m-audi: #ec4a42; --m-seat: #e0a800; --m-skoda: #45b541; --m-vwn: #7f9fd1;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1 { font-size: 20px; margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.untertitel { color: var(--ink-2); margin: 2px 0 12px; font-size: 13px; }
button, input, select { font: inherit; color: inherit; }

/* Kopf & Filter */
.kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
        padding: 16px 24px 8px; }
.kopf p { margin: 2px 0 0; font-size: 13px; }
.abmelden { display: flex; gap: 10px; align-items: center; }
.filter { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px 16px;
          align-items: center; padding: 10px 24px; background: var(--page);
          border-bottom: 1px solid var(--grid); }
.filter label { display: flex; gap: 6px; align-items: center; color: var(--ink-2); font-size: 13px; }
.filter input, .filter select { background: var(--surface); border: 1px solid var(--axis);
                                border-radius: 6px; padding: 4px 8px; }
.gruppe { display: inline-flex; border: 1px solid var(--axis); border-radius: 8px; overflow: hidden; }
.gruppe button { border: 0; background: var(--surface); padding: 5px 10px; cursor: pointer; }
.gruppe button + button { border-left: 1px solid var(--grid); }
.gruppe button:hover { background: var(--wash); }
.gruppe button.aktiv { background: var(--ink); color: var(--surface); font-weight: 600; }
button.leise { background: transparent; border: 1px solid var(--axis); border-radius: 6px;
               padding: 4px 10px; cursor: pointer; }
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }

/* Inhalt */
main { padding: 16px 24px 48px; max-width: 1500px; margin: 0 auto; transition: opacity .15s; }
main[aria-busy="true"] { opacity: .55; }
.raster { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 16px; margin-bottom: 16px; }
.karte { background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; padding: 16px 18px; min-width: 0; }
.karte.breit { margin-bottom: 16px; }
.diagramm { position: relative; width: 100%; }
.diagramm svg { display: block; width: 100%; overflow: visible; }
.hinweis { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }

/* KPI-Kacheln */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kachel { background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; padding: 12px 14px; }
.kachel .titel { color: var(--ink-2); font-size: 12.5px; }
.kachel .wert { font-size: 26px; font-weight: 600; margin-top: 2px; }
.kachel .zusatz { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kachel .delta.besser { color: var(--good); }
.kachel .delta.schlechter { color: var(--bad); }
.kachel.held .wert { font-size: 48px; line-height: 1.05; }

/* Achsen, Gitter, Marken */
.achse text, .beschriftung { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.gitter line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.basis { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.linie { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.flaeche { opacity: .10; }
.fadenkreuz { stroke: var(--axis); stroke-width: 1; }
.luecke { fill: var(--luecke); }
.luecke-text { fill: var(--muted); font-size: 11px; }
.endwert { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.balken:hover, .zelle:hover, .balken:focus, .zelle:focus { opacity: .8; outline: none; }
.zelle { stroke: var(--surface); stroke-width: 2; }

/* Legende */
.legende { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; color: var(--ink-2); font-size: 12px; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legende i.strich { height: 2px; width: 14px; border-radius: 1px; }

/* Tabellen */
.tabelle-rahmen { overflow-x: auto; }
table.daten { width: 100%; border-collapse: collapse; font-size: 13px; }
table.daten th, table.daten td { padding: 6px 10px; text-align: right; white-space: nowrap;
                                 border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
table.daten th:first-child, table.daten td:first-child { text-align: left; }
table.daten th { color: var(--ink-2); font-weight: 600; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface); }
table.daten th[aria-sort="descending"]::after { content: " ↓"; }
table.daten th[aria-sort="ascending"]::after { content: " ↑"; }
table.daten tbody tr { cursor: pointer; }
table.daten tbody tr:hover { background: var(--wash); }
table.daten tr.gewaehlt { background: var(--wash); font-weight: 600; }
table.daten td.links { text-align: left; }
table.daten tfoot td { font-weight: 600; color: var(--ink-2); border-bottom: 0; }
.inline-balken { display: inline-block; height: 8px; border-radius: 0 4px 4px 0; background: var(--s1); vertical-align: middle; margin-right: 8px; }
details.tabellenansicht { margin-top: 8px; font-size: 12.5px; color: var(--ink-2); }
details.tabellenansicht summary { cursor: pointer; color: var(--muted); }
details.tabellenansicht table { margin-top: 6px; }
.team-auswahl { margin-top: 12px; }
.team-auswahl summary { cursor: pointer; color: var(--ink-2); }
#team-liste { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; }
#team-liste label { display: inline-flex; gap: 6px; align-items: center; }

/* Reiter */
.reiter { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.reiter button { border: 1px solid var(--axis); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.reiter button[aria-selected="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.zaehler { color: var(--muted); font-weight: 400; margin-left: 4px; }

/* Tooltip */
#tooltip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--ink);
           border: 1px solid var(--ring); border-radius: 8px; padding: 8px 10px; font-size: 12.5px;
           box-shadow: 0 4px 16px rgba(0, 0, 0, .12); max-width: 280px; }
#tooltip .tt-kopf { color: var(--ink-2); margin-bottom: 4px; }
#tooltip .tt-zeile { display: flex; align-items: center; gap: 8px; }
#tooltip .tt-zeile b { font-variant-numeric: tabular-nums; }
#tooltip .tt-zeile i { display: inline-block; width: 12px; height: 2px; }

/* Login */
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-box { background: var(--surface); border: 1px solid var(--ring); border-radius: 12px; padding: 28px; width: min(360px, 92vw); }
.login-box form { display: grid; gap: 12px; margin-top: 16px; }
.login-box label { display: grid; gap: 4px; color: var(--ink-2); font-size: 13px; }
.login-box input { padding: 8px 10px; border: 1px solid var(--axis); border-radius: 6px; background: var(--page); }
.login-box button { padding: 9px; border: 0; border-radius: 6px; background: var(--ink); color: var(--surface); font-weight: 600; cursor: pointer; }
.meldung { background: var(--warn-bg); color: var(--warn-ink); padding: 8px 10px; border-radius: 6px; }

@media (max-width: 640px) {
  .kopf, .filter, main { padding-left: 16px; padding-right: 16px; }
  .raster { grid-template-columns: 1fr; }
  .kachel.held .wert { font-size: 38px; }
}

/* Admin-Bereich */
main.admin { max-width: 1100px; }
.erfolg { background: var(--wash); color: var(--ink); padding: 8px 10px; border-radius: 6px; }
table.verwaltung tbody tr { cursor: default; }
table.verwaltung th, table.verwaltung td { text-align: left; }
table.verwaltung th { cursor: default; }
table.verwaltung select { max-width: 100%; }
table.verwaltung tr.aus td:first-child { color: var(--muted); text-decoration: line-through; }
table.verwaltung select, table.verwaltung input[type=password], form.neu input, form.neu select {
  background: var(--surface); border: 1px solid var(--axis); border-radius: 6px; padding: 4px 8px; }
form.zeile { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
form.neu { gap: 12px; margin-top: 8px; }
form.neu label { display: grid; gap: 4px; color: var(--ink-2); font-size: 13px; }
form.neu button { align-self: end; }
button.haupt { padding: 6px 14px; border: 0; border-radius: 6px; background: var(--ink); color: var(--surface);
               font-weight: 600; cursor: pointer; }
button.gefahr { color: var(--bad); border-color: var(--bad); }
h2.abstand { margin-top: 20px; }
.kopf a, .abmelden a { color: var(--ink-2); }
@media (max-width: 640px) {
  .kopf, .filter, main { padding-left: 16px; padding-right: 16px; }
  .kopf { flex-direction: column; }
  table.verwaltung th, table.verwaltung td { padding: 6px 4px; white-space: normal; }
  table.verwaltung select { max-width: 44vw; }
}

/* Ansicht Team / Marken */
.gruppe.ansicht button { font-weight: 600; }
.karte-kopf { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; align-items: flex-start; }
.steuerung { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.steuerung label { display: flex; gap: 6px; align-items: center; color: var(--ink-2); font-size: 13px; }
.steuerung select { background: var(--surface); border: 1px solid var(--axis); border-radius: 6px; padding: 4px 8px; }
.legende-zusatz { font-size: 12px; margin: 4px 0 0; text-align: right; }
svg .blass { opacity: .45; }
#m-tabelle-titel { margin-top: 16px; }
table.daten.marken tbody tr { cursor: default; }
table.daten.marken tbody tr:hover { background: transparent; }
table.daten.marken tr.m-vw td { background: color-mix(in srgb, var(--m-vw) 13%, var(--surface)); }
table.daten.marken tr.m-audi td { background: color-mix(in srgb, var(--m-audi) 13%, var(--surface)); }
table.daten.marken tr.m-seat td { background: color-mix(in srgb, var(--m-seat) 16%, var(--surface)); }
table.daten.marken tr.m-skoda td { background: color-mix(in srgb, var(--m-skoda) 13%, var(--surface)); }
table.daten.marken tr.m-vwn td { background: color-mix(in srgb, var(--m-vwn) 13%, var(--surface)); }
table.daten.marken tr.summe td { font-weight: 700; border-top: 2px solid var(--axis); }
table.daten.marken td:first-child { border-left: 4px solid transparent; }
table.daten.marken tr.m-vw td:first-child { border-left-color: var(--m-vw); }
table.daten.marken tr.m-audi td:first-child { border-left-color: var(--m-audi); }
table.daten.marken tr.m-seat td:first-child { border-left-color: var(--m-seat); }
table.daten.marken tr.m-skoda td:first-child { border-left-color: var(--m-skoda); }
table.daten.marken tr.m-vwn td:first-child { border-left-color: var(--m-vwn); }
.themen-raster { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-top: 8px; }
.thema-karte { border: 1px solid var(--ring); border-left: 5px solid var(--m-andere); border-radius: 8px; padding: 12px 16px; }
.thema-karte.m-vw { border-left-color: var(--m-vw); } .thema-karte.m-audi { border-left-color: var(--m-audi); }
.thema-karte.m-seat { border-left-color: var(--m-seat); } .thema-karte.m-skoda { border-left-color: var(--m-skoda); }
.thema-karte.m-vwn { border-left-color: var(--m-vwn); }
.thema-karte h3 { margin: 0 0 6px; font-size: 16px; }
.thema { margin-top: 12px; }
.thema-kopf { margin: 0; }
.thema-meta { color: var(--ink-2); }
.thema-delta { font-weight: 700; }
.thema-delta.hoch { color: var(--bad); }
.thema-delta.tief { color: var(--good); }
.thema ul { margin: 4px 0 0; padding-left: 22px; color: var(--ink-2); }
.klein { font-size: 12px; }
@media (max-width: 640px) { .themen-raster { grid-template-columns: 1fr; } }

/* versteckte Filter (Markenansicht): .filter label setzt display und schlüge sonst [hidden] */
.filter label[hidden] { display: none; }

a.knopf { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 6px; background: var(--ink);
          color: var(--surface); font-weight: 600; font-size: 13px; text-decoration: none; }
a.knopf:hover { opacity: .88; }
