:root {
  --navy: #10243f;
  --navy-hell: #1b3a6b;
  --navy-tief: #0a1830;
  --orange: #e8703a;
  --gruen: #1a7f37;
  --gruen-hell: #e6f4ea;
  --amber: #b26a00;
  --amber-hell: #fdf3e0;
  --rot: #c0392b;
  --rot-hell: #fdecea;
  --blau: #1f6feb;
  --blau-hell: #e8f0fe;
  --grau-900: #121820;
  --grau-700: #44505f;
  --grau-500: #6b7785;
  --grau-300: #cfd6de;
  --grau-200: #e3e8ee;
  --grau-100: #f1f4f8;
  --weiss: #ffffff;
  --radius: 12px;
  --schatten: 0 1px 2px rgba(16, 36, 63, .08), 0 4px 12px rgba(16, 36, 63, .06);
  --kopf-hoehe: 56px;
  --fuss-hoehe: 60px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.45;
  color: var(--grau-900); background: var(--grau-100);
  -webkit-text-size-adjust: 100%;
}

body { overscroll-behavior-y: none; }

/* ------------------------------------------------------------------ Kopf */
header.kopf {
  position: sticky; top: 0; z-index: 40;
  height: calc(var(--kopf-hoehe) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--navy); color: var(--weiss);
  display: flex; align-items: center; gap: 10px; padding-inline: 12px;
  box-shadow: 0 2px 8px rgba(10, 24, 48, .25);
}
.kopf h1 { font-size: 1.05rem; font-weight: 650; margin: 0; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kopf .unter { font-size: .78rem; font-weight: 400; opacity: .72; display: block; }
.kopf button {
  background: rgba(255,255,255,.12); color: var(--weiss); border: 0;
  border-radius: 9px; min-width: 40px; height: 40px; padding: 0 12px;
  font-size: .9rem; font-weight: 600; cursor: pointer;
}
.kopf button:active { background: rgba(255,255,255,.26); }

/* --------------------------------------------------------------- Inhalt */
main { padding: 14px 12px calc(var(--fuss-hoehe) + env(safe-area-inset-bottom) + 24px); max-width: 860px; margin: 0 auto; }
main.ohne-fuss { padding-bottom: 32px; }

h2 { font-size: 1.12rem; margin: 20px 0 10px; letter-spacing: -.01em; }
h2:first-child { margin-top: 2px; }
h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--grau-500); margin: 22px 0 8px; font-weight: 700; }

.karte {
  background: var(--weiss); border-radius: var(--radius);
  box-shadow: var(--schatten); overflow: hidden; margin-bottom: 12px;
}
.karte-inhalt { padding: 14px 16px; }
.karte + h2, .karte + h3 { margin-top: 24px; }

