:root {
  --bg: #13131f;
  --bg-raised: #1e1e2f;
  --line: rgba(255,255,255,0.07);
  --line-soft: rgba(255,255,255,0.05);
  --text: #e0e0f0;
  --text-dim: #a1a1aa;
  --text-dimmer: #71717a;
  --text-faint: #52525b;
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --ok: #34d399;
  --ok-deep: #10b981;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 16px;
  --radius-sm: 8px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[v-cloak] { display: none; }

/* ---------- Sticky Header + Page Tabs ---------- */
/* Header und Tab-Leiste haengen als EIN sticky Block zusammen, damit die
   Tab-Leiste nicht auf eine feste Header-Hoehe (top: 52px) angewiesen ist --
   der Header hat seit Phase 3 zwei Zeilen (Aktionen + ein-/ausklappbare
   Status-Pills), seine Hoehe variiert also. */

.sticky-top {
  position: sticky;
  top: 0;
  z-index: 200;
}

.sticky-header {
  background: rgba(19,19,31,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
}

.header-top-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.app-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

/* Dasselbe SVG wie das Favicon, links neben dem Titel (Befund 33). */
.app-logo { width: 20px; height: 20px; border-radius: 4px; display: block; }

.app-title {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
}

.toggle-arrow { color: var(--text-dimmer); font-size: 0.8rem; }

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sm {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.78rem;
  font-family: inherit;
  min-height: 32px;
  transition: all 0.2s;
}
.btn-sm:hover { border-color: var(--accent); color: var(--text); }

.refresh-select {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-family: inherit;
  min-height: 32px;
  cursor: pointer;
}
.refresh-select option { background: var(--bg-raised); color: var(--text); }
.refresh-countdown { font-size: 0.72rem; color: var(--text-faint); min-width: 32px; text-align: right; }

/* Ein-/ausklappbare Status-Pills (Klick auf den Titel) */
.sticky-header .status-bar {
  margin-top: 8px;
  overflow: hidden;
  max-height: 120px;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
}
.sticky-header .status-bar.collapsed { max-height: 0; opacity: 0; margin-top: 0; pointer-events: none; }

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
/* Die Pills im System-Status des Studiostatus-Dashboards stehen mittig
   (Befund 22); die Pills im Kopf bleiben linksbuendig. */
#gymStatusPills { justify-content: center; }

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-fail { background: var(--err); }
/* Neutral: Studios geschlossen, kein Fehler (Befund 35). */
.dot-idle { background: var(--text-faint); }
.live-dot.closed { background: var(--text-faint); }
.dot-actual { background: var(--accent); }
.dot-plan { background: var(--warn); }
.dot-trend { background: var(--accent); }
.dot-band { background: rgba(251,191,36,0.35); }

/* ---------- Status-Tab: Live-Belegung + Log-Viewer (Option 3 / Phase 1) ---------- */
/* Klassennamen 1:1 aus watchdog_html.sh uebernommen, Farbwerte auf die
   hiesigen Tokens gemappt. */

.live-banner { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.live-item {
  flex: 1;
  min-width: 130px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Geschlossen-Banner ist eine einzelne, volle Breite -- Punkt und Text
   sollen darin mittig stehen (Befund 36). Bei geoeffneten Studios bleibt
   es bei den drei linksbuendigen Karten nebeneinander. */
.live-item-closed { justify-content: center; text-align: center; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.live-dot.low { background: var(--ok); }
.live-dot.mid { background: var(--warn); }
.live-dot.high { background: var(--err); }
.live-label { font-size: 0.78rem; color: var(--text-dim); }
.live-value { font-size: 1.1rem; font-weight: 700; }

.log-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.log-controls select {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 11px;
  font-size: 0.85rem;
  cursor: pointer;
}
.log-controls select:focus { outline: none; border-color: var(--accent); }
.log-controls select option { background: var(--bg-raised); color: var(--text); }
.log-filter-input {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 11px;
  font-size: 0.85rem;
  flex: 1;
  min-width: 160px;
}
.log-filter-input:focus { outline: none; border-color: var(--accent); }
.log-filter-input::placeholder { color: var(--text-faint); }
.log-level-btns { display: flex; gap: 5px; }
.log-level-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text-dimmer);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  transition: all 0.2s;
}
.log-level-btn.active-info { background: rgba(59,130,246,.2); border-color: var(--accent); color: var(--accent-light); }
.log-level-btn.active-warn { background: rgba(251,191,36,.2); border-color: var(--warn); color: var(--warn); }
.log-level-btn.active-error { background: rgba(239,68,68,.2); border-color: var(--err); color: var(--err); }

.log-box {
  background: rgba(0,0,0,.3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  max-height: 480px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.76rem;
  line-height: 1.65;
}
.log-box pre { white-space: pre-wrap; word-break: break-all; margin: 0; }
.log-line { display: block; }
.log-line-hidden { display: none; }
.log-line-warn { color: var(--warn); }
.log-line-error { color: var(--err); }

/* ---------- Status-Tab: Tages-Karten, Heatmap, Vorhersage (Phase 2) ---------- */
/* Klassennamen wieder 1:1 aus watchdog_html.sh uebernommen, Farbwerte auf
   die hiesigen Tokens gemappt -- gleiches Vorgehen wie oben in Phase 1. */

.studio-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.studio-tab {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.studio-tab.active, .studio-tab:hover { background: rgba(59,130,246,.18); border-color: var(--accent); color: var(--text); }

.analyse-chart-wrap { height: 260px; margin-bottom: 20px; }

/* Flex statt Grid: eine unvollstaendige letzte Zeile (1-2 Karten nach dem
   Tagesfilter, 4 oder 5 Karten) soll mittig stehen -- Grid kann das nicht
   (Befund 9). Karten wachsen bis max-width, dann wird zentriert. */
.day-cards-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 16px; }
.day-card {
  flex: 1 1 300px;
  max-width: 400px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
/* Kartenkopf flach (5px Luft oben/unten, Befunde 24 und 30), Wochentag und
   Feiertag-Marker mittig (Befund 24). */
.day-header {
  background: rgba(255,255,255,0.04);
  padding: 5px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-bottom: 1px solid var(--line-soft);
}
/* Browser-Standard fuer h3 (margin 1em oben/unten) und die Zeilenhoehe 1.6
   machten den Kopf trotz 5px Innenabstand hoch (Befund 30, Nachtest 4/6). */
.day-header h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin: 0; line-height: 1.2; }
.day-content { padding: 14px 16px; }
.day-card .section { margin-bottom: 14px; }
.day-card .section:last-child { margin-bottom: 0; }
/* Auf .day-card gescoped: weiter unten gibt es ein globales .section-title
   (18px, fett) fuer die Chart-Abschnitte, das diese Regel sonst ueberschreibt. */
.day-card .section-title { font-size: 0.67rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dimmer); margin: 0 0 7px; font-weight: 600; }

.badge { font-size: 0.62rem; padding: 2px 8px; border-radius: var(--radius-pill); font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-holiday { background: rgba(251,191,36,.18); color: var(--warn); }
.badge-best { background: rgba(251,191,36,.15); color: var(--warn); font-size: 0.62rem; padding: 2px 6px; border-radius: var(--radius-pill); margin-left: 6px; }

.time-block {
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid;
}
.time-block:last-child { margin-bottom: 0; }
.time-block.optimal { background: rgba(59,130,246,.1); border-color: rgba(59,130,246,.2); }
.time-block.low { background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.2); }
.time-block.high { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.2); }
.time-block.best-slot { border-color: rgba(251,191,36,.4) !important; background: rgba(251,191,36,.07) !important; }
.time-range { font-weight: 500; font-size: 0.88rem; }
.block-right { display: flex; align-items: center; gap: 6px; }
.percentage { font-size: 0.78rem; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.time-block.optimal .percentage { background: rgba(59,130,246,.2); color: var(--accent-light); }
.time-block.low .percentage { background: rgba(16,185,129,.2); color: var(--ok); }
.time-block.high .percentage { background: rgba(239,68,68,.2); color: var(--err); }

.trend { font-size: 0.72rem; font-weight: 600; padding: 2px 5px; border-radius: 5px; }
.trend-down { background: rgba(16,185,129,.15); color: var(--ok); }
.trend-up { background: rgba(239,68,68,.15); color: var(--err); }
.trend-neutral { background: rgba(161,161,170,.15); color: var(--text-dim); }

/* Tabelle nur so breit wie ihr Inhalt und mittig -- mit width:100% landete
   der ganze Rest der Breite in der Stunden-Spalte "Uhr" (Befund 12). Bei
   schmalem Fenster scrollt .heatmap-wrap weiterhin seitlich. */
.heatmap-wrap { overflow-x: auto; margin-top: 6px; }
.heatmap { border-collapse: collapse; font-size: 0.8rem; width: max-content; margin: 0 auto; }
.heatmap th { padding: 5px 8px; color: var(--text-dimmer); font-weight: 600; text-align: center; border-bottom: 1px solid var(--line); }
/* Zweizeiliger Kopf und senkrechte "Uhrzeit"-Achse links (Befund 25); Zeilen
   flacher (Innenabstand oben/unten 4px bzw. 3px, Befund 31), Zellen breiter.
   Selektoren mit .heatmap davor, damit sie die .heatmap-th-Regel darueber
   schlagen. */
.heatmap .hm-corner { border-bottom: none; }
.heatmap .hm-group { padding-bottom: 3px; }
.heatmap .hm-axis { border-bottom: none; vertical-align: middle; padding: 0 6px 0 0; font-size: 0.72rem; }
.heatmap .hm-axis span { writing-mode: vertical-rl; }
.hour-label { color: var(--text-dimmer); padding: 3px 8px; text-align: right; font-size: 0.72rem; white-space: nowrap; }
.hm-cell { width: 52px; text-align: center; padding: 4px 4px; border-radius: 4px; font-weight: 600; cursor: default; }
.hm-empty { color: var(--text-faint); }
.hm-low { background: rgba(16,185,129,.25); color: var(--ok); }
.hm-mid { background: rgba(59,130,246,.2); color: var(--accent-light); }
.hm-high { background: rgba(239,68,68,.2); color: var(--err); }
.empty-state { color: var(--text-faint); font-size: 0.83rem; padding: 3px 0; }

/* ---------- Status-Tab: Filter, View-Toggle, Stats, Vorhersage-Controls (Phase 3) ---------- */
/* Wieder Klassennamen 1:1 aus watchdog_html.sh, Farben auf Tokens. */

.view-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.view-btns { display: flex; gap: 6px; }
.view-btn, .export-btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.13);
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  min-height: 38px;
  transition: all 0.2s;
}
.view-btn.active { background: rgba(59,130,246,0.18); border-color: var(--accent); color: var(--text); }
.export-btn { margin-left: auto; }
.export-btn:hover { background: rgba(16,185,129,0.18); border-color: var(--ok-deep); color: var(--ok); }

.filters {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  /* Die drei Filterbloecke als Ganzes mittig im Kasten (Befund 29); die
     Ueberschriften bleiben linksbuendig ueber ihrem Block. */
  justify-content: center;
}
.filter-group, .segment-group { display: flex; flex-direction: column; gap: 5px; }
/* Wochentage | Auslastung | Tagestyp in einer Zeile, je Block ein senkrechter
   Trenner davor (Befunde 15 und 23). Knapp gehalten (Abstaende, Knopf-
   Innenabstaende, Knopftexte), damit die Zeile auch bei 1000px Breite nicht
   umbricht; auf dem Handy siehe Media-Query. */
.filters > * + * { border-left: 1px solid rgba(255,255,255,0.12); padding-left: 10px; }
.filter-group label, .segment-group label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dimmer);
  font-weight: 600;
}
.filter-group select, .prediction-controls select {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 11px;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  min-width: 130px;
  min-height: 38px; /* gleiche Hoehe wie .day-toggle und .segment (Befund 14) */
}
.filter-group select:focus, .prediction-controls select:focus { outline: none; border-color: var(--accent); }
.filter-group select option, .prediction-controls select option { background: var(--bg-raised); color: var(--text); }

