:root {
    --bg: #f6f7f9;
    --fg: #1c1f23;
    --muted: #5b6470;
    --accent: #2f6f4f;
    --border: #d9dde2;
    --danger: #b3261e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--fg);
    background: var(--bg);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; color: var(--accent); text-decoration: none; }

.topbar nav a { margin-left: 1rem; color: var(--muted); text-decoration: none; }


/* Burger button (feature 019). Every property of the global `button` rule further down is
   overridden here explicitly — inheriting its `color: #fff` is what made the first attempt's
   icon invisible (white on white). The three bars are drawn in currentColor, like the VFC site. */
.nav-toggle {
    display: none;
    position: relative;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--fg);
    cursor: pointer;
}
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
}
/* Unread notifications / action required while collapsed (FR-008). */
.nav-toggle.has-unread::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;   /* border-box: 8px dot + 2px white ring */
    height: 12px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--accent);
}

/* Collapsed top-bar. 960px must match the matchMedia query in src/app.js. The logged-in row
   needs up to ~860px (research R2), so narrower screens get the burger instead. */
@media (max-width: 960px) {
    .topbar { position: relative; }
    .nav-toggle { display: inline-flex; }
    .topbar nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        background: #fff;
        border-bottom: 1px solid var(--border);
        padding: 0.25rem 1.25rem 0.75rem;
        z-index: 10;
    }
    .topbar nav.open { display: flex; }
    .topbar nav a { margin-left: 0; padding: 0.5rem 0; }
}

.context-bar {
    padding: 0.4rem 1.25rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
/* Feature 021 (FR-018/FR-019): logged-in name, moved here from the top bar. Truncated so a long
   name/e-mail never widens a phone screen; the full text is in its title attribute. */
#user-name {
    display: inline-block;
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}
.topbar nav a:hover { color: var(--fg); }

.container { max-width: 760px; margin: 2rem auto; padding: 0 1.25rem; }

h1 { font-size: 1.4rem; }

form { display: grid; gap: 0.9rem; max-width: 360px; }

label { display: grid; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }

input {
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}

/* Feature 051: password input with an eye button (render.js passwordField). */
.password-wrap { position: relative; display: block; }
.password-wrap input { width: 100%; box-sizing: border-box; padding-right: 2.75rem; }
.password-toggle {
    position: absolute; top: 50%; right: 0.15rem; transform: translateY(-50%);
    width: 2.5rem; height: 2.5rem; padding: 0; margin: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 0; border-radius: 6px; color: var(--muted); cursor: pointer;
}
.password-toggle:hover { color: inherit; background: transparent; }
.password-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
.password-toggle svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

button {
    padding: 0.55rem 0.9rem;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    cursor: pointer;
}

button.secondary { background: #e7eaee; color: var(--fg); }
button.danger { background: var(--danger); }

.error { color: var(--danger); font-size: 0.85rem; }
.notice { color: var(--muted); font-size: 0.85rem; }

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
}

.tabs { display: flex; gap: 0.25rem; margin: 1rem 0; border-bottom: 1px solid var(--border); }
/* Feature 020 (FR-006/FR-007): below the container's full width (.container max 760px → 720px of
   content) the shrinking tabs no longer fit, so wrap them onto further lines instead of letting
   the page scroll sideways. From 760px up the content area is always 720px wide and the tabs look
   exactly as before (FR-008). */
/* Feature 038 follow-up: App Admin now has up to 7 tabs, more than fit 720px - wrap at every width.
   Tabs that fit on one line look exactly as before. */
.tabs { flex-wrap: wrap; }
.tabs a {
    padding: 0.5rem 0.9rem;
    text-decoration: none;
    color: var(--muted);
    border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--fg); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.card button { margin-top: 0.6rem; }

/* Spielbericht (feature 020): teams always stacked, one player list per line; substitution form
   three lines per team. No max-width on select — options are short enough (FR-004). */
