/* Gateburrow - Admin-Oberflaeche
   Farbwerte und Abstaende ausschliesslich ueber Variablen, damit Hell/Dunkel
   an genau einer Stelle definiert ist. Selektoren bewusst flach halten:
   keine Kombinationen aus Theme-Klasse und Komponentenregel. */

:root {
  --bg: #0a0c11;
  --surface: #11141c;
  --surface-2: #161a24;
  --surface-3: #1c2130;
  --border: #232a3a;
  --border-strong: #303950;
  --text: #e7eaf2;
  --text-dim: #99a2b8;
  --text-faint: #6b748c;
  --accent: #1a56ff;
  --accent-soft: rgba(26, 86, 255, 0.14);
  --accent-line: rgba(26, 86, 255, 0.45);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.13);
  --crit: #f87171;
  --crit-soft: rgba(248, 113, 113, 0.13);
  --idle: #64748b;
  --radius: 10px;
  --radius-sm: 6px;
  --nav-w: 236px;
  --top-h: 56px;
  --font: "Inter", "Inter var", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.24);
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --border: #dde3ed;
  --border-strong: #c3cddd;
  --text: #10141c;
  --text-dim: #55607a;
  --text-faint: #7d879c;
  --accent-soft: rgba(26, 86, 255, 0.09);
  --accent-line: rgba(26, 86, 255, 0.35);
  --ok: #0f9d66;
  --ok-soft: rgba(15, 157, 102, 0.11);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.11);
  --crit: #d33a3a;
  --crit-soft: rgba(211, 58, 58, 0.11);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ------------------------------------------------------------- Grundgeruest */

.shell { display: flex; min-height: 100vh; }

