/* Bussenrechner Schweiz — Designsystem "Accessible & Ethical" (ui-ux-pro-max).
   Hell ist der Standard, Dunkel folgt automatisch der Geräte-Einstellung.
   Eine Flächenebene, Listen statt Kachelwände, Farbe nie als einziges Signal. */

:root {
  color-scheme: light dark;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --primary: #1e3a8a;
  --primary-soft: #e0e7ff;
  --on-primary: #ffffff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --tabbar-bg: rgba(255, 255, 255, 0.92);
  --appbar-bg: rgba(248, 250, 252, 0.92);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);

  --radius: 12px;
  --tab-h: 58px;
  --appbar-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #131c2e;
    --surface-2: #1b2640;
    --border: #243049;
    --text: #eef2ff;
    --text-2: #a5b0cb;
    --text-3: #8c98b8;
    --primary: #6b9bff;
    --primary-soft: rgba(107, 155, 255, 0.16);
    --on-primary: #0b1220;
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, 0.14);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.14);
    --bad: #f87171;
    --bad-soft: rgba(248, 113, 113, 0.14);
    --tabbar-bg: rgba(19, 28, 46, 0.92);
    --appbar-bg: rgba(11, 18, 32, 0.92);
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: none;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
button { font-family: inherit; font-size: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

@media (prefers-reduced-motion: no-preference) {
  .zeile, .kachel, .btn, .tab, .icon-btn, .segment button, .folge > summary, .aufklapper > summary {
    transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
  }
}

.icon-svg { display: inline-flex; flex: 0 0 auto; }
.icon-svg svg { width: 1.25em; height: 1.25em; display: block; }

#app {
  min-height: 100vh;
  padding-top: var(--safe-t);
  padding-bottom: calc(var(--tab-h) + var(--safe-b) + 24px);
}
.screen { padding: 0 16px; max-width: 640px; margin: 0 auto; }

/* ---------- Titel & Text ---------- */
.gross-titel { font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; margin: 16px 0 16px; }
.h1 { font-size: 22px; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; margin: 8px 0 16px; }
.abschnitt { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); margin: 28px 4px 8px; }
.abschnitt-zeile { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 4px 8px; }
.abschnitt-zeile .abschnitt { margin: 0; }
.text-2 { color: var(--text-2); }
.klein { font-size: 13px; color: var(--text-3); line-height: 1.45; }
.fliesstext { font-size: 16px; line-height: 1.55; color: var(--text); margin: 0; }
.link-btn {
  background: none; border: none; padding: 10px 4px; margin: -10px -4px; cursor: pointer;
  color: var(--primary); font-weight: 600; font-size: 15px;
}

/* ---------- App-Leiste (Unterseiten) ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 4px;
  min-height: var(--appbar-h); padding: calc(var(--safe-t)) 8px 0;
  margin: calc(-1 * var(--safe-t)) 0 0;
  background: var(--appbar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.appbar-titel {
  flex: 1; min-width: 0; font-size: 17px; font-weight: 600; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-width: 44px; min-height: 44px; padding: 0 8px;
  background: none; border: none; border-radius: 10px; cursor: pointer; color: var(--primary);
  font-size: 16px;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn .icon-svg svg { width: 22px; height: 22px; }
.icon-btn.aktiv { color: var(--warn); }
.appbar-platz { min-width: 44px; }

/* ---------- Suche ---------- */
.suchfeld {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0 6px 0 14px; min-height: 48px; box-shadow: var(--shadow);
}
.suchfeld:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.suchfeld .icon-svg { color: var(--text-3); }
.suchfeld input {
  flex: 1; min-width: 0; border: none; background: transparent; color: var(--text);
  font-size: 16px; font-family: inherit; padding: 12px 0; outline: none;
}
.suchfeld input::-webkit-search-cancel-button { -webkit-appearance: none; }
.suchfeld.gross { min-height: 56px; }
.suchfeld.gross input { font-size: 17px; }
.suchfeld .icon-btn { color: var(--text-3); }

