:root {
    --bg: #f6f5f2;
    --surface: #ffffff;
    --text: #1f2328;
    --muted: #5f6670;
    --border: #dcdad5;
    --accent: #3a5bd9;
    --accent-text: #ffffff;
    --yes: #d9f2df;
    --yes-text: #1d6b33;
    --maybe: #fcefd2;
    --maybe-text: #8a5a00;
    --no: #f8dede;
    --no-text: #9b2c2c;
    --best: #eef2ff;
    --radius: 8px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16181c;
        --surface: #1f2228;
        --text: #e6e8eb;
        --muted: #9aa1ab;
        --border: #363a42;
        --accent: #7b95f0;
        --accent-text: #10131a;
        --yes: #1f3d28;
        --yes-text: #8fdca4;
        --maybe: #3d321a;
        --maybe-text: #f1c86a;
        --no: #452424;
        --no-text: #f0a0a0;
        --best: #252c45;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.top {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }

.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }

h1 { font-size: 1.6rem; margin: 0 0 8px; line-height: 1.25; }
h2 { font-size: 1.2rem; margin: 40px 0 8px; }
.lead { color: var(--muted); font-size: 1.1rem; margin-top: 0; }
.meta { color: var(--muted); margin: 0 0 12px; }
.hint { color: var(--muted); font-size: .9rem; }
.description { margin: 0 0 20px; }
.badge {
    font-size: .75rem; font-weight: 600; vertical-align: middle;
    padding: 2px 8px; border-radius: 99px; background: var(--best); color: var(--accent);
}

/* Messages */
.flash { padding: 12px 14px; border-radius: var(--radius); margin: 0 0 20px; }
.flash ul { margin: 0; padding-left: 18px; }
.flash.ok { background: var(--yes); color: var(--yes-text); }
.flash.warn { background: var(--maybe); color: var(--maybe-text); }
.flash.err { background: var(--no); color: var(--no-text); }

/* Accueil */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 28px; }
.card {
    display: flex; flex-direction: column; gap: 6px;
    padding: 22px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); text-decoration: none; color: var(--text);
}
.card:hover { border-color: var(--accent); }
.card strong { font-size: 1.15rem; color: var(--accent); }
.card span { color: var(--muted); }

/* Formulaires */
fieldset { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px; margin: 0 0 20px; min-width: 0; }
legend { font-weight: 600; padding: 0 6px; }
.form label { display: block; margin-bottom: 14px; font-weight: 500; }
.form label small { color: var(--muted); font-weight: 400; }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.form .narrow { max-width: 260px; }
.form label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }

input, textarea {
    font: inherit; color: var(--text); background: var(--bg);
    border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
}
.form input:not([type=checkbox]), .form textarea, .links input { display: block; width: 100%; margin-top: 4px; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.option-row { display: flex; gap: 8px; margin-bottom: 8px; }
.option-row input { flex: 1; min-width: 0; }
.option-row input[type=date] { flex: 0 0 170px; }

.btn {
    font: inherit; font-weight: 600; cursor: pointer;
    padding: 10px 18px; border-radius: 6px; border: 1px solid var(--accent);
    background: var(--accent); color: var(--accent-text);
}
.btn.secondary { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--no-text); border-color: var(--no-text); }
.link { font: inherit; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.link.danger { color: var(--no-text); font-size: .8rem; padding: 0; display: block; }

.links { display: grid; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.links label { font-weight: 500; }
.links small { color: var(--muted); font-weight: 400; }

/* Tableau des votes */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.votes { border-collapse: collapse; width: 100%; }
.votes th, .votes td { border-bottom: 1px solid var(--border); padding: 8px; text-align: center; }
.votes thead th { font-weight: 500; font-size: .9rem; min-width: 84px; vertical-align: bottom; }
.votes .opt span { display: block; }
.votes .dow { text-transform: capitalize; color: var(--muted); }
.votes .day { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.votes .month { color: var(--muted); font-size: .8rem; }
.votes .slot { margin-top: 4px; font-size: .8rem; font-weight: 600; }
.votes .best { background: var(--best); }
.votes tbody th.voter { text-align: left; font-weight: 500; white-space: nowrap; min-width: 160px; }
.votes .voter small { display: block; color: var(--muted); font-weight: 400; font-size: .8rem; }
.votes .voter input { display: block; width: 100%; margin: 2px 0; padding: 6px 8px; }
.votes tfoot th { text-align: left; }
.votes tfoot td small { color: var(--muted); }
.votes .empty { color: var(--muted); padding: 20px; }

.cell { font-weight: 700; }
.cell.yes { background: var(--yes); color: var(--yes-text); }
.cell.maybe { background: var(--maybe); color: var(--maybe-text); }
.cell.no { background: var(--no); color: var(--no-text); }

.input-row { background: var(--best); }
.pick { white-space: nowrap; }
.r { display: inline-block; cursor: pointer; position: relative; }
.r input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.r span[aria-hidden] {
    display: inline-block; min-width: 30px; padding: 4px 3px; margin: 1px;
    border-radius: 5px; border: 1px solid var(--border); font-weight: 700; font-size: .85rem;
    color: var(--muted); background: var(--surface);
}
.r input:focus-visible + span { outline: 2px solid var(--accent); }
.r.yes input:checked + span { background: var(--yes); color: var(--yes-text); border-color: var(--yes-text); }
.r.maybe input:checked + span { background: var(--maybe); color: var(--maybe-text); border-color: var(--maybe-text); }
.r.no input:checked + span { background: var(--no); color: var(--no-text); border-color: var(--no-text); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Gestion */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-nav { display: flex; align-items: center; gap: 4px; }
.admin-nav form { margin: 0; }
.login { max-width: 400px; }
.search { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0; }
.search input { flex: 1; min-width: 200px; }
.list { border-collapse: collapse; width: 100%; }
.list th, .list td { border-bottom: 1px solid var(--border); padding: 10px; text-align: left; vertical-align: top; }
.list th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.list small { display: block; color: var(--muted); font-size: .8rem; }
.list .actions { white-space: nowrap; }
.list .actions form { margin: 4px 0 0; }
.list .empty { color: var(--muted); text-align: center; padding: 20px; }
.status { font-size: .8rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.status.open { background: var(--yes); color: var(--yes-text); }
.status.closed { background: var(--no); color: var(--no-text); }
.pager { display: flex; gap: 16px; justify-content: center; margin-top: 16px; color: var(--muted); }

.legend { color: var(--muted); font-size: .85rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.legend .cell { padding: 1px 6px; border-radius: 4px; }
.vote-form .btn { margin-top: 4px; }
