:root {
  --bg: #f4f6f8; --card: #fff; --ink: #1c2530; --muted: #6b7785;
  --accent: #2e7d32; --accent-d: #1b5e20; --line: #e2e6ea; --danger: #c62828;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px; background: var(--accent-d); color: #fff;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.05rem;
  display: flex; flex-direction: column; line-height: 1.15; }
.brand small { font-weight: 500; font-size: .72rem; opacity: .85; }
.admin-nav { display: flex; align-items: center; gap: 12px; }
.admin-nav a { color: #d7f0d8; text-decoration: none; font-weight: 600; }
.orga-badge { background: #ffb300; color: #3a2c00; font-weight: 800; font-size: .72rem;
  letter-spacing: .5px; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; }
/* Admin-Kopf optisch abheben, damit die Orga ihren Bereich erkennt */
header.admin { background: #143a16; border-bottom: 3px solid #ffb300; }

/* Tab-Leiste (Teilnehmer) */
nav.tabs {
  position: sticky; top: 0; z-index: 9;
  display: flex; background: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
nav.tabs .tab {
  flex: 1; text-align: center; padding: 12px 8px; color: #e9f6ea;
  text-decoration: none; font-weight: 700; font-size: .95rem;
  border-bottom: 3px solid transparent;
}
nav.tabs .tab.is-active { color: #fff; border-bottom-color: #fff; background: rgba(255,255,255,.12); }
.hint { color: var(--muted); margin: 0 0 12px; }
.standings tr.winner td { background: #f1f8f2; }
.standings tr.winner td.team { font-weight: 700; }

/* Orga-Qualifikation: qualifizierte Plätze hervorheben + Schnittlinie */
.qual-admin tr.qualified td { background: #e6f4ea; }
.qual-admin tr.qualified td.pos { font-weight: 800; color: var(--accent-d); }
.qual-admin tr.cutline td { border-bottom: 3px solid var(--danger); }
.qual-admin .los-cell { white-space: nowrap; }
.qual-admin .los-cell .inline { display: inline; }
.qual-admin .los-cell button {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  width: 30px; height: 30px; font-size: 1rem; font-weight: 700; cursor: pointer;
  color: var(--ink);
}
.qual-admin .los-cell button:hover { border-color: var(--accent); color: var(--accent-d); }
main { max-width: 720px; margin: 0 auto; padding: 14px; }
h1 { font-size: 1.4rem; margin: .4em 0 .6em; }
h2 { font-size: 1.1rem; margin: 1.1em 0 .5em; display: flex; align-items: center; gap: 10px; }

/* Übersicht: Gruppenkarten */
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } }
.card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; text-decoration: none; color: inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.card:hover, .card:focus {
  transform: translateY(-2px); border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.card:hover .chev { transform: translateX(3px); }
.card-head { font-weight: 700; margin-bottom: 8px; display: flex;
  align-items: center; justify-content: space-between; }
.card-foot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line);
  color: var(--accent-d); font-weight: 600; font-size: .82rem; text-align: right; }
.chev { color: var(--accent); font-weight: 800; transition: transform .12s ease;
  display: inline-block; }
.mini-table { list-style: none; margin: 0; padding: 0; }
.mini-table li { display: flex; align-items: baseline; gap: 8px; padding: 2px 0; font-size: .92rem; }
.mini-table .pos { width: 1.3em; color: var(--muted); font-variant-numeric: tabular-nums; }
.mini-table .team { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-table .wpd { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Tabellen */
table.standings { width: 100%; border-collapse: collapse; background: var(--card);
  border-radius: 12px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.standings th, .standings td { padding: 9px 10px; text-align: center; border-bottom: 1px solid var(--line); }
.standings th { background: #eef2f4; font-size: .8rem; text-transform: uppercase; color: var(--muted); }
.standings td.team { text-align: left; }
.standings td.pos { color: var(--muted); font-variant-numeric: tabular-nums; }
.standings tr:last-child td { border-bottom: none; }
/* anklickbare Team-Zeilen */
.standings.clickable td.team a { color: inherit; text-decoration: none;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.standings.clickable tbody tr:hover { background: #f1f8f2; }
.standings.clickable td.team a .chev { color: var(--accent); }
.back { margin: 0 0 4px; }
.back a { color: var(--accent-d); text-decoration: none; font-weight: 600; }

/* Spiele-Liste */
ul.matches { list-style: none; margin: 0; padding: 0; }
ul.matches li {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; margin-bottom: 8px;
}
.matches .time { color: var(--muted); font-size: .82rem; min-width: 64px; font-variant-numeric: tabular-nums; }
.matches .pairing { flex: 1; min-width: 180px; }
.matches .vs { color: var(--muted); font-size: .8rem; margin: 0 4px; }
.matches .score { font-weight: 700; font-variant-numeric: tabular-nums; }
.matches .score.pending { font-weight: 700; font-size: .72rem; color: #8a6100;
  background: #fff4e0; border-radius: 6px; padding: 2px 8px; }
.matches li.open { border-style: dashed; background: #fffdf7; }
.win { font-weight: 700; color: var(--accent-d); }

.legend { color: var(--muted); font-size: .78rem; margin: 6px 2px 0; }
h2 .count { font-size: .8rem; font-weight: 600; color: var(--muted); margin-left: 8px; }

/* K.O.-Banner */
.ko-banner { margin-top: 18px; padding: 12px 14px; border-radius: 10px; font-weight: 600; }
.ko-banner.ready { background: #e6f4ea; color: var(--accent-d); }
.ko-banner.wait { background: #fff4e0; color: #8a6100; }
.ko-banner a { color: inherit; }

/* Eingabe */
.entry-head { display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden; background: var(--card); }
.view-toggle a { padding: 8px 14px; text-decoration: none; color: var(--muted);
  font-weight: 700; font-size: .9rem; }
.view-toggle a.is-active { background: var(--accent); color: #fff; }

/* Orga-Seite: breiter & kompakter (nicht für mobil gedacht) */
.admin-page main { max-width: 1280px; }
.admin-page { font-size: 14px; }

/* Zwei-Spalten-Layout: links Eingabe, rechts Live-Stände */
.entry-layout { display: flex; gap: 22px; align-items: flex-start; }
.entry-main { flex: 1; min-width: 0; }
.entry-side { width: 360px; flex-shrink: 0; position: sticky; top: 12px;
  max-height: calc(100vh - 24px); overflow-y: auto; }
.side-title { margin: 0 0 8px; font-size: 1rem; }
.side-group { margin-bottom: 12px; }
.side-group h3 { margin: 0 0 4px; font-size: .9rem; }
.side-group h3 a { color: var(--accent-d); text-decoration: none; }
.side-group h3 a:hover { text-decoration: underline; }
table.standings.mini { font-size: .8rem; }
table.standings.mini th, table.standings.mini td { padding: 4px 6px; }
table.standings.mini td.team { max-width: 150px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 900px) {
  .entry-layout { flex-direction: column; }
  .entry-side { width: 100%; position: static; max-height: none; }
}

/* Phasen-Abschnitte mit klarem Trenner */
.phase { margin: 0 0 22px; }
.phase-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 8px 14px; border-radius: 8px; margin-bottom: 8px;
  background: var(--accent-d); color: #fff;
}
.phase-head .phase-name { font-size: 1.15rem; font-weight: 800; letter-spacing: .3px; }
.phase-head .phase-progress { font-size: .85rem; opacity: .9; font-variant-numeric: tabular-nums; }
.phase-head.complete { background: #2e7d32; }
/* K.O.-Phasen farblich abheben */
.phase-viertelfinale .phase-head { background: #1565c0; }
.phase-halbfinale   .phase-head { background: #6a1b9a; }
.phase-finale       .phase-head { background: #c62828; }
.phase-achtelfinale .phase-head { background: #00838f; }

.slot { margin-bottom: 6px; }
.slot-time { font-weight: 700; color: var(--accent-d); margin: 6px 2px 3px;
  font-size: .82rem; font-variant-numeric: tabular-nums; }

.badge { font-size: .68rem; font-weight: 700; color: var(--accent-d);
  background: #e6f4ea; border-radius: 6px; padding: 1px 6px; white-space: nowrap;
  min-width: 64px; text-align: center; }

/* kompakte Eingabezeilen auf der Orga-Seite */
.admin-page ul.matches li { padding: 4px 10px; margin-bottom: 4px; gap: 8px; }
.admin-page .matches .time { min-width: 70px; font-size: .78rem; }
.admin-page .matches .pairing { min-width: 0; font-size: .9rem; }
.admin-page .score-form input[type=number] { width: 3.4em; padding: 9px 8px; font-size: 1.05rem; }
.admin-page .score-form button { padding: 9px 14px; font-size: 1rem; }
.entry-row.done { border-left: 4px solid var(--accent); }
.entry-row.done .pairing { color: var(--muted); }
/* OK-Knopf nur grün, wenn ein Ergebnis eingetragen ist – sonst neutral grau */
.entry-row .score-form button { background: #b7c0c8; }
.entry-row.done .score-form button { background: var(--accent); }
.entry-row.saved { animation: savedflash .9s ease; }
@keyframes savedflash {
  0% { background: #d7f0d8; } 100% { background: var(--card); }
}
.entry-row.cleared { animation: clearedflash .9s ease; }
@keyframes clearedflash {
  0% { background: #fdecea; } 100% { background: var(--card); }
}

/* Pause (z.B. Bewässerung) im Zeitplan */
.break-row {
  margin: 8px 0; padding: 8px 14px; border-radius: 8px;
  background: #e0f0ff; color: #14507d; font-weight: 700;
  border-left: 4px solid #1565c0; font-variant-numeric: tabular-nums;
}

/* Toast-Hinweis (Speicher-Feedback) */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: var(--accent-d); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-weight: 700; font-size: .92rem; box-shadow: 0 4px 14px rgba(0,0,0,.22);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

.reset-bar { margin: 18px 0 4px; }

/* Teams bearbeiten */
table.teams-edit { width: 100%; border-collapse: collapse; }
table.teams-edit th { text-align: left; font-size: .78rem; text-transform: uppercase;
  color: var(--muted); padding: 4px 8px; }
table.teams-edit td { padding: 4px 8px; }
table.teams-edit td.tid { color: var(--muted); font-variant-numeric: tabular-nums; width: 3em; }
table.teams-edit input[type=text] {
  width: 100%; padding: 8px 10px; font-size: .95rem;
  border: 1px solid var(--line); border-radius: 8px;
}
table.teams-edit input[type=text]:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,125,50,.15);
}
.save-bar { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 40%); }
button.save-all { border: none; border-radius: 10px; padding: 12px 22px; font-size: 1rem;
  font-weight: 700; color: #fff; background: var(--accent); cursor: pointer; }
.status-cell { white-space: nowrap; text-align: right; }
.wd-label { color: var(--danger); font-weight: 700; font-size: .8rem; margin-right: 8px; }
.withdraw-btn { border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 6px 12px; font-weight: 600; font-size: .85rem; cursor: pointer; }
.team-row.is-withdrawn input[type=text] { text-decoration: line-through; color: var(--muted); }
.team-row.is-withdrawn .withdraw-btn { border-color: var(--accent); color: var(--accent-d); }

/* Walkover-Spiele (Absage) – bleiben im Plan, klar als abgesagt markiert */
.entry-row.walkover { opacity: .8; }
.matches .score.pending.walkover, .score.walkover { background: #fdecea; color: var(--danger); }
.pairing .wd { text-decoration: line-through; color: var(--muted); }

details { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 10px; padding: 4px 12px; }
summary { cursor: pointer; font-weight: 700; padding: 8px 0; }
.entry-row { gap: 8px; }
.score-form { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.score-form input[type=number] {
  width: 3.8em; padding: 11px 10px; font-size: 1.15rem; font-weight: 700;
  text-align: center; color: var(--ink);
  border: 2px solid var(--line); border-radius: 10px; background: #fff;
  font-variant-numeric: tabular-nums; transition: border-color .12s, box-shadow .12s;
}
.score-form input[type=number]:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46,125,50,.15);
}
/* keine Spinner-Pfeile (Eingabe per Numpad) */
.score-form input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.score-form input[type=number]::-webkit-outer-spin-button,
.score-form input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.score-form .colon { font-weight: 800; font-size: 1.1rem; color: var(--muted); }
.score-form button, .login button, button.danger {
  border: none; border-radius: 8px; padding: 10px 14px; font-size: 1rem;
  font-weight: 700; color: #fff; background: var(--accent); cursor: pointer;
}
button.danger { background: var(--danger); padding: 6px 12px; font-size: .85rem; }
form.inline { display: inline; margin: 0; }

/* Login */
form.login { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; max-width: 360px; display: grid; gap: 14px; }
form.login label { display: grid; gap: 6px; font-weight: 600; }
form.login input { padding: 12px; font-size: 1rem; border: 1px solid var(--line); border-radius: 8px; }

/* Flash */
.flashes { max-width: 720px; margin: 10px auto 0; padding: 0 14px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-weight: 600; }
.flash.ok { background: #e6f4ea; color: var(--accent-d); }
.flash.error { background: #fdecea; color: var(--danger); }
