:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #dde3ea;
  --text: #1b2430;
  --muted: #5d6b7a;
  --brand: #1f4e79;
  --brand-2: #2d6aa3;
  --brand-ink: #ffffff;
  --red: #d93036;
  --red-bg: #fdecec;
  --yellow: #c98a00;
  --yellow-dot: #f5b400;
  --yellow-bg: #fff6dc;
  --green: #23854f;
  --green-bg: #e6f5ec;
  --focus: #2d6aa3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d;
    --panel: #19202a;
    --panel-2: #1e2632;
    --line: #2c3644;
    --text: #e3e8ef;
    --muted: #96a3b3;
    --brand: #2d6aa3;
    --brand-2: #3d80c0;
    --red: #f0585d;
    --red-bg: #3a1e21;
    --yellow: #f2c14e;
    --yellow-dot: #f5b400;
    --yellow-bg: #3a3119;
    --green: #4cc480;
    --green-bg: #17332a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.break { word-break: break-all; }

/* Kopfzeile */
.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--brand); color: var(--brand-ink);
  padding: 0 24px; height: 52px; position: sticky; top: 0; z-index: 10;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; color: #fff; }
.logo img { width: 24px; height: 24px; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav a {
  color: rgba(255, 255, 255, .82); padding: 8px 12px; border-radius: 6px; white-space: nowrap;
}
.nav a:hover { background: rgba(255, 255, 255, .12); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .18); color: #fff; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.userbox a { color: #fff; opacity: .85; }
.role-pill { background: rgba(255, 255, 255, .18); border-radius: 10px; padding: 1px 8px; font-size: 12px; }

/* Hinweis bei externem Zugriff (Admin-Funktionen ausgeblendet) */
.ext-banner {
  background: var(--yellow-bg); color: var(--text); border-bottom: 1px solid var(--line);
  padding: 6px 24px; font-size: 12.5px; text-align: center;
}

main { max-width: 1680px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--muted); }

/* Karten und Raster */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.card > h2:first-child { margin-top: 0; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); display: block; color: var(--text);
}
a.tile:hover { text-decoration: none; border-color: var(--brand-2); }
.tile .num { font-size: 28px; font-weight: 650; line-height: 1.1; }
.tile .lbl { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.tile.red { border-left: 4px solid var(--red); }
.tile.yellow { border-left: 4px solid var(--yellow-dot); }
.tile.green { border-left: 4px solid var(--green); }
.tile.alert .num { color: var(--red); }

/* Ampel */
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: -1px; flex: none; }
.dot.red { background: var(--red); }
.dot.yellow { background: var(--yellow-dot); }
.dot.green { background: var(--green); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 12px; padding: 2px 10px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.grey { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.sev { font-size: 12px; font-weight: 600; border-radius: 4px; padding: 1px 6px; }
.sev.hoch { background: var(--red-bg); color: var(--red); }
.sev.mittel { background: var(--yellow-bg); color: var(--yellow); }
.sev.niedrig { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.scorebar { display: inline-flex; align-items: center; gap: 6px; }
.scorebar .bar { width: 48px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.scorebar .bar span { display: block; height: 100%; background: var(--brand-2); }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--panel-2); }
tbody tr:hover { background: var(--panel-2); }
tr.clickable { cursor: pointer; }
td.domain { font-weight: 600; }
td.domain .ascii { font-weight: 400; color: var(--muted); font-size: 12px; }
/* kompakte Tabellen (eine Zeile je Eintrag): Spaltenköpfe ohne Umbruch, Notizen gekürzt */
table.compact th { white-space: nowrap; }
table.compact th, table.compact td { padding: 8px 8px; }
/* Aktionsknöpfe in einer Zeile; nur auf schmalen Bildschirmen umbrechen statt die Tabelle seitlich zu scrollen */
table.compact td.row-actions { text-align: right; }
table.compact td.row-actions button { margin: 2px 0; }
td.domain .note {
  display: inline-block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom;
  margin-left: 8px; font-weight: 400; color: var(--muted); font-size: 12px;
}
.warn-text { color: var(--yellow); }
/* laufende Varianten-Prüfung */
.spinner {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px;
  border: 2px solid var(--line); border-top-color: var(--brand-2); animation: dp-spin 1s linear infinite;
}
@keyframes dp-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* Formulare */
label { display: block; font-weight: 600; font-size: 12.5px; margin: 10px 0 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; font-size: 14px; margin: 6px 14px 6px 0; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=time], input[type=search], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--text); font: inherit;
}
textarea { min-height: 90px; font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }

