:root {
  --navy: #12162a;
  --navy-2: #1b2038;
  --navy-line: rgba(255, 255, 255, 0.06);
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e9ecf2;
  --line-soft: #f1f3f7;
  --head: #f8f9fc;
  --ink: #12162a;
  --text: #3d4357;
  --muted: #8a90a3;
  --faint: #b3b8c6;

  --accent: #f2541b;
  --up: #3dbf88;
  --up-soft: #e3f6ec;
  --degraded: #e9b949;
  --degraded-soft: #fcf3dc;
  --down: #ec5a4f;
  --down-soft: #fde7e5;
  --spark: #7fd6ae;
  --spark-fill: rgba(127, 214, 174, 0.16);

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 12px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Top-Leiste ---------- */
.topbar {
  height: 168px;
  background-color: var(--navy);
  background-image:
    linear-gradient(var(--navy-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--navy-line) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
  color: #fff;
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand img { border-radius: 8px; box-shadow: 0 0 0 1px rgba(255,255,255,.12); }

.nav { display: flex; gap: 6px; }
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: 10px;
  font: 600 12px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
}
.nav-item svg { width: 15px; height: 15px; color: var(--accent); }
.nav-item.active { background: var(--navy-2); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }

.topbar-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--navy-2);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
  font: 500 12px var(--mono);
  color: rgba(255, 255, 255, 0.75);
  font-variant-numeric: tabular-nums;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 0 3px rgba(61, 191, 136, 0.2);
}
.live-dot.busy { background: var(--degraded); animation: blink 1s ease-in-out infinite; box-shadow: 0 0 0 3px rgba(233, 185, 73, .2); }
.live-dot.bad { background: var(--down); box-shadow: 0 0 0 3px rgba(236, 90, 79, .22); }

/* ---------- Seite & Panel ---------- */
.page {
  max-width: 1240px;
  margin: -96px auto 0;
  padding: 0 24px 40px;
}
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(18, 22, 42, 0.04), 0 12px 40px -12px rgba(18, 22, 42, 0.18);
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 16px 0;
  border-bottom: 1px solid var(--line);
}
.filter {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 240px;
  height: 38px;
  margin-bottom: 14px;
  padding: 0 14px;
  border-radius: 999px;
  background: #f1f3f7;
  color: var(--muted);
  transition: box-shadow .15s, background .15s;
}
.filter:focus-within { background: #fff; box-shadow: 0 0 0 1px var(--line), 0 0 0 4px rgba(18,22,42,.05); }
.filter svg { width: 14px; height: 14px; flex: none; }
.filter input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: 13px var(--sans);
  color: var(--ink);
}
.filter input::placeholder { color: var(--muted); }

