/* ==========================================================================
   KI-Fleet — Ops-Dashboard
   Register: product (siehe PRODUCT.md). Dark ist Default (Abend-Nutzung),
   Light ist gleichwertig gepflegt. Farbe = Zustand, nie Dekoration.
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */
:root {
  /* Flächen — bg-2 ist die zweite Neutral-Ebene für Toolbars (dunkler als der Inhalt) */
  --bg:        oklch(0.165 0.012 265);
  --bg-2:      oklch(0.132 0.012 265);
  --panel:     oklch(0.215 0.014 265);
  --panel-2:   oklch(0.258 0.016 265);
  --inset:     oklch(0.185 0.013 265);
  --line:      oklch(0.315 0.018 265);
  --line-soft: oklch(0.268 0.016 265);

  /* Text — alle drei Stufen sind auf --panel gegen 4.5:1 geprüft */
  --ink:     oklch(0.940 0.008 265);
  --ink-dim: oklch(0.745 0.014 265);
  --off:     oklch(0.620 0.016 265);

  /* Akzent: nur Primäraktion, Auswahl, Fokus */
  --accent:      oklch(0.780 0.140 215);
  --accent-ink:  oklch(0.160 0.030 250);
  /* Akzent als TEXT auf getönter Akzent-Fläche (Primär-Buttons, aktive Toggles) */
  --accent-deep: oklch(0.800 0.130 215);

  /* Zustände */
  --ok:   oklch(0.760 0.160 152);
  --warn: oklch(0.810 0.140 82);
  --bad:  oklch(0.680 0.190 25);
  /* Textfarbe auf getönten Chips derselben Familie */
  --ok-ink:   oklch(0.790 0.150 152);
  --warn-ink: oklch(0.840 0.130 82);
  --bad-ink:  oklch(0.740 0.170 25);

  /* Radien — Karten max. 14px, Pillen nur für Badges/Chips */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --radius: var(--r-lg);      /* Alt-Name, wird von kanban.html genutzt */

  /* Abstands-Rhythmus */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 28px;

  /* Typo-Skala — fix in px (Produkt-UI, keine fluide Skalierung), Ratio ~1.12 */
  --fs-2xs: 11px;   /* Badges, Chips, Ports */
  --fs-xs:  12px;   /* Meta, Rolle, Zeitstempel */
  --fs-sm:  13px;   /* Sekundärtext, kleine Buttons */
  --fs-md:  14px;   /* Bedienelemente */
  --fs-base:15px;   /* Fließtext */
  --fs-lg:  16px;   /* Kartentitel */
  --fs-xl:  18px;   /* Marke */
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;

  /* Motion — ease-out (exponentiell), kurz genug fürs Arbeiten */
  --ease:     cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur:      180ms;
  --dur-slow: 240ms;

  /* Semantische z-Skala */
  --z-sticky:  10;
  --z-overlay: 100;
  --z-toast:   200;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg:        oklch(0.968 0.004 265);
  --bg-2:      oklch(0.995 0.002 265);
  --panel:     oklch(0.999 0.001 265);
  --panel-2:   oklch(0.945 0.005 265);
  --inset:     oklch(0.966 0.005 265);
  --line:      oklch(0.885 0.008 265);
  --line-soft: oklch(0.925 0.006 265);

  --ink:     oklch(0.245 0.015 265);
  --ink-dim: oklch(0.455 0.015 265);
  --off:     oklch(0.530 0.015 265);

  --accent:      oklch(0.520 0.140 235);
  --accent-ink:  oklch(0.995 0 0);
  --accent-deep: oklch(0.430 0.145 240);

  --ok:   oklch(0.520 0.140 152);
  --warn: oklch(0.550 0.120 70);
  --bad:  oklch(0.520 0.190 25);
  --ok-ink:   oklch(0.420 0.120 152);
  --warn-ink: oklch(0.420 0.100 68);
  --bad-ink:  oklch(0.450 0.180 25);

  color-scheme: light;
}

