:root {
  --bg:        #0d1117;
  --surface:   #151b24;
  --surface-2: #1c2530;
  --surface-3: #232e3b;
  --bg-2:      #151b24;   /* Alias auf --surface (Altbestand) */
  --bg-3:      #1c2530;   /* Alias auf --surface-2 (Altbestand) */
  --border:    #263241;
  --border-2:  #30404f;
  --text:      #e8ecf3;
  --text-dim:  #93a0b4;
  --text-mute: #63718a;
  --accent:    #4f8cff;
  --accent-2:  #6aa0ff;
  --accent-soft: rgba(79, 140, 255, .14);
  --ok:        #4ade80; --ok-bg:   rgba(74, 222, 128, .13);
  --warn:      #fbbf24; --warn-bg: rgba(251, 191, 36, .13);
  --err:       #f87171; --err-bg:  rgba(248, 113, 113, .13);
  --off:       #8a94a6; --off-bg:  rgba(138, 148, 166, .13);
  --shadow:    0 20px 50px rgba(0, 0, 0, .45);
  --radius:    14px;
  --radius-sm: 10px;
  --sidebar-w: 248px;

  /* aus dem Dark-Theme der BSC-WebApp übernommen */
  --bsc-primary: #2566a6;
  --bsc-head:    #ccc;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- Kopfzeile ----------
   Farben und Maße stammen aus dem Dark-Theme der BSC-WebApp
   (--primary: #2566a6, --text-head: #ccc), damit die Leiste über dem iframe
   dieselbe ist wie die im iframe. */
.topbar {
  flex: 0 0 52px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 6px 14px;
  background: var(--bsc-primary);
  color: var(--bsc-head);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
}

.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text strong { font-size: 16px; }
.brand-text small { font-size: 12px; margin-top: 3px; }

.topbar-title { font-size: 18px; }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Auf der Leiste sind die Kontraste andere als auf dunklem Grund. */
.topbar .btn-ghost { color: var(--bsc-head); border-color: rgba(255, 255, 255, .35); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.topbar .mono { color: var(--bsc-head); }

@media (max-width: 640px) {
  .brand-text, .topbar .mono { display: none; }
  .topbar-title { font-size: 15px; }
}

.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: 13px; }
.dim { color: var(--text-dim); font-size: 12px; }

/* ---------- Buttons ---------- */
.btn {
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: 600 14px var(--sans);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 24px; padding: 12px; }

/* ---------- Anmelde-/Schlüsselschirm ---------- */
.screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, #1a2130, var(--bg) 70%);
}

.card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.card h1 { font-size: 21px; margin-bottom: 10px; }

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 22px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin: 16px 0 6px;
}

/* Erklaerung unter einem Eingabefeld, kleiner als .subtitle. */
.hint {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 6px;
}

