:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --text: #18202b; --muted: #5b6676; --border: #dde2e9;
  --accent: #1f5fbf; --accent-2: #e8f0fb; --pos: #137a3e; --neg: #b3261e; --warn: #8a5a00; --warn-bg: #fff4dc;
  --sim: #7b3fbf; --sim-bg: #f3ecfb; --info-bg: #e8f0fb; --err-bg: #fde8e6; --ok-bg: #e5f5ea;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b; --surface: #161d27; --surface-2: #1d2633; --text: #e6ebf2; --muted: #9aa6b6; --border: #2a3646;
    --accent: #6ea8ff; --accent-2: #1b2a40; --pos: #4cc27a; --neg: #ff7a70; --warn: #f0c060; --warn-bg: #3a2e12;
    --sim: #c39bff; --sim-bg: #2a1f3a; --info-bg: #1b2a40; --err-bg: #3d1f1d; --ok-bg: #173323;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: .2rem 0 .8rem; line-height: 1.25; }
h2 { font-size: 1.2rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1.02rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: .9em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 99; }

/* En-tête */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 8px 16px; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--text); padding: 6px 9px; border-radius: 8px; font-size: .93rem; }
.nav a:hover, .nav a.active { background: var(--accent-2); text-decoration: none; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.mode-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.mode-switch button { border: 0; background: transparent; color: var(--text); padding: 5px 11px; font-size: .85rem; cursor: pointer; }
.mode-switch button.on { background: var(--accent); color: #fff; }
.menu-toggle { display: none; }
.notif { position: relative; }
.notif .count { position: absolute; top: -6px; right: -8px; background: var(--neg); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 5px; }
@media (max-width: 980px) {
  .topbar .inner { flex-wrap: wrap; }
  .menu-toggle { display: inline-block; }
  .nav { display: none; flex-basis: 100%; flex-direction: column; }
  .nav.open { display: flex; }
}

main { max-width: 1280px; margin: 0 auto; padding: 16px; }
.banner { padding: 9px 16px; font-size: .88rem; text-align: center; }
.banner.sim { background: var(--sim-bg); color: var(--sim); border-bottom: 1px solid var(--border); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }

/* Mises en page */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.kpi { font-size: 1.4rem; font-weight: 650; }
.kpi-label { color: var(--muted); font-size: .82rem; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.right { text-align: right; }
.hidden { display: none !important; }
body.mode-simple .expert-only { display: none !important; }
body.mode-expert .simple-only { display: none !important; }

/* Tableaux */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:hover td { background: var(--surface-2); }

/* Formulaires */
form.inline { display: inline; }
label { display: block; font-size: .87rem; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 90px; font-family: var(--mono); font-size: .85rem; }
.field { margin-bottom: 10px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: .92rem; }
button, .btn { display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; font: inherit; font-size: .92rem; cursor: pointer; text-decoration: none; }
.btn.secondary, button.secondary { background: transparent; color: var(--accent); }
.btn.danger, button.danger { background: var(--neg); border-color: var(--neg); }
.btn.small, button.small { padding: 4px 9px; font-size: .82rem; }
button:hover, .btn:hover { filter: brightness(1.07); text-decoration: none; }
button[disabled] { opacity: .5; cursor: not-allowed; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; }
.fieldset legend { padding: 0 6px; color: var(--muted); font-size: .85rem; }

/* Badges et messages */
.badge { display: inline-block; font-size: .74rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.fresh-temps_reel { background: var(--ok-bg); color: var(--pos); }
.badge.fresh-differe, .badge.fresh-fin_de_journee { background: var(--info-bg); color: var(--accent); }
.badge.fresh-synthetique { background: var(--sim-bg); color: var(--sim); }
.badge.fresh-obsolete { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--pos); } .badge.err { background: var(--err-bg); color: var(--neg); }
.badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.sim { background: var(--sim-bg); color: var(--sim); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--info-bg); }
.flash.error { background: var(--err-bg); color: var(--neg); }
.flash.warning { background: var(--warn-bg); color: var(--warn); }
.note { border-left: 4px solid var(--accent); background: var(--info-bg); padding: 8px 12px; border-radius: 6px; font-size: .9rem; margin: 10px 0; }
.note.warn { border-color: var(--warn); background: var(--warn-bg); }
.note.sim { border-color: var(--sim); background: var(--sim-bg); }
.note.err { border-color: var(--neg); background: var(--err-bg); }
.disclaimer { font-size: .8rem; color: var(--muted); border-top: 1px solid var(--border); margin-top: 24px; padding-top: 10px; }

/* Glossaire / infobulles */
a.term { border-bottom: 1px dotted var(--accent); color: inherit; position: relative; }
a.term:hover { text-decoration: none; }
.tip { position: absolute; z-index: 50; max-width: 320px; background: var(--text); color: var(--bg); padding: 8px 10px; border-radius: 8px; font-size: .82rem; line-height: 1.4; box-shadow: var(--shadow); }

/* Divulgation progressive */
details.layer { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin: 8px 0; }
details.layer > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style: none; }
details.layer > summary::before { content: "▸ "; color: var(--muted); }
details.layer[open] > summary::before { content: "▾ "; }
details.layer > div { padding: 0 14px 12px; }

/* Graphiques */
.chart { width: 100%; height: 420px; position: relative; }
.chart.small { height: 150px; }
.chart.medium { height: 300px; }
@media (max-width: 680px) { .chart { height: 320px; } }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .82rem; color: var(--muted); margin: 6px 0; }
.legend i { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 4px; border-radius: 2px; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px); height: 2px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.toolbar button { background: var(--surface-2); color: var(--text); border-color: var(--border); padding: 4px 9px; font-size: .82rem; }
.toolbar button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; gap: 6px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-size: .82rem; }
.chip button { background: none; border: 0; color: var(--muted); padding: 0; cursor: pointer; }

