@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/fira-sans-400.woff2) format('woff2'); }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/fira-sans-500.woff2) format('woff2'); }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/fira-sans-600.woff2) format('woff2'); }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/fira-sans-700.woff2) format('woff2'); }

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --primary: #1e40af;
  --primary-hover: #1e3a8a;
  --primary-soft: #eef3ff;
  --primary-text: #1e40af;
  --on-primary: #ffffff;
  --ring: #3b82f6;
  --good: #15803d; --good-bg: #dcfce7;
  --warn: #b45309; --warn-bg: #fef3c7;
  --bad: #b91c1c;  --bad-bg: #fee2e2;
  --info: #1d4ed8; --info-bg: #dbeafe;
  --neutral-bg: #eef2f7;
  /* Charts (validierte Kategorie-Reihenfolge: blau, orange, aqua) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --grid: #e7ebf0; --axis: #c3c9d3;
  --f1: #1c5cab; --f2: #2a78d6; --f3: #5598e7; --f4: #86b6ef; --on-fill: #ffffff;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.05);
  --shadow: 0 1px 3px rgb(15 23 42 / 0.06), 0 1px 2px rgb(15 23 42 / 0.04);
  --shadow-lg: 0 12px 32px rgb(15 23 42 / 0.16), 0 2px 6px rgb(15 23 42 / 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar: 232px;
  --font: 'Fira Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1020; --surface: #111827; --surface-2: #0f172a; --surface-3: #1e293b;
  --border: #1f2a3d; --border-strong: #334155;
  --text: #e5e9f0; --text-2: #cbd5e1; --muted: #94a3b8;
  --primary: #3b82f6; --primary-hover: #60a5fa; --primary-soft: #172554; --primary-text: #93c5fd; --on-primary: #ffffff; --ring: #60a5fa;
  --good: #4ade80; --good-bg: #052e16; --warn: #fbbf24; --warn-bg: #3a2a06; --bad: #f87171; --bad-bg: #3b0d0d; --info: #93c5fd; --info-bg: #172554;
  --neutral-bg: #1e293b;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --grid: #1f2a3d; --axis: #334155;
  --f1: #86b6ef; --f2: #5598e7; --f3: #2a78d6; --f4: #1c5cab; --on-fill: #0b1020;
  --shadow-sm: none; --shadow: 0 1px 2px rgb(0 0 0 / 0.4); --shadow-lg: 0 16px 40px rgb(0 0 0 / 0.55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1020; --surface: #111827; --surface-2: #0f172a; --surface-3: #1e293b;
    --border: #1f2a3d; --border-strong: #334155;
    --text: #e5e9f0; --text-2: #cbd5e1; --muted: #94a3b8;
    --primary: #3b82f6; --primary-hover: #60a5fa; --primary-soft: #172554; --primary-text: #93c5fd; --on-primary: #ffffff; --ring: #60a5fa;
    --good: #4ade80; --good-bg: #052e16; --warn: #fbbf24; --warn-bg: #3a2a06; --bad: #f87171; --bad-bg: #3b0d0d; --info: #93c5fd; --info-bg: #172554;
    --neutral-bg: #1e293b;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --grid: #1f2a3d; --axis: #334155;
    --f1: #86b6ef; --f2: #5598e7; --f3: #2a78d6; --f4: #1c5cab; --on-fill: #0b1020;
    --shadow-sm: none; --shadow: 0 1px 2px rgb(0 0 0 / 0.4); --shadow-lg: 0 16px 40px rgb(0 0 0 / 0.55);
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--bad); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.lg { width: 20px; height: 20px; }
svg.i.xl { width: 28px; height: 28px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh;
  background: linear-gradient(90deg, var(--surface) calc(var(--sidebar) - 1px), var(--border) calc(var(--sidebar) - 1px) var(--sidebar), transparent var(--sidebar)); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; font-size: 15px; color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); }
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; min-height: 38px; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-text); }
.nav a .count { margin-left: auto; font-size: 11px; font-weight: 600; background: var(--bad); color: #fff; border-radius: 999px; padding: 0 7px; line-height: 18px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 10px; }
.sidebar-foot button { justify-content: flex-start; }
.main { min-width: 0; padding: 28px 32px 64px; max-width: 1360px; width: 100%; }
.topbar { display: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.g-2 { grid-template-columns: 2fr 1fr; }
.g-2e { grid-template-columns: 1fr 1fr; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.mt { margin-top: 16px; } .mt-lg { margin-top: 24px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head .hint { color: var(--muted); font-size: 12px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .value small { font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.kpi .foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 12px; padding: 0 6px; border-radius: 999px; }
.delta svg.i { width: 12px; height: 12px; }
.delta.up { color: var(--good); background: var(--good-bg); }
.delta.down { color: var(--bad); background: var(--bad-bg); }
.delta.flat { color: var(--muted); background: var(--neutral-bg); }

/* ---------- Buttons ---------- */
button, .btn { font: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s; text-decoration: none; white-space: nowrap; }
button:hover, .btn:hover { background: var(--surface-3); text-decoration: none; }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn-solid-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-solid-danger:hover { filter: brightness(.95); background: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 32px; min-height: 32px; padding: 0; }
.btn-icon.sm { width: 28px; min-height: 28px; }
.btn-group { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* Segmented control */
.seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; min-height: 30px; padding: 0 12px; font-size: 13px; color: var(--text-2); border-radius: 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary-text); border-color: var(--primary); }
.tabs .pill { font-size: 11px; background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 0 7px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span, .label-text { font-size: 12px; font-weight: 500; color: var(--text-2); }
.field .help { font-size: 12px; color: var(--muted); }
input, textarea, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 36px; width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent); }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input[type=checkbox] { width: 16px; height: 16px; min-height: 0; accent-color: var(--primary); margin: 0; }
select { cursor: pointer; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.inline-num { width: 76px; min-height: 30px; padding: 4px 8px; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 32px; min-height: 34px; }

/* Selectable account chips */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.choice { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px; cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--ring); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice .grow { flex: 1; min-width: 0; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 999px; background: var(--neutral-bg); color: var(--text-2); white-space: nowrap; line-height: 18px; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.live::before { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.vchip { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 6px; font-size: 12px; font-weight: 700; color: #fff; background: var(--s1); }
.vchip.v1 { background: var(--s2); } .vchip.v2 { background: var(--s3); } .vchip.v3 { background: var(--s4); } .vchip.off { background: var(--border-strong); color: var(--text-2); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tr.clickable { cursor: pointer; }
.cell-main { font-weight: 500; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); }
.rate-bar { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.rate-bar .track { flex: 1; height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.rate-bar .fill { height: 100%; background: var(--s1); border-radius: 999px; }
.rate-bar b { font-weight: 600; min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

/* Progress (stacked) */
.progress { display: flex; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; gap: 2px; }
.progress span { height: 100%; }
.progress .p-done { background: var(--s3); } .progress .p-active { background: var(--s1); } .progress .p-replied { background: var(--s2); } .progress .p-err { background: var(--bad); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.line { height: 3px; border-radius: 2px; vertical-align: 3px; width: 14px; }

/* Step dots */
.steps-dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.steps-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border-strong); }
.steps-dots i.on { background: var(--s1); border-color: var(--s1); }

/* Filter chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-height: 30px; padding: 0 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); }
.chip b { font-weight: 600; margin-left: 2px; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ---------- Alerts / notes ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; font-size: 13px; border: 1px solid; }
.alert svg { margin-top: 2px; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert.bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.alert.info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert.good { background: var(--good-bg); color: var(--good); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.alert b { color: inherit; }
.alert .grow { flex: 1; }
.alert a { color: inherit; text-decoration: underline; }
.alert-list { display: flex; flex-direction: column; gap: 8px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ico { width: 52px; height: 52px; border-radius: 14px; background: var(--surface-3); display: grid; place-items: center; margin: 0 auto 14px; color: var(--text-2); }
.empty h3 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty p { margin: 0 auto 16px; max-width: 380px; }

/* ---------- Feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed .avatar { width: 32px; height: 32px; }
.feed .body { flex: 1; min-width: 0; }
.feed .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.feed .text { margin-top: 2px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; background: var(--primary-soft); color: var(--primary-text); flex: none; }

/* Campaign list rows */
.camp-name { display: flex; flex-direction: column; gap: 2px; }

/* ---------- Sequence editor ---------- */
.seq { display: flex; flex-direction: column; gap: 0; }
.seq-step { position: relative; padding-left: 40px; padding-bottom: 20px; }
.seq-step::before { content: ''; position: absolute; left: 15px; top: 34px; bottom: 0; width: 2px; background: var(--border); }
.seq-step:last-child::before { display: none; }
.seq-num { position: absolute; left: 0; top: 2px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; background: var(--primary); color: var(--on-primary); font-size: 13px; }
.seq-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 36px; margin-bottom: 10px; }
.seq-head .t { display: flex; flex-direction: column; }
.seq-wait { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.seq-wait input { width: 80px; min-height: 30px; padding: 4px 8px; }
.variants { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.variant { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; transition: border-color .15s, opacity .15s; }
.variant.inactive { opacity: .6; background: var(--surface-2); }
.variant.leader { border-color: color-mix(in srgb, var(--good) 55%, transparent); }
.variant-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.variant-head .grow { flex: 1; font-weight: 500; font-size: 13px; }
.variant textarea { border: 0; border-radius: 0; min-height: 120px; box-shadow: none; padding: 12px; }
.variant textarea:focus { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ring) 40%, transparent); }
.variant-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.variant-stats { display: flex; gap: 12px; flex-wrap: wrap; }
.variant-stats b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.variant .warn-edit { padding: 6px 12px; font-size: 12px; color: var(--warn); background: var(--warn-bg); }
.add-variant { border: 1px dashed var(--border-strong); border-radius: var(--radius); background: transparent; color: var(--muted); min-height: 120px; flex-direction: column; }
.add-variant:hover { border-color: var(--primary); color: var(--primary-text); background: var(--primary-soft); }
.ph-btns { display: flex; gap: 4px; }
.ph-btns button { min-height: 24px; padding: 0 7px; font-size: 11px; font-family: var(--mono); }
.toggle { position: relative; width: 34px; height: 20px; flex: none; }
.toggle input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; z-index: 1; }
.toggle span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .15s; }
.toggle span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgb(0 0 0 / .2); }
.toggle input:checked + span { background: var(--good); }
.toggle input:checked + span::after { transform: translateX(14px); }
.toggle input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 2px; }

.savebar { position: sticky; bottom: 16px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 16px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); margin-top: 16px; flex-wrap: wrap; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .cross { stroke: var(--border-strong); stroke-width: 1; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px;
  font-size: 12px; box-shadow: var(--shadow-lg); min-width: 140px; opacity: 0; transition: opacity .1s; }
.tooltip.show { opacity: 1; }
.tooltip .tt-title { font-weight: 600; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-row span:first-child { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; }
.tooltip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: minmax(120px, 170px) 1fr; gap: 12px; align-items: center; }
.funnel-row .lbl { font-size: 13px; color: var(--text-2); }
.funnel-row .bar-wrap { position: relative; height: 28px; background: var(--surface-2); border-radius: 6px; }
.funnel-row .bar { height: 100%; border-radius: 6px; min-width: 2px; transition: width .3s; }
.funnel-row .val { position: absolute; left: 10px; top: 0; bottom: 0; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; }
.funnel-row .val .conv { font-weight: 500; color: var(--text-2); background: var(--surface); padding: 0 6px; border-radius: 4px; }
.funnel-row .val.inside { color: var(--on-fill); }
.funnel-row .val.inside .conv { background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--text); }

