/* Anlagen Status - Web-App (Design angelehnt an Apple: iOS/macOS-Farben, Segmented Controls, Schalter, Glas-Leisten) */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --bg: #f2f2f7; --card: #ffffff; --card-2: #f2f2f7; --line: rgba(60, 60, 67, .16); --text: #1c1c1e; --muted: #6c6c70;
  --accent: #007aff; --accent-text: #ffffff; --accent-soft: rgba(0, 122, 255, .12);
  --danger: #ff3b30; --danger-soft: rgba(255, 59, 48, .12);
  --fill: rgba(120, 120, 128, .12); --fill-hover: rgba(120, 120, 128, .2); --track: rgba(120, 120, 128, .16); --track-strong: rgba(120, 120, 128, .32);
  --input: rgba(118, 118, 128, .12); --viewer: #e5e5ea; --seg-on: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 14px rgba(0, 0, 0, .05);
  --bar-text: #1c1c1e; --bar-shadow: none;
  --glass: rgba(249, 249, 251, .78); --glass-side: rgba(255, 255, 255, .72);
  --c-red: #ff3b30; --c-orange: #ff9500; --c-green: #34c759; --c-gray: #aeaeb2;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #000000; --card: #1c1c1e; --card-2: #2c2c2e; --line: rgba(84, 84, 88, .6); --text: #f5f5f7; --muted: #98989f;
  --accent: #0a84ff; --accent-soft: rgba(10, 132, 255, .22);
  --danger: #ff453a; --danger-soft: rgba(255, 69, 58, .22);
  --fill: rgba(120, 120, 128, .24); --fill-hover: rgba(120, 120, 128, .36); --track: rgba(120, 120, 128, .32); --track-strong: rgba(120, 120, 128, .5);
  --input: rgba(118, 118, 128, .24); --viewer: #101012; --seg-on: #636366; --shadow: none;
  --bar-text: #ffffff; --bar-shadow: 0 0 3px rgba(0, 0, 0, .65);
  --glass: rgba(28, 28, 30, .72); --glass-side: rgba(28, 28, 30, .7);
  --c-red: #ff453a; --c-orange: #ff9f0a; --c-green: #30d158; --c-gray: #636366;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --card: #1c1c1e; --card-2: #2c2c2e; --line: rgba(84, 84, 88, .6); --text: #f5f5f7; --muted: #98989f;
    --accent: #0a84ff; --accent-soft: rgba(10, 132, 255, .22);
    --danger: #ff453a; --danger-soft: rgba(255, 69, 58, .22);
    --fill: rgba(120, 120, 128, .24); --fill-hover: rgba(120, 120, 128, .36); --track: rgba(120, 120, 128, .32); --track-strong: rgba(120, 120, 128, .5);
    --input: rgba(118, 118, 128, .24); --viewer: #101012; --seg-on: #636366; --shadow: none;
    --bar-text: #ffffff; --bar-shadow: 0 0 3px rgba(0, 0, 0, .65);
    --glass: rgba(28, 28, 30, .72); --glass-side: rgba(28, 28, 30, .7);
    --c-red: #ff453a; --c-orange: #ff9f0a; --c-green: #30d158; --c-gray: #636366;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 var(--font); background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased; letter-spacing: -.003em;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 17px; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Bedienelemente ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 16px;
  border: 0; border-radius: 10px; background: var(--fill); color: var(--accent); font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .12s, opacity .12s, transform .06s;
}
.btn:hover:not(:disabled) { background: var(--fill-hover); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger); background: var(--danger-soft); }
.btn.danger:hover:not(:disabled) { filter: brightness(.96); }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--accent-soft); }
.btn.ghost.danger { background: transparent; }
.btn.ghost.danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn.sm { min-height: 30px; padding: 3px 12px; font-size: 13.5px; border-radius: 8px; }
.btn.on { background: var(--accent); color: var(--accent-text); }
.btn.block { display: flex; width: 100%; }
.btn.icon { min-width: 36px; padding: 6px 9px; font-size: 17px; line-height: 1; }

