/* ===========================================================================
   WSB-Dashboard -- Aussehen nach dem Entwurf
   (docs/APP-DEV-PROMPTS/FWA/wsb-dashboard/anlagen/wsb-dashboard-01-v1-entwurf/)

   Farben: die Paletten [data-wsb="dark"|"light"] des Entwurfs, dunkel als
   Vorgabe. Schriften: Barlow Condensed (Überschriften, Zahlen) über Barlow,
   selbst ausgeliefert -- keine Anfrage an Dritte (G3), die CSP erlaubt nur
   'self'. Keine style-Attribute im HTML, alles steht hier.
   =========================================================================== */

@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url(fonts/barlow-400-lat.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url(fonts/barlow-500-lat.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url(fonts/barlow-600-lat.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 500; font-display: swap; src: url(fonts/barlow-condensed-500-lat.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url(fonts/barlow-condensed-600-lat.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url(fonts/barlow-condensed-700-lat.woff2) format('woff2'); }

:root {
  --font-heading: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Barlow', system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}

[data-wsb="dark"] {
  color-scheme: dark;
  --bg: #0b1120; --surface: #101a2c; --surface-2: #0d1627; --text: #e2e8f0; --accent: #60a5fa;
  --divider: color-mix(in srgb, #94a3b8 20%, transparent);
  --n-400: #475569; --n-500: #64748b; --n-600: #94a3b8; --n-700: #a8b4c6; --n-800: #cbd5e1;
  --accent-ink: #0b1120; --accent-hover: #7fb4fb;
  --pos: #34d399; --neg: #f87171; --blue: #60a5fa; --purple: #a78bfa; --green: #34d399; --red: #f87171; --orange: #fb923c;
  --c-min: #60a5fa; --c-max: #a78bfa; --c-cur: #34d399; --c-diff: #fb923c; --c-nodes: #f87171; --c-band: rgba(167, 139, 250, .12);
  --warn-bg: #2a2426; --warn-bd: #fb923c; --err-bg: #2a1c22; --err-bd: #f87171;
  --glow: radial-gradient(1100px 360px at 15% -8%, rgba(96, 165, 250, .13), transparent 65%);
}

[data-wsb="light"] {
  color-scheme: light;
  --bg: #f5f7fb; --surface: #ffffff; --surface-2: #f8fafc; --text: #0f172a; --accent: #2563eb;
  --divider: color-mix(in srgb, #0f172a 12%, transparent);
  --n-400: #94a3b8; --n-500: #64748b; --n-600: #64748b; --n-700: #475569; --n-800: #334155;
  --accent-ink: #ffffff; --accent-hover: #1d4ed8;
  --pos: #059669; --neg: #dc2626; --blue: #2563eb; --purple: #7c3aed; --green: #059669; --red: #dc2626; --orange: #ea580c;
  --c-min: #2563eb; --c-max: #7c3aed; --c-cur: #059669; --c-diff: #ea580c; --c-nodes: #dc2626; --c-band: rgba(124, 58, 237, .08);
  --warn-bg: #fff7ed; --warn-bd: #ea580c; --err-bg: #fef2f2; --err-bd: #dc2626;
  --glow: radial-gradient(1100px 360px at 15% -8%, rgba(37, 99, 235, .08), transparent 65%);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--bg); background-image: var(--glow); background-repeat: no-repeat;
  color: var(--text); font: 400 15px/1.5 var(--font-body); font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
h1, h2, h3 { font-family: var(--font-heading); font-weight: 600; margin: 0; letter-spacing: -.005em; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.ic { width: 18px; height: 18px; flex: none; }

.seite { max-width: 1280px; margin: 0 auto; padding: 32px 40px 28px; }

/* --- Kopf ---------------------------------------------------------------- */
.kopf { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; padding-bottom: 18px; border-bottom: 1px solid var(--divider); }
.marke { display: flex; align-items: center; gap: 14px; min-width: 0; }
.marke img { width: 48px; height: 48px; flex: none; }
.kicker { display: block; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }
.kopf h1 { font-size: 32px; line-height: 1.05; }
.version { font: 500 11px var(--font-body); letter-spacing: .08em; color: var(--n-600); vertical-align: middle; margin-left: 6px; }
.aktionen { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.aktualisiert { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--n-700); }
.aktualisiert i { width: 7px; height: 7px; background: var(--n-500); display: block; }
.seite.laedt .aktualisiert i { background: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 6px 16px;
  font: 600 15px var(--font-heading); letter-spacing: .02em; border: 1px solid var(--divider); background: transparent;
  color: var(--text); cursor: pointer; text-decoration: none; border-radius: 0;
}
.btn:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); }
.btn-primaer { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primaer:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-icon { width: 36px; padding: 0; }
.btn[disabled] { opacity: .55; cursor: progress; }
.seite.laedt #refresh .ic { animation: dreh 1s linear infinite; }
@keyframes dreh { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .seite.laedt #refresh .ic { animation: none; } }

.auto { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 12px; border: 1px solid var(--divider); font-size: 13px; color: var(--n-800); cursor: pointer; }
.auto input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.schalter { width: 30px; height: 16px; border: 1px solid var(--n-500); position: relative; flex: none; }
.schalter::after { content: ''; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; background: var(--n-500); transition: transform .15s; }
.auto input:checked + .schalter { border-color: var(--accent); }
.auto input:checked + .schalter::after { transform: translateX(14px); background: var(--accent); }
.auto input:focus-visible + .schalter { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Sprungnavigation ---------------------------------------------------- */
.sprung { display: flex; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--divider); overflow-x: auto; scrollbar-width: none; }
.sprung a {
  flex: none; padding: 6px 16px; border: 1px solid var(--divider); background: var(--surface-2); color: var(--text);
  font: 600 14px var(--font-heading); letter-spacing: .1em; text-transform: uppercase; text-decoration: none;
}
.sprung a:hover, .sprung a[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* --- Hinweise ------------------------------------------------------------ */
#hinweise { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; }
#hinweise:empty { display: none; }
.hinweis { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border: 1px solid; font-size: 14px; }
.hinweis .ic { width: 24px; height: 24px; }
.hinweis p { margin: 0; flex: 1; }
.hinweis.warnung { background: var(--warn-bg); border-color: var(--warn-bd); }
.hinweis.warnung > .ic { color: var(--orange); }
.hinweis.fehler { background: var(--err-bg); border-color: var(--err-bd); }
.hinweis.fehler > .ic { color: var(--red); }
.hinweis.veraltet { background: var(--surface); border-color: var(--n-500); }
.hinweis.veraltet > .ic { color: var(--n-600); }
.hinweis.aus { display: none; }
.schliessen { background: none; border: 0; color: var(--text); cursor: pointer; padding: 4px; display: inline-flex; }

/* --- Karten und Kacheln -------------------------------------------------- */
.inhalt { display: flex; flex-direction: column; gap: 30px; margin-top: 30px; }
.seite.leer .daten { display: none; }
.karte { background: var(--surface); border: 1px solid var(--divider); }
.karten-kopf { padding: 12px 18px; border-bottom: 1px solid var(--divider); font: 700 13px var(--font-heading); letter-spacing: .14em; text-transform: uppercase; background: var(--surface-2); }
.reihe { display: grid; grid-template-columns: 3fr 4fr; gap: 28px; }
.zellen { display: grid; }
.z-balance { grid-template-columns: 2fr 1fr 1fr; }
.z3 { grid-template-columns: repeat(3, 1fr); }
.z4 { grid-template-columns: repeat(4, 1fr); }
.zelle { padding: 20px 18px 24px; display: flex; flex-direction: column; gap: 8px; min-width: 0; border-right: 1px solid var(--divider); }
.zelle:last-child { border-right: 0; }
.icon { width: 30px; height: 30px; display: grid; place-items: center; margin-bottom: 14px; }
.icon .ic { width: 16px; height: 16px; }
.ton-blau { background: color-mix(in srgb, var(--blue) 16%, transparent); color: var(--blue); }
.ton-lila { background: color-mix(in srgb, var(--purple) 16%, transparent); color: var(--purple); }
.ton-gruen { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.ton-rot { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.ton-orange { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange); }
.label { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--n-700); }
.wert { font: 600 26px/1.1 var(--font-heading); white-space: nowrap; }
/* Lange Beträge in schmalen Zellen: lieber etwas kleiner als umbrochen. */
.z3 .wert, .z4 .wert { font-size: clamp(19px, 1.85vw, 26px); }
.zelle.auf .wert { color: var(--pos); }
.zelle.ab .wert { color: var(--neg); }
.wert.riesig { font-size: 64px; line-height: .95; letter-spacing: -.02em; display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 10px; }
.nachkomma, .nebenwert { color: var(--n-500); }
.einheit { font: 600 16px var(--font-heading); letter-spacing: .08em; color: var(--accent); }
.zusatz { font-size: 12px; color: var(--n-700); }
.z-balance .zelle:not(.haupt) .wert { margin-top: auto; font-size: 34px; }
.z-balance .zelle:not(.haupt) { justify-content: flex-start; }

/* --- Chart --------------------------------------------------------------- */
.chart { padding: 22px 24px 18px; }
.chart-kopf { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 20px; }
.chart-titel { font-size: 22px; }
.chart-unter { font-size: 12px; color: var(--n-700); }
.bereiche { display: flex; border: 1px solid var(--divider); }
.bereiche button {
  font: 600 13px var(--font-heading); padding: 6px 13px; border: 0; border-left: 1px solid var(--divider);
  background: transparent; color: var(--text); cursor: pointer;
}
.bereiche button:first-child { border-left: 0; }
.bereiche button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.legende { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; margin: 16px 0 10px; padding: 0; font-size: 12px; color: var(--n-800); }
.legende li { display: flex; align-items: center; gap: 7px; }
.legende i { display: block; width: 14px; height: 2px; }
.l-min { background: var(--c-min); }
.l-max { background: var(--c-max); }
.l-cur { border-top: 2px dashed var(--c-cur); height: 0 !important; }
.l-nodes { background: var(--c-nodes); }
.l-diff { width: 8px !important; height: 10px !important; background: var(--c-diff); }
.chart-flaeche { position: relative; height: 470px; }
.ohne-js { color: var(--n-700); font-size: 13px; }

.about { padding: 22px 24px; display: grid; grid-template-columns: 180px 1fr; gap: 24px; }
.about p { margin: 0; font-size: 16px; line-height: 1.6; }
.t-min { color: var(--c-min); } .t-max { color: var(--c-max); } .t-diff { color: var(--c-diff); } .t-cur { color: var(--c-cur); } .t-nodes { color: var(--c-nodes); }

/* --- Nodes --------------------------------------------------------------- */
.nodes-kopf { display: flex; align-items: center; gap: 14px; padding: 16px 24px; border-bottom: 1px solid var(--divider); }
.nodes-kopf h2 { font-size: 22px; }
.nodes-kopf .anzahl { color: var(--accent); margin-left: 4px; }
.nodes-kopf .unter { font-size: 12px; color: var(--n-700); margin-right: auto; }
.tabelle-rahmen { overflow-x: auto; }
.tabelle { width: 100%; border-collapse: collapse; }
.tabelle th { text-align: left; font: 500 11px var(--font-body); letter-spacing: .14em; text-transform: uppercase; color: var(--n-700); padding: 12px 24px; border-bottom: 1px solid var(--divider); white-space: nowrap; }
.tabelle td { padding: 13px 24px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
.tabelle th.rechts, .tabelle td.betrag, .tabelle td.datum { text-align: right; }
.tabelle tr.mehr { display: none; }
.nodes.alle .tabelle tr.mehr { display: table-row; }
.tabelle tr.inaktiv td { color: var(--n-600); }
.rang { font: 600 17px var(--font-heading); color: var(--accent); }
.tabelle tr:nth-child(n+4) .rang { color: var(--n-700); }
.adresse { white-space: nowrap; }
.name { font-weight: 500; }
.tag { font: 500 10px var(--font-body); letter-spacing: .1em; text-transform: uppercase; padding: 2px 6px; border: 1px solid var(--n-500); color: var(--n-600); margin-left: 6px; }
.betrag span { font: 600 18px var(--font-heading); display: block; }
.balken { display: block; width: 180px; height: 3px; margin: 4px 0 0 auto; }
.balken .spur { fill: var(--divider); }
.balken .fuell { fill: var(--accent); }
.datum { font-size: 13px; color: var(--n-700); white-space: nowrap; }

/* --- Support und Fuß ----------------------------------------------------- */
.support-kopf { padding: 26px 24px 22px; display: grid; grid-template-columns: 180px 1fr; gap: 24px; border-bottom: 1px solid var(--divider); }
.support-kopf .kicker { color: var(--green); }
.support-kopf h2 { font-size: 30px; }
.support-kopf p { margin: 6px 0 0; color: var(--n-800); }
.support-wege { display: grid; grid-template-columns: 1fr 1fr; }
.weg { min-width: 0; padding: 22px 24px 26px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.weg + .weg { border-left: 1px solid var(--divider); }
.weg h3 { font-size: 18px; letter-spacing: .06em; text-transform: uppercase; display: flex; align-items: center; gap: 10px; }
.nr { font: 600 12px var(--font-body); padding: 4px 8px; background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.weg + .weg .nr { background: color-mix(in srgb, var(--blue) 16%, transparent); color: var(--blue); }
.weg p { margin: 0; color: var(--n-800); font-size: 14px; }
.kopierfeld { display: flex; width: 100%; border: 1px solid var(--divider); margin-top: 8px; }
.kopierfeld code { flex: 1; min-width: 0; padding: 8px 12px; font: 13px var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--surface-2); }
.btn-kopieren { border: 0; border-left: 1px solid var(--divider); color: var(--accent); }
.btn-kopieren.kopiert { color: var(--pos); }

.fuss { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--divider); font-size: 12px; color: var(--n-700); }

/* --- Schmaler ------------------------------------------------------------ */
@media (max-width: 1100px) {
  .reihe { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .seite { padding: 16px 16px 24px; }
  .kopf h1 { font-size: 24px; }
  .aktionen { width: 100%; }
  .aktualisiert { display: none; }
  .auto { flex: 1; }
  .z-balance { grid-template-columns: 1fr 1fr; }
  .z-balance .haupt { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--divider); }
  .wert.riesig { font-size: 46px; }
  .z3, .z4 { grid-template-columns: 1fr 1fr; }
  .zelle { border-bottom: 1px solid var(--divider); padding: 14px 14px 16px; }
  .zelle:nth-child(2n of :not(.haupt)) { border-right: 0; }
  .icon { display: none; }
  .wert { font-size: 22px; }
  .z-balance .zelle:not(.haupt) .wert { font-size: 22px; }
  .chart { padding: 14px 12px; }
  .chart-flaeche { height: 340px; }
  .about, .support-kopf { grid-template-columns: 1fr; gap: 10px; }
  .support-wege { grid-template-columns: 1fr; }
  .weg + .weg { border-left: 0; border-top: 1px solid var(--divider); }
  .nodes-kopf { flex-wrap: wrap; padding: 14px; }
  .nodes-kopf .unter { display: none; }
  .nodes-kopf .btn { margin-left: auto; }
  /* Tabelle wird zu Karten: Rang links, Adresse/Name/IP in der Mitte, Betrag/Datum rechts. */
  .tabelle thead { display: none; }
  .tabelle, .tabelle tbody { display: block; }
  .tabelle tr { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; grid-template-areas: "rang adresse betrag" "rang name name" "rang ip datum"; gap: 2px 10px; padding: 12px 14px; border-bottom: 1px solid var(--divider); }
  .nodes.alle .tabelle tr.mehr { display: grid; }
  .tabelle td { padding: 0; border: 0; }
  .rang { grid-area: rang; align-self: center; }
  .adresse { grid-area: adresse; overflow: hidden; text-overflow: ellipsis; }
  .name { grid-area: name; font-size: 13px; }
  .ip { grid-area: ip; font-size: 12px; color: var(--n-700); }
  .betrag { grid-area: betrag; }
  .datum { grid-area: datum; font-size: 12px; }
  .balken { display: none; }
  .fuss { flex-direction: column; }
}