.day-toggle-grid { display: flex; gap: 6px; flex-wrap: wrap; }
.day-toggle {
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.13);
  background: rgba(255,255,255,0.04);
  color: var(--text-dimmer);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  min-height: 38px;
  transition: all 0.2s;
}
.day-toggle:hover { border-color: var(--accent); color: var(--text); }
.day-toggle.selected { background: rgba(59,130,246,0.22); border-color: var(--accent); color: var(--accent-light); }
.day-toggle.active-all { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3); color: var(--text); }

.segment { display: flex; border: 1px solid rgba(255,255,255,0.13); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn {
  padding: 7px 10px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  border: none;
  border-right: 1px solid rgba(255,255,255,0.08);
  min-height: 36px; /* + 1px Rahmen oben/unten von .segment = 38px wie die Nachbarn */
  white-space: nowrap;
  transition: all 0.2s;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.seg-btn.active-all { background: rgba(255,255,255,0.12); color: var(--text); }
.seg-btn.active-optimal { background: rgba(59,130,246,0.22); color: var(--accent-light); }
.seg-btn.active-low { background: rgba(16,185,129,0.22); color: var(--ok); }
.seg-btn.active-high { background: rgba(239,68,68,0.22); color: var(--err); }

/* Zahlenkaesten (Tage, Zeitfenster <25 %, Zeitfenster >35 %) mittig statt
   links (Befund 29). */
.stats-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; justify-content: center; }
.stat-item {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.stat-item .number { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.stat-item .label { font-size: 0.78rem; color: var(--text-dimmer); }

.day-card.hidden { display: none; }
.no-results { text-align: center; padding: 40px 20px; color: var(--text-dimmer); }
.no-results h4 { font-size: 1rem; color: var(--text-dim); margin: 0 0 5px; }
.no-results p { margin: 0; }

.prediction-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.prediction-controls label { font-size: 0.78rem; color: var(--text-dimmer); }
.prediction-controls select { min-width: auto; padding: 6px 10px; font-size: 0.82rem; }

.chart-container {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.chart-title { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.analyse-chart-wrap { margin-bottom: 0; }
.analyse-chart-wrap.small { height: 200px; }

.log-meta { font-size: 0.72rem; color: var(--text-faint); margin-left: auto; white-space: nowrap; }

@media (max-width: 640px) {
  .filters { flex-direction: column; align-items: stretch; }
  .filters > * + * { border-left: none; padding-left: 0; }
  .segment { flex-wrap: wrap; }
  .seg-btn { border-right: none; border-bottom: 1px solid rgba(255,255,255,0.08); }
}

/* ---------- Page Tabs (2 Gruppen mit Flyout) ---------- */
/* Kein overflow-x:auto mehr -- das wuerde das absolut positionierte Flyout
   abschneiden; 2 Tabs brauchen ohnehin kein Scrollen. Sticky uebernimmt
   .sticky-top (oben). */

.page-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  background: rgba(19,19,31,0.95);
  backdrop-filter: blur(10px);
}

.page-tab {
  position: relative;
  padding: 12px 20px;
  font-size: 0.88rem;
  color: var(--text-dimmer);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  user-select: none;
  white-space: nowrap;
}
.page-tab:hover { color: var(--text-dim); }
.page-tab.active { color: #fff; border-bottom-color: var(--accent); }
.page-tab:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }

.flyout-arrow { font-size: 0.7rem; margin-left: 2px; color: var(--text-dimmer); }

.flyout {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: 0 8px 25px rgba(0,0,0,0.35);
  padding: 6px;
  z-index: 210;
}
/* Kein :focus-within hier: der Reiter behaelt nach einem Klick den Fokus und
   wuerde das Menue offen halten, obwohl Escape openMenu schon geleert hat
   (Abnahme-Befund 1). Tastatur: Enter toggelt .open, das reicht. */
.page-tab.has-flyout:hover .flyout,
.page-tab.has-flyout.open .flyout { display: block; }

.flyout-item {
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}
.flyout-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.flyout-item.active { background: rgba(59,130,246,0.18); color: var(--accent-light); }

/* Bottom-Navigation (Mobile): dieselben 2 Gruppen, Flyout als Sheet nach oben */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(19,19,31,0.97);
  border-top: 1px solid var(--line);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 300;
  justify-content: space-around;
  backdrop-filter: blur(12px);
}
.bottom-nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.65rem;
  color: var(--text-dimmer);
  min-width: 60px;
  user-select: none;
}
.bottom-nav-item .nav-icon { font-size: 1.3rem; }
.bottom-nav-item.active { color: var(--accent-light); }
.bottom-nav-item .flyout {
  top: auto;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  border-radius: var(--radius-sm);
}
.bottom-nav-item.open .flyout { display: block; }

@media (max-width: 640px) {
  body { padding-bottom: 70px; }
  .bottom-nav { display: flex; }
  .page-tabs { display: none; }
  .header-actions { gap: 6px; }
  .refresh-select { max-width: 90px; font-size: 0.7rem; }
}

@media (max-width: 640px) {
  .sticky-header { padding: 8px 12px; }
  .status-pill { max-width: 200px; overflow: hidden; text-overflow: ellipsis; font-size: 0.7rem; }
}

/* ---------- Page / Layout ---------- */

.page {
  padding: 20px;
  max-width: 1140px;
  margin: 0 auto;
}

@media (max-width: 640px) {
  .page { padding: 12px; }
}

/* ---------- Cards ---------- */

.chart-section,
.status-card,
.manual-entry,
.phase-banner {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.chart-section,
.manual-entry {
  padding: 20px 22px;
  margin-bottom: 20px;
}

.phase-banner {
  border-left: 3px solid var(--warn);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.phase-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}

.phase-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.phase-targets strong { color: var(--text); }

.phase-rules {
  margin: 12px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* Befund F10: Herkunft der Banner-Werte und Check-in-Erklärung */
.phase-source {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
}
.phase-source strong { color: var(--text); font-weight: 600; }
.phase-howto {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-dim);
}
.phase-howto summary { cursor: pointer; color: var(--text); font-weight: 600; }
.phase-howto ol { margin: 10px 0 0; padding-left: 20px; line-height: 1.6; }
.phase-howto li { margin-bottom: 6px; }

/* Befund F12: Check-in-Card im Phasen-Banner */
.checkin-card {
  margin: 14px 0 6px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.02);
}
.checkin-card.checkin-due { border-left: 3px solid var(--warn); }
.checkin-head { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.checkin-head strong { color: var(--text); font-size: 15px; }
.checkin-due-text { color: var(--warn); font-weight: 600; }
.checkin-lage { margin: 0 0 10px; padding-left: 18px; font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.checkin-lage strong { color: var(--text); }
.checkin-empfehlung { margin: 0 0 10px; font-size: 14px; color: var(--text); }
.checkin-empfehlung .tip-wrap { font-weight: 600; }
/* Erklärungen zur Empfehlung sind länger als die Tabellen-Hover */
.checkin-empfehlung .tip-pop, .alert .tip-pop { max-width: min(560px, 80vw); }
.checkin-options { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.checkin-options li { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.checkin-options label { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--text); cursor: pointer; }
.checkin-options input[type=radio] { accent-color: var(--warn); }
.checkin-option-makros { display: block; margin-top: 4px; padding-left: 24px; font-size: 12px; color: var(--text-dim); }
.checkin-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 8px; }
.checkin-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.checkin-form input { width: 110px; }
.checkin-history { margin-top: 10px; }
.required-mark { color: var(--warn); font-weight: 700; }
.bmr-result .tip-wrap { border-bottom-color: currentColor; }

.plan-table tr.active td { color: var(--text); background: rgba(251,191,36,0.08); }
.plan-table tr.own td { color: var(--text); }

/* Befund F10/F11: Zeiträume- und Plan-Phasen-Tabellen unter Manuelle Einträge */
.nutrition-phases-table tr.plan td { color: var(--text-dim); opacity: 0.75; }
.nutrition-phases-table tr.current td,
.plan-phases-table tr.current td { color: var(--text); opacity: 1; background: rgba(251,191,36,0.08); font-weight: 600; }
.nutrition-phases-table button,
.plan-phases-table button {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.nutrition-phases-table button:hover,
.plan-phases-table button:hover { background: var(--accent); color: #fff; }
.nutrition-phases-table button.danger,
.plan-phases-table button.danger { border-color: var(--err); color: var(--err); }
.nutrition-phases-table button.danger:hover,
.plan-phases-table button.danger:hover { background: var(--err); color: #fff; }
.plan-phases-table .action-cell { white-space: nowrap; }
.plan-phases-table .action-cell button + button { margin-left: 6px; }
.plan-phase-form .action-col { gap: 8px; }
.macro-targets-blocks { display: flex; flex-wrap: wrap; gap: 20px 40px; }
.macro-targets-grid { display: grid; grid-template-columns: 110px repeat(2, 110px); gap: 8px 12px; align-items: center; }
.macro-targets-grid .block-title { font-size: 14px; }
.macro-targets-grid .row-label { font-size: 13px; color: var(--text); font-weight: 600; }
.macro-targets-grid .col-label { font-size: 12px; color: var(--text-dim); }
.macro-targets-grid input { width: 100%; box-sizing: border-box; }

/* ---------- Status Row (Importe-Tab Detail-Cards) ---------- */

/* Drei Kaesten je Zeile, eine unvollstaendige Zeile steht mittig (Befund 17);
   auf schmalen Fenstern fallen sie ueber min-width auf zwei bzw. einen je
   Zeile zurueck. */
.status-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.status-card { padding: 16px 18px; flex: 0 1 calc((100% - 24px) / 3); min-width: 180px; }
.status-card.ok { border-color: rgba(52,211,153,0.35); }
.status-card.warn { border-color: rgba(251,191,36,0.35); }

.status-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dimmer);
  margin-bottom: 6px;
  font-weight: 600;
}

.status-value { font-size: 16px; }

.status-action {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--accent-light);
  text-decoration: none;
}
.status-action:hover { text-decoration: underline; }

.status-action-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
}
.status-action-btn:disabled { opacity: 0.5; cursor: default; text-decoration: none; }

/* ---------- Alerts ---------- */

.alert {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid transparent;
}
.alert-ok { background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.3); }
.alert-warn { background: rgba(251,191,36,0.1); border-color: rgba(251,191,36,0.35); }
.alert-err { background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.35); }
.alert-rule { display: block; margin-top: 4px; color: var(--text-dim); font-size: 13px; }
/* Schliessbare Sync-Meldungen (Befund 5) */
.alert-dismissible { position: relative; padding-right: 42px; }
.alert-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}
.alert-close:hover { color: var(--text); }

