/* Aventus Rechnungen — Design 2.0 „wie Revolut“ (SPEC §16): dunkel zuerst, wenige große Zahlen, eine Karte pro Aussage,
   Listen statt Tabellen, keine Rahmen, keine Schatten, nichts bewegt sich ohne Grund. Bausteine: .tile, .list/.row,
   .segment, .tabs, .pill-*, .progress, .card. Beschreibung mit Beispielen in static/DESIGN.md. Abstände 8 / 12 / 16 / 20 / 28 px. */

/* ---------- Tokens: dunkel ist Standard ---------- */
:root {
  --bg: #121214;
  --surface: #1c1c21;         /* Karten, ohne Rahmen */
  --surface-2: #26262d;       /* Eingabefelder, Segment-Hintergrund, Hover */
  --surface-3: #34343d;       /* aktiver Segment-Knopf, Button-Hover */
  --text: #f2f2f5;
  --text-muted: #8e8e98;      /* ≥ 4,5:1 auf --surface und --grey-soft */
  --text-muted-strong: #a4a4ae; /* gedämpfter Text auf --surface-3 (Segment in Karten): ≥ 4,5:1 */
  --border: #2a2a31;          /* nur Haarlinien zwischen Zeilen und die gestrichelte Ablagefläche */
  --accent: #ff4fa3;          /* Pink: Primär-Button, aktiver Tab, Fortschrittsbalken – sonst nichts */
  --accent-soft: #3a1a2e;
  --ok: #2fd27a;      --ok-soft: #163626;
  --warn: #f5a742;    --warn-soft: #3a2a14;
  --danger: #ff5c5c;  --danger-soft: #3b1d20;
  --info: #6ea3ff;    --info-soft: #1b2a45;
  --grey-soft: #26262d;
  /* Text AUF Akzent/OK/Danger-Flächen: dunkel, weil die dunklen Akzenttöne hell sind */
  --on-accent: #121214; --on-ok: #121214; --on-danger: #121214;
  --radius: 16px;             /* Karten, Listen, Kacheln */
  --radius-sm: 12px;          /* Buttons, Eingabefelder, Segment */
  --radius-xs: 8px;
  --shadow: none;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 220px;
  --page-w: 1000px;
  color-scheme: dark;
}
/* Hell: nur wenn das System hell ist (und nichts anderes gewählt wurde) oder ausdrücklich gewählt */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f4f6; --surface: #ffffff; --surface-2: #f0f0f3; --surface-3: #e4e4e9; --text: #1a1a1a; --text-muted: #66666e; --text-muted-strong: #5c5c64;
    --border: #e4e4e9; --accent: #b8005f; --accent-soft: #fce8f1;
    --ok: #15703f; --ok-soft: #dff5e8; --warn: #9a4f00; --warn-soft: #fff0dc;
    --danger: #c0262d; --danger-soft: #fde4e5; --info: #1f5fbf; --info-soft: #e3ecfb; --grey-soft: #ececf0;
    --on-accent: #ffffff; --on-ok: #ffffff; --on-danger: #ffffff;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f4f6; --surface: #ffffff; --surface-2: #f0f0f3; --surface-3: #e4e4e9; --text: #1a1a1a; --text-muted: #66666e; --text-muted-strong: #5c5c64;
  --border: #e4e4e9; --accent: #b8005f; --accent-soft: #fce8f1;
  --ok: #15703f; --ok-soft: #dff5e8; --warn: #9a4f00; --warn-soft: #fff0dc;
  --danger: #c0262d; --danger-soft: #fde4e5; --info: #1f5fbf; --info-soft: #e3ecfb; --grey-soft: #ececf0;
  --on-accent: #ffffff; --on-ok: #ffffff; --on-danger: #ffffff;
  color-scheme: light;
}

/* ---------- Basis ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.4;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; } h3 { font-size: 14px; }
.muted { color: var(--text-muted); } .small { font-size: 13px; } .mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.danger { color: var(--danger); } .ok { color: var(--ok); }
[hidden], .is-hidden { display: none !important; }
/* Textlinks: gedämpft und fett, Pink bleibt dem Primär-Button vorbehalten */
.link { color: var(--text-muted); font-weight: 600; cursor: pointer; background: none; border: 0; padding: 0; font: inherit; font-weight: 600; }
.link:hover { color: var(--text); }
.ico, .nav-icon svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round; display: block; }