input[type=text], input[type=password], input[type=search], input[type=email] {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
input:focus { outline: none; border-color: var(--accent); }

/* Passwort-/Schlüssel-Felder mit Augen-Button zum Ein-/Ausblenden. */
.input-reveal { position: relative; }
.input-reveal input { padding-right: 44px; }
.reveal-btn {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
}
.reveal-btn:hover { color: var(--text); }
.reveal-btn .eye-closed { display: none; }
.input-reveal.revealed .reveal-btn .eye-open { display: none; }
.input-reveal.revealed .reveal-btn .eye-closed { display: block; }

.row { display: flex; gap: 10px; margin-top: 24px; }
.row .btn { flex: 1; }

.error { color: var(--err); font-size: 13px; margin-top: 14px; line-height: 1.5; }

/* ---------- Rahmen ---------- */
.app { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.badge {
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-on  { background: rgba(74, 222, 128, .14); color: var(--ok); }
.badge-off { background: rgba(248, 113, 113, .14); color: var(--err); }

main { flex: 1; display: flex; min-height: 0; }

.panel { display: flex; flex-direction: column; min-width: 0; }
.panel-remote { flex: 1.25; }
.panel-logs { flex: 1; background: var(--bg-2); }

/* ---------- Trennlinie zwischen den Bereichen ---------- */
.splitter {
  flex: 0 0 5px;
  background: var(--border);
  cursor: col-resize;
  position: relative;
  transition: background .15s;
}

/* Der Greifbereich ist breiter als die sichtbare Linie — sonst muss man beim
   Ziehen zielen. */
.splitter::before {
  content: "";
  position: absolute;
  inset: 0 -4px;
}

.splitter:hover,
.splitter:focus-visible,
.splitter.dragging { background: var(--accent); outline: none; }

/* Während des Ziehens darf der iframe die Maus nicht abfangen — sonst reißt die
   Bewegung ab, sobald der Zeiger die WebApp überstreicht. */
body.splitting { cursor: col-resize; user-select: none; }
body.splitting #frame { pointer-events: none; }

.panel-head {
  flex: 0 0 auto;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-head h2 { font-size: 14px; font-weight: 600; }

#frame { flex: 1; width: 100%; border: 0; background: #fff; }

.panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px;
}

/* ---------- Log-Werkzeugleiste ---------- */
.notice {
  background: rgba(79, 140, 255, .1);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.notice .row { margin: 0; }
.notice .btn { flex: 0 0 auto; }

.toolbar { display: flex; align-items: center; gap: 14px; }
.toolbar input[type=search] { flex: 1; }

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.check input { cursor: pointer; }

/* ---------- Log-Anzeige ---------- */
.viewer {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
}

.placeholder { color: var(--text-dim); text-align: center; padding: 32px 0; font-family: var(--sans); }

.line { white-space: pre-wrap; word-break: break-word; padding: 1px 3px; border-radius: 3px; }
.line.fresh { animation: fresh .5s ease; }
@keyframes fresh {
  from { background: rgba(74, 222, 128, .18); }
  to   { background: transparent; }
}

mark { background: rgba(251, 191, 36, .28); color: inherit; border-radius: 2px; }

.file-head {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12px;
  padding: 10px 4px 4px;
  margin-top: 6px;
  cursor: pointer;
  border-radius: 4px;
}

.file-head:hover,
.file-head:focus-visible {
  background: rgba(79, 140, 255, .12);
  text-decoration: underline;
  outline: none;
}

/* Kurzes Aufblinken der Zeile, zu der gesprungen wurde — sonst muss man erst
   suchen, wo man gelandet ist. */
.line.jump {
  background: rgba(79, 140, 255, .22);
  box-shadow: inset 2px 0 0 var(--accent);
  transition: background 1.2s ease, box-shadow 1.2s ease;
}

/* ---------- Trennlinie zwischen Log-Anzeige und Dateiliste ---------- */
.hsplitter {
  flex: 0 0 5px;
  background: var(--border);
  border-radius: 3px;
  cursor: row-resize;
  position: relative;
  transition: background .15s;
}

.hsplitter::before {
  content: "";
  position: absolute;
  inset: -4px 0;
}

.hsplitter:hover,
.hsplitter:focus-visible,
.hsplitter.dragging { background: var(--accent); outline: none; }

body.splitting-v { cursor: row-resize; user-select: none; }

/* ---------- Dateiliste ---------- */
.files { flex: 0 0 168px; min-height: 0; display: flex; flex-direction: column; }

.files h3 {
  flex: 0 0 auto;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.files ul { flex: 1; min-height: 0; list-style: none; overflow-y: auto; }

.files li {
  padding: 6px 9px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.files li:hover { background: var(--bg-3); color: var(--text); }
.files li.active { background: rgba(79, 140, 255, .14); color: var(--accent); }

@media (max-width: 900px) {
  main { flex-direction: column; }
  .panel-remote { border-bottom: 1px solid var(--border); }
  .splitter { display: none; }
}

/* ==========================================================================
   Portal-Oberflaeche (Registrierung, Login, Dashboard, Konto, Maintainer)
   ========================================================================== */

/* Scrollbare Seite fuer Dashboard/Konto/Maintainer (der Body ist overflow:hidden). */
.app-page {
  flex: 1;
  overflow-y: auto;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
}

/* Globaler Hinweis-Banner. */
.flash {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(90vw, 460px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  box-shadow: var(--shadow), 0 0 0 5px var(--accent-soft);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  animation: flash-in .24s ease-out;
}

.flash::before {
  content: "";
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 14px 14px no-repeat,
    var(--accent);
}

@keyframes flash-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Pflichtfeld-Stern und Umschalter-Tabs. */
.req { color: var(--err); }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tab {
  flex: 1;
  padding: 8px;
  background: var(--bg-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

select, textarea {
  width: 100%;
  padding: 10px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 4px;
}

/* Formulare im Fluss. */
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.inline-form input { flex: 1; min-width: 160px; }
.stacked { display: flex; flex-direction: column; gap: 4px; max-width: 460px; }
.stacked label { margin-top: 8px; }

/* ---------- BSC-/Nutzer-Tabelle ---------- */
.bsc-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.bsc-table th, .bsc-table td {
  padding: 13px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.bsc-table thead th {
  color: var(--text-mute);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.bsc-table tbody tr:hover { background: var(--surface-2); }
.bsc-table tbody tr:last-child td { border-bottom: 0; }
.bsc-table td.dev-name { font-weight: 600; color: var(--text); }
.bsc-table td.dev-id { font-family: var(--mono); font-size: 12px; color: var(--text-mute); }
.bsc-table th.sortable { cursor: pointer; user-select: none; }
.bsc-table th.sortable:hover { color: var(--text); }
.bsc-table th.sort-asc::after  { content: " \25B2"; font-size: 10px; }
.bsc-table th.sort-desc::after { content: " \25BC"; font-size: 10px; }
.bsc-table td.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Status-Ampel als Zellhintergrund mit Kontrasttext ---------- */
.status { font-weight: 700; text-align: center; border-radius: 6px; }
.status-ok    { background: var(--ok);   color: #06340f; }
.status-warn  { background: var(--warn); color: #3a2a00; }
.status-error { background: var(--err);  color: #3b0000; }
.status-alarm { background: #a855f7;     color: #fff; animation: alarm-blink 1s steps(1) infinite; }
.status-offline { background: #6b7280;   color: #e5e7eb; }

@keyframes alarm-blink {
  50% { background: #d8b4fe; color: #2a0a45; }
}

/* ---------- Listen ---------- */
.plain-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.row.spread { display: flex; align-items: center; justify-content: space-between; }
.row.wrap { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge { padding: 3px 10px; border-radius: 999px; background: var(--bg-3); font-size: 13px; }
.badge.badge-off { background: rgba(248, 113, 113, .18); color: var(--err); }

/* ---------- Gefahr-Panel ---------- */
.panel-danger { border: 1px solid rgba(248, 113, 113, .4); border-radius: 10px; }
.btn-danger { background: var(--err); color: #2a0000; }
.btn-danger:hover { filter: brightness(1.08); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column; gap: 10px;
}
.modal-card.wide { max-width: 620px; }
.modal-actions { margin-top: 10px; gap: 8px; }
.hidden { display: none !important; }

/* ==========================================================================
   Hell-/Dunkelmodus, Icon-Aktionen, einzeilige Tabelle, Schiebeschalter
   ========================================================================== */

/* Der Standard (oben definiert) ist der Dunkelmodus. Der Hellmodus überschreibt
   nur die Farbvariablen; die Status-Ampel bringt ihre Kontrastfarben selbst mit
   und funktioniert daher in beiden Modi. */
:root[data-theme="light"] {
  --bg:        #f4f6fb;
  --surface:   #ffffff;
  --surface-2: #f7f9fd;
  --surface-3: #eef2f8;
  --bg-2:      #ffffff;
  --bg-3:      #f7f9fd;
  --border:    #e2e8f2;
  --border-2:  #d3dce8;
  --text:      #1a2230;
  --text-dim:  #5a6a80;
  --text-mute: #8a97ab;
  --accent:    #2f6fe0;
  --accent-2:  #2560c8;
  --accent-soft: rgba(47, 111, 224, .12);
  --ok:   #16a34a; --ok-bg:   rgba(22, 163, 74, .12);
  --warn: #d97706; --warn-bg: rgba(217, 119, 6, .12);
  --err:  #dc2626; --err-bg:  rgba(220, 38, 38, .12);
  --off:  #64748b; --off-bg:  rgba(100, 116, 139, .12);
  --shadow: 0 16px 40px rgba(35, 55, 90, .12);
}

select:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* Graue Icon-Knöpfe (wie der Augen-Knopf): transparent, beim Überfahren kräftiger. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: rgba(127, 127, 127, .14); }
.icon-btn.danger:hover { color: var(--err); }

/* Aktions-Knopf im Panel-Kopf (z. B. „BSC hinzufügen"). */
.icon-btn.accent { color: var(--accent); }
.icon-btn.accent:hover { color: var(--accent); background: rgba(127, 127, 127, .14); }
.head-actions { display: inline-flex; align-items: center; gap: 10px; }

/* Sprach-Umschalter: Flaggen-Emoji statt SVG-Icon. */
.lang-flag { font-size: 17px; line-height: 1; }

/* Der Umschalter in der (blauen) Kopfleiste nimmt deren Textfarbe an. */
.topbar-right .icon-btn { color: var(--bsc-head); }
.topbar-right .icon-btn:hover { color: #fff; }

/* Sonne im Dunkelmodus (Klick → hell), Mond im Hellmodus (Klick → dunkel). */
.i-moon { display: none; }
:root[data-theme="light"] .i-sun { display: none; }
:root[data-theme="light"] .i-moon { display: inline; }

/* Gerätetabelle einzeilig: nichts bricht um, die Aktionen bleiben in einer Reihe. */
.bsc-table th, .bsc-table td { white-space: nowrap; }
.bsc-table td.actions { display: flex; flex-wrap: nowrap; gap: 2px; }

/* Schiebeschalter (Darstellung). */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 460px;
  cursor: pointer;
}
.switch { position: relative; width: 46px; height: 26px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background .15s, border-color .15s;
}
.switch-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform .15s, background .15s;
}
.switch input:checked + .switch-slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); background: #fff; }

/* Im Hellmodus der Anmeldeschirm-Verlauf hell statt dunkel. */
:root[data-theme="light"] .screen { background: radial-gradient(circle at 50% 0%, #e6ecf5, var(--bg) 70%); }

/* ---------- Sprach-Dropdown ---------- */
.lang-select {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 13px;
  width: auto;
  cursor: pointer;
}
.lang-select:focus { outline: none; border-color: var(--accent); }
/* In der (blauen) Kopfleiste kontrastreich auf dem Blau. */
.topbar-right .lang-select {
  background: rgba(255, 255, 255, .14);
  color: var(--bsc-head);
  border-color: rgba(255, 255, 255, .35);
}
/* Sprachwahl in der Anmeldekarte rechtsbündig über den Tabs. */
.auth-lang { display: flex; justify-content: flex-end; margin-bottom: 12px; }

/* Marken-Kopf der Anmeldekarte: Logo + „BSC Connect" + Untertitel. */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  margin-bottom: 22px;
}
.brand-logo {
  filter: drop-shadow(0 8px 20px rgba(47, 111, 224, .45));
}
.brand-name {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .3px;
  margin-top: 4px;
}
.brand-name span {
  background: linear-gradient(90deg, #5b9cff, #2f6fe0);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.brand-tagline {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
  max-width: 300px;
}

/* ==========================================================================
   Hilfe-Icons (Fragezeichen) mit Hover-Tooltip + Konto-Tabs
   ========================================================================== */

/* Kleines "?"-Icon neben Feldern. */
.help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  position: relative;
  vertical-align: middle;
  user-select: none;
}
.help:hover, .help:focus { color: var(--text); border-color: var(--accent); outline: none; }

/* Tooltip-Blase über dem Icon; erscheint bei Hover/Fokus. */
.help::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 260px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .38);
  opacity: 0;
  visibility: hidden;
  transition: opacity .12s;
  pointer-events: none;
  z-index: 70;
}
/* Pfeil unter der Blase. */
.help::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border);
  opacity: 0;
  visibility: hidden;
  transition: opacity .12s;
}
.help:hover::after, .help:focus::after,
.help:hover::before, .help:focus::before { opacity: 1; visibility: visible; }

/* Eingabefeld + Hilfe-Icon nebeneinander (in Formularen ohne Label). */
.field-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 160px;
}
.field-help input { flex: 1; }

/* Konto-Tabs (oben laufend). */
.account-tabs { flex-wrap: wrap; margin-bottom: 4px; }
.account-tabs .tab { flex: 1 1 auto; }

/* Zwischenzustand der Fernsteuerungs-Verbindung (Selbstheilung läuft). */
.badge-warn { background: rgba(251, 191, 36, .16); color: var(--warn); }

/* ---------- Busy-/Ladeanzeige (z. B. während der Anlern-Abfrage) ---------- */
.btn:disabled { opacity: .7; cursor: progress; }
.btn.loading::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  vertical-align: -1px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin .6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
/* Während einer laufenden Aktion überall den Fortschritts-Cursor zeigen. */
body.busy, body.busy * { cursor: progress !important; }

/* ---------- Maintainer: verbundene BSCs ---------- */
.dev-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.dev-stats .badge { font-size: 13px; }
.pair-cell { text-align: center; }
.pair-badge { display: inline-flex; align-items: center; color: var(--accent); cursor: help; }

/* Sortierbare Tabellenkoepfe: Cursor + Sortpfeil an der aktiven Spalte. */
.bsc-table.sortable th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
.bsc-table.sortable th[data-sort]:hover { color: var(--text); }
.bsc-table.sortable th[data-sort]::after { content: ""; display: inline-block; width: 0.8em; opacity: .6; }
.bsc-table.sortable th.sort-asc::after  { content: "▲"; }
.bsc-table.sortable th.sort-desc::after { content: "▼"; }

/* ==========================================================================
   Sidebar-Layout der Portal-SPA (Dashboard, Fernsteuerung, Konto in einer Seite)
   ========================================================================== */

/* Die Shell fuellt (nach der Anmeldung) den ganzen Body: links die Navigation,
   rechts der Inhalt. Der Anmeldeschirm (view-auth) laeuft weiterhin ohne Sidebar. */
.app-shell {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* ---------- Sidebar ---------- */
.sidebar {
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 0;
}

.side-brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.side-brand .logo {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: none;
  box-shadow: 0 6px 16px rgba(37, 102, 166, .4);
}
.side-brand .brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.side-brand .brand-text strong { font-size: 14.5px; font-weight: 700; }
.side-brand .brand-text small { font-size: 11px; color: var(--text-mute); }

.side-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side-section {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--text-mute);
  padding: 14px 10px 6px;
}
.side-section:first-child { padding-top: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font: 500 14px var(--sans);
  text-align: left;
  cursor: pointer;
  transition: background .13s, color .13s;
}
.nav-item svg { flex: 0 0 auto; opacity: .85; }
.nav-item .nav-label { flex: 1; min-width: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-2); }
.nav-item.active svg { opacity: 1; }

.badge-count {
  flex: 0 0 auto;
  min-width: 20px;
  text-align: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
}
.nav-item.active .badge-count { background: var(--accent-soft); color: var(--accent-2); }

.side-foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  padding: 12px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.user-chip .avatar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #2566a6);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
.user-chip .user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.user-chip .u-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .u-mail { font-size: 11px; color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .logout-btn {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
}
.user-chip .logout-btn:hover { background: var(--surface-3); color: var(--err); }

/* ---------- Inhaltsbereich ---------- */
.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.content-topbar {
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px);
}
.page-title { font-size: 19px; font-weight: 700; }
.topbar-spacer { flex: 1; }

/* Suchfeld in der Topbar */
.search {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 240px;
  padding: 0 13px;
  height: 40px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-mute);
}
.search:focus-within { border-color: var(--accent); }
.search svg { flex: 0 0 auto; }
.search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: 14px var(--sans);
}
.search input::placeholder { color: var(--text-mute); }

.content-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Die Views fuellen den Inhaltsbereich; genau eine ist sichtbar. */
.content-main > .view { flex: 1; min-height: 0; }
.content-main > .app-page { min-height: 0; }

/* ---------- Icon-Buttons (Topbar) ---------- */
.content-topbar .icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: background .13s, color .13s, border-color .13s;
}
.content-topbar .icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* Der Hamburger-Knopf erscheint nur auf schmalen Bildschirmen. */
.burger { display: none; }
.sidebar-backdrop { display: none; }

/* ---------- Statistik-Karten (Dashboard) ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}
.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-ico {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
}
.stat-ico.ok   { background: var(--ok-bg);   color: var(--ok); }
.stat-ico.warn { background: var(--warn-bg); color: var(--warn); }
.stat-ico.error { background: var(--err-bg);  color: var(--err); }
.stat-ico.off  { background: var(--off-bg);  color: var(--off); }
.stat-ico.acc  { background: var(--accent-soft); color: var(--accent); }
.stat-ico.alarm { background: rgba(168, 85, 247, .16); color: #a855f7; }
.stat-meta { display: flex; flex-direction: column; line-height: 1.2; }
.stat-meta .v { font-size: 26px; font-weight: 800; }
.stat-meta .l { font-size: 12.5px; color: var(--text-dim); }

/* ---------- Status-Pills (Tabelle) ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.pill-ok   { background: var(--ok-bg);   color: var(--ok); }
.pill-ok   .dot { background: var(--ok);   box-shadow: 0 0 0 3px var(--ok-bg); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-warn .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.pill-err  { background: var(--err-bg);  color: var(--err); }
.pill-err  .dot { background: var(--err);  box-shadow: 0 0 0 3px var(--err-bg); }
.pill-off  { background: var(--off-bg);  color: var(--off); }
.pill-off  .dot { background: var(--off);  box-shadow: 0 0 0 3px var(--off-bg); }

/* ---------- Portal-Panels als Karten (nur im scrollbaren Seiteninhalt) ---------- */
.app-page .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.app-page .panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.app-page .panel-head h2 { font-size: 16px; font-weight: 700; margin: 0; }
.app-page .panel-head .spacer { flex: 1; }
.app-page .panel-body {
  display: block;
  flex: none;
  padding: 22px;
}
.app-page .panel.panel-danger { border-color: color-mix(in srgb, var(--err) 45%, var(--border)); }

/* Dashboard: die Geraeteliste scrollt bei Bedarf intern, statt die ganze
   Seite wachsen zu lassen. Der Tabellenkopf bleibt dabei sichtbar. */
#view-dashboard { overflow: hidden; }
#view-dashboard .panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#view-dashboard .panel-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 0; }
#view-dashboard .table-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#view-dashboard #bsc-empty { padding: 22px; }
#view-dashboard .bsc-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}
#view-dashboard .bsc-table th, #view-dashboard .bsc-table td { padding-left: 22px; }
#view-dashboard .bsc-table th:last-child, #view-dashboard .bsc-table td:last-child { padding-right: 22px; }


/* Formular-Raster im Prototyp-Stil */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  max-width: 720px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; }

/* Schalter-Zeilen (Einstellungen) */
.switch-row {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: space-between;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}
.switch-row:last-child { border-bottom: 0; }
.switch-row .st { font-size: 14px; font-weight: 600; }
.switch-row .sd { font-size: 12.5px; color: var(--text-mute); margin-top: 2px; }

/* ---------- Konsole als View ---------- */
.view-console {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Statusleiste der Fernsteuerung ueber der WebApp. */
.console-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.console-bar #device-id { color: var(--text-dim); }
.console-bar #con-logout { margin-left: auto; }

/* Kontextabhaengige Bedienelemente in der Statusleiste: statt einer eigenen
   Panel-Kopfleiste zeigt die Statusleiste je nach Ansicht nur das passende
   Element — „Neu laden" bei der Fernsteuerung, den Log-Dateinamen bei den Logs. */
#con-topbar-right #reload-frame,
#con-topbar-right #current-log { display: none; }
#con-topbar-right.view-remote #reload-frame { display: inline-flex; }
#con-topbar-right.view-logs #current-log { display: inline; }

/* Umschalter Fernsteuerung <-> Logs: kein Nebeneinander mehr, immer nur EIN
   Bereich sichtbar. Der senkrechte Splitter entfaellt. */
#con-main #splitter { display: none; }
#con-main .panel-remote,
#con-main .panel-logs { flex: 1 1 auto; min-width: 0; }
#con-main.show-remote .panel-logs { display: none; }
#con-main.show-logs .panel-remote { display: none; }

/* Segment-Schalter in der Statusleiste. */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.seg-btn {
  padding: 5px 14px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: 600 13px var(--sans);
  border-radius: 999px;
  cursor: pointer;
  transition: background .13s, color .13s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent); color: #fff; }

/* Innerhalb der View fuellen Anmeldeschirm bzw. App den Rest. */
.view-console > .screen { flex: 1; min-height: 0; }
.view-console > .app { flex: 1; min-height: 0; }

/* Tabellen-Aktionen bleiben kompakt und dezent (nicht die 40px-Topbar-Buttons). */
.bsc-table td.actions { display: flex; gap: 6px; }
.bsc-table td.actions .icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
}
.bsc-table td.actions .icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ---------- Schmale Bildschirme: Sidebar wird ausklappbar ---------- */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 60;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .5);
  }
  .app-shell.nav-open .sidebar { transform: none; }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s;
  }
  .app-shell.nav-open .sidebar-backdrop { opacity: 1; visibility: visible; }

  .burger { display: inline-flex; }
  .search { min-width: 0; width: 44px; padding: 0; justify-content: center; }
  .search input { display: none; }
}