/* ---------- Chart Sections ---------- */

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
}

.hint { color: var(--text-dim); font-size: 13px; margin: 0 0 16px; }

.chart-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 6px;
  margin-bottom: 16px;
}

.chart-tab {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.13);
  color: var(--text-dim);
  font-size: 12px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.chart-tab:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.chart-tab.active {
  background: rgba(59,130,246,0.22);
  border-color: var(--accent);
  color: var(--accent-light);
  font-weight: 600;
}

.metric-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.metric-check input[type="checkbox"] {
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
  margin: 0;
  cursor: pointer;
}

.zoom-reset-btn {
  margin-left: 4px;
  color: var(--text-dim);
}
.zoom-reset-btn:hover { color: var(--text); }

.chart-canvas-wrap { height: 380px; }
.chart-canvas-wrap.small { height: 240px; }

.chart-legend {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-dim);
}
.dot { margin-right: 6px; }

.export-row {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 12px;
}
.export-row a { color: var(--text-dim); text-decoration: none; }
.export-row a:hover { color: var(--accent-light); }

/* ---------- Forms ---------- */

.manual-entry h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
}

.entry-form {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
}

.entry-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.entry-form label.full { width: 100%; }

.entry-form input,
.entry-form select {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  width: 140px;
}
.entry-form select { cursor: pointer; }
/* Datei-Felder: die festen 140px schnitten den Dateinamen neben "Datei
   auswaehlen" ab (Befund 6). Das Datei-Feld steht mit Von/Bis und Knopf in
   einer Zeile und nimmt dort die Restbreite (Befund 19); reicht die Zeile
   nicht, bricht es als Ganzes um. */