/* ---------- Layout: Sidebar (Desktop) / wischbare untere Leiste (Handy) mit denselben zehn Einträgen (§16.2) ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; padding: 24px 12px 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 20px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid;
  place-items: center; font-weight: 800; font-size: 18px; }
.brand-name { font-weight: 700; line-height: 1.05; } .brand-name small { font-weight: 500; color: var(--text-muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav .nav-btn { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-muted);
  font-weight: 600; background: transparent; border: 0; font-family: inherit; font-size: inherit; cursor: pointer; text-align: left; width: 100%; }
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active { background: var(--surface); color: var(--text); }
.nav-icon { display: inline-flex; justify-content: center; align-items: center; }
.nav-short { display: none; }                 /* Kurzlabel nur in der Handy-Leiste */
.nav .nav-mobile { display: none; }           /* Theme und Abmelden: in der Handy-Leiste die letzten zwei Einträge, am Desktop im Fuß */
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 12px 0; font-size: 12px; color: var(--text-muted); }
.sidebar-theme .segment { display: flex; width: 100%; }
.sidebar-theme .segment-btn { flex: 1 1 0; padding: 6px 4px; }
.sidebar-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.sidebar-user-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .btn { flex: 0 0 auto; }
.main { min-width: 0; padding: 0 28px 56px; }
.page { max-width: var(--page-w); margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 28px 0 20px; }
.page-title { font-size: 24px; font-weight: 700; }
/* Kopf so hoch wie ein Knopf oben rechts: blendet eine Seite ihren Primär-Knopf je Reiter aus (E-Mails: „Alle ausstehenden
   senden“ nur unter Ausstehend), sprang der Inhalt sonst um 4 px (UI-Durchgang 16.10.) */
