/*
 * ASK Feasibility Tool — Shared Design System
 * The Spatialists · https://thespatialists.studio
 *
 * Single source of truth for:
 *   - Brand fonts
 *   - CSS reset
 *   - Design tokens (brand palette, UI surfaces, typography)
 *   - All shared UI components
 *
 * Layout skeleton (sidebar, topbar, main) lives here (admin layout section).
 * Page-specific styles live in per-page <style> blocks.
 */

/* ── Google Fonts fallback (Inter) ───────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ── Brand Fonts (local) ─────────────────────────────────── */
@font-face {
  font-family: 'GeneralSans';
  src: url('../fonts/GeneralSans-Regular.woff2') format('woff2'),
       url('../fonts/GeneralSans-Regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'GeneralSans';
  src: url('../fonts/GeneralSans-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'GeneralSans';
  src: url('../fonts/GeneralSans-Semibold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Design Tokens ───────────────────────────────────────── */
/* ───────────────────────────────────────────────────────────────────────────
   DESIGN-TOKENS  (Redesign — DESIGN_SPEC.md, Schritt 1)
   ⚠ FARBWERTE SIND PLATZHALTER — Finetuning erfolgt zuletzt (#24, Schritt 5).
   Hell = :root  ·  Dunkel = html[data-theme="dark"]  → reiner Token-Swap.
   Bestehende Token-Namen bleiben erhalten (bruchfrei); Werte verfeinert.
   ─────────────────────────────────────────────────────────────────────────── */
:root {
  /* Brand (fix) */
  --brand-green:  #9bf000;
  --brand-navy:   #020381;
  --brand-orange: #fe4708;
  --brand-black:  #141211;
  --brand-white:  #fefefe;

  /* CRUD-Popover-Akzente (Bild-Palette) — Hintergrund = Farbe, Icon = schwarz bzw. weiss */
  --crud-add:  var(--brand-green);    /* Neu / Hinzufügen — Lime */
  --crud-del:  var(--brand-orange);   /* Löschen — Rot-Orange */
  --crud-dup:  #0a33ff;               /* Duplizieren — Blau (Bild; --brand-navy wäre zu dunkel) */
  --crud-dark: var(--brand-black);    /* Report / Bearbeiten — Schwarz */

  /* Motion (DESIGN_SPEC §7) */
  --ease: cubic-bezier(.2,.8,.2,1);
  --dur:  .16s;

  /* Typography */
  --font: 'GeneralSans', 'Inter', -apple-system, 'Helvetica Neue', sans-serif;

  /* Radius */
  --r-sm: 6px;
  --r:    8px;
  --r-lg: 14px;

  /* Elevation */
  --shadow-card: 0 1px 2px rgba(0,0,0,.06);
  --shadow-pop:  0 8px 24px rgba(0,0,0,.18);

  /* Flächen */
  --surface: #ffffff;
  --bg:      #f3f1ec;
  --tile:    #f7f6f3;   /* Hover / Zebra / Footer */
  --head:    #fbfaf8;   /* Tabellen-/Gruppenkopf */
  --band-1:  rgba(20,18,17,.058); /* .dtab Gruppen-Stufe 1 (stärkstes Band) */
  --band-2:  rgba(20,18,17,.030); /* .dtab Gruppen-Stufe 2 (leichte Tönung) */
  --band-h:  rgba(20,18,17,.070); /* .dtab Gruppen-Hover */

  /* Text */
  --text:  #16140f;
  --muted: #8a877e;
  --faint: #b4b1a8;

  /* Linien */
  --border: rgba(20,18,17,.12);
  --line:   rgba(20,18,17,.07);

  /* Akzent / Override */
  --accent: var(--brand-orange);
  --ov-bg:  #ffe5d8;
  --ov-ink: #b8390a;

  /* Status */
  --ok:      #27500a;
  --ok-bg:   #eefbd6;
  --err:     #c0392b;
  --err-bg:  #fdecea;
  --success: #1e6b3e;   /* bestehend (Viewer-Freigabe) */
  --danger:  #c94f3a;   /* bestehend */

  /* Sidebar */
  --sidebar-w:        232px;
  --sidebar-bg:       #141211;
  --sidebar-text:     rgba(255,255,255,0.52);
  --sidebar-hover-bg: rgba(255,255,255,0.07);
  --sidebar-border:   rgba(255,255,255,0.09);

  /* Brand assets */
  --logo-white: url('/coliving/assets/img/TS_LOGO_white.png');
}

/* Dunkelmodus — reiner Token-Swap, opt-in via <html data-theme="dark">. Platzhalter-Werte. */
html[data-theme="dark"] {
  --surface: #171513;
  --bg:      #0f0e0c;
  --tile:    #1d1b18;
  --head:    #1b1916;
  --band-1:  rgba(255,255,255,.065);
  --band-2:  rgba(255,255,255,.032);
  --band-h:  rgba(255,255,255,.085);

  --text:  #f4f2ee;
  --muted: #8f8b82;
  --faint: #5f5c55;

  --border: rgba(255,255,255,.12);
  --line:   rgba(255,255,255,.07);

  --accent: var(--brand-green);
  --ov-bg:  #3a2113;
  --ov-ink: #ff8a52;

  --ok:      #9bf000;
  --ok-bg:   rgba(155,240,0,.12);
  --err:     #ff7a6a;
  --err-bg:  #2a1715;
  --success: #4ccb7f;
  --danger:  #ff7a6a;

  --sidebar-bg:       #100f0d;
  --sidebar-text:     rgba(255,255,255,0.55);
  --sidebar-hover-bg: rgba(255,255,255,0.08);
  --sidebar-border:   rgba(255,255,255,0.10);
}

/* ── iOS standalone safe-area support ───────────────────── */
@media all and (display-mode: standalone) {
  aside           { padding-top: env(safe-area-inset-top); }
  .topbar         { padding-top: env(safe-area-inset-top); }
  body > .login-wrap { padding-top: max(24px, env(safe-area-inset-top)); }
}

/* ── Base ────────────────────────────────────────────────── */
html { overflow-x: clip; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  max-width: 100%;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 30px;
  margin-bottom: 22px;
  overflow-x: auto;
}

.card-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 18px;
  font-weight: 600;
}

.card-grid-2 { display: grid; grid-template-columns: 1fr 1fr;     gap: 16px; margin-bottom: 16px; align-items: start; }
.card-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; align-items: start; }

.card-narrow { max-width: 50vw; }
.card-mid    { max-width: 70vw; }
@media (max-width: 1024px) {
  .card-narrow,
  .card-mid { max-width: 100%; }
}

/* ── Stats ───────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}

.stat-num   { font-size: 30px; font-weight: 600; line-height: 1; margin-bottom: 4px; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: var(--muted); }

.stats-mini { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.stat-sm    { padding: 10px 14px !important; }
.stat-sm .stat-num { font-size: 18px !important; }

/* ── Table ───────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 12px; background: var(--surface); }

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 10px 8px;
  background: var(--head);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--tile); }

/* ── Globales Muster: klickbare Zeile (Stretched-Link) ───────
   Eine Listen-/Tabellenzeile, die zu GENAU EINEM Ziel navigiert.
   Die ganze Zeile ist klickbar (Cursor + Hover), der Primärname ist ein
   echter Link ohne Unterstrich, der via ::after die Zeile überdeckt.
   Aktions-Buttons/Inputs in derselben Zeile bleiben darüber klickbar.
   Ausnahme: Vergleichs-Matrizen mit mehreren Zielen pro Zeile nutzen
   stattdessen pro Zelle klickbare Blöcke (z. B. Report-Übersicht). */
tr.row-nav { position: relative; cursor: pointer; }
.row-link { color: var(--text); text-decoration: none; font-weight: 500; }
.row-link::after { content: ""; position: absolute; inset: 0; }
.row-link:focus-visible { text-decoration: underline; outline: none; }
tr.row-nav .icon-btn,
tr.row-nav button,
tr.row-nav input,
tr.row-nav select,
tr.row-nav a:not(.row-link) { position: relative; z-index: 1; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .09s var(--ease);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { background: var(--bg); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
/* Icon-only Button (Toolbar): quadratisch, Icon zentriert. Aktiv-Zustand via .btn-primary */
.btn-icon { padding: 5px 8px; }
.btn-icon .icon { display: block; }
/* Auf-/Zuklappen-Toggle: gleicher Chevron wie die Tabellenzeilen (.dg-chev), zustandsabhängig gedreht.
   Offen (data-collapsed=0) → ▹ rechts (Aktion: zuklappen); zu (data-collapsed=1) → ▿ unten (Aktion: aufklappen). */
.dtab-all-btn .icon { transition: transform var(--dur, .16s) var(--ease, ease); }
.dtab-all-btn:not([data-collapsed="1"]) .icon { transform: rotate(-90deg); }

.btn-primary { background: var(--brand-black); color: var(--brand-white); border-color: var(--brand-black); }
.btn-primary:hover { background: #2c2a28; border-color: #2c2a28; }

.btn-green { background: var(--brand-green); color: var(--brand-black); border-color: var(--brand-green); }
.btn-green:hover { background: #88d400; border-color: #88d400; }

.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--err-bg); }

.btn-secondary { background: var(--surface); color: var(--muted); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }

/* ── Alerts ──────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--r); margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #edf7f2; border: 1px solid #a0dfc0; color: var(--success); }
.alert-error   { background: var(--err-bg); border: 1px solid #f5c4b3; color: var(--danger); }
.alert-warning { background: #fff4ec; border: 1px solid #ffc49e; color: #7a3a00; }

/* ── Forms — .form-group (full-width, labelled) ──────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 5px;
}

.form-group input[type=text],
.form-group input[type=number],
.form-group input[type=email],
.form-group input[type=date],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--brand-black);
  box-shadow: 0 0 0 3px rgba(155,240,0,.18);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-label  { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.form-control:focus {
  border-color: var(--brand-black);
  box-shadow: 0 0 0 3px rgba(155,240,0,.18);
}

/* ── Forms — .form-ctrl (compact, inline) ────────────────── */
.form-ctrl {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-ctrl:focus { border-color: var(--text); box-shadow: 0 0 0 3px rgba(155,240,0,.18); }
.form-lbl { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: block; }
textarea.form-ctrl { min-height: 52px; resize: vertical; }

/* ── Inline-Edit von Tabellen-Werten (.set-inp) ──────────────
   EINHEITLICH mit .d-edit: rahmenlos, gepunkteter Hover-Hint,
   farbiger Unterstrich für saving/saved/error. Formular-
   Eingabefelder (.form-ctrl/.form-control) bleiben boxig —
   das ist eine andere Kategorie (wie im Mockup). */
.set-inp {
  padding: 4px 6px;
  border: none;
  border-bottom: 1px dotted transparent;
  border-radius: 0;
  font-family: var(--font);
  font-size: 13px;
  background: none;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.set-inp:hover  { border-bottom-color: var(--border); }
.set-inp:focus  { border-bottom-color: var(--text); }
.set-inp.saving { border-bottom-color: var(--brand-orange); }
.set-inp.saved  { border-bottom-color: var(--success); }
.set-inp.error  { border-bottom-color: var(--danger); }
/* Inline-Feldvalidierung (fieldError() in app.js) */
.field-invalid   { border-color: var(--danger) !important; }
.set-inp.field-invalid { border: none !important; border-bottom: 1.5px solid var(--danger) !important; }
.field-error-msg { color: var(--danger); font-size: 11px; margin-top: 4px; }
/* Override = Farb-Pill an der Zahl, kein Rahmenfeld (DESIGN_SPEC §4). Bleibt editierbar. */
.set-inp.has-ov { background: var(--ov-bg); color: var(--ov-ink); border-radius: var(--r-sm); padding: 2px 8px; border-bottom-color: transparent; font-weight: 500; }
.set-inp.rt-m2-ro { background: none; color: var(--muted); cursor: default; }

/* ── Raumbaum-Vorschau (R3b-1, read-only) ─────────────────── */
/* Baum-Editor (Inversion 3/3): raum_knoten je Raumtyp als editierbarer Baum.  */
/* Räume grün, Elemente grau. Fläche/Anzahl/Bewohner inline, Kategorie per     */
/* Popover, «+»/«×» für Struktur. Hausstil: rahmenlos, Unterstrich, kein Ring.  */
.rb-preview { margin: 0 0 14px; padding: 10px 12px; background: var(--tile);
  border: 1px solid var(--border); border-radius: 8px; }
.rb-preview-head { font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px; display: flex; align-items: baseline; gap: 10px; }
.rb-preview-hint { text-transform: none; letter-spacing: 0; color: var(--faint); margin-left: 6px; }
.rb-bewohner { text-transform: none; letter-spacing: 0; color: var(--muted); margin-left: auto; }
.rb-node { border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px;
  margin-bottom: 5px; background: var(--surface); }
.rb-node.rb-room { border-left: 3px solid var(--brand-green); }
.rb-node.rb-elem { border-left: 3px solid var(--faint); border-style: dashed; }
.rb-nrow { display: flex; align-items: baseline; gap: 10px; }
.rb-nname { font-weight: 500; font-size: 13px; }
.rb-cat, .rb-fa, .rb-val { font-size: 11px; color: var(--muted); }
.rb-val { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text); }
.rb-val.rb-none { color: var(--faint); }
/* Inline editierbare Werte (Fläche/Anzahl/Kategorie/Bewohner) — Hausstil wie
   .set-inp/.d-edit: rahmenlos, gepunkteter Hover-Hint, schlichter Unterstrich im Fokus. */
.rb-fl-edit, .rb-anz-edit, .rb-cat-edit, .rb-bew-edit {
  cursor: text; border-bottom: 1px dotted transparent; padding-bottom: 1px; }
.rb-cat-edit { cursor: pointer; }
.rb-fl-edit:hover, .rb-anz-edit:hover, .rb-cat-edit:hover, .rb-bew-edit:hover {
  border-bottom-color: var(--border); }
.rb-bew-edit { color: var(--text); font-variant-numeric: tabular-nums; }
.rb-inline-input { width: 56px; font: inherit; font-size: 11px; text-align: right;
  border: none; border-bottom: 1px solid var(--text); border-radius: 0; outline: none;
  background: none; color: var(--text); padding: 0 1px 1px; font-variant-numeric: tabular-nums; }
.rb-fa { padding: 0 6px; border-radius: 9px; background: var(--ok-bg); color: var(--ok); }
/* Struktur-Aktionen «+»/«×» — dezente Ghost-Buttons, erscheinen deutlicher im Hover. */
.rb-actions { display: inline-flex; gap: 4px; align-items: center; }
.rb-btn { border: none; background: none; cursor: pointer; font-size: 14px; line-height: 1;
  color: var(--faint); padding: 0 3px; border-radius: 4px; }
.rb-btn:hover { color: var(--text); background: var(--tile); }
.rb-btn.rb-del:hover { color: var(--danger, #c0392b); }
.rb-kids { margin: 5px 0 0 16px; padding-left: 13px; border-left: 1px dashed var(--border); }
.rb-kids > .rb-node { margin-top: 5px; margin-bottom: 0; }

/* ── P3c Geschoss-Spiegel: derselbe Raumbaum (.rb-*) im Raum-Kontext ─────────── */
/* Total-m² + Aufklapp-Toggle in der m²/Raum-Zelle der Geschoss-Raumzeile. */
.room-nf-cell { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.room-nf-total { min-width: 62px; text-align: right; font-variant-numeric: tabular-nums; }
/* Override-Markierung: orange (Entscheid Sergej 2026-07-23) — Abweichung von der Typvorgabe. */
.room-nf-total.is-ovr { color: var(--brand-orange); font-weight: 600; }
.room-tree-toggle { border: none; background: none; cursor: pointer; color: var(--faint);
  font-size: 11px; line-height: 1; padding: 2px 4px; border-radius: 4px; }
.room-tree-toggle:hover { color: var(--text); background: var(--tile); }
.room-tree-toggle.open { color: var(--brand-orange); }
/* Der aufgeklappte Baum sitzt in einer colspan-Zeile — kompakter als der Editor-Baum. */
.floor-room-tree-row > td { padding: 4px 8px 10px 22px; border-bottom: 1px solid var(--border); }
.rb-ctx-tree { margin: 0; }
.rb-ctx-tree .rb-node { margin-bottom: 5px; }
/* Abweichender Knoten im Geschoss: hervorgehoben (orange) + Reset-Knopf (↺). */
.rb-fl-edit.rb-ovr { color: var(--brand-orange); font-weight: 600; border-bottom-color: transparent; }
.rb-btn.rb-reset { color: var(--brand-orange); font-size: 12px; }
.rb-btn.rb-reset:hover { color: var(--text); }

/* ── Detail-Edit-Maske (.detail-grid) ─────────────────────── */
/* Zentrales Muster für aufklappbare Inline-Bearbeitungsmasken. */
/* Gleichmässige label|wert-Spalten, gepunkteter Hover-Hint     */
/* statt Formularrahmen (wie .kw-cell). Auto-Save pro Feld.     */
/* Wiederverwendbar für alle künftigen Detail-Editoren.         */
/* Aufklappbare Zeile mit Toggle links (wie kennwerte.php) */
.rt-head { cursor: pointer; }
.rt-head:hover td { background: var(--tile); }
.rt-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  color: var(--muted);
  margin-right: 6px;
  vertical-align: middle;
  user-select: none;
  transition: transform var(--dur) var(--ease);
}
.rt-toggle svg { width: 13px; height: 13px; }
.rt-toggle.rt-collapsed { transform: rotate(-90deg); }
.detail-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  row-gap: 13px;
  column-gap: 24px;
  align-items: center;
}
.detail-grid .d-label {
  font-size: 12px;
  color: var(--muted);
}
.detail-grid .d-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
/* Editierbarer Wert: kein Rahmen, nur gepunkteter Hover-Hint.   */
.d-edit {
  cursor: text;
  border-bottom: 1px dotted transparent;
  padding-bottom: 1px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: border-color .15s;
  min-width: 30px;
  display: inline-block;
}
.d-edit:hover  { border-bottom-color: var(--border); }
.d-edit:empty::before,
.d-edit.empty  { content: '—'; color: var(--muted); }
.d-edit.saving { border-bottom-color: var(--brand-orange); }
.d-edit.saved  { border-bottom-color: var(--success); }
.d-edit.error  { border-bottom-color: var(--danger); }
.d-hint { font-size: 11px; color: var(--muted); }
/* Sektions-Heading in Detailmasken (Regel / Wenn / Dann u. a.) — Registry: .detail-grid-Ergänzung */
.d-sec { font-size: 12px; font-weight: 500; color: var(--muted); margin: 16px 0 8px; }
.d-sec:first-child { margin-top: 0; }
/* Augen-Toggle / randloser Zeilen-Icon-Button (zentralisiert aus project_detail.php, §2 2026-07-02).
   Icons via icon('eye'/'eye-off'). Registry: DESIGN.md "Augen-Toggle". */
.cl-hide-btn { background: none; border: none; cursor: pointer; padding: 3px 5px; color: var(--muted);
  border-radius: 6px; display: inline-flex; align-items: center; }
.cl-hide-btn:hover { color: var(--text); background: var(--tile); }
.cl-hide-btn.danger:hover { color: var(--danger); }
/* Inline-editierbare Bezeichnung in der Raumtyp-Titelzeile — wie .d-edit, ohne Fokus-Rand */
.rt-row-label { outline: none; cursor: text; border-bottom: 1px dotted transparent; transition: border-color .15s; }
.rt-row-label:hover, .rt-row-label:focus { border-bottom-color: var(--border); }
/* Aktiver Edit-Zustand: schlankes Inline-Input ohne Box-Look.  */
.d-edit-input {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--text);
  outline: none;
  padding: 0 1px 1px;
  width: 64px;
}
/* Segment-Umschalter (zählen / Ratio) — subtil, kein Button.   */
.d-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.d-seg button {
  font-family: var(--font);
  font-size: 11px;
  padding: 3px 10px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.d-seg button.on { background: var(--brand-black); color: var(--brand-white); }
/* Inline-Select im gleichen subtilen Stil (Ja/Nein, Funktion). */
.d-mini-sel {
  font-family: var(--font);
  font-size: 12px;
  color: var(--text);
  background: none;
  border: none;
  border-bottom: 1px dotted var(--border);
  padding: 1px 2px;
  cursor: pointer;
  outline: none;
}
.d-mini-sel:focus { border-bottom-color: var(--text); }
/* Responsive: Label über Wert stapeln auf schmalen Viewports.  */
@media (max-width: 560px) {
  .detail-grid { grid-template-columns: 1fr; row-gap: 9px; }
  .detail-grid .d-label { margin-bottom: -4px; }
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .02em;
}

/* Status badges */
.badge-active    { background: rgba(155,240,0,.2); color: #3a5800; }
.badge-draft     { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.badge-completed { background: #e8f4fd; color: #0a3d7a; }
.badge-archived  { background: #f0efeb; color: var(--muted); }

/* ── Utilities ───────────────────────────────────────────── */
.text-muted   { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.ok   { color: var(--success); font-weight: 500; }
.fail { color: var(--danger);  font-weight: 500; }

/* ── Page meta line ──────────────────────────────────────── */
.page-meta { font-size: 13px; color: var(--muted); margin: -12px 0 16px; }

/* ── Page tabs ───────────────────────────────────────────── */
.page-tabs {
  position: relative;
  display: flex;
  gap: 0;
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

/* Gleitender Aktiv-Indikator (Motion) — Position via JS, Glide via transition */
.page-ind {
  position: absolute;
  height: 2.5px;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
  transition: left .25s cubic-bezier(.4,0,.2,1), width .25s cubic-bezier(.4,0,.2,1), top .25s cubic-bezier(.4,0,.2,1);
}

.page-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 20px 0 0;
  padding: 10px 2px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  font-family: inherit;
  transition: color .15s;
}

.page-tab.active { color: var(--text); }
.page-tab:hover:not(.active) { color: var(--text); }

.page-tab-disabled { opacity: .35; cursor: default; pointer-events: none; }
.page-tab.tab-locked { opacity: .42; }
.page-tabs-spacer  { flex: 1; }

/* ── Tab-Gruppen (2026-07-20) ─────────────────────────────────────────────
   Trennt Erfassung («Grundlagen») von den Berechnungs-Phasen. Opt-in über
   .page-tabs-grouped am Container, damit die Leisten aller anderen Seiten
   unverändert bleiben. Die Gruppen-Wrapper müssen `position: static` bleiben —
   der gleitende Aktiv-Indikator (.page-ind, JS in _header.php) rechnet mit
   offsetLeft/offsetTop gegen .page-tabs als einzigen positionierten Vorfahr. */
.page-tabs-grouped { align-items: flex-end; }
.page-tab-group    { display: flex; flex-direction: column; margin-right: 36px; }
.page-tab-row      { display: flex; align-items: center; }
.page-tab-row .page-tab { padding-top: 4px; }
.page-tab-row .page-tab:last-child { margin-right: 0; }   /* Gruppenabstand kommt von .page-tab-group */

/* «+» am Ende der Phasen-Gruppe (E4). Kein data-tab → aktiviert keinen Panel-Tab und
   bekommt darum nie den Aktiv-Indikator; reiner Auslöser für den Anlege-Dialog. */
.page-tab-add { padding-left: 6px; padding-right: 6px; opacity: .55; }
.page-tab-add:hover { opacity: 1; }
.page-tab-add svg { display: block; }

/* Ausgeblendete Phase: aus der Leiste genommen, aber nicht gelöscht. Über «…»
   (.page-tab-more) wieder eingeblendet — dann gedimmt, damit der Zustand sichtbar bleibt. */
.page-tab.pt-hidden { display: none; }
.page-tab.pt-hidden.pt-revealed { display: inline-flex; opacity: .45; font-style: italic; }
.page-tab-more { padding-left: 6px; padding-right: 6px; opacity: .55; letter-spacing: .1em; }
.page-tab-more:hover, .page-tab-more.is-on { opacity: 1; }
.page-tab-glabel {
  padding: 0 2px 2px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .75;
  user-select: none;
}

/* ── Tab panels ──────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── SVG icon utility ────────────────────────────────────── */
.svg-icon { flex-shrink: 0; display: inline-block; vertical-align: middle; }

/* ── Icon button ─────────────────────────────────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg); color: var(--text); border-color: var(--text); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--err-bg); }

.tgl-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: var(--r);
  font-size: 12px;
  font-weight: 400;
  font-family: inherit;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: border-color .15s, color .15s;
}
.tgl-btn:hover { border-color: var(--text); color: var(--text); }
.tgl-btn.danger { color: var(--danger); border-color: var(--danger); }
.tgl-btn.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--err-bg); }

/* ── Page toolbar ────────────────────────────────────────── */
.page-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 8px;
  flex-wrap: wrap;
}
.page-toolbar-left,
.page-toolbar-right { display: flex; align-items: center; gap: 6px; }
/* Such-Eingabe in Toolbars: links, feste Breite (nicht voll dehnen → Buttons bleiben rechts) */
.kw-search-input { flex: 0 1 280px; max-width: 100%; }

/* ── Header row ──────────────────────────────────────────── */
.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }

/* ── Collapsible Panel — EINE Quelle (Engine: admin/app.js, data-collapse) ── */
/* Panel [data-collapse], Kopf [data-collapse-head], Body = übrige direkte Kinder. */
[data-collapse-head] { cursor: pointer; }
/* Chevron als CSS-::before am Titel — Pseudo-Element, kein DOM-Kind: überlebt textContent-Updates
   (z.B. Floor-Titel) und stört kein Flex-Layout. Klasse cl-title wird vom Engine gesetzt. */
.cl-title::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 9px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg);
  transition: transform var(--dur) var(--ease); vertical-align: middle; position: relative; top: -2px; }
.ls-name.cl-title::before { margin-left: 5px; }
[data-collapse-head]:hover .cl-title::before { border-color: var(--text); }
[data-collapse].is-collapsed .cl-title::before { transform: rotate(-45deg); }
[data-collapse].is-collapsed > :not([data-collapse-head]) { display: none !important; }
[data-collapse].is-collapsed > [data-collapse-head] { margin-bottom: 0; }

/* ── Progress bar ────────────────────────────────────────── */
.prog-bar  { height: 5px; background: var(--border); border-radius: 3px; }
.prog-fill { height: 100%; background: var(--success, #1a7a4a); border-radius: 3px; }

/* ── Save dot (inline autosave indicator) ────────────────── */
.save-dot         { width: 6px; height: 6px; border-radius: 50%; background: transparent; flex-shrink: 0; margin-top: 7px; transition: background .2s; }
.save-dot.saving  { background: #f0a500; }
.save-dot.saved   { background: #1a7a4a; }
.save-dot.error   { background: var(--danger); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 400;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%; max-width: 720px;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
  overflow: hidden;
}
.modal-sm { max-width: 520px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 500; }
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Override field (berechnet + override pattern) ───────── */
.override-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.override-calc {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.override-input {
  width: 100px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
}
.override-input:focus { border-color: var(--text); }
.override-input.has-override { background: var(--ov-bg); color: var(--ov-ink); border-color: transparent; font-weight: 500; }
.override-reset {
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline dotted;
  white-space: nowrap;
  background: none;
  border: none;
  font-family: inherit;
  padding: 0;
}
.override-reset:hover { color: var(--danger); }

/* ── Override-Pill & Herleitung (Redesign — DESIGN_SPEC §4) ──────────────────
   Übersteuerte Zahl = Farb-Pill an der Zahl (kein Rahmenfeld). Herleitung =
   dauerhafte, ruhige Unterzeile (kein Hover). Werden in Schritt 3 verdrahtet. */
.ov-pill {
  background: var(--ov-bg);
  color: var(--ov-ink);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.derivation {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.derivation .reset {
  color: var(--accent);
  cursor: pointer;
  margin-left: 6px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .stats        { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-num     { font-size: 24px; }
  .card-grid-2,
  .card-grid-3  { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  table  { font-size: 12px; }
  th, td { padding: 8px 10px; }
}

/* ─────────────────────────────────────────────────────────────
   File viewer modal
   ──────────────────────────────────────────────────────────── */
.viewer-modal {
  width:92vw; max-width:1200px; height:90vh;
  display:flex; flex-direction:column; padding:0; overflow:hidden;
}
.viewer-header {
  display:flex; align-items:center; gap:8px;
  padding:10px 14px; border-bottom:1px solid var(--border);
  flex-shrink:0; background:var(--surface);
}
.viewer-title {
  flex:1; min-width:0; font-size:13px; font-weight:500;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.viewer-body {
  flex:1; min-height:0; overflow:auto; background:#e0e0e0;
  position:relative; -webkit-overflow-scrolling:touch;
  display:flex; align-items:flex-start; justify-content:flex-start;
}
.viewer-spinner {
  position:absolute; top:0; left:0; right:0; bottom:0;
  display:flex; align-items:center; justify-content:center;
  background:#e0e0e0; color:var(--muted); font-size:13px;
  z-index:2;
}
#viewer-spacer { margin:auto; flex-shrink:0; display:flex; align-items:center; justify-content:center; }
#viewer-scaler { transform-origin:center center; flex-shrink:0; }
#viewer-object { width:100%; height:100%; display:block; }
#viewer-img    { display:block; }
.viewer-zoom-btn {
  flex-shrink:0;
  width:28px; height:28px;
  border:1px solid var(--border); border-radius:20px;
  background:var(--surface); color:var(--text);
  font-size:16px; line-height:1;
  display:inline-flex; align-items:center; justify-content:center;
  cursor:pointer; padding:0;
  transition:background .15s;
}
.viewer-zoom-btn:hover { background:var(--bg); }

/* ─────────────────────────────────────────────────────────────
   File row (attachments)
   ──────────────────────────────────────────────────────────── */
.file-row {
  display:flex; align-items:center; gap:6px;
  padding:5px 0; border-bottom:1px solid var(--border); font-size:12px;
}
.file-row:last-child { border-bottom:none; }
.file-row .fn-preview {
  flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  cursor:pointer; color:var(--text);
}
.file-row .fn-preview:hover { text-decoration:underline dotted; color:#BA7517; }

/* ─────────────────────────────────────────────────────────────
   Admin layout skeleton (sidebar, topbar, content)
   ──────────────────────────────────────────────────────────── */

/* ── Sidebar ─────────────────────────────────────────────── */
aside {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
  display: block;
  cursor: pointer;
}

.sidebar-brand-logo {
  display: block;
  width: 180px;
  max-width: 100%;
  height: 44px;
  margin-bottom: 14px;
  background-image: var(--logo-white);
  background-repeat: no-repeat;
  background-size: 100% auto;
  background-position: left center;
}

nav {
  padding: 8px 0;
  flex: 1;
}

nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: color .15s, background .15s;
}

nav a:hover {
  background: var(--sidebar-hover-bg);
  color: rgba(255,255,255,.88);
}

nav a svg {
  flex-shrink: 0;
  opacity: .55;
  transition: opacity .15s;
}

nav a:hover svg { opacity: .85; }

nav a.active {
  background: rgba(255,255,255,.08);
  color: #fff;
  font-weight: 500;
}

nav a.active svg { opacity: 1; color: var(--brand-orange); }

/* ASK-Marke + Nutzer-Avatar (Sidebar) */
.ask-mark { display: flex; align-items: center; gap: 10px; }
.ask-wordmark { font-weight: 700; font-size: 40px; letter-spacing: .03em; color: #fff; line-height: 1.05; }
.ask-dot { color: var(--brand-green); }
/* Entitäts-Marker: Icon vor Sektions-/Entitätstitel, sauber ausgerichtet */
.ent-title { display: inline-flex; align-items: center; gap: 8px; }
.ent-title .icon { flex: none; color: var(--muted); }
/* Klickbares Entitäts-Icon: Projekt → Liegenschaft-Modal, Variante → project_detail */
.ent-ico-btn { display: inline-flex; align-items: center; padding: 0; border: none; background: none; cursor: pointer; text-decoration: none; }
.ent-ico-btn:hover .icon { color: var(--text); }
/* Inline-Hinzufügen-Symbol in leeren Zuständen (keine Varianten / keine Projekte) */
.empty-add { display: inline-flex; vertical-align: middle; margin-left: 8px; padding: 2px; border: none; background: none; color: var(--brand-green); cursor: pointer; }
.empty-add:hover { opacity: .75; }
/* Reusable Empty-State (Mockup §5): Icon + Ursache + genau ein nächster Schritt */
.es-block { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 30px 20px; }
.es-block .es-b-ico { width: 44px; height: 44px; border-radius: 11px; background: var(--tile); color: var(--faint);
  display: flex; align-items: center; justify-content: center; flex: none; }
.es-block .es-b-title { font-size: 14px; font-weight: 600; color: var(--text); }
.es-block .es-b-sub { font-size: 12px; color: var(--muted); max-width: 320px; line-height: 1.5; }
.es-block .btn { margin-top: 4px; }
/* "THE SPATIALISTS" als Wortmarke unter ASK — gleicher Schriftstil wie .ask-wordmark, neue Zeile */
.ts-wordmark { display: block; margin-top: 5px; font-weight: 700; font-size: 13px; letter-spacing: .03em; color: #fff; white-space: nowrap; }
.sidebar-user { display: flex; align-items: center; gap: 11px; }
.su-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-green);
  color: var(--brand-black); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0; }
.su-name { color: rgba(255,255,255,.85); font-size: 14px; }

/* ── Command-Palette (⌘K) ────────────────────────────────── */
.cmdk-ov { position: fixed; inset: 0; background: rgba(20,18,17,.4); z-index: 9999;
  display: none; align-items: flex-start; justify-content: center; }
.cmdk-ov.open { display: flex; }
.cmdk { margin-top: 12vh; width: 580px; max-width: 92vw; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-pop);
  overflow: hidden; color: var(--text); }
.cmdk-s { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.cmdk-s svg { color: var(--muted); flex-shrink: 0; }
.cmdk-s input { border: none; outline: none; font-size: 17px; width: 100%; background: none; color: var(--text); font-family: var(--font); }
.cmdk-l { max-height: 52vh; overflow: auto; padding: 8px; }
.cmdk-g { font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); padding: 12px 12px 6px; }
.cmdk-i { display: flex; align-items: center; gap: 13px; padding: 11px 12px; border-radius: 9px; cursor: pointer; font-size: 15px; color: var(--text); }
.cmdk-i .ic { color: var(--muted); width: 18px; display: flex; flex-shrink: 0; }
.cmdk-i .ic svg { width: 16px; height: 16px; }
.cmdk-i .l { flex: 1; }
.cmdk-i .k { font-size: 12px; color: var(--faint); }
.cmdk-i.sel { background: var(--tile); }
.cmdk-i.sel .ic { color: var(--accent); }
.cmdk-f { display: flex; gap: 18px; padding: 11px 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--faint); }

/* Topbar-Suchbox (⌘K-Trigger, oben rechts) */
.topbar-search { position: absolute; top: 14px; right: 48px; display: inline-flex; align-items: center;
  gap: 8px; padding: 7px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; color: var(--muted); font-size: 13px; font-family: var(--font); cursor: pointer;
  transition: border-color .15s; z-index: 5; }
.topbar-search:hover { border-color: var(--muted); }
.topbar-search svg { width: 15px; height: 15px; flex-shrink: 0; }
.topbar-search .ts-kbd { font-size: 11px; background: var(--tile); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px; }
@media (max-width: 768px) { .topbar-search { display: none; } }

/* Toast-Feedback (showFlash) — Mockup-Stil: schwarzes Pill, von unten eingleitend */
.cl-toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  z-index: 10000; display: inline-flex; align-items: center; gap: 10px;
  background: var(--brand-black); color: #fff; font-size: 13.5px; font-weight: 500;
  padding: 11px 16px 11px 12px; border-radius: 11px; box-shadow: 0 10px 30px rgba(0,0,0,.24);
  opacity: 0; transition: opacity .25s, transform .25s cubic-bezier(.2,.8,.2,1);
  pointer-events: none; max-width: 90vw;
}
.cl-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.cl-toast .ct-ico {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--brand-green); color: var(--brand-black);
}
.cl-toast-error .ct-ico { background: #ff7a6a; color: var(--brand-black); }

/* ── System-State: Leer (global) ─────────────────────────────
   Einheitlicher Leer-Zustand: Icon-Kreis + Titel + Hinweis + optionale Aktion.
   Mockup minimal-präzise → Strich-Icon (kein Emoji). */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state .es-ico {
  width: 46px; height: 46px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--tile); color: var(--muted);
}
.empty-state .es-ico svg { width: 22px; height: 22px; }
.empty-state .es-title { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 6px; }
.empty-state .es-sub {
  color: var(--muted); font-size: 13px; line-height: 1.5;
  max-width: 380px; margin: 0 auto 18px;
}
.empty-state .es-sub:last-child { margin-bottom: 0; }
/* Kompakt-Variante (in Karten/Listen): kleinerer Abstand, kein Icon-Zwang */
.empty-state.is-inline { padding: 28px 20px; }
.empty-state.is-inline .es-ico { width: 38px; height: 38px; margin-bottom: 10px; }

/* ── System-State: Laden (global Skeleton) ───────────────────
   Schimmer-Platzhalter statt „Wird geladen…"-Text. */
@keyframes cl-shimmer { from { background-position: -340px 0; } to { background-position: 340px 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--tile) 25%, var(--head) 37%, var(--tile) 63%);
  background-size: 680px 100%;
  animation: cl-shimmer 1.3s ease-in-out infinite;
  border-radius: var(--r-sm);
}
.sk-line { height: 12px; margin: 10px 0; }
.sk-line.w-40 { width: 40%; } .sk-line.w-60 { width: 60%; } .sk-line.w-80 { width: 80%; }
.sk-row  { height: 40px; margin: 8px 0; }
.sk-panel { padding: 8px 0; }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-imprint {
  font-size: 11px;
  color: var(--sidebar-text);
  line-height: 1.6;
}

/* Hell/Dunkel-Umschalter (Sidebar-Fuss) */
.theme-toggle {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; background: none; border: none; border-radius: 8px;
  color: var(--sidebar-text); font-family: var(--font); font-size: 13px;
  cursor: pointer; transition: background .15s, color .15s;
}
.theme-toggle:hover { background: var(--sidebar-hover-bg); color: #fff; }
.theme-toggle .tt-ico { flex-shrink: 0; opacity: .8; }
.theme-toggle .tt-label::after { content: "Dunkelmodus"; }
html[data-theme="dark"] .theme-toggle .tt-label::after { content: "Hellmodus"; }

/* ── Mobile overlay ──────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20,18,17,.55);
  z-index: 190;
  backdrop-filter: blur(2px);
}

/* ── Main layout ─────────────────────────────────────────── */
main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  background: var(--bg);
  padding: 16px 0 16px 48px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-default {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 20px;
}
.topbar-default h1 {
  font-size: 22px; font-weight: 600;
  color: var(--text); margin: 0;
}
.topbar-pill {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 20px;
}

.topbar .page-meta { margin-top: 0; }
/* Editor-Tab-Reihe an die Content-Box angleichen: Topbar hat rechts kein Padding und
   keine max-width, der Content aber padding 48 + max-width 1480 → sonst überschiesst der
   rechtsbündige „Report →"-Link. Gleiche rechte Kante wie .content herstellen. */
.topbar .page-tabs { margin-bottom: 0; padding-right: 48px; max-width: 1432px; box-sizing: border-box; }

/* Hamburger — mobile only */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
  border-radius: 6px;
  line-height: 0;
  transition: background .15s;
}
.hamburger:hover { background: var(--bg); }

/* ── Content ─────────────────────────────────────────────── */
/* App-weite Lese-Maximalbreite (minimal-präzise): Inhalt wird nicht über
   ~1480px gestreckt, sondern links ausgerichtet — alle Tabellen lesen sich ruhig. */
.content { padding: 28px 48px 40px; flex: 1; width: 100%; max-width: 1480px; box-sizing: border-box; }

/* ── Mobile layout ───────────────────────────────────────── */
/* ── Schmal-Rail-Modus (Nutzerwahl, Desktop) ───────────────────────────── */
.nav-rail-toggle { display: flex; align-items: center; gap: 11px; width: 100%; background: none; border: none;
  cursor: pointer; color: var(--sidebar-text); font-family: var(--font); font-size: 13px; padding: 8px 14px; text-align: left; }
.nav-rail-toggle:hover { background: var(--sidebar-hover-bg); color: #fff; }
.nav-rail-toggle .rail-ico { flex: none; width: 15px; height: 15px; transition: transform .2s ease; }

@media (min-width: 769px) {
  html.nav-rail { --sidebar-w: 58px; }
  html.nav-rail #sidebar { overflow: visible; }
  html.nav-rail .sidebar-brand { padding: 18px 0 14px; text-align: center; }
  html.nav-rail .ask-wordmark { font-size: 18px; }
  html.nav-rail .ts-wordmark,
  html.nav-rail .nav-label,
  html.nav-rail .tt-label,
  html.nav-rail .su-name { display: none; }
  html.nav-rail nav a,
  html.nav-rail nav .nav-disabled,
  html.nav-rail .nav-rail-toggle,
  html.nav-rail .theme-toggle,
  html.nav-rail .sidebar-user { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; position: relative; }
  html.nav-rail .nav-rail-toggle .rail-ico { transform: rotate(180deg); }
  html.nav-rail nav a[data-label]:hover::after,
  html.nav-rail .nav-rail-toggle[data-label]:hover::after {
    content: attr(data-label); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    background: var(--brand-black); color: #fff; font-size: 11px; font-weight: 500; padding: 4px 9px; border-radius: 6px;
    white-space: nowrap; z-index: 320; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
}

/* ── Lade-Skeleton (System-Zustand „Laden") ────────────────────────────── */
.sk { display: inline-block; height: 11px; border-radius: 4px; vertical-align: middle;
  background: linear-gradient(90deg, var(--tile) 0%, var(--surface) 50%, var(--tile) 100%);
  background-size: 340px 100%; animation: sk-shimmer 1.3s ease-in-out infinite; }
@keyframes sk-shimmer { from { background-position: -340px 0; } to { background-position: 340px 0; } }
.sk-wrap { padding: 6px 0; }
.sk-strip { display: flex; gap: 12px; margin-bottom: 18px; }
.sk-kpi { flex: 1; height: 56px; border-radius: 8px; background: var(--tile); }
.sk-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sk-table th { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  text-align: left; padding: 0 10px 8px; border-bottom: 1px solid var(--border); }
.sk-table th.r, .sk-table td.r { text-align: right; }
.sk-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); }
.sk-hint { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 14px; }
.sk-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: sk-shimmer 1.3s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .sk, .sk-dot { animation: none; } }

/* ── Motion-Baseline (DESIGN_SPEC §7) — ruhig, kurz, zweckmässig ────────── */
.dg-chev { transition: transform var(--dur) var(--ease); }
.btn:active, .icon-btn:active, .ent-ico-btn:active, .empty-add:active, .nav-rail-toggle:active { transform: scale(.97); }
.btn:focus-visible, .icon-btn:focus-visible, .ent-ico-btn:focus-visible, nav a:focus-visible,
.crud-pop .crud-btn:focus-visible, .nav-rail-toggle:focus-visible, .theme-toggle:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
/* Karten erscheinen sanft beim Seitenaufbau (einmalig, NICHT beim Scrollen) */
.card, .ls-card { animation: card-in .2s var(--ease) both; }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* Modal: weiches Faden + leichtes Pop beim Öffnen */
.modal-overlay { animation: modal-fade .15s var(--ease); }
.modal-overlay .modal { animation: modal-pop var(--dur) var(--ease); }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop  { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

/* Reduced-Motion site-weit respektieren (DESIGN_SPEC §7) — Übergänge ~0, keine Endlos-Animation */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Fehler-Zustand (System-Zustand „Fehler") — ruhig, eine Aktion ───────── */
.err-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 40px 22px; }
.err-state .e-ico { width: 46px; height: 46px; border-radius: 11px; background: var(--err-bg); color: var(--err);
  display: flex; align-items: center; justify-content: center; flex: none; }
.err-state .e-ico svg { width: 24px; height: 24px; }
.err-state .e-title { font-size: 15px; font-weight: 600; color: var(--text); }
.err-state .e-sub { font-size: 13px; color: var(--muted); max-width: 360px; line-height: 1.55; }
.err-state .e-code { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 11px; color: var(--faint);
  background: var(--tile); padding: 3px 8px; border-radius: 5px; }
.err-state .btn { margin-top: 4px; }

@media (max-width: 768px) {
  aside {
    transform: translateX(calc(-1 * var(--sidebar-w)));
    box-shadow: none;
  }
  aside.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,.35);
  }
  .sidebar-overlay.open { display: block; }
  main      { margin-left: 0; }
  .hamburger { display: flex; }
  .topbar   { padding: 0 0 16px 16px; padding-top: 0; }
  .topbar.scrolled { box-shadow: 0 4px 16px rgba(0,0,0,.15); }
  .content  { padding: 20px 16px; }
}

@media (max-width: 480px) {
  .content { padding: 16px 12px; }
}

/* ── Kennwerte-Editor (kennwerte.php) ───────────────────────────────────── */

/* L1: top-level eBKP-H group */
/* Wie Phase II (.dtab): EINE durchgehende, flache Tabelle —
   keine Karten, keine Rundungen, kein Schatten, keine Lücken.
   L1-Gruppen nur durch eine Trennlinie oben abgesetzt. */
.kw-l1-wrap {
  border-top: 1px solid var(--border);
}
.kw-l1-wrap:first-child { border-top: none; }
.kw-l1-head {
  padding: 12px 24px !important;
  display: flex !important;
  align-items: center;
  gap: 10px;
  background: var(--band-1) !important;
}
.kw-l1-code {
  font-family: ui-monospace, monospace;
  font-size: 15px;
  font-weight: 600;
  min-width: 20px;
}
.kw-l1-label { flex: 1; font-size: 15px; font-weight: 600; }
.kw-l1-count {
  font-size: 11px;
  background: var(--ok-bg);
  color: var(--ok);
  padding: 1px 7px;
  border-radius: 9px;
  font-weight: 600;
}

/* L2: sub-group */
.kw-l2-wrap { border-top: 1px solid var(--border); }
.kw-l2-wrap:first-child { border-top: none; }
.kw-l2-head {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 9px 24px 9px 40px !important;
  background: var(--band-2) !important;
  font-size: 13px !important;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.kw-l2-head:hover { background: var(--band-h) !important; }
.kw-l2-code {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: var(--text);
  min-width: 36px;
  font-weight: 600;
}
.kw-l2-label { flex: 1; color: var(--text); font-weight: 600; }
.kw-l2-count {
  font-size: 11px;
  background: var(--ok-bg);
  color: var(--ok);
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
}

/* ── Kennwert-Tabelle (identisch in Phase 1 + Phase 2) ───────────────────── */
.kw-table { table-layout: fixed; }
.kw-table col.c-code  { width: 210px; }   /* breit genug für 4 Einrück-Stufen ohne Code-Abschneiden */
.kw-table col.c-label { width: auto; }
.kw-table col.c-chf   { width: 110px; }
.kw-table col.c-unit  { width: 150px; }
.kw-table col.c-src   { width: 160px; }
.kw-table col.c-act   { width: 76px; }

.kw-table th {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  padding: 12px 12px 10px;
  white-space: nowrap;
}
.kw-table th:first-child { padding-left: 24px !important; }
.kw-table th.r { text-align: right; }
.kw-table td {
  padding: 9px 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Phase-2-Baum (#kw-tree): EINE durchgehende Tabelle wie Phase II (.dtab).
   Ein Spaltenkopf oben (#kw-p2-tophead), feste Spalten (Top-Kopf fluchtet mit
   allen L2-Tabellen), durchgehende Zeilentrenner, KEIN Zebra.
   WICHTIG: weisser Karten-Untergrund (--surface) wie die Phase-II-.dtab — die
   Gruppen-Bänder sind halbtransparent, ihre EFFEKTIVE Farbe = Band über --surface.
   Ohne diese Karte säßen sie über dem beigen Seiten-BG und wirkten dunkler/wärmer. */
/* Gilt für BEIDE Tabs: Phase 2 (#kw-tree) und Phase 1 Richtwerte (#kw-tree-p1). */
#kw-tree,
#kw-tree-p1 {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
#kw-tree .kw-table,
#kw-tree-p1 .kw-table { table-layout: fixed; }
#kw-tree .kw-table tbody tr,
#kw-tree-p1 .kw-table tbody tr { border-bottom: 1px solid var(--line); }
#kw-tree .kw-table tbody tr td,
#kw-tree-p1 .kw-table tbody tr td { padding-top: 11px; padding-bottom: 11px; }
#kw-tree .kw-l3.has-entry.kw-zebra td,
#kw-tree-p1 .kw-l3.has-entry.kw-zebra td { background: transparent; }  /* kein Zebra (wie Phase II) */
.kw-tophead { margin-bottom: 0; }
.kw-tophead thead th { border-bottom: 1px solid var(--border); }

/* L3: position header row */
.kw-l3-head td { padding-top: 12px; border-bottom: none; font-weight: 600; color: var(--text); }
.kw-l3-head + .kw-l3 td { border-top: none; }
.kw-l3-head { cursor: pointer; }
.kw-l3-head.kw-l3-collapsed td { padding-bottom: 10px; border-bottom: 1px solid var(--border); }

/* L3: toggle arrow */
.kw-l3-toggle {
  display: inline-block; width: 12px; height: 12px; position: relative;
  font-size: 0; margin-right: 5px; vertical-align: middle; user-select: none;
}
.kw-l3-toggle::before { content: ''; position: absolute; left: 1px; top: 2px; width: 6px; height: 6px;
  border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  transform: rotate(45deg); transition: transform .18s ease; }
.kw-l3-head.kw-l3-collapsed .kw-l3-toggle::before { transform: rotate(-45deg); }

/* Kennwerte-Editor: Counter weg; Aktionen (Adder/Löschen/…) erst auf Hover (ruhige Flächen).
   Gilt für BEIDE Tabs (Phase 1 + 2) — alle Aktionen liegen in .kw-acts bzw. den Köpfen. */
.kw-l1-count, .kw-l2-count { display: none !important; }
.kw-acts .icon-btn,
.kw-l1-head .icon-btn,
.kw-l2-head .icon-btn { opacity: 0; transition: opacity .12s ease; }
tr:hover > .kw-acts .icon-btn,
.kw-l1-head:hover .icon-btn,
.kw-l2-head:hover .icon-btn,
.kw-acts .icon-btn:focus-visible { opacity: 1; }

/* L3: populated data rows */
.kw-l3.has-entry.kw-zebra td { background: var(--head); }
.kw-l3.has-entry:hover td { background: var(--tile); }
.kw-l3-code {
  font-size: 12px;
  color: var(--muted);
  padding-left: 52px !important;
  white-space: nowrap;
}
.kw-l3-label { font-size: 12px; color: var(--text); }

/* L3: variant rows — one level deeper (Phase 2 default) */
.kw-variant-code {
  font-size: 12px;
  color: var(--muted);
  padding-left: 68px !important;
  white-space: nowrap;
}

/* Phase 1: 3-level hierarchy — L2 > L3 > Variante */
/* L2 head (B05): top level inside table, minimal indent */
.kw-p1-l2-code {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  padding-left: 10px;
}
/* L3 head (B05-A): one indent step in */
.kw-p1-l3-head .kw-variant-code { padding-left: 26px !important; }
/* Variant (B05-A.1): deepest level */
.kw-p1-variant .kw-variant-code  { padding-left: 50px !important; }

/* L3: empty rows (no value set yet) */
.kw-l3.empty td { color: var(--muted); }
.kw-l3.empty .kw-l3-code-empty {
  font-size: 12px;
  padding-left: 52px !important;
}
.kw-l3.empty .kw-empty-dash { font-size: 11px; color: var(--border); }

/* Inline editing */
.kw-cell { cursor: text; }
.kw-cell:hover .kw-val { text-decoration: underline dotted var(--muted); }
.kw-cell.r { text-align: right; font-variant-numeric: tabular-nums; }
/* Inline-Edit: dezenter Unterstrich-Stil wie .set-inp/.dcell (kein schwerer Vollrahmen) */
.kw-edit-inp {
  width: 100%;
  padding: 2px 4px;
  border: none;
  border-bottom: 1.5px solid var(--text);
  border-radius: 0;
  font-family: inherit;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.kw-edit-inp[type=number] { text-align: right; }

/* Native Zahlen-Spinner app-weit entfernen — alle numerischen Felder
   (Inline-Edit, abgeleitete Mengen, Modale) nutzen saubere tabular inputs. */
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* DropZone — wiederverwendbare Datei-Drop-Komponente (JS: window.DropZone in app.js) */
.dropzone { border: 1.5px dashed var(--border); border-radius: var(--r); padding: 20px 16px; text-align: center;
  color: var(--muted); cursor: pointer; background: var(--bg);
  transition: border-color .15s, background .15s, box-shadow .15s, transform .15s; }
.dropzone:hover    { border-color: var(--text); }
/* Drag-über: durchgezogener grüner Rahmen + grüner Wash + Fokus-Ring (wie Eingabefelder) + leichtes Anheben */
.dropzone.is-over  { border: 1.5px solid var(--brand-green); background: rgba(155,240,0,.12);
  box-shadow: 0 0 0 3px rgba(155,240,0,.18); transform: scale(1.01); color: var(--text); }
/* Loslassen: kurzer Bestätigungs-Pop (JS entfernt die Klasse nach 400 ms) */
.dropzone.dz-dropped { animation: dz-pop .35s ease; border-color: var(--brand-green); }
@keyframes dz-pop { 0% { transform: scale(1); } 45% { transform: scale(1.025); } 100% { transform: scale(1); } }
/* Kinder transparent für Pointer/Drag → kein is-over-Flicker beim Überfahren des Textes */
.dropzone .dz-hint, .dropzone .dz-file { pointer-events: none; }
.dropzone .dz-hint { font-size: 13px; }
.dropzone .dz-file { font-size: 12px; color: var(--text); margin-top: 6px; }
/* Hinweistext wechselt im Drag-Zustand (rein CSS, generisch) */
.dropzone .dz-over { display: none; }
.dropzone.is-over .dz-idle { display: none; }
.dropzone.is-over .dz-over { display: inline; font-weight: 500; }

/* ── Pläne / Plan-Upload pro Variante (project_detail.php Editor + report.php Viewer) ── */
.plan-list { display: flex; flex-direction: column; }
.plan-row { display: flex; align-items: center; gap: 10px; padding: 9px 8px; margin: 0 -8px;
  border-bottom: 1px solid var(--line); border-radius: var(--r-sm); transition: background .12s; }
.plan-row:last-child { border-bottom: none; }
.plan-row:hover { background: var(--tile); }
.plan-open { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; background: none;
  border: none; cursor: pointer; font: inherit; color: var(--text); text-align: left; padding: 0; }
.plan-open svg { flex-shrink: 0; color: var(--muted); }
.plan-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-open:hover .plan-name { text-decoration: underline; }
.plan-size { font-size: 12px; color: var(--muted); flex-shrink: 0; white-space: nowrap; }
.plan-act { display: flex; align-items: center; justify-content: center; padding: 5px; border: none;
  background: none; cursor: pointer; color: var(--muted); border-radius: 6px; flex-shrink: 0; text-decoration: none; }
.plan-act:hover { color: var(--text); background: var(--tile); }
.plan-del:hover { color: var(--danger); }

/* Unit read-only cell on variant rows — not editable, just display */
.kw-unit-ro { color: var(--muted); font-size: 12px; }
.kw-muted   { color: var(--muted) !important; }

/* Actions column */
.kw-acts { text-align: right; white-space: nowrap; overflow: visible; text-overflow: clip; }
.kw-acts .icon-btn { width: 22px; height: 22px; padding: 0; font-size: 15px; line-height: 1; }

/* ── .dtab im Kennwerte-Editor: gestufte Hierarchie-Einzüge ───────────────────
   GRUPPENKÖPFE: Basis-Padding 24px, die sichtbare Stufe kommt aus der
   .dg-chev-Marge (lvl1=0 · lvl2=16 · lvl3=34). BLATTZEILEN (Varianten ohne
   Chevron) werden per Padding tiefer eingerückt, leere Platzhalter auf L3-Stufe.
   Überschreibt die alten 52/68px-Nested-Paddings. */
.dtab .dgroup td.kw-l3-code,
.dtab .dgroup td.kw-variant-code { padding-left: 24px !important; }
.dtab .drow td.kw-variant-code { padding-left: 96px !important; }           /* Variante: tiefste Stufe (deutlich unter L3 ~81px) */
.dtab .drow.empty td.kw-l3-code,
.dtab .drow.empty td.kw-l3-code-empty { padding-left: 72px !important; }     /* leere Position (unter L2, ~L3-Stufe) */
.dtab .drow.empty td { color: var(--muted); }

/* Editierbare Zellen in Gruppenköpfen: Text-Cursor statt Toggle-Pointer */
.dtab .dgroup td.kw-cell { cursor: text; }

/* Gruppen-Aktionen (+ / Löschen in Köpfen) erst auf Hover (ruhige Flächen) */
.dtab .dgroup .icon-btn { opacity: 0; transition: opacity .12s ease; }
.dtab .dgroup:hover .icon-btn,
.dtab .dgroup .icon-btn:focus-visible { opacity: 1; }

/* Filter „Nur eingetragene" + Suche (.dtab) */
.dtab tr.is-filtered { display: none; }
.dtab tr.is-searchhidden { display: none; }

/* Positions-Counter („N Pos.") überall entfernt — in ALLEN .dtab-Tabellen
   (Kennwerte P1/P2 + phase_view P1/P2/P3) konsistent ausgeblendet. */
.dtab .dg-count { display: none !important; }

/* Aktions-Buttons (+ / ⊕ / Löschen) in der acts-Spalte: nur auf Zeilen-Hover.
   WICHTIG: opacity:0 versteckt sie in dieser Chrome/Tabellen-Konstellation NICHT
   zuverlässig (getComputedStyle meldet 0, gemalt werden sie trotzdem → das war
   das „···"). Lösung über visibility: versteckt zuverlässig UND reserviert den
   Platz → die Zeilenhöhe ändert sich beim Hover NICHT. Gilt für alle .dtab. */
.dtab .kw-acts .icon-btn { visibility: hidden; }
.dtab tr:hover .kw-acts .icon-btn { visibility: visible; }
/* kennwerte P1/P2: alte Inline-Aktionsbuttons (+/⊕/Picker/Sammel/Löschen) komplett entfernt —
   alle Aktionen laufen jetzt über das zentrale CRUD-Popover (Griff wird per JS injiziert). */
.kw-table .kw-acts .icon-btn { display: none !important; }

/* Inline-„+" am Gruppenkopf (z.B. phase_view L2 → L3 hinzufügen): nur auf Hover */
.dtab .dgroup .dg-add { visibility: hidden; }
.dtab .dgroup:hover .dg-add,
.dtab .dgroup .dg-add:focus-visible { visibility: visible; }

/* Toolbar */
.kw-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.kw-toolbar .form-control { font-size: 13px; padding: 6px 10px; width: 220px; }

/* Kennwerte-Set-Umschalter (M4a, H5 — wiederverwendbar: Kennwerte- und künftig Richtwerte-Tab) */
.kw-set-switch { display: flex; gap: 4px; align-items: center; }
.kw-set-switch select { width: auto; min-width: 130px; max-width: 220px; }
.kw-set-desc { font-size: 12px; color: var(--muted); margin: -8px 0 12px; }

/* Kennwerte-Set der Variante im Phase-II/III-Kopf (M4a) */
.pv-kwset { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.pv-kwset select { width: auto; max-width: 170px; font-size: 12px; padding: 4px 8px; }

/* Utility */
.kw-zero { color: var(--muted) !important; }

@media (max-width: 768px) {
  .kw-table col.c-src { width: 0; display: none; }
  .kw-table td.kw-cell[data-field="source"],
  .kw-table th.hide-mobile { display: none; }
  .kw-toolbar .form-control { width: 150px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   .tbl — ZENTRALE einfache Listen-/Datentabelle (Single Source of Truth)
   Gemeinsames Muster der „flachen" Tabellen (Vorgaben, Raumtypen, gespeicherte
   Reports …). Destillat aus .settings-table + .dtab: gedämpfter Kopf mit 2px-
   Unterkante, Haarlinien-Zeilen, Hover-Tint, tabular-nums. Modifier:
   th/td.r = rechts (Zahlen) · .cap = Versalien-Kopf · .t-key = Monospace-Schlüssel
   · .t-sub = 11px-Zweitzeile · tfoot/.t-total = Summenzeile. Für hierarchische
   Tabellen (Collapse/Bänder) gilt weiterhin .dtab.
   ═══════════════════════════════════════════════════════════════════════════ */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl thead th { font-size: 11px; font-weight: 500; color: var(--muted); text-align: left;
                padding: 8px 12px 10px 0; border-bottom: 2px solid var(--border); white-space: nowrap; }
.tbl thead th.r { text-align: right; }
.tbl thead th.cap { text-transform: uppercase; letter-spacing: .04em; }
.tbl td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); color: var(--text); vertical-align: middle; }
.tbl td.r { text-align: right; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--tile); }
.tbl .t-key   { font-family: ui-monospace, "SF Mono", monospace; font-size: 11px; color: var(--muted); }
.tbl .t-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tbl .t-muted { color: var(--muted); }
.tbl tfoot td, .tbl .t-total td { border-top: 1px solid var(--border); border-bottom: none; font-weight: 600; padding-top: 12px; }

/* ═══════════════════════════════════════════════════════════════════════════
   .dtab — ZENTRALE Datentabellen-Komponente (Single Source of Truth)
   Ein Look für ALLE Tabellen: Kostenpositionen (Phase I/II), Kennwerte,
   Richtwerte. Collapse/Expand (beliebig tief) steuert app.js über data-parents.
   Referenz: mockup_kostentabelle.html + mockup_tabelle_collapse.html.
   ═══════════════════════════════════════════════════════════════════════════ */
.dtab { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
.dtab thead th { font-size: 12px; font-weight: 400; color: var(--muted); text-align: right; padding: 12px 24px 10px; white-space: nowrap; }
.dtab thead th.l { text-align: left; }
.dtab thead th.cap { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; text-align: left; }
.dtab thead th.cap.r { text-align: right; }

/* ── Sticky-Header: nur die Spaltenkopfzeile, fensterbezogen, unter der klebenden Topbar
   (--sticky-top via app.js). Hintergrund opak. Voraussetzung: kein Vorfahr mit
   overflow≠visible (Karte/Wrapper → visible). */
.dtab-sticky thead th { position: sticky; top: var(--sticky-top, 0px); z-index: 30; background: var(--surface); }
#kw-tree.dtab-sticky, #kw-tree-p1.dtab-sticky { overflow: visible; }

/* ── Collapsible Gruppenzeilen ───────────────────────────── */
.dtab .dgroup td { cursor: pointer; user-select: none; border-top: 1px solid var(--line); }
.dtab .dgroup:hover td { background: var(--band-h); }
.dg-chev { display: inline-flex; align-items: center; justify-content: center; width: 15px; margin-right: 8px;
  color: var(--muted); transition: transform .18s ease; }
.dg-chev svg { width: 13px; height: 13px; }
.dtab .dgroup.is-collapsed .dg-chev { transform: rotate(-90deg); }
.dg-code { }
.dg-name { color: var(--text); }
.dg-title { font-size: 14px; font-weight: 600; color: var(--text); }
.dg-count { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 8px; }
/* Phase-I-Referenz („Phase I Grob: …") dezent direkt nach der Bezeichnung */
.dg-ref { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 14px; }

/* phase_view: Aktionsspalte rechts (+ pro L2, Löschen bei Zusatzpos.) — nur auf Zeilen-Hover.
   Button via position/right vom Rand abgesetzt (padding/margin greifen in der schmalen
   Zelle an der Karten-Kante nicht zuverlässig). */
.dtab .pv-acts { text-align: right; white-space: nowrap; }
.dtab .pv-acts .icon-btn { visibility: hidden; width: 22px; height: 22px; padding: 0; position: relative; right: 16px; }
.dtab tr:hover .pv-acts .icon-btn { visibility: visible; }

/* ═══ CRUD-Popover — zentrale Komponente (Engine: app.js) ════════════════════
   Schmale Aktionsspalte + „⋯"-Griff auf Hover. Das eigentliche Popover wird von
   app.js am <body> erzeugt (.crud-pop), schwebt über allem und fächert per
   Web Animations API auf. Zeilen markieren sich per data-crud="add dup del". */
.crud-cell { width: 36px; position: relative; text-align: right; }
/* WICHTIG: in .dtab-Tabellen versteckt opacity:0 NICHT zuverlässig (Chrome malt trotzdem
   → das war die „···"). Darum visibility (wie .kw-acts), opacity nur für den Fade. */
.crud-handle { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); visibility: hidden; opacity: 0; transition: opacity .12s ease; cursor: pointer; }
[data-crud]:hover .crud-handle { visibility: visible; opacity: 1; }
[data-crud].crud-open .crud-handle { visibility: hidden; opacity: 0; }
/* Kopfzeilen-Variante (E4): der Griff fliesst als eigenes Element in der Flex-Reihe mit,
   statt absolut in einer Tabellenzelle zu sitzen — sonst liegt er hinter dem Nachbar-Button.
   Dauerhaft sichtbar (gedimmt), weil ein Abschnittskopf nicht überfahren wird wie eine Zeile. */
.crud-head { position: relative; display: inline-flex; align-items: center; }
.crud-head .crud-handle { position: static; transform: none; visibility: visible; opacity: .5; }
.crud-head:hover .crud-handle,
[data-crud]:hover .crud-head .crud-handle { opacity: 1; }
[data-crud].crud-open .crud-head .crud-handle { visibility: hidden; opacity: 0; }

/* Karten-Variante: Griff oben rechts statt mittig (projects.php Varianten-Karten) */
.var-card { position: relative; }
.crud-handle-card { top: 12px; right: 12px; transform: none; }
.vc-name-edit { cursor: text; border-radius: 4px; padding: 1px 5px; margin: -1px -5px; }
.vc-name-edit:hover { background: var(--tile); }
.vc-name-input { font: inherit; font-weight: inherit; color: inherit; width: 100%; max-width: 280px;
  border: 1px solid var(--text); border-radius: 4px; padding: 0 5px; background: var(--surface); }
.ls-name-edit { cursor: text; border-radius: 5px; padding: 1px 6px; margin: 0 -6px; }
.ls-name-edit:hover { background: var(--tile); }
.ls-name-input { font: inherit; font-weight: inherit; color: inherit; width: 100%; max-width: 380px;
  border: 1px solid var(--text); border-radius: 5px; padding: 1px 6px; background: var(--surface); }
.ls-meta-edit { cursor: text; border-radius: 5px; padding: 1px 6px; margin: 2px -6px 0; }
.ls-meta-edit:hover { background: var(--tile); }
.ls-meta-input { font: inherit; color: inherit; border: 1px solid var(--text); border-radius: 4px;
  padding: 1px 5px; margin-right: 4px; background: var(--surface); }

.crud-pop { position: fixed; z-index: 9999; height: 30px; }
.crud-pop .crud-btn { position: absolute; top: 0; right: 0; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--crud-dark); border-radius: 50%; background: var(--crud-dark); color: #fff; cursor: pointer; padding: 0; opacity: 0; box-shadow: 0 4px 10px rgba(0,0,0,.18), 0 1px 3px rgba(0,0,0,.12); transition: top .15s var(--ease, ease), box-shadow .15s var(--ease, ease); }
/* Akzentfarben je Aktion: Hintergrund = Farbe, Icon weiss.
   SCHWARZ IST DER DEFAULT (in der Basisregel oben) — nur die drei semantisch aufgeladenen
   Aktionen weichen ab. Vorher trug eine Namensliste das Schwarz; jede neue Aktion, die
   dort vergessen wurde (clear, attach, hide, compare), erschien im Browser-Grau. */
.crud-pop .crud-btn[data-crud-action="add"] { background: var(--crud-add); border-color: var(--crud-add); }
.crud-pop .crud-btn[data-crud-action="dup"] { background: var(--crud-dup); border-color: var(--crud-dup); }
.crud-pop .crud-btn[data-crud-action="del"] { background: var(--crud-del); border-color: var(--crud-del); }
.crud-pop .crud-btn:hover { filter: brightness(0.92); top: -3px; box-shadow: 0 12px 22px rgba(0,0,0,.30), 0 2px 4px rgba(0,0,0,.14); }
.crud-pop .crud-btn:nth-child(1){ z-index: 6; }
.crud-pop .crud-btn:nth-child(2){ z-index: 5; }
.crud-pop .crud-btn:nth-child(3){ z-index: 4; }
.crud-pop .crud-btn:nth-child(4){ z-index: 3; }
.crud-pop .crud-btn:nth-child(5){ z-index: 2; }
.crud-pop .crud-btn:nth-child(6){ z-index: 1; }
.dg-ref   { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 12px; }
.dg-sum   { text-align: right; font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; }
.dg-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px;
  padding: 0 6px; border-radius: 9px; background: var(--ok-bg); color: var(--ok); font-size: 11px; font-weight: 600; }

/* Stufe 1 — stärkstes Band */
.dtab .dgroup.lvl1 td { background: var(--band-1); padding: 12px 24px; border-top: 1px solid var(--border); }
.dtab .dgroup.lvl1:first-of-type td { border-top: none; }
.dtab .dgroup.lvl1 .dg-code, .dtab .dgroup.lvl1 .dg-name { font-size: 15px; font-weight: 600; }
.dtab .dgroup.lvl1 .dg-name { margin-left: 10px; }
/* Stufe 2 — leichte Tönung */
.dtab .dgroup.lvl2 td { background: var(--band-2); padding: 9px 24px; }
.dtab .dgroup.lvl2 .dg-chev { margin-left: 16px; }
.dtab .dgroup.lvl2 .dg-code, .dtab .dgroup.lvl2 .dg-name { font-size: 13px; font-weight: 600; }
.dtab .dgroup.lvl2 .dg-name { margin-left: 10px; }
/* Stufe 3 — ohne Fläche */
.dtab .dgroup.lvl3 td { padding: 8px 24px; }
.dtab .dgroup.lvl3 .dg-chev { margin-left: 34px; }
.dtab .dgroup.lvl3 .dg-code { font-size: 12px; color: var(--muted); }
.dtab .dgroup.lvl3 .dg-name { font-size: 12px; color: var(--muted); margin-left: 10px; }

/* ── Datenzeilen ─────────────────────────────────────────── */
.dtab .drow td { padding: 11px 24px; border-top: 1px solid var(--line); }
.dtab .drow:hover td { background: var(--tile); }
.dtab .drow.is-zebra td { background: var(--head); }
.dtab .drow.is-zebra:hover td { background: var(--tile); }
.dtab .d-code { font-size: 12px; color: var(--muted); }
.dtab .d-pos  { font-size: 13px; color: var(--text); }
.dtab .d-menge{ text-align: right; font-size: 13px; }
.dtab .d-unit { display: block; text-align: right; color: var(--muted); font-size: 11px; margin-top: 2px; line-height: 1.25; }
.dtab .d-num  { text-align: right; font-size: 13px; }
.dtab .d-total{ text-align: right; font-size: 13px; font-weight: 500; }
.dtab .d-src  { font-size: 11px; color: var(--muted); }

/* Override-Pill (nur an der Zahl) */
.dtab .ov-pill { display: inline-flex; align-items: center; gap: 5px; background: var(--ov-bg); color: var(--ov-ink);
  border-radius: var(--r-sm); padding: 3px 9px; font-weight: 500; }
.dtab .ov-pill svg { width: 12px; height: 12px; }

/* ── Summen-Fuß (tfoot-Band) ─────────────────────────────── */
.dtab tfoot td { background: var(--tile); padding: 9px 24px; }
.dtab tfoot tr:first-child td { border-top: 1px solid var(--border); padding-top: 16px; }
.dtab .tf-label { text-align: right; font-size: 13px; color: var(--muted); }
.dtab .tf-val   { text-align: right; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.dtab .tf-total .tf-label, .dtab .tf-total .tf-val { font-size: 17px; font-weight: 600; color: var(--text);
  padding-top: 6px; padding-bottom: 16px; }

/* ── Positionskommentare (Phase II/III, 2026-07-13) ──────── */
/* Icon in der Positionszelle: dezent, sichtbar bei Hover oder vorhandenem Kommentar */
.dtab .pv-note-btn { display: inline-flex; vertical-align: -2px; margin-left: 7px; padding: 0;
  border: 0; background: none; cursor: pointer; color: var(--muted); opacity: 0; transition: opacity .12s; }
.dtab .pv-note-btn svg { width: 13px; height: 13px; }
.dtab .drow:hover .pv-note-btn { opacity: .55; }
.dtab .pv-note-btn:hover { opacity: 1 !important; color: var(--text); }
.dtab .pv-note-btn.has-note { opacity: 1; color: var(--ov-ink); }
.dtab .pv-note-btn.has-note svg { fill: var(--ov-bg); }
/* Kommentarzeile: zu, ausser einzeln geöffnet (.open) oder globaler Toggle (nur befüllte) */
.dtab tr.drow-note { display: none; }
.dtab tr.drow-note.open { display: table-row; }
.dtab.pv-notes-open tr.drow-note.has-note { display: table-row; }
.dtab tr.drow-note.is-hidden, .dtab tr.drow-note.is-filtered { display: none !important; }
.dtab tr.drow-note td { border-top: 0; padding: 0 24px 10px; }
.dtab tr.drow-note td.note-cell { padding-top: 0; }
.dtab .pv-note-inp { width: 100%; max-width: 560px; resize: vertical; font: inherit; font-size: 12px;
  line-height: 1.45; color: var(--text); background: var(--tile); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 7px 10px; }
.dtab .pv-note-inp:focus { outline: none; border-color: var(--border); background: var(--head); }
.dtab .pv-note-inp::placeholder { color: var(--muted); }

/* ── Collapse-Sichtbarkeit + Reveal-Motion ───────────────── */
.dtab tr.is-hidden { display: none; }
@keyframes dtab-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dtab tr.reveal td { animation: dtab-in .18s cubic-bezier(.2,.8,.2,1) both; }
@media (prefers-reduced-motion: reduce) { .dtab tr.reveal td { animation: none; } }

/* ── Freie Zellen (Phase II / vereinheitlicht): Menge+CHF in EINER Zelle,
      obere Zahlenzeile + zweite Zeile (Quellen: Bezugsgrösse links, Kennwert rechts).
      Grid-Spalten = Spaltenbreiten (120/150) + padding-right 24px → Zahlen unter Header. */
.dtab td.d-mc { padding-left: 0; padding-right: 0; }
.dtab .mc-top { display: grid; grid-template-columns: 120px 150px; align-items: baseline; }
.dtab .mc-menge, .dtab .mc-chf { text-align: right; padding-right: 24px; font-size: 13px; white-space: nowrap; }
.dtab .mc-menge .d-unit { display: inline; text-align: left; color: var(--muted); font-size: 11px; margin: 0 0 0 4px; }
.dtab .mc-2 { display: grid; grid-template-columns: 120px 150px; margin-top: 3px; }
.dtab .mc-2 > * { text-align: right; padding-right: 24px; min-width: 0; }
.dcell { width: 80px; text-align: right; font-family: inherit; font-size: 13px; color: var(--text);
  border: none; border-bottom: 1px dotted transparent; background: none; padding: 2px 2px; outline: none;
  font-variant-numeric: tabular-nums; }
.dcell:hover { border-bottom-color: var(--border); }
.dcell:focus { border-bottom-color: var(--text); }
.dcell.ov { background: var(--ov-bg); color: var(--ov-ink); border-radius: var(--r-sm); padding: 2px 8px; }
/* Genauigkeit-Override im Kostentabellen-Header — schmale Inline-Variante von .dcell, gleicher .ov-Look */
.pv-acc-inp { width: 30px; text-align: center; font-family: inherit; font-size: 12px; color: inherit;
  border: none; border-bottom: 1px dotted var(--border); background: none; padding: 0 1px; outline: none;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.pv-acc-inp::-webkit-outer-spin-button, .pv-acc-inp::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pv-acc-inp:hover  { border-bottom-color: var(--text); }
.pv-acc-inp:focus  { border-bottom-color: var(--text); color: var(--text); }
.pv-acc-inp.ov { background: var(--ov-bg); color: var(--ov-ink); border-radius: var(--r-sm); border-bottom-color: transparent; padding: 1px 5px; }
.kw-link { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--accent);
  background: none; border: none; cursor: pointer; padding: 0; font-family: inherit; white-space: nowrap; }
.kw-link svg { width: 11px; height: 11px; flex-shrink: 0; }
.kw-link.adopted, .kw-link.src { color: var(--muted); }
.kw-link.reset { color: var(--ov-ink); }
/* Kennwert-Popover — z-index ÜBER allen Modals (statisch 400, dynamisch inline 10001):
   der Picker wird u.a. im Kennwert-Hinzufügen-Modal geöffnet und lag mit 200 dahinter
   (Livetest-Befund 2026-07-23: «Einheit nicht mehr festlegbar»). */
.kw-pop { position: absolute; z-index: 10100; min-width: 260px; max-height: 340px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-pop); padding: 6px; }
.kw-pop-h { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px 4px; }
.kw-opt { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline;
  padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.kw-opt:hover, .kw-opt.sel { background: var(--tile); }
.kw-opt .o-lbl { font-size: 13px; color: var(--text); }
.kw-opt.sel .o-lbl { font-weight: 500; }
.kw-opt .o-val { font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.kw-opt .o-src { font-size: 11px; color: var(--muted); grid-column: 1 / -1; }
.kw-pop-sec { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 9px 12px 3px; position: sticky; top: 0; background: var(--surface); }
/* Editierbare Einheit-Zelle als Picker (öffnet den geteilten UnitPicker, wie Phase II) */
.kw-cell[data-field="l3_unit"] .kw-val { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); cursor: pointer; }
.kw-cell[data-field="l3_unit"] .kw-val::after { content: "\25BE"; font-size: 9px; opacity: .55; }

/* ── Pos table (assessment.php Phase 1 & 2) ────────────── */
.pos-table { table-layout: fixed; width: 100%; }
.pos-table th { text-align: right; font-weight: 500; padding: 5px 10px 6px; white-space: nowrap; }
.pos-table th.pt-l { text-align: left; }
.pos-table td { padding: 8px 10px; vertical-align: middle; }
.pos-table .group-head td { background: var(--head); padding: 11px 10px; border-top: 1px solid var(--border); vertical-align: baseline; }
.pos-table .group-head:first-child td { border-top: none; }
.pos-table .gh-title { font-size: 14px; font-weight: 600; color: var(--text); }
.pos-table .gh-count { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.pos-table .gh-ref { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 12px; }
.pos-table .gh-sum   { text-align: right; font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.total-cell { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.pos-table td.pt-code { color: var(--muted); font-size: 12px; }
.pos-table td.pt-ein  { color: var(--muted); font-size: 12px; }
/* Menge + Einheit kombiniert (Mockup: Zahl, Einheit gedämpft darunter) */
.pos-table td.pt-menge { text-align: right; }
.pos-table .pt-unit { display: block; text-align: right; color: var(--muted); font-size: 11px; margin-top: 2px; line-height: 1.25; }
/* Override cell pattern */
.pos-table td .ov-cell { display: flex; flex-direction: row; align-items: center; justify-content: flex-end; gap: 4px; }
.pos-table .set-inp { width: 100px; text-align: right; }
.pos-table .set-inp.menge-inp { width: 60px; }
.ov-reset { font-size: 11px; color: var(--muted); cursor: pointer; background: none; border: none; font-family: inherit; padding: 0 1px; }
.ov-reset:hover { color: var(--danger); }
.qty-orig { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ── .dtab-grid — zwei (oder mehr) .dtab nebeneinander, responsiv ──────────────
   Wiederverwendbarer Wrapper (Registry → DESIGN.md). NUR für Tabellen, die in
   UNABHÄNGIGE Blöcke zerfallen (keine gemeinsame Summe/Sortierung/Collapse über
   beide Spalten). Auf schmal automatisch 1-spaltig. Für 3 Blöcke: 1fr 1fr 1fr. */
.dtab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 30px; align-items: start; }
@media (max-width: 620px) { .dtab-grid { grid-template-columns: 1fr; gap: 0; } }
/* .dtab-qty — einwertige .dtab-Zelle (nur Wert + Reset, kein Menge|CHF-Raster),
   z.B. Mengengerüst „Abgeleitete Mengen". Kollabiert das 120/150-Zellraster auf 1 Spalte. */
.dtab-qty .mc-top { grid-template-columns: 1fr; justify-items: end; }
.dtab-qty .mc-2   { grid-template-columns: 1fr; }
.dtab-qty .mc-2 > * { padding-right: 0; text-align: right; }
@media (max-width: 768px) {
  /* Switch to auto layout — Safari ignores col width:0 in fixed-layout tables,
     causing hidden cells to overlap. Auto layout lets the engine recalculate
     column widths from visible content only. */
  .pos-table { table-layout: auto; }
  .pos-table col.pt-hide-m { display: none; }
  .pos-table th.pt-hide-m,
  .pos-table td.pt-hide-m  { display: none; }
  /* Total CHF column: constrain so name column gets remaining space */
  .pos-table .total-cell { white-space: nowrap; }
}

/* ── Utility-Klassen (Inline-Styles → Tokens, ROADMAP §21 / Block 2) ─────────────
   Decken die häufigsten Inline-Muster ab. Prefix u- = Utility, kollisionsfrei.
   Mehrere kombinierbar (class="u-ta-r u-muted"). display:none bleibt bewusst inline
   (wird per JS getoggelt). */
.u-ta-r   { text-align: right; }
.u-ta-c   { text-align: center; }
.u-ta-l   { text-align: left; }
.u-muted  { color: var(--muted); }
.u-fw-500 { font-weight: 500; }
.u-fw-600 { font-weight: 600; }
.u-fw-700 { font-weight: 700; }
.u-small  { font-size: 12px; }
.u-xs     { font-size: 11px; }
.u-small-muted { font-size: 12px; color: var(--muted); }
.u-xs-muted    { font-size: 11px; color: var(--muted); }
.u-m0     { margin: 0; }
.u-mb0    { margin-bottom: 0; }

/* Zusatzpositions-Sortierung (2026-07-13): Drag & Drop via geteilter DragSort-Engine (app.js) */
.cl-drag-handle { cursor:grab; color:var(--muted); opacity:.25; font-size:13px; padding:0 5px 0 0; line-height:1; user-select:none; vertical-align:middle; }
.drow-custom:hover .cl-drag-handle { opacity:.55; }
.drow-custom.cl-dragging td { opacity:.4; }
.drow-custom.cl-drag-target td { box-shadow: inset 0 2px 0 0 #4f9cf5; }

/* ── Rich-Text-Mini-Editor (report_text — REPORT_TEXT.md) ─────────────────── */
.rtext-toolbar { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.rtext-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.rtext-editor {
  min-height: 140px;
  max-height: 420px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  outline: none;                /* Typografie: .rtext-body (geteilt mit Report-Card) */
  transition: border-color .15s, box-shadow .15s;
}
.rtext-editor:focus {                     /* identisch zu .form-control:focus */
  border-color: var(--brand-black);
  box-shadow: 0 0 0 3px rgba(155,240,0,.18);
}
.rtext-editor:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
/* .rtext-body: Typografie des Rich-Text-INHALTS — EINE Quelle für Editor (phase_view)
   und Report-Card (report.php). Editor-Div trägt beide Klassen. */
.rtext-body { font-size: 14px; line-height: 1.55; color: var(--text); }
.rtext-body h3 { font-size: 15px; font-weight: 700; margin: 12px 0 4px; }
.rtext-body h3:first-child { margin-top: 0; }
.rtext-body p { margin: 0 0 8px; }
.rtext-body p:last-child { margin-bottom: 0; }
.rtext-body ul, .rtext-body ol { margin: 0 0 8px; padding-left: 22px; }

/* ── P4: Formeln & Kennzahlen — Chips + Editor (aus mockups/mockup_p4_formeleditor.html) ── */
.fx-chip { display: inline-block; font-size: 11.5px; font-weight: 600; line-height: 1;
  padding: 3px 7px 4px; border-radius: 6px; background: rgba(2,3,129,.08); color: var(--brand-navy);
  border: 1px solid rgba(2,3,129,.18); white-space: nowrap; vertical-align: baseline; }
.fx-chip.kz      { background: rgba(254,71,8,.07);  color: var(--brand-orange); border-color: rgba(254,71,8,.22); }
.fx-chip.kosten  { background: rgba(20,18,17,.06);  color: var(--text);         border-color: rgba(20,18,17,.16); }
.fx-chip.vorgabe { background: rgba(155,240,0,.16); color: var(--success);      border-color: rgba(155,240,0,.5); }
.fx-op { font-weight: 600; color: var(--muted); padding: 0 2px; }
.fx-fn { font-weight: 600; color: var(--text); }

.fx-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fx-table th { text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border); }
.fx-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.fx-table tr:hover td { background: rgba(0,0,0,.02); }
.fx-key { font-size: 11px; color: var(--muted); font-family: ui-monospace, monospace; }
.fx-grp td { background: rgba(0,0,0,.03); font-size: 11px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); padding: 5px 10px; }
.fx-fmt { font-size: 12px; color: var(--muted); white-space: nowrap; }

.fxe { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.fxe-top { display: flex; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.fxe-top label { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); display: block; margin-bottom: 4px; }
.fxe-main { display: grid; grid-template-columns: 1fr 300px; }
.fxe-left { padding: 16px; border-right: 1px solid var(--border); min-width: 0; }
.fxe-field { min-height: 64px; border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  font-size: 15px; line-height: 2; background: var(--bg); outline: none; }
.fxe-field:focus { border-color: var(--brand-navy); box-shadow: 0 0 0 3px rgba(2,3,129,.08); }
.fxe-field .fx-chip { cursor: default; user-select: all; }
.fxe-hint { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.fxe-err  { font-size: 12px; color: var(--brand-orange); margin-top: 8px; display: flex; gap: 6px; align-items: baseline; }

.fxe-prev { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface); }
.fxe-prev .lbl { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.fxe-prev select { font-size: 12px; padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.fxe-prev .val { margin-left: auto; font-size: 17px; font-weight: 600; }
.fxe-prev .val small { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 6px; }

.fxv { display: flex; flex-direction: column; max-height: 430px; }
.fxv-search { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.fxv-search input { width: 100%; font-size: 13px; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); outline: none; }
.fxv-list { overflow-y: auto; padding: 6px 0 10px; }
.fxv-grp { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: 10px 14px 4px; }
.fxv-item { display: flex; align-items: baseline; gap: 8px; padding: 5px 14px; cursor: pointer; font-size: 13px; }
.fxv-item:hover { background: rgba(2,3,129,.05); }
.fxv-item .k { margin-left: auto; font-size: 10.5px; color: var(--muted); font-family: ui-monospace, monospace; }
.fxe-foot { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); align-items: center; }
.fxe-foot .spacer { flex: 1; }

/* ── P5 (ENTWURF_P5_POSITIONSHERKUNFT.md): Positions-Grössen — eBKP-Filter-Chips.
   Eigene Klasse statt der sonst hier üblichen Inline-Styles (gk-chip/gfa-Muster), weil die
   Ausschluss-Variante eine eigene Optik braucht, die eine Inline-style-Zeile nicht überschreiben
   könnte (Inline schlägt jede externe Regel). */
.gep-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--tile);
  border: 1px solid var(--border); border-radius: 14px; padding: 3px 6px 3px 10px; font-size: 12px; }
.gep-chip.gep-chip-excl { background: rgba(254,71,8,.07); color: var(--brand-orange); border-color: rgba(254,71,8,.22); }