.entry-form label.file-field { flex: 1 1 320px; max-width: 100%; }
.entry-form input[type="file"] { width: 100%; padding-top: 6px; padding-bottom: 6px; }
/* Die vier Formulare auf "Importe" (Withings- und Google-Health-Nachsync,
   die beiden FDDB-Importe) sollen spaltengleich sein (Befunde 28 und 34):
   der Knopf steht in allen in einer festen, gleich breiten Spalte und darin
   mittig; damit bleibt fuer die erste Spalte dieselbe Restbreite und Von/Bis
   stehen buendig untereinander. Die Sync-Formulare haben kein Datei-Feld
   und bekommen stattdessen einen leeren Platzhalter gleicher Flex-Breite. */
.entry-form .form-spacer { flex: 1 1 320px; }
.entry-form .action-col { flex: 0 0 300px; display: flex; justify-content: center; }
/* Alle Felder und Knoepfe gleich hoch, damit Datei-Feld, Datumsfelder und
   Knopf in einer Zeile buendig sind (Befund 19). */
.entry-form input,
.entry-form select,
.entry-form button { min-height: 38px; }
.entry-form input:focus,
.entry-form select:focus { outline: none; border-color: var(--accent); }
.entry-form select option { background: var(--bg-raised); color: var(--text); }

