:root {
  color-scheme: light;
  --page: #f3f3f1;
  --surface: #fcfcfb;
  --border: #e4e3df;
  --grid: #ecebe7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-1-hover: #5f9ae3;
  --good: #008300;
  --critical: #d03b3b;
  --accent-soft: #e8f0fb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #111110;
    --surface: #1a1a19;
    --border: #2e2e2c;
    --grid: #262624;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e88;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-1-hover: #6ea7ee;
    --good: #3fae3f;
    --critical: #e66767;
    --accent-soft: #1f2a3a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #111110;
  --surface: #1a1a19;
  --border: #2e2e2c;
  --grid: #262624;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e88;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-1-hover: #6ea7ee;
  --good: #3fae3f;
  --critical: #e66767;
  --accent-soft: #1f2a3a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 1100px; margin: 0 auto; padding: 32px 16px 48px; }
header { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; justify-content: space-between; margin-bottom: 24px; }
h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; }
h2 { margin: 0 0 4px; font-size: 16px; }
.subtitle { margin: 4px 0 0; color: var(--text-secondary); }
.hint { margin: 0 0 16px; color: var(--text-muted); font-size: 13px; }

.ranges { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.ranges button {
  border: 0; background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 7px; cursor: pointer;
}
.ranges button:hover { color: var(--text-primary); }
.ranges button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text-primary); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile, .card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.tile { padding: 16px 18px; }
.tile .label { color: var(--text-secondary); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .short { display: none; }
.tile .value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 18px; color: var(--text-muted); font-weight: 500; }
.tile .note { color: var(--text-muted); font-size: 13px; }
.tile .up { color: var(--good); }
.tile .down { color: var(--critical); }

.card { padding: 20px 20px 12px; margin-bottom: 16px; }
.chart { position: relative; height: 340px; }
.chart.small { height: 220px; }

details { margin-top: 8px; color: var(--text-secondary); font-size: 14px; }
summary { cursor: pointer; padding: 6px 0; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
th:first-child, td:first-child { text-align: left; }
.table-wrap { max-height: 320px; overflow: auto; }
.empty { padding: 48px 0; text-align: center; color: var(--text-muted); }

/* Smartphones: kompaktere Abstände, Kennzahlen nebeneinander, Zeitraum über volle Breite */
@media (max-width: 640px) {
  main { padding: 20px 12px 32px; }
  header { margin-bottom: 16px; }
  h1 { font-size: 22px; }
  .ranges { width: 100%; }
  .ranges button { flex: 1; padding: 10px 4px; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 12px 10px; border-radius: 12px; }
  .tile .label, .tile .note { font-size: 12px; line-height: 1.35; }
  /* Kurze Beschriftungen, damit alle Werte auf einer Höhe stehen */
  .tile .long { display: none; }
  .tile .short { display: inline; }
  .tile .value { font-size: 22px; }
  .tile .value small { font-size: 13px; }
  .card { padding: 16px 12px 8px; border-radius: 12px; }
  .hint { font-size: 12px; }
  .chart { height: 280px; }
  .chart.small { height: 200px; }
  th, td { padding: 6px 4px; }
}

/* Optionales Logo links neben dem Titel (siehe logo.js) */
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand .logo { height: 48px; width: auto; max-width: 200px; object-fit: contain; flex-shrink: 0; }
@media (max-width: 640px) {
  .brand .logo { height: 36px; max-width: 120px; }
}

/* Zeitraum-Auswahl und Abmelden nebeneinander */
.actions { display: flex; gap: 12px; align-items: center; }
button.link {
  border: 0; background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 14px; padding: 6px 4px; cursor: pointer; text-decoration: underline;
}
button.link:hover { color: var(--text-primary); }
@media (max-width: 640px) {
  .actions { width: 100%; flex-direction: column; align-items: stretch; }
  button.link { align-self: flex-end; }
}

/* Anmeldeseite */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login .card { padding: 24px; }
.login h1 { margin-bottom: 4px; }
.login .brand { flex-direction: column; align-items: flex-start; gap: 16px; }
.login form { display: grid; gap: 12px; margin-top: 16px; }
.login label { display: grid; gap: 4px; color: var(--text-secondary); font-size: 14px; }
.login input {
  font: inherit; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--page); color: var(--text-primary);
}
.login button[type="submit"] {
  font: inherit; font-weight: 600; padding: 10px 12px; border-radius: 8px; border: 0;
  background: var(--series-1); color: #fff; cursor: pointer;
}
.login button[type="submit"]:disabled { opacity: 0.6; cursor: wait; }
.login .error { min-height: 1.5em; margin: 0; color: var(--critical); font-size: 14px; }
