:root {
    --bg: #f6f3ed;
    --paper: #fffdf9;
    --ink: #1f2328;
    --muted: #6a6f76;
    --line: #e4ddd1;
    --accent: #8a1f1f;
    --accent-dark: #661717;
    --radius: 18px;
    --shadow: 0 10px 30px rgba(0,0,0,.06);
    --max: 1180px;
}

/* =========================
   BASE
========================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(138,31,31,.12), transparent 35%),
        linear-gradient(180deg, #fff, var(--bg));
}

.container {
    width: min(var(--max), calc(100% - 32px));
    margin: 0 auto;
}

main {
    padding: 34px 0 60px;
}

.hidden {
    display: none;
}

/* =========================
   HEADER PUBLIC
========================= */

.site-header {
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
}

.brand {
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
    font-size: 1.15rem;
}

nav {
    display: flex;
    gap: 18px;
}

nav a {
    color: var(--ink);
    text-decoration: none;
    font-weight: 650;
}

/* =========================
   BLOCS / CARDS
========================= */

.hero,
.card {
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
}

.hero {
    padding: 42px 34px;
}

.hero h1,
.card h1,
.card h2 {
    margin-top: 0;
}

.card h2 {
    margin-bottom: 1rem;
}

.hero p {
    color: var(--muted);
    font-size: 1.1rem;
    max-width: 780px;
}

.narrow {
    max-width: 480px;
    margin-inline: auto;
}

.grid {
    display: grid;
    gap: 22px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* =========================
   BOUTONS / ACTIONS
========================= */

.btn,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition:
        background .2s ease,
        transform .15s ease,
        box-shadow .2s ease;
}

.btn:hover,
button:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
}

.btn:active,
button:active {
    transform: translateY(0);
}

.btn.secondary {
    background: #e5e7eb;
    color: #111827;
}

.btn.secondary:hover {
    background: #d1d5db;
}

.btn.danger {
    background: #b91c1c;
}

.btn.danger:hover {
    background: #991b1b;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.back {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

/* =========================
   MESSAGES
========================= */

.flash {
    background: #dff0d8;
    border: 1px solid #b7dfb7;
    color: #245724;
    border-radius: 12px;
    padding: 12px 18px;
    margin-bottom: 20px;
}

.muted {
    color: var(--muted);
    font-size: .95rem;
}

.admin-info {
    font-size: .9rem;
    color: var(--muted);
    margin-bottom: 10px;
}

/* =========================
   FORMULAIRES
========================= */

.form {
    display: grid;
    gap: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(138,31,31,.12);
}

textarea {
    resize: vertical;
}

.search-input {
    width: 100%;
    max-width: 420px;
    padding: 10px 12px;
    margin: 15px 0;
    border: 1px solid var(--line);
    border-radius: 10px;
}

/* =========================
   TABLEAUX GÉNÉRAUX
========================= */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: .92rem;
    background: #faf7f0;
}

.table-actions,
table .actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
}

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

.table-actions form {
    display: inline;
}

.table-actions button {
    padding: 7px 12px;
    font-size: .9rem;
}

/* =========================
   PLAN DE TIR
========================= */

.serie-block {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.serie-block h2 {
    font-size: 1.2rem;
    margin-bottom: 16px;
}

.grid-postes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
}

.poste-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    min-height: 120px;
    background: #fff;
}

.poste-card.occupe {
    border-color: var(--accent);
    background: #fff8f6;
}

.poste-card.libre {
    background: #f7f7f7;
    color: #777;
}

.poste-link {
    text-decoration: none;
    color: inherit;
    transition:
        transform .15s ease,
        box-shadow .2s ease,
        border-color .2s ease;
}

.poste-link:hover {
    transform: translateY(-2px);
    border-color: var(--accent-dark);
    box-shadow: 0 6px 18px rgba(0,0,0,.08);
}

.poste-numero {
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 8px;
}

.tireur {
    display: grid;
    gap: 4px;
}

.tireur span,
.tireur small {
    color: var(--muted);
}

.poste-libre {
    font-style: italic;
}

/* =========================
   CHOIX DES SÉRIES
========================= */

.series-list {
    display: grid;
    gap: 12px;
}

.serie-choice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #fff;
    cursor: pointer;
}

.serie-choice input {
    width: auto;
    margin-top: 5px;
}

