/* ==========================================================================
   Funky – Dashboard
   Mobile first. Breakpoints: 640px (Tablet), 1024px (Desktop mit Seitenleiste).
   Nur Systemschriften (keine externen Fonts -> kein Datenabfluss an Dritte).
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --bg-elev: #10131a;
  --card: #151922;
  --card-2: #1b202b;
  --border: #252b38;
  --border-strong: #323a4b;
  --text: #e8ebf2;
  --text-2: #a7afc0;
  --text-3: #6d7588;
  --accent: #6d6af7;
  --accent-2: #a46bf5;
  --accent-text: #ffffff;
  --accent-soft: rgba(109, 106, 247, .14);
  --ok: #2fcf7a;
  --ok-soft: rgba(47, 207, 122, .14);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, .14);
  --err: #f0526a;
  --err-soft: rgba(240, 82, 106, .14);
  --track: #2a3040;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .5);
  --radius: 18px;
  --radius-sm: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sidebar-w: 248px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f5f9;
    --bg-elev: #ffffff;
    --card: #ffffff;
    --card-2: #f5f6fa;
    --border: #e4e7ee;
    --border-strong: #d3d8e2;
    --text: #141821;
    --text-2: #4c5468;
    --text-3: #8790a3;
    --accent: #5b57ea;
    --accent-2: #9152e8;
    --accent-soft: rgba(91, 87, 234, .1);
    --ok: #12a05a;
    --ok-soft: rgba(18, 160, 90, .1);
    --warn: #c77a00;
    --warn-soft: rgba(199, 122, 0, .1);
    --err: #d83a52;
    --err-soft: rgba(216, 58, 82, .1);
    --track: #e2e5ec;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
    --shadow-lg: 0 20px 60px rgba(16, 24, 40, .18);
  }
}

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font: 15px/1.5 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: 1.02rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
code { font-family: var(--mono); font-size: .88em; }
svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: .82rem; }
.spacer { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent;
  font: 600 .92rem var(--font); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--card-2); }
.btn.danger, .btn-ghost.danger { color: var(--err); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .84rem; border-radius: 10px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--card-2); color: var(--text); }
.icon-btn:active { transform: scale(.94); }

/* ---------- App-Gerüst ---------- */
.sidebar { display: none; }
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-weight: 750; font-size: 1.12rem; letter-spacing: -.02em; }
.desktop-only { display: none; }

.live {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 99px;
  font-size: .78rem; font-weight: 600; color: var(--text-2); background: var(--card-2); border: 1px solid var(--border);
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.live.ok .live-dot { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2s infinite; }
.live.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.live.err .live-dot { background: var(--err); }

.content {
  flex: 1; width: 100%; max-width: 1180px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px);
}
.view { display: grid; gap: 16px; animation: fadein .2s ease; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-top: 4px; }
.section-head .muted { margin-top: 2px; max-width: 60ch; }