.entry-form button {
  background: var(--accent);
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
}
.entry-form button:hover { filter: brightness(1.1); }
.bmr-result { margin: 14px 0 0; }

@media (max-width: 600px) {
  .entry-form input { width: 100%; }
  .entry-form .form-spacer { display: none; }
  .entry-form .action-col { flex: 1 1 100%; }
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 800px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 12px;
}
.mini-table th, .mini-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--text-dim);
}
.mini-table th { color: var(--text); font-weight: 600; }

.best-times-empty {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}

/* ---------- Optimale Trainingszeiten (Vue-Komponente) ---------- */

.bt-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.bt-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.bt-field input {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  width: 110px;
}
.bt-field input:focus { outline: none; border-color: var(--accent); }

.bt-loading { align-self: center; margin: 0; }

.bt-daypicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
}

.bt-day-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.13);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  min-width: 44px;
}
.bt-day-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.bt-day-btn.active {
  background: rgba(59,130,246,0.22);
  border-color: var(--accent);
  color: var(--accent-light);
}

.bt-day-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 4px;
}

.bt-day-all {
  border-style: dashed;
  font-weight: 400;
  min-width: auto;
}

.bt-status-error { color: var(--err); }

.bt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.bt-card {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
  padding: 16px 18px;
  transition: all 0.25s;
}
.bt-card:hover { border-color: rgba(255,255,255,0.14); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.25); }

