:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel2: #273449;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent2: #0ea5e9;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
  flex-wrap: wrap;
}
.brand { font-size: 20px; letter-spacing: .3px; }
.brand strong { color: var(--accent); }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: var(--muted); padding: 6px 14px; border-radius: 8px; font-weight: 500;
}
.topbar nav a:hover { color: var(--text); background: var(--panel2); }
.topbar nav a.active { color: #fff; background: var(--panel2); }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.wrap { flex: 1; width: 100%; max-width: 1800px; margin: 0 auto; padding: 36px 32px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }
h1 { font-size: 32px; margin-bottom: 8px; }
h2 { font-size: 22px; margin: 26px 0 12px; }
.sub { color: var(--muted); margin-bottom: 22px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 18px 0 26px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px;
}
.card .big { font-size: 34px; font-weight: 700; }
.card .lbl { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 16px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--panel2); color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.badge-on { background: rgba(52, 211, 153, .15); color: var(--ok); }
.badge-off { background: rgba(248, 113, 113, .15); color: var(--err); }
.badge-new { background: rgba(251, 191, 36, .15); color: var(--warn); }
.btn {
  display: inline-block; background: var(--accent2); color: #fff; border: none; cursor: pointer;
  padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
}
.btn:hover { filter: brightness(1.1); }
.btn-sm { padding: 6px 14px; font-size: 14px; }
.btn-ghost { background: var(--panel2); color: var(--text); }
.btn-danger { background: #b91c1c; }
form.inline { display: inline; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=url], select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 14px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent2); border-color: transparent; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.flash-ok { background: rgba(52, 211, 153, .12); color: var(--ok); border: 1px solid rgba(52,211,153,.35); }
.flash-err { background: rgba(248, 113, 113, .12); color: var(--err); border: 1px solid rgba(248,113,113,.35); }
.flash-warn { background: rgba(251, 191, 36, .12); color: var(--warn); border: 1px solid rgba(251,191,36,.35); }
img { max-width: 100%; height: auto; }
.shot { width: 260px; max-width: 260px; height: 146px; object-fit: cover; border-radius: 8px; background: #000; display: block; border: 1px solid var(--line); }
.shot-wrap { position: relative; display: inline-block; }
.shot-age { position: absolute; right: 4px; bottom: 4px; background: rgba(15,23,42,.85); color: var(--muted); font-size: 10px; padding: 1px 6px; border-radius: 999px; }
.shot-empty { width: 260px; height: 146px; border-radius: 8px; border: 1px dashed var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; text-align: center; }
/* Tabellen duerfen nie breiter werden als der Bildschirm */
.wrap { overflow-x: hidden; }
table { table-layout: auto; }
.tablewrap { overflow-x: auto; }

/* --- Mini-Balken fuer Speicher / Signal / Sync --- */
.meter { width: 54px; height: 6px; background: var(--panel2); border-radius: 999px; overflow: hidden; margin-top: 3px; }
.meter-fill { height: 100%; border-radius: 999px; }
.cell-sub { color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.cell-main { font-size: 16px; }
td.tight, th.tight { padding: 13px 14px; }
.badge-sync { background: rgba(56,189,248,.15); color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot-on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot-off { background: var(--err); }

/* --- Allgemeines Dialogfenster (z. B. WLAN einrichten) --- */
.modal {
  position: fixed; inset: 0; z-index: 9998; display: none;
  background: rgba(2, 6, 16, .82); backdrop-filter: blur(3px);
  align-items: center; justify-content: center; padding: 4vh 4vw;
}
.modal.show { display: flex; }
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  width: 100%; max-width: 460px; max-height: 92vh; overflow: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-body { padding: 18px; }

/* --- Vorschau-Fenster (Mini-Player) --- */
.lb-open { cursor: zoom-in; }
.lb-open.btn { cursor: pointer; }
#lb {
  position: fixed; inset: 0; z-index: 9999; display: none;
  background: rgba(2, 6, 16, .88); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 4vh 4vw;
}
#lb.show { display: flex; }
#lb-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  max-width: 1100px; width: 100%; max-height: 92vh; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
#lb-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); flex: none;
}
#lb-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lb-close {
  background: var(--panel2); color: var(--text); border: none; border-radius: 8px;
  width: 32px; height: 32px; font-size: 18px; line-height: 1; cursor: pointer; flex: none;
}
#lb-close:hover { background: #3b4a63; }
#lb-body {
  background: #000; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
#lb-body img, #lb-body video {
  display: block; width: 100%; height: auto;
  max-height: calc(92vh - 110px); object-fit: contain;
}
#lb-body iframe { width: 100%; height: calc(92vh - 110px); border: 0; background: #fff; }
#lb-foot { padding: 8px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; flex: none; }
.login-box { max-width: 380px; margin: 8vh auto; }
.thumb { width: 120px; height: 68px; object-fit: cover; border-radius: 6px; background: #000; display: block; }
.muted { color: var(--muted); font-size: 15px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.paircode { font-family: ui-monospace, Consolas, monospace; font-size: 20px; letter-spacing: 3px; color: var(--warn); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mt { margin-top: 16px; }
.help { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ======================= Seiten-Navigation (Sidebar) ======================= */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 220px; z-index: 50;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.side-brand { padding: 14px 8px 20px; text-align: center; }
.brand-logo { display: block; width: 100%; max-width: 168px; margin: 0 auto; }
.brand-tag { color: var(--muted); font-size: 11px; letter-spacing: 3.5px;
  text-transform: uppercase; margin: 10px 0 0; text-align: center; }
.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; color: var(--muted);
  padding: 11px 12px; border-radius: 10px; font-weight: 500; font-size: 15px;
  border-left: 3px solid transparent;
}
.side-nav a svg { width: 20px; height: 20px; flex: none; opacity: .85; }
.side-nav a:hover { color: var(--text); background: var(--panel2); }
.side-nav a.active {
  color: #fff; background: var(--panel2);
  border-left-color: var(--accent); font-weight: 600;
}
.side-nav a.active svg { opacity: 1; color: var(--accent); }
.side-foot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; }
.side-user { color: var(--muted); font-size: 13px; margin-bottom: 8px; word-break: break-all; }
.side-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-row .lang a { color: var(--muted); font-size: 13px; padding: 0 3px; opacity: .6; }
.side-row .lang a.on { opacity: 1; font-weight: 700; color: var(--text); }
/* Inhalt neben die Sidebar schieben */
body.has-side .wrap { margin-left: 220px; max-width: 1500px; }
.login-lang { position: fixed; top: 18px; right: 24px; z-index: 50; }
.login-lang a { color: var(--muted); font-size: 14px; padding: 0 4px; opacity: .6; }
.login-lang a.on { opacity: 1; font-weight: 700; color: var(--text); }
@media (max-width: 820px) {
  .sidebar { position: static; width: auto; flex-direction: row; align-items: center;
    border-right: none; border-bottom: 1px solid var(--line); padding: 8px 12px; gap: 10px; }
  .side-brand { padding: 0 8px 0 0; font-size: 17px; }
  .side-nav { flex-direction: row; overflow-x: auto; gap: 2px; }
  .side-nav a { padding: 8px 10px; border-left: none; border-bottom: 3px solid transparent; }
  .side-nav a span { display: none; }
  .side-nav a.active { border-left: none; border-bottom-color: var(--accent); }
  .side-foot { border-top: none; padding-top: 0; margin-top: 0; }
  .side-user { display: none; }
  body.has-side .wrap { margin-left: 0; }
}

/* ======================= Leere Zustaende (Empty State) ======================= */
.empty {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 48px 24px; text-align: center; margin: 8px 0 24px;
}
.empty-ic {
  width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 20px;
  background: radial-gradient(circle at 50% 40%, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 42px;
}
.empty h2 { font-size: 22px; margin: 0 0 6px; }
.empty p { color: var(--muted); margin: 0 auto 20px; max-width: 460px; }
.empty .btn { font-size: 15px; padding: 10px 22px; }
.btn-grad {
  background: linear-gradient(135deg, #7c3aed, var(--accent2)); color: #fff;
}
.btn-grad:hover { filter: brightness(1.08); }

/* ======================= Modal "Neuer Inhalt" ======================= */
.modal-box.modal-wide { max-width: 620px; }
.tabbar { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabbar button {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 9px 14px; font-size: 14px; font-weight: 600; border-bottom: 2px solid transparent;
}
.tabbar button:hover { color: var(--text); }
.tabbar button.on { color: var(--text); border-bottom-color: var(--accent); }
.dropzone {
  border: 2px dashed var(--line); border-radius: 12px; padding: 28px 16px;
  text-align: center; background: var(--bg); transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--accent); background: rgba(56,189,248,.06); }
.dropzone > div { margin: 4px 0; }
.progress {
  position: relative; height: 22px; margin-top: 14px; border-radius: 999px;
  background: var(--panel2); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, #7c3aed, var(--accent2)); transition: width .2s;
}
.progress span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff;
}