/* Untere Navigation (Handy) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; color: var(--text-3); font: 600 .72rem var(--font); cursor: pointer;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent); }

/* ---------- Karten ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.skeleton { height: 360px; background: linear-gradient(100deg, var(--card) 40%, var(--card-2) 50%, var(--card) 60%) 0 0/200% 100%; animation: shimmer 1.4s infinite; }

/* KPI-Leiste: am Handy eine wischbare Zeile, ab Tablet ein Raster */
.kpis {
  display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  margin: 0 -16px; padding: 2px 16px 4px;
}
.kpis::-webkit-scrollbar { display: none; }
.kpi { padding: 12px 14px; display: grid; gap: 4px; flex: 0 0 auto; min-width: 148px; scroll-snap-align: start; }
.kpi-label { display: flex; align-items: center; gap: 7px; font-size: .78rem; font-weight: 600; color: var(--text-2); }
.kpi-label svg { width: 16px; height: 16px; color: var(--text-3); }
.kpi-value { font-size: 1.3rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.kpi-value small { font-size: .85rem; font-weight: 600; color: var(--text-3); margin-left: 3px; }
.kpi-sub { font-size: .76rem; color: var(--text-3); }

/* ---------- Board-Karte ---------- */
.device-grid { display: grid; gap: 14px; }
.device { padding: 16px; display: grid; gap: 14px; }
.dev-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dev-title { flex: 1; min-width: 0; }
.dev-name {
  display: flex; align-items: center; gap: 8px; font-size: 1.05rem; font-weight: 650;
  background: none; border: 0; padding: 0; color: var(--text); cursor: pointer; max-width: 100%;
}
.dev-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-name svg { width: 14px; height: 14px; color: var(--text-3); opacity: 0; transition: opacity .15s; }
.dev-name:hover svg, .dev-name:focus-visible svg { opacity: 1; }
.dev-sub { font-size: .8rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  font-size: .74rem; font-weight: 650; background: var(--card-2); color: var(--text-2); white-space: nowrap;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.playing { background: var(--ok-soft); color: var(--ok); }
.status-pill.playing::before { animation: pulse 1.6s infinite; box-shadow: 0 0 0 0 currentColor; }
.status-pill.connecting, .status-pill.updating { background: var(--accent-soft); color: var(--accent); }
.status-pill.error { background: var(--warn-soft); color: var(--warn); }
.status-pill.offline { background: var(--err-soft); color: var(--err); }

/* "Läuft gerade" */
.now {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: 16px;
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 60%),
    radial-gradient(120% 140% at 100% 100%, color-mix(in srgb, var(--accent-2) 18%, transparent), transparent 55%),
    var(--card-2);
  border: 1px solid var(--border);
}
.device.offline .now { filter: grayscale(.8); opacity: .75; }
.now-art {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; flex: none;
  background: color-mix(in srgb, var(--accent) 22%, var(--card)); color: var(--accent);
}
.now-art svg { width: 26px; height: 26px; }
.eq { display: none; align-items: flex-end; gap: 3px; height: 22px; }
.eq i { display: block; width: 4px; border-radius: 2px; background: var(--accent); animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; } .eq i:nth-child(3) { animation-delay: -.6s; } .eq i:nth-child(4) { animation-delay: -.15s; }
.device.is-playing .now-art svg { display: none; }
.device.is-playing .eq { display: flex; }
.now-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.now-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.now-title {
  font-size: 1.1rem; font-weight: 700; line-height: 1.25; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere;
}
.now-meta { font-size: .8rem; color: var(--text-2); line-height: 1.35; }
.play-btn {
  display: grid; place-items: center; width: 56px; height: 56px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: transform .1s, background .2s;
}
.play-btn svg { width: 24px; height: 24px; }
.play-btn:active { transform: scale(.92); }
.play-btn.stop { background: var(--text); color: var(--bg); box-shadow: none; }

/* Update-Fortschritt */
.progress { display: grid; gap: 6px; }
.progress-bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s ease; }
.progress-text { display: flex; justify-content: space-between; font-size: .8rem; color: var(--text-2); }

/* Bedienung */
.controls { display: grid; gap: 12px; }
.select { position: relative; display: block; }
.select select {
  width: 100%; appearance: none; -webkit-appearance: none;
  min-height: 46px; padding: 0 40px 0 14px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--card-2); color: var(--text);
  font: 500 16px var(--font); cursor: pointer;
}
.select::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); pointer-events: none;
}
.volume { display: flex; align-items: center; gap: 6px; }
.volume .icon-btn { width: 40px; height: 40px; border: 1px solid var(--border); background: var(--card-2); }
.volume-val { min-width: 2.2ch; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); }
.range { flex: 1; height: 40px; display: flex; align-items: center; }
input[type=range] {
  --fill: 50%;
  width: 100%; height: 6px; margin: 0; appearance: none; -webkit-appearance: none; border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--track) var(--fill)); cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.35), 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}