.bt-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.bt-card-day { font-size: 16px; font-weight: 700; }
.bt-card-count { font-size: 11px; color: var(--text-dimmer); }

.bt-window {
  background: var(--bg-raised);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-left: 3px solid var(--accent);
}
.bt-window:last-child { margin-bottom: 0; }

/* Belegungsgrad-Einfärbung: je ruhiger, desto kräftiger die Akzentfarbe */
.bt-window.bt-level-quiet { border-left-color: var(--ok); }
.bt-window.bt-level-moderate { border-left-color: var(--accent); }
.bt-window.bt-level-ok { border-left-color: var(--text-dimmer); }

.bt-window-time {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.bt-window-arrow { color: var(--text-dim); font-weight: 400; }

.bt-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  background: var(--bg);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
}

.bt-window-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.bt-label { color: var(--text-dim); }
.bt-value { color: var(--text); font-weight: 600; }

/* ---------- Light Mode (Phase 3, ganze App) ---------- */
/* Erst die Tokens umdrehen (deckt alles ab, was var(--...) nutzt), danach
   gezielte Overrides fuer die hartcodierten rgba(255,255,255,..)-Flaechen,
   die auf hellem Grund unsichtbar waeren -- analog watchdog_html.sh.
   Chart.js-Farben (Raster/Ticks/Legende/Tooltip) kommen aus chartTheme() im
   Template und folgen dem Theme ebenfalls (Abnahme-Befund 4). */

