:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1b2130;
  --muted: #687082;
  --line: #e2e5ea;
  --accent: #2563eb;
  --ok: #15803d;   --ok-bg: #dcfce7;
  --warn: #b45309; --warn-bg: #fef3c7;
  --crit: #b91c1c; --crit-bg: #fee2e2;
  --none: #5b6170; --none-bg: #eceef2;
  --flood: #60a5fa;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141b; --card: #1a1f29; --ink: #e6e9ef; --muted: #959cab; --line: #2a303c;
    --accent: #60a5fa;
    --ok: #4ade80;   --ok-bg: #12321f;
    --warn: #fbbf24; --warn-bg: #3a2d0c;
    --crit: #f87171; --crit-bg: #3d1515;
    --none: #a3a9b6; --none-bg: #252b36;
    --flood: #60a5fa;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; padding-top: 14px; padding-bottom: 14px; }
.brand { font-weight: 700; font-size: 18px; color: var(--ink); display: inline-flex; align-items: center; gap: 10px; }
.brand:hover { text-decoration: none; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.sub { color: var(--muted); font-size: 13px; }

main { padding-top: 20px; padding-bottom: 20px; }
h1 { font-size: 24px; margin: 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h2 { font-size: 14px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; }
.stat .n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .n.small { font-size: 17px; padding: 4px 0 3px; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.ok .n { color: var(--ok); } .stat.warn .n { color: var(--warn); }
.stat.crit .n { color: var(--crit); } .stat.none .n { color: var(--none); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 16px; min-width: 0; }
#map { height: 380px; border-radius: 6px; }

.tablebar { margin-bottom: 10px; }
.tablebar input { width: 100%; max-width: 320px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit; }
.tablewrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.list th, .list td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.list th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.list th[data-sort] { cursor: pointer; user-select: none; }
.list th[data-dir="asc"]::after { content: " ▲"; } .list th[data-dir="desc"]::after { content: " ▼"; }
.list tbody tr:hover { background: var(--bg); }
.list .r { text-align: right; }
.list td.ok { color: var(--ok); } .list td.warn { color: var(--warn); font-weight: 600; } .list td.crit { color: var(--crit); font-weight: 700; }
.key { display: block; font-size: 11px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.note { font-size: 12px; color: var(--muted); margin: 10px 0 0; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn, .badge.stale { color: var(--warn); background: var(--warn-bg); }
.badge.none { color: var(--none); background: var(--none-bg); }

.bar { display: inline-block; width: 44px; height: 6px; border-radius: 3px; background: var(--line); vertical-align: middle; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); }
.bar.warn i { background: var(--warn); } .bar.crit i { background: var(--crit); }

.crumbs { margin: 0 0 10px; }
.titlebar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.ranges { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.ranges a { padding: 6px 12px; color: var(--ink); font-size: 14px; border-left: 1px solid var(--line); }
.ranges a:first-child { border-left: 0; }
.ranges a.on { background: var(--accent); color: #fff; }
.ranges a:hover { text-decoration: none; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 .card { margin-bottom: 0; }
.grid2 + .card { margin-top: 16px; }
.chart { position: relative; height: 260px; }
.info dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 12px; font-size: 14px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.btn { display: inline-block; padding: 7px 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--bg); font-size: 14px; }
.btn:hover { text-decoration: none; border-color: var(--accent); }

.empty { background: var(--card); border: 1px dashed var(--line); border-radius: 10px; padding: 28px; text-align: center; color: var(--muted); }
.foot { color: var(--muted); font-size: 12px; padding-bottom: 28px; }

@media (max-width: 760px) {
  .grid2 { grid-template-columns: 1fr; }
  .stat .n { font-size: 20px; }
  #map { height: 280px; }
}

/* Navigation */
.nav { margin-left: auto; display: inline-flex; gap: 16px; font-size: 14px; }
.nav a { color: var(--muted); }
.nav a:hover { color: var(--ink); text-decoration: none; }

/* Verfügbarkeitsraster */
.rasterwrap { overflow-x: auto; padding-bottom: 4px; }
.raster { --rname: 150px; --rcell: 11px; display: grid; gap: 3px 2px; align-items: center; width: max-content; font-size: 13px; }
.raster .rn { position: sticky; left: 0; background: var(--card); padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: var(--rname); z-index: 1; }
.raster .rday { font-size: 11px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 3px; white-space: nowrap; overflow: hidden; }
.raster .rq { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.rc { display: inline-block; width: 11px; height: 16px; border-radius: 2px; }
.rc.ok { background: var(--ok); }
.rc.okx { background: #d97706; }
.rc.okf { background: var(--flood); }
.rc.fail { background: var(--crit); }
.rc.none { background: var(--line); }
.rc.dstart { box-shadow: -2px 0 0 0 var(--card), -3px 0 0 0 var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .rc { width: 10px; height: 10px; }
.rules-intro { margin: 0 0 12px; font-size: 14px; }
.list.rules td { white-space: normal; }
@media (max-width: 760px) {
  .raster { --rname: 110px; }
  .nav { margin-left: 0; }
}
