:root {
  --bg: #f4f1ea; --surface: #fffdf8; --ink: #24211c; --muted: #6f685d; --line: #ddd5c6;
  --accent: #2f6f5e; --accent-ink: #fff; --accent-soft: #dcebe5;
  --ok: #2f6f5e; --bad: #a3322a; --bad-soft: #f6dedb;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614; --surface: #211f1c; --ink: #ece7de; --muted: #a79f92; --line: #3a362f;
    --accent: #7cc4ad; --accent-ink: #10201b; --accent-soft: #23362f;
    --ok: #7cc4ad; --bad: #f0958b; --bad-soft: #3d2320;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45; }
main { max-width: 980px; margin: 0 auto; padding: 16px 16px 48px; }
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 8px 0 16px; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: .95rem; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* navigation */
nav.top { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
nav.top a { text-decoration: none; color: var(--ink); }
nav.top .brand { font-weight: 700; color: var(--accent); margin-right: auto; }
@media (max-width: 520px) { nav.top .brand { display: none; } nav.top { justify-content: space-between; } }
nav.top .logout { margin: 0; }

/* éléments de formulaire */
input, button { font: inherit; color: inherit; }
input[type=text], input[type=number], input[type=date], input[type=password], input:not([type]) {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); min-width: 0; }
button, .btn { padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); cursor: pointer; text-decoration: none; color: var(--ink); display: inline-block; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.small { padding: 5px 10px; font-size: .9rem; }
button.link { border: none; background: none; color: var(--accent); padding: 0; }
button:disabled, .btn.disabled { opacity: .45; cursor: default; }
label { display: block; }

/* cartes */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 0 0 16px; }
.cards .card { margin: 0; }
.card.narrow { max-width: 360px; margin: 48px auto; display: grid; gap: 12px; }
.card.narrow input { width: 100%; margin-top: 4px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; }
.pill { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: .9rem; }
.pill.big { font-size: 1.1rem; font-weight: 700; }

fieldset { border: none; padding: 0; margin: 12px 0 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; font-weight: 600; }

/* boutons de notation 0..max */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg span { display: grid; place-items: center; min-width: 42px; height: 42px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-weight: 600; cursor: pointer; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.row > input:not(.num-in) { flex: 1 1 140px; }
.num-in { width: 68px; }
.row.edit { flex-wrap: nowrap; }
.row.edit > input:not(.num-in) { flex: 1 1 0; }
.row.inactive input:not([type=checkbox]) { opacity: .55; }
.row .check { display: flex; gap: 4px; align-items: center; font-size: .9rem; }
.title-input { font-size: 1.1rem; font-weight: 700; }

.daynav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.daynav .pick { display: flex; gap: 6px; }
.daynav .period { flex: 1; text-align: center; }
h1.day::first-letter { text-transform: uppercase; }
h1.day a { font-weight: 400; margin-left: 6px; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  text-decoration: none; color: var(--ink); background: var(--surface); }
.tabs a[aria-current] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: none; }
.barcell { display: flex; align-items: center; gap: 8px; }
meter { width: 110px; height: 12px; }
meter::-webkit-meter-bar { background: var(--line); border: none; border-radius: 6px; }
meter::-webkit-meter-optimum-value { background: var(--accent); border-radius: 6px; }
meter::-moz-meter-bar { background: var(--accent); }
.num { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .85rem; border-top: none; }

.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: 8px 0; border-top: 1px solid var(--line); }
.log li:first-child { border-top: none; }

.error { color: var(--bad); background: var(--bad-soft); padding: 8px 12px; border-radius: 8px; }
ul.error { padding-left: 28px; }
.ok { color: var(--ok); margin: 8px 0 0; }

/* comprimés */
.verdict { padding: 10px 14px; border-radius: 10px; margin: 4px 0 12px; }
.ok-box { background: var(--accent-soft); color: var(--ok); }
.bad-box { background: var(--bad-soft); color: var(--bad); }
.bad { color: var(--bad); font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 0 0 10px; }
.facts div { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
meter.wide { width: 100%; height: 14px; margin-bottom: 8px; }
meter::-webkit-meter-suboptimum-value, meter::-webkit-meter-even-less-good-value { background: var(--bad); border-radius: 6px; }
meter:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--bad); }
details { border-top: 1px solid var(--line); padding: 10px 0 0; margin-top: 10px; }
summary { cursor: pointer; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; align-items: end; }
.grid2 input { width: 100%; margin-top: 4px; }
.grid2 .full { grid-column: 1 / -1; margin: 0; }
label.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
