/*
 * Aussehen des Panels, übernommen vom vigil-Dashboard (soc.akquisio.eu): gleiche Farben,
 * gleiche Schrift (DM Sans / DM Mono), schmale Seitenleiste, die beim Darüberfahren
 * aufklappt, Kopfzeile mit Titel und Unterzeile, Karten mit kleinen Überschriften in
 * Großbuchstaben. Auf dem Handy wird die Seitenleiste zur Leiste am unteren Rand.
 *
 * Hell/Dunkel: Ohne Wahl folgt die Seite dem System (prefers-color-scheme). Wer unter
 * Einstellungen > Darstellung "Hell" oder "Dunkel" wählt, setzt data-theme am <html>;
 * das hat dann Vorrang.
 */

@font-face { font-family: "DM Sans"; font-weight: 400; font-display: swap; src: url("fonts/dm-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 500; font-display: swap; src: url("fonts/dm-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 600 700; font-display: swap; src: url("fonts/dm-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Mono"; font-weight: 400 500; font-display: swap; src: url("fonts/dm-mono-latin-400-normal.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --accent: #2d3436;
  --accent-fg: #ffffff;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #e8e8e4;
  --border-light: #f0f0ec;
  --text-primary: #1a1a18;
  --text-secondary: #6b6b67;
  --text-tertiary: #a0a09c;
  --green: #3d8b2d;
  --green-bg: #eaf3e7;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #c0392b;
  --red-bg: #fdeaea;
  --bar-muted: #e2e2de;
  --sidebar-w: 52px;
  --sidebar-exp: 224px;
  --topbar-h: 52px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --font: "DM Sans", system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --accent: #ecebe8;
    --accent-fg: #161615;
    --bg: #161615;
    --surface: #1f1f1e;
    --border: #2f2f2c;
    --border-light: #282826;
    --text-primary: #ecebe8;
    --text-secondary: #a9a8a1;
    --text-tertiary: #75746e;
    --green: #6cbf5a;
    --green-bg: #1f2d1b;
    --amber: #f0a43a;
    --amber-bg: #33270f;
    --red: #e5675a;
    --red-bg: #3a1d1a;
    --bar-muted: #3a3a37;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #ecebe8;
  --accent-fg: #161615;
  --bg: #161615;
  --surface: #1f1f1e;
  --border: #2f2f2c;
  --border-light: #282826;
  --text-primary: #ecebe8;
  --text-secondary: #a9a8a1;
  --text-tertiary: #75746e;
  --green: #6cbf5a;
  --green-bg: #1f2d1b;
  --amber: #f0a43a;
  --amber-bg: #33270f;
  --red: #e5675a;
  --red-bg: #3a1d1a;
  --bar-muted: #3a3a37;
  --shadow: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font: 13px/1.5 var(--font);
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 17px; height: 17px; flex-shrink: 0; }

/* ---------- Gerüst: Seitenleiste, Kopfzeile, Inhalt ---------- */

.app { display: flex; height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden;
  transition: width 0.24s cubic-bezier(0.4, 0, 0.2, 1); z-index: 100;
}
.sidebar:hover, .sidebar:focus-within { width: var(--sidebar-exp); }
.sidebar-logo {
  height: var(--topbar-h); padding: 0 12px; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border); flex-shrink: 0; text-decoration: none; white-space: nowrap;
}
.sidebar-logo img { width: 28px; height: 28px; flex-shrink: 0; }
.logo-text { font-size: 14px; font-weight: 600; letter-spacing: 0.01em; color: var(--text-primary); }
.logo-text .logo-sub { font-weight: 400; color: var(--text-secondary); }
.logo-text .logo-sub::before { content: "|"; margin: 0 4px 0 3px; color: var(--text-tertiary); font-weight: 300; }
.logo-text, .nav-label, .nav-section, .nav-count, .user-info, .logout-btn { opacity: 0; transition: opacity 0.16s 0.06s; white-space: nowrap; }
.sidebar:hover :is(.logo-text, .nav-label, .nav-section, .nav-count, .user-info, .logout-btn),
.sidebar:focus-within :is(.logo-text, .nav-label, .nav-section, .nav-count, .user-info, .logout-btn) { opacity: 1; }

.nav { flex: 1; padding: 10px 8px; overflow: hidden; display: flex; flex-direction: column; }
.nav-bottom { margin-top: auto; padding-top: 10px; }
.nav-section {
  font-size: 9px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; line-height: 13px;
  color: var(--text-tertiary); padding: 0 7px; margin: 16px 0 4px;
}
.nav-section:first-child { margin-top: 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none; margin-bottom: 1px; white-space: nowrap;
  transition: background 0.1s, color 0.1s; position: relative;
}
.nav-item:hover { background: var(--bg); color: var(--text-primary); }
.nav-item.active { background: var(--accent); color: var(--accent-fg); }
.nav-label { flex: 1; font-size: 13px; font-weight: 500; }
.nav-count { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.nav-item.active .nav-count { color: var(--accent-fg); }

.sidebar-footer { padding: 10px 8px; border-top: 1px solid var(--border); flex-shrink: 0; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 6px 7px; border-radius: var(--radius-sm); white-space: nowrap; }
.sidebar:hover .user-chip, .sidebar:focus-within .user-chip { background: var(--bg); }
.user-chip form { display: flex; }
.logout-btn { background: none; border: 0; padding: 4px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-tertiary); display: flex; }
.logout-btn:hover { color: var(--text-primary); }
.logout-btn .icon { width: 15px; height: 15px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700;
  flex-shrink: 0; letter-spacing: 0.5px; text-transform: uppercase;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 500; }
.user-role { font-size: 10px; color: var(--text-tertiary); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-shrink: 0;
}
.page-head { min-width: 0; }
.page-title { font-weight: 600; font-size: 15px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-sub { font-size: 12px; color: var(--text-secondary); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.content { flex: 1; overflow-y: auto; padding: 20px 24px 48px; }
.content > * + * { margin-top: 10px; }

/* Handy: die Seitenleiste wird zur Leiste am unteren Rand (wie in vigil). */
@media (max-width: 760px) {
  .app { flex-direction: column-reverse; height: auto; min-height: 100vh; }
  .sidebar, .sidebar:hover, .sidebar:focus-within {
    width: 100%; flex-direction: row; border-right: 0; border-top: 1px solid var(--border);
    position: fixed; bottom: 0; left: 0; height: 56px; overflow: hidden;
  }
  .sidebar-logo, .nav-section, .nav-label, .nav-count, .user-info, .user-chip .avatar { display: none; }
  .nav { flex-direction: row; justify-content: space-between; align-items: center; padding: 6px 8px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-bottom { margin: 0; padding: 0; display: flex; }
  .nav-item { padding: 9px 10px; margin: 0; flex-shrink: 0; }
  .sidebar-footer { border-top: 0; border-left: 1px solid var(--border); padding: 6px; display: flex; align-items: center; }
  .user-chip, .sidebar:hover .user-chip { padding: 0; background: none; }
  .logout-btn { opacity: 1; padding: 9px; }
  .main { min-height: 100vh; padding-bottom: 56px; }
  .topbar { padding: 0 16px; position: sticky; top: 0; z-index: 50; }
  .content { padding: 16px 16px 32px; overflow: visible; }
}

/* ---------- Schrift ---------- */

h2 { font-size: 13px; font-weight: 600; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
h3 { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
h3 .icon { width: 13px; height: 13px; }
.muted { color: var(--text-tertiary); }
.secondary { color: var(--text-secondary); }
.small { font-size: 11px; }
.mono { font-family: var(--font-mono); font-size: 12px; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Karten und Raster ---------- */

.grid { display: grid; gap: 10px; }
.metrics { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1180px) { .metrics { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .metrics { grid-template-columns: 1fr 1fr; } }
.dash-a { grid-template-columns: 2fr 1fr; }
.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
@media (max-width: 1000px) { .dash-a { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; min-width: 0;
}
.card.narrow { max-width: 560px; }

.metric-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; line-height: 15px;
  color: var(--text-tertiary); display: flex; align-items: center; gap: 5px; margin-bottom: 8px;
}
.metric-label .icon { width: 13px; height: 13px; }
.metric-value { font-size: 26px; font-weight: 600; letter-spacing: -0.8px; line-height: 1; font-variant-numeric: tabular-nums; }
.metric-value.text { font-size: 22px; letter-spacing: -0.5px; }
.metric-value.good { color: var(--green); }
.metric-value.warn { color: var(--amber); }
.metric-value.bad { color: var(--red); }
.metric-sub { font-size: 10px; color: var(--text-tertiary); margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric-bar { height: 5px; background: var(--border-light); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.metric-fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; }
.metric-fill.warn { background: var(--amber); }
.metric-fill.bad { background: var(--red); }

.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; }
.panel-extra { font-size: 11px; color: var(--text-tertiary); }
.panel-extra a { text-decoration: none; }
.panel-extra a:hover { color: var(--text-primary); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 12px; }
.kv dt { color: var(--text-tertiary); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Zustand: Punkte, Schilder, Hinweise ---------- */

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; background: var(--text-tertiary); }
.dot.ok { background: #639922; }
.dot.bad { background: var(--red); }
.dot.warn { background: var(--amber); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.pill { display: inline-block; font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 4px; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; background: var(--bg); color: var(--text-tertiary); }
.pill.ok { background: var(--green-bg); color: var(--green); }
.pill.bad { background: var(--red-bg); color: var(--red); }
.pill.warn { background: var(--amber-bg); color: var(--amber); }

.notice { border-radius: var(--radius-sm); padding: 10px 14px; font-size: 12px; font-weight: 500; border: 1px solid transparent; }
.notice-good { background: var(--green-bg); color: var(--green); }
.notice-danger { background: var(--red-bg); color: var(--red); }
.notice-warn { background: var(--amber-bg); color: var(--amber); }

/* ---------- Listen und Tabellen ---------- */

.feed { display: grid; margin: -4px -8px 0; }
.feed-row { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; padding: 8px; border-radius: var(--radius-sm); align-items: center; }
.feed-row + .feed-row { border-top: 1px solid var(--border-light); }
.feed-main { min-width: 0; }
.feed-title { font-weight: 500; overflow-wrap: anywhere; }
.feed-sub { font-size: 11px; color: var(--text-tertiary); overflow-wrap: anywhere; margin-top: 2px; }
.feed-time { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; }
.feed-row form { margin: 0; }
.empty { padding: 28px 16px; color: var(--text-tertiary); text-align: center; font-size: 12px; }

.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 14px; padding: 11px 16px; border-top: 1px solid var(--border-light); align-items: center; }
.row:first-child { border-top: 0; }
.row:hover { background: var(--bg); }
.row .title { overflow-wrap: anywhere; font-weight: 500; }
.row .sub { color: var(--text-tertiary); font-size: 11px; overflow-wrap: anywhere; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.row .sub .family { color: var(--text-primary); font-weight: 600; }
.row form { margin: 0; }

.tablewrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.card .tablewrap { box-shadow: none; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); padding: 12px 16px 8px; white-space: nowrap; border-bottom: 1px solid var(--border-light); }
td { padding: 9px 16px; border-top: 1px solid var(--border-light); vertical-align: top; }
tr:first-child td { border-top: 0; }
th.num, td.num { text-align: right; }
tr.row-danger td.action { color: var(--red); font-weight: 600; }
td.error-cell { color: var(--red); min-width: 180px; overflow-wrap: anywhere; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Bedienelemente ---------- */

.tabs { display: flex; gap: 3px; flex-wrap: wrap; }
.tabs a { border-radius: var(--radius-sm); padding: 5px 12px; font-size: 12px; font-weight: 500; color: var(--text-secondary); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.tabs a .icon { width: 14px; height: 14px; }
.tabs a:hover { background: var(--surface); color: var(--text-primary); }
.tabs a.on { background: var(--accent); color: var(--accent-fg); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px;
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-fg); text-decoration: none; white-space: nowrap; transition: opacity 0.1s;
}
.btn .icon { width: 15px; height: 15px; }
.btn:hover { opacity: 0.88; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn.ghost:hover { background: var(--bg); color: var(--text-primary); opacity: 1; }
.btn.danger { background: var(--red-bg); color: var(--red); }
.btn.icon-only { padding: 6px; background: transparent; color: var(--text-tertiary); }
.btn.icon-only:hover { background: var(--red-bg); color: var(--red); opacity: 1; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn[data-busy] .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn[data-busy] .icon { animation: none; } }

form.stack { display: grid; gap: 12px; align-content: start; }
form.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
form.inline label { flex: 1 1 180px; }
form.inline label.wide { flex: 3 1 320px; }
form.inline label.fixed { flex: 0 0 auto; }
label { display: grid; gap: 5px; font-size: 12px; font-weight: 500; color: var(--text-primary); }
input, select {
  width: 100%; min-width: 0; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-primary); background: var(--surface); outline: none; height: 36px;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-tertiary); }
input.mono { font-family: var(--font-mono); font-size: 12px; }
.code-input { font-variant-numeric: tabular-nums; }
.filter-form { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-form select { width: auto; }
.filter-form input { width: 220px; }

/* Auswahl Hell / Dunkel / System */
.segmented { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.segmented button { background: transparent; border: 0; border-radius: 4px; padding: 6px 14px; cursor: pointer; font-size: 12px; font-weight: 500; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.segmented button .icon { width: 14px; height: 14px; }
.segmented button:hover { color: var(--text-primary); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }

details.danger-zone { border-top: 1px solid var(--border-light); padding-top: 12px; }
details.danger-zone summary { cursor: pointer; color: var(--red); font-weight: 600; font-size: 12px; margin-bottom: 10px; }

/* ---------- Anmeldung (wie die Anmeldeseite von vigil) ---------- */

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px;
}
.login-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 26px; }
.login-brand img { width: 34px; height: 34px; }
.login-brand .logo-text { opacity: 1; font-size: 16px; }
.login-title { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; }
.login-sub { font-size: 12px; color: var(--text-secondary); margin: 4px 0 22px; }
.login form.stack { gap: 14px; }
.login .btn { width: 100%; padding: 9px 14px; margin-top: 10px; }
.login .notice { margin-bottom: 16px; }

/* ---------- Handy: Formulare und Kopf ---------- */

@media (max-width: 760px) {
  .filter-form, .filter-form input, .filter-form select { width: 100%; }
  form.inline .btn, .panel-head form, .panel-head form .btn { width: 100%; }
  .metric-value { font-size: 22px; }
}

/* ---------- Kleinigkeiten ---------- */

a.card-link { text-decoration: none; display: block; transition: border-color 0.1s; }
a.card-link:hover { border-color: var(--text-tertiary); }
.spaced { margin-top: 12px; }
.panel-gap { margin-top: 18px; }
.panel-head.toolbar { margin: 18px 0 0; }
.panel-head.toolbar + .list { margin-top: 10px; }
.content p { font-size: 12px; }

/* ---------- Admin: Kontenliste und neue Zugangsdaten ---------- */

.btn.small { padding: 4px 10px; font-size: 11px; }
.btn.small .icon { width: 13px; height: 13px; }
.row-form select { width: auto; height: 30px; padding: 4px 8px; font-size: 12px; }
td.actions-cell { text-align: right; }
td.actions-cell form { display: inline-block; margin-left: 4px; }
table td { vertical-align: middle; }
.secret { font-family: var(--font-mono); font-size: 12px; background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 8px 10px; overflow-wrap: anywhere; user-select: all; }
.access-card { border-color: var(--amber); }
.access-grid { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; }
.access-grid .kv { align-items: center; }
/* Der QR-Code bleibt immer schwarz auf weiß, auch in der dunklen Darstellung:
   viele Kamera-Apps lesen umgekehrte Farben nicht. */
.qr { background: #ffffff; border-radius: var(--radius-sm); padding: 6px; line-height: 0; border: 1px solid var(--border); }
.qr svg { width: 200px; height: 200px; }
@media (max-width: 640px) { .access-grid { grid-template-columns: 1fr; } .qr { justify-self: center; } }

/* ---------- IP-Liste ---------- */

/* Jeder Block ist 3 Stellen breit. Die Füllnullen kommen aus data-pad (::before) und sind
   blass; weil sie nicht im Text stehen, kopiert man die normale Form 124.151.44.5. */
.ip { font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ip-block[data-pad]::before { content: attr(data-pad); color: var(--text-tertiary); opacity: 0.45; }
.check-result { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 12px; }
.check-result .notice-text { color: var(--red); font-size: 12px; }
.row-actions { display: flex; gap: 6px; align-items: center; }
