/* ==========================================================================
   Consommation v2 — même identité que le thème Keycloak « labachot »
   ========================================================================== */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/manrope.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/fraunces.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;

  --ocean-950: #061828;
  --ocean-900: #0a2236;
  --ocean-800: #0f3350;
  --sky-300: #8fc1ea;
  --sand-200: #ecdcbe;

  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --input-bg: #f5f8fb;
  --input-bg-hover: #eef3f8;
  --text: #0f1e2c;
  --text-muted: #5a6b7c;
  --text-faint: #8796a5;
  --border: #dde5ec;
  --border-strong: #b5c4d3;
  --primary: #1b65a0;
  --primary-hover: #144f7e;
  --primary-text: #ffffff;
  --primary-soft: #eaf2f9;
  --primary-shadow: rgba(27, 101, 160, 0.3);
  --ring: rgba(27, 101, 160, 0.22);
  --hover-bg: #f0f5fa;

  --danger: #c0392b;
  --danger-bg: #fdf1ef;
  --danger-border: #f3c7c1;
  --success: #1e7a4c;
  --success-bg: #eef8f2;
  --success-border: #bfe3cf;
  --warning: #9a6200;
  --warning-bg: #fdf6e7;
  --warning-border: #f0d9a8;
  --info: #1b65a0;
  --info-bg: #eef5fb;
  --info-border: #c5dcef;

  /* Séries de graphiques (validées daltonisme / contraste) */
  --series-1: #1b65a0;
  --series-2: #b0731a;
  --grid: #e8eef3;

  --radius: 12px;
  --radius-card: 20px;
  --radius-lg: 28px;
  --control-h: 48px;
  --shadow: 0 1px 2px rgba(15, 30, 44, 0.04), 0 8px 24px rgba(15, 30, 44, 0.06);
  --shadow-lg: 0 24px 64px rgba(6, 24, 40, 0.24);
  --topbar-h: 64px;
  --bottombar-h: 68px;
}

:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #08131e;
    --surface: #0d1b29;
    --surface-2: #102031;
    --input-bg: #102233;
    --input-bg-hover: #142a3e;
    --text: #e7eef5;
    --text-muted: #94a6b8;
    --text-faint: #6c8196;
    --border: #1d3245;
    --border-strong: #33506a;
    --primary: #5eaee8;
    --primary-hover: #84c3f0;
    --primary-text: #04131f;
    --primary-soft: #11293d;
    --primary-shadow: rgba(94, 174, 232, 0.2);
    --ring: rgba(94, 174, 232, 0.28);
    --hover-bg: #132739;
    --danger: #f2877a; --danger-bg: #2a1614; --danger-border: #5a2b25;
    --success: #6fd19c; --success-bg: #10251b; --success-border: #23543b;
    --warning: #f0c060; --warning-bg: #2a2110; --warning-border: #57441c;
    --info: #84c3f0; --info-bg: #0f2233; --info-border: #1f4563;
    --series-1: #4a9ad6;
    --series-2: #b8801f;
    --grid: #172a3b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}
