/* ==========================================================================
   AF — design "couture & maison"
   Palette chaude, typographie arrondie, détails cousus.
   ========================================================================== */

:root {
    /* Couleurs : crème lin, terracotta, sauge, miel, bois */
    --bg:              #faf5ec;
    --bg-warm:         #f3ead8;
    --paper:           #ffffff;
    --paper-soft:      #fbf6ec;

    --text:            #3b2f26;
    --text-soft:       #5a4a3d;
    --muted:           #8b7e72;
    --muted-soft:      #b0a597;

    --primary:         #c87457;
    --primary-dark:    #a85a40;
    --primary-soft:    #f4dfd5;
    --primary-tint:    #fbeee8;

    --accent:          #7a9a6a;
    --accent-soft:     #e1ecd9;
    --accent-tint:     #eef4ea;

    --warm:            #e6a64a;
    --warm-soft:       #fbe8c2;
    --warm-tint:       #fdf3df;

    --danger:          #b85450;
    --danger-soft:     #f5d8d6;
    --danger-tint:     #fbeae9;

    --border:          #e6dcc9;
    --border-strong:   #d5c7ac;
    --border-soft:     #efe7d5;

    /* Rayons & ombres : douces, comme un coussin */
    --radius-sm:  6px;
    --radius:     12px;
    --radius-lg:  16px;
    --radius-xl:  20px;

    --shadow-sm:  0 1px 2px rgba(78, 53, 30, .06);
    --shadow:     0 2px 8px rgba(78, 53, 30, .07), 0 1px 2px rgba(78, 53, 30, .04);
    --shadow-lg:  0 8px 24px rgba(78, 53, 30, .10), 0 2px 6px rgba(78, 53, 30, .05);
    --shadow-up:  0 -4px 12px rgba(78, 53, 30, .08);

    /* Typo */
    --font-base:    system-ui, -apple-system, "Avenir Next", Nunito, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: ui-rounded, "SF Pro Rounded", "Avenir Next Rounded", "Hiragino Maru Gothic ProN", Nunito, system-ui, sans-serif;

    /* Layout */
    --topbar-h:    64px;
    --bottom-h:    68px;
    --content-max: 980px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-base);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    /* Texture lin discrète en fond — petit pattern de pointillés */
    background-image:
        radial-gradient(circle at 1px 1px, rgba(120, 90, 60, .04) 1px, transparent 0);
    background-size: 18px 18px;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--text);
    letter-spacing: -.01em;
    line-height: 1.25;
}
h1 { font-size: 1.6rem; margin: 0 0 1rem; font-weight: 700; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .75rem; font-weight: 700; }
h3 { font-size: 1rem; margin: 0 0 .5rem; font-weight: 700; }

a { color: var(--primary-dark); }
a:hover { color: var(--primary); }

code {
    background: var(--bg-warm);
    padding: .1rem .35rem;
    border-radius: 4px;
    font-size: .9em;
}

/* ==========================================================================
   Topbar (desktop) — barre crème avec liseré terracotta
   ========================================================================== */

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .85rem 1.25rem;
    background: var(--paper-soft);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-h);
}
/* fine ligne terracotta façon ourlet sous la topbar */
.topbar::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    background: repeating-linear-gradient(90deg,
        var(--primary) 0 6px, transparent 6px 12px);
    opacity: .35;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -.01em;
}
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    font-weight: 800;
    font-size: .85rem;
    letter-spacing: .02em;
    box-shadow: inset 0 0 0 2px var(--primary-soft), var(--shadow-sm);
}

.topbar nav {
    display: flex;
    gap: .25rem;
    margin-left: auto;
    flex-wrap: wrap;
}
.topbar nav a {
    color: var(--text-soft);
    text-decoration: none;
    padding: .45rem .8rem;
    border-radius: 999px;
    font-size: .92rem;
    font-weight: 600;
    transition: background .15s ease, color .15s ease;
}
.topbar nav a:hover { background: var(--primary-tint); color: var(--primary-dark); }
.topbar nav a.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
    text-decoration: none;
}

/* ==========================================================================
   Bottom nav (mobile) — barre du bas façon app native
   ========================================================================== */