/* ---------- 2. Basis ----------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: var(--fs-base)/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }

/* Ein Fokus-Ring für die ganze App */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Icons: 24er-Raster, Strich folgt der Textfarbe */
.i {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- 3. Login ----------------------------------------------------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--s-6) var(--s-4);
}
.login-card {
  width: min(340px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-6) var(--s-5) var(--s-5);
  display: grid;
  gap: var(--s-3);
  text-align: center;
}
.login-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto var(--s-1);
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--accent) 16%, var(--panel));
  color: var(--accent);
}
.login-mark .i { width: 24px; height: 24px; }
.login-card h1 { font-size: 20px; font-weight: 640; letter-spacing: -0.015em; }
.login-sub {
  margin-bottom: var(--s-2);
  color: var(--ink-dim);
  font-size: var(--fs-sm);
}
.login-card input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink);
  padding: 11px 12px;
  font-size: 16px;
  transition: border-color var(--dur) var(--ease-out);
}
.login-card input::placeholder { color: var(--off); }
.login-card input:hover { border-color: var(--ink-dim); }
.login-card button {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: var(--r-md);
  padding: 11px;
  font-weight: 640;
  transition: filter var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.login-card button:hover { filter: brightness(1.08); }
.login-card button:active { transform: scale(0.985); }
.login-error { color: var(--bad-ink); font-size: var(--fs-sm); }

/* ---------- 4. Topbar ---------------------------------------------------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--bg-2);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 10px var(--s-4);
}

/* Marke */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: none;
}
.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: color-mix(in oklab, var(--accent) 15%, var(--panel));
  color: var(--accent);
  font-size: var(--fs-lg);   /* Fallback, falls Emoji statt Icon (kanban.html) */
  line-height: 1;
}
.brand-mark .i { width: 18px; height: 18px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-size: var(--fs-xl);
  font-weight: 660;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.brand-sub {
  font-size: var(--fs-2xs);
  color: var(--off);
  letter-spacing: 0.01em;
  line-height: 1.3;
}

/* Status: Zähler + Zeitstempel als ein Block, links neben den Aktionen */
.fleet-status {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  padding: 5px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: color-mix(in oklab, var(--panel) 60%, transparent);
  min-width: 0;
}
.fleet-summary {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.fleet-summary:empty { display: none; }
.updated {
  font-size: var(--fs-2xs);
  color: var(--off);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.updated:empty { display: none; }

/* Aktionen: zwei Gruppen (Bereiche | Werkzeuge), getrennt statt Icon-Wurst */
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.btn-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--panel) 55%, transparent);
}
.tb-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex: none;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 32px;
  height: 32px;
  padding: 0 7px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--ink-dim);
  font-size: var(--fs-sm);
  transition: color var(--dur) var(--ease-out),
              background-color var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out);
}
.ghost-btn:hover { color: var(--ink); background: var(--panel-2); }
.ghost-btn:active { transform: scale(0.96); }
/* Freistehende Buttons (Abmelden, „← Dashboard" auf kanban.html) bekommen eine Kante */
.topbar-right > .ghost-btn {
  border-color: var(--line-soft);
  padding: 0 12px;
}
.ghost-btn.is-on { color: var(--ok-ink); }
#sort-run.active,
.ghost-btn[aria-pressed="true"] {
  background: color-mix(in oklab, var(--accent) 18%, transparent);
  color: var(--accent-deep);
}

/* ---------- 5. Broadcast-Band -------------------------------------------- */
.broadcast-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  max-width: 1500px;
  margin: 0 auto;
  width: 100%;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in oklab, var(--warn) 7%, var(--bg));
}
.broadcast-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--warn-ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  flex: none;
}
.broadcast-row input {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid color-mix(in oklab, var(--warn) 45%, var(--line));
  border-radius: var(--r-md);
  color: var(--ink);
  padding: 9px 12px;
  font-size: var(--fs-md);
}
.broadcast-row input::placeholder { color: var(--off); }
.broadcast-row button {
  flex: none;
  height: 38px;
  padding: 0 var(--s-4);
  border: 0;
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--warn) 22%, var(--panel));
  color: var(--warn-ink);
  font-size: var(--fs-md);
  font-weight: 640;
  transition: background-color var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.broadcast-row button:hover { background: color-mix(in oklab, var(--warn) 32%, var(--panel)); }
