:root {
  color-scheme: dark;
  --bg: #0c1110;
  --surface: #151c1a;
  --surface-2: #1e2825;
  --line: #2d3a35;
  --text: #eef3ef;
  --muted: #9dada6;
  --accent: #c7f36b;
  --accent-ink: #142006;
  --ok: #62d99a;
  --warn: #f2b84b;
  --bad: #ff8577;
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
.stack { display: grid; gap: 12px; }
.stack-lg { display: grid; gap: 20px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Bandeau de demo */
.demo-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 16px; font-size: 12px;
  background: #2a2412; color: var(--warn); border-bottom: 1px solid #453a18;
}
.demo-bar button {
  min-height: 32px; padding: 0 10px; border: 1px solid #5d4e20; border-radius: 8px;
  background: transparent; color: var(--warn); font-weight: 700; font-size: 12px; white-space: nowrap;
}

/* Mises en page */
.shell { width: 100%; max-width: 480px; margin: 0 auto; padding: 20px 16px 104px; }
.shell-plain { padding-bottom: 32px; }
.shell-wide { max-width: 1040px; padding-bottom: 40px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.01em; }
.brand i { width: 22px; height: 22px; border-radius: 7px; background: var(--accent); display: block; position: relative; }
.brand i::after { content: ""; position: absolute; inset: 6px 5px; border-left: 3px solid var(--accent-ink); border-bottom: 3px solid var(--accent-ink); transform: skewX(-12deg); }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-tight { padding: 4px 16px; }
.list-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 50px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 13px;
  font-weight: 700; background: var(--surface-2); border-color: var(--line);
}
a.btn { color: var(--text); }
.btn:hover { border-color: #46574f; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: #d4f886; border-color: #d4f886; }
.btn-danger { background: transparent; color: var(--bad); border-color: #6b3a33; }
.btn-danger:hover { border-color: var(--bad); }
.btn-solid-danger { background: var(--bad); color: #2c0b07; border-color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { width: auto; min-height: 40px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.link { background: none; border: 0; padding: 8px 0; color: var(--accent); font-weight: 700; font-size: 13px; min-height: 40px; }
a.link { display: inline-block; min-height: 0; padding: 4px 0; text-decoration: none; }
a.link:hover { text-decoration: underline; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Formulaires */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select {
  width: 100%; min-height: 50px; padding: 0 14px; font-size: 16px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
.field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 1px var(--accent); }
.field input[aria-invalid="true"] { border-color: var(--bad); }
.hint { font-size: 12.5px; color: var(--muted); }
.error { font-size: 13px; color: var(--bad); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* Etapes */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.steps span { height: 4px; border-radius: 4px; background: var(--line); }
.steps span.done { background: var(--accent); }

/* Choix du plafond */
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice button {
  padding: 14px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); text-align: left;
}
.choice button strong { display: block; font-size: 22px; font-weight: 800; }
.choice button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-weight: 600; text-align: right; }
.checks { display: grid; gap: 8px; padding: 0; margin: 0; list-style: none; font-size: 14px; }
.checks li { padding-left: 24px; position: relative; }
.checks li::before { content: "✓"; position: absolute; left: 2px; color: var(--ok); font-weight: 800; }

/* Etat du bot */
.status-card { border-width: 1px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 700; background: var(--surface-2); white-space: nowrap;
  justify-self: start; flex: none;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: #143226; }
.pill.warn { color: var(--warn); background: #352a10; }
.pill.bad { color: var(--bad); background: #3a1b17; }
.pill.neutral { color: var(--muted); }
.switch {
  flex: none; width: 56px; height: 32px; padding: 3px; border-radius: 99px; border: 0;
  background: var(--line); transition: background .15s;
}
.switch::after { content: ""; display: block; width: 26px; height: 26px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(24px); background: var(--accent-ink); }

/* Plafond */
.amount { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.amount small { font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.meter { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 8px; background: var(--accent); transition: width .25s; }
.meter.low i { background: var(--warn); }
.meter.empty i { background: var(--bad); }
.alert { padding: 12px 14px; border-radius: 12px; font-size: 14px; border: 1px solid; }
.alert.warn { color: var(--warn); border-color: #5d4e20; background: #231d0c; }
.alert.bad { color: var(--bad); border-color: #6b3a33; background: #2a1411; }

/* Navigation basse */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: rgba(12, 17, 16, .94); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs-inner { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; max-width: 480px; }
.tabs button {
  display: grid; justify-items: center; gap: 3px; min-height: 62px; padding: 10px 0 8px;
  background: none; border: 0; color: var(--muted); font-size: 12px; font-weight: 600;
}
.tabs button[aria-current="page"] { color: var(--accent); }
.tabs svg { width: 22px; height: 22px; }

/* Segments (filtres, onglets admin) */
.segments { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.segments button {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 10px; font-size: 13px; font-weight: 700;
  background: transparent; border: 1px solid var(--line); color: var(--muted);
}
.segments button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); border-color: #46574f; }

/* Admin */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.tile strong { display: block; font-size: 24px; font-weight: 800; }
.client-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.client-grid { display: grid; gap: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 620px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
@media (min-width: 720px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .client-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Fenetres et messages */
dialog {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow-y: auto;
  padding: 20px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px;
}
dialog::backdrop { background: rgba(0, 0, 0, .65); }
.toast {
  position: fixed; left: 50%; bottom: 84px; z-index: 30; transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600; text-align: center;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition: none !important; }
}