input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.35), 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Kacheln */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tile { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--card-2); min-width: 0; }
.tile-label { display: flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 600; color: var(--text-3); }
.tile-label svg { width: 14px; height: 14px; }
.tile-value { margin-top: 3px; font-size: .95rem; font-weight: 650; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value small { font-weight: 500; color: var(--text-3); }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.bars i { display: block; width: 4px; border-radius: 1px; background: var(--track); }
.bars i:nth-child(1) { height: 25%; } .bars i:nth-child(2) { height: 50%; } .bars i:nth-child(3) { height: 75%; } .bars i:nth-child(4) { height: 100%; }
.bars i.on { background: var(--ok); }
.batt { position: relative; display: inline-block; margin-right: 4px; width: 24px; height: 12px; border: 1.5px solid var(--text-3); border-radius: 3px; }
.batt::after { content: ""; position: absolute; right: -4px; top: 3px; width: 2px; height: 4px; border-radius: 0 1px 1px 0; background: var(--text-3); }
.batt i { position: absolute; left: 1px; top: 1px; bottom: 1px; border-radius: 1px; background: var(--ok); }
.batt.low i { background: var(--err); } .batt.mid i { background: var(--warn); }

/* Hinweiszeile */
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); font-size: .84rem; }
.callout svg { width: 18px; height: 18px; margin-top: 1px; }
.callout.info { background: var(--accent-soft); color: var(--text); }
.callout.info svg { color: var(--accent); }
.callout.warn { background: var(--warn-soft); color: var(--text); }
.callout.warn svg { color: var(--warn); }

/* Details */
.details { border-top: 1px solid var(--border); padding-top: 4px; }
.details summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 40px; font-size: .86rem; font-weight: 600; color: var(--text-2); cursor: pointer;
}
.details summary::-webkit-details-marker { display: none; }
.details summary svg { width: 18px; height: 18px; transition: transform .2s; }
.details[open] summary svg { transform: rotate(180deg); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 4px 0 6px; font-size: .86rem; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.fw-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Senderliste ---------- */
.station-list { display: grid; gap: 10px; }
.station { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; }
.station.disabled { opacity: .55; }
.avatar {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; flex: none;
  font-weight: 750; font-size: .95rem; color: #fff;
}
.station-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.station-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.station-meta { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--text-3); min-width: 0; }
.station-meta .host { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { padding: 2px 8px; border-radius: 99px; background: var(--card-2); border: 1px solid var(--border); font-size: .72rem; font-weight: 650; color: var(--text-2); white-space: nowrap; }
.chip.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-soft); }
.station .icon-btn.active { color: var(--accent); background: var(--accent-soft); }

/* ---------- System ---------- */
.system-grid { display: grid; gap: 14px; }
.sys-card { padding: 16px; display: grid; gap: 12px; }
.sys-card h3 { display: flex; align-items: center; gap: 10px; }
.sys-card h3 svg { color: var(--accent); }

/* ---------- Leerer Zustand ---------- */
.empty { padding: 32px 20px; text-align: center; display: grid; gap: 10px; justify-items: center; color: var(--text-2); }
.empty svg { width: 36px; height: 36px; color: var(--text-3); }