/* ---------- Gruppierte Listen ---------- */
.gruppe {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.gruppe + .gruppe { margin-top: 12px; }
.zeile {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 52px; padding: 11px 14px; text-align: left;
  background: none; border: none; border-top: 1px solid var(--border); color: var(--text);
  cursor: pointer; text-decoration: none;
}
.gruppe > .zeile:first-child, .gruppe > :first-child .zeile { border-top: none; }
.zeile:active { background: var(--surface-2); }
.zeile.statisch { cursor: default; }
.zeile.statisch:active { background: none; }
.zeile-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 32px; height: 32px; border-radius: 8px; background: var(--primary-soft); color: var(--primary);
}
.zeile-icon .icon-svg svg { width: 19px; height: 19px; }
.zeile-icon.ok { background: var(--ok-soft); color: var(--ok); }
.zeile-icon.warn { background: var(--warn-soft); color: var(--warn); }
.zeile-icon.bad { background: var(--bad-soft); color: var(--bad); }
.zeile-text { flex: 1; min-width: 0; }
.zeile-titel { font-size: 16px; line-height: 1.35; }
.zeile-meta { font-size: 13px; line-height: 1.4; color: var(--text-2); margin-top: 2px; }
.zeile-wert { flex: 0 0 auto; font-size: 15px; font-weight: 600; color: var(--text); text-align: right; }
.zeile-pfeil { flex: 0 0 auto; color: var(--text-3); }
.zeile-pfeil .icon-svg svg { width: 18px; height: 18px; }
.mehr-zeile { color: var(--primary); font-weight: 600; font-size: 15px; }

/* ---------- Kacheln (nur "Häufig" auf Start) ---------- */
.kacheln { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kachel {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 88px; padding: 12px 6px; text-align: center; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); box-shadow: var(--shadow);
}
.kachel:active { background: var(--surface-2); }
.kachel .icon-svg { color: var(--primary); }
.kachel .icon-svg svg { width: 26px; height: 26px; }
.kachel-label { font-size: 13px; font-weight: 500; line-height: 1.25; }

