/* ============================================================================
   FM-Funknetz Dashboard – app.css
   Design-System (Tokens), Layout und Komponenten. Hell + Dunkel gleichwertig.
   Regel: Farben NIE hart in Komponenten, immer über die Tokens unten.
   ========================================================================== */

/* ---------------------------------------------------------------- Tokens -- */
:root {
  /* Flächen */
  --bg:          #0d1117;
  --bg-grad:     radial-gradient(1200px 600px at 12% -10%, #16202e 0%, transparent 60%),
                 radial-gradient(900px 500px at 100% 0%, #14202a 0%, transparent 55%);
  --surface:     #151b24;
  --surface-2:   #1b2330;
  --surface-3:   #222c3a;
  --sunken:      #0b1017;

  /* Linien */
  --line:        #263243;
  --line-soft:   #1e2836;
  --line-strong: #35455c;

  /* Text */
  --text:        #e8edf4;
  --text-muted:  #9aa8bc;
  --text-faint:  #6b7a90;

  /* Akzente */
  --accent:      #38bdf8;
  --accent-ink:  #04212e;
  --accent-soft: rgba(56,189,248,.14);
  --brand:       #f5a524;

  /* Status */
  --ok:        #22c55e;
  --ok-soft:   rgba(34,197,94,.16);
  --warn:      #f59e0b;
  --warn-soft: rgba(245,158,11,.16);
  --bad:       #ef4444;
  --bad-soft:  rgba(239,68,68,.16);
  --off:       #64748b;
  --off-soft:  rgba(100,116,139,.16);

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 8px 24px -12px rgba(0,0,0,.7);
  --shadow-3: 0 20px 48px -20px rgba(0,0,0,.8);

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg:          #eef2f7;
  --bg-grad:     radial-gradient(1100px 550px at 10% -12%, #ffffff 0%, transparent 62%),
                 radial-gradient(900px 480px at 100% 0%, #e2ecf7 0%, transparent 58%);
  --surface:     #ffffff;
  --surface-2:   #f5f8fc;
  --surface-3:   #e9eff7;
  --sunken:      #e4eaf2;

  --line:        #d3dde9;
  --line-soft:   #e3eaf3;
  --line-strong: #b3c2d4;

  --text:        #101720;
  --text-muted:  #566275;
  --text-faint:  #7d8899;

  --accent:      #0b7fc4;
  --accent-ink:  #ffffff;
  --accent-soft: rgba(11,127,196,.12);
  --brand:       #d4820a;

  --ok:        #12874a;
  --ok-soft:   rgba(18,135,74,.14);
  --warn:      #b96908;
  --warn-soft: rgba(185,105,8,.14);
  --bad:       #cc2222;
  --bad-soft:  rgba(204,34,34,.12);
  --off:       #7a8798;
  --off-soft:  rgba(122,135,152,.14);

  --shadow-1: 0 1px 2px rgba(16,32,54,.08);
  --shadow-2: 0 8px 22px -14px rgba(16,32,54,.35);
  --shadow-3: 0 20px 44px -22px rgba(16,32,54,.4);

  color-scheme: light;
}

* { box-sizing: border-box; }

/* Muss die display-Werte der Komponenten schlagen, sonst bleiben mit [hidden]
   ausgeblendete Buttons/Tabellen sichtbar. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { margin-left: auto; }

/* ------------------------------------------------------------- Kopfzeile -- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}

.site-head__brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 11px;
  color: var(--accent-ink);
  background: linear-gradient(145deg, var(--brand), #e2660b);
  box-shadow: var(--shadow-2);
  flex: none;
}
:root[data-theme="light"] .brand-mark { color: #fff; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 16px; letter-spacing: .2px; }
.brand-text span { font-size: 12px; color: var(--text-muted); }

.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }

.nav-link {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.site-head__tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }

@media (max-width: 780px) {
  .site-head { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  /* Nav lieber seitlich schiebbar als über zwei Zeilen gebrochen */
  .site-nav {
    order: 3; width: 100%; gap: 2px;
    flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .nav-link { white-space: nowrap; }
  .nav-link { padding: 5px 10px; font-size: 12.5px; }
  .site-head__tools { margin-left: auto; }
  .brand-mark { width: 34px; height: 34px; border-radius: 9px; }
  .brand-mark svg { width: 22px; height: 22px; }
  .brand-text strong { font-size: 14.5px; }
  .site-head__tools select { max-width: 128px; font-size: 12.5px; padding: 5px 6px; }
  .wrap { padding: 12px 10px; }
}

/* -------------------------------------------------------------- Fußzeile -- */
.site-foot {
  display: flex; justify-content: center; align-items: center; gap: 8px;
  flex-wrap: wrap;
  padding: 22px 16px 30px;
  font-size: 12.5px;
  color: var(--text-faint);
}
.site-foot .dot { opacity: .5; }

/* ---------------------------------------------------------------- Layout -- */
.wrap { max-width: 1360px; margin: 0 auto; padding: 18px; }

.cols {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
.cols--2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 980px) { .cols--2 { grid-template-columns: 1fr; } }

.stack { display: grid; gap: 16px; }

/* ----------------------------------------------------------------- Karte -- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  min-width: 0;
}

.card__head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.card__head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.card__head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.card__body { padding: 14px 16px; }
.card__body--flush { padding: 0; }
.card__body--scroll { max-height: 46vh; overflow: auto; }

/* -------------------------------------------------------------- Elemente -- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  font: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.btn--primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, #000); }
.btn--sm { padding: 5px 10px; font-size: 12.5px; }

.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-3); }
/* Sonne im Hellmodus, Mond im Dunkelmodus */
.icon-btn .i-sun { display: none; }
:root[data-theme="light"] .icon-btn .i-sun { display: block; }
:root[data-theme="light"] .icon-btn .i-moon { display: none; }

input[type="text"], input[type="search"], input[type="number"], select {
  font: inherit; font-size: 13.5px;
  color: var(--text);
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, .icon-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--text-faint); }
select { cursor: pointer; }

/* Schalter */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  position: relative;
  width: 36px; height: 20px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  transition: background .18s, border-color .18s;
  flex: none;
}
.switch__track::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform .18s, background .18s;
}
.switch input:checked + .switch__track { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(16px); background: var(--accent); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Pills / Chips / Badges */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-muted);
  white-space: nowrap;
}
.pill--ok   { color: var(--ok);   background: var(--ok-soft);   border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill--warn { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill--bad  { color: var(--bad);  background: var(--bad-soft);  border-color: color-mix(in srgb, var(--bad) 40%, transparent); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 12px;
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-muted);
}
.chip--tg { cursor: pointer; }
.chip--tg:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.chip--on  { color: var(--ok);   background: var(--ok-soft);   border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.chip--off { color: var(--text-faint); }

.dot-state {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--off);
  flex: none;
}
.dot-state--on  { background: var(--ok);  box-shadow: 0 0 0 3px var(--ok-soft); }
.dot-state--tx  { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}

/* -------------------------------------------------------------- Tabellen -- */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th {
  position: sticky; top: 0; z-index: 1;
  text-align: left;
  padding: 9px 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }

td.call, .call-cell { font-weight: 600; font-family: var(--mono); }
td.call a { color: var(--text); }
td.call a:hover { color: var(--accent); }

.srv-tag {
  font-size: 9px; font-weight: 700;
  color: var(--accent);
  vertical-align: super;
  margin-left: 1px;
}

/* Zeile blinkt kurz auf, wenn sie neu dazukommt */
@keyframes rowIn { from { background: var(--accent-soft); } }
tr.is-new { animation: rowIn 1.6s ease-out; }

.empty-note {
  padding: 26px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
}

/* ------------------------------------------------------------- Toolbars -- */
.toolbar {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
}
.toolbar--filters { gap: 12px; align-items: flex-end; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label {
  font-size: 11px; font-weight: 600; letter-spacing: .4px;
  text-transform: uppercase; color: var(--text-faint);
}
.field__row { display: flex; gap: 6px; align-items: center; }
/* Das Feld füllt den freien Platz und bricht erst um, wenn es eng wird –
   width:100% hätte die Knöpfe sofort in die nächste Zeile geschoben. */
.field__row > input { flex: 1 1 180px; min-width: 0; }
.field--grow { flex: 1 1 200px; }

/* ------------------------------------------------- Kompakte Talker-Kacheln */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}
.tile {
  --tint: var(--off);
  position: relative;
  padding: 11px 12px;
  border-radius: var(--r);
  background: color-mix(in srgb, var(--tint) 18%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--tint) 55%, transparent);
  overflow: hidden;
}
.tile::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--tint);
}
.tile__call { font-family: var(--mono); font-weight: 700; font-size: 15px; }
.tile__tg   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.tile--past { opacity: .5; filter: saturate(.4); }