/* ---------- Formulare ---------- */
.field { display: grid; gap: 6px; font-size: .8rem; font-weight: 600; color: var(--text-2); }
.field input {
  min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--card-2); color: var(--text); font: 16px var(--font); width: 100%;
}
.field input:focus, .select select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--err); font-size: .85rem; min-height: 1.2em; }
.switch { display: flex; align-items: center; gap: 12px; font-size: .9rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { position: relative; width: 44px; height: 26px; border-radius: 99px; background: var(--track); transition: background .2s; flex: none; }
.switch-ui::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + .switch-ui { background: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Dialoge: Handy = Bottom-Sheet, Desktop = zentriert ---------- */
dialog.sheet {
  width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; padding: 8px 18px calc(18px + var(--safe-b));
  border: 1px solid var(--border); border-bottom: 0; border-radius: 22px 22px 0 0;
  background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-lg);
  overflow-y: auto;
}
dialog.sheet[open] { animation: sheet-up .25s cubic-bezier(.2, .9, .3, 1); }
dialog.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 99px; background: var(--border-strong); margin: 4px auto 10px; }
dialog:focus { outline: none; }
dialog::backdrop { background: rgba(5, 7, 12, .55); backdrop-filter: blur(2px); }
dialog form, dialog.sheet { display: grid; gap: 14px; }
dialog.sheet:not([open]) { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.head-actions { display: flex; gap: 4px; }
.sheet-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.action-list { display: grid; gap: 4px; }
.action {
  display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 12px; border-radius: 12px;
  border: 0; background: none; color: var(--text); font: 550 .95rem var(--font); text-align: left; cursor: pointer;
}
.action:hover { background: var(--card-2); }
.action svg { color: var(--text-2); }
.action.danger, .action.danger svg { color: var(--err); }
.action small { display: block; font-weight: 400; font-size: .78rem; color: var(--text-3); }
.keybox { display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: var(--card-2); word-break: break-all; }
.keybox div { display: grid; gap: 2px; }
.logbox {
  max-height: 60dvh; overflow: auto; padding: 12px; border-radius: 12px; background: var(--bg);
  border: 1px solid var(--border); font: 12px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word;
}
.logbox .t { color: var(--text-3); }
.logbox .l-err { color: var(--err); } .logbox .l-ok { color: var(--ok); } .logbox .l-ota { color: var(--accent); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 50;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: .88rem; font-weight: 550; box-shadow: var(--shadow-lg);
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--err); color: #fff; }
#toast.ok { background: var(--ok); color: #fff; }
#toast.warn { background: var(--warn); color: #fff; }

/* ---------- Login / Einrichtung ---------- */
.auth {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(60% 50% at 20% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent),
    radial-gradient(50% 40% at 100% 100%, color-mix(in srgb, var(--accent-2) 16%, transparent), transparent),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; padding: 28px 24px; display: grid; gap: 18px; }
.auth-card .brand { justify-content: center; }
.auth-card .brand-mark { width: 44px; height: 44px; border-radius: 13px; }
.auth-card .brand-mark svg { width: 26px; height: 26px; }
.auth-card .brand-name { font-size: 1.5rem; }
.auth-card form { display: grid; gap: 14px; }
.auth-card .btn { width: 100%; min-height: 48px; }
.auth-sub { text-align: center; color: var(--text-2); font-size: .9rem; margin-top: -8px; }
.log, .setup-log { margin: 0; padding: 12px 14px 12px 30px; border-radius: 12px; background: var(--card-2); color: var(--text-2); font-size: .84rem; }
.ok-text { color: var(--ok); font-weight: 600; }

/* ---------- Animationen ---------- */
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   Tablet
   ========================================================================== */
@media (min-width: 640px) {
  .content { padding: 24px 24px calc(var(--tabbar-h) + var(--safe-b) + 28px); }
  .kpis { display: grid; grid-template-columns: repeat(4, 1fr); overflow: visible; margin: 0; padding: 0; }
  .kpi { min-width: 0; padding: 14px; }
  .device-grid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .station-list { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
  .system-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  dialog.sheet {
    width: min(520px, calc(100vw - 48px)); margin: auto; border-radius: 20px; border-bottom: 1px solid var(--border);
    padding: 22px 24px; max-height: 86vh;
  }
  dialog.sheet.wide { width: min(920px, calc(100vw - 48px)); }
  dialog.sheet::before { display: none; }
  dialog.sheet[open] { animation: fadein .18s ease; }
}

/* ==========================================================================
   Desktop: Seitenleiste statt unterer Navigation
   ========================================================================== */
@media (min-width: 1024px) {
  .tabbar, .mobile-only { display: none; }
  .desktop-only { display: block; }
  #view-boards > .section-head h2, #view-system > .section-head h2 { visibility: hidden; }   /* steht schon in der Kopfzeile */
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 25;
    display: flex; flex-direction: column; gap: 24px; padding: 22px 14px;
    background: var(--bg-elev); border-right: 1px solid var(--border);
  }
  .sidebar .brand { padding: 0 8px; }
  .nav { display: grid; gap: 4px; }
  .nav-item {
    display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 11px;
    border: 0; background: none; color: var(--text-2); font: 600 .92rem var(--font); text-align: left; cursor: pointer;
  }
  .nav-item:hover { background: var(--card-2); color: var(--text); }
  .nav-item.active { background: var(--accent-soft); color: var(--accent); }
  .nav-item.subtle { color: var(--text-3); }
  .sidebar-foot { margin-top: auto; display: grid; gap: 6px; border-top: 1px solid var(--border); padding-top: 14px; }
  .who { display: flex; align-items: center; gap: 10px; padding: 0 12px; color: var(--text-2); font-size: .88rem; font-weight: 600; }
  .who svg { color: var(--text-3); }
  .shell { margin-left: var(--sidebar-w); }
  .topbar { padding: 18px 32px; }
  .content { padding: 28px 32px 48px; }
  #toast { bottom: 28px; }
}
