/* ════════════════════════════════════════════════════════════════
   Huginn Dashboard — Styles
   Dark theme is default; light theme via html[data-theme="light"].
   ════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: dark;
  --bg: #0a0c13;
  --bg-elev: #0f121b;
  --surface: #141823;
  --surface-2: #1b2030;
  --surface-3: #242a3c;
  --border: #242a3b;
  --border-strong: #343c55;
  --text: #e9ebf3;
  --text-2: #b0b6c9;
  --muted: #7f879e;

  --primary: #8b7cf8;
  --primary-strong: #6d5ef0;
  --primary-ink: #ffffff;
  --primary-soft: rgba(139, 124, 248, 0.14);
  --primary-ring: rgba(139, 124, 248, 0.45);
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #c026d3 100%);
  --grad-soft: linear-gradient(135deg, rgba(99,102,241,.18), rgba(192,38,211,.10));

  --green: #22c55e;   --green-soft: rgba(34, 197, 94, 0.14);
  --amber: #f59e0b;   --amber-soft: rgba(245, 158, 11, 0.15);
  --red: #f05252;     --red-soft: rgba(240, 82, 82, 0.15);
  --blue: #3b9eff;    --blue-soft: rgba(59, 158, 255, 0.15);
  --gray-soft: rgba(148, 156, 180, 0.14);

  /* Speaker colours */
  --sp-agent: #8b93ff;  --sp-agent-bg: rgba(99, 102, 241, 0.16);
  --sp-kunde: #34d399;  --sp-kunde-bg: rgba(52, 211, 153, 0.13);
  --sp-3: #fbbf24;      --sp-3-bg: rgba(251, 191, 36, 0.13);
  --sp-mixed: #9aa1b5;  --sp-mixed-bg: rgba(154, 161, 181, 0.12);

  /* Chart series (categorical, validated order) */
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
  --c5: #d55181; --c6: #2f9a2f; --c7: #9085e9; --c8: #e66767;
  --c-other: #6b7280;
  --grid: rgba(255, 255, 255, 0.06);

  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  --shadow-lg: 0 24px 64px rgba(0,0,0,.5);
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5fa;
  --bg-elev: #fbfbfe;
  --surface: #ffffff;
  --surface-2: #f2f3f9;
  --surface-3: #e7e9f2;
  --border: #e3e6ef;
  --border-strong: #cdd2e0;
  --text: #151826;
  --text-2: #444c63;
  --muted: #687089;

  --primary: #5b4ee6;
  --primary-strong: #4a3dd6;
  --primary-soft: rgba(91, 78, 230, 0.10);
  --primary-ring: rgba(91, 78, 230, 0.35);
  --grad-soft: linear-gradient(135deg, rgba(99,102,241,.10), rgba(192,38,211,.06));

  --green: #15803d;   --green-soft: rgba(22, 163, 74, 0.12);
  --amber: #b45309;   --amber-soft: rgba(217, 119, 6, 0.13);
  --red: #dc2626;     --red-soft: rgba(220, 38, 38, 0.10);
  --blue: #1d6fd6;    --blue-soft: rgba(29, 111, 214, 0.10);
  --gray-soft: rgba(100, 110, 140, 0.11);

  --sp-agent: #4f46e5;  --sp-agent-bg: rgba(79, 70, 229, 0.09);
  --sp-kunde: #047857;  --sp-kunde-bg: rgba(5, 150, 105, 0.09);
  --sp-3: #b45309;      --sp-3-bg: rgba(217, 119, 6, 0.10);
  --sp-mixed: #5b6378;  --sp-mixed-bg: rgba(100, 110, 140, 0.09);

  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  --c5: #e87ba4; --c6: #008300; --c7: #6250d6; --c8: #e34948;
  --c-other: #8b90a0;
  --grid: rgba(20, 24, 40, 0.07);
  --shadow: 0 1px 2px rgba(20,24,40,.06), 0 8px 24px rgba(20,24,40,.06);
  --shadow-lg: 0 24px 64px rgba(20,24,40,.18);
}

/* ── Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(139, 92, 246, .10), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(99, 102, 241, .08), transparent 60%);
}
html[data-theme="light"] body::before { opacity: .6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
code, kbd { font-family: var(--mono); font-size: .88em; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; color: var(--text-2); }
kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--muted); font-size: 11px; background: var(--surface); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--primary-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* Default icon size (zero specificity so component rules win) */
:where(svg[aria-hidden="true"]) { width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -0.18em; }
.section-title h3 svg { width: 17px; height: 17px; color: var(--primary); }
.callout h4 svg { width: 16px; height: 16px; color: var(--primary); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

/* ── Layout ─────────────────────────────────────────────────────── */
.shell { position: relative; z-index: 1; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 60;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform .3s var(--ease);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 16px 18px 10px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--grad);
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(124, 58, 237, .35);
}
.brand-logo svg { width: 22px; height: 22px; }
.brand h1 { font-size: 17px; font-weight: 750; letter-spacing: -.01em; }
.brand span { font-size: 11.5px; color: var(--muted); }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px 16px; }
.nav-group { margin-top: 10px; }
.nav-group-title { font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 0 10px 4px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 6px 10px; margin: 1px 0; border-radius: 9px;
  color: var(--text-2); font-weight: 520; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-item.active { background: var(--primary-soft); color: var(--text); }
.nav-item.active svg { color: var(--primary); opacity: 1; }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad);
}
.nav-badge { margin-left: auto; min-width: 20px; padding: 0 6px; height: 19px; border-radius: 10px; font-size: 11px; font-weight: 700; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.nav-badge.live { background: var(--red); color: #fff; }
.nav-badge.warn { background: var(--amber-soft); color: var(--amber); }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info span { font-size: 11px; color: var(--muted); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .hamburger { display: none; }
.global-search { position: relative; flex: 1; max-width: 420px; }
.global-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.global-search input[type="search"] { width: 100%; padding: 8px 40px 8px 34px; height: 36px; border-radius: 10px; }
.global-search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
  border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.pill:hover { border-color: var(--border-strong); text-decoration: none; }
.pill.ok { color: var(--green); }
.pill.warn { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, var(--border)); }
.pill.bad { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, var(--border)); background: var(--red-soft); }
.pill .label-long { color: var(--text-2); }

.banner {
  display: flex; align-items: center; gap: 12px; padding: 10px 28px;
  background: linear-gradient(90deg, rgba(240,82,82,.95), rgba(220,38,38,.92));
  color: #fff; font-weight: 600; font-size: 13.5px;
  animation: slideDown .35s var(--ease);
}
.banner svg { width: 18px; height: 18px; flex-shrink: 0; }
.banner a { color: #fff; text-decoration: underline; margin-left: auto; white-space: nowrap; }
.banner.warn { background: linear-gradient(90deg, #b45309, #d97706); }

#app { flex: 1; padding: 26px 28px 60px; max-width: 1480px; width: 100%; }

/* ── Page structure ─────────────────────────────────────────────── */
.page { animation: pageIn .38s var(--ease) both; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h2 { font-size: 24px; font-weight: 760; letter-spacing: -.02em; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 12px; }
.section-title h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.kpi-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }

/* ── Card ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h3 { font-size: 14px; font-weight: 680; display: flex; align-items: center; gap: 8px; }
.card-head h3 svg { width: 17px; height: 17px; color: var(--primary); }
.card-head .sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.card.gradient-border { position: relative; border-color: transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--grad) border-box; }

/* KPI */
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--kpi-tint, var(--primary-soft)); opacity: .6; }
.kpi-label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--kpi-tint, var(--primary-soft)); color: var(--kpi-color, var(--primary)); }
.kpi-icon svg { width: 16px; height: 16px; }
.kpi-value { font-size: 30px; font-weight: 780; letter-spacing: -.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.kpi-foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-bar { height: 5px; border-radius: 5px; background: var(--surface-3); margin-top: 10px; overflow: hidden; }
.kpi-bar > i { display: block; height: 100%; border-radius: 5px; background: var(--kpi-color, var(--primary)); width: 0; transition: width 1s var(--ease); }

/* ── Buttons & inputs ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 15px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-size: 13.5px; font-weight: 620; cursor: pointer; white-space: nowrap;
  background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(109, 94, 240, .28);
  transition: transform .12s, box-shadow .2s, filter .2s, background .2s;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; box-shadow: 0 6px 20px rgba(109, 94, 240, .38); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled, .btn.loading { opacity: .6; cursor: not-allowed; filter: none; }
.btn svg { width: 16px; height: 16px; }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn.secondary:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn.ghost { background: transparent; color: var(--text-2); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); box-shadow: none; }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn.xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn.xs.icon { width: 26px; }
.btn.loading::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.input, select.input, textarea.input, input[type="text"], input[type="search"], input[type="password"], input[type="number"], input[type="date"], input[type="url"], input[type="email"], select, textarea {
  font: inherit; font-size: 13.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 11px; height: 36px; outline: none; min-width: 0;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea, textarea.input { height: auto; min-height: 84px; resize: vertical; line-height: 1.5; padding: 9px 11px; }
select { padding-right: 30px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a91a8' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
input[type="date"] { color-scheme: inherit; }
input::placeholder, textarea::placeholder { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field-label { font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); line-height: 1.45; }
.field input, .field textarea, .field select { width: 100%; }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.check:hover { background: var(--surface-2); }
.check input { margin-top: 3px; accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; }
.check.disabled { opacity: .5; cursor: not-allowed; }
.check small { display: block; color: var(--muted); font-size: 12px; }

/* Toggle switch */
.switch { position: relative; width: 40px; height: 23px; border-radius: 23px; background: var(--surface-3); border: 1px solid var(--border-strong); cursor: pointer; transition: background .2s, border-color .2s; flex-shrink: 0; padding: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform .25s var(--ease); }
.switch[aria-checked="true"] { background: var(--primary); border-color: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(17px); }
.switch:disabled { opacity: .5; cursor: wait; }

/* Segmented control */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-2); background: transparent; border: 0; border-radius: 7px; padding: 5px 11px; cursor: pointer; transition: background .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.2); }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar .search-box { position: relative; flex: 1; min-width: 220px; }
.toolbar .search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.toolbar .search-box input { width: 100%; padding-left: 33px; }
.filter-label { font-size: 12px; color: var(--muted); }
.filter-toggle { color: var(--muted); }
.filter-toggle[aria-expanded="true"] { color: var(--text); }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 70; min-width: 240px; max-height: 340px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px;
  animation: popIn .16s var(--ease);
}
.dropdown-panel .dd-actions { display: flex; justify-content: space-between; padding: 4px 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu { position: fixed; z-index: 400; min-width: 200px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 5px; animation: popIn .14s var(--ease); }
.menu button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; font: inherit; font-size: 13px; color: var(--text); background: none; border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu button svg { width: 16px; height: 16px; color: var(--muted); }
.menu button.danger { color: var(--red); }
.count-chip { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--primary); color: #fff; font-size: 10.5px; font-weight: 700; }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap; background: var(--gray-soft); color: var(--text-2);
  vertical-align: middle;
}
.badge svg { width: 12px; height: 12px; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.working .dots::after { content: "…"; display: inline-block; animation: dots 1.4s steps(4, end) infinite; width: 1em; overflow: hidden; vertical-align: bottom; }
.badge.working .spin { width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.cat-chip i { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); vertical-align: middle; margin-right: 6px; flex-shrink: 0; }
.status-dot.green { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot.red { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.status-dot.amber { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.status-dot.pulse { animation: pulseDot 1.6s ease-in-out infinite; }

.live-dot { position: relative; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--red); flex-shrink: 0; }
.live-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--red); animation: ping 1.6s cubic-bezier(0, 0, .2, 1) infinite; }
.live-dot.green, .live-dot.green::after { background: var(--green); }

/* ── Tables ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; z-index: 1; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .sort-ind { opacity: .35; margin-left: 3px; font-size: 10px; }
.tbl th.sorted .sort-ind { opacity: 1; color: var(--primary); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tr.clickable { cursor: pointer; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .center { text-align: center; }

/* Stagger animation for list items */
.stagger > * { animation: itemIn .42s var(--ease) both; animation-delay: calc(var(--i, 0) * 28ms); }

/* ── Calls list (responsive rows) ───────────────────────────────── */
.call-list { display: flex; flex-direction: column; }
.call-row {
  display: grid; align-items: center; gap: 12px;
  grid-template-columns: 112px minmax(140px, 1.1fr) minmax(200px, 1.6fr) 68px minmax(150px, 1.1fr) 108px 120px 34px;
  padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s;
}
.call-row:last-child { border-bottom: 0; }
.call-row:hover { background: var(--surface-2); }
.call-row.head { cursor: default; background: transparent; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding-top: 10px; padding-bottom: 10px; }
.call-row.head:hover { background: transparent; }
.call-row.head .sortable { cursor: pointer; user-select: none; }
.call-row.head .sortable:hover { color: var(--text); }
.call-row.head .sorted { color: var(--primary); }
.call-time strong { display: block; font-size: 13px; font-variant-numeric: tabular-nums; }
.call-time span { font-size: 11.5px; color: var(--muted); }
.call-ext { min-width: 0; }
.call-ext strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.call-ext span { font-size: 11.5px; color: var(--muted); }
.call-parties { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.call-parties .party { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-parties .party a { color: var(--text); }
.call-parties .party a:hover { color: var(--primary); }
.call-parties .dir { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; flex-shrink: 0; }
.call-parties .dir svg { width: 14px; height: 14px; }
.dir.in { background: var(--blue-soft); color: var(--blue); }
.dir.out { background: var(--green-soft); color: var(--green); }
.dir.unk { background: var(--gray-soft); color: var(--muted); }
.call-status { display: flex; gap: 5px; flex-wrap: wrap; }
.data-icons { display: inline-flex; gap: 6px; color: var(--muted); }
.data-icons svg { width: 15px; height: 15px; }
.data-icons .on { color: var(--primary); }
.data-icons .off { opacity: .28; }

/* ── Pagination ─────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.pagination button { min-width: 34px; height: 34px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.pagination button:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }
.pagination button.active { background: var(--grad); color: #fff; border-color: transparent; }
.pagination button:disabled { opacity: .45; cursor: default; }
.pagination .info { font-size: 12.5px; color: var(--muted); margin: 0 10px; }

/* ── Empty states / skeleton / spinner ──────────────────────────── */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); animation: fadeIn .4s var(--ease); }
.empty-icon { width: 58px; height: 58px; border-radius: 18px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--grad-soft); color: var(--primary); }
.empty-icon svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); font-size: 15px; font-weight: 680; margin-bottom: 5px; }
.empty p { font-size: 13px; max-width: 420px; margin: 0 auto; }
.empty .btn { margin-top: 14px; }
.empty.error .empty-icon { background: var(--red-soft); color: var(--red); }
.empty.compact { padding: 22px 16px; }

