:root {
  --bg: #0b1220;
  --bg-soft: #131c2e;
  --card: #182233;
  --card-2: #1f2c42;
  --line: #2a3852;
  --text: #eaf0f9;
  --muted: #93a1bb;
  --accent: #3b82f6;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* hidden zuverlässig durchsetzen: sonst überschreibt z. B. .modal{display:flex}
   das HTML-hidden-Attribut → unsichtbares Modal liegt über der ganzen Seite. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(150px + var(--safe-bottom));
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: rgba(11,18,32,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__title { margin: 0; font-size: 20px; font-weight: 700; }
.iconbtn {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 8px 10px; font-size: 16px; cursor: pointer;
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Sichtbarer Fokus für Tastatur-/Switch-Control-Bedienung (WCAG 2.4.7) */
:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Deaktivierte Buttons (z. B. während des Speicherns) */
.btn:disabled, .btn[aria-busy="true"] {
  opacity: .6; cursor: progress; pointer-events: none;
}

/* View */
.view { padding: 16px; max-width: 720px; margin: 0 auto; }
.loading { color: var(--muted); text-align: center; padding: 40px 0; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.card__row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card__title { font-weight: 600; font-size: 16px; }
.card__sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.card__meta { color: var(--muted); font-size: 12px; }

.section-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 18px 4px 8px;
}

/* KPI grid (Dashboard) */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi {
  background: linear-gradient(160deg, var(--card-2), var(--card));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.kpi__value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.kpi__label { font-size: 12px; color: var(--muted); }
.kpi--good .kpi__value { color: var(--accent-2); }
.kpi--bad .kpi__value { color: var(--danger); }

/* Badges */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; background: var(--card-2); color: var(--muted);
}
.badge--offen { background: #3a2c10; color: var(--warn); }
.badge--bezahlt, .badge--angenommen { background: #0f2e1c; color: var(--accent-2); }
.badge--ueberfaellig, .badge--abgelehnt { background: #3a1414; color: var(--danger); }
.badge--teilbezahlt { background: #11233d; color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  background: var(--accent); color: #fff; border: none; border-radius: 12px;
  padding: 11px 16px; font-size: 15px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn--ghost { background: var(--card); border: 1px solid var(--line); color: var(--text); }
.btn--sm { width: auto; padding: 7px 12px; font-size: 13px; }
.btn--danger { background: var(--danger); }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }

/* Forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; color: var(--text); font-size: 16px;
}
.field textarea { min-height: 90px; resize: vertical; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty__big { font-size: 40px; }

/* Mic */
.mic {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(82px + var(--safe-bottom));
  width: 68px; height: 68px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 28px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(59,130,246,.45); z-index: 30;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s ease, background .2s ease;
}
.mic:active { transform: translateX(-50%) scale(.94); }
.mic.is-recording { background: var(--danger); animation: pulse 1.4s infinite; }
.mic.is-busy { background: var(--warn); }
/* Auf reinen Konfigurationsseiten (lange Formulare, kein Sprachbedarf) den
   schwebenden Mic-Button ausblenden, damit er keine Felder überlagert. */
#view[data-seite="einstellungen"] ~ .mic,
#view[data-seite="benutzer"] ~ .mic { display: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239,68,68,.55); }
  70% { box-shadow: 0 0 0 18px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

/* Statusbar (Feedback) */
.statusbar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(160px + var(--safe-bottom));
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; z-index: 40; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.statusbar small { color: var(--muted); display: block; margin-top: 4px; }
.statusbar.is-error { border-color: var(--danger); }
.statusbar.is-ok { border-color: var(--accent-2); }

/* Nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: rgba(11,18,32,.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  overflow-x: auto;
}
.nav__item {
  text-decoration: none; color: var(--muted); text-align: center;
  padding: 8px 4px 6px; font-size: 10px; display: flex; flex-direction: column; gap: 2px;
  min-width: 56px;
}
.nav__icon { font-size: 19px; }
.nav__item.is-active { color: var(--text); }
.nav__item.is-active .nav__icon { filter: drop-shadow(0 0 6px var(--accent)); }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end;
  background: rgba(0,0,0,.6);
}
.modal__box {
  background: var(--bg-soft); width: 100%; max-width: 720px; margin: 0 auto;
  border-radius: 20px 20px 0 0; border: 1px solid var(--line);
  padding: 16px 16px calc(20px + var(--safe-bottom));
  max-height: 88vh; overflow-y: auto;
}
.modal__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal__hint { color: var(--muted); font-size: 13px; margin: -6px 0 12px; }

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.tab {
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; white-space: nowrap; cursor: pointer;
}
.tab.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Bars (Statistik) */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar__row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar__label { width: 84px; color: var(--muted); flex-shrink: 0; }
.bar__track { flex: 1; background: var(--bg-soft); border-radius: 8px; height: 18px; overflow: hidden; }
.bar__fill { height: 100%; border-radius: 8px; }
.bar__fill--in { background: var(--accent-2); }
.bar__fill--out { background: var(--danger); }
.bar__val { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
