:root {
    --bg: #f4f6f9;
    --bg-card: #ffffff;
    --text: #1c2430;
    --text-muted: #667085;
    --border: #e2e6ec;
    --primary: #2f5fda;
    --primary-hover: #2549ac;
    --danger: #d43f3f;
    --danger-hover: #b33333;
    --success: #1f9d55;
    --warning: #b8860b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

html.dark, body.dark {
    --bg: #10141c;
    --bg-card: #1a2029;
    --text: #e6e9ef;
    --text-muted: #97a1b3;
    --border: #2a3140;
    --primary: #5b83f0;
    --primary-hover: #7a9bf5;
    --danger: #e56868;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { 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);
    transition: background 0.15s ease, color 0.15s ease;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; }

/* ------------------------------------------------------------------ */
/* Barre de navigation                                                 */
/* ------------------------------------------------------------------ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.topbar-brand a { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand-logo { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }

.main-nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.main-nav a { color: var(--text-muted); font-weight: 500; }
.main-nav a:hover { color: var(--primary); text-decoration: none; }

.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.user-chip { font-size: 0.9rem; color: var(--text-muted); }
.user-chip small { opacity: 0.8; }

/* ------------------------------------------------------------------ */
/* Layout                                                               */
/* ------------------------------------------------------------------ */
.page-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

.narrow { max-width: 480px; }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.card h3 { margin-top: 0; }

.grid-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
}

.stat-card span { display: block; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.25rem; }
.stat-card strong { font-size: 1.8rem; }

/* ------------------------------------------------------------------ */
/* Formulaires                                                         */
/* ------------------------------------------------------------------ */
label { display: block; font-weight: 600; font-size: 0.9rem; margin: 0.75rem 0 0.3rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="time"], input[type="datetime-local"], input[type="number"], input[type="file"],
select, textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}

textarea { resize: vertical; min-height: 90px; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-actions { margin-top: 1.25rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }

.help-text { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.25rem; }

.option-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.option-row input { flex: 1; }

/* ------------------------------------------------------------------ */
/* Boutons                                                             */
/* ------------------------------------------------------------------ */
.btn {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    border-radius: 6px;
    border: 1px solid transparent;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; color: #fff; }

.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }

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

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

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

/* ------------------------------------------------------------------ */
/* Tables & listes                                                      */
/* ------------------------------------------------------------------ */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.02em; }

.list-view { list-style: none; margin: 0; padding: 0; }
.list-view li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.list-view li:last-child { border-bottom: none; }

/* ------------------------------------------------------------------ */
/* Badges / statuts                                                     */
/* ------------------------------------------------------------------ */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.badge-blue { background: rgba(47, 95, 218, 0.15); color: var(--primary); }
.badge-green { background: rgba(31, 157, 85, 0.15); color: var(--success); }
.badge-gray { background: rgba(102, 112, 133, 0.15); color: var(--text-muted); }
.badge-orange { background: rgba(184, 134, 11, 0.15); color: var(--warning); }
.badge-red { background: rgba(212, 63, 63, 0.15); color: var(--danger); }

/* ------------------------------------------------------------------ */
/* Alertes / flash messages                                             */
/* ------------------------------------------------------------------ */
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.92rem; }
.alert-success { background: rgba(31, 157, 85, 0.12); color: var(--success); border: 1px solid rgba(31, 157, 85, 0.3); }
.alert-error { background: rgba(212, 63, 63, 0.12); color: var(--danger); border: 1px solid rgba(212, 63, 63, 0.3); }
.alert-info { background: rgba(47, 95, 218, 0.1); color: var(--primary); border: 1px solid rgba(47, 95, 218, 0.3); }

/* ------------------------------------------------------------------ */
/* Écran de connexion                                                   */
/* ------------------------------------------------------------------ */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.brand-block { text-align: center; margin-bottom: 1.5rem; }
.brand-block h1 { margin: 0.25rem 0 0; font-size: 1.3rem; }
.brand-block p { color: var(--text-muted); margin: 0.25rem 0 0; font-size: 0.9rem; }
.brand-icon {
    width: 56px; height: 56px; margin: 0 auto;
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.brand-icon img { width: 100%; height: 100%; object-fit: cover; }

/* ------------------------------------------------------------------ */
/* Toggle (switch) pour le mode sombre / A2F                            */
/* ------------------------------------------------------------------ */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: absolute; cursor: pointer; inset: 0;
    background-color: var(--border); border-radius: 999px; transition: 0.2s;
}
.switch-slider::before {
    content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
    background-color: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .switch-slider { background-color: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }

/* ------------------------------------------------------------------ */
/* Divers                                                               */
/* ------------------------------------------------------------------ */
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.empty-state { color: var(--text-muted); font-style: italic; padding: 1rem 0; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem; }
.progress-bar { background: var(--border); border-radius: 999px; overflow: hidden; height: 10px; margin: 0.35rem 0; }
.progress-bar-fill { background: var(--primary); height: 100%; }
.result-row { margin-bottom: 0.85rem; }
.result-row .result-label { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 0.2rem; }

/* ------------------------------------------------------------------ */
/* Liste d'émargement / impression                                      */
/* ------------------------------------------------------------------ */
.emargement-table td, .emargement-table th { border: 1px solid var(--border); padding: 0.5rem 0.6rem; }
.emargement-table td:last-child { height: 42px; }

@media print {
    .no-print, .topbar { display: none !important; }
    body, .page-container { background: #fff !important; color: #000 !important; }
    .card, .emargement-sheet { box-shadow: none !important; border: none !important; }
    .emargement-table td, .emargement-table th { border: 1px solid #000 !important; }
}
