:root {
  --fond: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --encre: #162323;
  --encre-2: #4d5b5a;
  --encre-3: #7d8a88;
  --trait: #dfe3de;
  --barre: #0e2a2b;
  --barre-encre: #c9dcd8;
  --accent: #0f8a73;
  --accent-fort: #0b6e5c;
  --accent-doux: #def3ec;
  --ok: #1d8a4e;
  --ok-doux: #e1f4e8;
  --attention: #a86500;
  --attention-doux: #fbf0dc;
  --danger: #b3322c;
  --danger-doux: #fbe6e4;
  --ombre: 0 1px 2px rgba(14, 42, 43, .06), 0 4px 16px rgba(14, 42, 43, .05);
  --rayon: 12px;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #0f1716; --surface: #16201f; --surface-2: #1c2827; --encre: #e4ecea; --encre-2: #a9b8b5;
    --encre-3: #788986; --trait: #263533; --barre: #0a1212; --barre-encre: #9fb8b3; --accent: #3fc6a5;
    --accent-fort: #63d8bb; --accent-doux: #173a33; --ok: #4fc483; --ok-doux: #173323; --attention: #e3a64a;
    --attention-doux: #3a2c14; --danger: #f07b74; --danger-doux: #3d1b19; color-scheme: dark;
    --ombre: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fond); color: var(--encre);
  font: 15px/1.5 "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-fort); }
button, input, select { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: .88em; }