/* Scénarios */
.scenarios { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .scenarios { grid-template-columns: minmax(0, 1fr); } }
.scen { border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--border); background: var(--surface); }
.scen.haussier { border-top: 4px solid var(--pos); } .scen.central { border-top: 4px solid var(--accent); } .scen.baissier { border-top: 4px solid var(--neg); }
.scen .value { font-size: 1.3rem; font-weight: 650; }
.meter { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); }

/* Robots */
.robot { border-left: 4px solid var(--border); }
.robot.st-succes { border-left-color: var(--pos); } .robot.st-echec, .robot.st-delai_depasse { border-left-color: var(--neg); }
.robot.st-donnees_insuffisantes { border-left-color: var(--warn); } .robot.st-ignore { border-left-color: var(--muted); opacity: .85; }
.orient { display: inline-block; min-width: 54px; text-align: center; border-radius: 6px; padding: 1px 6px; font-weight: 600; font-size: .85rem; background: var(--surface-2); }
.kind { font-size: .7rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

/* Recherche */
.search-box { position: relative; }
.suggest { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); z-index: 30; max-height: 320px; overflow: auto; }
.suggest a { display: block; padding: 7px 10px; color: var(--text); }
.suggest a:hover, .suggest a.sel { background: var(--accent-2); text-decoration: none; }

footer.site { max-width: 1280px; margin: 0 auto; padding: 16px; font-size: .82rem; color: var(--muted); }
footer.site a { color: var(--muted); }
.hero { padding: 28px 0 8px; }
.hero h1 { font-size: 2rem; }
@media (max-width: 680px) { .hero h1 { font-size: 1.5rem; } }
.price { font-size: 1.8rem; font-weight: 700; }
.assistant-sec h3 { font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
@media print { .topbar, .no-print, footer.site, .banner { display: none !important; } body { background: #fff; color: #000; } .card { box-shadow: none; } }