:root[data-theme="dark"] {
  --bg: #08131e;
  --surface: #0d1b29;
  --surface-2: #102031;
  --input-bg: #102233;
  --input-bg-hover: #142a3e;
  --text: #e7eef5;
  --text-muted: #94a6b8;
  --text-faint: #6c8196;
  --border: #1d3245;
  --border-strong: #33506a;
  --primary: #5eaee8;
  --primary-hover: #84c3f0;
  --primary-text: #04131f;
  --primary-soft: #11293d;
  --primary-shadow: rgba(94, 174, 232, 0.2);
  --ring: rgba(94, 174, 232, 0.28);
  --hover-bg: #132739;
  --danger: #f2877a; --danger-bg: #2a1614; --danger-border: #5a2b25;
  --success: #6fd19c; --success-bg: #10251b; --success-border: #23543b;
  --warning: #f0c060; --warning-bg: #2a2110; --warning-border: #57441c;
  --info: #84c3f0; --info-bg: #0f2233; --info-border: #1f4563;
  --series-1: #4a9ad6;
  --series-2: #b8801f;
  --grid: #172a3b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* --- Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1, h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; }
h3 { font-size: 0.95rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i--sm { width: 16px; height: 16px; }

/* --- Boutons ---------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 0.92rem; white-space: nowrap;
  cursor: pointer; text-decoration: none !important;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.btn:hover { background: var(--hover-bg); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); box-shadow: 0 8px 20px -6px var(--primary-shadow); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--hover-bg); border-color: transparent; }
.btn--danger { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.btn--danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn--lg { min-height: var(--control-h); padding: 0 22px; font-size: 1rem; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 0.85rem; border-radius: 10px; }
.btn--icon { width: 40px; min-height: 40px; padding: 0; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* --- Barre supérieure ------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--ocean-900) 94%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  backdrop-filter: saturate(140%) blur(12px);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff !important; text-decoration: none !important; }
.brand__mark { width: 34px; height: 34px; border-radius: 10px; flex: none; }
.brand__name { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
.brand__sub { display: block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--sand-200); line-height: 1; margin-top: 3px; }

.nav { display: flex; gap: 2px; margin-left: 12px; }
.nav a {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 14px; border-radius: 10px;
  color: rgba(255, 255, 255, 0.72); font-weight: 600; font-size: 0.9rem;
  text-decoration: none;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.nav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, 0.14); }

.topbar__spacer { flex: 1; }

.vehicle-switch {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 6px 0 12px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
}
.vehicle-switch select {
  appearance: none; -webkit-appearance: none;
  border: 0; background: transparent; color: #fff; font-weight: 600; font-size: 0.9rem;
  padding: 0 22px 0 0; height: 38px; max-width: 220px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 2px center; background-size: 16px;
}
.vehicle-switch select option { color: #0f1e2c; }

.avatar-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: linear-gradient(135deg, #1b65a0, #0f3350);
  color: #fff; font-weight: 700; font-size: 0.85rem; cursor: pointer;
}

.menu {
  position: absolute; right: 16px; top: calc(var(--topbar-h) - 6px); z-index: 40;
  min-width: 240px; padding: 8px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.menu__head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu__head strong { display: block; }
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: 10px; background: none;
  color: var(--text); font-weight: 500; text-align: left; cursor: pointer; text-decoration: none;
}
.menu a:hover, .menu button:hover { background: var(--hover-bg); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* --- Barre inférieure (mobile) --------------------------------------------- */

.bottombar { display: none; }

@media (max-width: 860px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .nav { display: none; }
  .brand__text { display: none; }
  .topbar__spacer { display: none; }
  .vehicle-switch { flex: 1; min-width: 0; justify-content: flex-start; }
  .vehicle-switch select { max-width: none; width: 100%; }
  .bottombar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    height: calc(var(--bottombar-h) + env(safe-area-inset-bottom));
    padding: 0 6px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    backdrop-filter: saturate(140%) blur(14px);
    border-top: 1px solid var(--border);
  }
  .bottombar a {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 8px 0; color: var(--text-faint); font-size: 0.7rem; font-weight: 600; text-decoration: none;
  }
  .bottombar a[aria-current="page"] { color: var(--primary); }
  .bottombar .fab {
    justify-self: center;
    display: grid; place-items: center;
    width: 56px; height: 56px; margin-top: -22px; border-radius: 18px;
    background: var(--primary); color: var(--primary-text);
    box-shadow: 0 10px 24px -6px var(--primary-shadow), 0 0 0 5px var(--bg);
    border: 0; cursor: pointer;
  }
  .bottombar .fab svg { width: 26px; height: 26px; stroke-width: 2.2; }
}

/* --- Mise en page ----------------------------------------------------------- */

.page {
  max-width: 1200px; margin: 0 auto;
  padding: 28px 24px 64px;
  animation: rise .35s cubic-bezier(.2,.7,.2,1) both;
}
@media (max-width: 860px) {
  .page { padding: 16px 16px calc(var(--bottombar-h) + 32px + env(safe-area-inset-bottom)); }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page, .hero__media { animation: none !important; } }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 20px; }
