/* Agenten-Leitstand – Gestaltung. Farben als Tokens, Dunkelmodus eigens abgestimmt (nicht invertiert). */

:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --surface-sunken: #f0efec;
  --border: #e5e4df;
  --border-strong: #d6d5cf;
  --text: #121211;
  --text-2: #52514e;
  --text-3: #85847e;
  --accent: #1c5cab;
  --accent-hover: #184f95;
  --accent-soft: #e7f0fc;
  --accent-text: #1c5cab;
  --sidebar: #101827;
  --sidebar-2: #172235;
  --sidebar-text: #c9d1de;
  --sidebar-muted: #7d8aa0;
  --sidebar-active: #22314a;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;

  --ok: #0ca30c;
  --ok-text: #0a7a0a;
  --ok-soft: #e8f6e8;
  --warning: #fab219;
  --warning-text: #8a5a00;
  --warning-soft: #fdf3dc;
  --critical: #d03b3b;
  --critical-text: #b42f2f;
  --critical-soft: #fbeaea;
  --info: #2a78d6;
  --info-text: #1c5cab;
  --info-soft: #e7f0fc;
  --neutral: #a3a29c;
  --neutral-text: #5e5d59;
  --neutral-soft: #efeeea;
  --empty: #e9e8e3;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 20px 48px -12px rgba(16, 24, 40, 0.25);
  --radius: 12px;
  --radius-sm: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e0d;
    --surface: #1a1a19;
    --surface-2: #1f1f1e;
    --surface-sunken: #141413;
    --border: #2c2c2a;
    --border-strong: #3a3a37;
    --text: #f4f4f2;
    --text-2: #c3c2b7;
    --text-3: #8d8c85;
    --accent: #3987e5;
    --accent-hover: #5598e7;
    --accent-soft: #15253a;
    --accent-text: #86b6ef;
    --sidebar: #0a0f18;
    --sidebar-2: #111827;
    --sidebar-active: #1b2a41;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --ok-text: #5ccf5c;
    --ok-soft: #142614;
    --warning-text: #fab219;
    --warning-soft: #2b2310;
    --critical: #e66767;
    --critical-text: #f08a8a;
    --critical-soft: #2e1616;
    --info-text: #86b6ef;
    --info-soft: #15253a;
    --neutral: #6c6b66;
    --neutral-text: #b4b3ab;
    --neutral-soft: #262624;
    --empty: #2a2a28;
    --shadow-sm: none;
    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.02);
    --shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e0d;
  --surface: #1a1a19;
  --surface-2: #1f1f1e;
  --surface-sunken: #141413;
  --border: #2c2c2a;
  --border-strong: #3a3a37;
  --text: #f4f4f2;
  --text-2: #c3c2b7;
  --text-3: #8d8c85;
  --accent: #3987e5;
  --accent-hover: #5598e7;
  --accent-soft: #15253a;
  --accent-text: #86b6ef;
  --sidebar: #0a0f18;
  --sidebar-2: #111827;
  --sidebar-active: #1b2a41;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --ok-text: #5ccf5c;
  --ok-soft: #142614;
  --warning-text: #fab219;
  --warning-soft: #2b2310;
  --critical: #e66767;
  --critical-text: #f08a8a;
  --critical-soft: #2e1616;
  --info-text: #86b6ef;
  --info-soft: #15253a;
  --neutral: #6c6b66;
  --neutral-text: #b4b3ab;
  --neutral-soft: #262624;
  --empty: #2a2a28;
  --shadow-sm: none;
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.02);
  --shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 0;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num, .kpi-value, .stage-count, td.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Grundgerüst ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 18px 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(145deg, #2a78d6, #1c5cab 60%, #184f95);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 4px 12px rgba(42, 120, 214, 0.35);
}
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-weight: 650; color: #fff; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--sidebar-muted); letter-spacing: 0.12em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--sidebar-muted); padding: 18px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--sidebar-text); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--sidebar-2); color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 2px 0 0 #5598e7; }
.nav a .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .count { font-size: 11px; font-weight: 650; background: #eda100; color: #1a1300; padding: 1px 7px; border-radius: 999px; }
.nav .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sidebar-foot { padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.theme-toggle {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  background: none; border: 0; color: var(--sidebar-muted); cursor: pointer; text-align: left;
}
.theme-toggle:hover { background: var(--sidebar-2); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 32px; min-height: 76px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs { font-size: 12px; color: var(--text-3); min-height: 18px; }
.crumbs a { color: var(--text-3); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.updated { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.icon-btn.menu-btn { display: none; }
.content { padding: 28px 32px 56px; max-width: 1400px; width: 100%; outline: none; }
.sidebar-scrim { display: none; }

/* ---------- Bausteine ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 550; font-size: 13px; cursor: pointer;
  box-shadow: var(--shadow-sm); white-space: nowrap; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--critical-text); }
.btn-danger:hover { background: var(--critical-soft); border-color: var(--critical); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface); border-color: var(--border); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text-2); }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.spin svg.i { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; }
.card-head h2, .card-head h3 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -0.005em; }
.card-head .sub { color: var(--text-3); font-size: 12px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px 20px 20px; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 32px 0 12px; }
.section-title h2 { margin: 0; font-size: 15px; font-weight: 650; }
.section-title .sub { color: var(--text-3); font-size: 12px; }
.section-title a { margin-left: auto; font-size: 13px; font-weight: 550; }
.muted { color: var(--text-3); }
.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }

/* Status-Pille: Punkt + Text, nie nur Farbe */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral-text);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.ok { background: var(--ok-soft); color: var(--ok-text); }
.pill.ok::before { background: var(--ok); }
.pill.running, .pill.info { background: var(--info-soft); color: var(--info-text); }
.pill.running::before { background: var(--info); animation: pulse 1.6s ease-in-out infinite; }
.pill.warning, .pill.paused { background: var(--warning-soft); color: var(--warning-text); }
.pill.warning::before, .pill.paused::before { background: var(--warning); }
.pill.critical, .pill.offline, .pill.error { background: var(--critical-soft); color: var(--critical-text); }
.pill.critical::before, .pill.offline::before, .pill.error::before { background: var(--critical); }
.pill.neutral::before { background: var(--neutral); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--info) 25%, transparent); } }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); background: var(--surface-sunken); border: 1px solid var(--border); padding: 1px 8px; border-radius: 6px; white-space: nowrap; }
.tag svg.i { width: 13px; height: 13px; }