.lineup { margin-top: 0.5rem; }
.lineup-side + .lineup-side { margin-top: 0.75rem; }
.lineup-side select { display: block; margin-top: 0.3rem; }
.sub-side { margin-top: 0.5rem; }
.sub-side > div + div { margin-top: 0.3rem; }
/* Feature 021 (FR-017): the "rein" line, without the team name, indented under "raus". */
.sub-side .sub-in { margin-left: 1rem; }
/* Feature 025 (FR-014/FR-015): team name above each result input; truncated, full name in title. */
.result-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem; margin-top: 0.5rem; }
.result-row button { margin-top: 0; }
/* Feature 057: Aufnahmen with Gegnerbestaetigung / Scorekeeper. */
.ends-list { margin: 0.25rem 0; border-collapse: collapse; }
.ends-list td, .ends-list th { padding: 0.15rem 0.5rem; text-align: left; }
.ends-pending { margin: 0.5rem 0; padding: 0.4rem 0.6rem; border-left: 3px solid #2563eb; background: rgba(37, 99, 235, 0.06); }
.ends-sides, .ends-points { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.ends-points button { min-width: 2.5rem; }
.result-cell { display: flex; flex-direction: column; min-width: 0; max-width: 40vw; }
.result-cell .result-team {
    font-size: 0.8rem; color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.badge { display: inline-flex; align-items: center; gap: 0.25rem; text-decoration: none; }
.badge-count {
    background: var(--accent); color: #fff; border-radius: 999px;
    font-size: 0.7rem; padding: 0.05rem 0.4rem; min-width: 1.1rem; text-align: center;
}
.badge-action {
    background: var(--danger); color: #fff; border-radius: 999px;
    font-size: 0.7rem; font-weight: 700; padding: 0.05rem 0.4rem;
}

/* Feature 025 (FR-009/FR-010): Partie status in the Liga-Spieltag overview. The text alone names
   the status; the color only helps scanning. */
.status-tag {
    display: inline-block; margin-top: 0.3rem; padding: 0.05rem 0.5rem; max-width: 100%;
    border-radius: 999px; border: 1px solid var(--border); font-size: 0.8rem; white-space: nowrap;
}
.status-scheduled { background: #eef0f3; color: var(--fg); }
.status-running_triplette { background: #dbe8f7; color: #1d4470; }
.status-running_doublette { background: #c7dbf2; color: #163a61; }
.status-awaiting_signature { background: #fbeccb; color: #6b4a00; }
.status-closed { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Feature 027: Liga-Tabelle. The server decides values, order, Live and zones; these rules only
   draw them. Live stays recognisable without color: "Live" text, bold values, a frame (FR-019). */
.league-table-wrap { max-width: 100%; overflow-x: auto; }
.league-table { border-collapse: collapse; width: 100%; margin: 0.5rem 0; }
.league-table th, .league-table td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; }
.league-table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.league-table .num { text-align: right; white-space: nowrap; }
.league-table .team-name {
    display: inline-block; max-width: 16rem; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; vertical-align: bottom;
}
.live-tag {
    display: inline-block; margin-left: 0.4rem; padding: 0 0.35rem; border: 1px solid var(--danger);
    border-radius: 999px; color: var(--danger); font-size: 0.75rem; font-weight: 700; vertical-align: middle;
}
.live-value { font-weight: 700; }
.league-table td.live-box { border-top: 2px solid var(--danger); border-bottom: 2px solid var(--danger); }
.league-table td.live-box-first { border-left: 2px solid var(--danger); }
.league-table td.live-box-last { border-right: 2px solid var(--danger); }
.zone-meister td { background: #e3f1e8; }
.zone-abstieg td { background: #f8e1df; }
.table-legend { list-style: none; padding: 0; margin: 0.5rem 0; font-size: 0.85rem; color: var(--muted); }
.table-legend li { margin: 0.25rem 0; }
.table-legend .live-tag { margin-left: 0; }
.legend-swatch {
    display: inline-block; width: 0.9rem; height: 0.9rem; border: 1px solid var(--border);
    vertical-align: middle;
}
.legend-swatch.zone-meister { background: #e3f1e8; }
.legend-swatch.zone-abstieg { background: #f8e1df; }
.rotate-hint { display: none; }
@media (max-width: 900px) {
    .league-table { font-size: 0.85rem; }
    .league-table th, .league-table td { padding: 0.25rem 0.35rem; }
    .league-table .team-name { max-width: 9rem; }
}
/* FR-022: on a phone held upright the table makes no sense — show a hint instead. Pure CSS, so
   turning the phone switches without a reload. */
@media (max-width: 639px) and (orientation: portrait) {
    .rotate-hint { display: block; }
    .league-table-wrap { display: none; }
}

/* Feature 028: direct final-result entry (Runden window + Partie page). Narrow number fields;
   the cell wraps instead of widening the page, the rounds table scrolls inside its card. */
.rounds-table-wrap { max-width: 100%; overflow-x: auto; }
input.result-entry { width: 3.5rem; padding: 0.35rem 0.4rem; }
.result-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.result-cell button { margin-top: 0; padding: 0.35rem 0.6rem; }
.result-cell .error { flex-basis: 100%; }
.result-line { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem; }
.result-sep { font-weight: 600; }

/* Feature 029: the two Mannschaften reported different results — both must re-report. */
.result-conflict {
    border: 1px solid var(--danger); border-radius: 6px; color: var(--danger);
    padding: 0.4rem 0.6rem; margin: 0.5rem 0; font-size: 0.9rem;
}

/* Feature 030: the Mannschaft's group line-up is final — red, not clickable. */
button.locked, button.locked:hover {
    background: var(--danger); color: #fff; border-color: var(--danger);
    cursor: not-allowed; opacity: 0.85;
}

/* Feature 033: QR code of "Nutzer reg. und verknüpfen" — scales to the card at 360 px (FR-014); white
   background keeps the quiet zone readable for phone cameras in dark mode too. */
.qr-code { display: block; width: 100%; max-width: 320px; height: auto; margin: 0.5rem auto; background: #fff; }

/* Feature 041: Landesverband/Region headers in the Liga dropdown — not selectable, readable. */
option.league-header { font-weight: 600; color: var(--muted); }

/* Feature 041: App Admin "Ligastruktur" — nested lists, one indent per level, no sideways scroll. */
.league-tree, .league-tree ul { list-style: none; margin: 0; padding-left: 0; }
.league-tree ul { padding-left: 1rem; border-left: 1px solid var(--border); margin-left: 0.3rem; }
.league-tree li { margin: 0.25rem 0; overflow-wrap: anywhere; }
.league-tree .tree-group { font-weight: 600; }
.league-tree .tree-meta { color: var(--muted); font-size: 0.9em; }

/* Feature 042: Saisonwechsel, Spieltermine. Zones reuse the Liga-Tabelle colours. */
.table-scroll { overflow-x: auto; max-width: 100%; }
table.transition td { vertical-align: top; }
table.transition tr.zone-up td { background: #e3f1e8; }
table.transition tr.zone-down td { background: #f8e1df; }
.transition-status { padding: 0.1rem 0.5rem; border-radius: 4px; background: #eef0f3; }
.transition-status.ready { background: #e3f1e8; }
.transition-status.waiting { background: #fdf3d8; }
.transition-status.applied { background: #e1ebf6; }
.issue { margin: 0.25rem 0; padding: 0.35rem 0.6rem; border-radius: 4px; }
.issue.error { background: #f8e1df; color: var(--danger); }
.issue.warning { background: #fdf3d8; color: #6b4e00; }
.matchday-dates { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin: 0.5rem 0; }
.matchday-dates label { display: flex; flex-direction: column; }
details > summary { cursor: pointer; margin: 0.35rem 0; }

/* Feature 044: Aufstiegsrunde — Los-Kennzeichen, Import-Fehler. */
.lot-tag { margin-left: 0.4rem; padding: 0 0.35rem; border-radius: 3px; background: #fdf3d8; color: #6b4e00; font-size: 0.8em; white-space: nowrap; }
ul.error { margin: 0.25rem 0; padding-left: 1.2rem; }
textarea { max-width: 100%; }

/* Feature 047: fold button of the Spielermeldeliste, on the heading line. */
.squad-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem; }
.squad-head .squad-toggle { margin-left: auto; padding: 0.15rem 0.6rem; font-size: 0.85rem; }

/* Feature 052: App Admin → Saison planen (season-plan.js, lib/drag.js). */
.warning { color: #8a6100; font-size: 0.85rem; }
button.small { padding: 0.15rem 0.45rem; font-size: 0.8rem; }
.plan-dates { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.plan-check p { margin: 0.2rem 0; }
.plan-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; align-items: start; margin-top: 1rem; }
.plan-termin { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; background: #fff; display: grid; gap: 0.6rem; }
.plan-place { border: 1px dashed var(--border); border-radius: 6px; padding: 0.5rem; display: grid; gap: 0.35rem; }
.plan-teams { display: flex; flex-wrap: wrap; gap: 0.3rem; min-height: 1.8rem; }
.plan-team { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.15rem 0.45rem; border-radius: 999px; background: #eef2f7; font-size: 0.8rem; }
.plan-spieltag { border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem 0.5rem; background: #fafbfc; }
.plan-spieltag.kept { background: #f1f1f1; color: var(--muted); }
.plan-spieltag-head { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.3rem; }
.plan-match { display: flex; justify-content: space-between; align-items: center; gap: 0.3rem; padding: 0.2rem 0; border-top: 1px solid #eceff3; font-size: 0.85rem; }
.move-select { padding: 0.05rem 0.2rem; font-size: 0.75rem; max-width: 2.6rem; }
.has-error { outline: 2px solid var(--danger); outline-offset: 1px; }
.draggable { cursor: grab; touch-action: none; user-select: none; }
.dragging { opacity: 0.4; }
.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; opacity: 0.9; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2); background: #fff; border-radius: 6px; }
.drop-ok { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop-no { outline: 2px dashed var(--danger); outline-offset: 2px; }
@media (max-width: 640px) {
    .plan-board { grid-template-columns: 1fr; }
}
.drag-handle { display: inline-block; padding: 0.1rem 0.35rem; color: var(--muted); }

/* Feature 053: Liga-Spiele (pages/league/games.js). */
.game-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.game-frame { border: 2px solid var(--border); border-radius: 8px; padding: 0.6rem 0.75rem; background: #fff; display: grid; gap: 0.25rem; }
/* Feature 054: laufende Begegnung blau; Kopf Heim | Gesamtergebnis | Gast, Plätze unter den Namen. */
.game-frame.running { border-color: #1d5fbf; }
.live-score { color: #1d5fbf; } /* feature 057 */
.game-head { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 0.5rem; font-weight: 600; }
.game-side { min-width: 0; text-align: center; }
.game-side .team-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-total { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.game-places { display: flex; justify-content: center; gap: 0.5rem; font-variant-numeric: tabular-nums; }
.place-official { color: #000; }
.place-better { color: #1b7f3b; }
.place-worse { color: var(--danger); }
.place-same { color: #1d5fbf; }
.game-line { display: flex; justify-content: space-between; font-size: 0.9rem; border-top: 1px solid #eceff3; padding-top: 0.2rem; }
.game-line .num { font-variant-numeric: tabular-nums; }
.move-promoted { color: var(--accent); }
.move-relegated { color: var(--danger); }
@media (max-width: 640px) { .game-group { grid-template-columns: 1fr; } }
/* Feature 055: Saisonwechsel-Struktur, kommissarische Bewegungen, entfernte Mannschaften. */
.structure-league { margin: 0.6rem 0 1rem; }
.structure-league h4 { margin: 0.4rem 0; }
.size-ok { color: var(--muted); font-weight: normal; }
.size-under, .size-over { color: var(--danger); font-weight: normal; }
tr.commissarial td { font-style: italic; }
tr.removed td { text-decoration: line-through; color: var(--muted); }
.fill-chooser select { max-width: 100%; }

/* Feature 058: Schiedsrichter-Wesen. */
.ref-row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.35rem 0; }
.ref-slot { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.3rem 0; }
.ref-slot select { max-width: 100%; }
.ref-sub { margin-bottom: 0.5rem; }
.ref-sub button.active { font-weight: bold; text-decoration: underline; }
.ref-months { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.4rem 0; }
.ref-day { padding: 0.2rem 0; border-bottom: 1px solid rgba(127, 127, 127, 0.2); }
.ref-ok { color: #1a7f37; }
.ref-due_soon { color: #9a6700; font-weight: bold; }
.ref-overdue { color: #cf222e; font-weight: bold; }
.ref-cal { max-width: 22rem; }
.ref-cal-head { display: flex; justify-content: space-between; align-items: center; margin: 0.4rem 0; }
.ref-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.2rem; }
.ref-cal-grid button { padding: 0.35rem 0; min-width: 0; }
.ref-cal-grid button.ref-on { background: #1d5fbf; color: #fff; }

/* Feature 059: Ergebnis über Gewinner und Punkte des Verlierers. */
.winner-entry { margin: 0.4rem 0; max-width: 100%; }
.winner-choices { display: flex; flex-direction: column; gap: 0.35rem; }
.winner-choice { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; overflow-wrap: anywhere; }
.winner-choice input { width: 1.4rem; height: 1.4rem; flex: 0 0 auto; margin: 0; }
.winner-sentence { margin: 0.5rem 0 0.35rem; overflow-wrap: anywhere; }
.winner-points { display: flex; flex-direction: column; gap: 0.35rem; }
.winner-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.3rem; max-width: 22rem; }
.winner-point { position: relative; display: flex; align-items: center; justify-content: center; min-height: 2.5rem;
    border: 1px solid rgba(127, 127, 127, 0.6); border-radius: 0.35rem; cursor: pointer; user-select: none;
    transition: transform 0.12s ease; font-weight: bold; }
.winner-point input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.winner-point:focus-within { outline: 2px solid #1d5fbf; outline-offset: 2px; }
.winner-point.chosen { transform: scale(1.12); background: #1d5fbf; color: #fff; border-color: #1d5fbf; }

/* Feature 060: Zeitregel — Meldeliste state and Frist */
.time-rule { margin: .5rem 0; }
.time-rule-state { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .9em; border: 1px solid currentColor; }
.time-rule-accepted { color: #1b7f3b; }
.time-rule-submitted { color: #8a6d00; }
.time-rule-refused { color: #b3261e; }
.time-rule-none { color: #666; }
.time-rule-frist { color: #b3261e; font-weight: 600; }
.countdown { font-variant-numeric: tabular-nums; }
.end-penalty { font-style: italic; color: #b3261e; }