.legend-line {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 12px; color: var(--text-faint);
  padding-bottom: 10px;
}

/* ----------------------------------------------------------- Node-Kacheln */
.node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 8px;
}

.node-btn {
  --tint: var(--off);
  position: relative;
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 10px 8px;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: color-mix(in srgb, var(--tint) 14%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--tint) 45%, var(--line));
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform .1s, border-color .15s, box-shadow .15s;
}
.node-btn:hover { transform: translateY(-1px); border-color: var(--tint); box-shadow: var(--shadow-2); }
.node-btn__call { font-family: var(--mono); font-weight: 650; font-size: 15px; letter-spacing: -.2px; }
.node-btn__meta { font-size: 13px; color: var(--text-muted); }
.node-btn__srv {
  position: absolute; top: 5px; right: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .3px;
  color: var(--accent);
  opacity: .8;
}
.node-btn--off { opacity: .62; }
.node-btn--off .node-btn__srv { color: var(--text-faint); }

/* ------------------------------------------------------- Key/Value-Blöcke */
.kv { display: grid; gap: 1px; background: var(--line-soft); border-radius: var(--r-sm); overflow: hidden; }
.kv__row {
  display: grid;
  grid-template-columns: minmax(120px, 34%) 1fr;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  font-size: 13.5px;
  align-items: baseline;
}
.kv__row:hover { background: var(--surface-2); }
.kv__k { color: var(--text-muted); font-size: 12.5px; }
.kv__v { min-width: 0; overflow-wrap: anywhere; }
.kv__v--mono { font-family: var(--mono); }
@media (max-width: 560px) {
  .kv__row { grid-template-columns: 1fr; gap: 2px; }
}

