:root {
    --red: #c8102e;
    --red-dark: #8b0a1f;
    --navy: #0a2a52;
    --navy-soft: #1d3a6b;
    --accent: #f5b800;
    --dark: #1f2933;
    --grey: #f4f6fa;
    --border: #d7dce2;
    --green: #2e7d32;
    --amber: #b26a00;
    --shadow-sm: 0 1px 3px rgba(15, 27, 50, 0.06), 0 1px 2px rgba(15, 27, 50, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 27, 50, 0.08);
    --shadow-lg: 0 12px 28px rgba(15, 27, 50, 0.14);
    --gradient-fire: linear-gradient(135deg, #c8102e 0%, #8b0a1f 100%);
    --gradient-hero: linear-gradient(135deg, #c8102e 0%, #0a2a52 100%);
    --gradient-navy: linear-gradient(135deg, #0a2a52 0%, #1d3a6b 100%);
}

* {
    box-sizing: border-box;
}

html {
    /* Scrollleiste immer reservieren, damit der Tab-Wechsel die Seitenbreite
       nicht ändert (modern via scrollbar-gutter, mit overflow-Fallback). */
    scrollbar-gutter: stable;
    overflow-y: scroll;
}

body {
    font-family: "Segoe UI", Arial, sans-serif;
    margin: 0;
    color: var(--dark);
    background: var(--grey);
    line-height: 1.45;
}

header.app {
    background: var(--gradient-fire);
    color: #fff;
    padding: 0.9rem 1.6rem;
    display: flex;
    align-items: center;
    gap: 1.4rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

header.app a {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}

header.app .auth {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 500;
}

header.app .auth form {
    margin: 0;
    display: inline;
}

header.app .auth a,
header.app .auth button {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 0.35rem 0.9rem;
    border-radius: 5px;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
}

header.app .auth a:hover,
header.app .auth button:hover {
    background: rgba(255, 255, 255, 0.25);
}

header.app .title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.18);
}

main {
    width: 100%;
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0 1.2rem;
    box-sizing: border-box;
}

/* Every tab panel takes the same horizontal space as its siblings, regardless
   of internal content (tables, iframes, …). */
.tab-panel {
    width: 100%;
    box-sizing: border-box;
}

/* For wide tables that may exceed the card width on narrow screens. */
.scroll-x {
    overflow-x: auto;
    max-width: 100%;
}

h1 {
    font-size: 1.4rem;
}

h2 {
    font-size: 1.1rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.3rem;
    margin-top: 1.8rem;
}

/* Card header with a title on the left and a control (button/info) on the right. */
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.card-head h2 {
    margin: 0;
    padding: 0;
    border: 0;
}

.btn.small {
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
}

/* Destructive action: clearly stands out and stays red even on hover. */
.btn.danger {
    background: #b91c1c;
    color: #fff;
    box-shadow: 0 2px 6px rgba(185, 28, 28, 0.25);
}

.btn.danger:hover {
    background: #8b1414;
    box-shadow: 0 6px 18px rgba(185, 28, 28, 0.35);
}

.btn.danger:disabled {
    background: #d8a5a5;
    color: #fff;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Danger-zone card: subtle red accent. */
.card.danger-zone {
    border-color: #fca5a5;
    background: #fef2f2;
    margin-top: 3rem;
}

/* Modal overlay + dialog. */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 27, 50, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: #fff;
    border-radius: 14px;
    padding: 1.6rem 1.8rem;
    max-width: 520px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: modal-pop 0.18s ease-out;
}

.modal.danger {
    border-top: 6px solid var(--red);
}

@keyframes modal-pop {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: none; opacity: 1; }
}

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.3rem 1.5rem;
    margin-bottom: 1.2rem;
    box-shadow: var(--shadow-sm);
}

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    /* Zahlen, Status-Badges und kurze Codes wirken zentriert ruhiger;
       lange Texte können per .col-text wieder linksbündig gesetzt werden. */
    text-align: center;
    vertical-align: middle;
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}

/* Linksbündige Ausnahme für Spalten mit langen Texten (Namen, JF, Notizen). */
th.col-text, td.col-text {
    text-align: left;
}

th {
    background: var(--grey);
}

.btn {
    display: inline-block;
    background: var(--gradient-fire);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.15rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    box-shadow: 0 2px 6px rgba(200, 16, 46, 0.25);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(200, 16, 46, 0.32);
}

.btn:disabled {
    background: #c0c6cf;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn.secondary {
    background: #fff;
    color: var(--dark);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.btn.secondary:hover {
    background: var(--grey);
    box-shadow: var(--shadow-md);
}

.btn.secondary:disabled {
    background: var(--grey);
    color: #8a929b;
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
}

/* Form controls erben standardmäßig nicht die Body-Schrift — explizit angleichen,
   damit Text-/Date-/E-Mail-Felder nicht in Times New Roman erscheinen. */
input,
select,
textarea,
button {
    font-family: inherit;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="date"],
textarea {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.95rem;
    color: inherit;
    background: #fff;
}

textarea {
    line-height: 1.45;
}

input[type="number"] {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.95rem;
    width: 8rem;
}

input[type="file"] {
    padding: 0.45rem 0.6rem;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: #fafbfc;
    font-size: 0.95rem;
    width: 100%;
    max-width: 32rem;
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    border: 0;
    background: var(--dark);
    color: #fff;
    padding: 0.35rem 0.9rem;
    border-radius: 5px;
    margin-right: 0.7rem;
    cursor: pointer;
    font-size: 0.9rem;
}

input[type="file"]::file-selector-button:hover {
    background: #000;
}

select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.95rem;
}

