/* ==========================================================================
   IMPACT — feuille de style globale
   Mobile-first. Aucune dépendance externe.
   ========================================================================== */

:root {
  --navy-950: #04121f;
  --navy-900: #071c33;
  --navy-800: #0b2545;
  --navy-700: #14375f;
  --navy-600: #1d4a7a;

  --blue-500: #2f80ed;
  --blue-400: #4c9dff;
  --sky-400: #4cc3ff;
  --mint-500: #17b890;
  --mint-400: #29d3a8;
  --amber-500: #f2b33d;
  --amber-400: #ffc659;
  --red-500: #e2574c;
  --red-400: #ff6f61;
  --teal-800: #0b3a3a;
  --teal-600: #127a70;

  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e3e9f2;
  --text: #0e2135;
  --text-soft: #43536b;
  --muted: #7c8aa0;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(11, 37, 69, .06), 0 2px 8px rgba(11, 37, 69, .05);
  --shadow-md: 0 6px 20px rgba(11, 37, 69, .09);
  --shadow-lg: 0 18px 44px rgba(7, 28, 51, .18);

  --nav-h: 68px;
  --topbar-h: 62px;

  --ease: cubic-bezier(.22, .61, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 800; letter-spacing: -.015em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
a { color: var(--blue-500); text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }

.muted { color: var(--muted); }
.ta-right { text-align: right; }
.ta-center { text-align: center; }
.is-readonly { background: #eef2f8; color: var(--text-soft); }

.ico { width: 22px; height: 22px; flex: none; }
.ico-sm { width: 18px; height: 18px; flex: none; }
.ico-lg { width: 34px; height: 34px; flex: none; }

/* ---------------------------------------------------------------- Marque */

.brand-mark {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(140deg, var(--blue-500), var(--sky-400));
  box-shadow: 0 6px 16px rgba(47, 128, 237, .32);
}
.brand-mark-lg { width: 56px; height: 56px; border-radius: 18px; }
.brand-mark-admin {
  background: linear-gradient(140deg, var(--teal-600), var(--mint-500));
  box-shadow: 0 6px 16px rgba(18, 122, 112, .32);
}

/* ------------------------------------------------------------- Auth page */

.auth-body { background: var(--navy-900); }

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}

.auth-brand {
  background:
    radial-gradient(120% 80% at 80% 0%, rgba(76, 195, 255, .28), transparent 60%),
    radial-gradient(90% 70% at 10% 100%, rgba(23, 184, 144, .22), transparent 60%),
    linear-gradient(160deg, var(--navy-900), var(--navy-800));
  color: #fff;
  padding: calc(2.2rem + env(safe-area-inset-top, 0px)) 1.5rem 2rem;
  display: flex;
  align-items: center;
}
.auth-brand-inner { max-width: 520px; margin: 0 auto; width: 100%; }
.auth-brand h1 {
  font-size: 1.9rem;
  margin: 1rem 0 .5rem;
  letter-spacing: .06em;
}
.auth-brand-claim { color: rgba(255, 255, 255, .78); margin-bottom: 1.4rem; }
.auth-points { display: grid; gap: .7rem; }
.auth-points li {
  display: flex; align-items: flex-start; gap: .65rem;
  color: rgba(255, 255, 255, .86);
  font-size: .92rem;
}
.auth-points .dot {
  width: 7px; height: 7px; margin-top: .5rem; flex: none;
  border-radius: 50%;
  background: var(--mint-400);
  box-shadow: 0 0 0 4px rgba(41, 211, 168, .16);
}
.auth-brand-foot {
  margin-top: 2rem;
  font-size: .76rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .40);
}

.auth-panel {
  background: var(--bg);
  padding: 1.6rem 1.25rem calc(2.4rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
}
.auth-card { width: 100%; max-width: 460px; margin: 0 auto; }
.auth-tabs {
  display: flex; gap: .35rem; padding: .3rem;
  background: #e7edf6; border-radius: 999px;
  margin-bottom: 1.4rem;
}
.auth-tab {
  flex: 1; text-align: center;
  padding: .62rem .8rem;
  border-radius: 999px;
  font-weight: 700; font-size: .9rem;
  color: var(--text-soft);
  transition: background .18s var(--ease), color .18s var(--ease);
}
.auth-tab.is-active { background: var(--surface); color: var(--navy-800); box-shadow: var(--shadow-sm); }
.auth-card h2 { font-size: 1.35rem; }
.auth-sub { color: var(--text-soft); margin: .4rem 0 1.3rem; font-size: .93rem; }
.auth-note {
  margin-top: 1.3rem; padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: .84rem;
}

/* -------------------------------------------------------------- Contrôles */

.field { display: block; margin-bottom: .95rem; }
.field-label {
  display: block; margin-bottom: .35rem;
  font-size: .82rem; font-weight: 700; color: var(--text-soft);
  letter-spacing: .01em;
}
.field-help { display: block; margin-top: .32rem; font-size: .76rem; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="number"], input[type="date"],
select, textarea {
  width: 100%;
  padding: .78rem .9rem;
  font-size: .95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(76, 157, 255, .18);
}
input[type="file"] {
  padding: .68rem .8rem;
  font-size: .88rem;
  background: var(--surface);
  border: 1px dashed #c6d3e6;
  border-radius: var(--radius-sm);
  width: 100%;
}
select {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237c8aa0' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.2rem;
}
.select-inline { max-width: 320px; }

.field-pass { position: relative; display: block; }
.field-pass input { padding-right: 3rem; }
.pass-toggle {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: none; border: 0; cursor: pointer;
  color: var(--muted); border-radius: 10px;
}
.pass-toggle:hover { background: var(--surface-2); color: var(--text-soft); }

.form-grid { display: grid; gap: .2rem; }
.form-grid-2 { grid-template-columns: 1fr; }
.form-actions {
  display: flex; flex-wrap: wrap; gap: .6rem;
  margin-top: .6rem;
}

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .78rem 1.2rem;
  font-size: .92rem; font-weight: 700;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform .12s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--blue-500), var(--navy-600));
  color: #fff;
  box-shadow: 0 8px 20px rgba(47, 128, 237, .26);
}
.btn-primary:hover { box-shadow: 0 10px 26px rgba(47, 128, 237, .34); }
.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text-soft);
}
.btn-ghost:hover { border-color: #c9d6e8; color: var(--text); }
.btn-danger { background: #fdecea; color: #b32c20; border-color: #f7cdc7; }
.btn-sm { padding: .5rem .8rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .72rem; }
.btn[disabled] { opacity: .6; cursor: progress; }

.link-btn {
  background: none; border: 0; padding: .3rem 0;
  color: var(--text-soft); font-size: .85rem; font-weight: 600;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--blue-500); }

/* --------------------------------------------------------------- Layout */

.app-body {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  min-height: 100vh;
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  padding-top: env(safe-area-inset-top, 0px);
  background: linear-gradient(150deg, var(--navy-900), var(--navy-700));
  color: #fff;
  box-shadow: 0 6px 22px rgba(7, 28, 51, .22);
}
.topbar-admin { background: linear-gradient(150deg, #0a2b33, var(--teal-600)); }
.topbar-inner {
  max-width: 1180px; margin: 0 auto;
  padding: .7rem 1rem;
  display: flex; align-items: center; gap: .8rem;
  min-height: var(--topbar-h);
}
.topbar-text { display: flex; flex-direction: column; min-width: 0; }
.topbar-title { font-weight: 800; font-size: 1rem; letter-spacing: -.01em; }
.topbar-sub {
  font-size: .76rem; color: rgba(255, 255, 255, .66);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.avatar {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .24);
  font-weight: 700; font-size: .82rem;
}
.avatar-admin { background: rgba(242, 179, 61, .22); border-color: rgba(242, 179, 61, .4); }
.topbar-logout {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 12px; color: rgba(255, 255, 255, .82);
}
.topbar-logout:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.admin-tabs {
  display: none;
  max-width: 1180px; margin: 0 auto;
  padding: 0 1rem;
  gap: .3rem;
}
.admin-tab {
  padding: .6rem .95rem .8rem;
  font-size: .88rem; font-weight: 700;
  color: rgba(255, 255, 255, .68);
  border-bottom: 3px solid transparent;
}
.admin-tab.is-active { color: #fff; border-bottom-color: var(--amber-400); }

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.1rem 1rem 1rem;
  display: grid;
  gap: 1rem;
}
.page-foot {
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center;
  padding: 1rem 0 .5rem;
}

/* ---------------------------------------------------------- Cartes / blocs */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .8rem; flex-wrap: wrap;
  margin-bottom: .9rem;
}
.card-hint { font-size: .78rem; color: var(--muted); }
.card-link { font-size: .84rem; font-weight: 700; }
.card-text { color: var(--text-soft); font-size: .9rem; }

.split { display: grid; grid-template-columns: 1fr; gap: 1rem; }

/* ------------------------------------------------------------- KPI / hero */

.hero-card {
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.2rem 1.15rem;
  color: #fff;
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(76, 195, 255, .30), transparent 58%),
    linear-gradient(140deg, var(--navy-900), var(--navy-700) 70%);
  box-shadow: var(--shadow-md);
}
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.hero-label {
  display: block; font-size: .8rem; letter-spacing: .05em;
  text-transform: uppercase; color: rgba(255, 255, 255, .66); margin-bottom: .25rem;
}
.hero-value { font-size: 2.1rem; font-weight: 800; letter-spacing: -.02em; }
.hero-badge {
  padding: .38rem .7rem;
  border-radius: 999px;
  font-size: .78rem; font-weight: 700;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .2);
  white-space: nowrap;
}
.hero-badge.is-up { background: rgba(255, 111, 97, .22); border-color: rgba(255, 111, 97, .4); }
.hero-badge.is-down { background: rgba(41, 211, 168, .2); border-color: rgba(41, 211, 168, .4); }
.hero-sub { color: rgba(255, 255, 255, .74); font-size: .86rem; margin: .5rem 0 .8rem; }
.hero-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .55rem;
  font-size: .82rem; color: rgba(255, 255, 255, .8);
}
.dot-sep { width: 4px; height: 4px; border-radius: 50%; background: rgba(255, 255, 255, .38); }