.broadcast-row button:active { transform: scale(0.97); }

/* ---------- 6. Grid & Karte ---------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  align-items: start;
  gap: var(--s-4);
  padding: var(--s-4);
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}
.card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  transition: border-color var(--dur) var(--ease-out);
}
.card:hover { border-color: color-mix(in oklab, var(--line) 55%, var(--ink-dim)); }

/* Karte, die Strg+V gerade annimmt */
.card.paste-target { border-color: color-mix(in oklab, var(--accent) 60%, var(--line)); }
.card.paste-target .composer { border-color: color-mix(in oklab, var(--accent) 45%, var(--line)); }

/* Datei über der Karte (Drag & Drop) */
.card.drop-target { border-color: var(--accent); }
.card.drop-target::after {
  content: "Datei loslassen — Bot analysiert sie";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--s-4);
  text-align: center;
  background: color-mix(in oklab, var(--panel) 80%, var(--accent));
  color: var(--ink);
  font-size: var(--fs-md);
  font-weight: 600;
  border-radius: var(--r-lg);
  pointer-events: none;
  z-index: 3;
  animation: drop-in 140ms var(--ease-out);
}
@keyframes drop-in { from { opacity: 0; } }

/* Zone 1 — Identität */
.card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 10px;
  row-gap: 2px;
}
.card-id { min-width: 0; }
.card-title {
  font-size: var(--fs-lg);
  font-weight: 640;
  letter-spacing: -0.012em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.card-role {
  margin-top: 1px;
  color: var(--ink-dim);
  font-size: var(--fs-xs);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.card-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex: none;
}
.card-ip {
  color: var(--off);
  font-size: var(--fs-2xs);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.dot {
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 50%;
  flex: none;
}
.dot.ok   { background: var(--ok);   box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 20%, transparent); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in oklab, var(--warn) 18%, transparent); }
.dot.bad  { background: var(--bad);  box-shadow: 0 0 0 3px color-mix(in oklab, var(--bad) 20%, transparent); }
.dot.off  { background: var(--off); }

/* Badge-System — eine Form, vier Zustände */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: var(--fs-2xs);
  font-weight: 640;
  letter-spacing: 0.005em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.badge.ok   { background: color-mix(in oklab, var(--ok)   16%, var(--panel)); color: var(--ok-ink); }
.badge.warn { background: color-mix(in oklab, var(--warn) 16%, var(--panel)); color: var(--warn-ink); }
.badge.bad  { background: color-mix(in oklab, var(--bad)  16%, var(--panel)); color: var(--bad-ink); }
.badge.off  { background: var(--panel-2); color: var(--ink-dim); }

/* Zone 2 — Metriken */
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-4);
  padding: var(--s-2) 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-dim);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}
.meta:empty { display: none; }
.meta b { color: var(--ink); font-weight: 620; }
.meta .badge { margin: -1px 0; }

/* Zone 3 — tmux-Pane */
.pane {
  position: relative;
  /* Terminal bleibt bewusst dunkel — auch im hellen Theme */
  background: oklch(0.135 0.012 265);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 9px 11px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: oklch(0.775 0.012 265);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-height: 128px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease-out);
}
.pane::after {
  content: "Terminal öffnen";
  position: absolute;
  right: 7px;
  bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--accent) 88%, black);
  color: oklch(0.14 0.02 250);
  font-family: system-ui, sans-serif;
  font-size: 10.5px;
  font-weight: 650;
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
}
.pane:hover { border-color: color-mix(in oklab, var(--accent) 70%, var(--line)); }
.pane:hover::after { opacity: 1; }
.pane-empty::after { content: none; }   /* der leere Pane sagt den Hinweis schon im Text */
.pane-empty {
  color: oklch(0.58 0.012 265);
  font-style: italic;
  max-height: none;
}

