/* Hope AI Console */
:root {
  --bg: #F3F5F7; --surface: #FFFFFF; --surface-2: #F7F8FA; --surface-3: #EEF1F5;
  --line: #E3E7EC; --line-strong: #D5DBE3;
  --ink: #0F1A2A; --ink-2: #3A4658; --ink-3: #5B6678;
  --accent: #C2410C; --accent-ink: #FFFFFF; --accent-soft: #FDEBE1; --accent-soft-ink: #9A3208; --accent-line: #F3C3A6;
  --ok: #0A6B4F; --ok-soft: #E3F4EC; --warn: #8A5A00; --warn-soft: #FFF3D6; --danger: #B42318; --danger-soft: #FDE8E6;
  --chart: #C2410C; --grid: #E8ECF1;
  --side: #0B1324; --side-ink: #C9D1DC; --side-ink-2: #8B97A8; --side-hover: #16213A;
  --shadow: 0 8px 24px rgba(15, 26, 42, 0.07);
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --display: 'Bricolage Grotesque', 'DM Sans', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B111C; --surface: #121A28; --surface-2: #172133; --surface-3: #1C273A; --line: #253147; --line-strong: #31405A;
    --ink: #EEF1F6; --ink-2: #C3CAD6; --ink-3: #95A0B2; --accent: #F07A3E; --accent-ink: #1A0D05; --accent-soft: #3A2215; --accent-soft-ink: #FFB48A; --accent-line: #6B3A20;
    --ok: #4CC79A; --ok-soft: #14322A; --warn: #F2C14E; --warn-soft: #3A2E12; --danger: #FF8A80; --danger-soft: #3D1A18; --chart: #F07A3E; --grid: #222D40;
    --side: #070C16; --side-hover: #121B2E; --shadow: 0 8px 24px rgba(0, 0, 0, 0.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B111C; --surface: #121A28; --surface-2: #172133; --surface-3: #1C273A; --line: #253147; --line-strong: #31405A;
  --ink: #EEF1F6; --ink-2: #C3CAD6; --ink-3: #95A0B2; --accent: #F07A3E; --accent-ink: #1A0D05; --accent-soft: #3A2215; --accent-soft-ink: #FFB48A; --accent-line: #6B3A20;
  --ok: #4CC79A; --ok-soft: #14322A; --warn: #F2C14E; --warn-soft: #3A2E12; --danger: #FF8A80; --danger-soft: #3D1A18; --chart: #F07A3E; --grid: #222D40;
  --side: #070C16; --side-hover: #121B2E; --shadow: 0 8px 24px rgba(0, 0, 0, 0.35); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }

/* Boutons et formulaires */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); }
.btn.small { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
.form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select, textarea { padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); font-weight: 400; color: var(--ink); outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

/* Accueil public : présentation de l'API et connexion */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.gate-wrap { width: min(980px, 100%); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 420px); gap: 40px; align-items: center; }
.pitch { display: flex; flex-direction: column; gap: 16px; }
.pitch h1 { margin: 8px 0 0; font: 700 clamp(30px, 5vw, 42px)/1.08 var(--display); letter-spacing: -.02em; }
.pitch .lead { margin: 0; font-size: 16.5px; color: var(--ink-2); max-width: 52ch; }
.price-card { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border-radius: 16px; background: var(--side); color: var(--side-ink); }
.price-card > span { font-size: 13px; color: var(--side-ink-2); }
.price-card b { font: 700 34px/1.15 var(--display); color: #fff; font-variant-numeric: tabular-nums; }
.price-card small { font-size: 13px; }
.perks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.perks li { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.perks b { font: 700 22px var(--display); color: var(--accent); font-variant-numeric: tabular-nums; }
.perks span { font-size: 13px; color: var(--ink-2); }
.pitch > p { margin: 0; }
.gate-card { width: 100%; padding: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.gate-card h2 { margin: 4px 0 0; font: 700 22px var(--display); }
.gate-card p { margin: 0; }
.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; color: var(--ink-2); }
.check input { width: 18px; height: 18px; margin-top: 2px; padding: 0; accent-color: var(--accent); flex: none; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-3); }
.seg button { height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-3); font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(15, 26, 42, .12); }
.msg { padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.ok-msg { padding: 10px 12px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-size: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 17px var(--display); }
.brand .logo { width: 32px; height: 32px; }
.brand b { color: var(--accent); }

/* Structure */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 18px 14px; background: var(--side); color: var(--side-ink); }
.side .brand { color: #fff; padding: 2px 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { margin: 14px 8px 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-ink-2); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--side-ink); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a.on { background: #fff; color: #0B1324; font-weight: 600; }
.side-foot { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.who b { color: #fff; font-size: 14px; }
.who small { color: var(--side-ink-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; flex: none; }
.side-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.side-actions .btn { background: transparent; border-color: rgba(255,255,255,.18); color: var(--side-ink); }
.side-actions .btn:hover { border-color: rgba(255,255,255,.4); color: #fff; }
.main { min-width: 0; padding: 26px 32px 60px; outline: none; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.top h1 { margin: 0; font: 700 26px var(--display); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.view { display: flex; flex-direction: column; gap: 18px; }

/* Cartes et indicateurs */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.card h2 { margin: 0 0 4px; font: 600 16px var(--font); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head p { margin: 0; color: var(--ink-3); font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile span { font-size: 13px; color: var(--ink-3); }
.tile b { font: 700 28px/1.15 var(--display); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tile small { font-size: 12.5px; color: var(--ink-3); }
.meter { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; border-radius: 6px; background: var(--chart); }
.meter.warn i { background: var(--warn); }
.meter.full i { background: var(--danger); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 48px; gap: 10px; align-items: center; font-size: 14px; }
.bar-row .meter { margin: 0; height: 8px; }
.bar-row b { text-align: right; font-variant-numeric: tabular-nums; }

/* Graphiques */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { fill: var(--ink-3); font: 11px var(--font); stroke: none; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--line-strong); stroke-width: 1; }
.chart .mark { fill: var(--chart); stroke: none; }
.chart .hit { fill: transparent; stroke: none; cursor: default; }
.chart .mark { pointer-events: none; }
.chart .mark.hl { filter: brightness(1.18); }
.tip { position: absolute; z-index: 5; pointer-events: none; padding: 7px 10px; border-radius: 9px; background: var(--ink); color: var(--surface); font-size: 12.5px; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px)); box-shadow: var(--shadow); }
.tip b { font-variant-numeric: tabular-nums; }

/* Tableaux */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 1 1 220px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td input { width: 100%; padding: 6px 8px; }
td input.n { max-width: 110px; text-align: right; }
.acts { display: flex; gap: 6px; justify-content: flex-end; }
.empty { padding: 26px; text-align: center; color: var(--ink-3); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.accent { background: var(--accent-soft); color: var(--accent-soft-ink); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.notice { padding: 14px 16px; border-radius: 12px; border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-soft-ink); font-size: 14px; }
.notice code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 5px; }

/* Fiche utilisateur, modale */
.modal { width: min(560px, calc(100vw - 24px)); max-height: min(88vh, 900px); border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(0,0,0,.28); }
.modal::backdrop { background: rgba(11, 17, 28, .55); }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { margin: 0; font: 700 20px var(--display); }
.modal-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 14px; margin: 0; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1 1 140px; }
.secret { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--surface-3); font: 13px var(--mono); overflow-wrap: anywhere; }
.secret span { flex: 1; min-width: 0; }

/* Atelier */
.bench { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
.bench-side { display: flex; flex-direction: column; gap: 12px; }
.chat { display: flex; flex-direction: column; gap: 12px; min-height: 280px; }
.bubble { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.user { align-self: flex-end; max-width: 85%; background: var(--ink); color: var(--surface); border-color: var(--ink); }
.bubble small { display: block; margin-top: 8px; color: var(--ink-3); font-size: 12px; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 46px; }

/* Documentation */
.doc h2 { font: 700 19px var(--display); margin: 8px 0 6px; }
.doc h3 { font: 600 15px var(--font); margin: 18px 0 6px; }
.doc p, .doc li { color: var(--ink-2); }
.doc code { font-family: var(--mono); font-size: 13px; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
.code { position: relative; margin: 8px 0 14px; border-radius: 12px; background: #0F1A2A; color: #E6EAF0; overflow: hidden; }
.code-tabs { display: flex; gap: 2px; padding: 6px 6px 0; background: #0B1324; overflow-x: auto; }
.code-tabs button { border: 0; background: transparent; color: #95A0B2; padding: 7px 12px; border-radius: 8px 8px 0 0; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.code-tabs button.on { background: #0F1A2A; color: #fff; }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; font: 12.5px/1.6 var(--mono); }
.code .copy { position: absolute; top: 6px; right: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: 8px; background: rgba(255,255,255,.08); color: #C3CAD6; font-size: 12px; cursor: pointer; }
.endpoint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font: 14px var(--mono); }
.verb { padding: 2px 8px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.verb.post { background: var(--accent-soft); color: var(--accent-soft-ink); }
.verb.get { background: var(--ok-soft); color: var(--ok); }

/* Crédit et facturation */
.balance { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.balance b { display: block; font: 700 38px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.balance.low b { color: var(--danger); }
.amounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.amounts button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; }
.amounts button b { font: 700 18px var(--display); font-variant-numeric: tabular-nums; }
.amounts button small { font-size: 12px; color: var(--ink-3); }
.amounts button.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.steps li::before { counter-increment: s; content: counter(s); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-weight: 700; font-size: 14px; }
.steps li.done::before { content: '✓'; background: var(--ok-soft); color: var(--ok); }
.steps li span { display: flex; flex-direction: column; }
.steps li small { color: var(--ink-3); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--surface); font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.loading { padding: 30px; text-align: center; color: var(--ink-3); }

/* Téléphone et tablette */
@media (max-width: 900px) {
  .gate { place-items: start center; }
  .gate-wrap { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side, .nav { min-width: 0; }
  /* Téléphone : toutes les rubriques visibles d'un coup d'œil (grille de 4 × 2), sans défilement caché. */
  .side { position: static; height: auto; flex-direction: column; gap: 10px; padding: 12px 12px 14px; }
  .nav { flex: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; overflow: visible; }
  .nav-label { display: none; }
  .nav a { flex-direction: column; justify-content: center; gap: 5px; min-height: 58px; padding: 8px 4px; font-size: 11.5px; line-height: 1.2; text-align: center; border-radius: 10px; }
  .nav a svg { width: 20px; height: 20px; }
  .nav.dev { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .side-foot { border: 0; padding: 0; }
  .who { display: none; }
  .main { padding: 18px 16px 50px; }
  .grid2, .bench { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 40px; }
  .dl { grid-template-columns: 1fr; }
  .dl dt { margin-top: 6px; }
}
@media (max-width: 520px) {
  .perks { grid-template-columns: minmax(0, 1fr); }
  .perks li { flex-direction: row; align-items: baseline; gap: 8px; }
  .perks b { font-size: 19px; }
  .steps li { grid-template-columns: 30px minmax(0, 1fr); }
  .steps li .btn { grid-column: 2; justify-self: start; }
}

/* Double authentification */
.mfa-card { max-width: 560px; }
.mfa-steps { margin: 0 0 12px; padding-left: 20px; line-height: 1.6; }
.mfa-qr { display: block; width: 190px; height: 190px; margin: 4px 0 10px; padding: 8px; background: #fff; border-radius: 12px; border: 1px solid var(--line, #E3E7EC); }
#mfaCode { letter-spacing: .3em; font-size: 20px; max-width: 200px; }

/* Hope Code */
.code-status.on { border-color: color-mix(in srgb, var(--accent, #C2410C) 45%, var(--line)); }
.code-meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 4px; }
.code-meter { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.code-meter .row-between { display: flex; justify-content: space-between; gap: 8px; }
.code-perks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.code-perks li { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.code-perks span { color: var(--ink-3); font-size: 13.5px; }
.code-steps li > span { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.code-cmd { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 10px; background: var(--code, #0F1A2A); color: #E6EAF0; min-width: 0; }
.code-cmd code, .doc .code-cmd code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font: 13px var(--mono, ui-monospace, monospace); background: transparent; color: #E6EAF0; padding: 0; border: 0; }
.code-cmd .btn { color: #E6EAF0; border-color: rgba(255,255,255,.25); background: transparent; flex: none; }
.code-notes { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); font-size: 14px; }
