:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #1c2330;
  --muted: #667085;
  --accent: #1f5eff;
  --accent-soft: #e8efff;
  --good: #117a4b;
  --good-soft: #e3f5ec;
  --warn: #9a6100;
  --warn-soft: #fff3db;
  --bad: #b42318;
  --bad-soft: #fde8e7;
  --info: #175cd3;
  --info-soft: #e6effd;
  --neutral-soft: #eef0f3;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
h3 { font-size: 0.95rem; margin: 0 0 0.5rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
p { margin: 0 0 0.75rem; }
code { font-size: 0.85em; background: var(--neutral-soft); padding: 0.1em 0.35em; border-radius: 4px; }

/* Layout */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: var(--muted); padding: 6px 12px; border-radius: 6px; white-space: nowrap; }
.nav a:hover { background: var(--neutral-soft); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--neutral-soft); font-weight: 600; }
.user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.9rem; }
.container { max-width: 1280px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .subtitle { color: var(--muted); margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-flush { padding: 0; overflow-x: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 0.8rem; }
.kpi .value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.kpi .hint { color: var(--muted); font-size: 0.78rem; }
.kpi.good .value { color: var(--good); }
.kpi.warn .value { color: var(--warn); }
.kpi.info .value { color: var(--info); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; background: #fafbfc; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-muted { color: var(--muted); font-size: 0.82rem; }
.empty { color: var(--muted); padding: 32px; text-align: center; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--neutral-soft); color: var(--text); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--neutral-soft); color: var(--muted); }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Forms */
label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: var(--surface); color: var(--text);
}
textarea { min-height: 180px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { margin-bottom: 12px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--neutral-soft); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #164ad6; }
.btn-good { background: var(--good); border-color: var(--good); color: #fff; }
.btn-good:hover { background: #0c5e3a; }
.btn-danger { color: var(--bad); }
.btn-small { padding: 4px 10px; font-size: 0.85rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
form.inline { display: inline; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; border: 1px solid transparent; }
.flash.success { background: var(--good-soft); color: var(--good); border-color: #b7e4cc; }
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: #f5c2bd; }
.flash.info { background: var(--info-soft); color: var(--info); border-color: #c4d8f8; }

/* Detail page */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 0.92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.big-score { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.big-score small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.reasons { list-style: none; padding: 0; margin: 0; }
.reasons li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.reasons li:last-child { border-bottom: none; }
.reasons .pts { font-weight: 700; color: var(--good); min-width: 38px; font-variant-numeric: tabular-nums; }
.reasons .pts.neg { color: var(--bad); }
.blocks td { padding: 3px 8px 3px 0; border: none; }
.reasons .val { color: var(--muted); font-size: 0.85rem; }
.message-box { white-space: pre-wrap; background: #fafbfc; border: 1px solid var(--border); border-radius: 6px; padding: 14px; font-size: 0.95rem; }
.message-subject { font-weight: 700; margin-bottom: 8px; }
.alert { padding: 10px 12px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-size: 0.9rem; margin-bottom: 12px; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
details summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--info-soft); border-top-color: var(--info); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Pagination */
.pagination { display: flex; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 16px; color: var(--muted); font-size: 0.9rem; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }

/* Consommation */
.meter { height: 6px; background: var(--neutral-soft); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.meter span { display: block; height: 100%; background: var(--accent); }
.meter.warn span { background: #d98c00; }
.meter.bad span { background: var(--bad); }
.limit-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; align-items: end; }
.limit-form input[type=text] { font-variant-numeric: tabular-nums; }
.inline-check { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.85rem; }

/* Croisement des données */
.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 0.92rem; }
.check-list li:last-child { border-bottom: none; }
.check-icon { width: 20px; text-align: center; font-weight: 700; }
.check-icon.yes { color: var(--good); }
.check-icon.no { color: var(--bad); }
.check-icon.na { color: var(--muted); }
.source-values { display: flex; flex-direction: column; gap: 2px; }
.source-values .badge { margin-right: 6px; }
details.advanced { margin-top: 10px; }
details.advanced[open] summary { margin-bottom: 10px; }
.progress-table td { font-size: 0.85rem; }
textarea.compact { min-height: 110px; }
.qa-form { margin-bottom: 8px; }
.qa-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 12px; margin-bottom: 8px; }

/* Carte « Maquette » de la fiche : étapes numérotées */
.demo-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.demo-step { border-top: 1px solid var(--border); padding: 16px 0 6px; }
.demo-step:first-of-type { margin-top: 8px; }
.step-title { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 10px; }
.step-num { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 0.8rem; flex: none; }
.step-body { margin-left: 34px; }
.field-label { font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 6px; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-bottom: 14px; }
.choices > div { display: grid; gap: 8px; align-content: start; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 0.9rem; font-weight: 600; background: var(--surface); }
.choice:hover { border-color: #c5cad3; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 3px; }
.choice small { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 400; }
/* Modèles de maquette rangés par métier : nom du groupe à gauche, variantes à droite */
.template-groups { display: grid; margin-bottom: 14px; border-top: 1px solid var(--border); }
.template-group { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.template-group .choices { margin-bottom: 0; }
.template-group-name { padding-top: 10px; font-size: 0.9rem; font-weight: 700; }
@media (max-width: 700px) { .template-group { grid-template-columns: 1fr; } .template-group-name { padding-top: 0; } }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border); vertical-align: -3px; margin-right: 2px; }
.identity { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-thumb { max-height: 52px; max-width: 200px; background: #fff; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; }
.logo-empty { display: grid; place-items: center; height: 52px; padding: 0 16px; border: 1px dashed var(--border); border-radius: 6px; color: var(--muted); font-size: 0.85rem; }
.subpanel-toggle { margin-top: 10px; }
.subpanel { display: grid; gap: 16px; margin-top: 10px; padding: 14px; background: #fafbfc; border: 1px solid var(--border); border-radius: 8px; }
.color-input { width: 44px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; }
@media (max-width: 700px) { .step-body { margin-left: 0; } }
