/* ---------- Palette (clair / sombre) — même charte que logical-quote-app ---------- */
:root {
    --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5;
    --ink: #1c2330; --muted: #667085; --line: #e2e5ea;
    --accent: #1f6feb; --accent-ink: #ffffff; --accent-soft: #e8f0fe;
    --ok: #15803d; --ok-soft: #e4f4ea;
    --warn: #b45309; --warn-soft: #fdf0dc;
    --bad: #b42318; --bad-soft: #fde8e6;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f141b; --surface: #171d26; --surface-2: #1f2733;
        --ink: #e6e9ef; --muted: #98a2b3; --line: #2a3340;
        --accent: #5b9bff; --accent-ink: #0b1220; --accent-soft: #1b2a44;
        --ok: #5fd08a; --ok-soft: #14301f;
        --warn: #f2b158; --warn-soft: #3a2b12;
        --bad: #ff8a80; --bad-soft: #3b1a17;
        --shadow: none;
    }
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 28px 0 10px; }
small, .muted { color: var(--muted); }
.neg { color: var(--bad); }
.r { text-align: right; }

/* ---------- Structure : menu latéral + contenu ---------- */
.app { display: grid; grid-template-columns: 204px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { padding: 4px 8px 16px; font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand small { display: block; font-weight: 400; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--ink); font-weight: 600; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.current { background: var(--accent-soft); color: var(--accent); }
.sidebar .spacer { flex: 1; }
.content { padding: 26px 22px 60px; min-width: 0; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; color: var(--muted); }

@media (max-width: 820px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
    .brand { padding: 0 8px 0 0; }
    .brand small { display: none; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar .spacer { display: none; }
    .content { padding: 18px 14px 50px; }
    /* Nom + déconnexion : en bas de page, après le contenu */
    .app { display: flex; flex-direction: column; }
    .sidebar { display: contents; }
    .brand, .nav { order: 0; background: var(--surface); padding: 10px 12px; }
    .brand { padding-bottom: 0; border-bottom: 0; }
    .nav { border-bottom: 1px solid var(--line); padding-top: 6px; }
    .content { order: 1; }
    .sidebar .who, .sidebar > .btn { order: 2; align-self: center; margin: 0 14px; }
    .sidebar .who { margin-top: 6px; }
    .sidebar > .btn { margin-bottom: 28px; }
}

/* ---------- Boutons et champs ---------- */
button, .btn { font: inherit; font-weight: 600; padding: 7px 14px; border: 1.5px solid var(--accent); background: transparent; color: var(--ink); border-radius: 8px; cursor: pointer; display: inline-block; text-decoration: none; }
button:hover, .btn:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .btn.primary:hover { background: var(--accent); color: var(--accent-ink); filter: brightness(1.08); }
button.danger, .btn.danger { border-color: var(--bad); color: var(--bad); }
button.danger:hover, .btn.danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn.small, button.small { padding: 4px 10px; font-size: 13px; }
label { display: grid; gap: 4px; font-weight: 600; }
input, select, textarea { font: inherit; font-weight: 400; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; width: 100%; background: var(--surface); color: var(--ink); }
input:focus, select:focus, textarea:focus, button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.flash { padding: 10px 14px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); margin: 0 0 14px; }

/* ---------- Cartes, panneaux ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card b { display: block; font-size: 24px; line-height: 1.2; white-space: nowrap; }
.card span, .card small { color: var(--muted); display: block; }
.card.bad b { color: var(--bad); }
.card.ok b { color: var(--ok); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 14px; overflow-x: auto; }
.panel > h2:first-child { margin-top: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters select { width: auto; min-width: 140px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline form { margin: 0; }

/* ---------- Tableaux ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.grid thead th, .grid tr:first-child th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
.grid tbody tr:hover { background: var(--surface-2); }
.grid .r, .grid td.num { text-align: right; white-space: nowrap; }
.grid tfoot td, .grid tr.total th { border-top: 2px solid var(--line); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

/* ---------- Formulaires ---------- */
.form { display: grid; gap: 12px; max-width: 640px; }
.form.row { max-width: none; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: end; }
.doc { border-bottom: 1px solid var(--line); padding: 12px 0; }
.doc:last-child { border-bottom: 0; }
.doc .meta { margin-top: 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Connexion ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-box { background: var(--surface); padding: 30px; border-radius: 14px; width: min(380px, 92vw); display: grid; gap: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .12); border: 1px solid var(--line); }
.login-box h1 { text-align: center; font-size: 19px; }
.login-box form { display: grid; gap: 14px; }

/* ---------- Graphique ---------- */
.chart { width: 100%; height: auto; }
.chart .a { fill: var(--accent); } .chart .d { fill: var(--bad); }
.chart text { fill: var(--muted); font-size: 10px; } .chart line { stroke: var(--line); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
.legend i.a { background: var(--accent); } .legend i.d { background: var(--bad); }

@media print {
    .sidebar, .no-print { display: none !important; }
    .app { display: block; } .panel, .table-wrap { box-shadow: none; }
}

.form.two { grid-template-columns: 1fr 1fr; max-width: none; }
.form.two .full { grid-column: 1 / -1; }
@media (max-width: 820px) { .form.two { grid-template-columns: 1fr; } }

/* Onglets */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; border-radius: 8px 8px 0 0; color: var(--ink); font-weight: 600; text-decoration: none; border: 1px solid transparent; border-bottom: 0; margin-bottom: -1px; }
.tabs a:hover { background: var(--surface-2); text-decoration: none; }
.tabs a.current { background: var(--surface); border-color: var(--line); color: var(--accent); }
.tab-panel[hidden] { display: none; }
.help { margin: 0; padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); }
.btn svg { vertical-align: -2px; margin-right: 6px; }

/* Logo */
.brand { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.brand img { border-radius: 14px; flex: none; }
.brand span { line-height: 1.25; }
.login-logo { justify-self: center; border-radius: 16px; }
@media (max-width: 820px) { .brand { flex-direction: row; text-align: left; gap: 10px; } .brand img { width: 40px; height: 40px; border-radius: 9px; } }
.brand small { font-size: 11.5px; text-wrap: balance; }
.who { padding: 0 8px; text-align: center; } details { margin-top: 6px; } details summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.panel .help { margin-bottom: 12px; }
[hidden] { display: none !important; }

/* Zone de dépôt */
.drop { position: relative; display: grid; justify-items: center; gap: 4px; text-align: center; padding: 28px 16px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface-2); color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); outline: none; }
.drop b { color: var(--ink); font-size: 15px; }
.drop span { font-size: 12.5px; }
.drop em { font-style: normal; font-weight: 600; color: var(--ink); margin-top: 6px; }
.drop.has { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; padding: 0; }

@media (max-width: 820px) { #go { width: 100%; padding: 12px 14px; font-size: 16px; } .drop + .actions { display: block; } .drop + .actions small { display: block; margin-top: 8px; } }

.admin-ban { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--warn-soft); color: var(--warn); }
.admin-ban b { color: var(--ink); }
.inline-form { display: inline-block; margin-right: 6px; }

button.icon { padding: 5px 7px; line-height: 0; border-radius: 7px; }
button.icon svg { display: block; }
.inline-form { margin-left: 6px; vertical-align: middle; }

button.ghost { border-color: transparent; background: transparent; color: var(--accent); }
button.ghost:hover { background: var(--accent-soft); }
button.ghost.danger { color: var(--bad); }
button.ghost.danger:hover { background: var(--bad-soft); color: var(--bad); }

.icons { display: flex; gap: 2px; align-items: center; }
.btn.icon { padding: 5px 7px; line-height: 0; border-radius: 7px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
