/* Vitalwerte-Tracker – seriöse, businesstaugliche Optik.
   Gedeckte Blau- und Grautöne, klare Formulare und Tabellen, kompakte
   Dichte, keine verspielten Elemente. Mobile-first, Haltepunkte bei
   768px und 1024px. */

:root {
  --flaeche: #eef1f5;
  --karte: #ffffff;
  --kopf: #1e3a5f;
  --kopf-text: #f4f7fb;
  --linie: #d7dde5;
  --linie-stark: #b7c1cf;
  --text: #1b2430;
  --text-leise: #5b6774;
  --text-schwach: #8994a1;
  --akzent: #2b5a8c;
  --akzent-dunkel: #1e3a5f;
  --akzent-hell: #e5edf6;
  --akzent-text: #ffffff;
  --erfolg: #1f7a4d;
  --erfolg-hell: #e5f3ec;
  --warnung: #9a6300;
  --warnung-hell: #fbf1de;
  --gefahr: #a4342a;
  --gefahr-hell: #fbeae8;
  --radius: 10px;
  --radius-klein: 6px;
  --schatten: 0 1px 2px rgba(20, 30, 45, 0.06), 0 1px 1px rgba(20, 30, 45, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --flaeche: #121722;
    --karte: #1a212d;
    --kopf: #0f1a29;
    --kopf-text: #e7edf5;
    --linie: #2b3543;
    --linie-stark: #3a4657;
    --text: #e7edf5;
    --text-leise: #a7b2c0;
    --text-schwach: #78828f;
    --akzent: #4c86c2;
    --akzent-dunkel: #6ba0d8;
    --akzent-hell: #1c2c3f;
    --akzent-text: #0f1a29;
    --erfolg: #4caf7d;
    --erfolg-hell: #16281f;
    --warnung: #d1a03a;
    --warnung-hell: #2c2410;
    --gefahr: #e2695f;
    --gefahr-hell: #2c1815;
    --schatten: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--flaeche);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  margin: 0 0 4px;
  letter-spacing: -0.01em;
  font-weight: 600;
}

h1 { font-size: 1.375rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }

p { margin: 0; }

a { color: var(--akzent); }

/* ---------- Kopfzeile ---------- */

.kopfzeile {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--kopf);
  color: var(--kopf-text);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--schatten);
}

.kopfzeile .marke {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--kopf-text);
  text-decoration: none;
}

.kopfzeile .marke svg { flex-shrink: 0; }

.kopfzeile .datum-heute {
  font-size: 0.8125rem;
  color: #c3d0e0;
}

/* ---------- Inhalt ---------- */

.inhalt {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 88px);
}

@media (min-width: 768px) {
  .inhalt { padding: 24px 24px calc(env(safe-area-inset-bottom, 0px) + 96px); }
}

@media (min-width: 1024px) {
  .inhalt { max-width: 900px; }
}

.seiten-kopf {
  margin-bottom: 16px;
}

.seiten-kopf p {
  color: var(--text-leise);
  font-size: 0.9375rem;
  margin-top: 2px;
}

/* ---------- Karten ---------- */

.karte {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 16px;
}

.karte + .karte { margin-top: 12px; }

.karten-reihe {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .karten-reihe.zwei-spalten { grid-template-columns: 1fr 1fr; }
}

/* ---------- Formulare ---------- */

form { display: block; }

.feld {
  margin-bottom: 14px;
}

.feld:last-child { margin-bottom: 0; }

.feld label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-leise);
  margin-bottom: 6px;
}

.feld .pflicht { color: var(--gefahr); }

.feld input[type="text"],
.feld input[type="number"],
.feld input[type="date"],
.feld input[type="time"],
.feld input[type="email"],
.feld input[type="password"],
.feld textarea,
.feld select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--linie-stark);
  border-radius: var(--radius-klein);
  background: var(--karte);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.feld textarea {
  min-height: 76px;
  resize: vertical;
}

.feld input:focus,
.feld textarea:focus,
.feld select:focus {
  outline: 2px solid var(--akzent);
  outline-offset: 1px;
  border-color: var(--akzent);
}

.feld input[aria-invalid="true"],
.feld textarea[aria-invalid="true"] {
  border-color: var(--gefahr);
}

.feld .hinweis {
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--text-schwach);
}

.feld .fehler {
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--gefahr);
  font-weight: 500;
}

.feld-gruppe-zeile {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.formular-fuss {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */

.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-klein);
  border: 1px solid transparent;
  background: var(--akzent);
  color: var(--akzent-text);
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  cursor: pointer;
  line-height: 1;
}

.knopf:hover { background: var(--akzent-dunkel); }

.knopf:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.knopf.sekundaer {
  background: transparent;
  color: var(--akzent);
  border-color: var(--linie-stark);
}

.knopf.sekundaer:hover { background: var(--akzent-hell); }

.knopf.gefahr {
  background: var(--gefahr);
}

.knopf.gefahr:hover { filter: brightness(0.92); }