input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 36px; padding: 6px 12px; border: 0; border-radius: 10px; background: var(--input); color: var(--text);
}
textarea { resize: vertical; min-height: 84px; }
select { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center; }
select:disabled { opacity: .6; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .tab:focus-visible {
  outline: 3px solid var(--accent-soft); outline-offset: 0; box-shadow: 0 0 0 1.5px var(--accent);
}
input:disabled, textarea:disabled { opacity: .55; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 4px 2px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }

/* Schalter wie bei iOS */
input[type=checkbox] {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 44px; height: 26px; margin: 0;
  border-radius: 13px; background: var(--track-strong); cursor: pointer; transition: background .2s;
}
input[type=checkbox]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .3); transition: transform .2s;
}
input[type=checkbox]:checked { background: var(--c-green); }
input[type=checkbox]:checked::after { transform: translateX(18px); }
input[type=checkbox]:disabled { opacity: .5; cursor: not-allowed; }

/* Regler wie bei iOS */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; cursor: pointer; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: var(--track-strong); }
input[type=range]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--track-strong); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 27px; height: 27px; margin-top: -11px; border-radius: 50%; background: #fff; border: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35), 0 0 0 .5px rgba(0, 0, 0, .1);
}
input[type=range]::-moz-range-thumb { width: 27px; height: 27px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
input[type=range]:disabled { opacity: .5; cursor: not-allowed; }

.card { background: var(--card); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.card > h2 { margin-bottom: 12px; }

.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.pill.read { background: var(--fill); color: var(--muted); }
.pill.admin { background: rgba(255, 149, 0, .18); color: #c93400; }
:root[data-theme="dark"] .pill.admin { color: #ffb340; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.admin { color: #ffb340; } }
.pill.off { background: var(--danger-soft); color: var(--danger); }

/* Segmented Control (Umschalter) */
.tabs { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--track); gap: 2px; }
.tab { border: 0; background: transparent; padding: 5px 14px; border-radius: 7px; cursor: pointer; white-space: nowrap; font-weight: 500; color: var(--text); }
.tab:hover:not(.on) { background: var(--fill); }
.tab.on { background: var(--seg-on); box-shadow: 0 1px 3px rgba(0, 0, 0, .18), 0 0 0 .5px rgba(0, 0, 0, .04); font-weight: 600; }

/* ---------- Fortschrittsbalken ---------- */
.pb { position: relative; height: 18px; border-radius: 6px; background: var(--track); overflow: hidden; min-width: 40px; }
.pb-fill { position: absolute; inset: 0 auto 0 0; border-radius: 6px; transition: width .2s; }
.pb-txt { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--bar-text); text-shadow: var(--bar-shadow); }
.pb.lg { height: 22px; border-radius: 7px; }
.pb.lg .pb-fill { border-radius: 7px; }
.pb.lg .pb-txt { font-size: 12px; }
.alert-dot {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--c-red); color: #fff; font-weight: 700; font-size: 12px; flex: none;
}

/* ---------- Seitengerüst ---------- */
.app { display: grid; grid-template-rows: auto 1fr; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border-bottom: .5px solid var(--line); z-index: 30; position: relative;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand img { width: 26px; height: 26px; border-radius: 7px; }
.topbar select { width: auto; max-width: 240px; }
.menu-btn { display: none; }
.body { display: grid; grid-template-columns: 270px 1fr; min-height: 0; }
.sidebar {
  background: var(--glass-side); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border-right: .5px solid var(--line); padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 6px;
}
.sidebar h3 { font-size: 11px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.nav-item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 10px;
  background: transparent; cursor: pointer; color: var(--text);
}
.nav-item:hover { background: var(--fill); }
.nav-item.active { background: var(--accent-soft); }
.nav-item.active > .nm { color: var(--accent); }
.nav-item .nm { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: 4px; }
.nav-item .nm span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .mini { display: grid; grid-template-columns: 14px 1fr; gap: 6px; align-items: center; margin-top: 3px; font-size: 11px; color: var(--muted); font-weight: 600; }
.nav-item .mini .pb { height: 13px; }
.nav-item .mini .pb-txt { font-size: 10px; }
.view { overflow: auto; padding: 18px; min-width: 0; }
.view.fill { overflow: hidden; display: flex; flex-direction: column; }
.backdrop { display: none; }

.usermenu { position: relative; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; background: var(--card); border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .28), 0 0 0 .5px var(--line); padding: 8px; z-index: 40;
}
.dropdown .btn { display: flex; width: 100%; justify-content: flex-start; }
.dropdown hr { border: 0; border-top: .5px solid var(--line); margin: 6px 0; }
.dropdown .tabs { display: flex; }
.dropdown .tabs .tab { flex: 1; text-align: center; padding: 5px 4px; }

/* ---------- Anmeldung ---------- */
.center-screen { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); padding: 30px; }
.login-card h1 { font-size: 26px; margin-bottom: 4px; letter-spacing: -.02em; }
.login-theme { position: fixed; right: 16px; top: 14px; }
.error { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 10px; margin-bottom: 12px; }