.nav {
  width: var(--nav-w);
  flex: 0 0 var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand-mark { width: 22px; height: 22px; flex: 0 0 auto; }
.brand-name { font-weight: 650; letter-spacing: -0.01em; font-size: 15px; color: var(--text); }
.brand a { color: inherit; display: flex; align-items: center; gap: 10px; }
.brand a:hover { text-decoration: none; }

.nav-group { padding: 14px 10px 4px; }
.nav-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  padding: 0 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
.nav-item[aria-current="page"] .nav-icon { color: var(--accent); }
.nav-icon { width: 16px; height: 16px; flex: 0 0 auto; color: var(--text-faint); }
.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  background: var(--surface-3);
  border-radius: 20px;
  padding: 1px 7px;
}
.nav-count.is-alert { color: var(--warn); background: var(--warn-soft); }
.nav-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); }
.nav-version { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--top-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.topbar-spacer { flex: 1 1 auto; }

.content { padding: 24px; max-width: 1420px; width: 100%; }

/* ---------------------------------------------------------------- Elemente */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 13.5px; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.card-head .sub { font-size: 12px; color: var(--text-faint); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.push { margin-left: auto; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.metric { padding: 16px 18px; }
.metric-label { font-size: 11.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.metric-value { font-size: 27px; font-weight: 620; letter-spacing: -0.025em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.metric-note { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.metric-value .unit { font-size: 14px; color: var(--text-faint); font-weight: 500; margin-left: 3px; }

/* Statuspunkt und Kennzeichen */
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: 0 0 auto; background: var(--idle); }
.dot-up { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot-down { background: var(--crit); box-shadow: 0 0 0 3px var(--crit-soft); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot-idle { background: var(--idle); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 550;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--surface-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.tag-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag-crit { background: var(--crit-soft); color: var(--crit); border-color: transparent; }
.tag-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.mono { font-family: var(--mono); font-size: 12.5px; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* --------------------------------------------------------------- Tabellen */

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
.table td { padding: 11px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .cell-main { font-weight: 550; }
.table .cell-sub { font-size: 12px; color: var(--text-faint); margin-top: 1px; }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty { padding: 40px 18px; text-align: center; color: var(--text-faint); }
.empty-title { color: var(--text-dim); font-weight: 550; margin-bottom: 4px; }

/* ------------------------------------------------------------ Bedienelement */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1749d8; }
.btn-danger { color: var(--crit); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--crit-soft); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; font-weight: 550; margin-bottom: 5px; color: var(--text-dim); }
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--text-faint); }
select { appearance: none; background-image: none; }

.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 11px; }
.check input { margin: 3px 0 0; accent-color: var(--accent); width: 15px; height: 15px; }
.check-text { font-size: 13px; }
.check-text .hint { font-size: 12px; color: var(--text-faint); }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; min-width: 0; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg label { display: block; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt {
  display: block;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-dim);
  cursor: pointer;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
}
.seg label:last-child .seg-opt { border-right: 0; }
.seg input:checked + .seg-opt { background: var(--accent-soft); color: var(--accent); }
.seg input:focus-visible + .seg-opt { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------------------------------------------------------------- Meldungen */

.note {
  display: flex;
  gap: 11px;
  padding: 12px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-bottom: 18px;
  font-size: 13px;
}
.note-ok { border-color: transparent; background: var(--ok-soft); color: var(--ok); }
.note-error { border-color: transparent; background: var(--crit-soft); color: var(--crit); }
.note-warn { border-color: transparent; background: var(--warn-soft); color: var(--warn); }
.note-accent { border-color: var(--accent-line); background: var(--accent-soft); }
.note strong { font-weight: 620; }

.secret-box {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--surface-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  word-break: break-all;
  color: var(--text);
}

/* -------------------------------------------------- Signatur: Pfadanzeige */
/* Zeigt den Weg eines Zugriffs: Client -> Edge -> Connector -> Ziel.
   Der aktive Transport wird als durchgezogene, ein Ersatzpfad als
   gestrichelte Linie dargestellt. */

.path { display: flex; align-items: stretch; gap: 0; padding: 4px 0; }
.path-node {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 108px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.path-node-title { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.path-node-meta { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }
.path-link { flex: 1 1 auto; min-width: 34px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; padding: 0 4px; }
.path-line { height: 2px; width: 100%; background: var(--border-strong); border-radius: 2px; }
.path-line.is-active { background: var(--accent); }
.path-line.is-fallback { background: repeating-linear-gradient(90deg, var(--warn) 0 6px, transparent 6px 11px); }
.path-line.is-down { background: repeating-linear-gradient(90deg, var(--crit) 0 4px, transparent 4px 9px); }
.path-tag { font-size: 10px; font-weight: 600; letter-spacing: 0.04em; color: var(--text-faint); text-transform: uppercase; }
.path-tag.is-active { color: var(--accent); }
.path-tag.is-fallback { color: var(--warn); }

/* Transportstreifen fuer einzelne Peers */
.lane { display: flex; align-items: center; gap: 7px; }
.lane-bar { width: 52px; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; position: relative; }
.lane-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; }
.lane-fill.is-tcp { background: repeating-linear-gradient(90deg, var(--warn) 0 4px, transparent 4px 7px); }
.lane-text { font-size: 11px; font-weight: 600; letter-spacing: 0.03em; }

/* ------------------------------------------------------------ Anmeldeseite */

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 372px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-mark { width: 34px; height: 34px; margin-bottom: 12px; }
.auth-title { font-size: 19px; font-weight: 640; letter-spacing: -0.02em; margin: 0 0 4px; }
.auth-sub { font-size: 13px; color: var(--text-faint); margin: 0; }
.auth-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.auth-foot { text-align: center; margin-top: 16px; font-size: 12px; color: var(--text-faint); }
.code-input { font-family: var(--mono); font-size: 21px; letter-spacing: 0.32em; text-align: center; }

/* ------------------------------------------------------------------ Sonstiges */

.qr-frame { background: #fff; padding: 10px; border-radius: var(--radius-sm); display: inline-block; line-height: 0; }
.qr-frame img { display: block; width: 190px; height: 190px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }

.kv { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; word-break: break-word; }

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--border); padding: 0 18px; }
.tab { padding: 10px 12px; font-size: 13px; font-weight: 550; color: var(--text-dim); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

.inline-form { display: inline; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 14px; }

.bar-track { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .nav { position: fixed; left: 0; top: 0; transform: translateX(-100%); z-index: 40; transition: transform 0.16s ease; box-shadow: var(--shadow); }
  .nav.is-open { transform: translateX(0); }
  .shell { display: block; }
  .content { padding: 16px; }
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .table th, .table td { padding: 9px 12px; }
}
@media (min-width: 861px) {
  .nav-toggle { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------- Filterleiste */

.filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding-bottom: 14px;
}

.filterbar-sep {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 120ms ease, color 120ms ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.chip.is-on {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.detail-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn.is-off {
  opacity: 0.4;
  pointer-events: none;
}

/* ------------------------------------------- Wiederherstellungscodes */

.code-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.code-grid span {
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--text);
  text-align: center;
  padding: 4px 0;
}