body.light-mode {
  --bg: #f4f4f7;
  --bg-raised: #ffffff;
  --line: #e5e5e5;
  --line-soft: #eeeeee;
  --text: #1a1a2e;
  --text-dim: #555555;
  --text-dimmer: #777777;
  --text-faint: #9a9a9a;
}
.light-mode .sticky-header { background: rgba(244,244,247,0.97); }
.light-mode .page-tabs { background: rgba(255,255,255,0.97); }
.light-mode .bottom-nav { background: rgba(255,255,255,0.97); }
.light-mode .app-title,
.light-mode .page-tab.active,
.light-mode .day-header h3 { color: var(--text); }

.light-mode .status-pill,
.light-mode .live-item,
.light-mode .stat-item,
.light-mode .filters,
.light-mode .day-header,
.light-mode .status-item { background: rgba(0,0,0,0.03); border-color: #dddddd; }

.light-mode .chart-section,
.light-mode .status-card,
.light-mode .manual-entry,
.light-mode .phase-banner,
.light-mode .day-card,
.light-mode .bt-card { box-shadow: 0 2px 12px rgba(0,0,0,0.07); }
.light-mode .day-card,
.light-mode .bt-card,
.light-mode .bt-window,
.light-mode .flyout { background: #ffffff; }
.light-mode .chart-container,
.light-mode .log-box { background: #f8f8f8; }

.light-mode .studio-tab,
.light-mode .view-btn,
.light-mode .export-btn,
.light-mode .seg-btn,
.light-mode .day-toggle,
.light-mode .log-level-btn,
.light-mode .chart-tab,
.light-mode .bt-day-btn,
.light-mode .btn-sm,
.light-mode .refresh-select,
.light-mode .log-controls select,
.light-mode .log-filter-input,
.light-mode .filter-group select,
.light-mode .prediction-controls select,
.light-mode .entry-form input,
.light-mode .entry-form select,
.light-mode .bt-field input { background: #ffffff; border-color: #dddddd; color: #333333; }
.light-mode .segment { border-color: #dddddd; }
.light-mode .filters > * + * { border-left-color: #dddddd; }
.light-mode .seg-btn { border-right-color: #e5e5e5; }

/* Aktiv-Zustaende wieder herstellen (die Button-Overrides oben haben gleiche Spezifitaet) */
.light-mode .studio-tab.active,
.light-mode .view-btn.active,
.light-mode .chart-tab.active,
.light-mode .bt-day-btn.active,
.light-mode .day-toggle.selected,
.light-mode .seg-btn.active-optimal,
.light-mode .log-level-btn.active-info { background: rgba(59,130,246,0.15); border-color: var(--accent); color: #2563eb; }
.light-mode .seg-btn.active-all,
.light-mode .day-toggle.active-all { background: rgba(0,0,0,0.08); border-color: #bbbbbb; color: var(--text); }
.light-mode .seg-btn.active-low { background: rgba(16,185,129,0.15); color: #059669; }
.light-mode .seg-btn.active-high,
.light-mode .log-level-btn.active-error { background: rgba(239,68,68,0.15); border-color: var(--err); color: #dc2626; }
.light-mode .log-level-btn.active-warn { background: rgba(251,191,36,0.2); border-color: var(--warn); color: #b45309; }
/* Gelbe Marker (⭐ Top, Feiertag) sind auf hellem Grund sonst kaum lesbar (Befund 3) */
.light-mode .badge-best,
.light-mode .badge-holiday { background: rgba(217,119,6,0.14); color: #b45309; }

.light-mode .flyout-item:hover { background: rgba(0,0,0,0.05); }
.light-mode .log-line-info { color: #444444; }
.light-mode .hm-empty { color: #cccccc; }
.light-mode .time-block.optimal .percentage { color: #2563eb; }
.light-mode .time-block.low .percentage,
.light-mode .trend-down { color: #059669; }
.light-mode .time-block.high .percentage,
.light-mode .trend-up { color: #dc2626; }

/* ---------- Login-Seite ---------- */
/* Eigenstaendige Seite (app/templates/login.html), ohne Vue und ohne
   Charts. Nutzt dieselben Farb-Tokens wie der Rest, damit Hell/Dunkel
   ohne Zusatzarbeit passt, und dieselben Klassen .app-logo/.app-title
   fuer den Kopf. */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
}

.login-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}
.login-head .app-logo { width: 28px; height: 28px; border-radius: 6px; }
.login-head .app-title { font-size: 1.15rem; }

.login-error {
  background: rgba(248,113,113,0.12);
  border: 1px solid var(--err);
  color: var(--err);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.login-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.login-input {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.login-input:focus { outline: none; border-color: var(--accent); }

.login-btn {
  margin-top: 6px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 11px 16px;
  cursor: pointer;
}
.login-btn:hover { background: var(--accent-light); }

/* Der Abmelden-Knopf steckt in einem eigenen Formular (POST /logout) --
   ohne das haenge es als Block in der Kopfzeile statt neben den anderen
   Knoepfen. */
.header-actions form { display: inline-flex; }

.light-mode .login-card { background: #ffffff; box-shadow: 0 2px 12px rgba(0,0,0,0.07); }
.light-mode .login-input { background: #ffffff; border-color: #dddddd; color: #333333; }

/* Fortschrittsbalken auf der Karte FDDB (Befund F1), nur während des Nachladens */
.fddb-progress { height: 6px; background: var(--line); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.fddb-progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; }

/* ---------- FDDB-Nährstoffe (Tab Ernährung (FDDB)) ---------- */

/* Auswahlfeld wie .log-controls select -- inkl. option-Zeile, sonst sind die
   Aufklapp-Einträge im Darkmode unlesbar (Befund 2026-09-07). */
.nutrient-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.nutrient-controls label { font-size: 12px; color: var(--text-dim); }
.nutrient-controls .chart-tabs { margin-bottom: 0; }
.nutrient-controls select {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  min-width: 220px;
}
.nutrient-controls select:focus { outline: none; border-color: var(--accent); }
.nutrient-controls select option, .nutrient-controls select optgroup { background: var(--bg-raised); color: var(--text); }

.nutrient-browser {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}
/* Scrollbare Tagesliste: alle Tage aus der DB, neueste oben. */
.nutrient-day-list {
  max-height: 560px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
}
.nutrient-day-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12px;
  padding: 8px 10px;
  cursor: pointer;
}
.nutrient-day-item:hover { color: var(--text); background: rgba(59,130,246,0.08); }
.nutrient-day-item.active { color: var(--accent-light); background: rgba(59,130,246,0.18); font-weight: 600; }
.nutrient-day-kcal { white-space: nowrap; }
.nutrient-day-detail { min-width: 0; }
.nutrient-day-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.nutrient-day-nav strong { font-size: 15px; }
.nutrient-day-nav button:disabled { opacity: 0.4; cursor: default; }
.nutrient-groups { display: flex; flex-wrap: wrap; gap: 0 20px; }
.nutrient-group { flex: 1 1 220px; margin-top: 10px; }
.mini-table td.num, .mini-table th.num { text-align: right; white-space: nowrap; }
.nutrient-items-wrap { overflow-x: auto; }
/* Zeilen-Hover in den Tabellen des Tages-Browsers (Befund F8) */
.nutrient-group tbody tr:hover td, .nutrient-items tbody tr:hover td { background: rgba(59,130,246,0.10); color: var(--text); }
.nutrient-items td:nth-child(3) { min-width: 200px; }
/* Mahlzeiten-Überschrift innerhalb der Positionstabelle (Befund F4) */
.nutrient-meal th {
  padding-top: 14px;
  color: var(--accent-light);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
}
.nutrient-items a { color: var(--text); text-decoration: none; border-bottom: 1px dotted var(--text-dim); }
.nutrient-items a:hover { color: var(--accent-light); }
@media (max-width: 760px) {
  .nutrient-browser { grid-template-columns: 1fr; }
  .nutrient-day-list { max-height: 220px; }
}

/* Befund F18/F23: Erklärungs-Hover als gestaltetes Popover, Muster aus
   bitcoin-nest (.tip-wrap/.tip-pop): Einblendung per opacity/transform,
   auch per Tastatur-Fokus, kein Browser-title. Tabellenzellen brauchen
   dafür overflow: visible. */
.tip-wrap { position: relative; display: inline-flex; cursor: help; border-bottom: 1px dotted var(--text-dim); outline: none; }
.tip-pop {
  position: absolute;
  left: 0;
  bottom: calc(100% + 7px);
  z-index: 200;
  width: max-content;
  max-width: 320px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 0.15s ease-out, transform 0.15s ease-out, visibility 0.15s ease-out;
}
.tip-wrap:hover .tip-pop,
.tip-wrap:focus-within .tip-pop,
.tip-wrap:focus .tip-pop { opacity: 1; visibility: visible; transform: none; }
.mini-table td:has(.tip-wrap) { overflow: visible; }
/* Befund F42: Popover darf nicht am Tabellen-Container abgeschnitten werden */
.plan-phases-table td.num .tip-pop { left: auto; right: 0; max-width: min(340px, 60vw); }
.manual-entry .nutrient-items-wrap:has(.plan-phases-table) { overflow: visible; }
/* Befund F43: leere Pflichtfelder */
.field-missing { border-color: var(--err) !important; box-shadow: 0 0 0 1px rgba(248,113,113,0.5); }
