/* ==========================================================================
   Garage — feuille de style (thème sombre par défaut, thème clair en option)
   ========================================================================== */

:root {
  --bg: #111827;
  --bg-elev: #0b1220;
  --card: #1f2937;
  --card-2: #273244;
  --border: #374151;
  --border-soft: #2b3646;
  --text: #f9fafb;
  --text-2: #d1d5db;
  --muted: #9ca3af;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-soft: rgba(2, 132, 199, .16);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, .15);
  --amber: #f59e0b;
  --green: #10b981;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 248px;
  --bottom-nav-h: 62px;
  --topbar-h: 56px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f3f4f6;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-2: #f3f4f6;
  --border: #d1d5db;
  --border-soft: #e5e7eb;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-soft: rgba(2, 132, 199, .1);
  --danger-soft: rgba(220, 38, 38, .08);
  --shadow: 0 1px 2px rgba(15, 23, 42, .08), 0 6px 20px rgba(15, 23, 42, .06);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6em; }
a { color: #38bdf8; text-decoration: none; }
a:hover { text-decoration: underline; }
:root[data-theme="light"] a { color: #0369a1; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; background: var(--card-2); padding: .1em .4em; border-radius: 6px; }
small, .small { font-size: .82rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #38bdf8; outline-offset: 2px; border-radius: 4px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: -4px; }
.icon-xl { width: 56px; height: 56px; stroke-width: 1.5; }
.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; }

/* ---------- Utilitaires ---------- */
.muted { color: var(--muted); }
.center-text { text-align: center; }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; word-break: break-word; }
.grow { flex: 1 1 200px; }
.mt { margin-top: 1rem; }
.row-end { display: flex; align-items: center; gap: .5rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: .75rem; }
.only-mobile { display: none !important; }
.back-link { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .9rem; margin-bottom: .35rem; }
.back-link .icon { width: 16px; height: 16px; }

/* ---------- Mise en page ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--bg-elev); border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; padding: 1rem .75rem; z-index: 40; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: .25rem .5rem 1.25rem; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #0ea5e9, #0369a1); color: #fff; flex-shrink: 0; }
.brand-mark-lg { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto .75rem; }
.brand-mark-lg .icon { width: 30px; height: 30px; }
.brand-name { font-weight: 800; font-size: 1.15rem; flex: 1; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-bottom { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border-soft); }
.nav-link {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  padding: .6rem .75rem; border-radius: var(--radius-sm); color: var(--text-2);
  font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer; text-align: left; text-decoration: none;
}
.nav-link:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: #38bdf8; }
:root[data-theme="light"] .nav-link.active { color: #0369a1; }
.nav-link .count, .icon-btn .count { margin-left: auto; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; border-radius: 999px; padding: 0 .45rem; min-width: 1.3rem; text-align: center; line-height: 1.3rem; }
.whoami { padding: .6rem .75rem 0; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.theme-sun { display: none; }
:root[data-theme="light"] .theme-sun { display: inline-block; }
:root[data-theme="light"] .theme-moon { display: none; }

.main-col { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { width: 100%; max-width: 1280px; margin: 0 auto; padding: 2rem 2rem 3rem; }
.scrim { display: none; }

.icon-btn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); background: none; border: 0; color: var(--text-2); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--card-2); color: var(--text); text-decoration: none; }
.icon-btn .count { position: absolute; top: 2px; right: 0; margin: 0; }

.bottom-nav { display: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head .muted { margin: .25rem 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.actions form { display: inline; }

/* ---------- Cartes ---------- */
.card { background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); min-width: 0; }
.card + .card, .stack > .card { margin-top: 0; }
.card h2 { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.card.no-pad { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
section.card, .grid-2, .charts, .kpis { margin-bottom: 1.25rem; }
.stack > section.card, .stack > .card, .stack > .kpis, .detail-grid .stack > * { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.form-wide { max-width: 900px; }
.form-narrow { max-width: 520px; }
.danger-zone { border-color: rgba(220, 38, 38, .45); }
.danger-zone > summary { color: #f87171; cursor: pointer; font-weight: 600; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .92rem; line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s; min-height: 40px;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--card-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: .35rem .7rem; min-height: 32px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > label, .field > legend, .label-like { font-size: .85rem; font-weight: 600; color: var(--text-2); padding: 0; }
.req { color: #f87171; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=search], input[type=url], select, textarea {
  width: 100%; padding: .6rem .75rem; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; min-height: 42px;
}
:root[data-theme="light"] input[type=text], :root[data-theme="light"] input[type=password], :root[data-theme="light"] input[type=email],
:root[data-theme="light"] input[type=number], :root[data-theme="light"] input[type=date], :root[data-theme="light"] input[type=search],
:root[data-theme="light"] input[type=url], :root[data-theme="light"] select, :root[data-theme="light"] textarea { background: #fff; }
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56, 189, 248, .25); }
input[type=file] { width: 100%; color: var(--text-2); font: inherit; }
input[type=file]::file-selector-button { margin-right: .75rem; padding: .45rem .8rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.hint { color: var(--muted); font-size: .8rem; margin: 0; }
.error-text { color: #f87171; font-size: .85rem; margin: 0; }
.has-error input, .has-error select, .has-error textarea { border-color: #ef4444; }
.otp-input { font-size: 1.5rem !important; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.form-grid:last-child { margin-bottom: 0; }
.form-grid .span-2 { grid-column: span 2; }
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.check { display: flex; align-items: flex-start; gap: .65rem; cursor: pointer; font-weight: 400; color: var(--text-2); }
.check input { width: 18px; height: 18px; margin-top: .15rem; accent-color: var(--primary); flex-shrink: 0; }
.check-list { display: flex; flex-direction: column; gap: .6rem; max-height: 320px; overflow-y: auto; }
.check-list.cols-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); max-height: none; }
.sticky-actions { position: sticky; bottom: 0; padding: .9rem 0; background: linear-gradient(to top, var(--bg) 70%, transparent); z-index: 5; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.inline-form { display: inline-flex; margin: 0; }
.inline-form select { min-height: 34px; padding: .25rem .5rem; width: auto; }

.photo-field { display: grid; grid-template-columns: 220px 1fr; gap: 1.25rem; align-items: start; }
.photo-preview { border-radius: var(--radius-sm); overflow: hidden; background: var(--card-2); aspect-ratio: 4 / 3; }
.photo-preview img, .photo-preview .placeholder { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Alertes ---------- */
.flashes { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.25rem; }
.flash { display: flex; align-items: flex-start; gap: .65rem; padding: .75rem 1rem; border-radius: var(--radius-sm); border: 1px solid; font-size: .93rem; }
.flash .icon { margin-top: 2px; }
.flash-success { background: rgba(16, 185, 129, .12); border-color: rgba(16, 185, 129, .45); color: #6ee7b7; }
.flash-error { background: var(--danger-soft); border-color: rgba(220, 38, 38, .5); color: #fca5a5; }
.flash-warning { background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .5); color: #fcd34d; }
:root[data-theme="light"] .flash-success { color: #047857; }
:root[data-theme="light"] .flash-error { color: #b91c1c; }
:root[data-theme="light"] .flash-warning { color: #92400e; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: .15rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.badge-red { background: rgba(220, 38, 38, .18); color: #fca5a5; }
.badge-amber { background: rgba(245, 158, 11, .18); color: #fcd34d; }
.badge-green { background: rgba(16, 185, 129, .18); color: #6ee7b7; }
.badge-gray { background: rgba(156, 163, 175, .2); color: var(--text-2); }
.badge-blue { background: rgba(2, 132, 199, .22); color: #7dd3fc; }
:root[data-theme="light"] .badge-red { color: #b91c1c; }
:root[data-theme="light"] .badge-amber { color: #92400e; }
:root[data-theme="light"] .badge-green { color: #047857; }
:root[data-theme="light"] .badge-blue { color: #0369a1; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .75rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: rgba(148, 163, 184, .06); }
.actions-cell { text-align: right; white-space: nowrap; }
.actions-cell form { display: inline; }
.chip { display: inline-flex; align-items: center; gap: .2rem; padding: .1rem .5rem; border-radius: 999px; background: var(--primary-soft); color: #7dd3fc; font-size: .8rem; margin-right: .25rem; }
.chip .icon { width: 14px; height: 14px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .45rem; background: #94a3b8; }
.dot-fuel { background: #f59e0b; } .dot-maintenance { background: #0ea5e9; } .dot-inspection { background: #8b5cf6; }
.dot-insurance { background: #10b981; } .dot-tax { background: #ec4899; } .dot-parking { background: #64748b; }
.dot-cleaning { background: #14b8a6; } .dot-accessories { background: #f97316; } .dot-fines { background: #ef4444; }

.filters-bar { display: flex; flex-wrap: wrap; gap: .85rem; align-items: flex-end; margin-bottom: 1rem; padding: 1rem; }
.filters-bar .field { min-width: 150px; }
.filters { display: flex; gap: .85rem; flex-wrap: wrap; }
.filters .field { min-width: 180px; }
.summary-bar { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: 0 0 .75rem; color: var(--text-2); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; margin: 1.25rem 0; }

/* ---------- Indicateurs et graphiques ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
@media (min-width: 1500px) { .kpis:not(.kpis-3) { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 1rem 1.15rem; display: flex; flex-direction: column; gap: .15rem; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.kpi-value { font-size: 1.55rem; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: .55em; font-weight: 600; color: var(--muted); }
.kpi-sub { color: var(--muted); font-size: .78rem; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.chart-card { margin: 0; }
.chart-box { position: relative; height: 290px; }
.chart-empty { text-align: center; padding: 3rem 1rem; margin: 0; }

/* ---------- Véhicules ---------- */
.vehicle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.25rem; }
.vehicle-card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none !important; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.vehicle-card:hover { transform: translateY(-2px); border-color: #38bdf8; }
.vc-media { position: relative; aspect-ratio: 16 / 9; background: var(--card-2); }
.vc-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder { display: grid; place-items: center; background: linear-gradient(135deg, var(--card-2), var(--bg)); color: var(--muted); }
.vc-badges { position: absolute; top: .6rem; left: .6rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.vc-body { padding: 1.1rem 1.25rem 1.2rem; }
.vc-body h2 { font-size: 1.1rem; margin: 0 0 .15rem; color: var(--text); }
.vc-body p { margin: 0 0 1.1rem; }
.vc-foot { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; }
.detail-img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
div.detail-img.placeholder { aspect-ratio: 16 / 10; }
.quick-links { display: flex; flex-wrap: wrap; gap: .5rem; }

.info { margin: 0; display: flex; flex-direction: column; }
.info-row { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--border-soft); }
.info-row:last-child { border-bottom: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }
.info.compact .info-row { padding: .3rem 0; font-size: .9rem; }

.plain-list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--border-soft); }
.list-row:last-child { border-bottom: 0; }
.list-row > div { min-width: 0; }

/* ---------- Rappels ---------- */
.reminder-list { display: flex; flex-direction: column; gap: 1rem; }
.reminder { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-left: 4px solid var(--border); }
.reminder.level-overdue { border-left-color: #ef4444; }
.reminder.level-soon { border-left-color: var(--amber); }
.reminder.level-ok { border-left-color: var(--green); }
.reminder-main { min-width: 0; flex: 1; }
.reminder-title { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .2rem; }
.meta { display: flex; flex-wrap: wrap; gap: .5rem 1.75rem; margin: .5rem 0 0; }
.meta div { display: flex; flex-direction: column; }
.meta dt { color: var(--muted); font-size: .75rem; }
.meta dd { margin: 0; font-weight: 600; font-size: .92rem; }
.reminder-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.reminder-actions form { display: inline; }

/* ---------- Pièces ---------- */
.parts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.part { display: flex; flex-direction: column; gap: .35rem; margin: 0; }
.part-head { display: flex; justify-content: space-between; align-items: center; }
.part h2 { margin: .25rem 0 0; }
.part-ref { margin: 0 0 .35rem; }

/* ---------- Documents ---------- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.doc { padding: 0; overflow: hidden; margin: 0; display: flex; flex-direction: column; }
.doc-thumb { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--card-2); color: var(--muted); text-decoration: none !important; overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb .ext { position: absolute; bottom: .6rem; font-weight: 800; font-size: .8rem; letter-spacing: .08em; }
.doc-body { padding: .9rem 1rem 1rem; display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.doc-body h2 { font-size: .98rem; margin: 0; word-break: break-word; }
.doc-body p { margin: 0; }
.doc-actions { display: flex; align-items: center; gap: .35rem; margin-top: auto; padding-top: .5rem; }
.doc-actions form { display: inline; }
.upload-card { margin-bottom: 1.25rem; }
.upload-card > summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.upload-card[open] > summary { margin-bottom: 1rem; }

/* ---------- Notifications ---------- */
.notif { display: flex; align-items: center; gap: .85rem; padding: .9rem 1.1rem; color: inherit; text-decoration: none !important; }
.notif:hover { background: var(--card-2); }
.notif-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.notif-dot { width: 10px; height: 10px; border-radius: 50%; background: transparent; flex-shrink: 0; }
.unread .notif-dot { background: #38bdf8; }
.notif-list li { border-bottom: 1px solid var(--border-soft); }
.notif-list li:last-child { border-bottom: 0; }

/* ---------- Divers ---------- */
.empty { text-align: center; padding: 3.5rem 1rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.empty h3 { color: var(--text); }
.steps { margin: 0 0 .5rem; padding-left: 1.2rem; color: var(--text-2); }
.steps li { margin-bottom: .35rem; }
.qr { background: #fff; padding: 10px; border-radius: 12px; image-rendering: pixelated; }
.secret-key { display: block; font-size: 1rem; letter-spacing: .08em; padding: .6rem .8rem; word-break: break-all; user-select: all; }
.codes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.codes li { background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: .6rem; text-align: center; font-size: 1.05rem; }
.codes code { background: none; font-size: 1.05rem; letter-spacing: .06em; }
.inline-details { position: relative; }
.inline-details > summary { list-style: none; cursor: pointer; }
.inline-details > summary::-webkit-details-marker { display: none; }
.popover { position: absolute; right: 0; top: 110%; width: 260px; z-index: 10; background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem; box-shadow: var(--shadow); }
details > summary { cursor: pointer; }
.actions-stack { display: flex; flex-direction: column; gap: .75rem; }
.action-box { border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: .75rem 1rem; }
.action-box > summary { font-weight: 600; }
.action-box[open] > summary { margin-bottom: .75rem; }
.error-code { font-size: 4.5rem; font-weight: 800; color: #38bdf8; margin: 0; line-height: 1; }

/* ---------- Page de connexion ---------- */
.auth-body { display: grid; place-items: center; padding: 1.25rem; background: radial-gradient(1200px 600px at 50% -10%, rgba(2, 132, 199, .22), transparent), var(--bg); }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card { background: var(--card); border: 1px solid var(--border-soft); border-radius: 16px; padding: 2rem 1.75rem; box-shadow: var(--shadow); }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { font-size: 1.6rem; }
.auth-brand p { margin: .25rem 0 0; }
.auth-foot { text-align: center; font-size: .8rem; margin-top: 1rem; }

/* ---------- Tablette / mobile ---------- */
@media (max-width: 1100px) {
  .charts { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 280px; }
  .only-mobile { display: inline-grid !important; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .55); }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 35; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .main-col { margin-left: 0; padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }
  .topbar { display: flex; align-items: center; gap: .5rem; height: var(--topbar-h); padding: 0 .75rem; position: sticky; top: 0; z-index: 30; background: var(--bg-elev); border-bottom: 1px solid var(--border-soft); padding-top: env(safe-area-inset-top); }
  .topbar-title { flex: 1; font-weight: 800; font-size: 1.05rem; }
  .content { padding: 1.25rem 1rem 2rem; }
  h1 { font-size: 1.45rem; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-elev); border-top: 1px solid var(--border-soft);
  }
  .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: none; border: 0; color: var(--muted); font: inherit; font-size: .68rem; font-weight: 600; text-decoration: none; cursor: pointer; padding: 0; }
  .bottom-nav a.active { color: #38bdf8; }
  .sticky-actions { bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }
  .grid-2 { grid-template-columns: 1fr; }
  .kpis-3 { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
  .page-head .actions { width: 100%; }
}

@media (max-width: 640px) {
  .form-grid .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .photo-field { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 1.2rem; }
  .chart-box { height: 240px; }
  .reminder { flex-direction: column; }
  .reminder-actions { justify-content: flex-start; }
  .filters-bar .field { flex: 1 1 100%; }
  .filters .field { min-width: 100%; }
  .vehicle-grid { grid-template-columns: 1fr; }
  .codes { grid-template-columns: 1fr; }
  .actions .btn { flex: 1 1 auto; }

  /* Tableaux : une « carte » par ligne */
  .stack-mobile thead { display: none; }
  .stack-mobile, .stack-mobile tbody, .stack-mobile tr, .stack-mobile td { display: block; width: 100%; }
  .stack-mobile tr { padding: .6rem .9rem; border-bottom: 1px solid var(--border); }
  .stack-mobile td { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border: 0; text-align: right; }
  .stack-mobile td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 600; text-align: left; flex-shrink: 0; }
  .stack-mobile td.actions-cell::before { content: none; }
  .stack-mobile td.actions-cell { justify-content: flex-end; }
  .stack-mobile .num { text-align: right; }
}

@media print {
  .sidebar, .topbar, .bottom-nav, .actions, .flashes, .sticky-actions, .scrim { display: none !important; }
  .main-col { margin: 0; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
