@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap');

/* ---------- Thème ---------- */
:root {
  --accent: #dfef65;
  --on-accent: #172923; /* recalculé en JS selon la couleur d'accent choisie */
  --ink: #172923;
  --bg: #f4f6f3;
  --card: #fff;
  --muted: #78827d;
  --line: #e5e9e3;
  --side: #172923;
}
body.dark { --bg: #14221d; --card: #1d2e26; --ink: #edf3e9; --muted: #a2b2a7; --line: #34463a; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px 'DM Sans', sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; }
button, a, input, select { outline-offset: 4px; }
:focus-visible { outline: 2px solid var(--ink); }
button { cursor: pointer; border: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, .brand { font-family: Manrope, sans-serif; }
h1 { font-size: 31px; letter-spacing: -1px; margin: 0 0 8px; }
h2 { font-size: 19px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { line-height: 1.6; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.hidden { display: none !important; }
#content:focus { outline: none; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 30; background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: 8px; font-weight: 700; }
.skip:focus { top: 12px; }

/* ---------- Barre latérale ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 236px; background: var(--side); color: #d9e3db; padding: 32px 22px; display: flex; flex-direction: column; }
.brand { font-size: 26px; color: white; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.mark { background: var(--accent); color: var(--on-accent); border-radius: 11px; width: 36px; height: 36px; display: grid; place-items: center; font-size: 22px; }
.brand img { max-width: 155px; max-height: 58px; object-fit: contain; }
.site-name { font-size: 10px; letter-spacing: 1.7px; margin: 12px 0 36px; color: #9cac9f; }
.nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: #83978b; margin: 16px 12px; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav button { display: flex; gap: 13px; align-items: center; text-align: left; padding: 13px; border-radius: 9px; color: inherit; background: none; }
.nav button.active { color: var(--on-accent); background: var(--accent); font-weight: 700; }
.nav button:hover:not(.active) { background: #ffffff12; }
.nav .short { display: none; }
.nav svg, .icon svg, .button svg, .avatar svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.7; flex-shrink: 0; }
.button svg { width: 17px; height: 17px; }
.sidebar-bottom { margin-top: auto; }
.eco { background: #ffffff09; border: 1px solid #ffffff13; padding: 18px; border-radius: 12px; margin: 24px 0; font-size: 12px; }
.eco strong { display: block; color: var(--accent); font-size: 20px; margin: 10px 0; }

/* ---------- Structure ---------- */
.main { margin-left: 236px; }
.topbar { height: 82px; border-bottom: 1px solid var(--line); background: var(--card); display: flex; align-items: center; justify-content: space-between; padding: 0 38px; gap: 20px; }
.topbar .sep { margin: 0 10px; }
.topbar select { border: 0; background: var(--bg); padding: 10px; border-radius: 8px; color: var(--ink); }
.account { display: flex; gap: 12px; align-items: center; font-size: 12px; }
.account .button { white-space: nowrap; }
.avatar { height: 37px; width: 37px; flex-shrink: 0; background: #e9ede4; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #24372a; }
.workspace { max-width: 1450px; margin: auto; padding: 32px 38px; }
.title-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 26px; }
.eyebrow { text-transform: uppercase; letter-spacing: 1.8px; font-size: 10px; font-weight: 700; margin-bottom: 10px; color: var(--muted); }
.footer { color: var(--muted); font-size: 10px; display: flex; justify-content: space-between; padding: 10px 0 20px; }
.link { background: none; color: inherit; padding: 0; }
.demo { font-size: 10px; background: var(--bg); color: var(--muted); padding: 5px 8px; border-radius: 4px; }

/* ---------- Boutons ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; background: var(--ink); color: var(--card); padding: 12px 18px; border-radius: 8px; font-weight: 600; }
.button.primary { background: var(--accent); color: var(--on-accent); }
.button.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.button:disabled { opacity: .6; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- Accueil ---------- */
.hero { border-radius: 16px; overflow: hidden; min-height: 245px; background: var(--side); display: grid; grid-template-columns: 1.1fr 1fr; margin-bottom: 24px; color: white; }
.hero-copy { padding: 30px; position: relative; }
.hero h2 { font-size: 30px; letter-spacing: -.7px; max-width: 360px; line-height: 1.2; margin: 14px 0; }
.hero p { color: #c4d0c6; font-size: 13px; max-width: 340px; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.pill { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 11px; border-radius: 20px; padding: 6px 10px; background: #eef4e7; color: #477047; font-weight: 600; }
.hero .pill { background: #ffffff15; color: var(--accent); }
.pill.pending { background: #fff3dc; color: #9d7124; }
.pill.refused { background: #fbe6e3; color: #9b3b2e; }
/* Pièce HubLink Coin (HLC) */
.coin { width: 18px; height: 18px; margin: -3px 0; }
details p:has(> .coin-large) { display: flow-root; }
.coin-large { float: left; width: 120px; height: 120px; margin: 0 16px 8px 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 17px; margin-bottom: 28px; }
.stat, .panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.stat { padding: 20px; }
.stat-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.stat strong { display: block; font: 800 28px Manrope; margin: 12px 0 7px; letter-spacing: -1px; }
.stat small { font-size: 10px; color: var(--muted); }
.grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 22px; }
.panel { padding: 24px; margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 23px; gap: 12px; }

/* ---------- Onglets et choix ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg); border-radius: 9px; margin-bottom: 22px; }
.tabs button { padding: 11px 17px; flex: 1; background: none; border-radius: 6px; color: var(--muted); }
.tabs button.active { background: var(--card); box-shadow: 0 1px 5px #0001; color: var(--ink); font-weight: 700; }
.choice label { flex: 1; position: relative; font-weight: 400; font-size: 14px; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.choice span { display: block; text-align: center; padding: 11px 17px; border-radius: 6px; color: var(--muted); cursor: pointer; }
.choice input:checked + span { background: var(--card); box-shadow: 0 1px 5px #0001; color: var(--ink); font-weight: 700; }
.choice input:focus-visible + span { outline: 2px solid var(--ink); }

/* ---------- Formulaires ---------- */
.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
label { display: block; font-size: 12px; font-weight: 600; }
input, select { width: 100%; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 7px; padding: 12px; margin-top: 7px; }
input[type=color] { height: 45px; padding: 4px; }
input[type=checkbox] { width: auto; }
.full { grid-column: 1 / -1; }
.days { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.days label { background: var(--bg); padding: 10px; border-radius: 7px; }

/* ---------- Listes ---------- */
.ride { display: flex; align-items: center; gap: 13px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.ride:last-child { border: 0; }
.ride-info { flex: 1; min-width: 0; }
.ride-info p { margin: 4px 0; font-size: 12px; color: var(--muted); }
.ride .avatar { background: #edf0e7; width: 43px; height: 43px; }
.ride button { padding: 9px 13px; font-size: 12px; }
.activity { padding: 15px 0; border-bottom: 1px solid var(--line); display: flex; gap: 12px; }
.activity:last-child { border: 0; }
.activity p { margin: 5px 0; color: var(--muted); font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #a2b98a; margin-top: 5px; flex-shrink: 0; }
.dot.pending { background: #e2b45c; }
.banner { background: #eaf0df; border-radius: 10px; padding: 20px; margin-top: 18px; color: #243b27; }
.banner p { font-size: 12px; margin: 6px 0 0; }
.banner.top { margin: 0 0 24px; }
.banner.warn { background: #fff3dc; color: #6e4f17; }
.table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
.table th { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 14px 10px; background: var(--bg); }
.table td { padding: 18px 10px; border-bottom: 1px solid var(--line); }
details { border-bottom: 1px solid var(--line); padding: 18px 0; }
summary { cursor: pointer; font-weight: 600; }
details p { color: var(--muted); }
/* Badges CO₂ (trajets confirmés) */
.badges { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.badge-co2 { display: flex; gap: 16px; align-items: center; background: var(--side); color: #fff; border-radius: 14px; padding: 18px 20px; }
.badge-co2 .eyebrow { color: #9fb0a4; margin-bottom: 4px; }
.badge-co2 strong { display: block; font: 800 28px Manrope, sans-serif; letter-spacing: -1px; color: var(--accent); }
.badge-co2 span { font-size: 12px; color: #c4d0c6; }
.badge-co2 .badge-leaf { color: var(--on-accent); font: 800 15px Manrope, sans-serif; }
.badge-leaf { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font: 800 15px Manrope, sans-serif; flex-shrink: 0; }
/* FAQ étendue : catégories et réponses */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 20px; padding: 8px 13px; font-size: 12px; font-weight: 600; }
.chip.active { background: var(--ink); color: var(--card); border-color: var(--ink); }
.faq-cat { margin: 26px 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); }
.faq-a { color: var(--muted); line-height: 1.6; margin: 10px 0 2px; display: flow-root; }
.faq-a ul { margin: 8px 0; padding-left: 20px; }

/* ---------- Fenêtre et notifications ---------- */
.dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); padding: 28px; width: 480px; max-width: 94vw; max-height: 90vh; }
.dialog::backdrop { background: #10211bb0; backdrop-filter: blur(4px); }
.dialog h2 { margin-bottom: 18px; }
.dialog .button { margin-top: 15px; }
.close { float: right; background: var(--bg); color: var(--ink); border-radius: 50%; width: 29px; height: 29px; }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: var(--card); padding: 17px 24px; border-radius: 10px; box-shadow: 0 10px 40px #0002; z-index: 20; max-width: 90vw; }

/* ---------- Inscription et QR code ---------- */
.step { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.consent { font-weight: 400; display: flex; gap: 10px; align-items: flex-start; line-height: 1.5; }
.consent input { margin-top: 2px; flex-shrink: 0; }
.qr { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; max-width: 260px; margin: 0 auto; }
.qr svg { display: block; width: 100%; height: auto; }
.qr-url { text-align: center; word-break: break-all; }
.qr-poster .actions { justify-content: center; flex-wrap: wrap; }
.print-only { display: none; }
@media print {
  body * { visibility: hidden; }
  .qr-poster, .qr-poster * { visibility: visible; }
  .qr-poster { position: absolute; inset: 0; border: 0; text-align: center; font-size: 18px; }
  .qr { max-width: 70%; border: 0; }
  .print-only { display: block; }
  .print-hide { display: none !important; }
}

/* ---------- Mode sombre ---------- */
.dark .banner { background: #33452d; color: #e4f2d7; }
.dark .banner.warn { background: #4a3b1c; color: #f6e3bd; }
.dark .avatar { color: #1c3221; }

/* ---------- Adaptatif ---------- */
@media (min-width: 1500px) {
  .workspace { padding-top: 40px; }
  .hero { min-height: 290px; }
}
@media (max-width: 1050px) {
  .sidebar { width: 195px; padding: 26px 15px; }
  .main { margin-left: 195px; }
  .workspace { padding: 26px 24px; }
  .topbar { padding: 0 24px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .hero h2 { font-size: 25px; }
}
/* Téléphone : en-tête compact, navigation en bas d'écran, cibles tactiles de 44 px minimum. */
@media (max-width: 700px) {
  .sidebar { position: static; width: 100%; padding: calc(14px + env(safe-area-inset-top)) 16px 14px; }
  .brand { font-size: 23px; }
  .site-name, .nav-label, .eco, .sidebar-bottom { display: none; }
  .sidebar > .nav { position: fixed; inset: auto 0 0 0; z-index: 15; flex-direction: row; gap: 2px; margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: var(--side); border-top: 1px solid #ffffff13; }
  .sidebar > .nav button { flex: 1 1 0; min-width: 0; min-height: 54px; flex-direction: column; justify-content: center; gap: 4px; padding: 8px 2px; font-size: 11px; text-align: center; }
  .nav .label { display: none; }
  .nav .short { display: block; }
  .main { margin: 0; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .no-nav .main { padding-bottom: env(safe-area-inset-bottom); }
  .no-nav .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .topbar { height: auto; min-height: 64px; padding: 10px 16px; }
  .topbar > span { display: none; }
  .account { width: 100%; justify-content: flex-end; }
  .account select { flex: 1; min-width: 0; margin-top: 0; }
  .workspace { padding: 24px 16px; }
  .hero { grid-template-columns: 1fr; }
  .hero img { height: 170px; }
  .hero-copy { padding: 24px; }
  .title-row { align-items: flex-start; flex-wrap: wrap; }
  h1 { font-size: 25px; }
  .title-row > .button { font-size: 11px; padding: 10px; }
  .stats { gap: 10px; }
  .stat { padding: 15px; }
  .stat strong { font-size: 24px; }
  .fields { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .table-wrap { overflow: auto; }
  .footer { gap: 12px; }
  .ride { flex-wrap: wrap; }
  .ride .actions { width: 100%; }
  .ride .actions .button { flex: 1; }
  .button, .ride button { min-height: 44px; }
  .close { width: 40px; height: 40px; }
  input, select { font-size: 16px; } /* évite le zoom automatique d'iOS */
  .dialog { width: 100%; padding: 22px; }
  .toast { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: none; }
}