.section-label {
  font-size: 11px; font-weight: 650; letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 8px;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }

/* Meldungsbox */
.note {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text-muted);
}
.note--warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-soft); color: var(--text); }

/* Signalbalken */
.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--sunken);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}
.meter__fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--bad), var(--warn) 45%, var(--ok));
  transition: width .3s ease;
}

/* ============================================================================
   Seitenspezifisch: node.php / client.php
   ========================================================================== */

.node-hero {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 18px 20px;
}
.node-hero__id { min-width: 0; }
.node-hero__call {
  font-size: 30px; font-weight: 750; letter-spacing: -.5px; line-height: 1.1;
}
.node-hero__sub { color: var(--text-muted); font-size: 13.5px; margin-top: 3px; }
.node-hero__badges { display: flex; gap: 7px; flex-wrap: wrap; }
.node-hero__actions { margin-left: auto; display: flex; gap: 7px; flex-wrap: wrap; }
@media (max-width: 620px) { .node-hero__actions { margin-left: 0; width: 100%; } }

/* Aktuelle Sprechgruppe – große Anzeige */
.tg-now {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: var(--r);
  background: color-mix(in srgb, var(--tint, var(--off)) 15%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--tint, var(--off)) 50%, transparent);
}
.tg-now__num { font-family: var(--mono); font-size: 26px; font-weight: 750; line-height: 1; }
.tg-now__name { font-size: 13.5px; color: var(--text-muted); }
.tg-now__side { margin-left: auto; text-align: right; font-size: 12.5px; color: var(--text-muted); }
@media (max-width: 520px) { .tg-now__side { margin-left: 0; text-align: left; } }

