/* ==========================================================================
   TrackCalender Design System — "Klar & Blau"
   Pures CSS, keine Toolchain. Weiß-blaues Farbschema (Vorgabe Auftraggeber,
   überstimmt Spec-Abschnitt 9). Tokens als Custom Properties.
   Die öffentliche Buchungsseite überschreibt ausschließlich --brand-*.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Kühle, neutrale Grauskala auf Weiß */
  --n-0: #ffffff;
  --n-25: #fbfcfe;
  --n-50: #f6f8fb;
  --n-100: #eef1f6;
  --n-200: #e1e6ee;
  --n-300: #c8d0dd;
  --n-400: #9aa5b8;
  --n-500: #707d94;
  --n-600: #515d73;
  --n-700: #3a4457;
  --n-800: #252d3d;
  --n-900: #151b28;

  /* Primärblau — einziger Markenakzent */
  --brand-500: #2f6fed;
  --brand-600: #2159cb;
  --brand-700: #1a47a4;
  --brand-50: #ecf2fe;
  --brand-100: #d8e4fc;
  --brand-contrast: #ffffff;

  --ok-500: #2e9e6b;
  --ok-50: #e7f6ef;
  --warn-500: #d78f1f;
  --warn-50: #fbf2df;
  --danger-500: #d24949;
  --danger-50: #fbeaea;
  --info-500: #2f6fed;
  --info-50: #ecf2fe;

  --bg: var(--n-50);
  --bg-elevated: var(--n-0);
  --bg-sunken: var(--n-100);
  --text: var(--n-800);
  --text-muted: var(--n-500);
  --text-faint: var(--n-400);
  --border: var(--n-200);
  --border-strong: var(--n-300);

  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --shadow-sm: 0 1px 2px rgb(21 27 40 / 0.05);
  --shadow: 0 1px 3px rgb(21 27 40 / 0.06), 0 4px 12px rgb(21 27 40 / 0.05);
  --shadow-lg: 0 4px 8px rgb(21 27 40 / 0.06), 0 12px 32px rgb(21 27 40 / 0.12);

  /* System-Stack: kein Font-CDN (DSGVO), Geist-Mono-Ersatz über ui-monospace */
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;

  --transition: 150ms cubic-bezier(0.3, 0, 0.2, 1);
  color-scheme: light;
}

/* ---------- Reset & Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-weight: 650; letter-spacing: -0.015em; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
small, .text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
/* Uhrzeiten/Daten immer mono: 14 Zeitfelder untereinander muessen fluchten */
.mono, time { font-family: var(--font-mono); font-size: 0.94em; }
strong { font-weight: 600; }
::selection { background: var(--brand-100); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Buttons (Pillen) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 9px 18px; border-radius: 999px;
  border: 1px solid transparent; background: transparent;
  font-weight: 560; font-size: 14px; line-height: 1.2; cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), box-shadow var(--transition);
  white-space: nowrap; user-select: none; text-decoration: none !important;
}
.btn:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand-600); color: var(--brand-contrast); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-700); }
.btn-secondary { background: var(--bg-elevated); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { border-color: var(--n-400); background: var(--n-25); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--text); }
.btn-danger { background: var(--danger-500); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }
.btn-sm { padding: 5px 13px; font-size: 13px; }
.w-full { width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: var(--space-6); }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}
.card-header h2, .card-header h3 { margin: 0; }
.card-body { padding: var(--space-6); }
.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--n-25);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex; justify-content: flex-end; gap: var(--space-3);
}

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: var(--space-4); }
.label { font-size: 13px; font-weight: 580; color: var(--text); }
.hint { font-size: 12.5px; color: var(--text-muted); }
.error { font-size: 12.5px; color: var(--danger-500); }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 18%, transparent);
}
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger-500); }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.textarea { min-height: 110px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23707d94' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.checkbox { display: inline-flex; gap: var(--space-3); align-items: flex-start; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--brand-600); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 580;
  background: var(--bg-sunken); color: var(--text-muted);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-50); color: var(--ok-500); }