/* Zone 4 — Composer (Vorlagen + Prompt gehören zusammen) */
.composer {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--inset);
  transition: border-color var(--dur) var(--ease-out);
}
.composer:focus-within { border-color: color-mix(in oklab, var(--accent) 55%, var(--line)); }

.tmpls { display: flex; flex-wrap: wrap; gap: 5px; }
.tmpl {
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  font-size: var(--fs-2xs);
  font-weight: 550;
  white-space: nowrap;
  transition: color var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out),
              background-color var(--dur) var(--ease-out);
}
.tmpl:hover { color: var(--ink); background: var(--panel-2); border-color: var(--ink-dim); }
.tmpl:active { transform: scale(0.97); }

.prompt-row { display: flex; gap: 6px; }
.prompt-row input {
  flex: 1;
  min-width: 0;
  height: 36px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  padding: 0 11px;
  font-size: var(--fs-md);
  transition: border-color var(--dur) var(--ease-out);
}
.prompt-row input::placeholder { color: var(--off); }
.prompt-row input:hover { border-color: var(--ink-dim); }
.prompt-row input:disabled { opacity: 0.55; cursor: progress; }

/* Werkzeug-Buttons im Composer — eine Form für 🎤/📎/📷 */
.prompt-row .attach {
  width: 36px;
  height: 36px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-dim);
  transition: color var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out),
              background-color var(--dur) var(--ease-out);
}
.prompt-row .attach:hover { color: var(--ink); border-color: var(--ink-dim); background: var(--panel-2); }
.prompt-row .attach:active { transform: scale(0.94); }

.prompt-row button:not(.attach) {
  flex: none;
  height: 36px;
  padding: 0 var(--s-3);
  background: var(--accent);
  border: 0;
  border-radius: var(--r-sm);
  color: var(--accent-ink);
  font-size: var(--fs-md);
  font-weight: 640;
  transition: filter var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.prompt-row button:not(.attach):hover { filter: brightness(1.08); }
.prompt-row button:not(.attach):active { transform: scale(0.96); }
.prompt-row button:disabled { opacity: 0.45; cursor: default; transform: none; }

/* Aufnahme läuft — Zustand, kein Deko-Blinken */
.mic-active {
  color: var(--bad-ink) !important;
  border-color: color-mix(in oklab, var(--bad) 60%, var(--line)) !important;
  background: color-mix(in oklab, var(--bad) 14%, var(--panel)) !important;
  animation: mic-pulse 1.6s var(--ease) infinite;
}
.mic-active .i-mic { display: none; }
.mic-active::after {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: currentColor;
}
@keyframes mic-pulse {
  50% { box-shadow: 0 0 0 4px color-mix(in oklab, var(--bad) 16%, transparent); }
}

/* Zone 5 — Aktionen */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: var(--s-1);
  border-top: 1px solid var(--line-soft);
  margin-top: auto;
}
.act-sep {
  /* Umbruch statt Strich: die Gefahren-Aktionen bekommen ihre eigene Zeile */
  flex-basis: 100%;
  height: 0;
  margin: 2px 0 0;
}
.act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-dim);
  font-size: var(--fs-sm);
  font-weight: 550;
  white-space: nowrap;
  transition: color var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out),
              background-color var(--dur) var(--ease-out);
}
.act:hover { color: var(--ink); background: var(--panel-2); border-color: var(--ink-dim); }
.act:active { transform: scale(0.97); }
.act:disabled { opacity: 0.5; cursor: default; transform: none; }
.act.primary {
  background: color-mix(in oklab, var(--accent) 15%, var(--panel));
  border-color: color-mix(in oklab, var(--accent) 30%, var(--line));
  color: var(--accent-deep);
  font-weight: 620;
}
.act.primary:hover { background: color-mix(in oklab, var(--accent) 24%, var(--panel)); color: var(--accent-deep); }
.act.go {
  background: color-mix(in oklab, var(--ok) 15%, var(--panel));
  border-color: color-mix(in oklab, var(--ok) 30%, var(--line));
  color: var(--ok-ink);
  font-weight: 620;
}
.act.go:hover { background: color-mix(in oklab, var(--ok) 24%, var(--panel)); color: var(--ok-ink); }
.act.danger:hover {
  color: var(--bad-ink);
  border-color: color-mix(in oklab, var(--bad) 55%, var(--line));
  background: color-mix(in oklab, var(--bad) 10%, var(--panel));
}

