:root {
    --brand: #2f6f4f;
    --brand-dark: #234f38;
    --bg: #f6f5f1;
    --card-bg: #ffffff;
    --border: #e1ddd3;
    --text: #2b2b28;
    --muted: #74716a;
    --error: #b3261e;
    --error-bg: #fbe9e7;
    --success: #1e6b3c;
    --success-bg: #e7f5ea;
    --today: #fff3cd;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--brand-dark); }

h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; margin-top: 2rem; }
h3 { font-size: 1.05rem; color: var(--brand-dark); }

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

/* --- En-tête / navigation --- */
.site-header {
    background: var(--brand);
    color: #fff;
}
.site-header-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; margin-right: auto; }
.nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; }
.main-nav { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.main-nav a { color: #eafbf0; text-decoration: none; padding: 0.25rem 0; border-bottom: 2px solid transparent; }
.main-nav a.active, .main-nav a:hover { border-bottom-color: #fff; }
.main-nav a.nav-logout { margin-left: auto; opacity: 0.85; }

@media (max-width: 700px) {
    .nav-toggle { display: block; }
    .main-nav { display: none; flex-direction: column; width: 100%; align-items: flex-start; }
    .main-nav.open { display: flex; }
    .main-nav a.nav-logout { margin-left: 0; }
}

/* --- Contenu --- */
.page-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

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

/* --- Messages --- */
.flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-error { background: var(--error-bg); color: var(--error); }
.flash-success { background: var(--success-bg); color: var(--success); }

/* --- Formulaires --- */
.stacked-form { display: flex; flex-direction: column; gap: 0.85rem; max-width: 420px; }
.stacked-form label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.9rem; }
.stacked-form input[type=text], .stacked-form input[type=email], .stacked-form input[type=password],
.stacked-form input[type=date], .stacked-form input[type=number], .stacked-form textarea, .stacked-form select {
    font: inherit;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}
.checkbox-label { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }

button, .btn-small {
    font: inherit;
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 0.6rem 1.1rem;
    border-radius: 6px;
    cursor: pointer;
}
button:hover, .btn-small:hover { background: var(--brand-dark); }
.btn-small { padding: 0.3rem 0.7rem; text-decoration: none; display: inline-block; }

.link-btn {
    background: none; border: none; color: var(--error); padding: 0; font-size: 0.85rem;
    text-decoration: underline; cursor: pointer;
}
.inline-form { display: inline; }

.auth-box { max-width: 380px; margin: 3rem auto; }

/* --- Deux colonnes --- */
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 2rem; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

/* --- Calendrier --- */
.month-nav { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.calendar-grid { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.calendar-grid th { padding: 0.4rem; font-size: 0.8rem; color: var(--muted); text-align: left; }
.calendar-grid td { border: 1px solid var(--border); vertical-align: top; padding: 0.3rem; height: 70px; width: 14.28%; background: #fff; }
.calendar-grid td.cal-outside { background: #f5f4f0; color: #b8b5ab; }
.calendar-grid td.cal-today { background: var(--today); }
.cal-daynum { font-size: 0.8rem; font-weight: 600; }
.cal-occupant { font-size: 0.72rem; background: var(--success-bg); color: var(--success); border-radius: 4px; padding: 1px 4px; margin-top: 2px; display: inline-block; }
.cal-task {
    font-size: 0.68rem;
    color: var(--muted);
    margin-top: 2px;
    display: block;
    text-decoration: none;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cal-task:hover { color: var(--brand-dark); text-decoration: underline; }

.stay-list, .task-list-simple { list-style: none; padding: 0; margin: 0; }
.stay-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.task-list-simple li { padding: 0.3rem 0; }

/* --- Tâches --- */
.task-list { list-style: none; padding: 0; }
.task-list li { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.task-list li.task-done .task-body strong { text-decoration: line-through; color: var(--muted); }
.checkbox-btn { background: none; border: none; font-size: 1.3rem; padding: 0; cursor: pointer; line-height: 1; color: var(--brand-dark); }
.task-body { flex: 1; }
.task-list li.task-overdue,
.task-list-simple li.task-overdue { background: var(--error-bg); border-radius: 6px; padding-left: 0.4rem; }

/* --- Cartes / grilles --- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1.5rem; }

/* --- Photos / documents des fiches infos --- */
.info-card { cursor: pointer; }
.info-card-body { cursor: pointer; }
.info-gallery { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.info-gallery-item { position: relative; }
.info-gallery .info-photo {
    width: 84px;
    height: 84px;
    margin-bottom: 0;
}
.info-photo { object-fit: cover; border-radius: 6px; display: block; cursor: zoom-in; }
.info-attachment-delete { position: absolute; top: -6px; right: -6px; }
.info-attachment-remove {
    background: var(--error);
    color: #fff;
    border: 2px solid var(--card-bg);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    line-height: 1;
    font-size: 0.9rem;
    padding: 0;
    cursor: pointer;
}
.info-attachment-remove:hover { background: #8a1f19; }
.info-doc-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.info-doc-row .info-doc-link { flex: 1; margin-bottom: 0; }
.info-doc-link {
    display: block;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.6rem;
    font-size: 0.85rem;
    text-decoration: none;
    word-break: break-word;
}
.info-doc-link:hover { border-color: var(--brand); }

/* --- Agrandissement d'une photo ou d'une fiche complète (page Infos) --- */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
    cursor: zoom-out;
    overflow-y: auto;
}
.lightbox-overlay img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    cursor: default;
}
.lightbox-caption {
    color: #fff;
    margin-top: 1rem;
    font-size: 0.95rem;
    text-align: center;
}
.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.2rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem 0.6rem;
}
.lightbox-detail-content {
    background: var(--card-bg);
    color: var(--text);
    border-radius: 12px;
    padding: 1.75rem;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    cursor: default;
    text-align: left;
}
.lightbox-detail-content h2 { margin-top: 0; }
.info-detail-gallery { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; }
.info-detail-gallery img { max-width: 260px; max-height: 220px; border-radius: 8px; cursor: zoom-in; box-shadow: none; }

/* --- Rangée de boutons (ex : liste de courses) --- */
.button-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.5rem; }

/* --- Tableaux --- */
.stock-table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.stock-table th, .stock-table td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); }
.stock-table tr.stock-low { background: #fff8ec; }
.badge-alert { background: #f5a524; color: #422; font-size: 0.7rem; padding: 1px 6px; border-radius: 4px; margin-left: 0.4rem; }

/* --- Statuts de validation --- */
.badge { font-size: 0.72rem; padding: 1px 7px; border-radius: 4px; margin-left: 0.3rem; display: inline-block; }
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-pending { background: #fff3cd; color: #8a6d1a; }
.badge-refused { background: var(--error-bg); color: var(--error); }
.badge-pin { background: #e0e7ff; color: #3b3b8a; }

.flash-pending { background: #fff3cd; color: #8a6d1a; }

.admin-pending-box { border-color: #f5a524; margin-bottom: 1.5rem; }

.cal-occupant-pending { background: #fff3cd; color: #8a6d1a; border: 1px dashed #d9a441; }

.btn-refuse { background: var(--error); }
.btn-refuse:hover { background: #8a1f19; }

/* --- Dépenses --- */
.filter-form { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filter-form label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.85rem; }
.filter-form select { font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.big-number { font-size: 1.8rem; font-weight: 700; color: var(--brand-dark); margin: 0.2rem 0 0; }
.solde-positif { color: var(--success); font-weight: 600; }
.solde-negatif { color: var(--error); font-weight: 600; }
