/* Twingo-Webapp im Stil der iPhone-App (TwingoDesign.swift, design-tesla/DESIGN-VORGABE.md). Mobil zuerst, ab 760 px linke Navigation.
   1 CSS-Pixel = 1 pt in der WKWebView (iPhone 430 × 932). Schriftstufen: 40 light · 24 · 20 · 18 · 16 · 14 · 12 · 11 (semibold).
   Variablen --bg --card --line --text --muted --blue --green nutzen auch driving.css und autonom.css – Namen nicht ändern. */

:root {
  color-scheme: dark;
  --bg: #161718;          /* TFarbe.hintergrund */
  --card: #222224;        /* karte */
  --knopf: #2c2c2c;       /* graue Knopffläche */
  --feld: #282828;        /* Eingabefeld */
  --text: #f3f3f3;
  --muted: #858586;       /* textLeise */
  --text-menue: #8a8b8b;  /* Untertitel Hauptmenü, Symbole */
  --text-start: #929294;
  --text-knopf: #9f9f9f;
  --pfeil: #454546;
  --band: #212222;
  --haarlinie: #232625;
  --umrandung: #2c2e2d;
  --line: #2a2b2d;
  --blue: #4067f6;        /* akzent */
  --schalter-aus: #6b6b6d;
  --green: #65c468;
  --gelb: #ffcc40;
  --rot: #ff5c54;
  --radius: 4px;
  --page-pad-x: 20px;     /* Seitenrand; driving.js kann mit margin-inline: calc(-1 * var(--page-pad-x)) randlos werden */
  --sidebar: 248px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
html.modal-offen, html.menue-offen { overflow: hidden; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); font-size: 14px; font-weight: 500; line-height: 1.25; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .38; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; font-weight: 600; letter-spacing: -.2px; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
small, .muted { color: var(--muted); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.unsichtbar { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

svg.icon { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg.icon.klein { width: 14px; height: 14px; stroke-width: 2.1; }

.t-zahl-gross { font-size: 40px; font-weight: 300; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.t-zahl { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }

@media (max-width: 759.98px) { .nur-gross { display: none !important; } }
@media (min-width: 760px) { .nur-klein { display: none !important; } }

/* ---------------------------------------------------------------- Hülle */

.shell { min-height: 100vh; min-height: 100dvh; }
.main { min-width: 0; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
.page { min-width: 0; }
.page-autonom { padding: 0 var(--page-pad-x); }

/* Kopf (TKopf): Zurück-Pfeil links, Titel 18 mittig, Aktionen rechts, 10 + 44 + 12 pt. */
.kopf { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr minmax(0, auto) 1fr; align-items: center; min-height: 66px; padding: calc(10px + env(safe-area-inset-top)) 8px 12px 0; background: var(--bg); }
.kopf-links { display: flex; align-items: center; padding-left: 11.8px; }
.kopf-mitte { min-width: 0; text-align: center; padding: 0 4px; }
.kopf-mitte h1 { font-size: 18px; font-weight: 600; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf-mitte p { margin-top: 1px; font-size: 14px; font-weight: 600; color: var(--text-menue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf-rechts { display: flex; justify-content: flex-end; align-items: center; gap: 2px; }
.kopf-aktion { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; min-height: 44px; padding: 0 10px; border-radius: var(--radius); color: var(--text); font-size: 14px; font-weight: 600; }
.kopf-aktion span { display: none; }
.kopf-aktion:active, .icon-btn:active { opacity: .55; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: var(--radius); color: var(--text); flex-shrink: 0; }
.kopf-zurueck svg.icon { width: 22px; height: 22px; stroke-width: 2.2; }
.in-app .shell[data-page="autonom"] .kopf { display: none; }

/* Navigation: mobil als Blatt von links (über ≡ auf der Startseite), ab 760 px feste Seitenleiste. */
.sidebar { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(320px, 86vw); display: flex; flex-direction: column; padding: calc(24px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom)); background: var(--bg); border-right: 1px solid var(--band); overflow-y: auto; overscroll-behavior: contain; transform: translateX(-102%); transition: transform .22s ease; visibility: hidden; }
.sidebar.offen { transform: none; visibility: visible; box-shadow: 24px 0 60px #000a; }
.scrim { position: fixed; inset: 0; z-index: 29; background: #0009; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 12px; margin-bottom: 22px; font-size: 20px; font-weight: 600; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 0 12px; border-radius: var(--radius); color: #b7b8b9; font-size: 14px; font-weight: 600; }
.nav a svg.icon { color: var(--text-menue); }
.nav a:hover { background: #1d1e20; color: var(--text); }
.nav a.active { background: var(--card); color: var(--text); }
.nav a.active svg.icon { color: var(--text); }
.nav-band { margin: 10px 0; }
.sidebar-fuss { margin-top: auto; padding: 22px 12px 0; display: grid; gap: 8px; }
.status-text { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.nav-abmelden { display: flex; align-items: center; gap: 12px; min-height: 44px; color: var(--text-knopf); font-size: 13px; font-weight: 600; }
.nav-abmelden:hover { color: var(--text); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.dot.off { background: var(--muted); }

/* ---------------------------------------------------------------- Bausteine */

/* Hauptmenü-Zeile (TMenueZeile): Icon 20 im 28er-Rahmen ab 22,8, Titel 20, Untertitel 14 #8A8B8B, Pfeil, 70 pt. */
.menue { display: flex; flex-direction: column; }
.menue-zeile { display: flex; align-items: center; width: 100%; min-height: 70px; padding: 8px 30px 8px 22.8px; text-align: left; color: var(--text); }
.menue-zeile .menue-icon { width: 20px; height: 20px; margin: 0 17.7px 0 4px; color: var(--icon, var(--text-menue)); }
.menue-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.menue-text strong { font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menue-text small { font-size: 14px; font-weight: 600; color: var(--text-menue); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.menue-zeile:active, .zeile:active { opacity: .55; }
.menue-unter .menue-zeile { min-height: 66px; }

/* Einstellzeile (TZeile): Icon 22 im 28er-Rahmen ab 19,8, Text ab 58,8, Titel 14, Untertitel 12 auf 16-pt-Zeilen, 70 pt. */
.zeile { display: flex; align-items: center; width: 100%; min-height: 70px; padding: 12px 20px 12px 19.8px; text-align: left; color: var(--text); background: none; }
.zeile .zeile-icon { width: 22px; height: 22px; margin: 0 14px 0 3px; color: var(--text-menue); }
.zeile-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.zeile-text strong { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.zeile-text small { font-size: 12px; font-weight: 600; line-height: 16px; color: var(--muted); overflow-wrap: anywhere; }
.zeile-wert { margin-left: 10px; font-size: 14px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.zeile .pfeil, .menue-zeile .pfeil { width: 15px; height: 15px; margin-left: 8px; color: var(--pfeil); stroke-width: 2.4; }
.zeile .pfeil { margin-right: 10px; }
.zeile.statisch:active { opacity: 1; }
label.zeile { cursor: pointer; margin: 0; font-size: inherit; color: var(--text); }
.zeile-paar { display: flex; align-items: center; padding-right: 8px; }
.zeile-paar > .zeile { flex: 1; min-width: 0; padding-right: 4px; }
.zeile-paar > .icon-btn, .zeile-paar > .btn { flex-shrink: 0; }
.zeile-zusatz { color: var(--text-menue); }

.band { height: 2px; margin: 10px 0; background: var(--band); }
.abschnitt { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 22px 20px 6px; }
.abschnitt h2 { font-size: 20px; font-weight: 600; }
.abschnitt-link { font-size: 14px; font-weight: 600; color: var(--muted); }
a.abschnitt-link { min-height: 44px; display: inline-flex; align-items: center; margin: -12px 0; }
.marke-kopf { padding: 20px 20px 4px; font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
.fusstext { padding: 6px 20px; font-size: 12px; font-weight: 600; line-height: 16px; color: var(--muted); }

/* Karte (TKarte): #222224, Radius 4, innen 16, außen 12. */
.karte { background: var(--card); border-radius: var(--radius); padding: 16px; }
.page > .karte { margin: 0 12px 12px; }
.kennzahlen { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 12px 12px; }
.kennzahl { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kennzahl-titel { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: #b9babb; }
.kennzahl-titel svg.icon { color: var(--text-menue); }
.kennzahl strong { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kennzahl small { font-size: 12px; font-weight: 600; line-height: 16px; }
.gross-zahl { display: flex; flex-direction: column; gap: 4px; padding: 8px 20px 18px; }
.gross-zahl small { font-size: 12px; font-weight: 600; line-height: 16px; }
.gross-zahl .t-zahl-gross span { font-size: 22px; font-weight: 400; color: var(--muted); }

.tank-karte { display: grid; gap: 8px; }
.tank-zeile { display: flex; align-items: center; gap: 12px; }
.tank-icon { width: 26px !important; height: 26px !important; color: var(--text); }
.tank-karte p { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; line-height: 16px; color: var(--muted); }

.drei-werte { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.drei-werte div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.drei-werte strong { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.drei-werte small { font-size: 12px; font-weight: 600; }
.chart-karte { padding: 12px 8px 4px 12px; }
.chart-karte .fusstext { padding: 6px 4px 8px; }
.preis-chart { display: block; width: 100%; height: auto; }
.chart-linie { fill: none; stroke: var(--blue); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart-punkt { fill: var(--bg); stroke: var(--blue); stroke-width: 2; }
.chart-gitter { stroke: #2e2f31; stroke-width: 1; stroke-dasharray: 2 4; }
.chart-text { fill: var(--muted); font-size: 11px; font-weight: 600; font-family: inherit; }

/* Segment-Wahl (TSegment) */
.segment { display: flex; gap: 3px; padding: 3px; margin: 0 12px 12px; background: var(--card); border-radius: var(--radius); }
.segment button { flex: 1; min-height: 44px; border-radius: 3px; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.segment button[aria-pressed="true"] { background: var(--knopf); color: var(--text); }

/* Knöpfe (TKnopfStil): Radius 4, Höhe 44; voll = blau, Fläche = #2C2C2C, Umrandung = 2 pt #2C2E2D. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border: 2px solid transparent; border-radius: var(--radius); background: var(--knopf); color: var(--text); font-size: 14px; font-weight: 600; line-height: 1.2; text-align: center; }
.btn:hover { background: #363638; }
.btn:active { opacity: .6; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: #5579f8; }
.btn.outline { background: transparent; border-color: var(--umrandung); }
.btn.outline:hover { background: #ffffff08; }
.btn.danger, .btn.loeschen { color: var(--rot); }
.btn.block { width: 100%; }
.btn.klein { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn svg.icon { width: 17px; height: 17px; }
.knopf-reihe { display: flex; flex-wrap: wrap; gap: 12px; padding: 4px 20px 12px; }
.knopf-reihe > .btn { flex: 1 1 auto; }
.knopf-reihe.zwei { display: grid; grid-template-columns: 1fr 1fr; }
.text-button { color: var(--text-knopf); font-size: 13px; font-weight: 600; padding: 7px 0; }
.text-button:hover { color: var(--text); }

/* Hinweis (Banner wie „Nicht verbunden“ in Steuerung) */
.hinweis, .notice { display: flex; align-items: flex-start; gap: 10px; margin: 4px 20px 14px; padding: 12px 14px; border: 1px solid var(--umrandung); border-radius: var(--radius); font-size: 12px; font-weight: 600; line-height: 16px; color: var(--text); }
.hinweis svg.icon { margin-top: 1px; color: var(--text-menue); }
.hinweis.gelb { flex-direction: column; border-color: #ffcc4066; background: #ffcc400d; margin: 0 0 16px; }
.hinweis.rot, .notice.error { border-color: #ff5c5466; color: #ffb1ac; }

.leer, .empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 36px 24px; text-align: center; color: var(--muted); }
.leer .leer-icon, .empty > svg.icon { width: 32px; height: 32px; margin-bottom: 4px; color: var(--text-menue); }
.leer strong, .empty strong { font-size: 16px; font-weight: 600; color: var(--text); }
.leer p, .empty p { max-width: 360px; font-size: 12px; font-weight: 600; line-height: 16px; }
.leer .btn { margin-top: 10px; }

/* Ältere Klassen, die driving.js weiter nutzt */
.description { color: var(--muted); font-size: 14px; line-height: 1.45; max-width: 690px; }
.help { color: var(--muted); font-size: 12px; font-weight: 600; line-height: 16px; margin-top: 6px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.panel { background: var(--card); border-radius: var(--radius); padding: 16px; }
.status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.status.good { color: var(--green); }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.data-table th { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 600; text-align: left; }
.data-table td { padding: 16px 12px 16px 0; border-bottom: 1px solid var(--line); }
pre { white-space: pre-wrap; word-break: break-word; background: #1d1e20; border-radius: var(--radius); padding: 14px; font-size: 11px; line-height: 1.5; max-height: 300px; overflow: auto; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

/* Felder: 16 px Schrift, sonst zoomt iOS beim Antippen. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid transparent; border-radius: var(--radius); background: var(--feld); color: var(--text); font-size: 16px; font-weight: 500; appearance: none; -webkit-appearance: none; }
select { padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%23858586' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--rot); }
input::placeholder, textarea::placeholder { color: #5f6062; }
input[type="date"], input[type="datetime-local"] { display: block; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; }

/* Schalter (TSchalterStil): 51 × 31, an #4067F6, aus #6B6B6D, Knopf 27 weiß. */
input.schalter { appearance: none; -webkit-appearance: none; position: relative; width: 51px; height: 31px; margin: 0; border-radius: 16px; background: var(--schalter-aus); cursor: pointer; flex-shrink: 0; transition: background .22s; }
input.schalter::before { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0004; transition: transform .22s; }
input.schalter:checked { background: var(--blue); }
input.schalter:checked::before { transform: translateX(20px); }

.formular { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.feld { margin-bottom: 16px; min-width: 0; }
.feld.breit { grid-column: 1 / -1; }
@media (max-width: 559.98px) { .feld-datetime { grid-column: 1 / -1; } }
.feld label .optional { font-weight: 500; color: #6a6b6d; }
.feld-rahmen { position: relative; }
.feld-rahmen.mit-einheit input { padding-right: 70px; }
.einheit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; font-weight: 600; color: var(--muted); pointer-events: none; }
.feld-fehler { margin-top: 6px; font-size: 12px; font-weight: 600; line-height: 16px; color: var(--rot); }
.feld-hilfe { margin-top: 6px; font-size: 12px; font-weight: 600; line-height: 16px; color: var(--muted); }
.feld-schalter { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; }
.feld-schalter label { margin: 0; font-size: 14px; color: var(--text); }
.form-error { min-height: 0; font-size: 13px; font-weight: 600; line-height: 18px; color: var(--rot); }
.form-error:empty { display: none; }
.form-error:not(:empty) { margin: 6px 0 12px; }

/* ---------------------------------------------------------------- Startseite */

.start { position: relative; }
.start-kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: calc(18px + env(safe-area-inset-top)) 10px 0 32px; }
.start-name { min-width: 0; }
.start-name h1 { font-size: 24px; font-weight: 600; margin-top: 4px; }
.start-werte { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 16px; font-weight: 600; color: var(--text-start); }
.start-werte span { display: inline-flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; }
.start-status { margin-top: 3px; font-size: 14px; font-weight: 600; color: var(--text-menue); }
.start-knoepfe { display: flex; gap: 2px; }
.start-buehne { position: relative; }
.home-model { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: clamp(260px, 36vh, 340px); }
.home-model canvas { width: 100% !important; height: 100% !important; touch-action: none; display: block; }
.home-model .car-image { max-height: 100%; width: auto; max-width: 100%; padding: 30px 20px; object-fit: contain; filter: drop-shadow(0 26px 26px #0009); }
.home-model-hint, .model-hint { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.home-model-hint { margin-top: -4px; }
/* 3D-Kapsel (TKapselKnopf3D): einzige Kapsel der App, 34 hoch, Weiß 10 % / Rand Weiß 22 %. */
.kapsel3d { position: absolute; z-index: 2; top: 6px; right: 12px; display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 12px; border: 1px solid #ffffff38; border-radius: 17px; background: #ffffff1a; color: var(--text); font-size: 14px; font-weight: 600; }
.kapsel3d::before { content: ""; position: absolute; inset: -5px; }
.kapsel3d svg.icon { width: 17px; height: 17px; }
.schnell { display: grid; grid-template-columns: repeat(4, 80px); justify-content: center; padding: 6px 0 14px; }
.schnell a { display: flex; align-items: center; justify-content: center; min-height: 56px; color: var(--text-menue); }
.schnell a:hover, .schnell a:active { color: var(--text); }
.schnell svg.icon { width: 24px; height: 24px; }
.start-listen { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 8px; border-top: 2px solid var(--band); padding-top: 8px; }
.start-listen .fusstext { padding-top: 10px; }

/* ---------------------------------------------------------------- Blatt (Formular) und Dialoge */

dialog#modal { margin: auto 0 0; padding: 0; width: 100%; max-width: 100%; max-height: calc(100dvh - 20px); border: 0; border-radius: 12px 12px 0 0; background: var(--bg); color: var(--text); overflow: hidden; box-shadow: 0 -10px 40px #000a; }
dialog#modal[open] { display: flex; flex-direction: column; animation: blatt-hoch .22s ease-out; }
dialog#modal::backdrop { background: #000a; }
@keyframes blatt-hoch { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
#modal-content { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.blatt { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.blatt-kopf { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 54px; padding: 4px 6px; border-bottom: 1px solid var(--haarlinie); flex-shrink: 0; }
.blatt-kopf h2 { font-size: 18px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blatt-link { justify-self: start; min-height: 44px; padding: 0 12px; color: var(--blue); font-size: 16px; font-weight: 500; }
.blatt-link.fett { justify-self: end; font-weight: 600; }
.blatt-link:disabled { opacity: .4; }
.blatt-inhalt { padding: 18px 20px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.blatt .loeschen { margin-top: 12px; }
.blatt-meta { margin-top: 14px; font-size: 12px; font-weight: 600; line-height: 16px; color: var(--muted); }
.bestaetigen { padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); }
.bestaetigen h2 { font-size: 18px; margin-bottom: 10px; }
.bestaetigen p { font-size: 14px; line-height: 1.45; color: var(--muted); }
.bestaetigen .knopf-reihe { padding: 20px 0 0; }
.viewer { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.viewer-canvas { position: relative; height: min(62dvh, 560px); display: flex; align-items: center; justify-content: center; }
.viewer-canvas canvas { width: 100% !important; height: 100% !important; touch-action: none; display: block; }
.viewer-canvas .car-image { max-height: 80%; width: auto; }
.viewer .model-hint { padding-bottom: calc(14px + env(safe-area-inset-bottom)); text-align: center; }

#toast { position: fixed; z-index: 60; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); max-width: calc(100vw - 40px); padding: 12px 16px; border-radius: var(--radius); background: #2c2c2c; color: var(--text); font-size: 14px; font-weight: 600; line-height: 1.35; box-shadow: 0 10px 30px #0008; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- Steuerung, Wächter, Client (gateway-ui.js) */

.gw-status { display: flex; align-items: center; gap: 10px; padding: 0 20px 12px; font-size: 14px; font-weight: 600; color: var(--muted); }
.gw-fahrzeug .hinweis { margin: 0 20px 14px; }
.ctl-gruppe { margin: 0 12px 12px; }
.ctl-gruppe h3 { font-size: 16px; margin-bottom: 12px; }
.ctl-raster { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ctl-kachel { display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 108px; padding: 6px 2px; color: var(--text); font-size: 12px; font-weight: 600; line-height: 15px; text-align: center; }
.ctl-symbol { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: var(--radius); background: var(--knopf); }
.ctl-symbol svg.icon { width: 24px; height: 24px; }
.ctl-kachel:disabled { opacity: 1; color: #6f7072; }
.ctl-kachel:disabled .ctl-symbol { background: #29292a; color: #5d5e60; }
.ctl-kachel:not(:disabled):active .ctl-symbol { background: var(--blue); }
.ctl-schalter { display: flex; align-items: center; gap: 12px; min-height: 56px; font-size: 14px; font-weight: 600; }
.ctl-schalter > span { flex: 1; min-width: 0; }
.ctl-schalter-icon { width: 22px; height: 22px; color: var(--text-menue); }
.ctl-schalter .segment { margin: 0; flex: 0 0 132px; background: var(--bg); }
.ctl-schalter .segment button { min-height: 44px; color: var(--text); }
.ctl-schalter .segment button:disabled { color: #5d5e60; opacity: 1; }
.gateway-feedback { padding: 2px 20px 6px; font-size: 13px; font-weight: 600; line-height: 18px; color: #a9bdfc; }
.gateway-feedback:empty { display: none; }
.gw-client { background: var(--card); border-radius: var(--radius); padding: 16px; }
.gw-einbettung .gw-client { margin: 6px 12px 0; }
.gw-kopf { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.gw-online { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: right; }
.gw-knoepfe { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 6px; }
.gw-knoepfe .btn.primary { grid-column: 1 / -1; }
.gw-knoepfe.gw-waechter .btn.primary { grid-column: auto; }
.gw-knoepfe .btn.scharf { border-color: var(--rot); background: #ff5c541a; }
.gw-client .gateway-feedback { padding: 6px 0 0; }
.gw-details { margin-top: 10px; }
.gw-details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--text-knopf); font-size: 13px; font-weight: 600; }
.gateway-panel pre { margin-top: 8px; }

/* ---------------------------------------------------------------- Anmeldung */

.login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.login-bild { position: relative; display: flex; flex-direction: column; align-items: center; padding: calc(20px + env(safe-area-inset-top)) 0 0; }
.login-bild .brand { align-self: flex-start; padding-left: 20px; margin-bottom: 0; }
.login-model { position: relative; width: 100%; height: 280px; display: flex; align-items: center; justify-content: center; }
.login-model canvas { width: 100% !important; height: 100% !important; touch-action: none; display: block; }
.login-model .hero { max-height: 100%; width: auto; padding: 24px; object-fit: contain; }
.login-form-wrap { display: flex; justify-content: center; padding: 8px 20px calc(30px + env(safe-area-inset-bottom)); }
.login-form { width: 100%; max-width: 360px; }
.login-form h1 { font-size: 24px; margin: 8px 0 8px; }
.login-text { font-size: 14px; line-height: 1.45; color: var(--muted); margin-bottom: 22px; }
.login-form .btn { margin-top: 4px; }
.login-form .fusstext { padding: 14px 0 0; }

/* ---------------------------------------------------------------- Ab 760 px: Seitenleiste, Kopf links, breitere Flächen */

@media (min-width: 760px) {
  :root { --page-pad-x: 20px; }
  .shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; width: auto; transform: none; visibility: visible; transition: none; box-shadow: none; padding-top: 28px; }
  .scrim { display: none !important; }
  .main { padding: 0 20px calc(48px + env(safe-area-inset-bottom)); }
  .main > .kopf, .main > .page { max-width: 780px; }
  .main.breit > .kopf, .main.breit > .page { max-width: 1400px; }
  .kopf { display: flex; justify-content: space-between; gap: 16px; min-height: 0; padding: 30px 8px 18px 20px; }
  .kopf-links { display: none; }
  .kopf-mitte { text-align: left; padding: 0; }
  .kopf-mitte h1 { font-size: 24px; }
  .kopf-mitte p { margin-top: 4px; }
  .kopf-aktion { background: var(--knopf); padding: 0 14px; }
  .kopf-aktion:hover { background: #363638; }
  .kopf-aktion span { display: inline; }
  .zeile:not(.statisch):hover, .menue-zeile:hover { background: #1c1d1f; }
  .zeile, .menue-zeile { border-radius: var(--radius); }
  .page > .karte, .kennzahlen, .segment, .ctl-gruppe, .gw-einbettung .gw-client { margin-left: 12px; margin-right: 12px; }
  .kennzahlen { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 0; margin-bottom: 12px; }
  .page-trips .kennzahlen { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 520px; }
  .start-kopf { padding: 30px 8px 0 20px; }
  .home-model { height: clamp(340px, 50vh, 600px); }
  .kapsel3d { top: 0; }
  .knopf-reihe.zwei { max-width: 520px; }
  .formular { gap: 0 16px; }
  dialog#modal { margin: auto; width: min(580px, calc(100vw - 48px)); max-height: min(86dvh, 860px); border-radius: 6px; border: 1px solid #2f3032; }
  dialog#modal.klein { width: min(440px, calc(100vw - 48px)); }
  dialog#modal.viewer-dialog { width: min(1100px, calc(100vw - 48px)); }
  dialog#modal[open] { animation: none; }
  .blatt-inhalt { padding-bottom: 24px; }
  .viewer-canvas { height: min(70dvh, 720px); }
  .ctl-raster { gap: 12px; }
  .ctl-gruppe { max-width: 640px; }
  .login { display: grid; grid-template-columns: 1.35fr 1fr; }
  .login-bild { justify-content: center; border-right: 1px solid var(--band); padding: 70px 40px; }
  .login-bild .brand { position: absolute; left: 32px; top: 30px; padding: 0; }
  .login-model { height: min(65vh, 600px); }
  .login-bild .model-hint { position: absolute; bottom: 36px; left: 0; right: 0; }
  .login-form-wrap { align-items: center; padding: 40px; }
  .login-form { max-width: 340px; }
}

@media (min-width: 1200px) {
  :root { --sidebar: 264px; }
  .main { padding-left: 32px; padding-right: 32px; }
}

@media (max-width: 380px) {
  .formular { grid-template-columns: 1fr; }
  .schnell { grid-template-columns: repeat(4, 1fr); }
  .kennzahl strong { font-size: 20px; }
}

@media (hover: none) {
  .btn:hover { background: var(--knopf); }
  .btn.primary:hover { background: var(--blue); }
  .btn.outline:hover { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
