/* =====================================================================
   Gardes Cata — feuille de style
   =====================================================================
   Conçue pour un usage en garde : lisible d'un coup d'œil, utilisable
   d'une main sur téléphone, et lisible de nuit (thème sombre automatique).
   ===================================================================== */

:root {
    /* Couleurs — thème clair */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --primary-contrast: #ffffff;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-hover: #f1f5f9;

    --text: #0f172a;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --success: #059669;
    --success-soft: #ecfdf5;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --warning: #d97706;
    --warning-soft: #fffbeb;

    /* Créneaux */
    --day-slot: #f59e0b;
    --night-slot: #6366f1;
    --assistant-slot: #059669;

    --garde-cata: #fee2e2;
    --garde-cata-border: #fca5a5;
    --my-garde: #dbeafe;
    --my-garde-border: #60a5fa;

    /* Carte « de garde en ce moment » : toujours du texte blanc, donc un
       fond soutenu dans les deux thèmes — les variables --primary du thème
       sombre sont trop claires pour cela. */
    --hero-from: #4f46e5;
    --hero-to: #4338ca;

    /* Élévation */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.1), 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.1), 0 4px 10px rgba(15, 23, 42, 0.05);

    --radius-sm: 0.375rem;
    --radius: 0.625rem;
    --radius-lg: 1rem;

    /* Cible tactile minimale recommandée */
    --tap: 44px;
}

/* Thème sombre : suit le réglage du téléphone, précieux en garde de nuit */
@media (prefers-color-scheme: dark) {
    :root {
        --primary: #818cf8;
        --primary-hover: #a5b4fc;
        --primary-soft: #1e1b4b;
        --primary-contrast: #0f172a;

        --bg: #0b1120;
        --surface: #161e2e;
        --surface-2: #1c2537;
        --surface-hover: #232d42;

        --text: #e2e8f0;
        --text-muted: #94a3b8;
        --text-faint: #64748b;

        --border: #2a3448;
        --border-strong: #3b475f;

        --success: #34d399;
        --success-soft: #052e23;
        --danger: #f87171;
        --danger-soft: #3f1414;
        --warning: #fbbf24;
        --warning-soft: #422006;

        --garde-cata: #4c1d24;
        --garde-cata-border: #9f4a52;
        --my-garde: #1e3a5f;
        --my-garde-border: #3b82f6;

        --hero-from: #3730a3;
        --hero-to: #312e81;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.6);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    /* Zones sûres des téléphones à encoche */
    padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }

/* Visible pour les lecteurs d'écran uniquement */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Respecte le réglage « réduire les animations » du système */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* =====================================================================
   Authentification
   ===================================================================== */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: linear-gradient(160deg, var(--bg) 0%, var(--surface-2) 100%);
}

.auth-container {
    background: var(--surface);
    padding: 2rem 1.75rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 26rem;
    border: 1px solid var(--border);
}

.auth-container h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    text-align: center;
    letter-spacing: -0.02em;
}

.auth-container h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-switch {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.link-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    font: inherit;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

/* =====================================================================
   Structure de l'application
   ===================================================================== */

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
    padding-top: env(safe-area-inset-top);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1rem;
    max-width: 75rem;
    margin: 0 auto;
}

