:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel2: #273449;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent2: #0ea5e9;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
}
:root[data-theme="light"]{
  --bg:#eef2f7; --panel:#ffffff; --panel2:#eef3f9; --line:#d8e1ec;
  --text:#0f172a; --muted:#586576; --ok:#0f7d54; --warn:#b45309; --err:#c62f2f;
}
.foot-in{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap;max-width:1100px;margin:0 auto;width:100%}
.foot-logo-img{height:38px;width:auto;filter:brightness(0) invert(.82);opacity:.92}
:root[data-theme="light"] .foot-logo-img{filter:none;opacity:1}
.foot-sig{text-align:right;line-height:1.3}
.foot-sig .b{font-weight:700;color:var(--text);font-size:15px}
.foot-sig .c{color:var(--muted);font-size:12.5px}
* { 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-flex; align-items: center; gap: 8px; background: var(--accent2); color: #fff; border: none; cursor: pointer;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
  box-shadow: 0 1px 2px rgba(2,8,23,.30);
  transition: background .15s ease, transform .12s ease, box-shadow .2s ease, border-color .15s ease;
}
.btn:hover { background: var(--accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(2,8,23,.35); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-sm { padding: 7px 14px; font-size: 14px; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn-ghost:hover { background: var(--panel2); border-color: var(--accent); }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #ef4444; }
form.inline { display: inline; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=url],
input[type=search], input[type=tel], select, textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 14px; width: 100%;
}
/* Textarea: dieselbe dunkle Optik wie Inputs + grosszuegige, ziehbare Hoehe.
   (Vorher fehlte textarea im Selektor -> weisser Browser-Default, wirkte fremd.) */
textarea {
  min-height: 130px; line-height: 1.55; resize: vertical;
  font-family: inherit; padding: 10px 12px;
}
input:focus, select:focus, textarea: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;
  overflow-y: auto;   /* Fallback: ganze Sidebar scrollt, wenn selbst das nicht reicht */
}
.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; }
/* min-height:0 erlaubt dem Flex-Kind zu schrumpfen und zu scrollen, statt die
   Sidebar (und damit Logout/Sprache) unten aus dem Bild zu schieben. */
.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 0; overflow-y: auto; }
.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.
   WICHTIG: .wrap hat width:100% (=100vw). Zusammen mit margin-left:220px ragt
   der Inhalt sonst um 220px ueber den rechten Rand hinaus (rechte Spalte wird
   abgeschnitten – sichtbar bei 100% Zoom). Darum die Breite um die Sidebar
   kappen. min(): auf Ultrawide bei 2200px gedeckelt, sonst genau der Platz
   neben der Sidebar. */
body.has-side .wrap { margin-left: 220px; max-width: min(2200px, calc(100% - 220px)); }
.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); }
/* Hamburger-Knopf: am Desktop unsichtbar, am Handy rechts oben. */
.burger { display: none; background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; width: 42px; height: 42px; font-size: 22px; line-height: 1; cursor: pointer; flex: none; }

/* ======================= Handy / schmale Bildschirme =======================
   Die Seitenleiste wird zur Kopfzeile (Logo + Hamburger); Bereich-Auswahl,
   Navigation und Fusszeile klappen darunter auf. Der Inhalt bekommt die volle
   Breite - WICHTIG: das Desktop-Pattern "calc(100% - 220px)" muss hier
   ausdruecklich aufgehoben werden, sonst bleiben 155 px fuer die Seite. */
@media (max-width: 820px) {
  body { font-size: 16px; }
  .sidebar { position: sticky; top: 0; bottom: auto; width: auto; z-index: 60;
    flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between;
    border-right: none; border-bottom: 1px solid var(--line); padding: 8px 12px; gap: 8px; overflow: visible; }
  .side-brand { padding: 0; display: flex; align-items: center; gap: 10px; text-align: left; }
  .brand-logo { max-width: 104px; margin: 0; }
  .brand-tag { display: none; }
  .burger { display: inline-flex; align-items: center; justify-content: center; }
  .side-ws, .side-nav, .side-foot { display: none; width: 100%; }
  body.nav-open .side-ws { display: block; padding: 6px 0 4px; }
  body.nav-open .side-nav { display: flex; flex-direction: column; gap: 2px; overflow: visible; }
  body.nav-open .side-foot { display: block; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; }
  .side-nav a { padding: 11px 10px; font-size: 16px; }
  .side-user { display: block; }
  body.has-side .wrap { margin-left: 0; max-width: 100%; padding: 16px 12px 28px; }
  .wrap { padding: 16px 12px 28px; }
  h1 { font-size: 24px; }
  h2 { font-size: 18px; margin: 18px 0 10px; }
  .sub { margin-bottom: 14px; }
  .panel { padding: 14px; }
  .card { padding: 14px; }
  .card .big { font-size: 26px; }
  th, td { padding: 10px 10px; }
  th { font-size: 12px; }
  /* Tabellen bleiben Tabellen (Spalten buendig); breite Tabellen wischt man
     seitlich innerhalb ihres Panels, die Seite selbst scrollt nie horizontal. */
  .panel, .tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td { white-space: normal; }
  td .btn, th .btn { white-space: nowrap; }
  /* Listen mit vielen Spalten (z. B. Team): am Handy jede Zeile als Karte
     untereinander statt 800 px breit zum Wischen. */
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.stack tr:last-child { border-bottom: none; }
  table.stack td { border: none; padding: 3px 10px; }
  table.stack td:first-child { padding-top: 6px; }
  /* Inline-Raster der Seiten (Kacheln, Formularzeilen) auf eine Spalte */
  .wrap [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  /* Flex-Zeilen mit fester Mindestbreite umbrechen lassen */
  .wrap [style*="min-width:220px"], .wrap [style*="min-width: 220px"] { min-width: 0 !important; }
  .btn { padding: 9px 14px; }
  input[type=text], input[type=password], input[type=email], input[type=number], input[type=url],
  input[type=search], input[type=tel], select, textarea { font-size: 16px; } /* iOS zoomt sonst rein */
  .shot, .shot-empty { width: 100%; max-width: 100%; height: auto; aspect-ratio: 16/9; }
  .modal { padding: 2vh 2vw; }
  .login-lang { top: 10px; right: 12px; }
}

/* ======================= 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 { background: linear-gradient(135deg, #8b4ef0, var(--accent)); transform: translateY(-1px); }

/* ======================= 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;
}

:root[data-theme="light"] img[src*="rinova-white"]{filter:invert(1)}