.page-head-main { min-height: 38px; display: flex; flex-direction: column; justify-content: center; }
.back-link { display: inline-block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.back-link:hover { color: var(--text); }
.page-action { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.view { display: flex; flex-direction: column; gap: 12px; }
.view-inner { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
#banner { margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.section-title { font-size: 17px; font-weight: 650; margin: 12px 0 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 12px; }
.section-head .section-title { margin: 0; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  /* Untere Leiste: fest am Rand, alle Einträge 72 px breit, horizontal wischbar (Scroll-Snap), ohne sichtbaren Scrollbalken;
     der aktive Eintrag wird vom Router in den sichtbaren Bereich gescrollt */
  .sidebar { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; flex-direction: row; padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--bg); border-top: 1px solid var(--border); z-index: 10; overflow: visible; }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; gap: 0; padding: 6px 8px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; -ms-overflow-style: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a, .nav .nav-btn { flex: 0 0 72px; width: 72px; min-width: 0; flex-direction: column; justify-content: center; gap: 4px; font-size: 10.5px;
    letter-spacing: -.01em; padding: 4px 0 6px; border-radius: var(--radius-xs); scroll-snap-align: center; text-align: center; }
  .nav .nav-mobile { display: flex; }
  .nav a:hover, .nav a.active, .nav .nav-btn:hover { background: transparent; }
  .nav-icon { padding: 3px 11px; border-radius: 10px; }
  .nav a.active .nav-icon { background: var(--surface-2); }
  .nav-short { display: block; }
  .nav-short + .nav-label { display: none; }
  .nav-label, .nav-short { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { padding: 0 16px calc(88px + env(safe-area-inset-bottom, 0px)); }
  .page-head { padding: 20px 0 14px; }
  .page-title { font-size: 24px; }
}

/* ---------- Karten und Raster ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 15px; }
.card-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-5, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .grid-3, .grid-4, .grid-5 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 440px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-2.keep { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* zwei Kacheln nebeneinander auf schmalen Handys: enger gesetzt, Zahl kleiner und ohne Umbruch */
  .grid-2.keep .tile { padding: 16px; }
  .grid-2.keep .tile-value { font-size: 24px; white-space: nowrap; }
  .grid-2.keep .tile-label, .grid-2.keep .tile-sub { font-size: 12px; }
}

/* Kachel: Label 13 px gedämpft, Zahl 30 px fett ohne Cent, Delta darunter oder daneben, optional Körper (Diagramm, Balken) */
.tile { background: var(--surface); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 4px;
  min-width: 0; color: inherit; }
a.tile:hover, .tile.clickable:hover { background: var(--surface-2); cursor: pointer; }
.tile-label { font-size: 13px; color: var(--text-muted); }
.tile-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tile-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile-value.danger { color: var(--danger); } .tile-value.ok { color: var(--ok); }
.tile-delta { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.tile-delta.danger { color: var(--danger); } .tile-delta.ok { color: var(--ok); }
/* Halbe Kacheln (zwei nebeneinander): Delta unter der Zahl, wie im Vorbild – nur die breite Kachel hat es daneben */
.grid-2 .tile-head { flex-direction: column; align-items: flex-start; gap: 2px; }
.tile-sub { font-size: 13px; color: var(--text-muted); }
.tile-sub.danger { color: var(--danger); }
.tile-body { margin-top: 12px; }
.spark { position: relative; height: 110px; } .spark-sm { height: 64px; }
.spark canvas { display: block; width: 100%; height: 100%; }
/* Alte Kennzahl-Kachel (.card.stat) sieht aus wie .tile */
.stat .label { font-size: 13px; color: var(--text-muted); }
.stat .value { font-size: 30px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.15; }
.stat .sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat.danger .value { color: var(--danger); } .stat.ok .value { color: var(--ok); } .stat.accent .value { color: var(--accent); }

/* Liste: eine Karte, Zeilen mit Titel/Untertitel links und Betrag/Status rechts, Haarlinie dazwischen, Zeile klickbar */
.list { background: var(--surface); border-radius: var(--radius); padding: 4px 0; overflow: hidden; min-width: 0; }
.list .empty { padding: 20px; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 20px; color: inherit; min-width: 0; width: 100%;
  text-align: left; background: transparent; border: 0; font: inherit; }
.row + .row, .row + .list-more { border-top: 1px solid var(--border); }
a.row, .row.clickable, button.row { cursor: pointer; }
a.row:hover, .row.clickable:hover, button.row:hover { background: var(--surface-2); }
.row-main { flex: 1 1 auto; min-width: 0; }
.row-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; }
.row-amount { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.row-amount.danger { color: var(--danger); } .row-amount.ok { color: var(--ok); }
.row-right { font-size: 12px; color: var(--text-muted); }
.row-right.danger { color: var(--danger); } .row-right.ok { color: var(--ok); }
.row-chevron { flex: 0 0 auto; color: var(--text-muted); }
.row-lead { flex: 0 0 auto; display: flex; align-items: center; }
.list-more { display: block; width: 100%; text-align: center; padding: 12px; font-size: 13px; font-weight: 600; color: var(--text-muted);
  background: transparent; border: 0; font-family: inherit; cursor: pointer; }
.list-more:hover { color: var(--text); background: var(--surface-2); }
@media (max-width: 600px) { .row { padding: 12px 16px; } .list .empty { padding: 16px; } }

/* Segment-Schalter (Zeitraum, Zusammen | Pro Person, Offen | Bezahlt | Alle) */
.segment { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; max-width: 100%; }
.segment-btn { border: 0; background: transparent; color: var(--text-muted); padding: 7px 14px; border-radius: 10px; font: inherit;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.segment-btn:hover { color: var(--text); }
.segment-btn.active { background: var(--surface-3); color: var(--text); }
.segment-sm .segment-btn { padding: 5px 10px; font-size: 12px; }
.card .segment, .list .segment { background: var(--surface-3); }
/* In Karten liegt das Segment auf --surface-3: dort reicht --text-muted nicht für 4,5:1 → etwas hellerer (dunkel) bzw. dunklerer (hell) Ton */
.card .segment-btn, .list .segment-btn { color: var(--text-muted-strong); }
.card .segment-btn:hover, .list .segment-btn:hover { color: var(--text); }
.card .segment-btn.active, .list .segment-btn.active { background: var(--surface); color: var(--text); }
/* Schmale Handys: Segmente füllen die Breite; passen die Beschriftungen nicht hinein, wischt das Segment in sich (die Seite bleibt
   so breit wie der Bildschirm) */
@media (max-width: 440px) {
  .segment { display: flex; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
  .segment::-webkit-scrollbar { display: none; }
  .segment-btn { flex: 1 1 0; padding-left: 8px; padding-right: 8px; }
}

/* Tabs (Unterbereiche innerhalb einer Seite) – der aktive Tab trägt das Pink */
.tabs { display: flex; gap: 2px; margin: -6px 0 4px; overflow-x: auto; }
.tab { padding: 8px 14px; border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 600; font-size: 14px; white-space: nowrap;
  border: 0; background: transparent; font-family: inherit; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.tab-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* Statuspillen 11 px (.badge-* ist dasselbe, für ältere Ansichten) */
.pill, .badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.6;
  white-space: nowrap; vertical-align: middle; }
.pill-open, .badge-open, .pill-draft, .badge-draft, .pill-grey, .badge-grey, .pill-replaced, .badge-replaced, .pill-cancelled, .badge-cancelled {
  background: var(--grey-soft); color: var(--text-muted); }
.pill-overdue, .badge-overdue, .pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-partial, .badge-partial, .pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-paid, .badge-paid, .pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-provisional, .badge-provisional { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pill-info, .badge-info { background: var(--info-soft); color: var(--info); }
.pill-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); vertical-align: middle; }
.pill-dot.ok { background: var(--ok); } .pill-dot.danger { background: var(--danger); } .pill-dot.accent { background: var(--accent); }

/* Fortschritt: 6 px, abgerundet; Pink für Ziele, Grün/Rot für Cashflow-Balken */
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; width: 100%; }
.card .progress, .tile .progress, .list .progress { background: var(--surface-3); }
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; }
.progress-bar.ok { background: var(--ok); } .progress-bar.danger { background: var(--danger); } .progress-bar.muted { background: var(--text-muted); }
.progress-lg { height: 10px; }
.progress + .progress { margin-top: 8px; }

/* ---------- Buttons, Eingaben ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: var(--surface-2); color: var(--text);
  padding: 9px 16px; border-radius: var(--radius-sm); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); filter: brightness(1.08); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.card .btn, .list .btn, .modal .btn { background: var(--surface-3); }
.card .btn-primary, .list .btn-primary, .modal .btn-primary { background: var(--accent); }
.card .btn-ghost, .list .btn-ghost, .modal .btn-ghost { background: transparent; }
.card .btn-danger, .list .btn-danger, .modal .btn-danger { background: var(--danger-soft); }

.input, select.input, textarea.input { width: 100%; border: 0; background: var(--surface-2); color: var(--text); padding: 10px 12px;
  border-radius: var(--radius-sm); font: inherit; font-size: 15px; }
.card .input, .modal .input, .list .input, .card select.input, .modal select.input, .card textarea.input, .modal textarea.input { background: var(--surface-3); }
.input:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent); }
.input::placeholder { color: var(--text-muted); }
textarea.input { min-height: 90px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
/* Sichtbarer Tastatur-Fokus für alles Klickbare: 2 px Akzent, 2 px Abstand */
.btn:focus-visible, .chip:focus-visible, .nav a:focus-visible, .tab:focus-visible, .segment-btn:focus-visible, .row:focus-visible,
.tile:focus-visible, .list-more:focus-visible, .link:focus-visible, .input:focus-visible, select.input:focus-visible,
textarea.input:focus-visible, .check input:focus-visible, .table tr.clickable:focus-visible, a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
.row:focus-visible, .table tr.clickable:focus-visible { outline-offset: -2px; }
/* Schmale Handys: das Segment wischt in sich (overflow) – der Ring liegt innen, sonst kappt ihn der Rand */
@media (max-width: 440px) { .segment .segment-btn:focus-visible { outline-offset: -2px; } }

/* Tabellen nur noch für Altbestand und Formulare – Listen sind der Standard (§16.1) */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--text-muted); font-weight: 600; padding: 8px 10px;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; } .table tr.clickable:hover td { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Chips (ältere Filter) sehen aus wie lose Segment-Knöpfe */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--text-muted); font-family: inherit; }
.chip:hover { color: var(--text); }
.chip.active { background: var(--surface-3); color: var(--text); }
.card .chip { background: var(--surface-3); } .card .chip.active { background: var(--text); color: var(--bg); }