.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 7px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); animation: shimmer 1.3s infinite; }
html[data-theme="light"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent); }
.skel-line { height: 12px; margin: 10px 0; }
.skel-rows { padding: 8px 18px; }
.skel-row { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.skel-row:last-child { border-bottom: 0; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--primary); animation: spin .8s linear infinite; margin: 30px auto; }

/* ── Live ───────────────────────────────────────────────────────── */
.live-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); }
.live-card { display: flex; flex-direction: column; animation: liveIn .5s var(--ease) both; overflow: hidden; }
.live-card.ending { animation: liveOut .4s var(--ease) both; }
.live-card-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--grad-soft); }
.live-card-head .who { flex: 1; min-width: 0; }
.live-card-head .who strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-card-head .who span { font-size: 12px; color: var(--muted); }
.live-timer { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--text); background: var(--surface); border: 1px solid var(--border); padding: 3px 9px; border-radius: 8px; }
.live-flags { display: flex; gap: 6px; padding: 8px 16px 0; flex-wrap: wrap; }
.live-flags:empty { display: none; }
.live-transcript { height: 300px; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth; }
.live-transcript.short { height: 120px; }
.lt-line { display: flex; flex-direction: column; max-width: 88%; animation: lineIn .35s var(--ease) both; }
.lt-line.kunde { align-self: flex-end; text-align: right; }
.lt-line .who { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.lt-line .txt { font-size: 13.5px; line-height: 1.45; padding: 6px 10px; border-radius: 11px; background: var(--sp-mixed-bg); margin-top: 2px; }
.lt-line.agent .who { color: var(--sp-agent); }
.lt-line.agent .txt { background: var(--sp-agent-bg); border-top-left-radius: 3px; }
.lt-line.kunde .who { color: var(--sp-kunde); }
.lt-line.kunde .txt { background: var(--sp-kunde-bg); border-top-right-radius: 3px; }
.lt-line.s3 .who { color: var(--sp-3); }
.lt-line.s3 .txt { background: var(--sp-3-bg); }
.lt-line.interim .txt { opacity: .55; font-style: italic; background: transparent; border: 1px dashed var(--border-strong); }
.lt-line.interim { animation: none; }
.lt-empty { margin: auto; color: var(--muted); font-size: 13px; text-align: center; }

.wave { display: inline-flex; align-items: center; gap: 2px; height: 22px; }
.wave i { display: block; width: 3px; height: 30%; border-radius: 3px; background: var(--primary); animation: wave 1.1s ease-in-out infinite; }
.wave i:nth-child(2) { animation-delay: -.9s; } .wave i:nth-child(3) { animation-delay: -.7s; }
.wave i:nth-child(4) { animation-delay: -.5s; } .wave i:nth-child(5) { animation-delay: -.3s; }
.wave.idle i { animation-play-state: paused; height: 20%; opacity: .5; }
.wave.speaking i { background: var(--green); animation-duration: .6s; }

.now-live-list { display: flex; flex-direction: column; }
.now-live-item { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); cursor: pointer; animation: itemIn .4s var(--ease) both; }
.now-live-item:last-child { border-bottom: 0; }
.now-live-item:hover { background: var(--surface-2); }
.now-live-item .meta strong { font-size: 13.5px; }
.now-live-item .meta .sub { font-size: 12px; color: var(--muted); }
.now-live-item .preview { font-size: 12.5px; color: var(--text-2); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.now-live-item .preview b { font-weight: 650; }

/* ── Charts ─────────────────────────────────────────────────────── */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-area { opacity: .12; }
.chart .crosshair { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.1s var(--ease) forwards; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; 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; }
.chart-tip {
  position: fixed; z-index: 500; pointer-events: none; min-width: 140px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 9px 11px; font-size: 12px; color: var(--text); animation: fadeIn .12s;
}
.chart-tip .t-head { font-weight: 700; margin-bottom: 5px; color: var(--text-2); }
.chart-tip .t-row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.chart-tip .t-row span { display: inline-flex; align-items: center; gap: 6px; }
.chart-tip .t-row i { width: 8px; height: 8px; border-radius: 2px; }
.chart-tip .t-row b { font-variant-numeric: tabular-nums; }

.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 150px) 1fr 44px; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.hbar .lbl i { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 0 5px 5px 0; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; width: 0; transition: width .9s var(--ease); }
.hbar .val { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; }
.donut { width: 168px; height: 168px; position: relative; flex-shrink: 0; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 18; transition: stroke-dasharray 1s var(--ease); }
.donut .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut .center strong { font-size: 26px; display: block; line-height: 1; }
.donut .center span { font-size: 11.5px; color: var(--muted); }
.legend-list { display: flex; flex-direction: column; gap: 8px; min-width: 180px; font-size: 13px; }
.legend-list div { display: flex; align-items: center; gap: 8px; }
.legend-list i { width: 10px; height: 10px; border-radius: 3px; }
.legend-list b { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend-list small { color: var(--muted); min-width: 38px; text-align: right; }

.stack-bar { display: flex; height: 8px; border-radius: 5px; overflow: hidden; gap: 2px; min-width: 70px; background: var(--surface-2); }
.stack-bar i { display: block; height: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--text); animation: popIn .35s var(--ease) both; animation-delay: calc(var(--i, 0) * 25ms); }
.chip b { color: var(--primary); font-weight: 700; font-size: 11.5px; }