/* RX/TX-Kacheln aus dem qth-Block */
.rt-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.rt-card {
  --tint: var(--off);
  padding: 11px 13px;
  border-radius: var(--r);
  background: color-mix(in srgb, var(--tint) 12%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--tint) 45%, var(--line));
}
.rt-card__head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 650;
  letter-spacing: .4px; text-transform: uppercase; color: var(--text-muted); }
.rt-card__head .right { margin-left: auto; }
.rt-card__freq { font-family: var(--mono); font-size: 19px; font-weight: 700; margin: 6px 0 2px; }
.rt-card__meta { font-size: 12.5px; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; }

/* Eingebettete Karte */
.map-embed { height: 420px; width: 100%; background: var(--sunken); }
@media (max-width: 640px) { .map-embed { height: 320px; } }

/* Rohdaten */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary .right::after { content: " · zuklappen"; }
.raw-json {
  margin: 0; padding: 14px 16px;
  font-size: 12px; line-height: 1.5;
  color: var(--text-muted);
  background: var(--sunken);
  border-top: 1px solid var(--line-soft);
  max-height: 420px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}

/* Log-Listen (client.php) */
.logline {
  display: flex; gap: 10px; align-items: baseline;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.logline:last-child { border-bottom: none; }
.logline__time { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); flex: none; }
.log-scroll { max-height: 260px; overflow: auto; }

/* Große Zustandsanzeige RX/TX (client.php) */
.state-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.state-box {
  --tint: var(--off);
  padding: 12px 14px;
  border-radius: var(--r);
  background: color-mix(in srgb, var(--tint) 13%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--tint) 45%, var(--line));
}
.state-box__label { font-size: 11px; font-weight: 650; letter-spacing: .5px;
  text-transform: uppercase; color: var(--text-muted); }
.state-box__value { font-size: 20px; font-weight: 700; margin-top: 3px; display: flex; align-items: center; gap: 8px; }
.state-box__sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================================
   Statistik (stats.php)
   ========================================================================== */

.kpi-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.kpi {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}
.kpi--soft { background: var(--surface-2); box-shadow: none; }
.kpi__label {
  font-size: 11px; font-weight: 650; letter-spacing: .5px;
  text-transform: uppercase; color: var(--text-faint);
}
.kpi__value {
  font-size: 27px; font-weight: 700; line-height: 1.15;
  font-variant-numeric: tabular-nums;
  margin-top: 3px;
}
.kpi__sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ------------------------------------------------------------ Diagramm -- */
.chart { position: relative; width: 100%; }
.ch-svg, .ch-overlay { display: block; width: 100%; }
.ch-svg { height: 220px; }
/* Beschriftungen liegen in einem zweiten SVG ohne Verzerrung, weil das
   Diagramm selbst mit preserveAspectRatio="none" gestreckt wird. */
.ch-overlay { position: absolute; inset: 0; height: 220px; pointer-events: none; }

.ch-grid { stroke: var(--line-soft); stroke-width: 1; }
.ch-axis { fill: var(--text-faint); font-size: 11px; font-family: var(--sans); }
.ch-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke;
           stroke-linejoin: round; stroke-linecap: round; }
.ch-area { fill: var(--accent); opacity: .14; }
.ch-hit  { fill: var(--accent); opacity: 0; }
.ch-hit:hover { opacity: .55; }