/* --------------------------------------------------------------- Termine */
.termin {
  display: flex; align-items: stretch; gap: 0; width: 100%;
  background: var(--weiss); border: 0; border-bottom: 1px solid var(--grau-200);
  padding: 0; text-align: left; cursor: pointer; font: inherit; color: inherit;
}
.termin:last-child { border-bottom: 0; }
.termin:active { background: var(--grau-100); }
.termin .tag {
  flex: 0 0 62px; background: var(--grau-100); border-right: 1px solid var(--grau-200);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px 4px; gap: 1px;
}
.termin .tag .wt { font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--grau-500); }
.termin .tag .dt { font-size: 1.22rem; font-weight: 700; line-height: 1.1; color: var(--navy); }
.termin .tag .mo { font-size: .66rem; color: var(--grau-500); }
.termin .mitte { flex: 1; padding: 11px 12px; min-width: 0; }
.termin .team { font-weight: 650; font-size: .98rem; margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.termin .meta { font-size: .8rem; color: var(--grau-500);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.termin .rechts { flex: 0 0 auto; display: flex; align-items: center; padding-right: 12px; }

.marke {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .72rem; font-weight: 700; padding: 4px 9px; border-radius: 99px;
  white-space: nowrap;
}
.marke.offen   { background: var(--amber-hell); color: var(--amber); }
.marke.fertig  { background: var(--gruen-hell); color: var(--gruen); }
.marke.teil    { background: var(--blau-hell);  color: var(--blau); }
.marke.abgesagt{ background: var(--rot-hell);   color: var(--rot); }
.marke.grau    { background: var(--grau-200);   color: var(--grau-700); }

/* ---------------------------------------------------------- Anwesenheit */
.einheit-kopf {
  background: linear-gradient(160deg, var(--navy-hell), var(--navy-tief));
  color: var(--weiss); padding: 16px; border-radius: var(--radius); margin-bottom: 14px;
}
.einheit-kopf .gross { font-size: 1.18rem; font-weight: 700; margin-bottom: 4px; }
.einheit-kopf .zeile { font-size: .86rem; opacity: .82; }
.einheit-kopf .zaehler { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.einheit-kopf .zaehler span {
  background: rgba(255,255,255,.14); border-radius: 8px; padding: 5px 10px;
  font-size: .8rem; font-weight: 600;
}

.werkzeuge { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

.spieler {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--grau-200); background: var(--weiss);
}
.spieler:last-child { border-bottom: 0; }
.spieler .name { flex: 1; min-width: 0; font-weight: 560; font-size: .97rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spieler .name small { display: block; font-weight: 400; font-size: .74rem; color: var(--grau-500); }
.spieler.gesetzt-anwesend    { background: #f4fbf6; }
.spieler.gesetzt-verspaetet  { background: #f4f8ff; }
.spieler.gesetzt-entschuldigt{ background: #fffbf3; }
.spieler.gesetzt-fehlt       { background: #fff6f5; }

.wahl { display: flex; gap: 4px; flex: 0 0 auto; }
.wahl button {
  width: 42px; height: 42px; border-radius: 10px; border: 1.5px solid var(--grau-300);
  background: var(--weiss); color: var(--grau-700);
  font-size: 1rem; font-weight: 700; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.wahl button:active { transform: scale(.93); }
.wahl button[aria-pressed="true"][data-s="anwesend"]    { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.wahl button[aria-pressed="true"][data-s="verspaetet"]  { background: var(--blau);  border-color: var(--blau);  color: #fff; }
.wahl button[aria-pressed="true"][data-s="entschuldigt"]{ background: var(--amber); border-color: var(--amber); color: #fff; }
.wahl button[aria-pressed="true"][data-s="fehlt"]       { background: var(--rot);   border-color: var(--rot);   color: #fff; }

.gruppen-titel {
  padding: 9px 12px; background: var(--grau-100); font-size: .76rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--grau-700);
  border-bottom: 1px solid var(--grau-200);
}

/* --------------------------------------------------------------- Knoepfe */
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 46px; padding: 0 18px; border-radius: 10px; border: 0;
  background: var(--navy); color: var(--weiss); font: inherit; font-weight: 650;
  cursor: pointer; text-decoration: none;
}
.knopf:active { background: var(--navy-tief); }
.knopf[disabled] { opacity: .5; cursor: default; }
.knopf.zweit { background: var(--weiss); color: var(--navy); border: 1.5px solid var(--grau-300); }
.knopf.zweit:active { background: var(--grau-100); }
.knopf.gruen { background: var(--gruen); }
.knopf.warn  { background: var(--rot); }
.knopf.klein { min-height: 38px; padding: 0 13px; font-size: .88rem; }
.knopf.breit { width: 100%; }

/* --------------------------------------------------------------- Formular */
label.feld { display: block; margin-bottom: 12px; }
label.feld span { display: block; font-size: .83rem; font-weight: 650;
  color: var(--grau-700); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; font: inherit;
  border: 1.5px solid var(--grau-300); border-radius: 10px; background: var(--weiss);
  color: var(--grau-900);
}
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--navy-hell); box-shadow: 0 0 0 3px rgba(27,58,107,.14);
}
select[multiple] { min-height: 150px; }
.feld-reihe { display: flex; gap: 10px; flex-wrap: wrap; }
.feld-reihe > label.feld { flex: 1 1 140px; }

/* --------------------------------------------------------------- Meldung */
.meldung {
  border-radius: 10px; padding: 11px 14px; margin-bottom: 12px; font-size: .9rem;
  display: flex; gap: 9px; align-items: flex-start;
}
.meldung.info    { background: var(--blau-hell);  color: #14448c; }
.meldung.gut     { background: var(--gruen-hell); color: #11562a; }
.meldung.warnung { background: var(--amber-hell); color: #7a4800; }
.meldung.fehler  { background: var(--rot-hell);   color: #8f2018; }

.leer { text-align: center; padding: 38px 20px; color: var(--grau-500); }
.leer .gross { font-size: 2rem; margin-bottom: 8px; opacity: .45; }

/* --------------------------------------------------------------- Tabelle */
.tabelle-huelle { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--grau-200);
  white-space: nowrap; }
th { background: var(--grau-100); font-size: .76rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--grau-700); position: sticky; top: 0; }
tbody tr:active { background: var(--grau-100); }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ Fuss */
nav.fuss {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--fuss-hoehe) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--weiss); border-top: 1px solid var(--grau-200);
  display: flex; align-items: stretch;
}
nav.fuss a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--grau-500); font-size: .68rem; font-weight: 650;
}
nav.fuss a svg { width: 22px; height: 22px; }
nav.fuss a[aria-current="page"] { color: var(--navy); }

/* ------------------------------------------------------------ Verschiedenes */
.liste-leiste { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.liste-leiste select, .liste-leiste input { min-height: 42px; flex: 1 1 150px; width: auto; }

.offline-hinweis {
  position: fixed; left: 12px; right: 12px; z-index: 50;
  bottom: calc(var(--fuss-hoehe) + env(safe-area-inset-bottom) + 10px);
  background: var(--navy-tief); color: var(--weiss); border-radius: 10px;
  padding: 10px 14px; font-size: .85rem; box-shadow: var(--schatten);
  display: flex; gap: 8px; align-items: center;
}
.offline-hinweis.weg { display: none; }

.anmeldung-huelle {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(165deg, var(--navy-hell), var(--navy-tief));
}
.anmeldung { background: var(--weiss); border-radius: 16px; padding: 26px 22px;
  width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(6,16,32,.3); }
.anmeldung .wappen { width: 52px; height: 52px; border-radius: 13px; background: var(--navy);
  color: var(--weiss); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.15rem; margin-bottom: 14px; letter-spacing: -.03em; }
.anmeldung h1 { font-size: 1.22rem; margin: 0 0 3px; }
.anmeldung p.unter { color: var(--grau-500); font-size: .88rem; margin: 0 0 20px; }

.pille {
  display: inline-block; font-size: .74rem; font-weight: 700; padding: 3px 9px;
  border-radius: 99px; background: var(--grau-200); color: var(--grau-700); margin-right: 5px;
}
.pille.admin      { background: #ede4ff; color: #5b2bbf; }
.pille.trainer    { background: var(--blau-hell); color: #14448c; }
.pille.vertretung { background: var(--amber-hell); color: var(--amber); }

details.gruppe { background: var(--weiss); border-radius: var(--radius); margin-bottom: 10px;
  box-shadow: var(--schatten); overflow: hidden; }
details.gruppe > summary { padding: 14px 16px; font-weight: 650; cursor: pointer; list-style: none; }
details.gruppe > summary::-webkit-details-marker { display: none; }
details.gruppe > summary::after { content: "+"; float: right; color: var(--grau-500); font-weight: 700; }
details.gruppe[open] > summary::after { content: "\2212"; }
details.gruppe > div { padding: 0 16px 16px; }

.lade { text-align: center; padding: 40px; color: var(--grau-500); }

@media (min-width: 720px) {
  nav.fuss { position: static; height: auto; padding: 0; border-top: 0; border-bottom: 1px solid var(--grau-200); }
  nav.fuss a { flex-direction: row; gap: 7px; padding: 13px 10px; font-size: .88rem; }
  main { padding-bottom: 40px; }
  .offline-hinweis { bottom: 14px; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --weiss: #161c25; --grau-100: #0e131a; --grau-200: #262e3a; --grau-300: #38424f;
    --grau-500: #8a95a3; --grau-700: #b4bec9; --grau-900: #e8edf3;
    --gruen-hell: #11291a; --amber-hell: #2b2110; --rot-hell: #2b1512; --blau-hell: #101d35;
  }
  :root:not([data-theme="light"]) body { background: var(--grau-100); color: var(--grau-900); }
  :root:not([data-theme="light"]) .termin .tag { background: #1c2430; }
  :root:not([data-theme="light"]) .spieler.gesetzt-anwesend { background: #13251a; }
  :root:not([data-theme="light"]) .spieler.gesetzt-verspaetet { background: #121d2f; }
  :root:not([data-theme="light"]) .spieler.gesetzt-entschuldigt { background: #272013; }
  :root:not([data-theme="light"]) .spieler.gesetzt-fehlt { background: #291614; }
  :root:not([data-theme="light"]) .knopf.zweit { background: var(--weiss); color: var(--grau-900); }
}