.badge-warn { background: var(--warn-50); color: var(--warn-500); }
.badge-danger { background: var(--danger-50); color: var(--danger-500); }
.badge-info { background: var(--info-50); color: var(--info-500); }
.badge-brand { background: var(--brand-50); color: var(--brand-600); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: 11px var(--space-4);
  font-size: 12px; font-weight: 620; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.table td { padding: 13px var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Tabs (Pillen) ---------- */
.tabs { display: flex; gap: var(--space-2); margin-bottom: var(--space-6); flex-wrap: wrap; }
.tab {
  padding: 7px 15px; border-radius: 999px; border: 1px solid transparent;
  background: none; color: var(--text-muted); font-weight: 560; font-size: 13.5px; cursor: pointer;
}
.tab:hover { background: var(--bg-sunken); color: var(--text); }
.tab.active { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand-100); }

/* ---------- Shell: Sidebar + Main ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg-elevated); border-right: 1px solid var(--border);
  padding: var(--space-4) var(--space-3);
  position: sticky; top: 0; height: 100vh;
}
.sidebar-logo { padding: var(--space-2) var(--space-3) var(--space-5); font-size: 17px; font-weight: 700; }
.sidebar-logo .name span { color: var(--brand-600); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-section {
  padding: var(--space-4) var(--space-3) var(--space-1);
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint);
}
.nav-link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px 12px; border-radius: 999px;
  color: var(--text-muted); font-weight: 550; font-size: 14px;
  border: none; background: none; cursor: pointer; text-decoration: none !important;
}
.nav-link:hover { background: var(--bg-sunken); color: var(--text); }
.nav-link.active { background: var(--brand-50); color: var(--brand-600); }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: var(--space-3); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); padding: 0 var(--space-6);
  background: var(--bg-elevated); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.page { padding: var(--space-8) var(--space-6); max-width: 1200px; width: 100%; margin: 0 auto; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); flex-wrap: wrap; }
.page-header .sub { color: var(--text-muted); font-size: 14px; margin-top: 2px; }

/* Account-Switcher */
.switcher {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 7px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-elevated);
  cursor: pointer; font-weight: 570; font-size: 13.5px; max-width: 230px;
}
.switcher:hover { border-color: var(--border-strong); background: var(--n-25); }
.switcher .acc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; z-index: 50;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px;
}
.dropdown-item {
  display: flex; width: 100%; align-items: center; gap: var(--space-2);
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 13.5px; text-align: left;
  background: none; border: none; cursor: pointer; text-decoration: none !important;
}
.dropdown-item:hover { background: var(--bg-sunken); }
.dropdown-item.active { background: var(--brand-50); color: var(--brand-600); font-weight: 600; }
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* ---------- Auth-Seiten ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: var(--space-6);
  background:
    radial-gradient(1100px 460px at 20% -10%, var(--brand-50), transparent 60%),
    var(--bg);
}
.auth-logo { display: flex; justify-content: center; margin-bottom: var(--space-6); font-size: 20px; font-weight: 700; }
.auth-logo span { color: var(--brand-600); }

