:root {
  --bg: #f3f5f8;
  --flaeche: #ffffff;
  --flaeche-2: #eaeef4;
  --rand: #d5dce6;
  --text: #17202c;
  --text-2: #5b6878;
  --akzent: #c41e1a;          /* VBV-Rot (Logo) */
  --akzent-text: #ffffff;
  --akzent-hell: #fbe6e4;
  --gruen: #2f7d4f;
  --warn: #9a5b00;
  --gefahr: #b3261e;
  --schatten: 0 1px 2px rgba(20, 35, 60, .06), 0 3px 12px rgba(20, 35, 60, .06);
  --radius: 10px;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabbar: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d; --flaeche: #1a212b; --flaeche-2: #232c38; --rand: #313c4b;
    --text: #e6ebf2; --text-2: #9aa7b8; --akzent: #f2847c; --akzent-text: #2a0a08; --akzent-hell: #3d1c1a;
    --gruen: #6cc28f; --warn: #e6a74a; --gefahr: #f08a80;
    --schatten: 0 1px 2px rgba(0, 0, 0, .3), 0 3px 12px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--schrift); }
.hidden { display: none !important; }
a { color: var(--akzent); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.klein { font-size: .85em; color: var(--text-2); }
.leer { color: var(--text-2); padding: 1.5rem 0; text-align: center; }
.fehler { color: var(--gefahr); }
.warn { color: var(--warn); }
.zahl { font-variant-numeric: tabular-nums; text-align: right; }
.spacer { flex: 1; }

/* ---------- Kopf und Tab-Leiste ---------- */
.kopf {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
  padding: 8px 16px; background: var(--flaeche); border-bottom: 1px solid var(--rand);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.logo img { border-radius: 8px; }
.logo span { display: flex; flex-direction: column; line-height: 1.15; }
.logo small { color: var(--text-2); font-size: .78rem; }
.admin-hinweis { margin-left: auto; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--akzent-hell); color: var(--akzent); }

.tabs { display: flex; gap: 2px; }
.tabs a {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.tabs a:hover { background: var(--flaeche-2); }
.tabs a.aktiv { color: var(--akzent); background: var(--akzent-hell); }
.tabs .ico { font-size: 1.05rem; line-height: 1; }

.inhalt { max-width: 1100px; margin: 0 auto; padding: 16px; }

@media (max-width: 760px) {
  .kopf { padding: 8px 16px; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tabbar) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: var(--flaeche); border-top: 1px solid var(--rand); gap: 0;
  }
  .tabs a { flex: 1; flex-direction: column; justify-content: center; gap: 2px; font-size: .72rem; border-radius: 0; padding: 6px 2px; }
  .tabs a.aktiv { background: none; }
  .tabs .ico { font-size: 1.3rem; }
  .inhalt { padding: 12px 12px calc(var(--tabbar) + 24px + env(safe-area-inset-bottom)); }
}

/* ---------- Formularelemente ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--rand); border-radius: 8px; background: var(--flaeche);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--akzent); outline-offset: -1px; border-color: transparent; }
input.ungueltig { border-color: var(--gefahr); background: color-mix(in srgb, var(--gefahr) 8%, var(--flaeche)); }
label { display: block; font-size: .82rem; color: var(--text-2); }
label > input, label > select, label > textarea { margin-top: 3px; font-size: .95rem; color: var(--text); }
.formular { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.formular .breit { grid-column: 1 / -1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35em; padding: 8px 14px;
  border: 1px solid var(--rand); border-radius: 8px; background: var(--flaeche); cursor: pointer;
  text-decoration: none; color: var(--text); white-space: nowrap; font-size: .92rem; line-height: 1.25;
}
.btn:hover { background: var(--flaeche-2); }
.btn.primaer { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.btn.primaer:hover { filter: brightness(1.08); }
.btn.gefahr { color: var(--gefahr); }
.btn.klein { padding: 4px 9px; font-size: .82rem; }
.btn.ohne { border-color: transparent; background: none; }
.btn:disabled { opacity: .5; cursor: default; }
.knopfleiste { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }

/* Segment-Schalter (Damen/Herren, Klassen) */
.segment { display: inline-flex; background: var(--flaeche-2); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segment button {
  border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-weight: 500;
}
.segment button.aktiv { background: var(--flaeche); color: var(--text); box-shadow: var(--schatten); }

.steuerung { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.steuerung .suche { flex: 1 1 180px; max-width: 260px; }
.steuerung select { width: auto; }

/* ---------- Karten ---------- */
.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); box-shadow: var(--schatten); padding: 16px; margin-bottom: 16px; }
.karte > h2:first-child, .karte > h3:first-child { margin-top: 0; }
.karte-kopf { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 10px; }
.karte-kopf h2 { margin: 0; }

.stand { color: var(--text-2); font-size: .88rem; margin: 0 0 12px; }
.stand b { color: var(--text); font-weight: 600; }

/* ---------- Ranglisten-Tabelle ---------- */
.tabelle-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 6px; text-align: left; border-bottom: 1px solid var(--rand); vertical-align: middle; }
th { font-size: .75rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
tbody tr:hover { background: var(--flaeche-2); }
.rl td.rang { width: 2.4em; text-align: right; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.rl tr.top3 td.rang { color: var(--akzent); }
.rl td.name { font-weight: 600; }
.rl td.name a { color: inherit; text-decoration: none; }
.rl td.name a:hover { color: var(--akzent); text-decoration: underline; }
.rl td.name .sub { display: block; font-weight: 400; font-size: .8rem; color: var(--text-2); }
.rl td.erg, .rl th.erg { text-align: right; font-variant-numeric: tabular-nums; width: 3.6em; }
.rl td.erg.null { color: var(--text-2); }
.rl td.erg.gestrichen { text-decoration: line-through; color: var(--text-2); }
.rl td.ges, .rl th.ges { text-align: right; font-weight: 700; width: 3.8em; font-variant-numeric: tabular-nums; }
.rl th.erg small { display: block; font-weight: 400; text-transform: none; letter-spacing: 0; }
.marke { display: inline-block; margin-left: 4px; font-size: .75rem; font-weight: 700; color: var(--gruen); }
.marke.gast { color: var(--akzent); }
.legende { font-size: .8rem; color: var(--text-2); margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.nur-breit { }
@media (max-width: 560px) {
  .nur-breit { display: none; }
  .karte { padding: 12px; }
  .tabelle-wrap { margin: 0 -12px; padding: 0 12px; }
  th, td { padding: 7px 3px; }
  .rl td.rang { width: 2em; }
  .rl td.erg, .rl th.erg { width: 2.7em; font-size: .82rem; }
  .rl th.erg small { font-size: .62rem; }
  .rl td.ges, .rl th.ges { width: 3em; }
  .rl td.name { font-size: .92rem; }
  [data-drucken] { display: none; }
}

/* ---------- Admin-Listen ---------- */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--rand); }
.liste li:last-child { border-bottom: 0; }
.liste a.zeile { display: flex; flex: 1; gap: 10px; align-items: center; color: inherit; text-decoration: none; min-width: 0; }
.liste .titel { font-weight: 600; }
.liste .meta { font-size: .82rem; color: var(--text-2); }
.pille { display: inline-block; font-size: .72rem; padding: 1px 7px; border-radius: 99px; background: var(--flaeche-2); color: var(--text-2); font-weight: 600; }
.pille.E { background: #fbe6e4; color: #a3150f; }
.pille.D { background: #dff3e6; color: #24683f; }
.pille.M { background: #f6e6f3; color: #7d2c6c; }
@media (prefers-color-scheme: dark) {
  .pille.E { background: #3d1c1a; color: #f5aca6; }
  .pille.D { background: #1d3a2a; color: #9ad7b1; }
  .pille.M { background: #3a2036; color: #e3a8d6; }
}

/* Ergebnis-Eingabe */
.erg-tab td { padding: 4px 3px; border-bottom: 0; }
.erg-tab td.platz { width: 4.2em; }
.erg-tab td.punkte { width: 5.5em; }
.erg-tab td.aktion { width: 2.4em; }
.erg-tab input { padding: 6px 8px; }
.erg-tab .hinweis { font-size: .75rem; color: var(--warn); display: block; margin-top: 1px; }
.erg-tab .hinweis.info { color: var(--text-2); }
@media (max-width: 560px) {
  .erg-tab tr { display: grid; grid-template-columns: 4em 1fr 2.4em; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--rand); }
  .erg-tab td { width: auto !important; }
  .erg-tab td.sp { grid-column: 2 / 3; }
  .erg-tab td.sp + td.sp { grid-column: 2 / 3; }
  .erg-tab td.punkte { grid-column: 2 / 3; }
  .erg-tab thead { display: none; }
}

/* ---------- Dialog und Meldungen ---------- */
.dialog { border: 0; border-radius: 12px; padding: 20px; width: min(520px, calc(100vw - 32px)); background: var(--flaeche); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.dialog::backdrop { background: rgba(10, 20, 35, .45); }
.meldung {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 16px); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--schatten); max-width: calc(100vw - 32px);
}
.meldung.fehler { background: var(--gefahr); color: #fff; }
@media (min-width: 761px) { .meldung { bottom: 24px; } }

.login { max-width: 360px; margin: 8vh auto; }

.info-text p, .info-text li { max-width: 70ch; }
.info-text table { width: auto; }
.info-text td, .info-text th { padding: 4px 12px 4px 0; }

/* ---------- Druck ---------- */
@media print {
  .kopf, .tabs, .steuerung, .knopfleiste, .nicht-drucken { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .inhalt { padding: 0; max-width: none; }
  .karte { border: 0; box-shadow: none; padding: 0; break-inside: avoid; }
  .nur-breit { display: table-cell !important; }
  tbody tr:hover { background: none; }
}

/* Punktetabelle */
.punkte-tab th small { display: block; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: .7rem; }
.punkte-tab td.zahl, .punkte-tab th.zahl { width: 4.5em; text-align: right; }
.punkte-tab td.rang { width: 3em; }
.punkte-tab input { width: 4.6em; padding: 4px 6px; text-align: right; margin-left: auto; display: block; }

/* Alle Altersklassen untereinander: beim Druck jede Liste auf eigener Seite */
@media print {
  .liste-block + .liste-block { break-before: page; }
}

/* Checkbox in der Filterleiste */
.schalter { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--text); white-space: nowrap; cursor: pointer; }
.schalter input { width: auto; margin: 0; accent-color: var(--akzent); }