.page-head h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); }
.page-head p { margin-top: 4px; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.eyebrow { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-muted); }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .grid--3, .grid--main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .grid--2 { grid-template-columns: minmax(0, 1fr); } }
.stack { display: grid; gap: 16px; align-content: start; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card__head h2 { font-size: 1.15rem; }
.card__head .sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; font-family: var(--font); letter-spacing: 0; }
.card--flush { padding: 0; overflow: hidden; }
.card--flush .card__head { padding: 18px 20px 0; }

/* --- Hero ------------------------------------------------------------------- */

.hero {
  position: relative; isolation: isolate; overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  min-height: 220px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 20px;
  color: #fff;
  background:
    radial-gradient(120% 140% at 85% 0%, rgba(143, 193, 234, 0.35) 0%, rgba(143, 193, 234, 0) 55%),
    linear-gradient(135deg, var(--ocean-800) 0%, var(--ocean-950) 100%);
  margin-bottom: 20px;
}
.hero__media {
  position: absolute; inset: 0; z-index: -2;
  background-image: url("../img/bg.webp");
  background-size: cover; background-position: 58% 60%;
  animation: drift 40s ease-in-out infinite alternate;
}
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(90deg, rgba(6, 24, 40, 0.82) 0%, rgba(6, 24, 40, 0.45) 55%, rgba(6, 24, 40, 0.15) 100%),
    linear-gradient(0deg, rgba(6, 24, 40, 0.5) 0%, rgba(6, 24, 40, 0) 50%);
}
.hero__waves { position: absolute; right: -40px; bottom: -30px; width: 420px; opacity: 0.18; z-index: -1; pointer-events: none; }
@keyframes drift { from { transform: scale(1.02); } to { transform: scale(1.1) translate3d(-1.2%, -0.6%, 0); } }
.hero .eyebrow { color: var(--sand-200); }
.hero h1 { font-size: clamp(1.7rem, 3.4vw, 2.6rem); margin-top: 8px; text-wrap: balance; }
.hero__text { margin-top: 8px; color: rgba(255, 255, 255, 0.82); max-width: 40rem; }
.hero__row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.hero__facts { display: flex; flex-wrap: wrap; gap: 10px 28px; }
.hero__fact .v { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; line-height: 1; }
.hero__fact .v small { font-family: var(--font); font-size: 0.85rem; font-weight: 600; opacity: .8; margin-left: 3px; }
.hero__fact .l { font-size: 0.78rem; color: rgba(255, 255, 255, 0.7); margin-top: 4px; }
.hero .btn--primary { background: #fff; color: var(--ocean-900); border-color: #fff; box-shadow: 0 10px 24px -8px rgba(0,0,0,.5); }
.hero .btn--primary:hover { background: var(--sand-200); border-color: var(--sand-200); }
@media (max-width: 640px) {
  .hero { padding: 22px 20px; border-radius: 22px; min-height: 0; }
  .hero__fact .v { font-size: 1.3rem; }
}

/* --- Tuiles KPI ------------------------------------------------------------- */

.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
@media (min-width: 1180px) { .kpis--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 16px 18px; box-shadow: var(--shadow); min-width: 0;
}
.kpi__label { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.kpi__label svg { color: var(--primary); }
.kpi__value { font-family: var(--font-display); font-size: 1.85rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi__value small { font-family: var(--font); font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-left: 4px; letter-spacing: 0; }
.kpi__foot { margin-top: 6px; font-size: 0.8rem; color: var(--text-muted); }
@media (max-width: 520px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi__value { font-size: 1.45rem; }
}

.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.delta--good { color: var(--success); }
.delta--bad { color: var(--danger); }

/* --- Badges / pastilles ---------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted);
}
.badge--info { background: var(--info-bg); border-color: var(--info-border); color: var(--info); }
.badge--warn { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.badge--danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.badge--good { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }

/* --- Listes ----------------------------------------------------------------- */

.list { display: grid; }
.list-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 12px 20px; border-top: 1px solid var(--border);
  color: inherit; text-decoration: none !important; cursor: pointer;
  background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; width: 100%;
}
.list-item:first-child { border-top: 0; }
.list-item:hover { background: var(--hover-bg); }
.list-item__date {
  display: grid; place-items: center; width: 48px; height: 52px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary); line-height: 1.05; text-align: center;
}
.list-item__date b { font-size: 1.15rem; font-weight: 800; }
.list-item__date span { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.list-item__title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item__meta { font-size: 0.82rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.list-item__end { text-align: right; }
.list-item__end b { display: block; font-variant-numeric: tabular-nums; }
.list-item__end span { font-size: 0.8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.list-item .badges { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.group-label {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 20px; font-size: 0.8rem; font-weight: 700; color: var(--text-muted);
  background: var(--surface-2); border-top: 1px solid var(--border);
}

.empty { padding: 36px 20px; text-align: center; color: var(--text-muted); }
.empty h3 { color: var(--text); font-size: 1.05rem; margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

/* --- Tableaux --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th, .table td { padding: 10px 14px; border-top: 1px solid var(--border); text-align: left; white-space: nowrap; }
.table thead th { border-top: 0; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface-2); }
.table td.r, .table th.r { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: var(--hover-bg); }
.table tr.clickable { cursor: pointer; }
.table tfoot td { font-weight: 700; background: var(--surface-2); }

.bar-cell { display: flex; align-items: center; gap: 10px; }
.minibar { flex: 1; min-width: 60px; height: 6px; border-radius: 4px; background: var(--grid); overflow: hidden; }
.minibar i { display: block; height: 100%; border-radius: 4px; background: var(--series-1); }

/* --- Insights ---------------------------------------------------------------- */

.insights { display: grid; gap: 10px; }
.insight { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.insight__icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--info-bg); color: var(--info); }
.insight--warn .insight__icon { background: var(--warning-bg); color: var(--warning); }
.insight--good .insight__icon { background: var(--success-bg); color: var(--success); }
.insight--danger .insight__icon { background: var(--danger-bg); color: var(--danger); }
.insight p { font-size: 0.88rem; }
.insight strong { font-weight: 700; }

/* --- Graphiques -------------------------------------------------------------- */

.chart { position: relative; height: 260px; }
.chart--sm { height: 170px; }
.chart--lg { height: 320px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.8rem; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; background: var(--series-1); }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--series-2) 0 5px, transparent 5px 8px); }

/* --- Filtres / segmented ---------------------------------------------------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.segmented { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); gap: 2px; overflow-x: auto; max-width: 100%; }
.segmented button { border: 0; background: none; padding: 7px 12px; border-radius: 9px; font-weight: 600; font-size: 0.85rem; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.segmented button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); }
.search { position: relative; flex: 1 1 220px; max-width: 360px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.search input { padding-left: 38px !important; }

/* --- Formulaires ------------------------------------------------------------ */

.form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 520px) { .form-row--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-row--3 > :last-child:nth-child(odd) { grid-column: 1 / -1; } }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .field__label { font-size: 0.84rem; font-weight: 600; }
.field__hint { font-size: 0.78rem; color: var(--text-muted); }
.field__hint button { border: 0; background: none; padding: 0; color: var(--primary); font-weight: 700; cursor: pointer; font-size: inherit; }
.input-wrap { position: relative; }
.input-wrap .unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 0.85rem; font-weight: 600; pointer-events: none; }
.input-wrap input { padding-right: 46px; }
.input, .field input:not([type="checkbox"]), .field select, .field textarea {
  width: 100%; min-height: var(--control-h);
  padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--input-bg); color: var(--text); font-size: 1rem;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.field textarea { padding: 12px 14px; min-height: 84px; resize: vertical; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { background: var(--input-bg-hover); border-color: var(--border-strong); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.field input.computed { border-style: dashed; }
.field input[readonly] { background: var(--hover-bg); }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(18px); }

.preview {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  padding: 12px; border-radius: 14px; background: var(--primary-soft);
}
.preview div { text-align: center; }
.preview b { display: block; font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.preview span { font-size: 0.74rem; color: var(--text-muted); font-weight: 600; }

.alert { padding: 12px 14px; border-radius: 12px; font-size: 0.88rem; border: 1px solid var(--info-border); background: var(--info-bg); color: var(--text); }
.alert--warn { border-color: var(--warning-border); background: var(--warning-bg); }
.alert--danger { border-color: var(--danger-border); background: var(--danger-bg); }

/* --- Modale (bottom sheet sur mobile) -------------------------------------- */

dialog.modal {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 1px solid var(--border); border-radius: 24px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.modal[open] { display: flex; flex-direction: column; animation: pop .22s cubic-bezier(.2,.7,.2,1); }
dialog.modal::backdrop { background: rgba(6, 24, 40, 0.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 8px; }
.modal__head h2 { font-size: 1.45rem; }
.modal__body { padding: 12px 22px 20px; overflow-y: auto; }
.modal__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.modal__foot .left { margin-right: auto; }
@media (max-width: 640px) {
  dialog.modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 24px 24px 0 0; max-height: 94dvh; border-bottom: 0; }
  dialog.modal[open] { animation: sheet .28s cubic-bezier(.2,.7,.2,1); }
  .modal__foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .modal__foot .btn { flex: 1; }
  .modal__foot .left { flex: 0 0 auto; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

/* --- Toasts ----------------------------------------------------------------- */

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
@media (max-width: 860px) { .toasts { bottom: calc(var(--bottombar-h) + 16px + env(safe-area-inset-bottom)); } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; background: var(--ocean-900); color: #fff; box-shadow: var(--shadow-lg); font-size: 0.9rem; animation: pop .2s ease; }
.toast--error { background: #7d2018; }
.toast button { margin-left: auto; border: 0; background: rgba(255,255,255,.14); color: #fff; padding: 6px 10px; border-radius: 8px; font-weight: 700; cursor: pointer; }

/* --- Écran de connexion (comme le SSO) -------------------------------------- */

.landing {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(400px, 560px);
  min-height: 100vh; min-height: 100dvh; background: var(--surface);
}
.landing .hero { margin: 16px 0 16px 16px; min-height: 0; padding: 36px 44px 44px; height: calc(100dvh - 32px); position: sticky; top: 16px; }
.landing .hero::after {
  background:
    linear-gradient(180deg, rgba(6, 24, 40, 0.42) 0%, rgba(6, 24, 40, 0) 26%),
    linear-gradient(0deg, rgba(6, 24, 40, 0.86) 0%, rgba(6, 24, 40, 0.5) 30%, rgba(6, 24, 40, 0) 58%);
}
.landing .hero h1 { font-size: clamp(2rem, 3.1vw, 3.1rem); line-height: 1.08; max-width: 34rem; }
.landing .hero__text { font-size: 1.02rem; max-width: 30rem; }
.landing__side { display: flex; flex-direction: column; justify-content: center; padding: 40px 56px; }
.landing__card { width: 100%; max-width: 400px; margin: 0 auto; animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }
.landing__card h2 { font-size: 2.1rem; }
.landing__card p { margin: 10px 0 28px; color: var(--text-muted); }
.landing__features { margin: 28px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.landing__features li { display: flex; gap: 12px; align-items: flex-start; font-size: 0.9rem; color: var(--text-muted); }
.landing__features svg { color: var(--primary); margin-top: 1px; }
.landing__foot { margin-top: 36px; font-size: 0.8rem; color: var(--text-faint); display: flex; align-items: center; gap: 6px; }
@media (max-width: 900px) {
  .landing { grid-template-columns: minmax(0, 1fr); }
  .landing .hero { position: relative; top: 0; height: auto; min-height: 300px; margin: 12px 12px 0; padding: 24px; }
  .landing__side { padding: 28px 20px 40px; }
}

.auth-error { display: grid; place-items: center; padding: 24px; }
.auth-error__card { max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 28px; box-shadow: var(--shadow); }
.auth-error__card h1 { font-size: 1.8rem; margin-bottom: 10px; }
.auth-error__card p { color: var(--text-muted); margin-bottom: 20px; }

/* --- Divers ------------------------------------------------------------------ */

.loading { display: grid; place-items: center; min-height: 60vh; color: var(--text-muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.vehicle-card { display: grid; gap: 14px; }
.vehicle-card__head { display: flex; align-items: center; gap: 14px; }
.vehicle-card__icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: #fff; background: var(--ocean-800); flex: none; }
.vehicle-card__icon svg { width: 24px; height: 24px; }
.vehicle-card h3 { font-size: 1.05rem; }
.plate { display: inline-block; padding: 1px 8px; border-radius: 6px; border: 1.5px solid var(--border-strong); font-weight: 800; font-size: 0.78rem; letter-spacing: 0.06em; background: var(--surface-2); }
.specs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.specs div { padding: 10px; border-radius: 12px; background: var(--surface-2); }
.specs b { display: block; font-variant-numeric: tabular-nums; }
.specs span { font-size: 0.75rem; color: var(--text-muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.due { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.due:first-child { border-top: 0; padding-top: 0; }
.due__bar { grid-column: 1 / -1; height: 6px; border-radius: 4px; background: var(--grid); overflow: hidden; }
.due__bar i { display: block; height: 100%; border-radius: 4px; background: var(--success); }
.due__bar i.warn { background: var(--warning); }
.due__bar i.danger { background: var(--danger); }

.only-mobile { display: none; }
@media (max-width: 760px) {
  .only-desktop, .hide-mobile { display: none !important; }
  .only-mobile { display: grid; }
}

.footer-note { margin-top: 28px; font-size: 0.78rem; color: var(--text-faint); text-align: center; }

/* --- Stations ------------------------------------------------------------------ */

.st-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.st-card { display: grid; gap: 12px; cursor: pointer; transition: border-color .15s ease, transform .15s ease; text-align: left; font: inherit; color: inherit; }
.st-card:hover { border-color: var(--border-strong); }
.st-card__head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.st-logo {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: 0.82rem; letter-spacing: -0.02em;
}
.st-card h3 { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-card .sub { font-size: 0.82rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star-btn { border: 0; background: none; padding: 4px; cursor: pointer; color: var(--text-faint); line-height: 0; border-radius: 8px; }
.star-btn:hover { background: var(--hover-bg); }
.star-btn[aria-pressed="true"] { color: #d99a1e; }
.star-btn[aria-pressed="true"] svg { fill: currentColor; }
.stars { display: inline-flex; gap: 1px; color: #d99a1e; }
.stars svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.stars .off { color: var(--border-strong); }
.official {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border);
}
.official b { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.official span { font-size: 0.78rem; color: var(--text-muted); }
.official--none { display: block; color: var(--text-muted); font-size: 0.84rem; }
.official--none svg { vertical-align: -3px; margin-right: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 0.82rem; font-weight: 600; cursor: pointer; user-select: none; }
.chip input { display: none; }
.chip:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip--static { cursor: default; background: var(--surface-2); }

.rating-input { display: inline-flex; gap: 2px; }
.rating-input button { border: 0; background: none; padding: 2px; cursor: pointer; color: var(--border-strong); line-height: 0; }
.rating-input button.on { color: #d99a1e; }
.rating-input svg { width: 26px; height: 26px; fill: currentColor; stroke: none; }

/* Carte */
.near { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .near { grid-template-columns: minmax(0, 1fr); } }
.map { height: 560px; border-radius: var(--radius-card); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); position: relative; z-index: 0; }
.map--sm { height: 200px; }
@media (max-width: 960px) { .map { height: 52vh; min-height: 300px; } .map--sm { height: 180px; min-height: 0; } }
.near__list { max-height: 560px; overflow-y: auto; }
@media (max-width: 960px) { .near__list { max-height: none; } }
.map-overlay { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 500; }
.leaflet-container { font-family: var(--font); background: var(--surface-2); }
.leaflet-control-attribution { font-size: 10px; }
.tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.85) saturate(0.6); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.leaflet-popup-content-wrapper { border-radius: 14px; }
.leaflet-popup-content { margin: 12px 14px; font-size: 0.86rem; line-height: 1.4; }
.leaflet-bar a { background: var(--surface); color: var(--text); border-color: var(--border); }
.leaflet-bar a:hover { background: var(--hover-bg); }
:root[data-theme="dark"] .leaflet-control-attribution { background: rgba(13,27,41,.8); color: var(--text-muted); }

.pin-wrap { background: none; border: 0; }
.pin {
  position: relative; display: inline-block; transform: translate(-50%, -100%);
  padding: 3px 7px; border-radius: 8px; white-space: nowrap;
  font: 700 12px/1.2 var(--font); font-variant-numeric: tabular-nums;
  background: var(--surface); color: var(--text); border: 1.5px solid var(--border-strong);
  box-shadow: 0 2px 6px rgba(6, 24, 40, 0.25);
}
.pin::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 8px; height: 8px; background: inherit; border: inherit; border-top: 0; border-left: 0; transform: translateX(-50%) rotate(45deg); }
.pin--cheap { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.pin--mine { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring), 0 2px 6px rgba(6,24,40,.25); }
.pin--stale { opacity: .55; }
.pin--none { padding: 3px 5px; color: var(--text-faint); }
.pin--active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); z-index: 1000; }
.pin-me { width: 16px; height: 16px; border-radius: 50%; background: #2a7de1; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(42,125,225,.25); transform: translate(-50%, -50%); }

.near-item { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); cursor: pointer; }
.near-item:first-child { border-top: 0; }
.near-item:hover, .near-item.is-active { background: var(--hover-bg); }
.near-item__price { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }
.near-item__price small { display: block; font-family: var(--font); font-size: 0.7rem; color: var(--text-muted); font-weight: 600; margin-top: 4px; }
.near-item__price.stale { color: var(--text-faint); }
.near-item h4 { margin: 0; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.near-item p { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.picker { display: grid; gap: 6px; margin-top: 8px; }
.picker button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); text-align: left; cursor: pointer; font: inherit; color: inherit; }
.picker button:hover { border-color: var(--primary); }
.picker b { font-variant-numeric: tabular-nums; }
.picker small { display: block; color: var(--text-muted); font-size: 0.78rem; }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; font-size: 0.88rem; }
.kv dt { color: var(--text-muted); font-weight: 600; }
.kv dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.price-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.price-table td { padding: 6px 0; border-top: 1px solid var(--border); }
.price-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.price-table tr:first-child td { border-top: 0; }
.price-table tr.hl td { font-weight: 800; color: var(--primary); }
.section-title { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin: 18px 0 8px; }

@media (max-width: 520px) { .segmented svg { display: none; } .segmented button { padding: 7px 10px; } }