.empty { padding: 28px 20px; text-align: center; color: var(--text-muted); }
.hint { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; }
.hint.warn { background: var(--warn-soft); color: var(--warn); }
.hint.danger { background: var(--danger-soft); color: var(--danger); }
.hint.ok { background: var(--ok-soft); color: var(--ok); }
.hint .mono, .kv .mono { overflow-wrap: anywhere; }

/* Toasts: nur ein kurzes Einblenden (Opazität), keine Bewegung. Sie sind nicht klickbar (pointer-events: none) – sonst
   schluckt ein Toast über dem Dialog-Fuß den nächsten Klick auf „Speichern“. */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; pointer-events: none; }
@media (max-width: 900px) {
  .toasts { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .toast { max-width: none; }
}
.toast { background: var(--text); color: var(--bg); padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  max-width: 360px; animation: toast-fade .18s ease-out; }
.toast.error { background: var(--danger); color: var(--on-danger); }
.toast.ok { background: var(--ok); color: var(--on-ok); }
@keyframes toast-fade { from { opacity: 0; } to { opacity: 1; } }

/* Dialog: mittig, auf dem Handy als Blatt von unten */
.modal-root:empty { display: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--surface); border-radius: 20px; width: min(640px, 100%); max-height: 90vh; overflow: auto; padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.modal-head h2 { font-size: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@media (max-width: 600px) {
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal { border-radius: 20px 20px 0 0; max-height: 92vh; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .modal-foot .btn { flex: 1 1 0; }
}

.dropzone { border: 1px dashed var(--border); border-radius: var(--radius); padding: 20px; text-align: center; color: var(--text-muted);
  cursor: pointer; }
.dropzone.over { border-color: var(--accent); color: var(--accent); }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--text-muted); } .kv dd { margin: 0; }
/* Lade-Spinner: die einzige Bewegung – sie zeigt, dass gerade geladen wird */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
pre.copybox { background: var(--surface-2); padding: 12px 14px; border-radius: var(--radius-sm); white-space: pre-wrap;
  font-family: var(--font); margin: 0; font-size: 14px; }
.card pre.copybox { background: var(--surface-3); }

/* ---------- Als App installiert (SPEC §23.2): Statusleiste, Notch, Home-Balken ----------
   viewport-fit=cover lässt die Seite bis an die Displayränder reichen; im normalen Browser-Tab sind alle env(safe-area-inset-*) 0,
   dort ändert sich nichts. Auf dem iPhone (Statusleiste „black-translucent“ = weiße Uhrzeit über der Seite) liegt oben ein fester
   Streifen in der dunklen Seitenfarbe: die Uhrzeit bleibt auch im hellen Design lesbar, gescrollter Inhalt läuft nicht darunter durch. */
@media (display-mode: standalone) {
  body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top, 0px);
    background: #121214; z-index: 60; pointer-events: none; }
}
@media (min-width: 901px) {
  .app { grid-template-columns: calc(var(--sidebar-w) + env(safe-area-inset-left, 0px)) minmax(0, 1fr); }
  .sidebar { padding: calc(24px + env(safe-area-inset-top, 0px)) 12px calc(20px + env(safe-area-inset-bottom, 0px))
    calc(12px + env(safe-area-inset-left, 0px)); }
  .main { padding-right: calc(28px + env(safe-area-inset-right, 0px)); padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
  .page-head { padding-top: calc(28px + env(safe-area-inset-top, 0px)); }
  .toasts { right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 900px) {
  .page-head { padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
  .main { padding-left: calc(16px + env(safe-area-inset-left, 0px)); padding-right: calc(16px + env(safe-area-inset-right, 0px)); }
  .sidebar { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
  .toasts { left: calc(16px + env(safe-area-inset-left, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); }
}
@media (min-width: 601px) {
  .modal-backdrop { padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
}
@media (max-width: 600px) {
  .modal { max-height: min(92vh, calc(100vh - env(safe-area-inset-top, 0px) - 16px)); }
}

/* ---------- „Was ist das?“ (SPEC §28, classifyDialog / kindSelect in app.js) ---------- */
.clf-form { display: flex; flex-direction: column; gap: 12px; }
.clf-kv { display: flex; flex-direction: column; }
.clf-kv:empty, .clf-hint:empty { display: none; }
.clf-kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.clf-kv-row:first-child { border-top: 0; padding-top: 0; }
.clf-kv-row > span:last-child { text-align: right; font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.clf-links { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
select.clf-kind, select.clf-sub { min-width: 0; }

/* ---------- View-spezifisch (Views hängen hier an) ---------- */