.serie-choice.disabled {
    opacity: .55;
    cursor: not-allowed;
    background: #f3f3f3;
}

.series-subchoices {
    display: grid;
    gap: 6px;
    margin-top: 10px;
    padding-left: 10px;
}

/* =========================
   CONSENTEMENTS
========================= */

.consentements,
.representant-block {
    margin-top: 1.5rem;
    padding: 1rem 1.2rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fafafa;
}

.representant-block h3 {
    margin-top: 0;
    margin-bottom: 1rem;
}

.checkbox-line {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    margin-bottom: .9rem;
    font-size: .92rem;
    line-height: 1.45;
    cursor: pointer;
    color: var(--muted);
    font-weight: 500;
}

.checkbox-line input[type="checkbox"] {
    width: auto;
    margin-top: .2rem;
    flex-shrink: 0;
}

.checkbox-line span {
    display: block;
}

.consentement-info {
    font-size: .8rem;
}

/* =========================
   RÉSULTATS
========================= */

.score-input {
    max-width: 110px;
}

.score-total {
    font-weight: 800;
}

.score-error {
    border: 2px solid #b00020 !important;
    background: #ffe5e9 !important;
    color: #b00020 !important;
    font-weight: 800 !important;
}

.result-row-complete {
    background: #e6f7ea;
}

.result-row-error {
    background: #fff0f0;
}

.result-row-locked.result-row-complete {
    background: #d8f5dd;
}

.result-row-locked input[readonly] {
    background: #eee;
    color: #555;
    cursor: not-allowed;
}

.lock-icon {
    margin-left: 6px;
    font-size: 14px;
    opacity: .75;
}

.result-row-locked .lock-icon {
    opacity: 1;
}

/* =========================
   STATUTS
========================= */

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 800;
}

.status-en_cours {
    background: #dcfce7;
    color: #166534;
}

.status-preparation {
    background: #dbeafe;
    color: #1e40af;
}

.status-clos {
    background: #fef3c7;
    color: #92400e;
}

.status-archive {
    background: #e5e7eb;
    color: #374151;
}

/* =========================
   LAYOUT ADMIN
========================= */

.admin-body {
    display: flex;
    min-height: 100vh;
    margin: 0;
}

.admin-sidebar {
    width: 240px;
    background: #1f2937;
    color: #fff;
    padding: 20px;
}

.admin-sidebar h2 {
    margin-top: 0;
}

.admin-sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-sidebar a {
    color: #fff;
    text-decoration: none;
    padding: 10px;
    border-radius: 8px;
}

.admin-sidebar a:hover {
    background: rgba(255,255,255,.1);
}

.admin-main {
    flex: 1;
    padding: 30px;
    background: #f5f6fa;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.admin-hero {
    background: #fff;
    border-radius: 18px;
    padding: 40px;
    margin-bottom: 30px;
    max-width: 1200px;
    width: 100%;
    box-shadow: 0 4px 18px rgba(0,0,0,.06);
}

.admin-hero h1 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 2rem;
    line-height: 1.2;
}

.admin-hero p {
    margin: 0;
    color: var(--muted);
    font-size: 1rem;
}

.admin-main .card,
.admin-main table,
.admin-main form {
    width: 100%;
    max-width: 1200px;
}

/* =========================
   EXPORTS / IMPRESSION
========================= */

.print-page {
    width: 100%;
    max-width: 1200px;
    background: #fff;
    padding: 30px;
    border-radius: 18px;
    box-shadow: 0 4px 18px rgba(0,0,0,.06);
}

.print-header {
    margin-bottom: 30px;
    text-align: center;
}

.print-header h1,
.print-header h2 {
    margin: 0 0 8px;
}

.print-serie {
    margin-bottom: 34px;
    page-break-inside: avoid;
}

.print-serie h3 {
    margin-bottom: 10px;
    color: var(--accent);
}

.print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.print-table th,
.print-table td {
    border: 1px solid #ddd;
    padding: 7px 9px;
}

.print-table th {
    background: #f4f4f4;
}

.print-table td {
    height: 28px;
}



/* =========================
   EXPORT INVITATION
========================= */

.invitation-page {
    font-size: 13px;    
    line-height: 1.35;
    padding: 18px 24px;
}