.knopf.klein {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.knopf-breit { width: 100%; }

/* ---------- Meldungen ---------- */

.meldung {
  padding: 12px 14px;
  border-radius: var(--radius-klein);
  font-size: 0.9375rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.meldung.erfolg { background: var(--erfolg-hell); color: var(--erfolg); border-color: var(--erfolg); }
.meldung.fehler { background: var(--gefahr-hell); color: var(--gefahr); border-color: var(--gefahr); }
.meldung.hinweis { background: var(--akzent-hell); color: var(--akzent-dunkel); border-color: var(--linie-stark); }

/* ---------- Kennzahlen (Zusammenfassung) ---------- */

.kennzahlen {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
  .kennzahlen { grid-template-columns: repeat(4, 1fr); }
}

.kennzahl {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 12px;
}

.kennzahl .bezeichnung {
  font-size: 0.75rem;
  color: var(--text-schwach);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kennzahl .wert {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 4px;
  color: var(--akzent-dunkel);
}

.kennzahl .zusatz {
  font-size: 0.75rem;
  color: var(--text-leise);
  margin-top: 2px;
}

/* ---------- Werte-Liste als Karten (mobil) / Tabelle (ab 768px) ---------- */

.werte-liste {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.werte-zeile {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--schatten);
}

.werte-zeile .zeile-kopf {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--linie);
}

.werte-zeile .zeile-kopf .zeit {
  font-weight: 600;
  font-size: 0.9375rem;
}

.werte-zeile .zeile-kopf .datum {
  font-size: 0.8125rem;
  color: var(--text-schwach);
}

.werte-zeile .messwerte {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.messwert .bezeichnung {
  font-size: 0.6875rem;
  color: var(--text-schwach);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.messwert .zahl {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
}

.messwert .zahl.warnung { color: var(--warnung); }
.messwert .zahl.gefahr { color: var(--gefahr); }

.werte-zeile .notiz {
  font-size: 0.875rem;
  color: var(--text-leise);
  margin-bottom: 8px;
}

.werte-zeile .zeile-aktionen {
  display: flex;
  gap: 8px;
}

@media (min-width: 768px) {
  .werte-liste.als-tabelle {
    display: block;
  }
  .werte-tabelle {
    width: 100%;
    border-collapse: collapse;
    background: var(--karte);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.9375rem;
  }
  .werte-tabelle th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-schwach);
    background: var(--flaeche);
    padding: 10px 12px;
    border-bottom: 1px solid var(--linie);
  }
  .werte-tabelle td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--linie);
    vertical-align: top;
  }
  .werte-tabelle tr:last-child td { border-bottom: none; }
  .werte-tabelle td.zahlen { text-align: right; font-variant-numeric: tabular-nums; }
  .werte-karten-mobil { display: none; }
}

.werte-karten-mobil { display: block; }
@media (min-width: 768px) { .werte-karten-mobil { display: none; } }
.werte-tabelle-wrapper { display: none; }
@media (min-width: 768px) { .werte-tabelle-wrapper { display: block; } }

/* ---------- Badges ---------- */

.abzeichen {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.abzeichen.neutral { background: var(--akzent-hell); color: var(--akzent-dunkel); }
.abzeichen.warnung { background: var(--warnung-hell); color: var(--warnung); }
.abzeichen.gefahr { background: var(--gefahr-hell); color: var(--gefahr); }

/* ---------- Leerzustand ---------- */

.leerzustand {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-leise);
}

.leerzustand svg {
  margin-bottom: 12px;
  color: var(--text-schwach);
}

.leerzustand h3 { margin-bottom: 4px; color: var(--text); }

/* ---------- Untere Navigation ---------- */

.untenleiste {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--karte);
  border-top: 1px solid var(--linie);
  padding: 6px 4px calc(env(safe-area-inset-bottom, 0px) + 6px);
  box-shadow: 0 -1px 3px rgba(20, 30, 45, 0.06);
}

.untenleiste a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 4px;
  border-radius: var(--radius-klein);
  color: var(--text-schwach);
  text-decoration: none;
  font-size: 0.6875rem;
  font-weight: 600;
}

.untenleiste a.aktiv {
  color: var(--akzent);
  background: var(--akzent-hell);
}

.untenleiste a svg { width: 22px; height: 22px; }

/* ---------- Anmelde-/Registrierseiten ---------- */

.anmelde-buehne {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.anmelde-karte {
  width: 100%;
  max-width: 26rem;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 28px 24px;
}

.anmelde-kopf {
  text-align: center;
  margin-bottom: 20px;
}

.anmelde-kopf .marke-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--akzent-hell);
  color: var(--akzent-dunkel);
  margin-bottom: 12px;
}

.anmelde-kopf p {
  color: var(--text-leise);
  font-size: 0.875rem;
  margin-top: 4px;
}

.anmelde-fuss {
  text-align: center;
  margin-top: 16px;
  font-size: 0.875rem;
  color: var(--text-leise);
}

.anmelde-fuss a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 4px 10px;
  margin: -4px -10px;
  border-radius: var(--radius-klein);
  font-weight: 600;
  vertical-align: middle;
}

.anmelde-fuss a:hover {
  background: var(--akzent-hell);
}

/* ---------- Zeitraum-Filter ---------- */

.filter-leiste {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .filter-leiste { grid-template-columns: 1fr 1fr auto; }
  .filter-leiste .feld { margin-bottom: 0; }
}

/* ---------- Hinweiskasten (Rechtstexte/Disclaimer) ---------- */

.hinweiskasten {
  border: 1px solid var(--linie-stark);
  background: var(--akzent-hell);
  color: var(--akzent-dunkel);
  border-radius: var(--radius-klein);
  padding: 10px 12px;
  font-size: 0.8125rem;
  margin-bottom: 16px;
}

/* Bildschirmlesegeräte-only */
.sr-nur {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