.note {
  color: var(--ink-dim);
  font-size: var(--fs-sm);
  line-height: 1.5;
  max-width: 62ch;
  text-wrap: pretty;
}
.note a { color: var(--accent); }

/* Outbox — Ergebnisse, die der Bot abgelegt hat */
.outbox {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-2) 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--inset);
}
.outbox .ob-head {
  color: var(--off);
  font-size: var(--fs-2xs);
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.outbox .ob-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.outbox a {
  flex: 1;
  min-width: 0;
  color: var(--accent);
  font-size: var(--fs-xs);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.outbox a:hover { text-decoration: underline; }
.outbox .ob-del {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: var(--r-xs);
  color: var(--off);
  font-size: var(--fs-xs);
  transition: color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}
.outbox .ob-del:hover { color: var(--bad-ink); background: var(--panel-2); }

/* FreePBX — letzte Anrufe */
.cdr {
  font-size: var(--fs-xs);
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.cdr div {
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--s-2);
  padding: 3px 0;
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
}
.cdr div > span { min-width: 0; overflow-wrap: anywhere; }
.cdr div:last-child { border-bottom: 0; }

/* KI-Stack — Container-Liste */
.stack {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1px var(--s-3);
}
.st-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 2px 0;
}
.st-row .dot { width: 7px; height: 7px; margin-top: 0; box-shadow: none; }
.st-name {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-xs);
  color: var(--ink-dim);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.st-btn {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: var(--r-xs);
  color: var(--off);
  font-size: var(--fs-xs);
  transition: color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}
.st-btn:hover { color: var(--ink); background: var(--panel-2); }
.st-btn.go { color: var(--ok-ink); }

/* Site-Health-Monitor (NAS-Karte) */
.sitehealth {
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--inset);
}
.sh-title { font-weight: 620; font-size: var(--fs-sm); margin-bottom: var(--s-2); }
.sh-sub { font-weight: 400; font-size: var(--fs-2xs); color: var(--off); margin-left: 6px; }
.sh-master {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 7px;
  cursor: pointer;
}
.sh-list { display: grid; grid-template-columns: 1fr 1fr; gap: 1px var(--s-3); }
.sh-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
  cursor: pointer;
  font-size: var(--fs-xs);
  color: var(--ink-dim);
}
.sh-row:hover { color: var(--ink); }
.sh-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-port { color: var(--off); font-size: var(--fs-2xs); font-family: var(--mono); }
.sh-box input[type="checkbox"] { accent-color: var(--ok); width: 15px; height: 15px; cursor: pointer; }

/* ---------- 7. Terminal-Overlay ------------------------------------------ */
.term-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: grid;
  place-items: center;
  padding: var(--s-4);
  background: color-mix(in oklab, oklch(0.09 0.01 265) 72%, transparent);
  backdrop-filter: blur(3px);
}
.term-frame {
  width: min(1100px, 100%);
  height: min(720px, 92dvh);
  background: oklch(0.135 0.012 265);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: term-in 200ms var(--ease-out);
}
@keyframes term-in { from { opacity: 0; transform: translateY(8px) scale(0.995); } }
.term-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--line);
  color: oklch(0.94 0.008 265);
  font-size: var(--fs-md);
  font-weight: 620;
}
.term-head .ghost-btn { color: oklch(0.72 0.014 265); border-color: oklch(0.30 0.016 265); padding: 0 12px; }
.term-head .ghost-btn:hover { color: oklch(0.96 0.008 265); background: oklch(0.22 0.014 265); }
.term-hint {
  margin-left: auto;
  color: oklch(0.64 0.014 265);
  font-size: var(--fs-xs);
  font-weight: 400;
}
.term-mount { flex: 1; padding: 6px; min-height: 0; }
.term-mount .xterm { height: 100%; }