/* Score bar */
.score { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.score .bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.score .bar i { display: block; height: 100%; border-radius: 4px; }
.score b { font-variant-numeric: tabular-nums; font-size: 12.5px; min-width: 38px; text-align: right; }

/* ── Summary list ───────────────────────────────────────────────── */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 13px; padding: 13px 18px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.feed-item:last-child { border-bottom: 0; }
.feed-item:hover { background: var(--surface-2); }
.feed-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--primary-soft); color: var(--primary); }
.feed-icon svg { width: 17px; height: 17px; }
.feed-body { flex: 1; min-width: 0; }
.feed-body .title { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; font-weight: 640; }
.feed-body .title span { font-weight: 500; font-size: 12px; color: var(--muted); white-space: nowrap; }
.feed-body p { font-size: 13px; color: var(--text-2); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Modal & drawer ─────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; z-index: 200; background: rgba(5, 7, 14, .62); backdrop-filter: blur(3px); opacity: 0; transition: opacity .22s; display: flex; align-items: center; justify-content: center; padding: 20px; }
html[data-theme="light"] .overlay { background: rgba(20, 24, 40, .35); }
.overlay.visible { opacity: 1; }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow-lg); transform: translateY(14px) scale(.97); transition: transform .28s var(--ease); }
.modal.wide { max-width: 860px; }
.modal.xwide { max-width: 1120px; }
.overlay.visible .modal { transform: none; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { flex: 1; font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); z-index: 2; }