.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .95rem;
  display: flex; flex-direction: column; gap: .28rem;
  box-shadow: var(--shadow-sm);
}
.kpi-icon {
  width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center; color: #fff;
  margin-bottom: .2rem;
}
.kpi-icon-blue { background: linear-gradient(135deg, var(--blue-400), var(--blue-500)); }
.kpi-icon-green { background: linear-gradient(135deg, var(--mint-400), var(--mint-500)); }
.kpi-icon-amber { background: linear-gradient(135deg, var(--amber-400), var(--amber-500)); }
.kpi-icon-red { background: linear-gradient(135deg, var(--red-400), var(--red-500)); }
.kpi-label { font-size: .78rem; font-weight: 700; color: var(--text-soft); }
.kpi-value { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.kpi-foot { font-size: .74rem; color: var(--muted); }

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

.chart-wrap { position: relative; height: 240px; }
.chart-wrap-sm { height: 200px; }

.legend { display: grid; gap: .45rem; margin-top: .9rem; }
.legend li { display: flex; align-items: center; gap: .55rem; font-size: .85rem; }
.legend .lg-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .lg-name { flex: 1; color: var(--text-soft); }
.legend .lg-val { font-weight: 700; }

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

.rank-list, .watch-list, .evo-list { display: grid; gap: .55rem; }
.rank-item, .watch-item, .evo-item {
  display: flex; align-items: center; gap: .8rem;
  padding: .7rem .8rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.rank-index {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--navy-800); color: #fff;
  font-size: .76rem; font-weight: 700;
}
.rank-main { flex: 1; min-width: 0; }
.rank-title { font-weight: 700; font-size: .9rem; display: block; }
.rank-sub { font-size: .76rem; color: var(--muted); }
.rank-value { font-weight: 800; font-size: .92rem; white-space: nowrap; }

.watch-item { display: block; }
.watch-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.watch-metrics {
  display: flex; flex-wrap: wrap; gap: .45rem .9rem;
  margin-top: .45rem; font-size: .78rem; color: var(--text-soft);
}
.watch-metrics b { color: var(--text); font-weight: 700; }

.evo-item { justify-content: space-between; }
.evo-name { font-weight: 600; font-size: .88rem; }
.evo-delta { font-weight: 800; font-size: .88rem; }
.evo-delta.is-up { color: var(--red-500); }
.evo-delta.is-down { color: var(--mint-500); }
.evo-delta.is-flat { color: var(--muted); }

.skeleton-row {
  height: 46px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, #eef2f8, #f7f9fc, #eef2f8);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* -------------------------------------------------------- Synthèse / IA */

.summary-card {
  background:
    radial-gradient(90% 120% at 100% 0%, rgba(76, 195, 255, .16), transparent 60%),
    linear-gradient(150deg, var(--navy-900), var(--navy-700));
  color: #fff;
  border: 0;
}
.summary-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .8rem; }
.summary-badge {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .38rem .75rem; border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .2);
  font-size: .78rem; font-weight: 700;
}
.summary-date { font-size: .76rem; color: rgba(255, 255, 255, .6); }
.summary-text { font-size: .96rem; line-height: 1.65; color: rgba(255, 255, 255, .94); }
.summary-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .6rem; margin-top: 1.1rem;
  padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, .16);
}
.summary-stat { display: flex; flex-direction: column; gap: .15rem; }
.ss-value { font-size: 1.2rem; font-weight: 800; }
.ss-label { font-size: .72rem; color: rgba(255, 255, 255, .66); }

