:root {
    --bg: #f5f7fa;
    --card: #ffffff;
    --ink: #1f2933;
    --muted: #647084;
    --line: #e2e8f0;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --ok: #059669;
    --ok-bg: #ecfdf5;
    --warn: #b45309;
    --warn-bg: #fffbeb;
    --err: #dc2626;
    --err-bg: #fef2f2;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body { max-width: 100%; overflow-x: hidden; }

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

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

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 60px;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-wrap: wrap;
}
.topbar .brand { font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.topbar .brand span { color: var(--brand); }
.topbar nav { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.topbar nav a {
    color: var(--muted);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.topbar nav a:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.topbar nav a.active { background: #eff6ff; color: var(--brand-dark); }
.topbar .user { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.topbar .user img { width: 30px; height: 30px; border-radius: 50%; }
.hamburger {
    display: none; margin-left: auto;
    background: none; border: 1px solid var(--line); border-radius: 8px;
    width: 38px; height: 38px; cursor: pointer;
    align-items: center; justify-content: center;
}
.hamburger span, .hamburger span::before, .hamburger span::after {
    display: block; width: 18px; height: 2px; background: var(--ink); position: relative;
}
.hamburger span::before, .hamburger span::after { content: ""; position: absolute; left: 0; }
.hamburger span::before { top: -6px; } .hamburger span::after { top: 6px; }

.container { max-width: 960px; margin: 32px auto; padding: 0 24px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--muted); }

@media (max-width: 780px) {
    .topbar { padding: 0 16px; }
    .hamburger { display: flex; }
    .topbar nav {
        display: none;
        width: 100%;
        order: 3;
        flex-direction: column;
        gap: 2px;
        padding: 8px 0 12px;
        border-top: 1px solid var(--line);
        margin-top: 8px;
    }
    .topbar nav.open { display: flex; }
    .topbar nav a { padding: 10px 12px; }
    .topbar .user span { display: none; }
    .container { padding: 0 14px; margin: 20px auto; }
    .card { padding: 16px; }
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    margin-bottom: 18px;
}
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card .desc { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
    align-items: start;
    margin-bottom: 18px;
}
.grid-cards .card { margin-bottom: 0; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
input[type=text], input[type=password], input[type=email], input[type=number], textarea, select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--brand); color: #fff; border: none;
    padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
    cursor: pointer;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--err); }
.btn.small { padding: 6px 11px; font-size: 13px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.off { background: #f1f5f9; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* Interrupteur */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .2s; cursor: pointer; }
.slider:before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider:before { transform: translateX(20px); }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.flash.success { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.flash.info { background: #eff6ff; color: var(--brand-dark); }

.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 480px; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); word-break: break-word; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 5px; font-size: 13px; word-break: break-all; }

/* Bloc repliable (glossaire, aide...) */
details.disclosure { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: 18px; }
details.disclosure summary {
    cursor: pointer; padding: 16px 22px; font-weight: 600; font-size: 15px;
    list-style: none; display: flex; align-items: center; justify-content: space-between;
}
details.disclosure summary::-webkit-details-marker { display: none; }
details.disclosure summary::after { content: "Afficher ▾"; font-weight: 500; font-size: 13px; color: var(--muted); }
details.disclosure[open] summary::after { content: "Masquer ▴"; }
details.disclosure .disclosure-body { padding: 0 22px 20px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 40px; max-width: 420px; width: 100%; text-align: center; }
.login-card h1 { margin: 0 0 6px; font-size: 26px; }
.login-card h1 span { color: var(--brand); }
.login-card p { color: var(--muted); margin: 0 0 28px; }
.google-btn {
    display: inline-flex; align-items: center; gap: 12px; justify-content: center;
    width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
    background: #fff; color: var(--ink); font-weight: 600; font-size: 15px; cursor: pointer;
}
.google-btn:hover { background: var(--bg); text-decoration: none; }
.muted { color: var(--muted); font-size: 13px; }
.mt { margin-top: 16px; }