.overlay.drawer-overlay { justify-content: flex-end; padding: 0; align-items: stretch; }
.drawer { width: min(940px, 100%); height: 100%; background: var(--bg-elev); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; transform: translateX(40px); opacity: .4; transition: transform .32s var(--ease), opacity .32s; }
.overlay.visible .drawer { transform: none; opacity: 1; }
.drawer-head { padding: 18px 24px 0; background: var(--surface); border-bottom: 1px solid var(--border); }
.drawer-title { display: flex; align-items: flex-start; gap: 12px; }
.drawer-title h3 { font-size: 18px; font-weight: 740; letter-spacing: -.01em; }
.drawer-title .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.drawer-title .grow { flex: 1; min-width: 0; }
.drawer-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tabs { display: flex; gap: 2px; margin-top: 14px; overflow-x: auto; }
.tab { font: inherit; font-size: 13.5px; font-weight: 620; color: var(--muted); background: none; border: 0; padding: 10px 14px; cursor: pointer; position: relative; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--grad); animation: grow .3s var(--ease); }
.tab .count { font-size: 11px; color: var(--muted); margin-left: 4px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 40px; }
.tab-panel { animation: fadeUp .3s var(--ease); }

.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 18px; }
.info-grid .k { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.info-grid .v { font-size: 14px; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.info-grid .v small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.block { margin-top: 22px; }
.block > h4 { font-size: 13px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.summary-text { font-size: 14.5px; line-height: 1.7; color: var(--text); }
.kp-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 7px; }
.kp-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.5; }
.kp-list li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--grad); margin-top: 7px; flex-shrink: 0; }
.task-line { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 6px; }
.task-line .t { flex: 1; font-size: 13.5px; }
.task-line.done .t { text-decoration: line-through; color: var(--muted); }
.task-check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--border-strong); background: transparent; cursor: pointer; display: grid; place-items: center; color: #fff; flex-shrink: 0; transition: background .2s, border-color .2s, transform .15s; padding: 0; }
.task-check:hover { border-color: var(--green); }
.task-check svg { width: 13px; height: 13px; opacity: 0; transform: scale(.4); transition: opacity .2s, transform .25s var(--ease); }
.task-check.done { background: var(--green); border-color: var(--green); }
.task-check.done svg { opacity: 1; transform: none; }
.status-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.status-box .grow { flex: 1; min-width: 200px; font-size: 13px; color: var(--text-2); }
.status-box.bad { border-color: color-mix(in srgb, var(--red) 40%, var(--border)); background: var(--red-soft); }
.status-box.warn { border-color: color-mix(in srgb, var(--amber) 40%, var(--border)); background: var(--amber-soft); }

