:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --ink: #1b2230;
  --muted: #687082;
  --line: #e1e3dd;
  --accent: #0f5bd8;
  --accent-ink: #ffffff;
  --accent-soft: #e6eefc;
  --ok: #157a46;
  --ok-soft: #e3f4ea;
  --warn: #b35c00;
  --warn-soft: #fdf0e1;
  --err: #b42318;
  --err-soft: #fdeceb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b2029;
    --ink: #e8eaee;
    --muted: #98a0b0;
    --line: #2c3340;
    --accent: #5b93f5;
    --accent-ink: #0b1220;
    --accent-soft: #1d2a44;
    --ok: #5fcf8f;
    --ok-soft: #173326;
    --warn: #f0a650;
    --warn-soft: #3a2a16;
    --err: #f08a80;
    --err-soft: #3d1f1d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 64px; }
.wrap.schmal { max-width: 440px; padding-top: 10vh; }
.wrap.breit { max-width: 1100px; }

h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
p { margin: 0 0 12px; }
small, .muted { color: var(--muted); }
.zahl { font-variant-numeric: tabular-nums; white-space: nowrap; }

.karte {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

/* Kopfzeile */
.kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.kopf .aktionen { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* Formulare */
label, legend { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 4px; padding: 0; }
fieldset { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.feld { margin-bottom: 14px; }
.hilfe, .feld .hilfe { font-size: .82rem; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=search], input[type=email], input[type=number], input[type=password], input[type=date],
select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
}
input:focus, select:focus, textarea:focus, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--accent); }
.code-eingabe { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:disabled { opacity: .55; cursor: default; }
button.zweit, .btn.zweit { background: var(--surface); color: var(--ink); border-color: var(--line); }
button.text { background: none; color: var(--accent); padding: 6px 8px; min-height: 36px; }
button.klein, .btn.klein { padding: 6px 10px; min-height: 36px; font-size: .9rem; }
button.gefahr { background: var(--err); color: #fff; }
button.icon { background: none; color: var(--muted); padding: 6px; min-height: 36px; min-width: 36px; }
button.icon:hover { color: var(--ink); background: var(--bg); }
button.voll { width: 100%; }
.zeile { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.zeile.rechts { justify-content: flex-end; }

/* Hinweise */
.banner { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: .95rem; }
.banner.offen { background: var(--accent-soft); }
.banner.zu { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.banner.ok { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.fehler { background: var(--err-soft); color: var(--err); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: .92rem; }
.hinweis { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px 6px; margin-bottom: 16px; font-size: .95rem; }
.leer-hinweis { text-align: center; padding: 28px 16px; color: var(--muted); }
.status { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .82rem; font-weight: 700; }
.status.offen { background: var(--warn-soft); color: var(--warn); }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.info { background: var(--accent-soft); color: var(--accent); }
.status.storno { background: var(--err-soft); color: var(--err); }
.status.leer { background: var(--bg); color: var(--muted); }

/* Profil: Übungsgruppen */
.gruppen-wahl { border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; }
.gruppen-wahl .check { padding: 8px 0; margin: 0; }
.gruppen-wahl .check + .check { border-top: 1px solid var(--line); }
.gruppen-wahl.ungueltig { border-color: var(--err); box-shadow: 0 0 0 1px var(--err); }
#p-gruppen-fehler { margin-bottom: 8px; }
.konto-loeschen summary { cursor: pointer; color: var(--muted); font-size: .9rem; padding: 6px 0; }

/* Startaktionen und Abschnitte */
.start-aktionen { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.aktion-karte { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 4px; text-align: left;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; min-height: 0; font-weight: 400; }
.aktion-karte:hover { border-color: var(--accent); }
.aktion-titel { font-weight: 700; color: var(--accent); font-size: 1.02rem; }
.aktion-titel::before { content: "+ "; }
.aktion-text { font-size: .88rem; color: var(--muted); }
.abschnitt { margin-bottom: 28px; }
#angebote-info { font-size: .92rem; margin: -4px 0 12px; }
.treff-titel { display: flex; align-items: center; gap: 4px; }
.treff-titel button.text { min-height: 28px; padding: 2px 6px; font-size: .9rem; }
.treff-liste { margin: 2px 0 0; padding-left: 18px; color: var(--ink); font-weight: 600; line-height: 1.45; }
.abschnitt > h2 { font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.zahl-badge:not(:empty) { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); font-size: .8rem; line-height: 20px; color: var(--muted); text-align: center; font-weight: 600; }
.eigen-badge { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: .75rem; font-weight: 700; text-transform: none; letter-spacing: 0; vertical-align: 1px; }
.gruppe-kopf.eigen { background: var(--accent-soft); }
.gruppe-kopf.eigen .eigen-badge { background: var(--surface); }

/* Einträge */
.eintrag { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 12px; overflow: hidden; }
.eintrag-kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 12px 14px 4px; }
.eintrag-kopf .titel { font-weight: 700; }
.eintrag-kopf .meta { font-size: .85rem; color: var(--muted); }
.eintrag-kopf .aktionen { display: flex; gap: 2px; flex-shrink: 0; }
.eintrag-inhalt { padding: 4px 14px 12px; }
.gesucht-info { color: var(--ok); font-weight: 600; }
.notiz { font-size: .9rem; color: var(--muted); margin-top: 6px; white-space: pre-line; }
.notiz::before { content: "„"; }
.notiz::after { content: "“"; }

.varianten { display: grid; gap: 4px; }
.v-zeile { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.v-schnitt { font-size: .85rem; color: var(--muted); min-width: 58px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px;
  font-size: .88rem; font-weight: 600; background: var(--bg); font-variant-numeric: tabular-nums; }
.chip.treffer { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.chip-zahl { background: var(--ok); color: var(--surface); border-radius: 999px; font-size: .72rem; min-width: 18px; line-height: 18px;
  text-align: center; padding: 0 5px; }

.treffer-block { border-top: 1px solid var(--line); background: var(--bg); padding: 10px 14px 12px; }
.treffer-titel { font-weight: 700; font-size: .92rem; margin-bottom: 6px; color: var(--ok); }
.ort { margin-top: 8px; }
.ort-name { font-size: .85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
.anbieter { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; }
.anbieter-name { font-weight: 700; margin-bottom: 4px; }

/* Alle Angebote nach Übungsgruppe */
.gruppe { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow); }
.gruppe-kopf { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px;
  padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--line); }
.gruppe-kopf .titel { font-weight: 700; }
.gruppe-kopf .meta { font-size: .88rem; color: var(--muted); }
.person { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person-artikel { margin-top: 4px; }
.person-artikel + .person-artikel { margin-top: 10px; }
.person-artikel-name { font-size: .9rem; font-weight: 600; margin-bottom: 2px; }

/* Raster Schnitt × Größe */
.raster { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 8px; }
.raster-zeile { display: grid; grid-template-columns: 70px 1fr; gap: 8px; align-items: start; }
.raster-schnitt { font-weight: 600; font-size: .9rem; padding-top: 8px; }
.raster-groessen { display: flex; flex-wrap: wrap; gap: 6px; }
.toggle { margin: 0; font-weight: 600; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle span { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 40px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-variant-numeric: tabular-nums; }
.toggle input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Dialog */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); max-height: calc(100vh - 24px); overflow: auto;
}
dialog::backdrop { background: rgba(10, 15, 25, .5); }
dialog .innen { padding: 18px; }

/* Tabellen (Admin) */
.tabelle-wrap { overflow-x: auto; }
table.liste { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.liste th, table.liste td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.liste th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.liste td.r, table.liste th.r { text-align: right; }
table.liste tfoot td { font-weight: 700; }
table.liste tr.luecke td { background: var(--warn-soft); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; color: var(--muted); border-radius: 8px 8px 0 0; border-bottom: 2px solid transparent; flex-shrink: 0; }
.tabs button.aktiv { color: var(--ink); border-bottom-color: var(--accent); }
.filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter > * { width: auto; flex: 1 1 180px; }
.nachweis { margin-top: 6px; padding: 6px 10px; background: var(--accent-soft); border-radius: 6px; font-size: .88rem; white-space: pre-line; font-weight: 400; }
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 16px; }
.kacheln .wert { font-size: 1.3rem; font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: .93rem; z-index: 50; max-width: calc(100vw - 32px);
}
.versteckt { display: none !important; }

@media (max-width: 520px) {
  h1 { font-size: 1.3rem; }
  .start-aktionen { grid-template-columns: 1fr; gap: 8px; }
  .kopf { flex-direction: column; }
  .raster-zeile { grid-template-columns: 1fr; gap: 4px; }
  .raster-schnitt { padding-top: 0; }
}
