:root {
    --fond: #f4f5f7;
    --surface: #ffffff;
    --texte: #1c2330;
    --discret: #626c7c;
    --trait: #d9dde4;
    --accent: #1f5fbf;
    --ok: #1d7a46;
    --ok-fond: #e3f4ea;
    --alerte: #a15c00;
    --alerte-fond: #fdf0d8;
    --danger: #b3261e;
    --danger-fond: #fbe6e4;
    --info-fond: #e5eefb;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --fond: #12151a;
        --surface: #1b2028;
        --texte: #e6e9ee;
        --discret: #98a2b3;
        --trait: #2e3541;
        --accent: #7fb0f5;
        --ok: #5fcf8f;
        --ok-fond: #17321f;
        --alerte: #f0b455;
        --alerte-fond: #3a2c10;
        --danger: #f2867f;
        --danger-fond: #3d1b19;
        --info-fond: #1a2a44;
    }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
h1 small, h2 small { font-size: .85rem; font-weight: normal; color: var(--discret); margin-left: .35rem; }
p { margin: 0 0 .75rem; }

main { max-width: 60rem; margin: 0 auto; padding: 1rem; }

/* Bandeau */
.bandeau {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
    padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--trait);
}
.marque { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--texte); }
.menu { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; }
.menu form { margin: 0; }
.lien { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

.fil { font-size: .9rem; color: var(--discret); margin-bottom: .75rem; }
.discret { color: var(--discret); font-size: .9rem; }
.avertissement { color: var(--alerte); font-size: .9rem; }
.vide { color: var(--discret); padding: 1.5rem 0; text-align: center; }

/* Messages */
.message { padding: .6rem .8rem; border-radius: .4rem; border: 1px solid var(--trait); background: var(--surface); }
.message-ok { background: var(--ok-fond); border-color: var(--ok); }
.message-erreur { background: var(--danger-fond); border-color: var(--danger); }
.message-info { background: var(--info-fond); border-color: var(--accent); font-size: .9rem; }

/* Boutons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
    min-height: 2.5rem; padding: .4rem .85rem;
    border: 1px solid var(--trait); border-radius: .4rem;
    background: var(--surface); color: var(--texte);
    font: inherit; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled, .btn-inactif { opacity: .4; cursor: default; }
.btn-ok { background: var(--ok-fond); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.btn-danger { background: var(--danger-fond); border-color: var(--danger); color: var(--danger); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Cartes */
.cartes, .comptes { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); margin-bottom: 1.5rem; }
.carte { background: var(--surface); border: 1px solid var(--trait); border-radius: .6rem; padding: 1rem; }
.carte h2 a { color: inherit; text-decoration: none; }
.carte-inactive { opacity: .6; }
.chiffres { margin-bottom: .35rem; }

/* Titre encadré de flèches (mois, jour) */
.titre-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.titre-nav h1 { margin: 0; text-align: center; flex: 1; }

/* Calendrier */
.calendrier { display: grid; grid-template-columns: repeat(7, 1fr); gap: .3rem; margin-top: .75rem; }
.entete-jour { text-align: center; font-size: .8rem; color: var(--discret); }
.case {
    min-height: 4.2rem; padding: .3rem .4rem; border-radius: .4rem;
    border: 1px solid var(--trait); color: var(--discret);
    display: flex; flex-direction: column; text-decoration: none; font-size: .8rem; overflow: hidden;
}
.case-hors { border-color: transparent; }
.case-jour { border-color: var(--accent); }
.case-pleine { background: var(--surface); color: var(--texte); }
.case-pleine:hover { border-color: var(--accent); }
.case .numero { font-size: .85rem; }
.case .nombre { font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
.case .reste { color: var(--discret); white-space: nowrap; }

/* Lecteur */
.lecteur {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface); border: 1px solid var(--trait); border-radius: .6rem;
    padding: .75rem; margin-bottom: 1rem;
}
.lecteur h2 { font-size: 1rem; }
.lecteur video { display: block; width: 100%; max-height: 55vh; background: #000; border-radius: .4rem; margin-bottom: .6rem; }
.lecteur .actions { justify-content: center; }

/* Liste */
.liste { list-style: none; margin: 0 0 1rem; padding: 0; border: 1px solid var(--trait); border-radius: .6rem; overflow: hidden; background: var(--surface); }
.ligne + .ligne { border-top: 1px solid var(--trait); }
.ligne a { display: flex; align-items: center; gap: .75rem; padding: .7rem .8rem; color: inherit; text-decoration: none; }
.ligne a:hover { background: var(--fond); }
.ligne-active a { background: var(--info-fond); }
.ligne .jour { min-width: 6.5rem; }
.ligne .heure { font-variant-numeric: tabular-nums; font-weight: 600; }
.ligne .taille { color: var(--discret); font-size: .9rem; margin-left: auto; white-space: nowrap; }

.badge { font-size: .8rem; padding: .15rem .5rem; border-radius: 1rem; white-space: nowrap; }
.badge-ok { background: var(--ok-fond); color: var(--ok); }
.badge-alerte { background: var(--alerte-fond); color: var(--alerte); }
.badge-neutre { background: var(--fond); color: var(--discret); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--discret); }

/* Formulaires */
.formulaire { background: var(--surface); border: 1px solid var(--trait); border-radius: .6rem; padding: 1rem; max-width: 26rem; }
.formulaire-etroit { margin: 2rem auto; }
.formulaire label { display: block; margin-bottom: .75rem; font-size: .9rem; }
input[type=text], input[type=password], select {
    display: block; width: 100%; min-height: 2.5rem; margin-top: .2rem; padding: .4rem .6rem;
    border: 1px solid var(--trait); border-radius: .4rem;
    background: var(--fond); color: var(--texte); font: inherit;
}
.en-ligne { display: flex; gap: .4rem; margin-top: .5rem; }
.en-ligne input, .en-ligne select { margin-top: 0; flex: 1; min-width: 0; }

/* Journal */
.defilant { overflow-x: auto; margin-bottom: 1rem; }
.tableau { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .9rem; }
.tableau th, .tableau td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--trait); white-space: nowrap; }
.tableau .detail { white-space: normal; word-break: break-all; }

/* Notification */
.toast {
    position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 5;
    display: flex; align-items: center; gap: .75rem;
    max-width: calc(100vw - 2rem); padding: .6rem .9rem; border-radius: .5rem;
    background: var(--texte); color: var(--fond); box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
}
.toast button { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: inherit; text-decoration: underline; cursor: pointer; white-space: nowrap; }
.toast-erreur { background: var(--danger); color: #fff; }

@media (max-width: 34rem) {
    main { padding: .75rem; }
    .ligne a { gap: .5rem; padding: .7rem .6rem; }
    .ligne .jour { min-width: 0; }
    .case { min-height: 3.6rem; padding: .2rem .25rem; }
    .case .reste { font-size: .7rem; }
    .lecteur { margin-left: -.75rem; margin-right: -.75rem; border-radius: 0; border-left: 0; border-right: 0; }
    .lecteur .btn { flex: 1 1 40%; }
}