.header-content h1 {
    font-size: 1.125rem;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Le site est en cours de construction : le dire évite qu'on prenne un
   planning encore incertain pour une consigne de service. */
.beta-flag {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    color: var(--warning);
    background: var(--warning-soft);
    border: 1px solid var(--warning);
    white-space: nowrap;
}

/* Sur un écran étroit, le titre prime : l'étiquette passe dessous plutôt
   que de comprimer le nom du site. */
@media (max-width: 26rem) {
    .beta-flag { font-size: 0.65rem; }
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.app-nav {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding: 0 0.5rem;
    max-width: 75rem;
    margin: 0 auto;
    scrollbar-width: none;
}

.app-nav::-webkit-scrollbar { display: none; }

.nav-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.75rem 0.875rem;
    min-height: var(--tap);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

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

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

.page-content { display: none; }
.page-content.active { display: block; }

.content-wrapper,
.container {
    max-width: 75rem;
    margin: 0 auto;
    padding: 1.25rem 1rem 3rem;
}

.content-wrapper > h2 {
    font-size: 1.375rem;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.page-description {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
}

/* Blocs de contenu */
.card,
.desiderata-form,
.planning-section,
.planning-controls,
.next-gardes,
.users-list,
.user-form,
.profile-form,
.stats-section,
.desiderata-list,
.info-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.card h3,
.desiderata-form h3,
.planning-section h3,
.planning-controls h3,
.next-gardes h3,
.users-list h3,
.user-form h3,
.stats-section h3,
.info-panel h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.section-info {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* =====================================================================
   Accueil — qui est de garde
   ===================================================================== */

.now-card {
    background: linear-gradient(135deg, var(--hero-from) 0%, var(--hero-to) 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-lg);
}

.now-card .now-label {
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.85;
    margin-bottom: 0.75rem;
}

.now-person {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.75rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.now-person:first-of-type { border-top: none; }

.now-person .role {
    font-size: 0.8125rem;
    opacity: 0.85;
}

.now-person .name {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.call-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 0.625rem 1rem;
    min-height: var(--tap);
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.call-btn:hover { background: rgba(255, 255, 255, 0.26); }

.now-empty {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    text-align: center;
    padding: 2rem 1.5rem;
}

.now-empty .countdown {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.my-next {
    border-left: 3px solid var(--primary);
}

/* =====================================================================
   Calendrier
   ===================================================================== */

.calendar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.calendar-header h2 {
    font-size: 1.125rem;
    text-transform: capitalize;
}

.nav-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: var(--tap);
    height: var(--tap);
    display: grid;
    place-items: center;
    cursor: pointer;
    color: var(--text);
}

.nav-btn:hover { background: var(--surface-hover); }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.legend-color {
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 0.25rem;
    display: inline-block;
}

.garde-color {
    background: var(--garde-cata);
    border: 1px solid var(--garde-cata-border);
}

.my-garde-color {
    background: var(--my-garde);
    border: 1px solid var(--my-garde-border);
}

.calendar-weekdays,
.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.weekday {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-faint);
    padding: 0.5rem 0;
    text-transform: uppercase;
}

.calendar-day {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
    transition: background 0.12s;
}

.calendar-day:hover { background: var(--surface-hover); }

.calendar-day.other-month { color: var(--text-faint); opacity: 0.5; }

.calendar-day.today {
    font-weight: 700;
    color: var(--primary);
    box-shadow: inset 0 0 0 2px var(--primary);
}

.calendar-day.garde-cata {
    background: var(--garde-cata);
    border-color: var(--garde-cata-border);
}

.calendar-day.my-garde {
    background: var(--my-garde);
    border-color: var(--my-garde-border);
    font-weight: 700;
}

.calendar-day.selected {
    box-shadow: inset 0 0 0 2px var(--text);
}

.container {
    display: grid;
    gap: 1.25rem;
}

@media (min-width: 62rem) {
    .container {
        grid-template-columns: minmax(0, 2fr) minmax(18rem, 1fr);
        align-items: start;
    }
}

.info-item {
    padding: 0.875rem 0;
    border-top: 1px solid var(--border);
}

.info-item:first-child { border-top: none; }

.info-item h4 {
    font-size: 0.9375rem;
    margin-bottom: 0.5rem;
}

.info-item p { font-size: 0.875rem; margin: 0.25rem 0; }

.no-info {
    color: var(--text-faint);
    font-size: 0.875rem;
    text-align: center;
    padding: 1.5rem 0;
}

/* =====================================================================
   Formulaires
   ===================================================================== */

.form-group { margin-bottom: 1rem; }

.form-row {
    display: grid;
    gap: 1rem;
}

@media (min-width: 40rem) {
    .form-row { grid-template-columns: 1fr 1fr; }
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.6875rem 0.875rem;
    min-height: var(--tap);
    /* 16px minimum : en dessous, iOS zoome à la mise au point */
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

input:disabled, select:disabled {
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: not-allowed;
}

textarea { resize: vertical; }

.readonly-value { font-weight: 600; margin: 0.25rem 0; }

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6875rem 1.125rem;
    min-height: var(--tap);
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn-danger { background: var(--danger); color: #fff; }

.btn-sm { padding: 0.4375rem 0.75rem; font-size: 0.8125rem; min-height: 2.25rem; }
.btn-block { width: 100%; }

/* Boutons de préférence des desiderata */
.preference-buttons { margin-bottom: 1rem; }

.btn-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.preference-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.875rem 0.5rem;
    min-height: var(--tap);
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8125rem;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}

.preference-btn .icon { font-size: 1.375rem; }
.preference-btn:hover { border-color: var(--border-strong); }

.preference-btn.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    font-weight: 600;
}

/* =====================================================================
   Listes
   ===================================================================== */

.desiderata-item,
.scheduled-item,
.user-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.875rem 0;
    border-top: 1px solid var(--border);
}

.desiderata-item:first-child,
.scheduled-item:first-child,
.user-item:first-child { border-top: none; }

.desiderata-item h4,
.scheduled-item h4,
.user-item h4 {
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

.desiderata-item p,
.scheduled-item p,
.user-item p {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.action-btn {
    padding: 0.4375rem 0.75rem;
    min-height: 2.25rem;
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.action-btn:hover { background: var(--surface-hover); }

.action-delete { color: var(--danger); border-color: var(--danger); }
.action-delete:hover { background: var(--danger-soft); }

.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

.badge-admin { background: var(--primary-soft); color: var(--primary); }
.badge-done  { background: var(--success-soft, var(--surface-2)); color: var(--success, var(--text-muted)); }

/* ---------------------------------------------------------------------
   Signalements
   --------------------------------------------------------------------- */

.page-intro {
    color: var(--text-muted);
    margin: -0.5rem 0 1rem;
    line-height: 1.5;
}

.feedback-item {
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
}

.feedback-item:last-child { border-bottom: none; }

/* Un signalement traité reste consultable mais s'efface visuellement, pour
   que les demandes en attente ressortent. */
.feedback-done { opacity: 0.6; }

.feedback-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.feedback-kind { font-weight: 600; }

.feedback-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Le texte est saisi librement : on préserve les retours à la ligne. */
.feedback-message {
    margin: 0 0 0.5rem;
    line-height: 1.55;
    white-space: pre-wrap;
}
.badge-prefer { background: var(--success-soft); color: var(--success); }
.badge-avoid { background: var(--warning-soft); color: var(--warning); }
.badge-unavailable { background: var(--danger-soft); color: var(--danger); }

.role-select { display: block; margin-top: 0.5rem; font-size: 0.8125rem; }
.role-select select { margin-top: 0.25rem; max-width: 18rem; }

/* =====================================================================
   Plannings
   ===================================================================== */

.planning-days {
    display: grid;
    gap: 0.5rem;
    margin-top: 1rem;
}

.planning-day {
    display: grid;
    gap: 0.5rem;
    padding: 0.875rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

@media (min-width: 48rem) {
    .planning-day {
        grid-template-columns: 10rem 1fr;
        align-items: center;
    }
}

.planning-day.weekend {
    background: var(--primary-soft);
    border-color: var(--primary);
}

.planning-day.is-today {
    box-shadow: inset 0 0 0 2px var(--primary);
}

.shift-assignments { display: grid; gap: 0.375rem; font-size: 0.875rem; }

.shift-day, .shift-night, .shift-assistant {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-left: 0.625rem;
    border-left: 3px solid;
}

.shift-day { border-color: var(--day-slot); }
.shift-night { border-color: var(--night-slot); }
.shift-assistant { border-color: var(--assistant-slot); }

.phone-link {
    color: var(--primary);
    text-decoration: none;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 500;
}

.phone-link:hover { text-decoration: underline; }

.garde-period {
    padding: 0.875rem 0;
    border-top: 1px solid var(--border);
}

.garde-period:first-child { border-top: none; }

.garde-assignment {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    padding: 0.25rem 0;
}

/* Origine du planning : IA ou algorithme de repli */
.planning-note {
    background: var(--primary-soft);
    border-left: 3px solid var(--primary);
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    font-size: 0.875rem;
}

.planning-note p { margin-top: 0.5rem; }

.planning-note-fallback {
    background: var(--warning-soft);
    border-left-color: var(--warning);
}

.planning-note-desiderata {
    background: var(--surface-2);
    border-left-color: var(--assistant-slot);
}

/* Quand l'IA a échoué, ces souhaits sont la seule chose sur laquelle
   s'appuyer pour corriger : ils ne doivent pas se fondre dans la page. */
.planning-note-attention {
    background: var(--warning-soft);
    border-left-color: var(--warning);
}

.week-desideratum {
    margin-top: 0.7rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
}

.week-desideratum-author {
    font-weight: 600;
    font-size: 0.9rem;
}

.week-desideratum p {
    margin: 0.2rem 0 0;
    line-height: 1.55;
    white-space: pre-wrap;
}

.planning-note-simulation {
    background: var(--info-soft, var(--surface-2));
    border-left-color: var(--accent);
}

/* Ce que l'IA a compris des desiderata : c'est ce bloc qu'on relit pour
   vérifier son travail, il doit donc rester lisible et aéré. */
.planning-note-constraints ul {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
}

.planning-note-constraints li {
    margin-bottom: 0.4rem;
    line-height: 1.5;
}

.planning-note-constraints em {
    color: var(--text-muted);
}

/* Un planning qui cite quelqu'un ne participant plus aux gardes est
   périmé : le signaler vaut mieux que l'afficher comme valide. */
.stale-warning {
    margin: 0.75rem 0 0;
    padding: 0.6rem 0.75rem;
    background: var(--warning-soft);
    border-left: 3px solid var(--warning);
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Retouche manuelle d'un planning : repliée par défaut, pour ne pas
   alourdir la liste des périodes. */
.period-edit {
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

/* Sous une garde programmée, le volet appartient visuellement à la ligne
   qui le précède. */
.scheduled-list .period-edit {
    margin: -0.25rem 0 1rem;
    border-top: none;
    padding-top: 0;
}

.period-edit summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.35rem 0;
    min-height: var(--tap);
    display: flex;
    align-items: center;
}

.edit-day {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.9rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.edit-day strong {
    flex-basis: 100%;
    font-size: 0.9rem;
}

.edit-day label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.edit-day select {
    min-height: var(--tap);
    font-size: 16px; /* évite le zoom automatique sur iOS */
}

/* État d'attente pendant une génération : elle peut durer plusieurs
   minutes, il faut que ça se voie tout du long. */
.planning-pending {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 1rem 1.1rem;
    background: var(--surface-2);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
}

.planning-pending p {
    margin: 0.3rem 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.spinner {
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Une animation perpétuelle gêne certaines personnes ; le repère visuel
   reste, sans la rotation. */
@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; border-top-color: var(--accent); }
}

.period-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.scheduled-item.auto-generated { opacity: 0.75; }

/* =====================================================================
   Statistiques
   ===================================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 0.75rem;
}

.stat-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* =====================================================================
   Notifications et confirmations
   ===================================================================== */

.toast-stack {
    position: fixed;
    left: 50%;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 90;
    display: grid;
    gap: 0.5rem;
    width: min(26rem, calc(100vw - 2rem));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    animation: toast-in 0.2s ease-out;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(0.75rem); }
    to { opacity: 1; transform: none; }
}

.toast.leaving { opacity: 0; transition: opacity 0.2s; }

dialog.confirm-dialog {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    max-width: 24rem;
    width: calc(100vw - 2rem);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}

dialog.confirm-dialog::backdrop { background: rgba(15, 23, 42, 0.5); }

.confirm-body { padding: 1.5rem 1.5rem 1rem; }
.confirm-body h3 { font-size: 1.0625rem; margin-bottom: 0.5rem; }
.confirm-body p { font-size: 0.9375rem; color: var(--text-muted); }

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0 1.5rem 1.5rem;
}

/* Chargement */
.app-loading {
    display: grid;
    place-items: center;
    gap: 1rem;
    min-height: 60vh;
    color: var(--text-muted);
}

.spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-message {
    background: var(--danger-soft);
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
    font-size: 0.875rem;
}

.success-message {
    background: var(--success-soft);
    color: var(--success);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

/* Abonnement calendrier */
.feed-url {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0.75rem 0;
}

.feed-url input {
    flex: 1 1 14rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8125rem;
}

.help-list {
    font-size: 0.875rem;
    color: var(--text-muted);
    padding-left: 1.25rem;
    display: grid;
    gap: 0.375rem;
}

/* =====================================================================
   Impression — tableau hebdomadaire à afficher au service
   ===================================================================== */

@media print {
    body { background: #fff; color: #000; }

    .app-header,
    .app-nav,
    .btn,
    .actions,
    .toast-stack,
    .planning-note,
    .no-print { display: none !important; }

    .page-content { display: none !important; }
    .page-content.active { display: block !important; }

    .card, .planning-section, .next-gardes {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .print-table {
        display: table !important;
        width: 100%;
        border-collapse: collapse;
        font-size: 11pt;
    }

    .print-table th,
    .print-table td {
        border: 1px solid #000;
        padding: 6pt 8pt;
        text-align: left;
    }

    /* Les couleurs reprennent celles des feuilles actuelles : on retrouve
       la colonne rouge du Dir-Med sans avoir à lire l'en-tête. */
    .print-table caption {
        caption-side: top;
        font-size: 15pt;
        font-weight: 700;
        color: #4472c4;
        letter-spacing: 0.02em;
        padding: 0 0 10pt;
        border: 1px solid #000;
        margin-bottom: 6pt;
    }

    .print-table thead th {
        text-align: center;
        font-weight: 700;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .print-table th.print-date  { background: #f2f2f2 !important; }
    .print-table th.print-adj   { background: #92d050 !important; }
    .print-table th.print-phone { background: #9dc3e6 !important; }
    .print-table th.print-dirmed{ background: #ff0000 !important; color: #000; }

    .print-table td {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .print-table td.print-date   { font-weight: 700; background: #f2f2f2 !important; }
    .print-table td.print-adj    { background: #00b0f0 !important; text-align: center; }
    .print-table td.print-phone  { background: #bdd7ee !important; text-align: center; }
    .print-table td.print-dirmed { background: #ff5050 !important; text-align: center; }

    .print-table tfoot td {
        background: #f2f2f2 !important;
        text-align: center;
        font-weight: 600;
    }

    @page { margin: 1.5cm; size: landscape; }
}

/* Le tableau d'impression reste caché à l'écran */
.print-table { display: none; }

/* Un souhait dont la semaine a commencé reste consultable mais n'est plus
   modifiable : l'estomper évite de le confondre avec les suivants. */
.desiderata-closed { opacity: 0.65; }

/* Le lien brut reste accessible pour les clients qui ignorent webcal://,
   mais replié : le bouton doit être le chemin évident. */
.feed-manual {
    margin-top: 1rem;
}

.feed-manual summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
    min-height: var(--tap);
    display: flex;
    align-items: center;
}

/* Écran d'attente au chargement : discret, il ne doit pas ressembler à une
   page en soi — il dure moins d'une seconde. */
.boot-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    color: var(--text-muted);
}

.boot-card .spinner {
    width: 26px;
    height: 26px;
    margin: 0;
}

/* ---------------------------------------------------------------------
   Conversation sur un signalement
   --------------------------------------------------------------------- */

.feedback-thread {
    margin: 0.6rem 0 0.8rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--border);
}

.feedback-thread summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
    min-height: var(--tap);
    display: flex;
    align-items: center;
}

.thread-message {
    margin: 0.5rem 0;
    padding: 0.55rem 0.7rem;
    background: var(--surface-2);
    border-radius: 8px;
}

/* Ses propres messages tirent vers la couleur d'accent : suivre un
   échange demande de distinguer qui parle sans lire les noms. */
.thread-mine {
    background: var(--primary-soft);
}

.thread-author {
    font-weight: 600;
    font-size: 0.85rem;
}

.thread-message p {
    margin: 0.15rem 0 0;
    line-height: 1.55;
    white-space: pre-wrap;
}

.thread-reply {
    margin-top: 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

.thread-reply textarea {
    width: 100%;
}

/* ---------------------------------------------------------------------
   Accusés de lecture et répartition
   --------------------------------------------------------------------- */

.ack-btn { margin-top: 0.9rem; }

.ack-done,
.ack-pending {
    margin: 0.6rem 0 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.ack-done { color: var(--success); }
.ack-pending { color: var(--warning); }

.equity {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.equity th,
.equity td {
    padding: 0.5rem 0.4rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.equity th:first-child,
.equity td:first-child {
    text-align: left;
}

.equity th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
}

/* Sa propre ligne est mise en avant : on cherche d'abord la sienne, puis on
   compare. */
.equity-me {
    background: var(--primary-soft);
    font-weight: 600;
}

/* Bandeau hors ligne : il doit être vu avant qu'on se fie à ce qui est
   affiché, donc en tête de page et non dans un coin. */
.offline-banner {
    position: sticky;
    top: 0;
    z-index: 60;
    padding: 0.6rem 1rem;
    background: var(--warning);
    color: #1f2430;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
}

/* ---------------------------------------------------------------------
   Recherche d'une garde passée
   --------------------------------------------------------------------- */

.lookup {
    padding: 0 1rem 1rem;
    border-bottom: 1px solid var(--border);
}

.lookup label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.lookup-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.lookup-row input {
    flex: 1 1 10rem;
    min-height: var(--tap);
    font-size: 16px; /* évite le zoom automatique sur iOS */
}

.lookup-card {
    margin-top: 0.8rem;
    padding: 0.8rem 0.9rem;
    background: var(--surface-2);
    border-radius: var(--radius);
}

.lookup-card h4 {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.lookup-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
}

.lookup-line span { color: var(--text-muted); }
.lookup-line em { color: var(--text-faint); }

/* Page d'aide : du texte à lire, pas une interface. */
#helpPage h4 {
    margin-top: 1rem;
    font-size: 0.95rem;
}

#helpPage p {
    margin-top: 0.4rem;
    line-height: 1.6;
}

#helpPage blockquote {
    margin: 0.6rem 0;
    padding: 0.6rem 0.85rem;
    background: var(--surface-2);
    border-left: 3px solid var(--primary);
    border-radius: 6px;
    color: var(--text-muted);
    font-style: italic;
}

/* Journal des modifications : replié, il ne doit pas alourdir l'éditeur. */
.change-log {
    margin-top: 0.8rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
}

.change-log summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    min-height: var(--tap);
    display: flex;
    align-items: center;
}

.change-entry {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.change-when { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.change-who  { color: var(--text-muted); }

/* Invitation groupée : le résultat doit se lire sans ouvrir la console. */
.bulk-ok    { color: var(--success); margin-top: 0.8rem; }
.bulk-error { color: var(--danger);  margin-top: 0.8rem; }

.bulk-list {
    margin: 0.4rem 0 0 1.2rem;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Pièce jointe : une vignette cliquable, assez grande pour être lue sans
   ouvrir, assez petite pour ne pas noyer la conversation. */
.photo-attachment {
    margin: 0.5rem 0;
}

.photo-attachment img {
    max-width: min(100%, 20rem);
    max-height: 14rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: block;
}

input[type="file"] {
    font-size: 0.875rem;
    color: var(--text-muted);
    padding: 0.4rem 0;
    min-height: var(--tap);
}
