:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f0f1f4; --line: #e3e5ea; --grid: #eceef2;
  --text: #16181d; --text-2: #5d6370; --text-3: #8a909c;
  --accent: #1d2330;
  --good: #0f8a3a; --good-bg: #e6f5ec; --warn: #b26a00; --warn-bg: #fff3df; --bad: #c62828; --bad-bg: #fdeaea;
  --radius: 16px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101113; --surface: #191919; --surface-2: #222326; --line: #2c2e33; --grid: #26282c;
    --text: #efefef; --text-2: #a9adb5; --text-3: #7d828b; --accent: #efefef;
    --good: #3fc06a; --good-bg: #13291b; --warn: #f0a838; --warn-bg: #2d2412; --bad: #ff6b6b; --bad-bg: #331717;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; font-variant-numeric: tabular-nums; }
a { color: inherit; }
button { font: inherit; color: inherit; }

/* Kopf */
header.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 0; border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 10px; max-width: 1100px; margin: 0 auto; }
.brand { min-width: 0; overflow: hidden; font-weight: 750; font-size: 20px; letter-spacing: -.3px; }
.brand small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 450; font-size: 12px; color: var(--text-3); letter-spacing: 0; }
.spacer { flex: 1; }
.icon-btn { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; width: 40px; height: 40px;
  display: grid; place-items: center; cursor: pointer; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

nav.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; max-width: 1100px; margin: 10px auto 0; padding-bottom: 10px; }
nav.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 13px;
  font-size: 14px; font-weight: 550; cursor: pointer; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.tab .dot { width: 9px; height: 9px; border-radius: 50%; }
.tab[aria-selected="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.periods { flex: none; display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; }
.periods button { white-space: nowrap; border: 0; background: transparent; padding: 6px 11px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.periods button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

main { max-width: 1100px; margin: 0 auto; padding: 14px 14px calc(40px + env(safe-area-inset-bottom)); }
.banner { border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.banner.demo { background: var(--warn-bg); color: var(--warn); }
.banner.err { background: var(--bad-bg); color: var(--bad); }

h2.sec { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); font-weight: 650; margin: 22px 4px 8px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 2px; font-size: 15px; font-weight: 650; }
.card .sub { color: var(--text-3); font-size: 12.5px; margin-bottom: 10px; }
.grid { display: grid; gap: 12px; margin-bottom: 12px; }
.grid > * { min-width: 0; margin-bottom: 0; }
.card { min-width: 0; }
@media (max-width: 380px) { .periods button { padding: 6px 8px; } .brand { font-size: 18px; } }
@media (min-width: 760px) { .grid.c2 { grid-template-columns: 1fr 1fr; } .grid.c3 { grid-template-columns: repeat(3, 1fr); } }

/* Kennzahlen */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 13px; box-shadow: var(--shadow); min-width: 0; }
.kpi .l { font-size: 12.5px; color: var(--text-2); line-height: 1.25; min-height: 2.5em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kpis.short .kpi .l { min-height: 0; }
.kpi .v { font-size: 24px; font-weight: 720; letter-spacing: -.4px; margin-top: 2px; white-space: nowrap; }
.kpi .d { font-size: 12.5px; margin-top: 2px; color: var(--text-3); white-space: nowrap; }
.kpi.hero { grid-column: span 2; }
.kpi.hero .v { font-size: 34px; }
.up { color: var(--good); } .down { color: var(--bad); }

/* Projektkarten */
.pcard { cursor: pointer; transition: transform .1s; }
.pcard:active { transform: scale(.99); }
.pcard .head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.pcard .head .dot { width: 12px; height: 12px; border-radius: 4px; }
.pcard .head b { font-size: 16px; }
.pcard .head .st { margin-left: auto; font-size: 12px; }
.mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; }
.mini div { min-width: 0; }
.mini .l { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .v { font-size: 17px; font-weight: 680; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.mute { background: var(--surface-2); color: var(--text-2); }

/* Listen mit Balken */
.blist { display: flex; flex-direction: column; gap: 7px; }
.brow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; font-size: 14px; }
.brow .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .c { color: var(--text-2); text-align: right; }
.brow .bar { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.brow .bar i { display: block; height: 100%; border-radius: 4px; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 600; color: var(--text-3); font-size: 12px; padding: 6px 6px; border-bottom: 1px solid var(--line); }
table.t td { padding: 8px 6px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; }
.tscroll { overflow-x: auto; margin: 0 -4px; }

/* Ereignisse */
.ev { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--grid); align-items: start; }
.ev:last-child { border-bottom: 0; }
.ev .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; background: var(--surface-2); }
.ev .tt { font-weight: 600; font-size: 14.5px; }
.ev .mt { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.ev .am { font-weight: 650; font-size: 14px; white-space: nowrap; }
.ev .pj { display: inline-flex; align-items: center; gap: 5px; }
.ev .pj i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.filters { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; scrollbar-width: none; }
.filters select { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; padding: 7px 10px; font: inherit; font-size: 14px; }

/* Diagramme */
.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis { font-size: 11px; fill: var(--text-3); }
.chart .gridl { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--line); stroke-width: 1; }
.chart .cross { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.tip { position: absolute; pointer-events: none; background: var(--accent); color: var(--bg); border-radius: 10px; padding: 7px 10px;
  font-size: 12.5px; line-height: 1.35; white-space: nowrap; transform: translate(-50%, -100%); top: 0; z-index: 5; display: none; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.tip b { font-weight: 700; }
.tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--text-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.empty { color: var(--text-3); font-size: 14px; padding: 8px 0; }
details.tbl summary { cursor: pointer; color: var(--text-3); font-size: 12.5px; margin-top: 8px; }

.src-status { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.src-status div { display: flex; justify-content: space-between; gap: 10px; }
.foot { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 24px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 11px; padding: 9px 14px; font-weight: 600; cursor: pointer; }
pre.report { white-space: pre-wrap; font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 12px; border-radius: 12px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: 100%; max-width: 360px; }
.login input { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 16px; margin-bottom: 10px; }
.login button { width: 100%; padding: 13px; border-radius: 12px; border: 0; background: var(--accent); color: var(--bg); font-weight: 650; font-size: 16px; cursor: pointer; }
.login .err { color: var(--bad); font-size: 14px; min-height: 20px; margin-bottom: 6px; }
