/* ==========================================================================
   League of Market — Design system
   --------------------------------------------------------------------------
   Loaded by every page (auth, dashboards, landing).

   Note on constraints: the CSP in public/.htaccess is `style-src 'self'`,
   so no inline <style> and no external stylesheet/font CDN is possible.
   Typography therefore relies on the system font stack, and every visual
   effect here is pure CSS (gradients, backdrop-filter, transforms).

   Contents
   1.  Design tokens (dark default + light theme)
   2.  Reset & base elements
   3.  Typography
   4.  Layout primitives
   5.  Buttons
   6.  Forms
   7.  Surfaces: cards, panels, KPIs
   8.  Tables
   9.  Badges & pills
   10. App shell: topbar
   11. Auth pages
   12. Footer
   13. Toasts
   14. Motion preferences & utilities
   ========================================================================== */

/* ---------- 1. Design tokens ------------------------------------------- */

:root {
  color-scheme: dark;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --bg: #070a12;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, #12224a 0%, transparent 60%),
             radial-gradient(1000px 500px at 100% 0%, #0b3b33 0%, transparent 55%),
             #070a12;
  --surface: rgba(148, 163, 184, 0.045);
  --surface-solid: #0e1424;
  --surface-2: rgba(148, 163, 184, 0.075);
  --control-bg: #151e33;
  --select-text: #ffb547;
  --control-option-bg: #101829;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.26);

  --text: #e9eefb;
  --muted: #93a3bd;
  --faint: #7586a6;

  --brand: #2ee6a8;
  --brand-ink: #03251b;
  --brand-soft: rgba(46, 230, 168, 0.14);
  --blue: #5b8cff;
  --blue-soft: rgba(91, 140, 255, 0.14);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.14);
  --danger: #ff5f70;
  --danger-soft: rgba(255, 95, 112, 0.14);
  --warn: #ffb547;
  --warn-soft: rgba(255, 181, 71, 0.14);

  --grad-brand: linear-gradient(135deg, #2ee6a8 0%, #38bdf8 50%, #5b8cff 100%);
  --grad-surface: linear-gradient(180deg, rgba(148, 163, 184, 0.08), rgba(148, 163, 184, 0.02));

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-full: 999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 30px 70px -25px rgba(0, 0, 0, 0.85);
  --ring: 0 0 0 3px rgba(46, 230, 168, 0.35);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t-fast: 140ms;
  --t: 240ms;

  --container: 1200px;
  --topbar-h: 68px;
}

[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f7fc;
  --bg-grad: radial-gradient(1100px 560px at 10% -12%, #dbe8ff 0%, transparent 60%),
             radial-gradient(900px 480px at 100% 0%, #d6f5ea 0%, transparent 55%),
             #f4f7fc;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --surface-2: #f1f5fb;
  --control-bg: #ffffff;
  --select-text: var(--text);
  --control-option-bg: #ffffff;
  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.20);

  --text: #0a1020;
  --muted: #55637e;
  --faint: #616e8a;

  --brand: #0b9e70;
  --brand-ink: #ffffff;
  --brand-soft: rgba(11, 158, 112, 0.12);
  --blue: #2a5cd7;
  --blue-soft: rgba(42, 92, 215, 0.12);
  --violet: #7c4ddb;
  --violet-soft: rgba(124, 77, 219, 0.12);
  --danger: #d32b40;
  --danger-soft: rgba(211, 43, 64, 0.10);
  --warn: #b26a00;
  --warn-soft: rgba(178, 106, 0, 0.12);

  --grad-surface: linear-gradient(180deg, #ffffff, #fbfcfe);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 30px -14px rgba(15, 23, 42, 0.22);
  --shadow-lg: 0 30px 70px -30px rgba(15, 23, 42, 0.32);
  --ring: 0 0 0 3px rgba(11, 158, 112, 0.28);
}

/* ---------- 2. Reset & base ------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 16px);
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--brand-soft); color: var(--text); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 50%;
  top: -60px;
  transform: translateX(-50%);
  z-index: 200;
  padding: 0.7rem 1.2rem;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 650;
  border-radius: 0 0 var(--r-md) var(--r-md);
  transition: top var(--t) var(--ease);
}
.skip-link:focus { top: 0; text-decoration: none; }

/* ---------- 3. Typography -------------------------------------------- */

h1, h2, h3, h4 {
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
  text-wrap: balance;
}

h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.1rem); }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.15rem); }
h3 { font-size: 1.15rem; }