/* Balken direkt in der Tabellenzeile – spart ein zweites Diagramm */
table.data--bars tbody tr {
  background-image: linear-gradient(to right,
    var(--accent-soft) 0 var(--bar, 0%), transparent var(--bar, 0%) 100%);
}
table.data--bars tbody tr:hover {
  background-image: linear-gradient(to right,
    color-mix(in srgb, var(--accent) 22%, transparent) 0 var(--bar, 0%),
    var(--surface-2) var(--bar, 0%) 100%);
}
table.data td.num, table.data th.num { text-align: right; }

.tag-sm {
  font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 4px;
  background: var(--surface-3); color: var(--text-faint);
  vertical-align: middle;
}

/* ------------------------------------------------------------- Heatmap -- */
.hm {
  display: grid;
  grid-template-columns: 34px repeat(24, minmax(0, 1fr));
  gap: 2px;
  min-width: 620px;
}
.card__body:has(.hm) { overflow-x: auto; }
.hm__cell {
  aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 3px;
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
}
.hm__head, .hm__day { color: var(--text-faint); font-size: 10px; aspect-ratio: auto; }
.hm__day { justify-self: start; padding-left: 2px; font-weight: 600; }
.hm__val {
  background: color-mix(in srgb, var(--accent) calc(var(--v, 0) * 100%), var(--sunken));
  color: var(--text);
}
/* ab etwa der Hälfte wird der Untergrund kräftig – Text dann invertieren */
.hm__val { color: color-mix(in srgb, var(--text) calc((1 - var(--v, 0)) * 100%), var(--accent-ink)); }