.tabs { display: flex; gap: 22px; align-self: stretch; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 4px 14px;
  border: 0;
  background: none;
  font: 500 13.5px var(--sans);
  color: var(--muted);
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); }
.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #eceff4;
  color: var(--text);
  font: 600 11px var(--mono);
}
.badge-accent { background: var(--accent); color: #fff; }

.btn-dark {
  margin: 0 0 14px auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font: 600 12px var(--mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.btn-dark svg { width: 14px; height: 14px; }
.btn-dark:hover { background: #262c4a; }
.btn-dark:active { transform: scale(.97); }
.btn-dark:focus-visible, .tab:focus-visible, .row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-dark[disabled] { opacity: .75; cursor: progress; }
.btn-dark[disabled] svg { animation: spin 1s linear infinite; }

/* ---------- Tabelle ---------- */
.thead, .row {
  display: grid;
  grid-template-columns: minmax(200px, 1.25fr) minmax(220px, 1.6fr) 110px 120px minmax(170px, 1fr) 44px;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
}
.thead {
  height: 40px;
  background: var(--head);
  border-bottom: 1px solid var(--line);
  font: 500 11px var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.item { border-bottom: 1px solid var(--line-soft); }
.item:last-child { border-bottom: 0; }
.row {
  min-height: 62px;
  cursor: pointer;
  transition: background .12s;
}
.row:hover, .item.open .row { background: #fafbfd; }

.monitor { display: flex; align-items: center; gap: 12px; min-width: 0; }
.status-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 3px #eef0f4;
  transition: background .3s, box-shadow .3s;
}
[data-state="up"] .status-dot { background: var(--up); box-shadow: 0 0 0 3px var(--up-soft); }
[data-state="degraded"] .status-dot { background: var(--degraded); box-shadow: 0 0 0 3px var(--degraded-soft); }
[data-state="down"] .status-dot { background: var(--down); box-shadow: 0 0 0 3px var(--down-soft); }
[data-state="pending"] .status-dot { animation: blink 1s ease-in-out infinite; }

.fav {
  position: relative;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.fav img { width: 18px; height: 18px; object-fit: contain; }
.fav .mono {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  font: 600 11px var(--sans);
  color: #fff;
  background: hsl(var(--hue) 30% 45%);
}
.fav.no-img .mono { display: grid; }

.ident { min-width: 0; }
.name {
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sub {
  font: 11.5px var(--mono);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.perf { position: relative; height: 40px; padding-top: 12px; }
.perf svg.spark { display: block; width: 100%; height: 28px; overflow: visible; }
.spark .line { stroke: var(--spark); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark .area { fill: var(--spark-fill); stroke: none; }
[data-state="degraded"] .spark .line { stroke: #ebc874; }
[data-state="degraded"] .spark .area { fill: rgba(233, 185, 73, .14); }
[data-state="down"] .spark .line { stroke: #f08c84; }
[data-state="down"] .spark .area { fill: rgba(236, 90, 79, .12); }
.perf-ms {
  position: absolute;
  top: -2px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  font: 600 11px var(--mono);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.perf-ms::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--up); }
[data-state="degraded"] .perf-ms::before { background: var(--degraded); }
[data-state="down"] .perf-ms::before { background: var(--down); }
[data-state="pending"] .perf-ms::before { background: var(--faint); }

.cell-mono { font: 500 12.5px var(--mono); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-mono.warn { color: #b98713; }
.cell-mono.bad { color: var(--down); }

.issue { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); }
.issue svg { width: 15px; height: 15px; flex: none; }
.issue span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-state="up"] .issue svg { color: var(--up); }
[data-state="degraded"] .issue svg { color: var(--degraded); }
[data-state="down"] .issue svg { color: var(--down); }
[data-state="down"] .issue span { color: var(--down); font-weight: 500; }
[data-state="pending"] .issue { color: var(--faint); }

.go {
  justify-self: end;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--faint);
  transition: background .12s, color .12s;
}
.go svg { width: 15px; height: 15px; }
.go:hover { background: #eef0f5; color: var(--ink); }

/* ---------- Detail ---------- */
.detail {
  display: none;
  grid-template-columns: 1fr 1.6fr;
  gap: 0;
  border-top: 1px solid var(--line-soft);
  background: #fff;
}
.item.open .detail { display: grid; }
.detail section { padding: 22px 24px 24px; }
.detail section + section { border-left: 1px solid var(--line-soft); }
.detail h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--ink); }
.kv { margin: 0; }
.kv div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}
.kv div:last-child { border-bottom: 0; }
.kv dt { color: var(--ink); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--muted); }
.code-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font: 600 11.5px var(--mono);
  background: var(--up-soft);
  color: #1d8a5c;
}
.code-badge.warn { background: var(--degraded-soft); color: #a77508; }
.code-badge.bad { background: var(--down-soft); color: #c8382d; }

.stat-boxes {
  display: inline-flex;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.stat-boxes div { padding: 6px 14px; }
.stat-boxes div + div { border-left: 1px solid var(--line); }
.stat-boxes dt { font: 500 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat-boxes dd { margin: 0; display: flex; align-items: center; gap: 6px; font: 600 12.5px var(--mono); color: var(--ink); }
.stat-boxes dd::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--up); }

.chart { display: block; width: 100%; height: 120px; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .area { fill: rgba(150, 190, 225, 0.35); stroke: none; }
.chart .line { stroke: #9cc2e3; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.chart-axis { display: flex; justify-content: space-between; margin-top: 6px; font: 11px var(--mono); color: var(--muted); }

.uptime-bar { display: flex; gap: 2px; height: 22px; margin-top: 14px; }
.uptime-bar i { flex: 1; border-radius: 2px; background: var(--up); opacity: .9; }
.uptime-bar i.degraded { background: var(--degraded); }
.uptime-bar i.down { background: var(--down); }
.uptime-bar i.none { background: #edf0f4; }

/* ---------- Sonstiges ---------- */
.empty { margin: 0; padding: 48px 24px; text-align: center; color: var(--muted); }
code, kbd {
  font: 500 11.5px var(--mono);
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 0 4px;
  font: 12px var(--mono);
  color: var(--muted);
}

@keyframes blink { 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1000px) {
  .thead, .row { grid-template-columns: minmax(160px, 1.2fr) minmax(140px, 1.4fr) minmax(130px, 1fr) 36px; }
  .col-ssl, .col-uptime { display: none; }
  .detail { grid-template-columns: 1fr; }
  .detail section + section { border-left: 0; border-top: 1px solid var(--line-soft); }
}

@media (max-width: 680px) {
  .topbar { height: 140px; }
  .topbar-inner { padding: 14px 16px; gap: 10px; }
  .brand span { display: none; }
  .nav { display: none; }
  .topbar-meta { padding: 0 12px; font-size: 11px; white-space: nowrap; }
  .page { padding: 0 16px 32px; margin-top: -76px; }
  .toolbar { flex-wrap: wrap; gap: 12px 18px; padding: 12px 14px 0; }
  .filter { width: 100%; margin-bottom: 0; }
  .tabs { align-self: stretch; gap: 16px; }
  .btn-dark { margin-bottom: 10px; width: 36px; padding: 0; justify-content: center; }
  .btn-label { display: none; }
  .thead { display: none; }
  .row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "mon go" "perf perf" "issue issue";
    gap: 8px 12px;
    padding: 14px 16px;
  }
  .row .monitor { grid-area: mon; }
  .row .perf { grid-area: perf; }
  .row .issue { grid-area: issue; }
  .row .go { grid-area: go; }
  .detail section { padding: 18px 16px; }
  .kv div { grid-template-columns: 110px 1fr; }
  .foot { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
