:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e3e2de;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-soft: #e4effc;
  --series-1: #2a78d6; /* Menschen */
  --series-3: #1baf7a; /* Unklar */
  --series-2: #eb6834; /* Bots */
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --grid: #e8e7e3;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --radius: 14px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86; --accent: #3987e5; --accent-soft: #1b2a3d;
    --series-1: #3987e5; --series-3: #199e70; --series-2: #d95926; --grid: #2a2a27;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86; --accent: #3987e5; --accent-soft: #1b2a3d;
  --series-1: #3987e5; --series-3: #199e70; --series-2: #d95926; --grid: #2a2a27;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--critical); }
[hidden] { display: none !important; }

/* ---------- Kopf ---------- */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); }
.top-inner { max-width: 1440px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #2a78d6, #6250d6); color: #fff; font-size: 14px; }
.env-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); text-transform: uppercase; }
.env-badge.dev { background: #fdf1d6; color: #8a5a00; }
nav.tabs { display: flex; gap: 2px; }
nav.tabs a { white-space: nowrap; padding: 6px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
nav.tabs a:hover { background: var(--surface-2); text-decoration: none; }
nav.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.top .spacer { flex: 1; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 8px; height: 32px; min-width: 32px; padding: 0 10px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font: inherit; }
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 9px; padding: 7px 14px; font: inherit; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--critical); }

main { max-width: 1440px; margin: 0 auto; padding: 24px; }

/* ---------- Kennzahlen ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 18px 0 22px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--text-2); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; }

/* ---------- Filter ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.search { flex: 1 1 260px; max-width: 420px; position: relative; }
.search input { width: 100%; padding: 9px 12px 9px 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); padding: 5px 11px; border-radius: 99px; font: inherit; font-size: 12.5px; cursor: pointer; }
.chip.active { background: var(--text); border-color: var(--text); color: var(--surface); }
select.sel { padding: 7px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }

/* ---------- Kacheln ---------- */
.group-title { margin: 26px 0 10px; display: flex; align-items: baseline; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; min-width: 0; }
.tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); box-shadow: 0 6px 24px rgba(0,0,0,.08); }
.tile-head { display: flex; gap: 12px; align-items: center; min-width: 0; }
.logo { width: 42px; height: 42px; border-radius: 11px; background: var(--surface-2); display: grid; place-items: center; font-size: 22px; flex: none; overflow: hidden; border: 1px solid var(--border); }
.logo img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.logo.lg { width: 64px; height: 64px; font-size: 34px; border-radius: 16px; }
.tile-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-desc { color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 39px; }
.tile-links { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2);
  border: 1px solid transparent; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.pill:hover { border-color: var(--border); text-decoration: none; color: var(--text); }
.pill.env-prod { background: var(--accent-soft); color: var(--accent); }
.pill.env-dev { background: #fdf1d6; color: #8a5a00; }
:root[data-theme="dark"] .pill.env-dev, :root[data-theme="dark"] .env-badge.dev { background: #3a2e12; color: #f2c55c; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .pill.env-dev, :root:where(:not([data-theme="light"])) .env-badge.dev { background: #3a2e12; color: #f2c55c; } }
.tile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.stat .n { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; }
.stat .l { color: var(--muted); font-size: 11px; }
.tile-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; min-width: 0; }
.tile-foot .sess { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fav { border: none; background: none; cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 4px; color: var(--muted); border-radius: 6px; flex: none; }
.fav:hover { color: var(--warning); background: var(--surface-2); }
.fav.on { color: var(--warning); }
.tile.is-fav { border-color: color-mix(in srgb, var(--warning) 55%, var(--border)); }
.group-title.favs h2 { display: flex; gap: 6px; align-items: center; }
.btn .star { color: var(--warning); }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; }
.status.up .dot { background: var(--good); } .status.up { color: var(--text-2); }
.status.partial .dot { background: var(--warning); }
.status.down .dot { background: var(--critical); } .status.down { color: var(--critical); }
.status.unknown .dot { background: var(--muted); }
.ml-auto { margin-left: auto; }

/* ---------- Karten / Detail ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; margin-top: 14px; }
.cols > .card + .card { margin-top: 0; }
.detail-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.detail-head .grow { flex: 1; min-width: 260px; }
.detail-head p { color: var(--text-2); margin: 6px 0 0; max-width: 820px; }
.back { display: inline-flex; gap: 6px; color: var(--muted); margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.copy { cursor: pointer; border: 1px solid var(--border); background: var(--surface-2); border-radius: 6px; padding: 1px 7px; font-size: 11px; color: var(--text-2); }
.codebox { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; overflow-x: auto; white-space: pre; position: relative; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
.session { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.session:last-child { border-bottom: none; }
.session .t { font-weight: 500; }
.session .meta { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.session .acts { margin-left: auto; display: flex; gap: 6px; flex: none; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); }

/* ---------- Diagramme ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .grid line { stroke: var(--grid); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
.tooltip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12px; padding: 7px 10px; border-radius: 8px; white-space: nowrap; z-index: 5;
  transform: translate(-50%, calc(-100% - 10px)); box-shadow: var(--shadow); }
.tooltip b { font-weight: 600; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 70px; gap: 10px; align-items: center; font-size: 13px; padding: 4px 0; }
.bar-row .bar { height: 8px; border-radius: 4px; background: var(--series-1); }
.bar-row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Anmeldung ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, #2a78d6 18%, transparent), transparent), radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, #6250d6 16%, transparent), transparent), var(--bg); }
.auth-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: 0 10px 40px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 22px; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-2); }
.auth-card input, .field { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.auth-card .btn { justify-content: center; padding: 10px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 9px 16px; border-radius: 10px; z-index: 50; font-size: 13px; }
.spin { display: inline-block; animation: spin 1s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .top-inner { padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
  nav.tabs { order: 3; width: 100%; overflow-x: auto; }
  .top .icon-btn .small { display: none; }
  .top .spacer { display: none; }
  .top .icon-btn#refresh { margin-left: auto; }
  main { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .bar-row { grid-template-columns: 110px 1fr 56px; }
  .session { flex-wrap: wrap; } .session .acts { margin-left: 0; }
}