.bottom-nav {
    display: none; /* visible seulement en mobile via media query */
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: var(--bottom-h);
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--paper-soft);
    border-top: 1px solid var(--border);
    box-shadow: var(--shadow-up);
    z-index: 30;
    justify-content: space-around;
    align-items: stretch;
}
.bottom-nav a, .bottom-nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .15rem;
    padding: .35rem .25rem;
    color: var(--muted);
    text-decoration: none;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .01em;
    position: relative;
    border: none;
    background: none;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav a:focus, .bottom-nav button:focus { outline: none; }
.bottom-nav svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.bottom-nav a.active, .bottom-nav button.active {
    color: var(--primary-dark);
}
/* point cousu sous l'item actif */
.bottom-nav a.active::after, .bottom-nav button.active::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 22px;
    height: 3px;
    border-radius: 999px;
    background: var(--primary);
}

/* ==========================================================================
   Layout principal
   ========================================================================== */

main, .container {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 1.25rem;
}

#banner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* Espace réservé pour la barre du bas en mobile (boutons d'action) */
@media (max-width: 760px) {
    html { scroll-padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0) + 2rem); }
    main { padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0) + 4rem); }
    #banner { padding-bottom: 0; }
    form.stacked, .form { margin-bottom: 2rem; padding-bottom: 1.75rem; }
    form.stacked .actions, .form .form-actions { margin-bottom: .25rem; }
}

.muted { color: var(--muted); }
.lead { color: var(--text-soft); margin-top: -.5rem; font-size: 1rem; }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* ==========================================================================
   Boutons — ourlets cousus au hover
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .55rem 1rem;
    border: 1px solid var(--border-strong);
    background: var(--paper);
    color: var(--text);
    border-radius: 10px;
    text-decoration: none;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.2;
    font-family: inherit;
    box-shadow: var(--shadow-sm);
    transition: transform .12s ease, box-shadow .12s ease, background .15s ease, border-color .15s ease;
}
.btn:hover {
    background: var(--paper-soft);
    border-color: var(--primary-soft);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }

.btn.primary, .btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), var(--shadow);
}
.btn.primary:hover, .btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

.btn.danger, .btn-danger {
    background: var(--paper);
    color: var(--danger);
    border-color: var(--danger-soft);
}
.btn.danger:hover, .btn-danger:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-sm { padding: .25rem .6rem; font-size: .82rem; }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin: 1rem 0 1.25rem;
}

/* ==========================================================================
   Cartes — coussins doux
   ========================================================================== */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.2rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s ease, transform .15s ease;
    position: relative;
}
.card:hover { box-shadow: var(--shadow); }

.card h3 {
    margin: 0 0 .6rem;
    font-size: .8rem;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-family: var(--font-base);
}
.card .val, .card-value {
    font-family: var(--font-display);
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}
.card .sub, .card-sub {
    font-size: .88rem;
    color: var(--muted);
    margin-top: .35rem;
}
.card-label { font-weight: 700; }

/* Carte alerte : pointillé miel + fond chaud */
.card.warn, .card.card-warn {
    background: var(--warm-tint);
    border-color: var(--warm);
    border-style: dashed;
    border-width: 1.5px;
}
.card.warn .val, .card.warn .card-value,
.card.card-warn .val, .card.card-warn .card-value {
    color: var(--primary-dark);
}

/* ==========================================================================
   Tables — coussin, scroll horizontal si trop large
   ========================================================================== */

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--paper);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--paper);
    font-size: .94rem;
}
.table-wrap > table { border: none; box-shadow: none; }

th, td {
    padding: .7rem .9rem;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}
th {
    background: var(--bg-warm);
    font-size: .78rem;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
tbody tr:hover { background: var(--paper-soft); }
tr:last-child td { border-bottom: 0; }

tfoot td {
    background: var(--bg-warm);
    font-weight: 700;
}

.depenses {
    width: 100%;
    border-collapse: collapse;
    background: var(--paper);
}
.depenses .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Mobile : tables converties en mini-cards */
@media (max-width: 600px) {
    .depenses thead { display: none; }
    .depenses, .depenses tbody, .depenses tr, .depenses td { display: block; width: 100%; }
    .depenses tr {
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: .6rem;
        background: var(--paper);
        box-shadow: var(--shadow-sm);
        padding: .35rem 0;
    }
    .depenses td {
        border: none;
        padding: .4rem .9rem;
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        white-space: normal;
    }
    .depenses td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--muted);
        font-size: .82rem;
        text-transform: uppercase;
        letter-spacing: .04em;
    }
    .depenses .num { text-align: right; }
}

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