/* ---------- Karten ---------- */
.karte {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.karte + .karte, .karte + .gruppe, .gruppe + .karte { margin-top: 12px; }
.gross-wert { font-size: 34px; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; margin: 4px 0; }
.label-klein { font-size: 13px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Urteil (Ampel) ---------- */
.urteil { border-radius: var(--radius); padding: 16px; border: 1px solid transparent; }
.urteil.ok { background: var(--ok-soft); }
.urteil.warn { background: var(--warn-soft); }
.urteil.bad { background: var(--bad-soft); }
.urteil-kopf { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.urteil-label { font-size: 17px; font-weight: 700; }
.urteil.ok .urteil-kopf { color: var(--ok); }
.urteil.warn .urteil-kopf { color: var(--warn); }
.urteil.bad .urteil-kopf { color: var(--bad); }
.urteil-kopf .icon-svg svg { width: 24px; height: 24px; }
.urteil .fliesstext { margin-top: 10px; }
.pill {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.4;
  background: var(--surface); color: var(--text-2); border: 1px solid var(--border);
}
.pill.gesetz { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.richtwert { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.pill.schaetzung { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

/* ---------- Folgen-Zeilen & Aufklapper ---------- */
.folge, .aufklapper { border-top: 1px solid var(--border); }
.gruppe > .folge:first-child, .gruppe > .aufklapper:first-child, .gruppe > .folge-statisch:first-child { border-top: none; }
.folge > summary, .aufklapper > summary, .folge-statisch {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 52px;
  cursor: pointer; list-style: none;
}
.folge-statisch { cursor: default; border-top: 1px solid var(--border); }
.folge > summary::-webkit-details-marker, .aufklapper > summary::-webkit-details-marker { display: none; }
.folge > summary:active, .aufklapper > summary:active { background: var(--surface-2); }
.folge-kopf { flex: 1; min-width: 0; }
.folge-typ { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }
.folge-titel { font-size: 15px; line-height: 1.35; color: var(--text-2); margin-top: 1px; }
.folge-wert { font-size: 17px; font-weight: 700; line-height: 1.3; margin-top: 3px; color: var(--text); }
.folge-body, .aufklapper-body { padding: 0 14px 14px 58px; font-size: 15px; line-height: 1.55; color: var(--text-2); }
.aufklapper-body { padding-left: 14px; }
.folge-body p, .aufklapper-body p { margin: 0 0 8px; }
.folge-fuss { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--text-3); }
.dreh { color: var(--text-3); flex: 0 0 auto; }
.dreh .icon-svg svg { width: 18px; height: 18px; }
@media (prefers-reduced-motion: no-preference) { .dreh { transition: transform 180ms ease; } }
details[open] > summary .dreh { transform: rotate(90deg); }
.aufklapper-titel { flex: 1; font-size: 16px; font-weight: 600; }
.aufklapper-meta { font-size: 13px; color: var(--text-3); }
.gesetz-block { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.gesetz-block:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.gesetz-block .gesetz-titel { font-weight: 600; color: var(--text); font-size: 15px; }
.gesetz-block .gesetz-text { font-size: 14px; line-height: 1.55; margin: 6px 0; white-space: pre-line; }
.liste { margin: 0; padding-left: 20px; }
.liste li { margin-bottom: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 48px; padding: 12px 16px; border: none; border-radius: var(--radius);
  background: var(--primary); color: var(--on-primary); font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.sekundaer { background: var(--surface); color: var(--primary); border: 1px solid var(--border); box-shadow: var(--shadow); }
.btn-reihe { display: flex; gap: 10px; margin-top: 12px; }
.btn-reihe .btn { flex: 1; }
.btn .icon-svg svg { width: 20px; height: 20px; }

/* ---------- Segment (Filter) ---------- */
.segment { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.segment button {
  flex: 1; min-height: 40px; border: none; border-radius: 8px; background: transparent;
  color: var(--text-2); font-size: 15px; font-weight: 500; cursor: pointer;
}
.segment button.aktiv { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12); }

/* ---------- Formulare ---------- */
.feld { margin-bottom: 16px; }
.feld:last-child { margin-bottom: 0; }
.feld label { display: block; font-size: 14px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.feld select, .feld input {
  width: 100%; min-height: 48px; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 16px; font-family: inherit;
}
.feld select:focus, .feld input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.feld .klein { margin-top: 6px; }

/* ---------- Hinweise & Leerzustände ---------- */
.hinweis {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--warn-soft); color: var(--text); border-radius: var(--radius);
  padding: 12px 14px; font-size: 15px; line-height: 1.5; margin-top: 12px;
}
.hinweis .icon-svg { color: var(--warn); margin-top: 1px; }
.hinweis.info { background: var(--primary-soft); }
.hinweis.info .icon-svg { color: var(--primary); }
.leer { text-align: center; color: var(--text-2); padding: 32px 16px; font-size: 15px; }
.leer .vorschlaege { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.vorschlag {
  min-height: 40px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--primary); font-weight: 500;
}
.lade { text-align: center; color: var(--text-3); padding: 32px 16px; font-size: 15px; }

/* ---------- Tab-Leiste ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: var(--tabbar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: none; color: var(--text-3); font-size: 11px; font-weight: 500; cursor: pointer; min-height: 44px;
}
.tab .icon-svg svg { width: 24px; height: 24px; }
.tab.aktiv { color: var(--primary); }

/* ---------- Bussenbuch ---------- */
.summen { display: grid; grid-template-columns: repeat(3, 1fr); }
.summe { padding: 14px 8px; text-align: center; border-left: 1px solid var(--border); }
.summe:first-child { border-left: none; }
.summe-zahl { font-size: 17px; font-weight: 700; }
.summe-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.status-btn {
  flex: 0 0 auto; min-height: 36px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  font-size: 13px; font-weight: 600; border: 1px solid var(--border); background: var(--surface);
}
.status-btn.offen { color: var(--warn); border-color: currentColor; }
.status-btn.bezahlt { color: var(--ok); border-color: currentColor; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4, 8, 16, 0.55); z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  background: var(--surface); border-radius: 18px 18px 0 0; width: 100%; max-width: 640px;
  max-height: 88vh; overflow-y: auto; padding: 22px 20px calc(20px + var(--safe-b));
}
.modal-sheet h2 { margin: 0 0 10px; font-size: 20px; }
.modal-sheet p { color: var(--text-2); line-height: 1.55; font-size: 15px; margin: 0 0 18px; }

.abstand { height: 12px; }

@media print {
  .tabbar, .appbar, .btn, .btn-reihe, .status-btn, .icon-btn, .suchfeld, .segment { display: none !important; }
  body, #app { background: #fff; color: #000; padding: 0; }
  .gruppe, .karte { border-color: #ccc; box-shadow: none; }
}