p { text-wrap: pretty; }

.hint { color: var(--muted); font-size: 0.85rem; }
.mono {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  word-break: break-all;
  font-variant-numeric: tabular-nums;
}
.num { font-variant-numeric: tabular-nums; }

.errors { color: var(--danger); }
.success { color: var(--brand); }

.gradient-text {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- 4. Layout primitives -------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1rem, 0.6rem + 2vw, 2rem);
}

main { max-width: 1180px; margin: 0 auto; padding: clamp(1.25rem, 1rem + 2vw, 2rem); }
main.flush { max-width: none; padding: 0; }

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-sm { gap: 0.5rem; }
.gap { gap: 1rem; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.center { text-align: center; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 1rem;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  align-items: stretch;
}

/* Une formule, deux moyens de reglement. La pile et les boutons cote a cote
   plutot que deux cartes : ce sont les deux facons de payer le meme prix, pas
   deux formules, et les juxtaposer ferait croire a un choix different. */
.plan-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.plan-info h3 { margin-bottom: 0.15rem; }
.plan-info p { margin-bottom: 0; }
.plan-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.inline-form { display: inline-flex; margin: 0; }

/* Choix du moyen de versement, et bascule sur le champ de numero Wave.
   La bascule se fait sans script : un script qui doit s'executer pour rendre
   le champ visible est un script qui bloque le retrait quand il echoue.
   `:has()` est necessaire parce que chaque bouton radio est enveloppe dans son
   <label> : le selecteur frere `~` ne peut donc pas l'atteindre, et ne reliait
   jamais le bouton au champ. Le repli `@supports` laisse le champ visible
   partout ailleurs — un champVisible en trop est corriger par le serveur, un
   champ invisible retire au Pro son seul moyen de paiement. */
.method-choice {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  display: grid;
  gap: 0.5rem;
}
.method-choice .label { margin-bottom: 0; }
.wave-only { display: block; }
@supports selector(:has(*)) {
  .wave-only { display: none; }
  .method-choice:has(input[value="WAVE"]:checked) .wave-only { display: block; }
}

@media (max-width: 560px) {
  .plan-actions { width: 100%; }
  .plan-actions .btn { flex: 1 1 auto; justify-content: center; }
}

.align-end { align-items: flex-end; }

/* Horizontal rule for splitting a long settings panel. A styled div rather than
   <hr> so the thickness and colour stay in the design system. */
.divider {
  height: 1px;
  border: 0;
  background: var(--border);
}

.p-3 { padding: 0.9rem; }
.p-4 { padding: 1.6rem; }

/* Progress bar — the fill width comes from data-width and is applied by JS,
   since the CSP rules out an inline style attribute. */
.progress {
  height: 7px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: var(--r-full);
  background: var(--grad-brand);
  transition: width 900ms var(--ease);
}
.progress-bar.is-ok { background: var(--brand); }

/* ---------- 5. Buttons ----------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: transform var(--t-fast) var(--ease),
              box-shadow var(--t) var(--ease),
              background var(--t) var(--ease),
              border-color var(--t) var(--ease),
              opacity var(--t) var(--ease);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: 0 8px 24px -10px var(--brand);
}
.btn-primary:hover { background: var(--brand); filter: brightness(1.07); }

.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-outline:hover { background: var(--surface-2); border-color: var(--brand); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--brand); color: var(--brand); }

.btn-danger { background: var(--danger); color: #fff; }

/* Wave : le bleu de la marque, distinct du vert de la plateforme pour que les
   deux moyens de paiement ne se confondent jamais a la lecture. Le texte est
   blanc sur le bleu de Wave, dont le contraste passe largement AA — un bleu
   clair avec du blanc dessus ne le passerait pas. */
.btn-wave {
  background: #1a56db;
  border-color: #1a56db;
  color: #fff;
  box-shadow: 0 8px 24px -12px #1a56db;
}
.btn-wave:hover { background: #1543ab; border-color: #1543ab; filter: none; }
.btn-wave.btn-sm { box-shadow: 0 6px 18px -12px #1a56db; }
.btn-ok { background: var(--brand); color: var(--brand-ink); }

.btn-sm { padding: 0.45rem 0.8rem; font-size: 0.85rem; border-radius: var(--r-sm); }
.btn-lg { padding: 0.95rem 1.75rem; font-size: 1.05rem; border-radius: var(--r-lg); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--t) var(--ease);
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

/* Plain <button> used by legacy forms still gets a sane look. */
form > button:not([class]),
.inline-form button {
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 650;
  border: none;
  cursor: pointer;
  transition: filter var(--t) var(--ease), transform var(--t-fast) var(--ease);
}
form > button:not([class]):hover,
.inline-form button:hover { filter: brightness(1.08); transform: translateY(-1px); }

.inline-form { display: inline-flex; flex-direction: row; gap: 0.4rem; }
.inline-form button { padding: 0.4rem 0.75rem; border-radius: var(--r-sm); font-size: 0.85rem; }

/* ---------- 6. Forms --------------------------------------------------- */

form { display: flex; flex-direction: column; gap: 0.5rem; }

label, .label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 0.5rem;
  letter-spacing: 0.01em;
}
.label { display: block; }

input, select, textarea {
  width: 100%;
  padding: 0.72rem 0.9rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease),
              background var(--t) var(--ease);
}
input:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
input::placeholder { color: var(--faint); }
input:disabled, select:disabled, textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--surface);
  border-color: var(--border);
}
input:disabled:hover, select:disabled:hover, textarea:disabled:hover {
  border-color: var(--border);
}