.reco-list { display: grid; gap: .8rem; }
.reco-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue-500);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  background: var(--surface-2);
}
.reco-item.is-haute { border-left-color: var(--red-500); }
.reco-item.is-moyenne { border-left-color: var(--amber-500); }
.reco-item.is-basse { border-left-color: var(--mint-500); }
.reco-top { display: flex; align-items: flex-start; gap: .6rem; justify-content: space-between; }
.reco-title { font-weight: 800; font-size: .95rem; }
.reco-detail { color: var(--text-soft); font-size: .87rem; margin-top: .4rem; }
.reco-foot {
  display: flex; flex-wrap: wrap; gap: .5rem .9rem;
  margin-top: .6rem; font-size: .78rem; color: var(--muted);
}
.reco-saving { font-weight: 800; color: var(--mint-500); }
.pill {
  padding: .2rem .55rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700;
  background: #eef2f8; color: var(--text-soft);
}
.pill-haute { background: #fdecea; color: #b32c20; }
.pill-moyenne { background: #fff5e2; color: #96660c; }
.pill-basse { background: #e6f8f2; color: #0b7a5c; }

.anomaly-list { display: grid; gap: .7rem; }
.anomaly-item {
  display: flex; gap: .8rem;
  padding: .85rem .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.anomaly-icon {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px; display: grid; place-items: center;
  background: #fdecea; color: var(--red-500);
}
.anomaly-item.is-moyenne .anomaly-icon { background: #fff5e2; color: var(--amber-500); }
.anomaly-item.is-basse .anomaly-icon { background: #eef2f8; color: var(--text-soft); }
.anomaly-title { font-weight: 700; font-size: .9rem; }
.anomaly-vehicle { font-size: .76rem; color: var(--muted); }
.anomaly-detail { font-size: .85rem; color: var(--text-soft); margin-top: .35rem; }
.anomaly-action { font-size: .8rem; color: var(--navy-700); margin-top: .4rem; font-weight: 600; }

/* -------------------------------------------------------------- Chatbot */

.chat-card { display: flex; flex-direction: column; }
.chat-log {
  display: grid; gap: .6rem;
  max-height: 320px; overflow-y: auto;
  padding: .3rem .1rem .6rem;
}
.chat-log:empty { display: none; }
.msg { max-width: 88%; padding: .62rem .85rem; border-radius: 14px; font-size: .88rem; line-height: 1.5; white-space: pre-line; }
.msg-user { justify-self: end; background: var(--blue-500); color: #fff; border-bottom-right-radius: 5px; }
.msg-assistant { justify-self: start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg-thinking { color: var(--muted); font-style: italic; }

.chat-suggest { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .7rem; }
.chip {
  padding: .42rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
  font-size: .8rem; font-weight: 600;
  cursor: pointer;
  transition: border-color .16s var(--ease), color .16s var(--ease);
}
.chip:hover { border-color: var(--blue-400); color: var(--blue-500); }

.chat-form { display: flex; gap: .5rem; align-items: center; }
.chat-form input { flex: 1; }
.chat-legal { font-size: .74rem; color: var(--muted); margin: .6rem 0 0; }

.chat-fab {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-500), var(--navy-600));
  color: #fff;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: 60;
}
.chat-fab:hover { transform: translateY(-2px); }

.chat-panel {
  position: fixed; inset: 0;
  z-index: 90;
  display: flex; flex-direction: column;
  background: var(--surface);
  padding-top: env(safe-area-inset-top, 0px);
}
.chat-panel-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(140deg, var(--navy-900), var(--navy-700));
  color: #fff;
}
.chat-panel-head h3 { font-size: .95rem; }
.chat-panel-head .close-x {
  margin-left: auto; width: 36px; height: 36px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .14); border: 0; border-radius: 10px;
  color: #fff; cursor: pointer; font-size: 1.1rem;
}
.chat-panel-body {
  flex: 1; overflow-y: auto;
  padding: 1rem;
  display: grid; gap: .6rem;
  align-content: start;
  background: var(--bg);
}
.chat-panel-foot {
  padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

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

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; min-width: 540px; }
.data-table th, .data-table td {
  padding: .68rem .6rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: .85rem;
  vertical-align: middle;
}
.data-table th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700;
  white-space: nowrap;
}
.data-table tbody tr:hover { background: var(--surface-2); }
.table-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: .8rem; flex-wrap: wrap;
  margin-bottom: .8rem;
  font-size: .82rem; color: var(--text-soft);
}
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }
.cat-badge {
  display: inline-block; padding: .18rem .5rem;
  border-radius: 6px; font-size: .74rem; font-weight: 700;
  background: #eef2f8; color: var(--text-soft);
  white-space: nowrap;
}

.filters { display: grid; gap: .6rem; margin-bottom: .9rem; }
.search-field {
  position: relative; display: flex; align-items: center;
  gap: .4rem;
}
.search-field .ico-sm { position: absolute; left: .7rem; color: var(--muted); }
.search-field input { padding-left: 2.2rem; }

.pager {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  margin-top: .9rem; font-size: .82rem; color: var(--text-soft);
}

/* -------------------------------------------------------------- Véhicules */

.vehicle-list { display: grid; gap: .8rem; }
.vehicle-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .95rem 1rem;
  background: var(--surface);
}
.vehicle-top { display: flex; align-items: flex-start; gap: .7rem; justify-content: space-between; }
.vehicle-plate {
  font-weight: 800; font-size: 1rem; letter-spacing: .02em;
  display: inline-flex; align-items: center; gap: .5rem;
}
.energy-tag {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: .16rem .45rem; border-radius: 5px;
  background: #eef2f8; color: var(--text-soft);
}
.energy-tag.is-elec { background: #e6f8f2; color: #0b7a5c; }
.vehicle-model { font-size: .8rem; color: var(--muted); }
.vehicle-total { font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.vehicle-stats {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem; margin-top: .8rem;
}
.vs-item {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: .45rem .6rem;
}
.vs-label { display: block; font-size: .7rem; color: var(--muted); }
.vs-value { font-weight: 700; font-size: .88rem; }
.vehicle-bar { height: 6px; border-radius: 3px; background: #eef2f8; margin-top: .8rem; overflow: hidden; }
.vehicle-bar span { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--blue-400), var(--blue-500)); }

/* ------------------------------------------------------------ Install/PWA */

.install-card {
  display: flex; flex-direction: column; gap: .9rem;
  background: linear-gradient(150deg, #eef6ff, #f7fbff);
  border-color: #d4e6fb;
}
.install-head h2 { margin-bottom: .3rem; }
.install-head p { color: var(--text-soft); font-size: .87rem; margin: 0; }
.install-btn {
  align-self: flex-start;
  background: var(--surface);
  border-color: #cfdff3;
  color: var(--navy-700);
}
.install-btn:hover { border-color: var(--blue-400); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(7, 28, 51, .58);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 1.2rem;
}
.modal-card {
  width: 100%; max-width: 460px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-lg);
}
.modal-card h3 { margin-bottom: .5rem; }
.modal-card > p { color: var(--text-soft); font-size: .88rem; }
.install-guide { display: grid; gap: .7rem; margin: 1rem 0 1.2rem; }
.install-guide-block {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .75rem .85rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.install-logo { color: var(--navy-800); display: flex; }
.install-guide-block strong { display: block; font-size: .88rem; }
.install-guide-block span { font-size: .8rem; color: var(--text-soft); }

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

.empty-state { text-align: center; padding: 2.2rem 1.2rem; }
.empty-icon {
  width: 62px; height: 62px; margin: 0 auto .9rem;
  display: grid; place-items: center;
  border-radius: 20px;
  background: #eef2f8; color: var(--navy-600);
}
.empty-state h2 { margin-bottom: .5rem; }
.empty-state p { color: var(--text-soft); max-width: 480px; margin: 0 auto; font-size: .9rem; }

.alert {
  padding: .75rem .9rem;
  border-radius: var(--radius-sm);
  font-size: .87rem;
  margin-bottom: 1rem;
}
.alert-error { background: #fdecea; color: #a5241a; border: 1px solid #f7cdc7; }
.alert-success { background: #e6f8f2; color: #0b6b51; border: 1px solid #bfe9de; }

.toasts {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 20px);
  z-index: 200;
  display: grid; gap: .5rem;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  padding: .75rem .95rem;
  border-radius: var(--radius-sm);
  background: var(--navy-900);
  color: #fff;
  font-size: .86rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in .22s var(--ease);
}
.toast.is-error { background: #8f251c; }
.toast.is-success { background: #0b6b51; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.import-progress { margin-top: 1rem; display: grid; gap: .5rem; font-size: .84rem; color: var(--text-soft); }
.progress-track { height: 8px; border-radius: 4px; background: #e7edf6; overflow: hidden; }
.progress-bar { height: 100%; width: 35%; border-radius: 4px; background: linear-gradient(90deg, var(--blue-400), var(--mint-400)); animation: progress-slide 1.2s infinite ease-in-out; }
@keyframes progress-slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

.gate-screen {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: 1.4rem;
  background:
    radial-gradient(90% 80% at 100% 0%, rgba(76, 195, 255, .2), transparent 60%),
    linear-gradient(150deg, var(--navy-900), var(--teal-800));
}
.gate-card {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  box-shadow: var(--shadow-lg);
}
.gate-card .brand-mark { margin-bottom: 1rem; }
.gate-card h1 { font-size: 1.3rem; margin-bottom: .5rem; }
.gate-card > p { color: var(--text-soft); font-size: .88rem; margin-bottom: 1.2rem; }
.gate-logout { display: block; text-align: center; margin-top: 1.1rem; }

/* ---------------------------------------------------- Barre de navigation */

.bottomnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -6px 20px rgba(11, 37, 69, .07);
}
.bnav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .18rem;
  padding: .55rem .2rem .6rem;
  min-height: var(--nav-h);
  font-size: .68rem; font-weight: 700;
  color: var(--muted);
  transition: color .16s var(--ease);
}
.bnav-item .bnav-icon { color: currentColor; }
.bnav-item.is-active { color: var(--navy-800); }
.bnav-item.is-active .bnav-icon { color: var(--blue-500); }
.bnav-item.is-active span { color: var(--navy-800); }

/* --------------------------------------------------------------- Tablette */

@media (min-width: 620px) {
  .filters { grid-template-columns: 2fr 1fr 1fr; }
  .form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid-2 .form-actions { grid-column: 1 / -1; }
  .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 768px) {
  body { font-size: 15.5px; }
  .auth-shell { grid-template-columns: 1.05fr 1fr; }
  .auth-brand { padding: 3rem; }
  .auth-panel { padding: 2rem 3rem; }
  .split { grid-template-columns: 1fr 1fr; }
  .chat-log { max-height: 380px; }
  .card { padding: 1.3rem; }
  .admin-tabs { display: flex; }
}

@media (min-width: 1024px) {
  .kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .vehicle-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bottomnav { display: none; }
  .app-body { padding-bottom: 2rem; }
  .chat-fab { bottom: 1.5rem; }
  .toasts { bottom: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