button, .btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); padding: 7px 14px; border-radius: 6px; font: inherit; cursor: pointer; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--brand-2); text-decoration: none; }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-2); }
button.danger { color: var(--red); }
button.danger:hover { border-color: var(--red); }
button.small, .btn.small { padding: 3px 9px; font-size: 12.5px; }
button:disabled { opacity: .55; cursor: not-allowed; }

/* Filterleiste */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters > div { min-width: 140px; }
.filters label { margin-top: 0; }
.filters input[type=search] { min-width: 220px; }
.chips { display: flex; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line);
  border-radius: 16px; background: var(--panel); cursor: pointer; user-select: none;
}
.chip.on { border-color: var(--brand-2); background: var(--panel-2); font-weight: 600; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }

/* Detailseite */
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.headline { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.headline h1 { font-size: 24px; word-break: break-all; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 2px 0 12px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-2); }
.timeline .when { color: var(--muted); font-size: 12px; }
.score-list { margin: 0; padding: 0; list-style: none; }
.score-list li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.score-list li.total { font-weight: 700; border-bottom: none; }
.pos { color: var(--red); }
.neg { color: var(--green); }

/* Diagramm */
.chart svg { width: 100%; height: 190px; display: block; }
.chart .bar-new { fill: var(--red); }
.chart .bar-base { fill: var(--yellow-dot); opacity: .75; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: var(--line); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* Status */
.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.status-list li:last-child { border-bottom: none; }
.status-list .name { width: 170px; flex: none; font-weight: 600; }
.state { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 4px; }
.state.up { background: var(--green-bg); color: var(--green); }
.state.down { background: var(--red-bg); color: var(--red); }
.state.degraded, .state.unknown { background: var(--yellow-bg); color: var(--yellow); }
/* Quelle hat sich länger als erwartet nicht gemeldet (unabhängig vom Zustand) */
.state.stale { background: transparent; color: var(--yellow); border: 1px dashed var(--yellow-dot); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-bottom-color: var(--brand-2); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .logo { color: var(--text); font-size: 18px; margin-bottom: 18px; }
.login-card .logo img { width: 30px; height: 30px; }
.qr { background: #fff; padding: 8px; display: inline-block; border-radius: 6px; border: 1px solid var(--line); }
.qr svg { display: block; width: 190px; height: 190px; }

/* Meldungen */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--brand-2);
  border-radius: 6px; padding: 10px 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .15); max-width: 420px;
}
.toast.error { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
.notice { border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.notice.warn { background: var(--yellow-bg); border-color: transparent; }
.notice.err { background: var(--red-bg); color: var(--red); border-color: transparent; }
/* Hinweis unter einem Formular (z. B. nach dem Speichern) */
.card > form + div > .notice { margin: 14px 0 0; }

/* Dialog */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal { background: var(--panel); border-radius: 10px; padding: 20px; width: 100%; max-width: 520px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.secret { font-family: var(--mono); font-size: 17px; background: var(--panel-2); border: 1px dashed var(--line); padding: 10px; border-radius: 6px; user-select: all; }

@media (max-width: 760px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .ext-banner { padding: 6px 12px; }
  .logo span { display: none; }
  main { padding: 16px; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .userbox .uname { display: none; }
}

/* Sprachumschalter */
.lang-switch { margin-top: 18px; text-align: center; font-size: 12.5px; color: var(--muted); }
.lang-switch a { color: var(--muted); }
.lang-switch a.active { color: var(--text); font-weight: 600; }