/* --------------------------------------------------------- Detailblock -- */
.detail-head {
  display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap;
  padding-bottom: 12px; margin-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.detail-title { font-size: 24px; font-weight: 750; line-height: 1.1; }
.detail-kpis { margin-left: auto; display: flex; gap: 20px; flex-wrap: wrap; }
.detail-kpis > div { display: flex; flex-direction: column; }
.detail-kpis .k { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-faint); }
.detail-kpis .v { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
@media (max-width: 620px) { .detail-kpis { margin-left: 0; gap: 14px; } }

code {
  font-family: var(--mono); font-size: 12px;
  padding: 1px 5px; border-radius: 4px;
  background: var(--surface-3);
}

/* ============================================================================
   Siegertreppchen
   ========================================================================== */

/* Umschalter Heute/Gestern/Woche/Monat */
.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.seg button {
  font: inherit; font-size: 12.5px;
  padding: 4px 12px;
  border: none; border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

/* Die Treppe: Platz 2 – 1 – 3, Höhe über die Stufe darunter */
.pod {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 8px;
  margin-bottom: 14px;
}
/* Bei nur einem oder zwei Platzierten nicht auseinanderziehen */
.pod:has(.pod__place:only-child) { grid-template-columns: 1fr; max-width: 240px; margin-inline: auto; }

.pod__place {
  --medal: var(--off);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
  color: var(--text);
  text-align: center;
}
.pod__place:hover { text-decoration: none; }
.pod__place:hover .pod__step { filter: brightness(1.12); }

.pod__place--1 { --medal: #f5b301; }
.pod__place--2 { --medal: #a8b3c1; }
.pod__place--3 { --medal: #cd7f32; }

.pod__medal {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  margin-bottom: 4px;
  border-radius: 50%;
  font: 700 14px/1 var(--sans);
  color: #1a1206;
  background: radial-gradient(circle at 35% 30%,
              color-mix(in srgb, var(--medal) 60%, #fff), var(--medal));
  border: 1px solid color-mix(in srgb, var(--medal) 70%, #000);
  box-shadow: 0 2px 6px -2px color-mix(in srgb, var(--medal) 70%, transparent);
}
.pod__place--1 .pod__medal { width: 36px; height: 36px; font-size: 16px; }

.pod__call {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -.3px;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pod__place--1 .pod__call { font-size: 15px; }
.pod__time { font-size: 12.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.pod__sub  { font-size: 10.5px; color: var(--text-faint); }

/* Die Stufe – Höhe macht den Rang sichtbar */
.pod__step {
  position: relative;
  width: 100%;
  margin-top: 7px;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg,
              color-mix(in srgb, var(--medal) 78%, var(--surface)),
              color-mix(in srgb, var(--medal) 34%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--medal) 80%, var(--line));
  border-bottom: none;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 45%, transparent);
  transition: filter .15s;
}
.pod__step[data-rank="1"] { height: 64px; }
.pod__step[data-rank="2"] { height: 44px; }
.pod__step[data-rank="3"] { height: 30px; }

/* Platzziffer in die Stufe */
.pod__step::after {
  content: attr(data-rank);
  position: absolute;
  left: 50%; bottom: 6px;
  transform: translateX(-50%);
  font: 800 15px/1 var(--sans);
  color: color-mix(in srgb, var(--medal) 55%, #000);
  opacity: .5;
}
:root[data-theme="dark"] .pod__step::after { color: #0b1017; opacity: .45; }

/* Plätze 4 und weiter */
.rank-list {
  margin: 0; padding: 0 0 0 30px;
  list-style: decimal;
  font-size: 13px;
  color: var(--text-muted);
}
.rank-list li {
  display: flex; align-items: baseline; gap: 8px;
  padding: 3px 0;
  border-top: 1px solid var(--line-soft);
}
.rank-list li::marker { color: var(--text-faint); font-size: 11px; }
.rank-list a { font-family: var(--mono); font-weight: 600; color: var(--text); }
.rank-list a:hover { color: var(--accent); }
.rank-list__time { margin-left: auto; color: var(--text); }
.rank-list__cnt { min-width: 46px; text-align: right; font-size: 12px; }

@media (max-width: 560px) {
  .seg { flex-wrap: wrap; }
  .pod__sub { display: none; }
}

/* ============================================================================
   Breite Tabellen auf schmalen Displays
   Ohne das quetscht der Browser die Spalten zusammen, bis die letzte
   (Uhrzeit/Dauer) nicht mehr lesbar ist – und ein Scrollbalken fehlt ganz.
   ========================================================================== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Verlauf am rechten Rand, solange noch etwas außerhalb liegt. iOS blendet
     Scrollbalken aus, sonst sieht niemand, dass es weitergeht. */
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left / 24px 100% no-repeat local,
    linear-gradient(to left,  var(--surface) 30%, transparent) right / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.18), transparent) left / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.18), transparent) right / 12px 100% no-repeat scroll;
}
.table-wrap > table.data { min-width: 500px; }

/* Auf Touch-Geräten den Balken sichtbar lassen statt ihn auszublenden */
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-track { background: var(--sunken); }
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
}
.table-wrap { scrollbar-width: thin; scrollbar-color: var(--line-strong) var(--sunken); }

/* Der Sticky-Kopf darf beim Querscrollen nicht über den Rand hinauslaufen */
.table-wrap table.data th { background-clip: padding-box; }

@media (max-width: 560px) {
  /* Auf dem Handy passen fünf Spalten nicht nebeneinander. Der ausgeschriebene
     Sprechgruppen-Name ist dort das Entbehrlichste – die TG-Nummer daneben
     sagt dasselbe kürzer. Ohne ihn sind Call, TG, Dauer und Zeit vollständig
     lesbar, ganz ohne Schieben. */
  .table-wrap > table.data { min-width: 0; font-size: 13px; }
  table.data th, table.data td { padding-left: 9px; padding-right: 9px; white-space: nowrap; }
  table.data th:nth-child(3), table.data td:nth-child(3) { display: none; }
}

/* ============================================================================
   Hinweisleiste (fehlende Bibliothek o. ä.)
   ========================================================================== */
.fm-banner {
  position: relative;
  z-index: 900;
  padding: 11px 16px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--warn-soft);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 55%, transparent);
}
.fm-banner--bad {
  background: var(--bad-soft);
  border-bottom-color: color-mix(in srgb, var(--bad) 55%, transparent);
}
.fm-banner a { text-decoration: underline; }

/* ---------------------------------------------------------- Selbsttest -- */
.check-list { display: grid; gap: 1px; background: var(--line-soft);
  border-radius: var(--r-sm); overflow: hidden; }
.check-row {
  display: grid;
  grid-template-columns: 26px minmax(160px, 26%) 1fr;
  gap: 12px; align-items: baseline;
  padding: 9px 12px;
  background: var(--surface);
  font-size: 13.5px;
}
.check-row__mark { font-size: 15px; line-height: 1.2; }
.check-row--ok   .check-row__mark { color: var(--ok); }
.check-row--warn .check-row__mark { color: var(--warn); }
.check-row--bad  .check-row__mark { color: var(--bad); }
.check-row__what { color: var(--text-muted); }
.check-row__info { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }

/* ============================================================================
   Sprechgruppen-Monitor (tg.php)
   ========================================================================== */

.tg-hero {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 18px 20px;
}
.tg-hero__num { font-size: 30px; font-weight: 750; line-height: 1.1; letter-spacing: -.5px; }
.tg-hero__name { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.tg-hero__stats { margin-left: auto; display: flex; gap: 22px; flex-wrap: wrap; }
.tg-hero__stats > div { display: flex; flex-direction: column; }
.tg-hero__stats .k {
  font-size: 11px; letter-spacing: .4px; text-transform: uppercase; color: var(--text-faint);
}
.tg-hero__stats .v { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 620px) { .tg-hero__stats { margin-left: 0; gap: 16px; } }

/* Aktiver Sprecher */
.talker-live {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 18px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface-2);
  transition: background .2s, border-color .2s;
}
.talker-live__icon {
  display: grid; place-items: center;
  width: 54px; height: 54px; flex: none;
  border-radius: 50%;
  color: var(--text-faint);
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.talker-live__body { min-width: 0; }
.talker-live__call { font-size: 26px; font-weight: 750; line-height: 1.15; }
.talker-live__call a { color: inherit; }
.talker-live__sub { font-size: 13.5px; color: var(--text-muted); margin-top: 2px; }
.talker-live__time {
  margin-left: auto;
  font-size: 30px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.talker-live--tx {
  background: color-mix(in srgb, var(--bad) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--bad) 50%, transparent);
}
.talker-live--tx .talker-live__icon {
  color: #fff;
  background: var(--bad);
  border-color: var(--bad);
  animation: talkPulse 1.6s ease-in-out infinite;
}
.talker-live--tx .talker-live__time { color: var(--bad); }
@keyframes talkPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 55%, transparent); }
  70%      { box-shadow: 0 0 0 14px transparent; }
}
.talker-live--idle .talker-live__call { color: var(--text-muted); font-size: 21px; }