.invitation-logo {
    display: block;
    width: 100%;
    max-width: 540px;   
    height: auto;
    margin: 0 auto 10px;
}

.invitation-page .print-header {
    margin-bottom: 12px;
    text-align: center;
}

.invitation-page .print-header h1 {
    color: #b22222;
    font-size: 1.6rem; 
    margin: 0 0 6px;
    font-weight: 800;
}

.invitation-page .print-header p {
    margin: 3px 0;
    font-size: .95rem;
}

.invitation-section {
    margin-bottom: 10px;
}

.invitation-section h2 {
    color: var(--accent);
    margin: 0 0 5px;
    font-size: 1rem;
}

.invitation-page p {
    margin: 5px 0;
}

.invitation-page .print-table {
    width: auto;
    max-width: 100%;
    margin: 8px auto 12px;
    border-collapse: collapse;
    table-layout: auto;
    font-size: 11.5px; 
}

.invitation-page .print-table th,
.invitation-page .print-table td {
    border: 1px solid #ccc;
    padding: 4px 8px;  
    height: auto;
    vertical-align: middle;
    white-space: nowrap;
}

.invitation-page .print-table th {
    text-align: center;
    background: #f4f4f4;
    font-weight: 700;
}

.invitation-page .print-table td {
    text-align: left;
}

.invitation-page .jour-row td {
    text-align: center;
    font-weight: 800;
    color: var(--accent);
    background: #faf7f0;
    padding: 4px 7px;
}

.inscription-box {
    border: 2px solid #b22222;
    border-radius: 10px;
    padding: 8px 12px;
    text-align: center;
    font-weight: 700;
    margin-top: 10px;
}

.invitation-footer {
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px solid #ddd;
    text-align: center;
    font-size: 8.5px;
    line-height: 1.15;
    color: #555;
}

.invitation-section:last-of-type {
    margin-bottom: 2px;
}

.invitation-disciplines {
    display: grid;
    grid-template-columns: repeat(2, minmax(160px, 1fr));
    gap: 2px 14px;
    margin: 4px 0 8px;
    padding-left: 18px;
    font-size: 11px;
}





/* =========================
   FOOTER PUBLIC
========================= */

.site-footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    padding: 24px 0;
    background: rgba(255,255,255,.65);
}

/* =========================
   MEDIA PRINT
========================= */

@media print {
    .site-header,
    .site-footer,
    .admin-sidebar,
    .no-print {
        display: none !important;
    }

    body,
    .admin-main {
        background: #fff;
    }

    .card,
    .admin-hero,
    .print-page {
        box-shadow: none;
        border: none;
    }

    .print-page {
        max-width: none;
        padding: 0;
        border-radius: 0;
    }

    .print-header {
        margin-bottom: 18px;
    }

    .print-serie {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .print-table {
        font-size: 11px;
    }

    .print-table th,
    .print-table td {
        padding: 4px 6px;
    }

    .print-table td {
        height: 22px;
    }

    .invitation-page {
        font-size: 11px;   
        line-height: 1.24;
        padding: 0;
    }

    .invitation-logo {
        max-width: 350px;
        margin-bottom: 6px;
    }

    .invitation-page .print-header {
        margin-bottom: 8px;
    }

    .invitation-page .print-header h1 {
        font-size: 1.25rem;
    }

    .invitation-section {
        margin-bottom: 6px;
    }

    .invitation-page .print-table {
        width: auto;
        font-size: 10.5px; 
        margin: 5px auto 8px;
    }

    .invitation-page .print-table th,
    .invitation-page .print-table td {
        padding: 3px 6px;
        height: auto;
    }

    .invitation-page .jour-row td {
        padding: 3px 5px;
    }

    .inscription-box {
        padding: 6px 10px;
        margin-top: 6px;
    }
    
    .invitation-footer {
        margin-top: 3px;
        padding-top: 3px;
        font-size: 7.5px;
        line-height: 1.1;
    }

     .invitation-disciplines {
        font-size: 9.5px;
        gap: 1px 10px;
        margin: 2px 0 5px;
    }
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 720px) {
    .header-inner {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 0;
        gap: 8px;
    }

    nav {
        flex-wrap: wrap;
        gap: 10px;
    }

    .hero,
    .card,
    .admin-hero {
        padding: 22px;
    }

    .admin-body {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .invitation-page .print-table {
        width: 100%;
    }
}