:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #1c2330;
  --muted: #677285;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --ok: #16a34a;
  --ok-bg: #e8f7ee;
  --warn: #c27803;
  --warn-bg: #fdf4e3;
  --err: #d92d20;
  --err-bg: #fdecea;
  --idle: #8a94a6;
  --idle-bg: #eef0f3;
  --add: #dff5e6;
  --del: #fde2e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --surface: #181d26;
    --surface-2: #1f2530;
    --border: #2c3442;
    --text: #e6e9ef;
    --muted: #97a1b3;
    --accent: #6d8dff;
    --accent-text: #0b1020;
    --ok: #3ccb72;
    --ok-bg: #15301f;
    --warn: #f0b13c;
    --warn-bg: #362a12;
    --err: #ff6b5e;
    --err-bg: #3a1a17;
    --idle: #8a94a6;
    --idle-bg: #262c36;
    --add: #18392a;
    --del: #45201d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .inner { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.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); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; }
.nav a:hover, .nav a.active { color: var(--text); background: var(--surface-2); text-decoration: none; }
.container { max-width: 1320px; margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 24px; padding-bottom: 48px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 16px; }
.section { margin-bottom: 20px; }
.section > .card-body > h2:first-child, .section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
form.inline { display: inline; margin: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.changed { color: var(--warn); background: var(--warn-bg); }
.badge.error, .badge.down { color: var(--err); background: var(--err-bg); }
.badge.pending, .badge.paused { color: var(--idle); background: var(--idle-bg); }
.sev { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 1px 6px; border-radius: 4px; }
.sev.error { color: var(--err); background: var(--err-bg); }
.sev.warn { color: var(--warn); background: var(--warn-bg); }
.sev.info { color: var(--muted); background: var(--surface-2); }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; }
.alert.error { background: var(--err-bg); color: var(--err); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.info { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- Formulare ---------- */
label { display: block; font-weight: 600; margin-bottom: 4px; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; margin-top: 4px; }
input[type=text], input[type=url], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 96px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.form-card { max-width: 760px; }

/* ---------- Übersicht ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.stat-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .9rem;
}
.stat-chip:hover { text-decoration: none; background: var(--surface-2); }
.stat-chip.active { border-color: var(--accent); }
.stat-chip b { font-variant-numeric: tabular-nums; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters input[type=search] { max-width: 280px; }
.filters select { width: auto; min-width: 180px; }
.view-toggle { margin-left: auto; display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle a { padding: 6px 12px; color: var(--muted); background: var(--surface); }
.view-toggle a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.view-toggle a:hover { text-decoration: none; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.page-card { display: flex; flex-direction: column; overflow: hidden; color: var(--text); transition: border-color .15s; }
.page-card:hover { text-decoration: none; border-color: var(--accent); }
.page-card .thumb { aspect-ratio: 16 / 10; background: var(--surface-2); border-bottom: 1px solid var(--border); position: relative; overflow: hidden; }
.page-card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.page-card .thumb .badge { position: absolute; top: 10px; left: 10px; box-shadow: var(--shadow); }
.page-card .thumb .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .9rem; }
.page-card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.page-card .client { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.page-card .name { font-weight: 600; }
.page-card .url { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-card .reason { font-size: .85rem; margin-top: 4px; }
.page-card .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; color: var(--muted); margin-top: auto; padding-top: 8px; }
.page-card .meta span { white-space: nowrap; }
.page-card .meta b { color: var(--text); font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* ---------- Detailansicht ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: .9rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.tabs { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tabs button, .tabs a { border: 0; background: var(--surface); padding: 6px 12px; font: inherit; color: var(--muted); cursor: pointer; }
.tabs button.active, .tabs a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.tabs a:hover { text-decoration: none; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.compare-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.compare-3.mobile { grid-template-columns: repeat(3, minmax(0, 300px)); justify-content: center; }
.pane { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.pane-title { font-size: .8rem; font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--border); background: var(--surface); display: flex; justify-content: space-between; gap: 8px; }
.pane-scroll { max-height: 72vh; overflow: auto; }
.pane-scroll img { display: block; width: 100%; height: auto; }
.pane .none { padding: 40px 12px; text-align: center; color: var(--muted); font-size: .9rem; }

.ba { position: relative; max-height: 75vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.ba.mobile { max-width: 420px; margin: 0 auto; }
.ba-inner { position: relative; }
.ba-inner img { display: block; width: 100%; height: auto; user-select: none; pointer-events: none; }
.ba-inner .after { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--pos, 50%)); }
.ba-inner .after img { width: 100%; }
.ba-line { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 2px; background: var(--accent); transform: translateX(-1px); pointer-events: none; }
.ba-controls { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: .85rem; color: var(--muted); }
.ba-controls input { flex: 1; accent-color: var(--accent); }

.change-group { margin-bottom: 16px; }
.change-group h3 { display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.change-group h3 .count { color: var(--muted); font-weight: 500; }
.changes { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.changes li { padding: 9px 12px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: baseline; }
.changes li:last-child { border-bottom: none; }
.changes .msg { flex: 1; overflow-wrap: anywhere; }
.changes .vp { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.worddiff { display: block; margin-top: 4px; font-size: .88rem; color: var(--muted); }
ins { background: var(--add); color: var(--text); text-decoration: none; border-radius: 3px; padding: 0 2px; }
del { background: var(--del); color: var(--text); border-radius: 3px; padding: 0 2px; }
.swatch { display: inline-block; width: .9em; height: .9em; border-radius: 3px; border: 1px solid var(--border); vertical-align: -1px; margin: 0 2px; }

.uptime-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-bottom: 12px; }
.uptime-nums div { background: var(--surface-2); border-radius: 8px; padding: 8px 4px; }
.uptime-nums b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.uptime-nums span { font-size: .75rem; color: var(--muted); }
.bars { display: flex; gap: 2px; height: 28px; align-items: stretch; margin: 6px 0 2px; }
.bars span { flex: 1; border-radius: 2px; background: var(--idle-bg); }
.bars span.ok { background: var(--ok); }
.bars span.partial { background: var(--warn); }
.bars span.down { background: var(--err); }
.bars-legend { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); }
.chart { width: 100%; min-height: 200px; }
.chart .u-legend { font-size: .8rem; }
.chart .u-legend th { text-transform: none; letter-spacing: 0; background: none; font-weight: 500; color: var(--text); }
.chart .u-legend td, .chart .u-legend th { border: 0; padding: 2px 4px; }
.chart .u-legend tr:hover { background: none; }
.list-compact { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.list-compact li { padding: 6px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; }
.list-compact li:last-child { border-bottom: none; }
tr.current td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.running { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-size: .9rem; font-weight: 500; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; margin-bottom: 20px; font-size: 1.15rem; }

/* ---------- Responsiv ---------- */
@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .topbar .inner { gap: 8px; }
  .brand .hide-sm, .topbar .hide-sm { display: none; }
  .nav { min-width: 0; }
  .nav a { padding: 6px 6px; font-size: .9rem; }
  .nav .hide-sm { display: none; }
  .grid-3 { grid-template-columns: 1fr; }
  .compare-3, .compare-3.mobile { grid-template-columns: 1fr; }
  .view-toggle { margin-left: 0; }
  .filters input[type=search], .filters select { max-width: none; flex: 1 1 100%; }
  .page-head .btn-row { width: 100%; }
}