/* ---------- 8. Toast ----------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  z-index: var(--z-toast);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--r-md);
  padding: 10px var(--s-4);
  font-size: var(--fs-md);
  box-shadow: 0 6px 20px oklch(0 0 0 / 0.28);
  animation: toast-in 180ms var(--ease-out);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- 9. Responsive ------------------------------------------------ */
@media (max-width: 640px) {
  .topbar-inner {
    padding: var(--s-2) var(--s-3);
    gap: var(--s-2);
    row-gap: var(--s-2);
    flex-wrap: wrap;
  }
  .brand-sub { display: none; }
  .brand { flex: 1 1 auto; }
  /* Online-Zähler bleibt sichtbar (wichtigste Information), Zeitstempel weicht */
  .fleet-status { padding: 4px 9px; margin-left: auto; }
  .updated { display: none; }
  /* Aktionen als eigene, volle Zeile — sonst stapeln sie rechtsbündig übereinander */
  .topbar-right { flex: 1 0 100%; margin-left: 0; gap: 6px; justify-content: space-between; flex-wrap: wrap; }
  .btn-group { flex: 0 1 auto; gap: 1px; }
  .topbar-right .ghost-btn { min-width: 38px; padding: 0 6px; }
  .topbar-right > .ghost-btn { padding: 0 10px; }
  .tb-sep { display: none; }
  #logout { padding: 0 10px; }
  #logout span { display: none; }

  /* Prompt-Feld auf volle Breite, Werkzeuge darunter */
  .prompt-row { flex-wrap: wrap; }
  .prompt-row input { flex: 1 0 100%; }
  .prompt-row button:not(.attach) { margin-left: auto; }

  .broadcast-row { padding: var(--s-2) var(--s-3); flex-wrap: wrap; }
  .broadcast-label { width: 100%; }

  .grid { grid-template-columns: 1fr; padding: var(--s-3); gap: var(--s-3); }
  .card { padding: var(--s-3); }

  /* iOS zoomt bei Inputs < 16px in die Seite — deshalb hier 16px */
  .prompt-row input, .login-card input, .broadcast-row input { font-size: 16px; }

  /* Terminal = Vollbild auf dem Handy */
  .term-overlay { padding: 0; }
  .term-frame { width: 100%; height: 100dvh; border-radius: 0; border: 0; }
  .term-hint { display: none; }

  .sh-list { grid-template-columns: 1fr; }
  .toast { left: var(--s-3); right: var(--s-3); bottom: var(--s-3); transform: none; max-width: none; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
}

/* Touch-Geräte: größere Ziele */
@media (pointer: coarse) {
  .act { height: 38px; padding: 0 14px; font-size: var(--fs-md); }
  .ghost-btn { min-width: 40px; height: 40px; padding: 0 11px; }
  .topbar-right > .ghost-btn { padding: 0 14px; }
  .tmpl { height: 28px; padding: 0 12px; font-size: var(--fs-xs); }
  .prompt-row input { height: 44px; padding: 0 12px; }
  .prompt-row .attach { width: 44px; height: 44px; }
  .prompt-row button:not(.attach) { height: 44px; padding: 0 16px; }
  .st-btn, .outbox .ob-del { width: 32px; height: 32px; }
  .pane { max-height: 110px; }
}

/* Mobil + Touch zusammen: die coarse-Regeln oben würden die Topbar-Icons auf 40px
   aufblasen — dann passt die Aktionszeile nicht mehr in eine Zeile. Hier gewinnt Mobil.
   Die großen 44px-Ziele bleiben da, wo wirklich getippt wird (Karten-Aktionen, Prompt). */
@media (max-width: 640px) {
  .topbar-right { gap: 5px; }
  .btn-group { padding: 1px; gap: 0; }
  .topbar-right .ghost-btn { min-width: 34px; height: 38px; padding: 0 5px; }
  .topbar-right > .ghost-btn { min-width: 38px; padding: 0 8px; }
  .topbar-right .i { width: 17px; height: 17px; }
}

/* ---------- 10. Reduced Motion ------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .act:active, .tmpl:active, .ghost-btn:active,
  .prompt-row button:active, .login-card button:active,
  .broadcast-row button:active { transform: none; }
}

/* ---------- 12. Boot-Gerüst + Zustands-Motion ---------------------------- */
/* Das Gerüst steht bis showApp()/showLogin() es entfernt. Es benutzt dieselben
   Flächen, Radien und Abstände wie die echten Karten — dadurch springt beim
   Übergang nichts. Kein Spinner: Produkt-UI zeigt Struktur, nicht Warten. */
.boot {
  position: fixed;
  inset: 0;
  z-index: var(--z-sticky);
  background: var(--bg);
  overflow: hidden;
}
.boot-topbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px var(--s-4);
  background: var(--bg-2);
  border-bottom: 1px solid var(--line-soft);
}
.boot-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--panel-2);
  color: var(--accent);
}
.boot-mark .i { width: 19px; height: 19px; }
.boot-brand { display: flex; flex-direction: column; line-height: 1.15; }
.boot-name { font-size: var(--fs-xl); font-weight: 650; color: var(--ink); }
.boot-sub  { font-size: var(--fs-xs); color: var(--off); }