/* Audio player */
.player { position: sticky; top: -20px; z-index: 5; margin: -20px -24px 18px; padding: 12px 24px; background: color-mix(in srgb, var(--bg-elev) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.player .play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; box-shadow: 0 4px 14px rgba(109, 94, 240, .4); transition: transform .15s; }
.player .play:hover { transform: scale(1.06); }
.player .play svg { width: 18px; height: 18px; }
.player .time { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 40px; text-align: center; }
.player .track { flex: 1; height: 28px; position: relative; cursor: pointer; display: flex; align-items: center; touch-action: none; }
.player .track .bg { position: absolute; left: 0; right: 0; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.player .track .marks { position: absolute; left: 0; right: 0; height: 6px; overflow: hidden; border-radius: 6px; }
.player .track .marks i { position: absolute; top: 0; height: 6px; opacity: .55; }
.player .track .fill { position: absolute; left: 0; height: 6px; border-radius: 6px; background: var(--grad); width: 0; }
.player .track .thumb { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 5px rgba(0,0,0,.4); transform: translateX(-50%); left: 0; transition: transform .15s; }
.player .track:hover .thumb { transform: translateX(-50%) scale(1.2); }
.player .speed { font: inherit; font-size: 12px; font-weight: 700; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 4px 8px; cursor: pointer; min-width: 44px; }

/* Transcript chat */
.transcript { display: flex; flex-direction: column; gap: 10px; }
.seg-line { display: flex; flex-direction: column; max-width: 80%; align-self: flex-start; animation: lineIn .3s var(--ease) both; animation-delay: calc(min(var(--i, 0), 30) * 12ms); }
.seg-line.right { align-self: flex-end; align-items: flex-end; }
.seg-line .meta { display: flex; gap: 8px; align-items: baseline; font-size: 11.5px; margin-bottom: 3px; padding: 0 4px; }
.seg-line .meta b { font-weight: 700; }
.seg-line .meta .ts { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.seg-line .bubble { padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.55; background: var(--sp-mixed-bg); border: 1px solid transparent; transition: border-color .2s, box-shadow .2s, transform .2s; }
.seg-line.agent .meta b { color: var(--sp-agent); }
.seg-line.agent .bubble { background: var(--sp-agent-bg); border-top-left-radius: 4px; }
.seg-line.kunde .meta b { color: var(--sp-kunde); }
.seg-line.kunde .bubble { background: var(--sp-kunde-bg); border-top-right-radius: 4px; }
.seg-line.s3 .meta b { color: var(--sp-3); }
.seg-line.s3 .bubble { background: var(--sp-3-bg); }
.seg-line.mixed .meta b { color: var(--sp-mixed); }
.seg-line.seekable .bubble { cursor: pointer; }
.seg-line.seekable .bubble:hover { border-color: var(--border-strong); }
.seg-line.playing .bubble { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.sparkle { color: var(--amber); font-size: 11px; }

/* STT comparison */
.cmp-providers { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; margin-bottom: 14px; }
.cmp-provider { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.cmp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.cmp-stat { padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--eng); }
.cmp-stat .n { font-size: 12px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.cmp-stat .v { font-size: 18px; font-weight: 750; color: var(--eng); }
.cmp-stat .d { font-size: 12px; color: var(--muted); }
.cmp-table-wrap { overflow: auto; max-height: 65vh; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table.cmp { border-collapse: collapse; width: 100%; font-size: 13px; table-layout: fixed; min-width: 640px; }
.cmp th { position: sticky; top: 0; background: var(--surface); padding: 10px 12px; text-align: left; font-size: 12px; border-bottom: 2px solid var(--eng, var(--border)); color: var(--eng, var(--muted)); z-index: 1; }
.cmp td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; line-height: 1.5; overflow-wrap: anywhere; }
.cmp td.time { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.cmp td.cell { border-left: 2px solid var(--eng); }
.cmp td.cell.empty { color: var(--muted); opacity: .4; border-left-color: var(--border); }
.cmp tr:hover td { background: var(--surface-2); }
.spk { display: inline-block; font-size: 10px; font-weight: 750; padding: 0 5px; border-radius: 4px; margin-right: 5px; }
.spk.agent { color: var(--sp-agent); background: var(--sp-agent-bg); }
.spk.kunde { color: var(--sp-kunde); background: var(--sp-kunde-bg); }
.spk.s3 { color: var(--sp-3); background: var(--sp-3-bg); }
.spk.mixed { color: var(--sp-mixed); background: var(--sp-mixed-bg); }
.progress-line { height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; position: relative; margin: 10px 0; }
.progress-line::after { content: ""; position: absolute; top: 0; bottom: 0; width: 35%; background: var(--grad); border-radius: 3px; animation: indet 1.3s ease-in-out infinite; }

/* ── Health / system ────────────────────────────────────────────── */
.health-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); }
.health-card .card-head { gap: 12px; }
.health-state { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.health-state.ok { color: var(--green); } .health-state.warn { color: var(--amber); } .health-state.bad { color: var(--red); } .health-state.unk { color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.sip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sip-acc { border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; background: var(--surface-2); position: relative; overflow: hidden; animation: popIn .35s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
.sip-acc.busy { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); background: var(--primary-soft); }
.sip-acc.unreg { border-color: color-mix(in srgb, var(--red) 45%, var(--border)); background: var(--red-soft); }
.sip-acc strong { font-family: var(--mono); font-size: 13px; }
.sip-acc .s { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.ring-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.ring { width: 96px; height: 96px; position: relative; flex-shrink: 0; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.ring .center { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 780; font-size: 20px; }

/* ── Timeline ───────────────────────────────────────────────────── */
.gantt-scroller { overflow-x: auto; overflow-y: hidden; cursor: grab; }
.gantt-scroller.dragging { cursor: grabbing; }
.gantt-row { display: flex; height: 42px; align-items: center; border-bottom: 1px solid var(--border); }
.gantt-label { position: sticky; left: 0; z-index: 2; background: var(--surface); width: 170px; flex-shrink: 0; padding: 0 12px 0 16px; font-size: 12.5px; font-weight: 640; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; height: 100%; display: flex; align-items: center; border-right: 1px solid var(--border); }
.gantt-lane { flex: 1; position: relative; height: 100%; }
.gantt-bar { position: absolute; top: 8px; bottom: 8px; border-radius: 6px; min-width: 5px; cursor: pointer; color: #fff; font-size: 10.5px; font-weight: 600; display: flex; align-items: center; padding: 0 6px; overflow: hidden; white-space: nowrap; transition: transform .15s, box-shadow .15s, filter .15s; animation: barIn .5s var(--ease) both; transform-origin: left center; }
.gantt-bar:hover { transform: scaleY(1.15); box-shadow: 0 4px 14px rgba(0,0,0,.35); filter: brightness(1.1); z-index: 3; }
.gantt-bar.active-call { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px); background-size: 200% 100%; animation: barIn .5s var(--ease) both, stripes 1.2s linear infinite; }
.gantt-axis { position: relative; height: 28px; border-bottom: 1px solid var(--border); }
.gantt-axis span { position: absolute; top: 7px; transform: translateX(-50%); font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.gantt-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--grid); }
.gantt-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); opacity: .7; z-index: 1; }

/* ── Integrations ───────────────────────────────────────────────── */
.wh-list { display: flex; flex-direction: column; gap: 10px; }
.wh-item { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.wh-item.inactive { opacity: .65; }
.wh-item .url { font-family: var(--mono); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.wh-item .desc { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.wh-item .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.wh-item .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.secret-box { display: flex; gap: 8px; align-items: center; padding: 12px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--primary); font-family: var(--mono); font-size: 13px; word-break: break-all; }
.secret-box span { flex: 1; }
.callout { padding: 14px 16px; border-radius: 12px; background: var(--grad-soft); border: 1px solid var(--border); font-size: 13px; line-height: 1.6; }
.callout.warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 35%, var(--border)); }
.callout h4 { font-size: 13.5px; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.callout pre { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; overflow-x: auto; font-family: var(--mono); font-size: 12px; margin: 8px 0; color: var(--text-2); }
.help-steps { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }

/* Settings */
.setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 18px; padding: 18px; border-bottom: 1px solid var(--border); align-items: start; }
.setting:last-child { border-bottom: 0; }
.setting .s-title { font-weight: 680; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.setting .s-desc { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.setting .s-key { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 6px; }
.setting > div { min-width: 0; }
.setting .s-ctrl { display: flex; flex-direction: column; gap: 8px; }
.setting .s-ctrl > select, .setting .s-ctrl > textarea, .setting .s-ctrl > input { width: 100%; max-width: 100%; }
.setting .s-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.save-state { font-size: 12px; color: var(--muted); min-height: 16px; transition: color .2s; }
.save-state.ok { color: var(--green); } .save-state.err { color: var(--red); }

/* ── Toasts & tooltip ───────────────────────────────────────────── */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 600; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 11px; min-width: 260px; max-width: 420px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toastIn .35s var(--ease) both; position: relative; overflow: hidden; }
.toast.out { animation: toastOut .3s var(--ease) forwards; }
.toast .ti { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; flex-shrink: 0; background: var(--primary-soft); color: var(--primary); }
.toast .ti svg { width: 14px; height: 14px; }
.toast.success .ti { background: var(--green-soft); color: var(--green); }
.toast.error .ti { background: var(--red-soft); color: var(--red); }
.toast.warn .ti { background: var(--amber-soft); color: var(--amber); }
.toast .tm { flex: 1; padding-top: 1px; }
.toast .tm small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.toast .tx { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; width: 20px; height: 20px; }
.toast::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; background: currentColor; opacity: .25; animation: toastTimer var(--dur, 4.5s) linear forwards; }
.tooltip { position: fixed; z-index: 700; pointer-events: none; max-width: 300px; padding: 7px 10px; border-radius: 8px; background: #0b0d14; color: #f1f2f7; font-size: 12px; line-height: 1.45; box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: fadeIn .12s; white-space: pre-line; }
html[data-theme="light"] .tooltip { background: #1d2133; }

/* ── Login ──────────────────────────────────────────────────────── */
.login { position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; padding: 20px; background: var(--bg); overflow: hidden; }
.login::before, .login::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; filter: blur(80px); opacity: .45; animation: float 14s ease-in-out infinite; }
.login::before { background: #6366f1; top: -160px; left: -120px; }
.login::after { background: #c026d3; bottom: -180px; right: -140px; animation-delay: -7s; opacity: .3; }
.login-card { position: relative; z-index: 1; width: 100%; max-width: 390px; padding: 34px 30px 28px; border-radius: 22px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(20px); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); animation: popIn .5s var(--ease) both; }
.login-card .brand { padding: 0 0 22px; }
.login-card .brand-logo { width: 46px; height: 46px; border-radius: 14px; }
.login-card .brand h1 { font-size: 22px; }
.login-card .btn { width: 100%; height: 42px; margin-top: 6px; }
.login-card.shake { animation: shake .45s; }

/* ── Misc ───────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.text-green { color: var(--green); } .text-red { color: var(--red); } .text-amber { color: var(--amber); }
.hide-sm { }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .25s; }
.backdrop.visible { opacity: 1; pointer-events: auto; }
.inline-list { display: flex; flex-wrap: wrap; gap: 5px; }
.preview-frame { width: 100%; height: 520px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.sev { display: inline-flex; align-items: center; gap: 5px; }
.escal-item { display: grid; grid-template-columns: 6px 1fr auto; gap: 14px; padding: 13px 18px 13px 0; border-bottom: 1px solid var(--border); cursor: pointer; align-items: center; }
.escal-item:hover { background: var(--surface-2); }
.escal-item:last-child { border-bottom: 0; }
.escal-item .rail { align-self: stretch; border-radius: 0 4px 4px 0; }

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes itemIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes lineIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes liveIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes liveOut { to { opacity: 0; transform: scale(.95); } }
@keyframes popIn { from { opacity: 0; transform: translateY(4px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
@keyframes toastTimer { from { width: 100%; } to { width: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes ping { 75%, 100% { transform: scale(2.4); opacity: 0; } }
@keyframes pulseDot { 50% { opacity: .45; } }
@keyframes wave { 0%, 100% { height: 25%; } 50% { height: 100%; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: none; } }
@keyframes dots { from { width: 0; } to { width: 1em; } }
@keyframes indet { 0% { left: -35%; } 100% { left: 100%; } }
@keyframes barIn { from { transform: scaleX(0); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes stripes { to { background-position: -24px 0; } }
@keyframes float { 50% { transform: translate(40px, 30px) scale(1.08); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .live-dot::after, .wave i { animation: none !important; }
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .call-row { grid-template-columns: 100px minmax(120px, 1fr) minmax(180px, 1.5fr) 64px minmax(130px, 1fr) 34px; }
  .call-row .c-sent, .call-row .c-cat { display: none; }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .topbar .hamburger { display: inline-grid; }
  #app { padding: 20px 16px 60px; }
  .banner { padding: 10px 16px; }
  .setting { grid-template-columns: 1fr; gap: 10px; }
}
@media (max-width: 720px) {
  .global-search kbd, .pill .label-long, .hide-sm { display: none; }
  .global-search { max-width: none; }
  .page-head h2 { font-size: 21px; }
  .call-row.head { display: none; }
  .call-row { grid-template-columns: 1fr auto; grid-template-areas: "parties more" "ext time" "status status"; gap: 4px 10px; padding: 12px 14px; }
  .call-row .c-time { grid-area: time; text-align: right; }
  .call-row .c-time strong, .call-row .c-time span { display: inline; font-size: 12px; color: var(--muted); font-weight: 500; }
  .call-row .c-time span::before { content: " · "; }
  .call-row .c-ext { grid-area: ext; }
  .call-row .c-ext strong { display: inline; font-size: 12px; color: var(--muted); font-weight: 500; }
  .call-row .c-ext span { display: none; }
  .call-row .c-parties { grid-area: parties; }
  .call-row .c-dur { display: none; }
  .call-row .c-status { grid-area: status; }
  .call-row .c-more { grid-area: more; }
  .call-row .c-sent, .call-row .c-cat { display: none; }
  .drawer-head { padding: 14px 16px 0; }
  .drawer-body { padding: 16px 16px 40px; }
  .player { margin: -16px -16px 16px; padding: 10px 16px; top: -16px; }
  .seg-line { max-width: 92%; }
  .modal-body { padding: 16px; }
  .modal-head, .modal-foot { padding: 14px 16px; }
  .toasts { left: 12px; right: 12px; top: 10px; bottom: auto; align-items: stretch; flex-direction: column-reverse; }
  @keyframes toastIn { from { opacity: 0; transform: translateY(-20px) scale(.97); } to { opacity: 1; transform: none; } }
  @keyframes toastOut { to { opacity: 0; transform: translateY(-20px); } }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi-label { font-size: 12px; }
  .filters-collapsible:not(.open) > :not(.filter-toggle) { display: none; }
  .modal-foot .btn { flex: 1; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
  .toast { max-width: none; min-width: 0; }
  .wh-item { grid-template-columns: 1fr; }
  .wh-item .actions { justify-content: flex-start; }
  .gantt-label { width: 110px; }
  .kpi-value { font-size: 26px; }
  .hbar { grid-template-columns: minmax(70px, 110px) 1fr 38px; }
}