.form, form.stacked {
    display: flex;
    flex-direction: column;
    gap: .9rem;
    max-width: 520px;
    background: var(--paper);
    padding: 1.2rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.form label, form.stacked label {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    font-weight: 600;
    font-size: .85rem;
    color: var(--text-soft);
}
.form input, .form select, .form textarea,
form.stacked input, form.stacked select, form.stacked textarea {
    padding: .6rem .75rem;
    border: 1.5px solid var(--border-strong);
    border-radius: 10px;
    font: inherit;
    font-size: 1rem;
    background: var(--paper-soft);
    color: var(--text);
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.form input:focus, .form select:focus, .form textarea:focus,
form.stacked input:focus, form.stacked select:focus, form.stacked textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--paper);
    box-shadow: 0 0 0 3px var(--primary-tint);
}
.form textarea, form.stacked textarea { min-height: 90px; resize: vertical; }

.form input[type="file"], form.stacked input[type="file"] {
    background: var(--paper);
    border-style: dashed;
    cursor: pointer;
    padding: .55rem .65rem;
}
.form input[type="file"]::file-selector-button,
form.stacked input[type="file"]::file-selector-button {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: .4rem .9rem;
    border-radius: 8px;
    margin-right: .75rem;
    font-family: inherit;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
    transition: background .15s ease;
}
.form input[type="file"]::file-selector-button:hover,
form.stacked input[type="file"]::file-selector-button:hover {
    background: var(--primary-dark);
}
.form-actions {
    display: flex;
    gap: .5rem;
    margin-top: .5rem;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* ==========================================================================
   Filtres (selects horizontaux)
   ========================================================================== */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: .9rem;
    align-items: flex-end;
    margin-bottom: 1.25rem;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    box-shadow: var(--shadow-sm);
}
.filters label {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    font-size: .78rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.filters select, .filters input {
    padding: .45rem .65rem;
    border: 1.5px solid var(--border-strong);
    border-radius: 10px;
    background: var(--paper-soft);
    font: inherit;
    font-size: .95rem;
    color: var(--text);
}
.filters select:focus { outline: 2px solid var(--primary-soft); outline-offset: 1px; }

/* ==========================================================================
   Flashs et notes
   ========================================================================== */

.flash {
    padding: .7rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .95rem;
    border: 1px solid transparent;
}
.flash.error { background: var(--danger-tint); color: var(--danger); border-color: var(--danger-soft); }
.flash.ok    { background: var(--accent-tint); color: #2f5d1f; border-color: var(--accent-soft); }
.flash.warn  { background: var(--warm-tint); color: #7a4f10; border-color: var(--warm-soft); }
.flash a { color: inherit; font-weight: 700; margin-left: .35rem; text-decoration: underline; }

#banner .flash.warn { margin-top: 1rem; }

.note {
    background: var(--primary-tint);
    border-left: 3px solid var(--primary);
    padding: .65rem .85rem;
    font-size: .9rem;
    color: var(--text);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 1rem;
}

/* ==========================================================================
   États vides — pointillés façon point de croix
   ========================================================================== */

.empty {
    padding: 2.25rem 1.25rem;
    text-align: center;
    color: var(--muted);
    background: var(--paper);
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    font-style: italic;
}

/* ==========================================================================
   Badges et pills
   ========================================================================== */

.badge {
    display: inline-block;
    color: #fff;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}

.type-badge {
    font-size: .7rem;
    padding: .15rem .5rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: var(--primary-tint);
    color: var(--primary-dark);
    font-weight: 700;
}
.type-badge.type-relais { background: var(--accent-tint); color: #4a6e3a; }

.type-pill {
    padding: .15rem .55rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: .75rem;
}
.enfant-pill {
    background: var(--primary-tint);
    color: var(--primary-dark);
    padding: .15rem .55rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: .75rem;
}

.card-badge {
    display: inline-block;
    background: var(--danger);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: .1rem .45rem;
    border-radius: 999px;
    margin-left: .25rem;
    vertical-align: middle;
}

/* ==========================================================================
   Liste des enfants
   ========================================================================== */

.enfant-list { list-style: none; padding: 0; margin: 0; }
.enfant-item {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem 1.1rem;
    margin-bottom: .55rem;
    display: flex;
    align-items: center;
    gap: .9rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s ease;
}
.enfant-item:hover { box-shadow: var(--shadow); }
.enfant-item.is-parti { opacity: .55; }
.enfant-body { flex: 1; min-width: 0; }
.enfant-main { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.enfant-prenom {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-dark);
    text-decoration: none;
}
.enfant-prenom:hover { color: var(--primary); }
.enfant-meta, .enfant-dates { color: var(--muted); font-size: .85rem; }
.enfant-actions { display: flex; gap: .4rem; align-items: center; flex-shrink: 0; }
.enfant-actions form { margin: 0; padding: 0; border: none; background: none; box-shadow: none; max-width: unset; }
@media (max-width: 480px) {
    .enfant-item { flex-direction: column; align-items: stretch; }
    .enfant-actions { justify-content: flex-end; }
}

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

.cal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: .75rem;
}
.cal-nav { display: flex; align-items: center; gap: .5rem; }
.cal-nav h1 { margin: 0; font-size: 1.3rem; min-width: 11rem; text-align: center; }
.cal-actions { display: flex; gap: .5rem; }

table.calendar, .cal-mois {
    width: 100%;
    border-collapse: separate;
    border-spacing: 3px;
    table-layout: fixed;
    background: transparent;
    box-shadow: none;
}
table.calendar th, .cal-mois th {
    background: var(--paper-soft);
    padding: .45rem .3rem;
    font-size: .72rem;
    color: var(--muted);
    text-align: center;
    border-radius: 6px;
    border-bottom: none;
    text-transform: uppercase;
    letter-spacing: .05em;
}
table.calendar td, .cal-cell {
    background: var(--paper);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    vertical-align: top;
    height: 92px;
    padding: .25rem;
    overflow: hidden;
    position: relative;
    white-space: normal;
}
table.calendar td:hover, .cal-cell:hover {
    background: var(--primary-tint);
    border-color: var(--primary-soft);
}
table.calendar td.out, .cal-cell.is-out {
    background: var(--bg-warm);
    opacity: .55;
}
table.calendar td.today, .cal-cell.is-today {
    background: var(--warm-tint);
    border-color: var(--warm);
    border-width: 1.5px;
}
.cal-cell-overlay {
    position: absolute;
    inset: 0;
    z-index: 0;
    text-indent: -9999px;
    overflow: hidden;
}
.cal-cell-head { display: flex; justify-content: flex-end; position: relative; z-index: 1; pointer-events: none; }
.day-num, .cal-day {
    display: inline-block;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    padding: 0 .3rem;
    font-size: .82rem;
}
.day-num:hover { color: var(--primary-dark); }

.cal-events, .evt-list {
    list-style: none;
    padding: 0;
    margin: 2px 0 0;
    font-size: .72rem;
    line-height: 1.2;
    position: relative;
    z-index: 1;
}
.cal-evt, .evt {
    margin: 1px 0;
    padding: 2px 5px;
    border-radius: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fff;
    font-size: .68rem;
}
.cal-evt a { color: #fff; text-decoration: none; display: block; }
.cal-h { font-weight: 700; }
.evt-more {
    font-size: .68rem;
    color: var(--muted);
    margin-top: 2px;
    padding: 0 5px;
    font-weight: 600;
}

@media (max-width: 700px) {
    table.calendar td, .cal-cell { height: 60px; }
    .cal-evt, .evt { font-size: .62rem; padding: 1px 3px; }
    table.calendar th, .cal-mois th { font-size: .6rem; padding: .3rem .15rem; }
    .day-num, .cal-day { font-size: .75rem; padding: 0 .2rem; }
}

.evt-list {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .5rem 1rem;
    margin-top: 1rem;
    box-shadow: var(--shadow-sm);
}
.evt-list li {
    padding: .55rem 0;
    border-bottom: 1px solid var(--border-soft);
    font-size: .9rem;
}
.evt-list li:last-child { border-bottom: none; }
.evt-list .dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: .5rem;
    vertical-align: middle;
}

.cal-legende {
    margin-top: 1rem;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .6rem 1rem;
    box-shadow: var(--shadow-sm);
}
.cal-legende summary { cursor: pointer; font-weight: 700; color: var(--text-soft); }
.legende {
    list-style: none;
    padding: 0;
    margin: .5rem 0 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .35rem;
    font-size: .85rem;
}
.legende .dot {
    display: inline-block;
    width: .8rem;
    height: .8rem;
    border-radius: 50%;
    margin-right: .5rem;
    vertical-align: middle;
}

/* ==========================================================================
   Agenda + vue jour
   ========================================================================== */

.agenda-list { list-style: none; padding: 0; margin: 0; }
.agenda-day { margin-bottom: 1.25rem; }
.agenda-date {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: .35rem;
    font-size: 1rem;
}
.agenda-items { list-style: none; padding: 0; margin: 0; }
.agenda-item {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .4rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.agenda-item a {
    display: block;
    padding: .6rem .85rem;
    text-decoration: none;
    color: var(--text);
}
.agenda-item a:hover { background: var(--paper-soft); }
.agenda-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    align-items: center;
    font-size: .75rem;
}
.agenda-time { color: var(--muted); }
.agenda-title { font-weight: 700; margin-top: .15rem; }
.agenda-notes { color: var(--muted); font-size: .85rem; margin-top: .15rem; }

.jour-list { list-style: none; padding: 0; margin: 0; }
.jour-item {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .55rem;
    padding: .85rem 1.1rem;
    display: flex;
    gap: .9rem;
    align-items: flex-start;
    box-shadow: var(--shadow-sm);
}
.jour-body { flex: 1; min-width: 0; }
.jour-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    align-items: center;
    font-size: .75rem;
    margin-bottom: .3rem;
}
.jour-titre { font-weight: 700; }
.jour-lieu { color: var(--muted); font-size: .9rem; }
.jour-notes { color: var(--muted); font-size: .85rem; margin-top: .25rem; white-space: pre-wrap; }
.jour-actions {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    flex-shrink: 0;
}
.jour-actions form { margin: 0; padding: 0; border: none; background: none; box-shadow: none; max-width: unset; }
@media (max-width: 480px) {
    .jour-item { flex-direction: column; }
    .jour-actions { flex-direction: row; align-self: flex-end; }
}

.form-row-enfant {
    display: flex;
    align-items: flex-end;
    gap: .5rem;
}
.enfant-create-link {
    white-space: nowrap;
    margin-bottom: 0;
    flex-shrink: 0;
}

.jour-badge {
    display: inline-block;
    font-size: .65rem;
    font-weight: 700;
    padding: .15rem .55rem;
    border-radius: 999px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.jour-badge--today  { background: var(--warm-soft); color: #7a4f10; }
.jour-badge--past   { background: var(--bg-warm); color: var(--muted); }
.jour-badge--future { background: var(--accent-tint); color: #4a6e3a; }

/* ==========================================================================
   Récapitulatif indemnités
   ========================================================================== */

.mois-nav {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.mois-selector { display: inline-flex; gap: .5rem; align-items: center; }
.recap-head { margin: .5rem 0 1rem; }
.recap-head h2 { margin: 0; }
.recap-head .muted { margin: .25rem 0 0; font-size: .9rem; }
.recap-table tfoot .recap-total td {
    background: var(--bg-warm);
    font-size: 1.1rem;
    padding: .85rem .85rem;
    font-family: var(--font-display);
}
.recap-table tfoot .recap-total td:first-child { text-align: right; }
.recap-note { font-size: .85rem; margin-top: .5rem; color: var(--muted); }

/* ==========================================================================
   Grille annuelle des droits (12 mois)
   ========================================================================== */

.droits-grille {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .75rem;
    margin-top: 1rem;
}
.droits-mois {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    box-shadow: var(--shadow-sm);
}
.droits-mois-label { font-weight: 700; font-family: var(--font-display); }
.droits-mois-icon { font-size: 1.5rem; }
.droits-mois--pris   { border-color: var(--accent); background: var(--accent-tint); }
.droits-mois--pris   .droits-mois-icon { color: var(--accent); }
.droits-mois--manque { border-color: var(--danger); background: var(--danger-tint); }
.droits-mois--manque .droits-mois-icon { color: var(--danger); }
.droits-mois--futur  { color: var(--muted); }
.droits-mois--futur  .droits-mois-icon { color: var(--muted); }
.droits-mois-evts {
    list-style: none;
    padding: 0;
    margin: .25rem 0 0;
    font-size: .85rem;
}
.droits-mois-evts li { margin: .1rem 0; }

/* ==========================================================================
   Dépenses : ticket / actions
   ========================================================================== */

.ticket-link {
    margin-left: .5rem;
    font-size: .8rem;
    color: var(--primary-dark);
}
.actions-cell { white-space: nowrap; }
.actions-cell .btn-sm { padding: .15rem .55rem; margin-right: .25rem; }

/* Vignette de ticket dans la liste */
.ticket-thumb-link {
    display: inline-block;
    line-height: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-sm);
    transition: transform .12s ease, box-shadow .12s ease;
}
.ticket-thumb-link:hover { transform: scale(1.05); box-shadow: var(--shadow); }
.ticket-thumb {
    display: block;
    width: 44px;
    height: 44px;
    object-fit: cover;
}

/* Aperçu du ticket existant dans le formulaire */
.ticket-existant {
    background: var(--paper-soft);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: .75rem .85rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
}
.ticket-existant-head {
    font-size: .75rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}
.ticket-preview-link {
    display: inline-block;
    line-height: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-sm);
    max-width: 100%;
}
.ticket-preview {
    display: block;
    max-width: 100%;
    max-height: 240px;
    height: auto;
    width: auto;
    background: #fff;
}
.form-hint {
    font-size: .78rem;
    font-style: italic;
    font-weight: 400;
    margin-top: .25rem;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-weight: 500;
    font-size: .9rem;
    color: var(--text-soft);
    cursor: pointer;
}
.inline-check input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

/* ==========================================================================
   Divers
   ========================================================================== */

.danger-zone {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 2px dashed var(--border-strong);
}

.footer {
    text-align: center;
    color: var(--muted);
    font-size: .8rem;
    padding: 2rem 1rem 1rem;
}

/* ==========================================================================
   Drawer "Plus" (mobile, ouvert depuis bottom-nav)
   ========================================================================== */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(59, 47, 38, .45);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
.sheet-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}
.sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--paper);
    border-top-left-radius: var(--radius-xl);
    border-top-right-radius: var(--radius-xl);
    box-shadow: 0 -10px 30px rgba(78, 53, 30, .18);
    z-index: 41;
    padding: 1rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0));
    transform: translateY(100%);
    transition: transform .25s cubic-bezier(.2, .8, .3, 1);
}
.sheet.open { transform: translateY(0); }
.sheet-handle {
    width: 44px;
    height: 5px;
    background: var(--border-strong);
    border-radius: 999px;
    margin: 0 auto .85rem;
}
.sheet h3 {
    margin: 0 0 .75rem;
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    text-align: center;
}
.sheet-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.sheet-list a {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .85rem 1rem;
    background: var(--paper-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}
.sheet-list a:hover, .sheet-list a.active {
    background: var(--primary-tint);
    border-color: var(--primary-soft);
    color: var(--primary-dark);
}
.sheet-list svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* ==========================================================================
   Responsive : bascule topbar ↔ bottom-nav
   ========================================================================== */

@media (max-width: 760px) {
    .topbar nav { display: none; }
    .topbar { padding: .65rem 1rem; height: 56px; }
    .bottom-nav { display: flex; }
    main, .container {
        padding-top: 1rem;
        padding-left: 1rem;
        padding-right: 1rem;
        /* padding-bottom est piloté par le bloc dédié plus haut (bottom-nav clearance) */
    }
    h1 { font-size: 1.35rem; }
    h2 { font-size: 1.1rem; }
}

@media (min-width: 761px) {
    .bottom-nav, .sheet, .sheet-backdrop { display: none !important; }
}

/* ==========================================================================
   Impression
   ========================================================================== */

@media print {
    @page { size: A4; margin: 1.5cm; }
    body { background: #fff; background-image: none; }
    .topbar, .bottom-nav, .footer, .no-print, .mois-nav,
    .sheet, .sheet-backdrop { display: none !important; }
    main, .container { max-width: 100%; padding: 0; }
    .page-head h1 { margin-top: 0; }
    .table-wrap, .card, table { box-shadow: none; border: 1px solid #999; }
    .recap-table { font-size: .9rem; page-break-inside: auto; }
    .recap-table th, .recap-table td { border-color: #999; }
}
