:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #6b6a66;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --neutral: #898781;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --critical-text: #b42828;
  --wash: rgba(42, 120, 214, 0.08);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #9a9890;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --neutral: #898781;
    --good-text: #0ca30c;
    --critical-text: #e66767;
    --wash: rgba(57, 135, 229, 0.14);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 var(--font);
}

a { color: var(--series-1); }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

header.top {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
header.top .wrap {
  display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap;
}
.brand { font-weight: 600; font-size: 16px; }
nav.main { display: flex; gap: 4px; flex: 1; }
nav.main a {
  padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--text-secondary);
}
nav.main a.active { background: var(--wash); color: var(--text-primary); font-weight: 600; }
.logout button { background: none; border: 0; color: var(--text-secondary); cursor: pointer; font: inherit; }

.statusbar {
  font-size: 13px; color: var(--text-secondary); padding: 8px 0; display: flex; gap: 6px 18px; flex-wrap: wrap;
}
.statusbar strong { color: var(--text-primary); font-weight: 600; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--good); }
.dot.hinweis, .dot.laeuft, .dot.wartet { background: var(--warning); }
.dot.fehler { background: var(--critical); }

.banner {
  margin: 12px 0 0; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-1); font-size: 14px;
}
.banner.warn { border-left: 4px solid var(--warning); }
.banner.bad { border-left: 4px solid var(--critical); }

main { padding: 8px 0 48px; }
h1 { font-size: 26px; margin: 20px 0 4px; }
h2 { font-size: 18px; margin: 32px 0 8px; }
.lead { font-size: 17px; color: var(--text-secondary); margin: 0 0 16px; max-width: 760px; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }

.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px;
}
.card + .card { margin-top: 16px; }
.grid2 > .card { margin-top: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .label { font-size: 13px; color: var(--text-secondary); }
.tile .value { font-size: 28px; font-weight: 600; margin-top: 2px; }
.tile .note { font-size: 13px; color: var(--text-muted); }
.up { color: var(--good-text); }
.down { color: var(--critical-text); }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 13px; }
th, td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--grid); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 16px; padding-left: 10px; }
td.num:last-child, th.num:last-child { padding-right: 0; }
.scroll { overflow-x: auto; }

.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.badge.yes { border-color: var(--good); }
.badge.no { border-color: var(--critical); }

.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
button.btn, a.btn {
  font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); text-decoration: none;
}
button.btn.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
form.inline { display: inline; }

.filters { display: flex; gap: 12px 20px; flex-wrap: wrap; align-items: end; margin: 8px 0 16px; }
.filters label { display: flex; flex-direction: column; font-size: 13px; color: var(--text-secondary); gap: 4px; }
select, input[type="number"], input[type="text"], input[type="password"] {
  font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--axis);
  background: var(--surface-1); color: var(--text-primary);
}

.chart { position: relative; width: 100%; margin-top: 8px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .tick { font-size: 12px; fill: var(--text-muted); font-variant-numeric: tabular-nums; }
.chart .endlabel { font-size: 12px; fill: var(--text-primary); font-weight: 600; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.legend .key { display: inline-block; width: 16px; height: 2px; vertical-align: middle; margin-right: 6px; border-radius: 1px; }
.legend .key.marker { width: 10px; height: 10px; border-radius: 0; background: none !important; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  min-width: 160px; display: none; z-index: 2;
}
.tooltip .t-date { color: var(--text-secondary); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; }
.tooltip .t-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip .t-row span.name { color: var(--text-secondary); }
.tooltip .t-key { width: 12px; height: 2px; flex: none; }

details.table-view { margin-top: 10px; font-size: 13px; }
details.table-view summary { cursor: pointer; color: var(--text-secondary); }
details.table-view .scroll { max-height: 320px; overflow-y: auto; margin-top: 8px; }

details.why summary { cursor: pointer; }
ul.lines { margin: 6px 0 0; padding-left: 18px; }

.etf-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.etf-tabs a { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--border); text-decoration: none; color: var(--text-secondary); font-size: 14px; }
.etf-tabs a.active { background: var(--wash); color: var(--text-primary); font-weight: 600; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) {
  .grid2 { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .tile .value { font-size: 24px; }
  /* Auf dem Telefon reicht das Kürzel; der Name steht unter Regel. */
  table.signals .muted.name { display: none; }
  table.signals th, table.signals td { padding-left: 4px; padding-right: 4px; }
  .overview td .small.muted { display: none; }
}

.login { max-width: 360px; margin: 80px auto; }
.login label { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--text-secondary); }
.login input { width: 100%; }
.error { color: var(--critical-text); }