select {
  appearance: none;
  background-color: var(--control-bg);
  color: var(--select-text);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.4rem;
}

select option,
select optgroup {
  background-color: var(--control-option-bg);
  color: var(--select-text);
}

select option:checked {
  background-color: var(--control-option-bg);
  color: var(--select-text);
}

.field-hint { font-size: 0.78rem; color: var(--faint); margin-top: 0.15rem; }
.field-error { font-size: 0.8rem; color: var(--danger); }

/* Password field with a show/hide toggle */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 2.9rem; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--faint);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
}
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
.pw-toggle.is-on { color: var(--brand); }

/* Password strength meter (register page) */
.pw-meter {
  height: 5px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 0.4rem;
}
.pw-meter > span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: var(--r-full);
  background: var(--danger);
  transition: width var(--t) var(--ease), background var(--t) var(--ease);
}
.pw-meter[data-level="2"] > span { background: var(--warn); }
.pw-meter[data-level="3"] > span { background: var(--blue); }
.pw-meter[data-level="4"] > span { background: var(--brand); }

/* ---------- 7. Surfaces ----------------------------------------------- */

.card {
  position: relative;
  background: var(--surface);
  background-image: var(--grad-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  transition: transform var(--t) var(--ease),
              border-color var(--t) var(--ease),
              box-shadow var(--t) var(--ease);
}
.card-hover:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.panel {
  background: var(--surface);
  background-image: var(--grad-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: clamp(1.25rem, 1rem + 1.4vw, 2rem);
}

/* The QR SVG is injected by assets/js/payment-qr.js, so the frame lives here.
   The white plate keeps the code scannable on the dark surface. */
.qr-code {
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  margin: 0.6rem 0;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.qr-code svg { display: block; width: 168px; height: auto; max-width: 100%; }
.qr-code:empty { display: none; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}

.kpi-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.kpi {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  background-image: var(--grad-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem 1.15rem;
}
.kpi::after {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 3px; height: 100%;
  background: var(--grad-brand);
  opacity: 0.75;
}
.kpi h3 {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-value {
  margin: 0;
  font-size: clamp(1.35rem, 1.2rem + 0.6vw, 1.7rem);
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi .mono { font-size: 0.78rem; }

.badge-ok { color: var(--brand); }
.badge-no { color: var(--danger); }

/* Transient states driven by app.js: the gas KPI pulses on debit, and a
   settled selection card fades itself out once it has been consumed. */
.kpi.is-updated {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand-soft), 0 0 34px -10px var(--brand);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.card.is-settled {
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 400ms var(--ease), transform 400ms var(--ease);
  pointer-events: none;
}

/* ---------- 8. Tables -------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.table-wrap table { margin-top: 0; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-weight: 650;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--surface-2);
  position: sticky;
  top: 0;
}
tbody tr { transition: background var(--t-fast) var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td .mono { font-size: 0.8rem; }

/* ---------- 8b. Pagination ---------------------------------------------- */

/* Sits outside .table-wrap on purpose: `th` is sticky inside that container, so
   a pager rendered within it would scroll away with the header. */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2, 0.75rem);
  margin-top: var(--sp-3, 1rem);
  padding-top: var(--sp-3, 1rem);
  border-top: 1px solid var(--border);
}
.pagination-count {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pagination-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
/* The current page is a span, not a link: a link to the page you are already on
   invites a pointless reload and reads as "unvisited" to assistive tech. */
.pagination-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--brand);
  border-radius: var(--r-md, 0.5rem);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pagination-gap { padding: 0 0.2rem; color: var(--muted); }
/* Disabled edges reuse the button outline so the bar does not change height
   when a page becomes unavailable. */
.pagination [aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- 9. Badges & pills ------------------------------------------ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.7rem;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}
.pill-brand { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.pill-blue  { background: var(--blue-soft);  border-color: transparent; color: var(--blue); }
.pill-violet{ background: var(--violet-soft);border-color: transparent; color: var(--violet); }
.pill-warn  { background: var(--warn-soft);  border-color: transparent; color: var(--warn); }
.pill-danger{ background: var(--danger-soft);border-color: transparent; color: var(--danger); }

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.dot-live { background: var(--danger); animation: pulse-dot 1.6s var(--ease) infinite; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
  50% { opacity: 0.65; box-shadow: 0 0 0 5px transparent; }
}

/* ---------- 10. App shell ---------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--topbar-h);
  padding: 0.75rem clamp(1rem, 0.6rem + 2vw, 2rem);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--t) var(--ease), background var(--t) var(--ease);
}
.topbar.is-scrolled { box-shadow: var(--shadow-md); }
.topbar a { color: var(--muted); text-decoration: none; }
.topbar a:hover { color: var(--text); text-decoration: none; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text) !important;
  font-size: 1.02rem;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--grad-brand);
  color: #04121d;
  font-size: 0.95rem;
  font-weight: 900;
  box-shadow: 0 6px 18px -8px var(--brand);
  flex: none;
}
.brand small {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  line-height: 1;
}

.nav { display: flex; align-items: center; gap: 0.35rem; }
.nav-links { display: flex; align-items: center; gap: 0.2rem; }
.nav-links a {
  padding: 0.5rem 0.8rem;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-weight: 550;
  color: var(--muted);
}
.nav-links a:hover, .nav-links a.is-active {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

/* Theme toggle: sun/moon swap driven by the [data-theme] on <html> */
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* Mobile drawer */
.nav-toggle { display: none; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    position: fixed;
    inset: var(--topbar-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    padding: 1rem clamp(1rem, 0.6rem + 2vw, 2rem) 1.5rem;
    background: var(--surface-solid);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateY(-130%);
    visibility: hidden;
    transition: transform var(--t) var(--ease), visibility var(--t) var(--ease);
  }
  .nav-links.is-open { transform: translateY(0); visibility: visible; }
  .nav-links a { padding: 0.75rem 0.9rem; font-size: 1rem; }
  .nav-links .btn { margin-top: 0.5rem; }
}

body.nav-open { overflow: hidden; }

/* ---------- 11. Auth pages -------------------------------------------- */

.auth-shell {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
}

.auth-aside {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(1.5rem, 1rem + 2vw, 2.75rem);
  background: var(--bg-grad);
  border-right: 1px solid var(--border);
}
.auth-aside::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% -20%;
  height: 60%;
  background: radial-gradient(closest-side, var(--brand-soft), transparent);
  pointer-events: none;
}
.auth-aside > * { position: relative; z-index: 1; }

.auth-quote {
  font-size: clamp(1.35rem, 1rem + 1.6vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  max-width: 20ch;
}
.auth-points { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 1.75rem; }
.auth-point { display: flex; gap: 0.75rem; align-items: flex-start; }
.auth-point b { display: block; font-size: 0.92rem; }
.auth-point span { font-size: 0.85rem; color: var(--muted); }
.auth-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 800;
}

.auth-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(1.5rem, 1rem + 3vw, 3rem);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: clamp(1.5rem, 1.2rem + 1.6vw, 2.25rem);
  background: var(--surface);
  background-image: var(--grad-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { margin: 0 0 0.35rem; font-size: 1.55rem; }
.auth-card .hint { margin-bottom: 0.5rem; }
.auth-card > p:last-child { margin-top: 1.25rem; font-size: 0.9rem; }

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  padding: 0.25rem;
  margin: 0.25rem 0 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.auth-switch label { margin: 0; text-align: center; cursor: pointer; }
.auth-switch input { position: absolute; opacity: 0; pointer-events: none; }
.auth-switch span {
  display: block;
  padding: 0.5rem;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  transition: all var(--t) var(--ease);
}
.auth-switch input:checked + span {
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: var(--shadow-sm);
}
.auth-switch input:focus-visible + span { box-shadow: var(--ring); }

/* ---------- Pick selector (Pro form) -----------------------------------
   Same idea as .auth-switch but three outcomes and the live price of each.
   The pro picks an outcome; the price of that outcome is what multiplies into
   the combined odds, so the selector has to show them side by side. ------- */

.pick-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  padding: 0.25rem;
  margin: 0.25rem 0 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.pick-switch label { margin: 0; text-align: center; cursor: pointer; }
.pick-switch input { position: absolute; opacity: 0; pointer-events: none; }
.pick-switch span {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.45rem 0.3rem;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  transition: all var(--t) var(--ease);
}
.pick-switch em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.85;
}
.pick-switch input:checked + span {
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: var(--shadow-sm);
}
.pick-switch input:focus-visible + span { box-shadow: var(--ring); }
/* An outcome with no published price cannot be picked. */
.pick-switch input:disabled + span {
  opacity: 0.4;
  cursor: not-allowed;
  text-decoration: line-through;
}
/* Admin result selector carries a fourth outcome: the match being abandoned. */
.pick-switch.is-four { grid-template-columns: repeat(4, 1fr); }

.combined {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.9rem;
  margin-top: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.combined output { font-size: 1.15rem; font-weight: 700; color: var(--brand); }

.pick-line { display: block; font-size: 0.85rem; }
.pick-line b { font-weight: 700; }

.result-form { min-width: 190px; }
.result-form .pick-switch { margin-bottom: 0.5rem; }

.alert {
  display: flex;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--r-md);
  font-size: 0.87rem;
  border: 1px solid transparent;
  margin-bottom: 0.75rem;
}
.alert-ok { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-soft); }
.alert-err { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-soft); }
.alert ul { padding-left: 1.1rem; margin: 0; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

/* ---------- 12. Footer -------------------------------------------------
   Part of the shared shell: View::footer() renders it on the landing page,
   the auth pages and every dashboard, so it belongs here and not in
   landing.css. --------------------------------------------------------- */

.site-footer {
  padding-block: clamp(2.5rem, 2rem + 2vw, 4rem) 2rem;
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(auto-fit, minmax(150px, 1fr));
  gap: 2rem;
  margin-bottom: 2.5rem;
}
.footer-about p {
  margin-top: 1rem;
  max-width: 38ch;
  font-size: 0.86rem;
  color: var(--muted);
}
.footer-col h4 {
  margin-bottom: 0.85rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.footer-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.footer-col a { font-size: 0.88rem; color: var(--muted); }
.footer-col a:hover { color: var(--brand); }

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--faint);
}
.footer-legal { display: flex; flex-wrap: wrap; gap: 1.1rem; }

@media (max-width: 640px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-about { grid-column: 1 / -1; }
}

/* ---------- 13. Toasts ------------------------------------------------- */
.toast-stack {
  position: fixed;
  right: clamp(0.75rem, 2vw, 1.5rem);
  bottom: clamp(0.75rem, 2vw, 1.5rem);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: min(380px, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 1rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  pointer-events: auto;
  animation: toast-in var(--t) var(--ease);
}
.toast.is-out { animation: toast-out var(--t) var(--ease) forwards; }
.toast-ok { border-left: 3px solid var(--brand); }
.toast-err { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--blue); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}

/* Withdrawal panel (professional dashboard). A <details> is used rather than a
   modal so the form works with no JavaScript at all — only the submit guard
   and the confirm step come from app.js. */
.withdraw { position: relative; }
.withdraw > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.withdraw > summary::-webkit-details-marker { display: none; }
.withdraw-form {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 30;
  width: 300px;
  padding: 1rem;
  text-align: left;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.withdraw-form label { margin-top: 0.6rem; }
.withdraw-form .field-hint { margin-top: 0.25rem; }

@media (max-width: 720px) {
  .withdraw-form { position: static; width: 100%; margin-top: 0.75rem; }
}

/* ---------- 14. Motion & utilities ------------------------------------- */
/* Spacing utilities. The CSP forbids inline `style=""` attributes, so anything
   that used to be a one-off inline style is a class here instead. */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Scroll reveal.
   The hidden state is gated behind `html.js`, which site.js sets as its very
   first action. Without JS the class is absent and every section renders
   normally — content must never depend on an animation to become visible.
   site.js also force-reveals anything left hidden after 3.5s as a last resort. */
.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 700ms var(--ease), transform 700ms var(--ease);
  will-change: opacity, transform;
}
.js .reveal.is-in { opacity: 1; transform: none; }

.divider { height: 1px; background: var(--border); border: 0; }

/* ---------- 15. Annotations ------------------------------------------- */
/* Commentaires de lecture : un encadré de texte, pas une statistique de plus.
   Le ton porte le sens (ce qui est rassurant, ce qui doit alerter, ce qui est
   neutre), la couleur ne le porte jamais seule — chaque ligne garde un texte
   explicite, pour rester lisible sans distinguer les teintes. */
.annotations {
  display: grid;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.annotations-title {
  margin: 0 0 0.15rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.annotations ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.45rem; }
.annotations li {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.86rem;
  line-height: 1.6;
  color: inherit;
}
.annotations li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
}
/* Le ton est porte par chaque ligne, pas par le bloc : un encadre peut
   contenir un avis rassurant et une mise en garde cote a cote. */
.annotations li.is-ok::before { background: var(--brand); }
.annotations li.is-warn::before { background: var(--warn); }
.annotations li.is-muted::before { background: var(--border); }
.annotations li.is-muted { opacity: 0.75; }

/* Liste de contrôle de validation comptable : une ligne = un contrôle, et
   l'état est rendu par une pastille ET par le texte, jamais par la couleur
   seule. Un comptable valide un montant, il ne valide pas une pastille. */
.checks { display: grid; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.checks li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.86rem;
  line-height: 1.5;
}
.checks .check-mark {
  flex: none;
  min-width: 6.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.checks .is-pass .check-mark { color: var(--brand); }
.checks .is-fail .check-mark { color: var(--danger); }
.checks .is-fail { color: var(--danger); }

/* Référence courte et copiable (identifiant de combinaison, code de reçu). */
.ref {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  white-space: nowrap;
}

/* Montant signé : un crédit et un débit ne doivent pas se ressembler. */
.amount-in { color: var(--brand); font-weight: 700; }
.amount-out { color: var(--danger); font-weight: 700; }

/* Panier du subscriber. Chaque ligne est une combinaison indépendante : la
   retirer est un geste explicite, parce que l'abonné doit voir ce qu'il a
   déjà engagé en gaz avant de valider. */
.basket-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.basket-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 0.88rem;
}
.basket-remove {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--danger);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}
.basket-remove:hover { background: var(--danger-soft); }
.basket-remove:focus-visible { box-shadow: var(--ring); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

@media print {
  .topbar, .toast-stack, .btn, .nav-toggle { display: none !important; }
  body { background: #fff; color: #000; }
}