.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: 80px 1fr 40px; gap: 10px; align-items: center; font-size: 12px; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 0 4px 4px 0; }
.hbar .fill { height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; }
.hbar b { text-align: right; font-variant-numeric: tabular-nums; }

/* A/B groups */
.ab-group + .ab-group { border-top: 1px solid var(--border); }
.ab-title { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 12px 18px 4px; flex-wrap: wrap; }
.ab-text { min-width: 180px; max-width: 360px; color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Drawer / modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgb(15 23 42 / 0.45); z-index: 50; opacity: 0; transition: opacity .2s; }
.overlay.show { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--surface); z-index: 51; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .22s ease-out; }
.drawer.show { transform: none; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-head .grow { flex: 1; min-width: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; background: var(--surface-2); }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.meta-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; margin-bottom: 16px; }
.meta-grid dt { color: var(--muted); }
.meta-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 85%; padding: 9px 12px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; box-shadow: var(--shadow-sm); }
.bubble.out { align-self: flex-end; background: var(--primary); color: var(--on-primary); border-bottom-right-radius: 4px; }
.bubble.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble-meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.bubble-meta.out { align-self: flex-end; }
.bubble-meta svg.i { width: 12px; height: 12px; }

.modal { position: fixed; z-index: 61; left: 50%; top: 12vh; transform: translate(-50%, 8px); width: min(520px, calc(100vw - 32px)); background: var(--surface);
  border-radius: 12px; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .15s, transform .15s; max-height: 76vh; display: flex; flex-direction: column; }