/* ---------- Empty / Toast / Modal ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); padding: var(--space-10) var(--space-6); color: var(--text-muted); }
.empty h3 { color: var(--text); }
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--n-800); color: #fff; padding: 11px 18px; border-radius: 999px;
  box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 540;
  animation: toast-in 220ms cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.toast.error { background: var(--danger-500); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgb(21 27 40 / 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh var(--space-4) var(--space-4);
}
.modal {
  width: 100%; max-width: 560px; background: var(--bg-elevated);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); max-height: 84vh; display: flex; flex-direction: column;
}
.modal .card-body { overflow-y: auto; }
[x-cloak] { display: none !important; }

/* ---------- Utilities ---------- */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; } .gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
.grid { display: grid; gap: var(--space-4); } .grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.mt-2 { margin-top: var(--space-2); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); } .mb-6 { margin-bottom: var(--space-6); } .text-right { text-align: right; }
.mobile-only { display: none; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform var(--transition); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .mobile-only { display: inline-flex; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ==========================================================================
   Öffentliche Buchungsseite
   Eigener, sehr ruhiger Bereich: weisser Grund, Karten auf --n-25, keine
   Navigation. Ab Phase 8 überschreibt das Account-Branding nur die --brand-*.
   ========================================================================== */
.booking-page {
  /* --page-bg setzt das Branding im Kopf der Seite; ohne Branding bleibt Weiss. */
  min-height: 100vh; background: var(--page-bg, var(--n-0));
  display: flex; flex-direction: column; align-items: center;
  padding: var(--space-8) var(--space-4);
}
/* ?embed=1: die Seite steckt in einem fremden Rahmen - kein eigener Rand,
   kein voller Viewport, durchsichtiger Grund. */
.booking-page.is-embed { min-height: 0; padding: var(--space-4) var(--space-2); background: transparent; }
.booking-logo { max-height: 52px; margin-bottom: var(--space-6); }
.booking-shell { width: 100%; max-width: 980px; }
.booking-foot { margin-top: var(--space-8); text-align: center; }
.booking-card {
  background: var(--n-25); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow-sm);
}
.booking-grid { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: var(--space-4); align-items: start; }
.booking-brand { font-weight: 700; color: var(--brand-600); margin-bottom: var(--space-2); }
.booking-summary h1, .booking-done h1 { font-size: 21px; }
.booking-meta { color: var(--text-muted); font-size: 14px; display: flex; gap: var(--space-2); flex-wrap: wrap; }
.booking-context {
  border-left: 3px solid var(--brand-500); background: var(--n-0);
  border-radius: var(--radius-sm); padding: var(--space-3);
}
.booking-context.is-struck { border-left-color: var(--border-strong); text-decoration: line-through; color: var(--text-muted); }
.booking-picker { display: grid; grid-template-columns: 1fr minmax(220px, 300px); gap: var(--space-6); }
.booking-empty { text-align: center; color: var(--text-muted); }
.booking-warning {
  background: var(--warn-50); border: 1px solid var(--warn-500);
  border-radius: var(--radius); padding: var(--space-3); margin-bottom: var(--space-4);
}
.booking-done { text-align: center; }

/* Monatskalender, Montag zuerst */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: 12px; color: var(--text-faint); padding-bottom: var(--space-1); }
.cal-day {
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 1; border-radius: 999px; border: 1px solid transparent;
  background: transparent; color: var(--text-faint); font-variant-numeric: tabular-nums;
  font-size: 14px; cursor: default;
}
.cal-day.is-muted { opacity: 0.35; }
button.cal-day.is-open { background: var(--brand-50); color: var(--brand-600); font-weight: 600; cursor: pointer; }
button.cal-day.is-open:hover { background: var(--brand-100); }
button.cal-day.is-selected { background: var(--brand-600); color: var(--brand-contrast); }
.cal-day:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* Slot-Pillen: ab 12 Slots zweispaltig, damit die Liste nicht ins Endlose läuft */
.slot-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-2); }
.slot-grid.is-dense { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.slot-pill {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--brand-100); background: var(--n-0); color: var(--brand-600);
  font-weight: 560; transition: background var(--transition), border-color var(--transition);
}
.slot-pill:hover { background: var(--brand-50); border-color: var(--brand-500); }
.slot-pill.is-selected { background: var(--brand-600); color: var(--brand-contrast); border-color: var(--brand-600); }
.slot-pill:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.slot-seats { font-size: 11px; color: var(--text-muted); }
.slot-skeleton {
  display: block; height: 38px; border-radius: 999px; margin-bottom: var(--space-2);
  background: linear-gradient(90deg, var(--n-100), var(--n-50), var(--n-100));
  background-size: 200% 100%; animation: slot-shimmer 1.2s linear infinite;
}
@keyframes slot-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (max-width: 860px) {
  .booking-grid, .booking-picker { grid-template-columns: 1fr; }
}

/* ---------- Auswertung (Phase 9) ---------- */
/* Balken statt Diagrammbibliothek: die Auswertung zeigt Anteile, und ein
   Anteil ist eine Breite. Kein JS, kein CDN, keine dritte Abhaengigkeit.
   Bewusst ohne Uebergaenge - Zahlen sollen dastehen, nicht auffahren. */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: var(--space-4); }
.kpi { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); box-shadow: var(--shadow-sm); }
.kpi .k-label { font-size: 12.5px; color: var(--text-muted); }
.kpi .k-value { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--text-faint); }
.delta { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok-500); }
.delta.down { color: var(--danger-500); }
.delta.flat { color: var(--text-faint); }

.bar-row { display: grid; grid-template-columns: minmax(100px, 190px) 1fr minmax(72px, auto); gap: var(--space-3); align-items: center; }
.bar-row + .bar-row { margin-top: var(--space-2); }
.bar-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--bg-sunken); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { background: var(--brand-600); height: 100%; border-radius: 999px; }
.bar-fill.is-soft { background: var(--brand-100); }
.bar-value { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-muted); text-align: right; }

/* Tageszeiten: 24 Saeulen, Achse darunter */
.hist { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; align-items: end; height: 120px; }
.hist .col { background: var(--brand-100); border-radius: var(--radius-xs) var(--radius-xs) 0 0; min-height: 2px; }
.hist .col.is-peak { background: var(--brand-600); }
.hist-axis { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; margin-top: 4px; font-size: 10px; color: var(--text-faint); text-align: center; }

.row-worst { background: var(--danger-50); }
.sort-btn { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.sort-btn:hover { color: var(--brand-600); }