@media (max-width: 560px) {
  .talker-live { gap: 12px; padding: 14px; }
  .talker-live__call { font-size: 20px; }
  .talker-live__time { font-size: 22px; }
  .talker-live__icon { width: 44px; height: 44px; }
}

/* Auswahlkacheln für Sprechgruppen */
.tg-pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.tg-card {
  --tint: var(--off);
  display: block;
  padding: 11px 13px;
  border-radius: var(--r);
  background: color-mix(in srgb, var(--tint) 12%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--tint) 42%, var(--line));
  color: var(--text);
  transition: transform .1s, border-color .15s, box-shadow .15s;
}
.tg-card:hover {
  text-decoration: none;
  transform: translateY(-1px);
  border-color: var(--tint);
  box-shadow: var(--shadow-2);
}
.tg-card--live { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface-2)); }
.tg-card__num { font-size: 19px; font-weight: 700; line-height: 1.1; }
.tg-card__name {
  font-size: 12.5px; color: var(--text-muted); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tg-card__meta {
  display: flex; align-items: center; gap: 6px;
  margin-top: 7px; padding-top: 7px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px; color: var(--text-muted);
}
.tg-card__tx { display: flex; align-items: center; gap: 5px; color: var(--bad); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================================
   Handy-Feinschliff
   ========================================================================== */

/* Nebensächlichen Text auf schmalen Displays weglassen */
@media (max-width: 620px) { .hide-sm { display: none !important; } }

/* Formularzeilen dürfen umbrechen – sonst schieben sich Buttons aus dem Bild */
.field__row { flex-wrap: wrap; }

@media (max-width: 620px) {
  /* Eingabefelder nehmen die volle Breite, Buttons reihen sich darunter */
  .field__row > input[type="text"],
  .field__row > input[type="search"],
  .field__row > input[type="number"] { flex: 1 1 100%; min-width: 0 !important; }
  .field__row > .btn { flex: 1 1 auto; justify-content: center; }

  /* Karten-Kopfzeilen: Titel oben, Bedienelemente darunter */
  .card__head { flex-wrap: wrap; row-gap: 8px; }
  .card__head .right { margin-left: auto; }

  /* Werkzeugleisten enger */
  .toolbar { gap: 12px; padding: 12px; }
  .toolbar--filters .field { flex: 1 1 100%; }

  /* Kennzahlen-Kacheln: zwei nebeneinander statt einer pro Zeile */
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 11px 12px; }
  .kpi__value { font-size: 21px; }
  .kpi__label { font-size: 10px; }
  .kpi__sub { font-size: 11px; }

  /* Sprechgruppen-Kopf: Zahlen in eine Reihe */
  .tg-hero { padding: 14px; gap: 12px; }
  .tg-hero__num { font-size: 25px; }
  .tg-hero__stats { width: 100%; margin-left: 0; gap: 0; justify-content: space-between; }
  .tg-hero__stats > div { flex: 1; }
  .tg-hero__stats .v { font-size: 18px; }
  .tg-hero__stats .k { font-size: 9.5px; }

  /* Station-Kacheln etwas schmaler, damit zwei nebeneinander passen */
  .node-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 6px; }
  .tg-pick { grid-template-columns: 1fr; }

  /* Sprechgruppen-Auswahl: Serverspalte im Verlauf ist entbehrlich */
  #histTable th:nth-child(4), #histTable td:nth-child(4) { display: none; }

  /* Podium: schmaler, aber weiterhin dreispaltig */
  .pod { gap: 4px; }
  .pod__call { font-size: 11.5px; }
  .pod__place--1 .pod__call { font-size: 13px; }
  .pod__time { font-size: 11.5px; }
  .pod__medal { width: 25px; height: 25px; font-size: 12px; }
  .pod__place--1 .pod__medal { width: 30px; height: 30px; font-size: 14px; }
  .pod__step[data-rank="1"] { height: 46px; }
  .pod__step[data-rank="2"] { height: 32px; }
  .pod__step[data-rank="3"] { height: 22px; }

  /* Node-Detail: Aktionsknöpfe über die volle Breite */
  .node-hero { padding: 14px; gap: 12px; }
  .node-hero__call { font-size: 24px; }
  .node-hero__actions { width: 100%; }
  .node-hero__actions .btn { flex: 1 1 auto; justify-content: center; }

  /* Zustandskacheln der Client-Ansicht zu zweit nebeneinander */
  .state-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .state-box__value { font-size: 17px; }

  .rt-grid { grid-template-columns: 1fr; }
  .detail-kpis { gap: 12px; }
  .detail-title { font-size: 20px; }
  .wrap { gap: 12px; }
  .stack { gap: 12px; }
  .cols { gap: 12px; }
}