.modal.show { opacity: 1; transform: translate(-50%, 0); }
.modal-head { padding: 18px 20px 6px; display: flex; gap: 12px; align-items: flex-start; }
.modal-head .ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary-text); }
.modal-head .ico.danger { background: var(--bad-bg); color: var(--bad); }
.modal-body { padding: 6px 20px 18px; overflow-y: auto; color: var(--text-2); }
.modal-foot { padding: 12px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 12px 12px; }
.overlay.modal-ov { z-index: 60; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 420px; padding: 12px 14px; border-radius: 10px; background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg); font-size: 13px; animation: toast-in .2s ease-out; }
.toast.err { background: var(--bad); color: #fff; }
.toast.ok svg { color: #4ade80; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Skeleton */
.skeleton { display: flex; flex-direction: column; gap: 16px; }
.sk { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); }
@keyframes sk { to { background-position: -200% 0; } }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--primary-soft), transparent), var(--bg); }
.login { width: min(380px, 100%); padding: 28px; }
.login .brand { padding: 0 0 20px; }

/* Account cards */
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.acc-card .top { display: flex; gap: 12px; align-items: center; padding: 16px 18px 12px; }
.acc-card .top .grow { flex: 1; min-width: 0; }
.acc-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.acc-card .stats div { padding: 10px 14px; }
.acc-card .stats div + div { border-left: 1px solid var(--border); }
.acc-card .stats b { display: block; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.acc-card .stats span { font-size: 11px; color: var(--muted); }
.acc-card .cfg { padding: 12px 18px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.acc-card .cfg-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.acc-card .actions { padding: 10px 14px; display: flex; gap: 6px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.meter { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--s1); }

.log-level { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px; }
.log-level.info { background: var(--info-bg); color: var(--info); }
.log-level.warn { background: var(--warn-bg); color: var(--warn); }
.log-level.error { background: var(--bad-bg); color: var(--bad); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g-2, .g-2e { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar { position: fixed; z-index: 70; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
  .main { padding: 20px 16px 64px; }
  .kpi .value { font-size: 22px; }
  .funnel-row { grid-template-columns: 1fr; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
