:root {
  color-scheme: light;
  --bg: #f4f3f1;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e0db;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7b7a75;
  --grid: #e8e6e1;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0ca30c;
  --critical: #d03b3b;
  --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --border: #2e2e2b;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --grid: #2a2a27;
    --series-1: #3987e5;
    --series-2: #d95926;
    --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface-1: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86; --grid: #2a2a27;
  --series-1: #3987e5; --series-2: #d95926; --accent: #3987e5;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text-primary);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.muted { color: var(--text-muted); }
p.muted { margin: 2px 0 0; font-size: 12.5px; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand { font-size: 17px; letter-spacing: .2px; }
.brand b { font-weight: 800; }
.proto { font-size: 11px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 99px; padding: 1px 8px; margin-left: 6px; vertical-align: 2px; }
.account { display: flex; align-items: center; gap: 10px; flex: 1; color: var(--text-secondary); }
.account img { width: 28px; height: 28px; border-radius: 50%; }
.refresh { display: flex; align-items: center; gap: 12px; font-size: 12.5px; }

.btn {
  font: inherit; font-size: 13px; padding: 6px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
}
.btn:hover { border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .55; cursor: progress; }

main { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; display: grid; gap: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .label { font-size: 12px; color: var(--text-secondary); }
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -.5px; margin-top: 2px; }
.tile .sub { font-size: 12px; color: var(--text-muted); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.seg button { font: inherit; font-size: 13px; border: 0; background: none; color: var(--text-secondary); padding: 5px 12px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
#f-q { font: inherit; font-size: 13px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-primary); min-width: 220px; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 960px) { .charts { grid-template-columns: 1fr; } }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin: 0; min-width: 0; }
.plot { position: relative; margin-top: 10px; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.axis text { fill: var(--text-muted); font-size: 11px; }
.axis line.grid { stroke: var(--grid); }
.axis line.base { stroke: var(--text-muted); stroke-opacity: .5; }
.axis .title { fill: var(--text-secondary); font-size: 11.5px; }
.dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; cursor: pointer; }
.dot.sel { fill: var(--series-2); }
.dot:hover { stroke: var(--text-primary); }
.bar { fill: var(--series-1); cursor: pointer; }
.bar.sel { fill: var(--series-2); }
.bar:hover { opacity: .8; }
.dlabel { fill: var(--text-secondary); font-size: 11px; pointer-events: none; }
.hit { fill: transparent; cursor: pointer; }

.table-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.compare-bar { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th { color: var(--text-secondary); font-weight: 600; font-size: 12px; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface-1); }
th.l, td.l { text-align: left; }
th.sorted::after { content: " ↓"; }
th.sorted.asc::after { content: " ↑"; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.sel { background: color-mix(in srgb, var(--series-2) 12%, transparent); }
td.title { max-width: 340px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
td img.thumb { width: 34px; height: 46px; object-fit: cover; border-radius: 4px; display: block; background: var(--surface-2); }
td.warn { color: var(--critical); font-weight: 600; }
td.ok { color: var(--good); font-weight: 600; }
.type { font-size: 11px; color: var(--text-muted); }
.caveat { font-size: 11px; color: var(--text-muted); }
input.pick { width: 15px; height: 15px; cursor: pointer; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); overflow-y: auto; z-index: 10;
  background: var(--surface-1); border-left: 1px solid var(--border); padding: 20px 24px 40px;
  box-shadow: -12px 0 40px rgba(0,0,0,.18);
}
.drawer .close { position: absolute; top: 10px; right: 14px; font-size: 26px; background: none; border: 0; color: var(--text-secondary); cursor: pointer; }
.detail-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.detail-head img { width: 120px; border-radius: 8px; background: var(--surface-2); }
.detail-head .cap { font-size: 13px; color: var(--text-secondary); white-space: pre-line; max-height: 140px; overflow: auto; }
.detail-head a { color: var(--accent); font-size: 13px; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 18px; }
.kv div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.kv .k { font-size: 11.5px; color: var(--text-secondary); }
.kv .v { font-size: 18px; font-weight: 650; }
.cmp-row { display: grid; grid-template-columns: 130px 1fr 70px; align-items: center; gap: 10px; margin: 5px 0; font-size: 12.5px; }
.cmp-row .bars { display: grid; gap: 3px; }
.cmp-row .b { height: 8px; border-radius: 0 4px 4px 0; }
.cmp-row .b.me { background: var(--series-2); }
.cmp-row .b.med { background: var(--series-1); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); margin: 6px 0 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
h3 { font-size: 13.5px; margin: 18px 0 6px; }

.ab { display: grid; gap: 12px; }
.ab table td, .ab table th { text-align: right; }
.ab .win { color: var(--good); font-weight: 650; }
.ab .win::after { content: " ✓"; }

.tip {
  position: fixed; z-index: 20; pointer-events: none; max-width: 280px;
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.tip b { display: block; margin-bottom: 3px; font-size: 12.5px; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; color: var(--text-secondary); }
.tip .row span:last-child { color: var(--text-primary); font-weight: 600; }
.empty { color: var(--text-muted); padding: 24px 0; text-align: center; }

[hidden] { display: none !important; }

/* ---------- Tabs, Planung ---------- */
.tabs { display: inline-flex; gap: 2px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.tabs button { font: inherit; font-size: 13px; border: 0; background: none; color: var(--text-secondary); padding: 5px 14px; border-radius: 7px; cursor: pointer; }
.tabs button.on { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.notice { font-size: 12.5px; color: var(--text-secondary); background: var(--surface-1); border: 1px dashed var(--border); border-radius: 10px; padding: 10px 14px; }
.plan-grid { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.3fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .plan-grid { grid-template-columns: 1fr; } }
.plan-item { display: grid; grid-template-columns: 74px 1fr auto; gap: 12px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 8px; }
.plan-item:hover, .plan-item.sel { background: var(--surface-2); }
.plan-item .when { font-size: 12px; color: var(--text-secondary); line-height: 1.3; }
.plan-item .when b { display: block; font-size: 15px; color: var(--text-primary); }
.plan-item .t { font-weight: 600; font-size: 13.5px; }
.plan-item .c { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.badge { font-size: 11px; font-weight: 600; border-radius: 99px; padding: 2px 9px; border: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap; }
.badge.scheduled { border-color: var(--series-1); color: var(--series-1); }
.badge.published { border-color: var(--good); color: var(--good); }
.badge.failed { border-color: var(--critical); color: var(--critical); }
.badge.publishing { border-color: var(--series-2); color: var(--series-2); }
.editor { display: grid; grid-template-columns: 220px 1fr; gap: 18px; }
@media (max-width: 700px) { .editor { grid-template-columns: 1fr; } }
.phone { width: 220px; aspect-ratio: 9 / 16; background: #000; border-radius: 14px; overflow: hidden; position: relative; }
.phone video { width: 100%; height: 100%; object-fit: cover; display: block; }
.phone .ph-cap { position: absolute; left: 10px; right: 46px; bottom: 12px; color: #fff; font-size: 11px; line-height: 1.35; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.phone .ph-cap b { display: block; margin-bottom: 2px; }
.phone .empty { color: #888; position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; padding: 0 14px; text-align: center; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.field input, .field textarea, .field select { font: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-primary); width: 100%; }
.field textarea { min-height: 170px; resize: vertical; line-height: 1.45; }
.field .hint { font-size: 11.5px; color: var(--text-muted); }
.field .hint.bad { color: var(--critical); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.btn.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn.danger { color: var(--critical); }
.errors { color: var(--critical); font-size: 12.5px; margin: 6px 0; }
.files { max-height: 180px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.files div { padding: 5px 9px; font-size: 12.5px; cursor: pointer; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; }
.files div:hover { background: var(--surface-2); }
.files div.on { background: color-mix(in srgb, var(--series-1) 14%, transparent); }
.files span:last-child { color: var(--text-muted); white-space: nowrap; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: grid; place-items: center; }
.modal-box { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; width: min(460px, 92vw); }
.modal-box p { color: var(--text-secondary); font-size: 13.5px; }
.bt-bar { fill: var(--series-1); }
.bt-bar.none { fill: var(--grid); }

/* ---------- Login, Verwaltung ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login { width: min(420px, 92vw); background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 28px; }
.login h1 { font-size: 22px; margin: 18px 0 6px; }
.login form { display: flex; gap: 8px; margin-top: 16px; }
.login input { flex: 1; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-primary); }
.account select { font: inherit; font-size: 13px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-primary); }
.account .user { font-size: 12.5px; margin-left: auto; }
.account .user a { color: var(--text-secondary); }
.admin { display: grid; gap: 16px; max-width: 900px; }
.inline-input, .admin select, .tokform input { font: inherit; font-size: 13px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-primary); min-width: 240px; }
table.mini td { padding: 6px 4px; }
.tokform { margin: 10px 0; font-size: 13px; }
.tokform summary { cursor: pointer; color: var(--text-secondary); }
a.btn { text-decoration: none; display: inline-block; }