/* ---------- mise en page */
.cadre { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.barre {
  background: var(--barre); color: var(--barre-encre); padding: 22px 14px;
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.marque { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; color: #fff; font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; }
.marque svg { width: 30px; height: 30px; }
.marque small { display: block; font-weight: 400; font-size: .72rem; color: var(--barre-encre); letter-spacing: 0; }
.barre a {
  color: inherit; text-decoration: none; padding: 9px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center;
}
.barre a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.barre a.actif { background: rgba(63, 209, 174, .14); color: #fff; }
.barre a .ico { width: 18px; text-align: center; opacity: .8; }
.barre .bas { margin-top: auto; font-size: .8rem; padding: 10px 12px; }
.barre .bas button { background: none; border: 0; color: var(--barre-encre); cursor: pointer; padding: 0; text-decoration: underline; }

main.page { padding: 30px 36px 60px; max-width: 1180px; width: 100%; }
.entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
h1 { font-size: 1.55rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0 0 12px; }
.sous { color: var(--encre-2); margin: 4px 0 0; }

/* ---------- éléments */
.carte { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 18px 20px; }
.grille { display: grid; gap: 16px; }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chiffre { font-size: 1.5rem; font-weight: 600; letter-spacing: -.01em; }
.etiquette { color: var(--encre-3); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.jauge { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.jauge span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.jauge.haut span { background: var(--attention); }
.petit { font-size: .84rem; color: var(--encre-2); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--trait); background: var(--surface);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; text-decoration: none; color: var(--encre);
}
.btn:hover { border-color: var(--encre-3); }
.btn.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.principal:hover { background: var(--accent-fort); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.danger.plein { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.pastille { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pastille::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.p-ok { background: var(--ok-doux); color: var(--ok); }
.p-att { background: var(--attention-doux); color: var(--attention); }
.p-err { background: var(--danger-doux); color: var(--danger); }
.p-neutre { background: var(--surface-2); color: var(--encre-2); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--encre-3); font-weight: 600; padding: 0 12px 10px; }
td { padding: 13px 12px; border-top: 1px solid var(--trait); vertical-align: middle; }
tr.lien { cursor: pointer; }
tr.lien:hover td { background: var(--surface-2); }
td .nom { font-weight: 600; }
.vide { text-align: center; padding: 34px 10px; color: var(--encre-2); }

/* ---------- formulaires */
form .champ { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
label { font-weight: 600; font-size: .9rem; }
.aide { font-size: .82rem; color: var(--encre-3); font-weight: 400; }
input[type=text], input[type=email], input[type=password], select {
  border: 1px solid var(--trait); background: var(--surface); border-radius: 8px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-color: var(--accent); }
.choix { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choix label { border: 1px solid var(--trait); border-radius: 10px; padding: 12px 14px; cursor: pointer; font-weight: 500; display: flex; gap: 10px; align-items: flex-start; }
.choix label:has(input:checked) { border-color: var(--accent); background: var(--accent-doux); }
.choix input { margin-top: 4px; accent-color: var(--accent); }
.suffixe { display: flex; align-items: stretch; }
.suffixe input { border-radius: 8px 0 0 8px; }
.suffixe span { border: 1px solid var(--trait); border-left: 0; background: var(--surface-2); border-radius: 0 8px 8px 0; padding: 9px 11px; font-family: var(--mono); font-size: .85rem; color: var(--encre-2); white-space: nowrap; }
input[type=color] { width: 52px; height: 38px; border: 1px solid var(--trait); border-radius: 8px; padding: 2px; background: var(--surface); }
.dns { font-size: .84rem; margin-top: 2px; }
.dns.ok { color: var(--ok); } .dns.non { color: var(--attention); }
.message { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .92rem; }
.message.err { background: var(--danger-doux); color: var(--danger); }
.message.ok { background: var(--ok-doux); color: var(--ok); }
.message.info { background: var(--accent-doux); color: var(--accent-fort); }

/* ---------- connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; background:
  radial-gradient(1200px 500px at 20% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent), var(--fond); }
.connexion .carte { width: 100%; max-width: 380px; padding: 30px 28px; }
.connexion .marque { color: var(--encre); padding: 0 0 18px; }
.connexion .marque small { color: var(--encre-3); }
.connexion .btn { width: 100%; justify-content: center; padding: 10px; }

/* ---------- tâche / journal */
.journal { background: #0d1717; color: #cfe3de; font-family: var(--mono); font-size: .82rem; line-height: 1.6;
  border-radius: 10px; padding: 14px 16px; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.journal .err { color: #ff9b94; }
.secret { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--accent-doux); border-radius: 10px; padding: 14px 16px; margin: 14px 0; }
.secret code { font-family: var(--mono); font-size: 1.05rem; background: var(--surface); padding: 4px 10px; border-radius: 6px; user-select: all; }
.tourne { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: t .8s linear infinite; }
@keyframes t { to { transform: rotate(360deg); } }

dl.infos { display: grid; grid-template-columns: 160px 1fr; gap: 9px 16px; margin: 0; }
dl.infos dt { color: var(--encre-3); font-size: .88rem; }
dl.infos dd { margin: 0; }
.qr { background: #fff; padding: 8px; border-radius: 8px; display: inline-block; }
.bandeau-tache { display: flex; align-items: center; gap: 10px; background: var(--accent-doux); color: var(--accent-fort); padding: 10px 14px; border-radius: 10px; margin-bottom: 18px; text-decoration: none; }

dialog { border: 0; border-radius: 14px; padding: 24px; max-width: 440px; width: calc(100% - 32px); background: var(--surface); color: var(--encre); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(10, 20, 20, .45); }

@media (max-width: 860px) {
  .cadre { grid-template-columns: 1fr; }
  .barre { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 12px 16px; align-items: center; }
  .marque { padding: 0 12px 0 0; }
  .barre .bas { margin: 0 0 0 auto; padding: 0; }
  main.page { padding: 20px 16px 50px; }
  .g3, .g2, .choix { grid-template-columns: 1fr; }
  dl.infos { grid-template-columns: 1fr; gap: 2px; }
  dl.infos dd { margin-bottom: 8px; }
  .masquer-mobile { display: none; }
}

/* espacement vertical entre blocs */
.page > .grille, .page > .carte, .page > form, .page > .message { margin-bottom: 16px; }
hr.espace { border: 0; border-top: 1px solid var(--trait); margin: 18px 0; }
.carte .entete { margin-bottom: 12px; }

[hidden] { display: none !important; }