.boot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  align-items: start;
  gap: var(--s-4);
  padding: var(--s-4);
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}
.sk-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-4);
}
.sk-card .sk-dot  { grid-row: span 2; }
.sk-card .sk-pane { grid-column: 1 / -1; }

/* Ein Platzhalter-Element: Fläche in Panel-Nähe, damit es ruhig bleibt. */
.sk {
  display: block;
  background: var(--inset);
  border-radius: var(--r-xs);
  height: 11px;
}
.sk-dot  { width: 10px; height: 10px; border-radius: 50%; }
.sk-pill { margin-left: auto; width: 104px; height: 22px; border-radius: 999px; }
.sk-line { height: 12px; }
.sk-line.w30 { width: 30%; } .sk-line.w35 { width: 35%; }
.sk-line.w40 { width: 40%; } .sk-line.w45 { width: 45%; }
.sk-line.w50 { width: 50%; } .sk-line.w55 { width: 55%; }
.sk-line.w60 { width: 60%; } .sk-line.w65 { width: 65%; }
.sk-line.w70 { width: 70%; }
.sk-pane { height: 76px; margin-top: var(--s-2); border-radius: var(--r-md); }

/* Ein einziger, langsamer Puls über alle Platzhalter — kein Wander-Shimmer,
   der bei 9 Karten wie Flimmern wirkt. */
.sk { animation: sk-breathe 1.6s var(--ease-out, ease-out) infinite; }
@keyframes sk-breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* Zustands-Motion: der Punkt pulst, solange ein Bot wirklich arbeitet.
   Das ist Zustand, keine Dekoration — PRODUCT.md Prinzip 1 und 4. */
.dot.working {
  animation: dot-pulse 1.8s var(--ease-out, ease-out) infinite;
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--ok) 55%, transparent); }
  70%      { box-shadow: 0 0 0 7px color-mix(in oklab, var(--ok) 0%, transparent); }
}

/* Eine Karte, die sich gerade geändert hat, blitzt einmal kurz am Rand auf.
   Nur bei echter Änderung — der Diff-Renderer ersetzt sonst nichts mehr. */
.card.card-updated { animation: card-touch 900ms var(--ease-out, ease-out) 1; }
@keyframes card-touch {
  0%   { border-color: color-mix(in oklab, var(--accent) 55%, var(--line)); }
  100% { border-color: var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  .sk, .dot.working, .card.card-updated { animation: none; }
  .sk { opacity: 0.7; }
}
