:root {
    --primary: #245d74;
    --primary-dark: #163e50;
    --accent: #d9a923;
    --background: #f4f7f9;
    --surface: #ffffff;
    --text: #1d2933;
    --muted: #5c6b75;
    --border: #dce4e8;
    --radius: 16px;
    --shadow: 0 12px 30px rgba(25, 61, 78, 0.10);
}

* {
    box-sizing: border-box;
}

html {
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: var(--text);
    background: var(--background);
}

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
}

.container {
    width: min(1120px, calc(100% - 32px));
    margin-inline: auto;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-content {
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: flex;
    flex-direction: column;
}

.brand-name {
    color: var(--primary);
    font-size: 1.45rem;
    font-weight: 750;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 0.9rem;
}

.environment-badge {
    padding: 7px 12px;
    color: var(--primary-dark);
    background: #e7f3f7;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 650;
}

main {
    flex: 1;
}

.hero {
    padding: 76px 0;
}

.hero-content {
    display: grid;
    gap: 48px;
}

.hero-text {
    max-width: 760px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

h1 {
    margin: 0;
    color: var(--primary-dark);
    font-size: clamp(2.2rem, 6vw, 4.2rem);
    line-height: 1.05;
}

.hero-description {
    margin: 24px 0 0;
    color: var(--muted);
    font-size: clamp(1.05rem, 2vw, 1.25rem);
    line-height: 1.7;
}

.portal-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
}

.portal-card {
    display: flex;
    flex-direction: column;
    min-height: 260px;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.portal-card h2 {
    margin: 0;
    color: var(--primary);
    font-size: 1.35rem;
}

.portal-card p {
    flex: 1;
    margin: 18px 0 26px;
    color: var(--muted);
    line-height: 1.65;
}

.button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    padding: 11px 18px;
    color: white;
    background: var(--primary);
    border-radius: 10px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

.button:hover {
    background: var(--primary-dark);
}

.button.disabled {
    color: var(--muted);
    background: #edf1f3;
}

.site-footer {
    padding: 24px 0;
    color: var(--muted);
    background: var(--surface);
    border-top: 1px solid var(--border);
    text-align: center;
}

.site-footer p {
    margin: 0;
}

@media (max-width: 820px) {
    .hero {
        padding: 48px 0;
    }

    .portal-grid {
        grid-template-columns: 1fr;
    }

    .portal-card {
        min-height: auto;
    }
}

@media (max-width: 520px) {
    .container {
        width: min(100% - 22px, 1120px);
    }

    .header-content {
        min-height: 72px;
    }

    .environment-badge {
        display: none;
    }

    .hero {
        padding: 38px 0;
    }

    .portal-card {
        padding: 22px;
    }
}

.brand-link {
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
}

.account-main {
    flex: 1;
    padding: 54px 0;
    background: var(--background);
}

.form-page {
    width: min(520px, calc(100% - 32px));
    margin-inline: auto;
}

.form-page.wide {
    width: min(900px, calc(100% - 32px));
}

.form-card {
    padding: 34px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-title,
.dashboard-title {
    margin: 0;
    color: var(--primary-dark);
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.1;
}

.form-introduction {
    margin: 18px 0 28px;
    color: var(--muted);
    line-height: 1.6;
}

.form-section {
    margin: 30px 0;
    padding: 0;
    border: 0;
}

.form-section legend {
    width: 100%;
    margin-bottom: 18px;
    padding-bottom: 10px;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    font-size: 1.25rem;
    font-weight: 750;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 20px;
}

.form-field label {
    color: var(--primary-dark);
    font-weight: 700;
}

.form-control {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    color: var(--text);
    background: white;
    border: 1px solid #bfcbd1;
    border-radius: 8px;
    font: inherit;
}

.form-control:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(36, 93, 116, 0.14);
}

.help-text {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.4;
}

.field-error {
    margin: 0;
    color: #a61b1b;
    font-size: 0.88rem;
    font-weight: 650;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 30px;
}

.button.secondary {
    color: var(--primary);
    background: #e9f1f4;
}

.button.full-width {
    width: 100%;
    border: 0;
    cursor: pointer;
}

.text-button {
    padding: 8px 0;
    color: var(--primary);
    background: transparent;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    flex-wrap: wrap;
}

.logout-form {
    margin: 0;
}

.logout-button {
    color: #9f2d2d;
}

.logout-button:hover,
.text-button:hover {
    text-decoration: underline;
}

.dashboard-container {
    display: grid;
    gap: 40px;
}

.dashboard-heading {
    max-width: 760px;
}

.role-label {
    display: inline-flex;
    margin: 16px 0 0;
    padding: 7px 12px;
    color: var(--primary-dark);
    background: #e7f3f7;
    border-radius: 999px;
    font-weight: 700;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
}

.message {
    padding: 14px 16px;
    border-radius: 9px;
    font-weight: 650;
}

.message.success {
    color: #185b34;
    background: #e5f5eb;
}

.message.error {
    color: #8f1d1d;
    background: #fbe9e9;
}

.warning-card {
    border-color: #dfb84a;
}

@media (max-width: 820px) {
    .dashboard-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .account-main {
        padding: 34px 0;
    }
}

@media (max-width: 520px) {
    .form-card {
        padding: 22px;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .button {
        width: 100%;
    }
}

.document-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
}

.document-card {
    display: flex;
    flex-direction: column;
    min-height: 320px;
    padding: 26px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.document-card h2 {
    margin: 0 0 16px;
    color: var(--primary);
}

.document-empty {
    flex: 1;
    color: var(--muted);
}

.status-pill {
    align-self: flex-start;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.status-pending {
    color: #725500;
    background: #fff2c6;
}

.status-validated {
    color: #185b34;
    background: #e5f5eb;
}

.status-rejected,
.status-expired {
    color: #8f1d1d;
    background: #fbe9e9;
}

.document-meta {
    flex: 1;
    margin: 22px 0;
}

.document-meta div {
    margin-bottom: 14px;
}

.document-meta dt {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
}

.document-meta dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
}

.document-actions {
    display: flex;
    gap: 10px;
}

.document-actions .button {
    flex: 1;
}

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

@media (max-width: 520px) {
    .document-actions {
        flex-direction: column;
    }
}

.student-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.student-card {
    display: flex;
    flex-direction: column;
    min-height: 280px;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.student-card h2 {
    margin: 6px 0 0;
    color: var(--primary-dark);
    font-size: 1.5rem;
}

.student-level {
    margin: 0;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.student-school {
    margin: 10px 0 0;
    color: var(--muted);
}

.assignment-list {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.assignment-list h3 {
    margin: 0 0 12px;
    color: var(--primary);
    font-size: 1rem;
}

.assignment-list ul {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
    line-height: 1.7;
}

.student-empty {
    margin-top: auto;
    padding-top: 24px;
    color: var(--muted);
}

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

.month-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.month-card {
    display: flex;
    min-height: 220px;
    flex-direction: column;
    justify-content: space-between;
    gap: 24px;
    padding: 25px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.month-card h2 {
    margin: 0 0 14px;
    color: var(--primary-dark);
}

.month-summary {
    margin: 18px 0 0;
    color: var(--muted);
}

.status-draft {
    color: var(--primary-dark);
    background: #e7f3f7;
}

.status-submitted {
    color: #725500;
    background: #fff2c6;
}

.status-approved {
    color: #185b34;
    background: #e5f5eb;
}

.submission-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 30px;
}

.submission-total {
    display: flex;
    min-width: 190px;
    flex-direction: column;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: right;
}

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

.submission-total strong {
    margin: 4px 0;
    color: var(--primary-dark);
    font-size: 1.6rem;
}

.toolbar {
    display: flex;
    justify-content: flex-end;
}

.table-wrapper {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

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

.data-table th,
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: var(--primary-dark);
    background: #edf3f5;
    font-size: 0.85rem;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.table-actions {
    display: flex;
    gap: 12px;
    white-space: nowrap;
}

.table-actions form {
    margin: 0;
}

.table-actions a,
.link-danger {
    padding: 0;
    color: var(--primary);
    background: transparent;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
}

.link-danger {
    color: #a61b1b;
}

.submission-finalize {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.submission-finalize h2 {
    margin: 0;
    color: var(--primary-dark);
}

.submission-finalize p {
    margin: 8px 0 0;
    color: var(--muted);
}

.form-field-wide {
    grid-column: 1 / -1;
}

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

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

    .submission-heading,
    .submission-finalize {
        align-items: stretch;
        flex-direction: column;
    }

    .submission-total {
        text-align: left;
    }

    .submission-finalize .button {
        width: 100%;
    }

    .data-table thead {
        display: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        padding: 14px;
        border-bottom: 1px solid var(--border);
    }

    .data-table td {
        display: grid;
        grid-template-columns: 120px 1fr;
        gap: 12px;
        padding: 7px 0;
        border: 0;
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--primary-dark);
        font-weight: 700;
    }

    .table-actions {
        white-space: normal;
    }
}

.course-grid-container {
    width: min(100% - 32px, 1500px);
    margin-inline: auto;
    padding: 42px 0 70px;
}

.course-grid-header {
    display: grid;
    grid-template-columns:
        190px
        minmax(210px, 1.25fr)
        minmax(150px, 0.8fr)
        125px
        minmax(220px, 1.3fr)
        190px;
    gap: 10px;
    padding: 12px 16px;
    color: #ffffff;
    background: var(--primary);
    border-radius: 12px 12px 0 0;
    font-size: 0.82rem;
    font-weight: 750;
}

.monthly-calendar {
    overflow: hidden;
    border: 1px solid var(--border);
    border-top: 0;
    border-radius: 0 0 12px 12px;
    background: var(--surface);
}

.calendar-day {
    display: grid;
    grid-template-columns: 190px 1fr;
    border-bottom: 1px solid var(--border);
}

.calendar-day:last-child {
    border-bottom: 0;
}

.calendar-day.weekend {
    background: #f7f8f9;
}

.calendar-day-label {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    background: #edf3f5;
    border-right: 1px solid var(--border);
}

.calendar-day.weekend .calendar-day-label {
    background: #e8ecee;
}

.calendar-day-label strong {
    color: var(--primary-dark);
}

.add-day-course {
    display: inline-flex;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #ffffff;
    background: var(--primary);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    font: inherit;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
    transition:
        background 0.15s ease,
        transform 0.15s ease;
}

.add-day-course:hover {
    background: var(--primary-dark);
    transform: scale(1.06);
}

.add-day-course:focus-visible {
    outline: 3px solid rgba(27, 99, 122, 0.25);
    outline-offset: 2px;
}

.calendar-day-rows {
    min-width: 0;
}

.course-entry {
    display: grid;
    grid-template-columns:
        minmax(210px, 1.25fr)
        minmax(150px, 0.8fr)
        125px
        minmax(220px, 1.3fr)
        190px;
    gap: 10px;
    align-items: start;
    padding: 10px 14px;
    border-bottom: 1px dashed var(--border);
}

.course-entry:last-child {
    border-bottom: 0;
}

.course-entry-error {
    background: #fff4f4;
}

.course-cell select,
.course-cell input {
    box-sizing: border-box;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    font: inherit;
}

.course-cell select:focus,
.course-cell input:focus {
    border-color: var(--primary);
    outline: 2px solid rgba(27, 99, 122, 0.15);
}

.course-row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    min-height: 40px;
}

.course-icon-button {
    padding: 7px 9px;
    color: var(--primary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 7px;
    cursor: pointer;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
}

.course-icon-button:hover {
    background: #edf3f5;
}

.course-icon-button.danger {
    color: #a61b1b;
}

.course-field-error,
.course-row-error {
    display: block;
    margin-top: 5px;
    color: #a61b1b;
    font-size: 0.78rem;
    font-weight: 650;
}

.course-row-error {
    grid-column: 1 / -1;
}

.course-grid-savebar {
    position: sticky;
    z-index: 10;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-top: 24px;
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 -8px 30px rgba(18, 49, 61, 0.08);
    backdrop-filter: blur(8px);
}

.course-grid-savebar p {
    margin: 0;
    color: var(--muted);
}

.course-grid-buttons {
    display: flex;
    gap: 12px;
}

.readonly-calendar {
    display: grid;
    gap: 16px;
}

.readonly-day {
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.readonly-day h2 {
    margin: 0 0 14px;
    color: var(--primary-dark);
    font-size: 1.1rem;
}

.readonly-course {
    display: grid;
    grid-template-columns:
        minmax(150px, 1fr)
        minmax(190px, 1.15fr)
        minmax(140px, 0.8fr)
        minmax(130px, 0.75fr)
        90px
        minmax(130px, 0.7fr)
        minmax(150px, 0.9fr);
    gap: 14px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

@media (max-width: 1100px) {
    .course-grid-header {
        display: none;
    }

    .calendar-day {
        grid-template-columns: 1fr;
    }

    .calendar-day-label {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .course-entry {
        grid-template-columns:
            minmax(190px, 1fr)
            minmax(140px, 0.8fr)
            120px
            minmax(180px, 1fr);
    }

    .course-row-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

@media (max-width: 700px) {
    .course-grid-container {
        width: min(100% - 20px, 1500px);
        padding-top: 26px;
    }

    .course-entry {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .course-row-actions {
        grid-column: auto;
        justify-content: stretch;
    }

    .course-icon-button {
        flex: 1;
    }

    .course-grid-savebar {
        position: static;
        align-items: stretch;
        flex-direction: column;
    }

    .course-grid-buttons {
        flex-direction: column;
    }

    .course-grid-buttons .button {
        width: 100%;
    }

    .readonly-course {
        grid-template-columns: 1fr;
        gap: 5px;
    }
}

/* Une ligne marquée pour suppression doit disparaître,
   même si .course-entry utilise display: grid. */
.course-entry[hidden],
.course-entry-deleted {
    display: none !important;
}

/* Grille tarifaire des cours */

.course-grid-header {
    grid-template-columns:
        160px
        minmax(170px, 1fr)
        minmax(170px, 0.95fr)
        90px
        minmax(280px, 1.55fr)
        minmax(110px, 0.65fr)
        85px
        105px
        minmax(150px, 0.9fr)
        145px;
}

.course-entry {
    grid-template-columns:
        minmax(170px, 1fr)
        minmax(170px, 0.95fr)
        90px
        minmax(280px, 1.55fr)
        minmax(110px, 0.65fr)
        85px
        105px
        minmax(150px, 0.9fr)
        145px;
}

.course-profile-cell {
    display: flex;
    min-height: 40px;
    align-items: center;
}

.course-profile-value {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 650;
    line-height: 1.45;
    white-space: pre-line;
}

.course-amount-cell {
    display: flex;
    min-height: 40px;
    flex-direction: column;
    justify-content: center;
}

.course-amount-cell strong {
    color: var(--primary-dark);
    white-space: nowrap;
}

.course-amount-cell small {
    color: var(--muted);
    font-size: 0.72rem;
}

.pricing-missing {
    color: #a61b1b !important;
}

.submission-amount-label {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--muted);
}

@media (max-width: 1250px) {
    .course-grid-header {
        display: none;
    }

    .course-entry {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .course-row-actions,
    .course-row-error {
        grid-column: 1 / -1;
    }
}

@media (max-width: 700px) {
    .course-entry {
        grid-template-columns: 1fr;
    }

    .course-row-actions,
    .course-row-error {
        grid-column: auto;
    }
}

/* Utilisateur connecté et fermeture mensuelle */

.course-site-header {
    position: sticky;
    z-index: 100;
    top: 0;
    box-shadow: 0 4px 18px rgba(18, 49, 61, 0.08);
}

.header-user-zone {
    display: flex;
    align-items: center;
    gap: 24px;
}

.connected-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.25;
}

.connected-user span {
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.connected-user strong {
    color: var(--primary-dark);
    font-size: 0.93rem;
}

.status-closed {
    color: #ffffff;
    background: #59636a;
}

.closed-period-message {
    color: #384147;
    background: #edf0f2;
    border: 1px solid #cbd2d6;
}

.closed-period-message strong {
    display: block;
    margin-bottom: 4px;
    color: #20272b;
}

@media (max-width: 700px) {
    .header-user-zone {
        align-items: flex-end;
        gap: 10px;
    }

    .header-actions {
        gap: 10px;
    }

    .connected-user span {
        display: none;
    }

    .connected-user strong {
        max-width: 150px;
        overflow: hidden;
        font-size: 0.8rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Statuts mensuels distincts des statuts des relevés */

.status-open {
    color: #185b34;
    background: #e5f5eb;
}

.status-closed {
    color: #ffffff;
    background: #59636a;
}

.month-card-closed {
    background: #f2f4f5;
    border-color: #cbd2d6;
}

.month-card-closed h2 {
    color: #455057;
}

.month-secondary-status {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.submission-secondary-status {
    display: block;
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.88rem;
}

.invoice-table-wrapper {
    box-shadow: var(--shadow);
}

.invoice-table td strong {
    color: var(--primary-dark);
}

.invoice-empty-card {
    width: min(620px, 100%);
    min-height: auto;
}

.invoice-empty-card p {
    flex: 0;
}