/* ---------- KPI-Kacheln ---------- */
.kpi { padding: 16px 18px 15px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-label { font-size: 12px; font-weight: 550; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value.small { font-size: 20px; line-height: 1.6; }
.kpi-hint { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .flag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; }
.kpi .flag.warning { color: var(--warning-text); }
.kpi .flag.critical { color: var(--critical-text); }
.kpi .flag svg.i { width: 13px; height: 13px; }

/* ---------- Agentenkarten ---------- */
.agent-card { display: flex; flex-direction: column; overflow: hidden; }
.agent-card-head { display: flex; gap: 14px; align-items: flex-start; padding: 20px 20px 0; }
.agent-icon {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent-text); border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
}
.agent-icon svg.i { width: 21px; height: 21px; }
.agent-icon.lg { width: 52px; height: 52px; border-radius: 13px; }
.agent-icon.lg svg.i { width: 25px; height: 25px; }
.agent-title { min-width: 0; flex: 1; }
.agent-title h3 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.agent-title h3 a { color: var(--text); }
.agent-title .meta { color: var(--text-3); font-size: 12px; margin-top: 1px; }
.agent-state { padding: 10px 20px 0; font-size: 13px; color: var(--text-2); min-height: 30px; }
.agent-state.problem { color: var(--critical-text); }
.agent-kpis { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; margin: 16px 20px 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.agent-kpis > div { padding: 10px 12px; min-width: 0; }
.agent-kpis > div + div { border-left: 1px solid var(--border); }
.agent-kpis .v { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-kpis .l { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-card .uptime-wrap { padding: 16px 20px 0; }
.agent-card-foot { margin-top: auto; display: flex; gap: 8px; align-items: center; padding: 16px 20px; margin-top: 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.agent-card-foot .spacer { flex: 1; }
.agent-card.offline .agent-icon, .agent-card.error .agent-icon { background: var(--critical-soft); color: var(--critical-text); border-color: transparent; }

/* Mini-Pipeline */
.mini-flow { display: flex; align-items: stretch; margin: 16px 20px 0; gap: 0; }
.mini-step { flex: 1; min-width: 0; position: relative; padding: 9px 10px 8px; background: var(--surface-sunken); border: 1px solid var(--border); }
.mini-step:first-child { border-radius: 9px 0 0 9px; }
.mini-step:last-child { border-radius: 0 9px 9px 0; }
.mini-step + .mini-step { border-left: 0; }
.mini-step + .mini-step::before {
  content: ""; position: absolute; left: -6px; top: 50%; width: 10px; height: 10px; transform: translateY(-50%) rotate(45deg);
  background: var(--surface-sunken); border-top: 1px solid var(--border); border-right: 1px solid var(--border); z-index: 1;
}
.mini-step .c { font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; }
.mini-step .t { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-step.warning .c { color: var(--warning-text); }
.mini-step.skipped { opacity: 0.55; }

/* Erreichbarkeit */
.uptime-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.uptime-head b { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.uptime { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; height: 26px; }
.uptime span { border-radius: 2px; background: var(--empty); }
.uptime span.ok, .uptime span.running { background: var(--ok); }
.uptime span.paused { background: color-mix(in srgb, var(--ok) 55%, var(--surface)); }
.uptime span.warning { background: var(--warning); }
.uptime span.offline, .uptime span.error { background: var(--critical); }
.uptime span:hover { filter: brightness(1.15); }
.uptime-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ---------- Workflow-Diagramm ---------- */
.flow { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 34px; position: relative; }
.stage { position: relative; }
.stage-node {
  position: relative; padding: 14px 14px 13px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); min-height: 118px; display: flex; flex-direction: column; gap: 2px;
}
.stage + .stage .stage-node::before {
  content: ""; position: absolute; left: -35px; top: 50%; width: 34px; border-top: 2px solid var(--border-strong);
}
.stage + .stage .stage-node::after {
  content: ""; position: absolute; left: -9px; top: calc(50% - 5px); width: 8px; height: 8px;
  border-top: 2px solid var(--border-strong); border-right: 2px solid var(--border-strong); transform: rotate(45deg);
}
.stage-top { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.stage-idx { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--text-3); flex: none; }
.stage-idx svg.i { width: 13px; height: 13px; }
.stage-count { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; margin-top: 6px; line-height: 1.1; }
.stage-hint { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-node.ok { border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.stage-node.ok .stage-idx { color: var(--ok-text); background: var(--ok-soft); border-color: transparent; }
.stage-node.warning { border-color: color-mix(in srgb, var(--warning) 60%, var(--border)); background: color-mix(in srgb, var(--warning-soft) 55%, var(--surface-2)); }
.stage-node.warning .stage-idx { color: var(--warning-text); background: var(--warning-soft); border-color: transparent; }
.stage-node.warning .stage-count { color: var(--warning-text); }
.stage-node.skipped { border-style: dashed; background: transparent; }
.stage-node.skipped .stage-count { color: var(--text-3); }
.stage-exits { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; padding-left: 16px; position: relative; }
.stage-exits::before { content: ""; position: absolute; left: 6px; top: -10px; bottom: 12px; border-left: 2px dashed var(--border-strong); }
.exit { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; }
.exit::before { content: ""; position: absolute; left: -10px; top: 50%; width: 9px; border-top: 2px dashed var(--border-strong); }
.exit b { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--text); }
.exit.critical { border-color: color-mix(in srgb, var(--critical) 45%, var(--border)); color: var(--critical-text); }
.exit.critical b { color: var(--critical-text); }

/* ---------- Diagramm ---------- */
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.tooltip {
  position: fixed; z-index: 100; pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity 0.1s, transform 0.1s;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 9px; box-shadow: var(--shadow-lg); padding: 9px 11px; font-size: 12px; min-width: 150px;
}
.tooltip.show { opacity: 1; transform: none; }
.tooltip .tt-title { font-weight: 650; margin-bottom: 5px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 7px; color: var(--text-2); }
.tooltip .tt-row b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; padding-left: 12px; }
.tooltip .tt-row i { width: 9px; height: 9px; border-radius: 2px; }

/* ---------- Listen ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; padding: 13px 20px; border-top: 1px solid var(--border); align-items: flex-start; }
.list-item:first-child { border-top: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--surface-2); }
.list-item .body { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.list-item .detail { color: var(--text-2); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.list-item .ctx { color: var(--text-3); font-size: 12px; margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.list-item .actions { display: flex; gap: 6px; flex: none; align-items: center; }
.list-item time { color: var(--text-3); font-size: 12px; white-space: nowrap; flex: none; }
.task-mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--warning-soft); color: var(--warning-text); }
.dot-tone { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--neutral); box-shadow: 0 0 0 3px var(--surface); }
.dot-tone.ok { background: var(--ok); }
.dot-tone.warning { background: var(--warning); }
.dot-tone.critical { background: var(--critical); }
.dot-tone.info { background: var(--info); }
.timeline .list-item { position: relative; }
.timeline .list-item::before { content: ""; position: absolute; left: 24px; top: 0; bottom: 0; border-left: 1px solid var(--border); }
.timeline .list-item:first-child::before { top: 18px; }
.timeline .list-item:last-child::before { bottom: calc(100% - 18px); }
.timeline .dot-tone { position: relative; z-index: 1; }
.day-head { padding: 14px 20px 6px; font-size: 12px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; border-top: 1px solid var(--border); background: var(--surface-2); }
.day-head:first-child { border-top: 0; border-radius: var(--radius) var(--radius) 0 0; }

.empty { padding: 36px 20px; text-align: center; color: var(--text-3); }
.empty svg.i { width: 28px; height: 28px; margin-bottom: 8px; color: var(--ok); }
.empty b { display: block; color: var(--text-2); font-weight: 600; margin-bottom: 2px; }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; border: 1px solid; }
.banner.critical { background: var(--critical-soft); border-color: color-mix(in srgb, var(--critical) 35%, transparent); color: var(--critical-text); }
.banner.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 50%, transparent); color: var(--warning-text); }
.banner ul { margin: 2px 0 0; padding-left: 18px; color: var(--text-2); }
.banner b { display: block; }
.banner svg.i { margin-top: 2px; }

/* Filter-Chips und Tabs */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 550; color: var(--text-2); }
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip .n { font-size: 11px; opacity: 0.75; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tab { background: none; border: 0; padding: 12px 10px 11px; cursor: pointer; font-weight: 550; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab .n { font-size: 11px; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; font-variant-numeric: tabular-nums; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.text { color: var(--text-2); min-width: 260px; max-width: 520px; }
td.nowrap, td.datetime { white-space: nowrap; }
td.num { text-align: right; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
dl.kv { display: grid; grid-template-columns: minmax(160px, max-content) 1fr; margin: 0; }
dl.kv dt, dl.kv dd { padding: 11px 20px; border-top: 1px solid var(--border); margin: 0; }
dl.kv dt { color: var(--text-3); font-size: 13px; }
dl.kv dd { overflow-wrap: anywhere; }
dl.kv dt:first-of-type, dl.kv dd:first-of-type { border-top: 0; }

/* Kopfbereich der Agentenseite */
.agent-hero { display: flex; gap: 18px; align-items: center; margin-bottom: 22px; flex-wrap: wrap; }
.agent-hero .agent-title h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.agent-hero .agent-title p { margin: 4px 0 0; color: var(--text-2); max-width: 70ch; }
.agent-hero .controls { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

/* ---------- Seitenleiste (Detail) ---------- */
.drawer { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.drawer::before { content: ""; position: absolute; inset: 0; background: rgba(10, 12, 18, 0.45); opacity: 0; transition: opacity 0.18s; }
.drawer.open { pointer-events: auto; }
.drawer.open::before { opacity: 1; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(620px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex; flex-direction: column;
}
.drawer.open .drawer-panel { transform: none; }
.drawer-head { display: flex; gap: 12px; align-items: flex-start; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.drawer-head .sub { color: var(--text-3); font-size: 12px; margin-top: 3px; display: flex; gap: 8px; align-items: center; }
.drawer-head .spacer { flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 24px; }
.drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin-bottom: 18px; }
.fields .l { font-size: 12px; color: var(--text-3); }
.fields .v { overflow-wrap: anywhere; }
.drawer textarea { width: 100%; min-height: 220px; resize: vertical; padding: 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); line-height: 1.55; }
.drawer textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.drawer .textblock { white-space: pre-wrap; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; line-height: 1.55; }
.drawer .img { display: block; max-width: 100%; max-height: 280px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 16px; }
.drawer .label { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 0 0 6px; }
.transcript { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 84%; padding: 9px 13px; border-radius: 14px; line-height: 1.5; }
.bubble .who { font-size: 11px; font-weight: 600; color: var(--text-3); margin-bottom: 2px; display: flex; gap: 8px; }
.bubble.caller { align-self: flex-start; background: var(--surface-sunken); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.agent { align-self: flex-end; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); border-bottom-right-radius: 4px; }

/* Bestätigungsdialog und Meldungen */
.modal { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; background: rgba(10, 12, 18, 0.5); padding: 16px; }
.modal.open { display: grid; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(420px, 100%); padding: 22px; }
.modal-box h3 { margin: 0 0 6px; font-size: 16px; }
.modal-box p { margin: 0 0 20px; color: var(--text-2); }
.modal-box .row { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--sidebar); color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 420px; font-size: 13px; animation: toast-in 0.2s ease-out; }
.toast .t-sub { color: var(--sidebar-text); font-size: 12px; }
.toast svg.i { margin-top: 2px; }
.toast.ok svg.i { color: #5ccf5c; }
.toast.warning svg.i { color: #fab219; }
.toast.critical svg.i { color: #f08a8a; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.skeleton { background: linear-gradient(90deg, var(--surface-sunken), var(--surface-2), var(--surface-sunken)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius); border: 1px solid var(--border); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Benutzer in der Seitenleiste ---------- */
.user-box { display: flex; align-items: center; gap: 10px; padding: 10px 10px 2px; margin-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; background: #22314a; color: #fff; font-size: 12px; font-weight: 650; letter-spacing: 0.02em; }
.user-box .who { flex: 1; min-width: 0; }
.user-box .n { color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-box .r { color: var(--sidebar-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-box button { background: none; border: 0; color: var(--sidebar-muted); cursor: pointer; width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; }
.user-box button:hover { background: var(--sidebar-2); color: #fff; }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field small { color: var(--text-3); font-size: 12px; }
.field input, .field select {
  height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-weight: 550; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.btn-block { width: 100%; height: 40px; }
.form-error { background: var(--critical-soft); color: var(--critical-text); border-radius: 8px; padding: 9px 12px; margin-bottom: 14px; font-size: 13px; }
.modal-box.wide { width: min(520px, 100%); }
.modal-box .row.split { justify-content: space-between; }
.modal-box .row .left { margin-right: auto; }
.hint { background: var(--info-soft); color: var(--info-text); border-radius: 8px; padding: 9px 12px; font-size: 12.5px; margin-bottom: 14px; }

/* ---------- Anmeldeseite ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%), var(--bg); }
.login-wrap { width: min(400px, 100%); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; justify-content: center; }
.login-brand .brand-mark { width: 42px; height: 42px; border-radius: 11px; }
.login-brand .brand-mark svg { width: 24px; height: 24px; }
.login-title { font-weight: 700; font-size: 18px; letter-spacing: -0.015em; }
.login-sub { font-size: 12px; color: var(--text-3); letter-spacing: 0.06em; }
.login-card { padding: 28px 28px 22px; box-shadow: var(--shadow-lg); }
.login-card h1 { margin: 0 0 4px; font-size: 20px; letter-spacing: -0.015em; }
.login-card p.muted { margin: 0 0 20px; font-size: 13px; }
.login-card .btn-ghost { margin-top: 8px; }
.login-error { background: var(--critical-soft); color: var(--critical-text); border-radius: 8px; padding: 9px 12px; margin-bottom: 14px; font-size: 13px; }
.qr { background: #fff; border-radius: 12px; padding: 12px; width: 220px; height: 220px; margin: 4px auto 14px; }
.qr svg { width: 100%; height: 100%; display: block; }
.secret { margin-bottom: 14px; font-size: 13px; }
.secret summary { cursor: pointer; color: var(--accent-text); }
.secret code { display: block; font-family: var(--mono); font-size: 15px; letter-spacing: 0.08em; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-top: 6px; user-select: all; overflow-wrap: anywhere; }
.codes { columns: 2; gap: 12px; margin: 0 0 16px; padding: 12px 14px 12px 34px; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: 10px; font-family: var(--mono); font-size: 15px; line-height: 1.9; }
.login-card .btn + .btn { margin-top: 8px; }
.sec-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.sec-row:first-of-type { border-top: 0; }
.sec-row .grow { flex: 1; min-width: 0; }
.sec-row .t { font-weight: 600; }
.sec-row .d { font-size: 12.5px; color: var(--text-3); }
.login-foot { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 18px; }

/* ---------- Benutzerverwaltung ---------- */
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell .avatar { background: var(--accent-soft); color: var(--accent-text); }
.user-cell .n { font-weight: 600; }
.user-cell .e { color: var(--text-3); font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.audit td { font-size: 12.5px; }
.audit code { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.readonly-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }

/* ---------- Responsiv ---------- */
@media (max-width: 1180px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .flow { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .stage + .stage .stage-node::before, .stage + .stage .stage-node::after { display: none; }
}
@media (max-width: 960px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; z-index: 70; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: none; }
  .sidebar-scrim.open { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(10, 12, 18, 0.45); }
  .icon-btn.menu-btn { display: grid; }
  .topbar { padding: 12px 16px; min-height: 64px; }
  .content { padding: 20px 16px 48px; }
  .updated { display: none; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .list-item { padding: 12px 16px; flex-wrap: wrap; }
  .list-item .actions { width: 100%; padding-left: 42px; }
  .agent-hero .controls { margin-left: 0; width: 100%; }
}
@media (max-width: 520px) {
  .grid-kpi { gap: 10px; }
  .kpi { padding: 13px 14px; }
  .flow { grid-template-columns: minmax(0, 1fr); }
  .kpi-value { font-size: 22px; }
  .kpi-value.small { font-size: 16px; }
  .agent-kpis > div { padding: 9px 10px; }
  .agent-kpis .v { font-size: 16px; }
  #refreshBtn .lbl { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  .pill::before, .dot-tone, .uptime span { forced-color-adjust: none; }
}

.modal-box .codes { margin-bottom: 18px; }
.sec-row .avatar { background: var(--accent-soft); color: var(--accent-text); }
.sec-row .avatar svg.i { width: 16px; height: 16px; }

/* Veröffentlichte Beiträge */
.pub-note { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 14px; color: var(--text-2, var(--muted)); font-size: 13px; }
.pub-note.warn { color: var(--warning-text, #b7791f); }
.pub-note svg.i { flex: none; width: 16px; height: 16px; margin-top: 2px; }
.pub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.pub { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; color: inherit; text-decoration: none; background: var(--surface, transparent); transition: border-color .15s, transform .15s; }
.pub:hover { border-color: var(--accent); transform: translateY(-1px); }
.pub-img { position: relative; aspect-ratio: 4 / 5; background: var(--surface-2, #0b1220); }
.pub-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pub-kind { position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: rgba(0,0,0,.6); color: #fff; }
.pub-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.pub-meta { font-size: 12px; color: var(--text-3, var(--muted)); }
.pub-text { font-size: 13px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pub-link { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--accent-text, var(--accent)); }
.pub-link svg.i { width: 14px; height: 14px; }

/* Rückfragen (eigene Dialoge statt Browser-Fenster) */
.dlg-title { display: flex; align-items: center; gap: 8px; }
.dlg-warn { display: inline-flex; color: var(--critical); }
.dlg-warn svg.i { width: 18px; height: 18px; }
.dlg-text { white-space: pre-line; line-height: 1.55; }
.modal-box .btn-danger[data-yes] { background: var(--critical); border-color: var(--critical); color: #fff; }
.modal-box .btn-danger[data-yes]:hover { filter: brightness(0.92); }