/* ---------- Dashboard ---------- */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 26px; letter-spacing: -.02em; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.filters label.field { margin: 0; min-width: 150px; }
.filters .search { min-width: 220px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi .v { font-size: 30px; font-weight: 600; line-height: 1.2; letter-spacing: -.02em; }
.kpi.alert .v { color: var(--danger); }
.two { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 12px; margin-bottom: 14px; }
.three { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 14px; }
.dual { display: grid; grid-template-columns: 96px 1fr; gap: 6px; align-items: center; margin-bottom: 4px; font-size: 12.5px; color: var(--muted); }
.cat-row { display: grid; grid-template-columns: 165px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.anl-card { border-radius: 12px; padding: 12px; cursor: pointer; background: var(--card-2); transition: transform .08s, background .12s; }
.anl-card:hover { background: var(--accent-soft); }
.anl-card:active { transform: scale(.99); }
.anl-card b { display: block; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow: auto; border-radius: 12px; box-shadow: 0 0 0 .5px var(--line); }
table.grid { width: 100%; border-collapse: collapse; min-width: 980px; }
table.grid th, table.grid td { padding: 8px 10px; text-align: left; border-bottom: .5px solid var(--line); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid th {
  position: sticky; top: 0; background: var(--card); font-size: 11.5px; color: var(--muted); cursor: pointer; user-select: none;
  white-space: nowrap; z-index: 1; text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
}
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: var(--accent-soft); }
table.grid td.bar { min-width: 96px; }
table.grid td:nth-child(-n+2) { white-space: nowrap; }
table.users { min-width: 0; }
table.users tbody tr { cursor: default; }
table.users tbody tr:hover { background: transparent; }
.problem-cell { display: flex; align-items: center; gap: 6px; color: var(--danger); max-width: 240px; }
.problem-cell span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Kuchendiagramme */
.pie-section { margin-bottom: 14px; }
.pie-section > h2 { margin: 6px 2px 10px; }
.pie-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.pie-grid.big { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.pie-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.pie-card h3 { font-size: 14px; }
.pie-card svg { display: block; overflow: visible; }
.pie-card svg path, .pie-card svg circle { transition: opacity .12s; }
.pie-card svg:hover path { opacity: .85; }
.pie-card .ctr { fill: var(--text); font-weight: 600; letter-spacing: -.02em; }
.pie-card .sub { fill: var(--muted); }
.legend { width: 100%; display: grid; gap: 4px; font-size: 13px; text-align: left; }
.legend div { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.legend b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Übersicht (Tabelle aller Anlagen, nur Ansicht mit Fortschrittsbalken) */
table.erf { min-width: 760px; }
table.erf th { cursor: default; }
table.erf td:first-child, table.erf th:first-child { position: sticky; left: 0; background: var(--card); z-index: 2; white-space: nowrap; }
table.erf td.bar { min-width: 120px; }
table.erf tr.group { cursor: default; }
table.erf tr.group:hover { background: transparent; }
table.erf tr.group td { background: var(--card-2); font-weight: 600; position: static; }
.erf-link { cursor: pointer; color: var(--accent); background: none; border: 0; padding: 0; font-weight: 600; text-align: left; }
.erf-link:hover { text-decoration: underline; }

/* ---------- Layout-Ansicht ---------- */
.viewer { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; }
.viewer-main { display: grid; grid-template-columns: 1fr 330px; gap: 12px; flex: 1; min-height: 0; }
.viewport {
  position: relative; overflow: hidden; background: var(--viewer); border-radius: 14px; box-shadow: 0 0 0 .5px var(--line);
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; min-height: 260px;
}
.viewport.draw { cursor: crosshair; }
.viewport.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; box-shadow: 0 2px 16px rgba(0, 0, 0, .3); }
.world > canvas, .world > img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.overlay { position: absolute; inset: 0; }
.viewport-hint { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 30px; color: var(--muted); pointer-events: none; font-size: 15px; white-space: pre-line; }
.viewport-help { position: absolute; left: 12px; bottom: 8px; pointer-events: none; font-size: 12px; color: var(--muted); }
.side { overflow: auto; }
.side .card { height: 100%; }

.frame {
  position: absolute; border: calc(2.5px / var(--z, 1)) solid; border-radius: calc(6px / var(--z, 1)); cursor: pointer;
  touch-action: none;
}
.frame.sel { border-color: #0a60d8 !important; border-width: calc(3.5px / var(--z, 1)); z-index: 10; }
.frame-inner {
  position: absolute; left: 50%; top: 50%; width: 230px; height: 176px; padding: 8px; border-radius: 6px;
  background: rgba(255, 255, 255, .92); color: #1c1c1e; transform-origin: center; pointer-events: none;
}
.f-title { display: flex; justify-content: space-between; gap: 6px; font-weight: 700; font-size: 15px; height: 24px; line-height: 24px; }
.f-title .f-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-row { display: grid; grid-template-columns: 100px 1fr; align-items: center; height: 20px; font-size: 12px; }
.f-row .pb { height: 16px; background: rgba(120, 120, 128, .2); }
.f-row .pb-txt { color: #1c1c1e; text-shadow: none; }
.badge {
  position: absolute; display: none; place-items: center; background: #ff3b30; color: #fff; font-weight: 700; border-radius: 50%;
  right: calc(var(--bs) * -.3); top: calc(var(--bs) * -.3); width: var(--bs); height: var(--bs);
  border: calc(var(--bs) * .08) solid #fff; font-size: calc(var(--bs) * .68); line-height: 1; pointer-events: auto;
  --bs: max(calc(24px / var(--z, 1)), min(calc(var(--m, 100) * 0.2px), 80px));
}
.frame.problem .badge { display: grid; }
.handle {
  position: absolute; right: calc(-6px / var(--z, 1)); bottom: calc(-6px / var(--z, 1)); width: calc(18px / var(--z, 1)); height: calc(18px / var(--z, 1));
  background: #0a60d8; border: calc(2px / var(--z, 1)) solid #fff; border-radius: calc(4px / var(--z, 1)); cursor: nwse-resize; display: none;
}
.frame.sel.editable .handle { display: block; }
.draw-preview { position: absolute; border: calc(2px / var(--z, 1)) dashed #0a60d8; background: rgba(10, 96, 216, .18); pointer-events: none; }

.slider-row { margin-bottom: 6px; }
.slider-row .top { display: flex; justify-content: space-between; font-weight: 600; }
.slider-row .top span:last-child { font-weight: 400; color: var(--muted); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.problem-box { margin-top: 14px; padding-top: 12px; border-top: .5px solid var(--line); }
.problem-read { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; }

.k-row { padding: 12px 0; border-top: .5px solid var(--line); }
.k-row.off { opacity: .75; }
.k-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.k-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.k-slider { display: grid; grid-template-columns: 1fr 52px; gap: 12px; align-items: center; }
.k-val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Dialog & Hinweise ---------- */
dialog {
  border: 0; border-radius: 20px; background: var(--card); color: var(--text); padding: 0; width: min(440px, calc(100vw - 24px));
  box-shadow: 0 24px 70px rgba(0, 0, 0, .4), 0 0 0 .5px var(--line);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog form { padding: 22px; }
dialog h2 { margin-bottom: 14px; font-size: 19px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; }
.toast {
  background: rgba(44, 44, 46, .94); color: #fff; padding: 10px 18px; border-radius: 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, .3);
  max-width: min(92vw, 520px); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.toast.err { background: rgba(215, 0, 21, .94); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Dashboard kompakt: alles auf einer Seite ---------- */
.view.fill > .dash { flex: 1; min-height: 0; }
.dash { display: flex; flex-direction: column; gap: 10px; }
.dash .card { padding: 12px 14px; }
.dash .card > h2 { font-size: 14px; margin-bottom: 8px; }
.dash .filters { margin: 0; gap: 10px; padding: 10px 12px; flex: none; }
.dash .filters label.field { min-width: 130px; }
.dash .filters .search { min-width: 180px; }
.dash .kpis { grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: 10px; margin: 0; flex: none; }
.dash .kpi { padding: 9px 14px; }
.dash .kpi .v { font-size: 22px; }
.dash .kpi .small { font-size: 12px; }
.overview-host { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.dash .three { margin: 0; gap: 10px; flex: none; }
.dash .three > .card { max-height: 272px; overflow: auto; }
.dash .cat-row { grid-template-columns: 150px 1fr; margin-bottom: 5px; }
.dash .pb.lg { height: 17px; border-radius: 6px; }
.dash .pb.lg .pb-fill { border-radius: 6px; }
.dash .pb.lg .pb-txt { font-size: 11px; }
.dash .cards { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.dash .anl-card { padding: 9px 11px; }
.dash .anl-card b { margin-bottom: 4px; }
.dash .table-card { flex: 1; min-height: 140px; display: flex; flex-direction: column; overflow: hidden; }
.dash .table-card .table-wrap { flex: 1; min-height: 0; }
.dash table.grid th, .dash table.grid td { padding: 5px 9px; }
.pie-host { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.pie-section { margin: 0; flex: none; }
.pie-section > h2 { font-size: 14px; margin: 0 2px 6px; }
.pie-grid { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.pie-grid.big { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.pie-card { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; text-align: left; padding: 10px 12px !important; }
.pie-card h3 { font-size: 13px; margin-bottom: 4px; }
.pc-body { min-width: 0; }
.legend { font-size: 12px; gap: 2px; }
.pie-grid.small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pie-card.compact { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 8px 6px !important; }
.pie-card.compact h3 { font-size: 12.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.mini-legend { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.mini-legend span { display: inline-flex; align-items: center; gap: 3px; }
.mini-legend i { width: 8px; height: 8px; border-radius: 50%; display: block; }

/* Niedrige Fenster: Elemente automatisch verkleinern, damit das Dashboard weiter auf eine Seite passt */
@media (min-width: 861px) and (max-height: 800px) {
  .dash { gap: 8px; }
  .dash .filters { padding: 8px 10px; }
  .dash .kpi { padding: 6px 12px; }
  .dash .kpi .v { font-size: 19px; }
  .pie-host { gap: 8px; }
  .pie-section > h2 { margin-bottom: 4px; }
  .pie-grid.big .pie-card { padding: 8px 10px !important; }
  .pie-grid.big .pie-card svg { width: 90px; height: 90px; }
  .pie-card.compact { padding: 5px 6px !important; gap: 2px; }
  .pie-card.compact svg { width: 62px; height: 62px; }
}

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 35; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-102%);
    transition: transform .22s; padding-top: 64px; box-shadow: 0 0 40px rgba(0, 0, 0, .35); background: var(--card);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 31; }
  .brand span { display: none; }
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .usermenu { margin-left: auto; }
  .usermenu > .btn { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
  .usermenu > .btn .pill { display: none; }
  .toolbar .muted.small { flex-basis: 100%; }
  .view { padding: 12px; }
  .two { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 22px; }
  .viewer-main { display: flex; flex-direction: column; flex: none; overflow: visible; }
  .view.fill { overflow: auto; }
  .view.fill > .dash { flex: none; }
  .overview-host { display: block; }
  .dash .three > .card { max-height: none; }
  .dash .table-card .table-wrap { max-height: 60vh; }
  .pie-host { overflow: visible; }
  .pie-grid.big { grid-template-columns: 1fr; }
  .viewer { height: auto; min-height: 100%; }
  .viewport { flex: none; height: 56dvh; min-height: 280px; }
  .side { flex: none; overflow: visible; }
  .side .card { height: auto; }
  .topbar select { max-width: 150px; }
}