.points {
    font-weight: 700;
    color: var(--red);
    margin-left: 0.5rem;
}

/* Disziplinen-Tabelle: Input + Einheit als feste Einheit, damit die Eingabefelder
   trotz unterschiedlich breiter Einheiten (m / Sek.) in einer Spalte stehen. */
.scoring-input {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
}

.scoring-input input[type="number"] {
    width: 6rem;
    text-align: right;
}

.scoring-input .unit {
    display: inline-block;
    min-width: 2.5rem;
    text-align: left;
    color: #6b7480;
}

.flash {
    padding: 0.7rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.flash.ok {
    background: #e7f4e8;
    border: 1px solid var(--green);
    color: var(--green);
}

.flash.err {
    background: #fdecea;
    border: 1px solid var(--red);
    color: var(--red);
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.95rem;
}

.badge.passed { background: #e7f4e8; color: var(--green); }
.badge.eliminated { background: #fdecea; color: var(--red); }
.badge.repeat { background: #fff4e0; color: var(--amber); }
.badge.incomplete { background: #eceff3; color: var(--dark); }

/* Substitute rows ("E") get a soft amber tint so they stand apart. */
tr.substitute {
    background: #fff8ec;
}

tr.substitute > td:first-child {
    font-weight: 700;
    color: var(--amber);
}

th.danger,
td.danger {
    color: var(--red);
}

td.danger input[type="checkbox"] {
    accent-color: var(--red);
    transform: scale(1.15);
}

.locked-banner {
    border-left: 4px solid var(--red);
}

fieldset[disabled] {
    opacity: 0.75;
}

.repeat-box {
    border: 1px dashed var(--amber);
    background: #fffaf0;
    padding: 1rem;
    border-radius: 6px;
    margin-top: 1rem;
}

.reasons {
    margin: 0.4rem 0 0;
    padding-left: 1.2rem;
}

.muted {
    color: #6b7480;
    font-size: 0.85rem;
}

/* Mindeststärke unterschritten: deutlich roter Warn-Block im Wertungsbogen. */
.warn-box {
    background: #fef2f2;
    border-left: 4px solid var(--red);
    color: #8b1414;
    padding: 0.7rem 1rem;
    border-radius: 6px;
    margin: 0.6rem 0 0.4rem;
    line-height: 1.55;
}

.warn-box strong {
    color: var(--red);
}

/* Inline-Hervorhebung in der Teilnehmer-Überschrift. */
.understaffed-inline {
    color: var(--red);
    font-weight: 600;
}

/* ⚠ Icon in Tabellen, wenn die Mindeststärke unterschritten ist. */
.understaffed-icon {
    color: var(--red);
    font-weight: 700;
    margin-right: 0.15rem;
    cursor: help;
}

.total {
    font-size: 1.6rem;
    font-weight: 700;
}

/* Statistik-Übersicht: zweispaltige Kachel mit visuellem Trenner in der Mitte. */
.stats-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.4rem;
    align-items: center;
}

.stats-split .stats-half {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stats-split .stats-half + .stats-half {
    border-left: 1px solid var(--border);
    padding-left: 1.4rem;
}

@media (max-width: 640px) {
    .stats-split {
        grid-template-columns: 1fr;
    }
    .stats-split .stats-half + .stats-half {
        border-left: 0;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: 1rem;
    }
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 2rem;
}

/* --- Landing page --- */
.hero {
    background: var(--gradient-hero);
    color: #fff;
    text-align: center;
    padding: 4rem 1.5rem 3.2rem;
    border-radius: 16px;
    margin: 1rem 0 2rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.hero::before {
    /* Subtle decorative circle in the corner. */
    content: '';
    position: absolute;
    right: -120px;
    top: -120px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(245, 184, 0, 0.18) 0%, transparent 70%);
    pointer-events: none;
}

.hero h1 {
    font-size: 2.9rem;
    margin: 0;
    color: #fff;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

.hero .subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.92);
    margin: 0.6rem 0 1.8rem;
}

.hero .btn {
    background: #fff;
    color: var(--red);
    padding: 0.75rem 1.8rem;
    font-size: 1.05rem;
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

.hero .btn:hover {
    background: var(--accent);
    color: var(--dark);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.2rem;
    margin: 2rem 0;
}

@media (max-width: 900px) {
    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 540px) {
    .feature-grid {
        grid-template-columns: 1fr;
    }
}

.feature {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.8rem 1.2rem 1.4rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature::before {
    /* Accent stripe on top, matching DJF colours. */
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-hero);
}

.feature:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.feature .icon {
    font-size: 2.4rem;
    line-height: 1;
}

.feature h3 {
    margin: 0.7rem 0 0.4rem;
    font-size: 1.05rem;
    color: var(--navy);
}

.feature p {
    color: #5e6772;
    font-size: 0.92rem;
    margin: 0;
}

/* --- Login --- */
.login-card {
    max-width: 26rem;
    margin: 3rem auto;
    padding: 2.5rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Dezente Akzent-Linie oben in den DJF-Farben. */
.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-hero);
}

.login-logo {
    display: block;
    width: 96px;
    height: 96px;
    margin: 0.4rem auto 1rem;
    filter: drop-shadow(0 4px 10px rgba(15, 27, 50, 0.18));
}

.login-card h1 {
    margin: 0 0 0.3rem;
    font-size: 1.6rem;
}

.login-sub {
    margin: 0 0 1.6rem;
    color: #6b7480;
    font-size: 0.95rem;
}

.login-card .flash {
    text-align: left;
}

/* Voll-breiter Login-Button mit etwas mehr Größe als der Standard. */
.btn-block {
    display: block;
    width: 100%;
    padding: 0.85rem 1.2rem;
    font-size: 1.05rem;
    margin-bottom: 0.6rem;
    box-sizing: border-box;
}

.login-cancel {
    display: inline-block;
    margin-top: 1rem;
    color: #6b7480;
    text-decoration: none;
    font-size: 0.9rem;
}

.login-cancel:hover {
    color: var(--dark);
    text-decoration: underline;
}

/* --- Step indicator for the public registration flow --- */
.step-indicator {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    counter-reset: step;
    gap: 0;
    flex-wrap: wrap;
}

.step-indicator li {
    flex: 1;
    min-width: 9rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-right: 0;
    color: #9aa2ad;
    font-size: 0.92rem;
    position: relative;
}

.step-indicator li:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.step-indicator li:last-child {
    border-right: 1px solid var(--border);
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.step-indicator li .num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    background: var(--grey);
    color: #9aa2ad;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.step-indicator li.active {
    color: var(--dark);
    border-color: var(--red);
    background: linear-gradient(180deg, #fff 0%, #fff5f6 100%);
}

.step-indicator li.active .num {
    background: var(--gradient-fire);
    color: #fff;
}

/* --- Global footer --- */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

footer.app-footer {
    background: var(--gradient-navy);
    color: rgba(255, 255, 255, 0.85);
    padding: 1.1rem 1.6rem;
    margin-top: 3rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.9rem;
    border-top: 3px solid var(--red);
}

footer.app-footer a {
    color: #ffffff;
    text-decoration: none;
}

footer.app-footer a:hover {
    text-decoration: underline;
}

/* --- Score sheet tabs --- */
.tabs {
    display: flex;
    gap: 0.4rem;
    margin: 0 0 1rem;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
}

.tab {
    background: transparent;
    border: 0;
    padding: 0.7rem 1.2rem;
    cursor: pointer;
    font-weight: 600;
    color: #6b7480;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-family: inherit;
    font-size: 0.95rem;
}

.tab:hover {
    color: var(--dark);
}

.tab.active {
    color: var(--red);
    border-bottom-color: var(--red);
}

.tab-panel.tab-hidden {
    display: none !important;
}

/* ============================================================
   Druck-Layout
   ------------------------------------------------------------
   Versteckt alle Bedien-Elemente und schmückt die Seite auf ein
   reines Ergebnis-Blatt herunter. Elemente, die nicht in den
   Druck sollen, bekommen die Klasse .no-print im HTML.
   ============================================================ */
@media print {
    /* Hintergrund weg, Farben dürfen aber bleiben (Status-Badges). */
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 10.5pt;
        display: block !important;
    }

    header.app, footer.app-footer, .no-print, .modal-backdrop {
        display: none !important;
    }

    /* Sperrsymbol soll im Ausdruck nicht auftauchen (verwirrt sonst). */
    .lock-icon {
        display: none !important;
    }

    main {
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
    }

    h1 {
        font-size: 16pt;
        margin: 0 0 0.6rem;
    }

    h2 {
        font-size: 12pt;
        margin: 1rem 0 0.4rem;
        border-bottom: 1px solid #000;
        padding-bottom: 0.2rem;
    }

    .card {
        border: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 0 0.8rem !important;
        page-break-inside: avoid;
    }

    /* Tabellen drucken kompakter, mit dünnen Linien, Zeilen nicht trennen. */
    table {
        border-collapse: collapse;
        width: 100%;
    }

    th, td {
        border-bottom: 1px solid #888 !important;
        padding: 0.25rem 0.4rem !important;
        font-size: 10pt !important;
    }

    th {
        background: #eee !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    tr {
        page-break-inside: avoid;
    }

    /* Status-Badges drucken mit voller Farbe (sonst weiß auf weiß). */
    .badge {
        border: 1px solid #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Links nicht als blauer Unterstrich, keine URL-Fußnoten. */
    a {
        color: inherit !important;
        text-decoration: none !important;
    }
    a[href]:after {
        content: "" !important;
    }
}
