/* ==========================================================================
   Révizio — feuille de style de base (composants des pages)
   La coque (menu, barres), la typographie Barlow et les nouveaux composants sont dans ui.css (3.0).
   Les couleurs sont redéfinies par thème dans themes.css.
   ========================================================================== */

: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);
  --on-primary: #ffffff;
  --accent: var(--accent);
  --accent-2: var(--accent-2);
  --input-bg: #111827;
  --dim: rgba(3, 7, 18, .62);
  --brand-a: #0ea5e9;
  --brand-b: #0369a1;
  --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);
  --accent: #0369a1;
  --accent-2: #0369a1;
  --input-bg: #ffffff;
  --dim: rgba(15, 23, 42, .48);
  --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: 400 15px/1.5 "Barlow", 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: 30px; font-weight: 700; line-height: 1.15; letter-spacing: -.015em; }
h2 { font-size: 17px; font-weight: 600; line-height: 1.3; }
h3 { font-size: 15.5px; font-weight: 600; line-height: 1.3; }
p { margin: 0 0 .6em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
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 var(--accent); 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: 1.9; 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: 6px; color: var(--muted); font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.back-link:hover { color: var(--text); text-decoration: none; }
.back-link .icon { width: 16px; height: 16px; }

/* ---------- Mise en page ---------- */
/* Coque de l'application (barre latérale, rail sur tablette, tiroir et barres sur téléphone) : voir ui.css */
.brand-mark-lg { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto .75rem; }
.brand-mark-lg .icon { width: 30px; height: 30px; }
.theme-sun { display: none; }
:root[data-theme="light"] .theme-sun { display: inline-block; }
:root[data-theme="light"] .theme-moon { display: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .muted { margin: 5px 0 0; font-size: 15px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions form { display: inline; }

/* ---------- Cartes ---------- */
.card { background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--r-lg, 18px); padding: var(--card-pad, 20px 22px); box-shadow: var(--shadow); min-width: 0; }
.card + .card, .stack > .card { margin-top: 0; }
.card h2 { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.card h2 .icon { color: var(--muted); }
.card.no-pad { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
section.card, .grid-2, .charts, .kpis { margin-bottom: 20px; }
.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: 20px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; 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: var(--red-ink, #f87171); cursor: pointer; font-weight: 600; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: .45rem 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 14.5px; line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s; min-height: 40px;
}
.btn .icon { width: 18px; height: 18px; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 1px 2px rgba(14, 26, 47, .16); }
.btn-primary:hover { background: var(--primary-hover); }
:root[data-theme="light"] a.btn-primary { color: var(--on-primary); }
:root[data-theme="light"] a.btn-danger { color: #fff; }
/* « ghost » : bouton secondaire, sur fond de carte et bordé */
.btn-ghost, .btn-secondary { background: var(--card); border-color: var(--border); color: var(--text); box-shadow: var(--shadow); }
.btn-ghost:hover, .btn-secondary:hover { background: var(--card-2); }
:root[data-theme="light"] a.btn-ghost, :root[data-theme="light"] a.btn-secondary { color: var(--text); }
.btn-soft { background: var(--primary-soft); color: var(--accent); }
.btn-soft:hover { background: color-mix(in srgb, var(--primary) 20%, transparent); }
.btn-plain { background: transparent; color: var(--text-2); }
.btn-plain:hover { background: var(--card-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in oklab, var(--danger) 86%, black); }
.btn-sm { padding: .3rem 12px; min-height: 34px; font-size: 13.5px; border-radius: 9px; gap: 6px; }
.btn-sm .icon { width: 16px; height: 16px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > label, .field > legend, .label-like { font-size: 14px; font-weight: 600; color: var(--text-2); padding: 0; }
.req { color: var(--red, #f87171); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=search], input[type=url], input[type=tel], input[type=time], input[type=month], select, textarea {
  width: 100%; padding: .55rem .8rem; background-color: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 11px; font: inherit; min-height: 44px; box-shadow: var(--shadow);
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 85%, transparent); }
/* liste déroulante : flèche dessinée (deux teintes selon le mode, les variables CSS n'entrent pas dans une image) */
select:not([multiple]) {
  appearance: none; -webkit-appearance: none; padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238d99b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: calc(100% - 12px) 50%; background-size: 16px 16px; background-repeat: no-repeat;
}
:root[data-theme="light"] select:not([multiple]) { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235e6a82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
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: 13px; margin: 0; }
.error-text { color: var(--red-ink, #f87171); font-size: 13.5px; margin: 0; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red, #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: 14px 16px; margin-bottom: 16px; }
.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: 12px; padding: 12px 16px; border-radius: var(--r, 14px); border: 1px solid; font-size: 14.5px; }
.flash .icon { margin-top: 1px; }
.flash-success { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 35%, transparent); color: var(--green-ink); }
.flash-error { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 32%, transparent); color: var(--red-ink); }
.flash-warning { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 38%, transparent); color: var(--amber-ink); }
.flash-info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 26%, transparent); color: var(--accent); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: .15rem 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 1.2; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge-red { background: var(--red-soft); color: var(--red-ink); }
.badge-amber { background: var(--amber-soft); color: var(--amber-ink); }
.badge-green { background: var(--green-soft); color: var(--green-ink); }
.badge-gray { background: var(--surface-3); color: var(--text-2); }
.badge-blue { background: var(--primary-soft); color: var(--accent); }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--text-2); }
.badge-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 11px 14px; background: var(--card-2); border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-family: var(--font-num, inherit); font-size: 15px; font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: color-mix(in srgb, var(--card-2) 70%, transparent); }
.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: var(--accent-2); 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: 12px 14px; align-items: flex-end; margin-bottom: 16px; padding: 16px 18px; }
.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: 14px; }
@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(--r-lg, 18px); padding: 16px 20px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: 13.5px; font-weight: 500; }
.kpi-value { margin-top: 4px; font-family: var(--font-num, inherit); font-size: 28px; font-weight: 600; line-height: 1.1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi-value small { margin-left: 2px; font-family: var(--font, inherit); font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--muted); white-space: nowrap; }
.kpi-sub { color: var(--muted); font-size: 13px; }
.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: var(--accent); }
.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: var(--surface-3); 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: var(--accent); }
.notif-list li { border-bottom: 1px solid var(--border-soft); }
.notif-list li:last-child { border-bottom: 0; }

/* ---------- Divers ---------- */
.empty { text-align: center; padding: 52px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty > .icon-xl { width: 64px; height: 64px; padding: 16px; border-radius: 20px; background: var(--primary-soft); color: var(--accent); stroke-width: 1.7; }
.empty h3 { color: var(--text); font-size: 18px; }
.empty p { max-width: 46ch; }
.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: var(--accent); 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; }
.auth-title { font-size: 1.2rem; margin: 0; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.small-link { font-size: .85rem; font-weight: 600; color: var(--accent); }
.auth-card .back-link { justify-content: center; }

/* Assistant de double authentification */
.wizard-steps { display: flex; gap: .5rem; list-style: none; margin: 0; padding: 0; font-size: .75rem; color: var(--muted); }
.wizard-steps li { flex: 1; display: flex; flex-direction: column; gap: .4rem; line-height: 1.3; min-width: 0; }
.wizard-steps li::before { content: ""; height: 4px; border-radius: 2px; background: var(--border); }
.wizard-steps li.done::before, .wizard-steps li.current::before { background: var(--primary); }
.wizard-steps li.current { color: var(--text); font-weight: 600; }
.wizard-steps .icon { width: 12px; height: 12px; color: var(--green); margin-right: .2rem; vertical-align: -1px; }
.choices { display: flex; flex-direction: column; gap: .7rem; }
.choice { display: flex; gap: .85rem; align-items: flex-start; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--card-2); color: var(--text); text-decoration: none; }
.choice, .choice:hover, .choice:focus { text-decoration: none; }
.choice:hover, .choice:focus-visible { border-color: var(--primary); background: var(--primary-soft); }
.choice-icon { flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--accent); }
.choice-icon .icon { width: 22px; height: 22px; }
.choice-text { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.choice-text .badge { align-self: flex-start; }
:root[data-theme="light"] a.choice { color: var(--text); }
.manual-key summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.manual-key[open] { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.manual-key .secret-key { word-break: break-all; }
.wizard-foot { display: flex; justify-content: center; gap: 1.25rem; font-size: .85rem; padding-top: .25rem; border-top: 1px solid var(--border-soft); }
.wizard-foot a, .link-button { color: var(--muted); }
.link-button { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

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

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpis-3 { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .only-mobile { display: inline-grid !important; }
  .sticky-actions { bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }
  .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: 22px; }
  .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; }
}

/* ==========================================================================
   Version 1.1 : carnet d'interventions, fiche technique, saisie rapide, scan
   ========================================================================== */

.pad { padding: 1.25rem 1.25rem 0; }
.card.no-pad > h2.pad { margin-bottom: .5rem; }
.btn-lg { min-height: 50px; padding: .6rem 22px; font-size: 16px; border-radius: 13px; }
.field-sm { max-width: 100%; }
label.field { cursor: default; }
.input-group { display: flex; gap: .25rem; align-items: center; }
.input-group input { flex: 1; min-width: 0; }
.input-group .icon-btn { flex-shrink: 0; border: 1px solid var(--border); height: 42px; width: 42px; }
.input-unit { display: flex; align-items: center; gap: .4rem; }
.input-unit input { min-width: 0; }
.input-unit span { color: var(--muted); font-size: .85rem; }

/* ---------- Bandeau d'information ---------- */
.notice { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; border-left: 4px solid var(--amber); }
.notice form { margin: 0; }
.notice-info { justify-content: flex-start; flex-wrap: nowrap; align-items: flex-start; gap: .65rem; border-left-color: var(--accent); color: var(--text-2); font-size: .9rem; }
.notice-info .icon { color: var(--accent); margin-top: 1px; }
p.notice { margin-top: 0; }

/* ---------- Saisie rapide ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; max-width: 900px; }
.quick-tile { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; padding: 1.25rem; min-height: 132px; background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); text-decoration: none !important; transition: transform .15s, border-color .15s; }
.quick-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.quick-tile strong { font-size: 1.08rem; }
.quick-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--accent); margin-bottom: .35rem; }
.quick-icon .icon { width: 24px; height: 24px; }
.quick-form { max-width: 560px; }
.quick-form input, .quick-form select, .quick-form textarea { font-size: 1.02rem; min-height: 48px; }
.file-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.file-actions .btn { flex: 1 1 150px; cursor: pointer; }
.file-actions .btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.ai-btn { align-self: flex-start; margin-top: .25rem; }
.ai-btn .icon { color: #a78bfa; }

/* ---------- Carnet : liste chronologique ---------- */
.timeline { display: flex; flex-direction: column; gap: .9rem; }
.entry { display: grid; grid-template-columns: 118px minmax(0, 1fr) auto; gap: 1.1rem; align-items: start; border-left: 4px solid var(--primary); margin: 0; }
.entry-date { display: flex; flex-direction: column; gap: .1rem; }
.entry-title { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.entry-title h2 { margin: 0; font-size: 1.05rem; }
.entry-title h2 a { color: var(--text); }
.entry-meta { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; color: var(--muted); font-size: .85rem; margin-top: .5rem; }
.entry-meta .icon { width: 15px; height: 15px; margin-right: .3rem; vertical-align: -2px; }
.entry-side { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; }
.entry-cost { font-size: 1.05rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ops { margin: .5rem 0 0; padding-left: 1.15rem; color: var(--text-2); font-size: .92rem; }
.ops li { margin-bottom: .15rem; }
.ops-lg { font-size: 1rem; margin-top: 0; }
.ops-lg li { margin-bottom: .35rem; }
.kpis-detail .kpi-value { font-size: 23px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.photo-grid a { display: block; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--card-2); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.part-usage { display: flex; gap: .4rem; align-items: flex-start; color: var(--text-2); margin: .35rem 0 0; }
.part-usage .icon { width: 15px; height: 15px; margin-top: 2px; color: var(--muted); }

/* ---------- Carnet : lignes de pièces du formulaire ---------- */
.part-rows { display: flex; flex-direction: column; gap: .75rem; margin-top: .75rem; }
.part-row { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .7rem; padding: .9rem 3.2rem .9rem .9rem; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); background: var(--bg); }
:root[data-theme="light"] .part-row { background: var(--card-2); }
.part-row .field { grid-column: span 2; }
.part-row .part-pick { grid-column: span 4; }
.part-row .field-sm { grid-column: span 1; }
.part-row .part-pick + [hidden] + .field { grid-column: span 2; }
.part-remove { position: absolute; top: .45rem; right: .45rem; }

/* ---------- Fiche technique ---------- */
.spec-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.spec-groups > section { margin: 0; }
.spec-list { list-style: none; margin: 0; padding: 0; }
.spec { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 1.25rem; border-top: 1px solid var(--border-soft); }
.spec-label { display: flex; flex-direction: column; min-width: 0; }
.spec-value { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; text-align: right; }
.spec-value strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.spec-progress { margin: 0; padding: .55rem 0; }
.spec-edit-list { display: flex; flex-direction: column; gap: .75rem; }
.spec-edit { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, .7fr) minmax(0, 1.6fr) minmax(0, 1.6fr) auto; gap: .6rem; align-items: end; padding-bottom: .75rem; border-bottom: 1px solid var(--border-soft); }
.spec-edit:last-child { border-bottom: 0; padding-bottom: 0; }
.spec-edit-flags { display: flex; flex-direction: column; gap: .3rem; padding-bottom: .35rem; font-size: .88rem; }
.spec-new { border-top: 1px dashed var(--border); padding-top: .75rem; }

/* ---------- Scan de code-barres ---------- */
.scan-dialog { width: min(92vw, 460px); padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.scan-dialog::backdrop { background: rgba(0, 0, 0, .7); }
.scan-frame { position: relative; aspect-ratio: 4 / 3; background: #000; border-radius: var(--radius-sm); overflow: hidden; }
.scan-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-guide { position: absolute; inset: 28% 8%; border: 2px solid color-mix(in srgb, var(--accent) 90%, transparent); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .28); pointer-events: none; }
.scan-status { margin: .75rem 0; min-height: 1.4em; color: var(--text-2); font-size: .92rem; }

/* ---------- Adaptations tablette / mobile ---------- */
@media (max-width: 1100px) {
  .spec-groups { grid-template-columns: 1fr; }
  .spec-edit { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spec-edit-label { grid-column: 1 / -1; }
  .spec-edit-flags { flex-direction: row; gap: 1.25rem; grid-column: 1 / -1; padding-bottom: 0; }
}

@media (max-width: 900px) {
  .part-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .part-row .part-pick { grid-column: 1 / -1; }
  .part-row .field-sm { grid-column: span 2; }
}

@media (max-width: 640px) {
  .entry { grid-template-columns: 1fr; gap: .6rem; }
  .entry-date { flex-direction: row; align-items: baseline; gap: .6rem; }
  .entry-side { flex-direction: row; justify-content: space-between; align-items: center; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .quick-tile { min-height: 118px; padding: 1rem; }
  .quick-form { max-width: none; }
  .part-row { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: .8rem 2.9rem .8rem .8rem; }
  .part-row .field { grid-column: 1 / -1; }
  .part-row .field-sm { grid-column: span 1; }
  .spec { flex-direction: column; align-items: flex-start; gap: .35rem; padding: .7rem 1rem; }
  .spec-value { justify-content: flex-start; text-align: left; }
  .spec-edit { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .notice-info { font-size: .86rem; }
  .pad { padding: 1rem 1rem 0; }
}

/* Fiche technique (grand écran) : les intitulés de colonnes ne sont affichés que sur la première ligne */
@media (min-width: 1101px) {
  .spec-edit:not(:first-child):not(.spec-new) > .field > .label-like { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .spec-edit:not(:first-child) { align-items: center; }
  .spec-edit:not(:first-child) .spec-edit-flags { padding-bottom: 0; }
}

/* ==========================================================================
   Visite guidée
   ========================================================================== */
/* La page est assombrie sauf l'élément expliqué (halo) ; une fenêtre compacte se place à côté (js/tour.js). */
.tour-layer { position: fixed; inset: 0; z-index: 60; }
.tour-block { position: absolute; inset: 0; }
.tour-spot {
  position: fixed; left: 50%; top: 50%; width: 0; height: 0; border-radius: 50%; pointer-events: none; z-index: 61;
  box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent, 0 0 0 200vmax var(--dim);
  transition: left .42s cubic-bezier(.22, .9, .24, 1), top .42s cubic-bezier(.22, .9, .24, 1), width .42s cubic-bezier(.22, .9, .24, 1),
              height .42s cubic-bezier(.22, .9, .24, 1), border-radius .42s, box-shadow .3s;
}
.tour-spot.is-on { box-shadow: 0 0 0 2px var(--accent), 0 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent), 0 0 0 200vmax var(--dim); }
.tour-spot.is-instant { transition: none; }
.tour-card {
  position: fixed; z-index: 62; right: 1.5rem; bottom: 1.5rem; width: 320px; max-width: calc(100vw - 24px);
  background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5); padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 8px;
  opacity: 0; transform: translateY(6px) scale(.98); transition: opacity .2s ease, transform .2s ease; pointer-events: none;
}
:root[data-theme="light"] .tour-card { box-shadow: 0 18px 50px rgba(15, 23, 42, .22); }
.tour-card.is-shown { opacity: 1; transform: none; pointer-events: auto; }
.tour-card.is-wide { width: 420px; padding: 20px 22px 18px; gap: 10px; }
.tour-card.is-nudge { animation: tour-nudge .32s ease; }
@keyframes tour-nudge { 30% { transform: scale(1.025); } 60% { transform: scale(.995); } }
.tour-card form { margin: 0; }
.tour-meta { display: flex; align-items: center; gap: 8px; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.tour-num { color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.tour-close { margin: -6px -8px 0 auto; width: 30px; height: 30px; border: 0; background: none; color: var(--muted); border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.tour-close:hover { background: var(--card-2); color: var(--text); }
.tour-close .icon { width: 16px; height: 16px; }
.tour-title { margin: 0; font-size: 1.05rem; font-weight: 750; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tour-card.is-wide .tour-title { font-size: 1.3rem; }
.tour-text { margin: 0; color: var(--text-2); font-size: .9rem; line-height: 1.45; }
.tour-admin { font-size: .66rem; font-weight: 700; letter-spacing: .03em; background: rgba(245, 158, 11, .16); color: var(--amber); border-radius: 99px; padding: 1px 7px; }
.tour-bar { position: absolute; left: 14px; right: 14px; top: 0; height: 3px; border-radius: 0 0 3px 3px; background: var(--border-soft); overflow: hidden; }
.tour-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .4s ease; }
.tour-foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.tour-back { width: 36px; height: 36px; flex-shrink: 0; border-radius: 9px; border: 1px solid var(--border); background: none; color: var(--text); display: grid; place-items: center; cursor: pointer; }
.tour-back .icon { width: 18px; height: 18px; transform: rotate(180deg); }
.tour-back:disabled { opacity: .35; cursor: default; }
.tour-next { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; background: var(--primary); color: var(--on-primary); border: 0; border-radius: 9px; padding: 0 14px; height: 36px; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; }
.tour-next:hover { background: var(--primary-hover); }
.tour-next .icon { width: 16px; height: 16px; }
.tour-ghost { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; padding: 0 6px; height: 36px; }
.tour-ghost:hover { color: var(--text); }
.tour-keys { font-size: .74rem; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.tour-keys kbd { font: 600 .72rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 .3rem; background: var(--card-2); color: var(--text-2); }
.tour-where { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; color: var(--text-2); background: var(--card-2); border-radius: 99px; padding: 2px 9px 2px 7px; }
.tour-where .icon { width: 14px; height: 14px; flex-shrink: 0; }
.tour-arrow { position: absolute; width: 12px; height: 12px; background: var(--card); border: 1px solid var(--border); transform: rotate(45deg); }
.tour-arrow[data-side="left"] { left: -7px; border-top: 0; border-right: 0; }
.tour-arrow[data-side="right"] { right: -7px; border-bottom: 0; border-left: 0; }
.tour-arrow[data-side="top"] { top: -7px; border-bottom: 0; border-right: 0; }
.tour-arrow[data-side="bottom"] { bottom: -7px; border-top: 0; border-left: 0; }
.tour-chapters { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 2px; }
.tour-chapter { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 1px solid var(--border-soft); background: var(--card-2); color: var(--text); border-radius: 10px; padding: 8px 10px; cursor: pointer; font: inherit; }
.tour-chapter:hover, .tour-chapter:focus-visible { border-color: var(--accent); }
.tour-chapter .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); color: var(--accent); flex-shrink: 0; }
.tour-chapter .ic .icon { width: 16px; height: 16px; }
.tour-chapter b { display: block; font-size: .88rem; }
.tour-chapter small { color: var(--muted); font-size: .76rem; }
.tour-chapter .n { color: var(--muted); font-size: .74rem; font-weight: 500; margin-left: 6px; white-space: nowrap; }
.has-tour .content { padding-bottom: 8rem; }
.tour-toast { position: fixed; left: 50%; bottom: 1.5rem; z-index: 66; transform: translateX(-50%); display: flex; gap: 12px; align-items: center; width: max-content; max-width: calc(100vw - 24px);
  background: var(--text); color: var(--bg); border-radius: 10px; padding: 9px 10px 9px 14px; font-size: .88rem; box-shadow: 0 18px 50px rgba(0, 0, 0, .4); animation: tour-toast-in .2s ease-out; }
.tour-toast form { margin: 0; }
.tour-toast button { border: 0; background: none; color: var(--bg); font: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; white-space: nowrap; }
@keyframes tour-toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
@media (max-width: 767px) {
  .tour-card { left: 12px; right: 12px; width: auto; bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 12px); padding: 12px 14px 10px; gap: 6px; }
  .tour-card.is-wide { width: auto; padding: 18px 16px 14px; }
  .tour-keys { display: none; }
  .has-tour .sticky-actions { position: static; }
  .tour-toast { bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 14px); }
}
@media (prefers-reduced-motion: reduce) {
  .tour-spot, .tour-card, .tour-bar i { transition: none; }
  .tour-card.is-nudge, .tour-toast { animation: none; }
}
@media print { .tour-layer, .tour-card, .tour-toast { display: none !important; } }

/* ---------- Dépenses récurrentes ---------- */
.recurring-card { margin-bottom: 1.25rem; }
.recurring-card > summary { display: flex; align-items: center; gap: .5rem; font-weight: 700; flex-wrap: wrap; }
.recurring-card > summary .muted { font-weight: 400; }
.recurring-card[open] > summary { margin-bottom: .5rem; }

/* ---------- Contrôle technique ---------- */
.ct-status-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.ct-status { margin: 0; border-left: 4px solid var(--border); }
.ct-status.level-ok { border-left-color: var(--green); }
.ct-status.level-soon { border-left-color: var(--amber); }
.ct-status.level-overdue { border-left-color: #ef4444; }
.ct-entry.result-favorable { border-left-color: var(--green); }
.ct-entry.result-counter { border-left-color: var(--amber); }
.ct-entry.result-critical { border-left-color: #ef4444; }
.ct-link { display: flex; gap: .4rem; align-items: flex-start; color: var(--text-2); margin: .5rem 0 0; }
.ct-link .icon { width: 15px; height: 15px; margin-top: 2px; color: var(--muted); }
.ct-docs { margin: .6rem 0 0; }

/* ---------- Recherche par plaque ---------- */
.plate-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: stretch; margin: .6rem 0 .4rem; }
.plate-input { flex: 1 1 12rem; max-width: 18rem; text-transform: uppercase; font-weight: 700; letter-spacing: .08em; }
.plate-input::placeholder { font-weight: 400; letter-spacing: normal; }
.just-filled { border-color: var(--green) !important; }
@media (max-width: 520px) { .plate-input { max-width: none; } .plate-row .btn { flex: 1 1 100%; } }

/* ---------- Carnet PDF : masquage des coordonnées ---------- */
.redact-card h2 { margin-bottom: .35rem; }
.small-title { font-size: .95rem; font-weight: 600; display: flex; align-items: center; gap: .45rem; margin: 0; }
.min-w-0 { min-width: 0; }
.text-warning { color: var(--amber); display: flex; gap: .4rem; align-items: flex-start; margin: .3rem 0 0; }
:root[data-theme="light"] .text-warning { color: #92400e; }
.text-warning .icon { width: 15px; height: 15px; margin-top: 3px; flex-shrink: 0; }
.redact-list, .redact-suggestions, .redact-report { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.redact-list li, .redact-suggestions li, .redact-report li {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .55rem .75rem; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); background: var(--card-2);
}
.redact-list li.redact-empty { background: none; border-style: dashed; }
.redact-report li { align-items: flex-start; }
.redact-report strong { margin-right: .4rem; }
.redact-text { font-weight: 600; overflow-wrap: anywhere; }
.redact-list form, .redact-suggestions form { margin: 0; }
.redact-add { display: flex; gap: .5rem; }
.redact-add input { flex: 1 1 auto; min-width: 0; }
.redact-add .btn { flex-shrink: 0; }
.btn-icon { width: 40px; min-width: 40px; padding: 0; justify-content: center; }
.btn-sm.btn-icon { width: 34px; min-width: 34px; }
.redact-report .row-end { flex-wrap: wrap; gap: .35rem .75rem; }
@media (max-width: 520px) { .redact-add .btn span { display: none; } }

/* ---------- Carnet PDF : suivi de la création ---------- */
.job-scrim { position: fixed; inset: 0; z-index: 80; background: rgba(3, 7, 18, .62); display: grid; place-items: center; padding: 16px; }
:root[data-theme="light"] .job-scrim { background: rgba(17, 24, 39, .45); }
.job-dialog { width: min(440px, 100%); background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: 0 20px 50px rgba(0, 0, 0, .35); padding: 1.35rem; }
body.job-open { overflow: hidden; }
.job { display: flex; flex-direction: column; gap: 1rem; }
.job-head { display: flex; align-items: center; gap: 1rem; }
.job-title { font-size: 1.1rem; margin: 0; }
.job-status { margin: .15rem 0 0; font-size: .88rem; color: var(--text-2); overflow-wrap: anywhere; }
.job-bar { height: 8px; border-radius: 99px; background: var(--card-2); overflow: hidden; }
.job-bar > span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 99px; }
.job.is-done .job-bar > span { background: var(--green); }
.job.is-error .job-bar > span { background: var(--danger); }
.job-meta { display: flex; justify-content: space-between; margin-top: .3rem; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.job-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; font-size: .88rem; }
.job-steps li { display: grid; grid-template-columns: 18px 1fr; gap: .65rem; align-items: start; color: var(--muted); }
.job-steps li.is-current { color: var(--text); font-weight: 600; }
.job-steps li.is-done { color: var(--text-2); }
.job-detail { display: block; font-size: .8rem; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.job-mark { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); margin-top: 1px; display: grid; place-items: center; }
.job-steps li.is-done .job-mark { border-color: var(--green); background: var(--green); }
.job-steps li.is-done .job-mark::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.job-steps li.is-current .job-mark { border-color: var(--primary); border-right-color: transparent; animation: job-spin .8s linear infinite; }
.job-steps li.is-failed .job-mark { border-color: var(--danger); background: var(--danger); }
.job-result { background: rgba(16, 185, 129, .14); color: #6ee7b7; border-radius: var(--radius-sm); padding: .6rem .75rem; font-size: .87rem; overflow-wrap: anywhere; }
.job-result.is-error { background: var(--danger-soft); color: #fca5a5; }
:root[data-theme="light"] .job-result { color: #047857; }
:root[data-theme="light"] .job-result.is-error { color: #b91c1c; }
.job-result code { background: none; padding: 0; }
.job-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .5rem; }
.job-foot:empty { display: none; }
.job-note { margin-right: auto; font-size: .8rem; color: var(--muted); }
.booklet { width: 54px; height: 70px; flex-shrink: 0; }
.booklet .sheet { fill: #f8fafc; stroke: var(--border); stroke-width: 1.5; }
.booklet .fold { fill: var(--card-2); stroke: var(--border); stroke-width: 1.5; }
.booklet .track { fill: #e2e8f0; }
.booklet .ink { fill: var(--primary); }
.job.is-done .booklet .ink { fill: var(--green); }
.job.is-error .booklet .ink { fill: var(--danger); }
.booklet .ink.pulse { animation: job-pulse 1.1s ease-in-out infinite; }
.job-page { max-width: 480px; margin: 6vh auto 0; display: flex; flex-direction: column; gap: .75rem; }
@keyframes job-spin { to { transform: rotate(360deg); } }
@keyframes job-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .job-steps li.is-current .job-mark, .booklet .ink.pulse { animation: none; } }
@media (max-width: 560px) {
  .job-scrim { place-items: end center; padding: 0; }
  .job-dialog { width: 100%; border-radius: 16px 16px 0 0; padding-bottom: calc(1.35rem + env(safe-area-inset-bottom)); }
  .job-page { margin-top: 2vh; }
}

/* ---------- Chargement d'une page ---------- */
.page-loader { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: rgba(3, 7, 18, .25); pointer-events: none; animation: page-loader-in .15s ease-out; }
:root[data-theme="light"] .page-loader { background: rgba(17, 24, 39, .12); }
.page-loader-box { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: 1.1rem 1.4rem; border-radius: var(--radius); background: var(--card); border: 1px solid var(--border-soft); box-shadow: var(--shadow); color: var(--text-2); font-size: .88rem; font-weight: 600; }
.page-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: job-spin .75s linear infinite; }
@keyframes page-loader-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .page-spinner { animation-duration: 2s; } .page-loader { animation: none; } }
@media print { .page-loader { display: none !important; } }

/* ---------- Contrôle technique : défaillances structurées ---------- */
.defects-editor { display: flex; flex-direction: column; gap: .5rem; border-radius: var(--radius-sm); container-type: inline-size; }
.defects-head, .defect-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 170px 92px 36px; gap: .5rem; align-items: center; }
.defects-head { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 0 .1rem; }
.defects-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.defect-row { border-left: 3px solid var(--border); padding-left: .45rem; }
.defect-row input, .defect-row select { min-height: 38px; padding: .45rem .6rem; font-size: .9rem; }
.defect-row .defect-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.defect-row.sev-critical { border-left-color: #ef4444; }
.defect-row.sev-major, .defect-row.sev-cv { border-left-color: var(--amber); }
.defect-row.sev-minor, .defect-row.sev-no_cv { border-left-color: #64748b; }
.defect-remove { width: 36px; height: 36px; }
.defects-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.defects-foot .hint { flex: 1 1 260px; }
.defect-list { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; color: var(--text-2); }
.defect-list li { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: .6rem; align-items: baseline; }
.defect-list .badge { justify-self: start; }
.defect-code-ro { font-size: .8rem; color: var(--muted); background: var(--card-2); padding: .05rem .35rem; border-radius: 5px; }
.defect-loc-ro { font-size: .75rem; font-weight: 700; color: var(--text-2); border: 1px solid var(--border); border-radius: 5px; padding: 0 .3rem; margin-left: .2rem; }
.defects-details { margin-top: .6rem; }
.defects-details > summary { cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--text-2); }
/* éditeur étroit (écran de vérification, téléphone) : le libellé prend toute la largeur */
@container (max-width: 780px) {
  .defects-head { display: none; }
  .defect-row { grid-template-columns: 130px minmax(0, 1fr) 92px 36px; grid-template-areas: "label label label rm" "code sev loc ."; row-gap: .4rem; padding: .5rem 0 .5rem .55rem; }
  .defect-row .defect-label { grid-area: label; }
  .defect-row .defect-code { grid-area: code; }
  .defect-row .defect-sev { grid-area: sev; }
  .defect-row .defect-loc { grid-area: loc; }
  .defect-row .defect-remove { grid-area: rm; }
}
@container (max-width: 420px) {
  .defect-row { grid-template-columns: minmax(0, 1fr) 80px 36px; grid-template-areas: "label label rm" "sev sev ." "code loc ."; }
}
@media (max-width: 760px) {
  .defect-list li { grid-template-columns: 1fr; gap: .15rem; }
}

/* ---------- Import de procès-verbaux ---------- */
.import-hint, .import-banner { display: flex; align-items: center; gap: .9rem; color: var(--text); text-decoration: none; margin-bottom: 1.25rem; }
.import-hint:hover, .import-banner:hover { text-decoration: none; border-color: var(--primary); }
.import-hint > span:nth-child(2), .import-banner > span:nth-child(2) { display: flex; flex-direction: column; gap: .15rem; flex: 1; min-width: 0; }
.import-hint > .icon:last-child { color: var(--muted); }
.import-hint-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--accent-2); flex-shrink: 0; }
.import-banner { border-left: 4px solid var(--primary); }
.import-banner.status-ready { border-left-color: var(--amber); }
.page-spinner.small { width: 26px; height: 26px; border-width: 3px; flex-shrink: 0; }
.warn-text { color: #fcd34d; }
:root[data-theme="light"] .warn-text { color: #b45309; }
.no-scroll { overflow: hidden; }

.ct-drop { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; margin-top: 1rem; padding: 1.6rem 1rem; border: 2px dashed var(--border); border-radius: var(--radius); cursor: pointer; transition: border-color .15s, background .15s; }
.ct-drop:hover, .ct-drop.is-over { border-color: var(--primary); background: var(--primary-soft); }
.ct-drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ct-drop .hint { max-width: 520px; }
.ct-drop-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--primary-soft); color: var(--accent-2); margin-bottom: .3rem; }
.ct-drop-icon .icon { width: 24px; height: 24px; }
.ct-files { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.ct-file { display: grid; grid-template-columns: 54px minmax(0, 1fr) 110px 36px; gap: .65rem; align-items: center; padding: .45rem .55rem; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); background: var(--card-2); }
.ct-file-type { font-size: .7rem; font-weight: 800; text-align: center; color: var(--text-2); border: 1px solid var(--border); border-radius: 6px; padding: .15rem 0; }
.ct-file-name { display: flex; flex-direction: column; min-width: 0; }
.ct-file-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.ct-file-name small { font-size: .78rem; }
.ct-file-bar { height: 6px; border-radius: 99px; background: var(--bg); overflow: hidden; visibility: hidden; }
.ct-file-bar > span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.ct-file[data-state="uploading"] .ct-file-bar, .ct-file[data-state="done"] .ct-file-bar { visibility: visible; }
.ct-file[data-state="done"] .ct-file-bar > span { background: var(--green); }
.ct-file[data-state="error"] { border-color: rgba(239, 68, 68, .5); }
.ct-file .icon-btn { width: 36px; height: 36px; font-size: 1.2rem; }
.ct-reading-text { margin: 0; color: var(--muted); max-width: 70ch; }
.ct-reading-text + .ct-reading-text { margin-top: .5rem; }
.ct-mask { margin-top: .25rem; }
.ct-mask .check > span { display: flex; flex-direction: column; gap: .2rem; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: job-spin .7s linear infinite; }

.ct-progress { max-width: 720px; display: flex; flex-direction: column; gap: 1rem; }
.ct-progress-head { display: flex; align-items: center; gap: 1.1rem; }
.ct-progress-head h2 { margin: 0 0 .15rem; }
.ct-progress-head p { margin: 0; }
.ct-ring { --p: 0; position: relative; width: 84px; height: 84px; flex-shrink: 0; }
.ct-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ct-ring circle { fill: none; stroke-width: 4; }
.ct-ring-track { stroke: var(--card-2); }
.ct-ring-value { stroke: var(--primary); stroke-linecap: round; stroke-dasharray: var(--p) 100; transition: stroke-dasharray .5s ease; }
.ct-ring span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: .95rem; font-variant-numeric: tabular-nums; }
.ct-steps li[hidden] { display: none; }
.ct-found { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; max-height: 300px; overflow-y: auto; font-size: .88rem; }
.ct-found:empty { display: none; }
.ct-found li { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: .6rem; align-items: center; padding: .35rem .55rem; border-radius: var(--radius-sm); background: var(--card-2); color: var(--muted); }
.ct-found li.ct-found-ready { color: var(--text); }
.ct-found li.ct-found-ready .job-mark { border-color: var(--green); background: var(--green); }
.ct-found li.ct-found-ready .job-mark::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.ct-found li.ct-found-reading .job-mark { border-color: var(--primary); border-right-color: transparent; animation: job-spin .8s linear infinite; }
.ct-found li.ct-found-error .job-mark { border-color: var(--danger); background: var(--danger); }
.ct-progress-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.ct-progress-foot .hint { flex: 1 1 300px; }
.ct-progress-foot form { margin: 0; }
.ct-fallback { display: flex; gap: .5rem; align-items: flex-start; margin: .6rem 0 0; padding: .6rem .75rem; border-radius: var(--radius-sm); background: rgba(245, 158, 11, .12); color: #fcd34d; font-size: .88rem; }
:root[data-theme="light"] .ct-fallback { color: #92400e; }
.ct-fallback .icon { width: 17px; height: 17px; flex-shrink: 0; margin-top: 2px; }
.ct-fallback[hidden] { display: none; }

.ct-summary { display: flex; flex-direction: column; gap: .6rem; }
.ct-summary-main { display: flex; align-items: center; gap: .9rem; }
.ct-summary-count { font-size: 2.2rem; font-weight: 800; line-height: 1; color: var(--primary); font-variant-numeric: tabular-nums; }
.ct-legend { display: flex; align-items: center; gap: .55rem; margin: 0; font-size: .85rem; color: var(--text-2); }
.ct-legend-swatch { width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--amber); background: rgba(245, 158, 11, .15); flex-shrink: 0; }
.ct-review-form { max-width: 1180px; }
.ct-review { border-left: 4px solid var(--border); transition: opacity .2s; }
.ct-review.result-favorable { border-left-color: var(--green); }
.ct-review.result-counter { border-left-color: var(--amber); }
.ct-review.result-critical { border-left-color: #ef4444; }
.ct-review.is-excluded { opacity: .55; }
.ct-review.is-excluded .ct-review-body, .ct-review.is-excluded .ct-warnings, .ct-review.is-excluded .ct-remark { display: none; }
.ct-review.has-errors { box-shadow: 0 0 0 2px rgba(239, 68, 68, .55), var(--shadow); }
.ct-review-head { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.ct-review-title { flex: 1; min-width: 180px; }
.ct-review-title h2 { margin: 0; font-size: 1.1rem; }
.ct-include { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .7rem; border-radius: 999px; border: 1px solid var(--border); font-weight: 700; font-size: .85rem; cursor: pointer; }
.ct-include input { width: 17px; height: 17px; accent-color: var(--green); margin: 0; }
.ct-include:has(input:checked) { border-color: var(--green); background: rgba(16, 185, 129, .12); }
.ct-warnings { list-style: none; margin: .8rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.ct-warnings li, .ct-remark { display: flex; gap: .5rem; align-items: flex-start; padding: .5rem .7rem; border-radius: var(--radius-sm); background: rgba(245, 158, 11, .12); color: #fcd34d; font-size: .86rem; }
.ct-remark { background: var(--primary-soft); color: var(--accent-2); margin: .6rem 0 0; }
:root[data-theme="light"] .ct-warnings li { color: #92400e; }
.ct-warnings .icon, .ct-remark .icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.ct-review-body { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 1.25rem; margin-top: 1rem; align-items: start; }
.ct-scan { display: flex; flex-direction: column; gap: .6rem; position: sticky; top: calc(var(--topbar-h) + 12px); }
.ct-thumb { display: block; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; overflow: hidden; cursor: zoom-in; position: relative; }
.ct-thumb img { display: block; width: 100%; height: auto; }
.ct-thumb > span { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; padding: .3rem .5rem; font-size: .75rem; font-weight: 700; color: #fff; background: linear-gradient(to top, rgba(0, 0, 0, .65), transparent); }
.ct-thumb > span .icon { width: 14px; height: 14px; }
.ct-thumb:hover, .ct-thumb:focus-visible { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.ct-fields { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.ct-fields .form-grid { margin-bottom: 0; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.field.is-uncertain > label::after { content: "à vérifier"; margin-left: .4rem; padding: .05rem .4rem; border-radius: 999px; font-size: .7rem; font-weight: 700; background: rgba(245, 158, 11, .18); color: #fcd34d; }
:root[data-theme="light"] .field.is-uncertain > label::after { color: #92400e; }
.field.is-uncertain input, .field.is-uncertain select { border-color: var(--amber); background: rgba(245, 158, 11, .08); }
.field.is-checked input, .field.is-checked select { border-color: rgba(16, 185, 129, .6); }
.defects-editor.is-uncertain { outline: 2px solid rgba(245, 158, 11, .55); outline-offset: 4px; }
.ct-parent, .ct-action { max-width: 520px; }
.ct-parent[hidden] { display: none; }
.ct-defects h3 { font-size: .95rem; margin-bottom: .5rem; }
.ct-notes > summary { cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--text-2); }
.ct-notes textarea { margin-top: .5rem; min-height: 60px; }
.ct-review-tools { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; border-top: 1px solid var(--border-soft); padding-top: .75rem; }
.ct-savebar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.ct-error p { margin: 0 0 .75rem; }

.ct-lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(3, 7, 18, .9); display: grid; grid-template-rows: auto 1fr; }
.ct-lightbox[hidden] { display: none; }
.ct-lightbox-bar { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; color: #e5e7eb; font-weight: 700; }
.ct-lightbox-bar span { flex: 1; }
.ct-lightbox-bar .icon-btn { color: #e5e7eb; }
.ct-lightbox-stage { overflow: auto; display: grid; place-items: center; padding: 0 3.5rem 1rem; }
.ct-lightbox-stage img { max-width: 100%; max-height: calc(100vh - 80px); background: #fff; cursor: zoom-in; border-radius: 4px; }
.ct-lightbox-stage.is-zoomed { place-items: start center; }
.ct-lightbox-stage.is-zoomed img { max-width: none; max-height: none; width: min(1600px, 180vw); cursor: zoom-out; }
.ct-lightbox-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer; display: grid; place-items: center; }
.ct-lightbox-nav.prev { left: .5rem; }
.ct-lightbox-nav.prev .icon { transform: rotate(180deg); }
.ct-lightbox-nav.next { right: .5rem; }
.ct-lightbox-nav[hidden] { display: none; }
@media (max-width: 760px) {
  .ct-review-body { grid-template-columns: 1fr; }
  .ct-scan { position: static; flex-direction: row; overflow-x: auto; padding-bottom: .25rem; }
  .ct-thumb { flex: 0 0 132px; }
  .ct-file { grid-template-columns: 46px minmax(0, 1fr) 36px; }
  .ct-file-bar { grid-column: 1 / -1; grid-row: 2; }
  .ct-lightbox-stage { padding: 0 .5rem 1rem; }
  .ct-progress-head { align-items: flex-start; }
  .ct-ring { width: 64px; height: 64px; }
}

/* ---------- Carburants : stations et prix ---------- */
.fuel-where { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .35rem; }
.fuel-where .icon { width: 16px; height: 16px; vertical-align: -3px; }
.fuel-fresh.is-old { color: #fcd34d; }
:root[data-theme="light"] .fuel-fresh.is-old { color: #92400e; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(16, 185, 129, .2); margin-right: .2rem; }
.fuel-filters { display: flex; flex-direction: column; gap: .85rem; margin-bottom: 1rem; }
.fuel-search { display: flex; gap: .5rem; align-items: stretch; }
.fuel-search input[type=search] { flex: 1; min-width: 0; }
.fuel-search .btn { flex-shrink: 0; }
.fuel-search .btn.is-busy .icon { animation: job-spin 1.2s linear infinite; }
.fuel-locate-msg { margin-top: -.35rem; color: #fcd34d; }
:root[data-theme="light"] .fuel-locate-msg { color: #92400e; }
.fuel-vehicle { display: flex; align-items: center; gap: .6rem; }
.fuel-vehicle select { max-width: 340px; }
.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg-btn { display: inline-flex; align-items: center; gap: .3rem; padding: .35rem .8rem; min-height: 34px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); font-size: .88rem; text-decoration: none; white-space: nowrap; }
.seg-btn:hover { background: var(--card-2); color: var(--text); text-decoration: none; }
.seg-btn .icon { width: 15px; height: 15px; }
.seg-btn[aria-current="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--text); font-weight: 600; }
:root[data-theme="light"] .seg-btn { color: var(--text-2); }
.seg-note { color: var(--muted); font-weight: 500; font-size: .8rem; }
.seg-joined { gap: 0; }
.seg-joined .seg-btn { border-radius: 0; margin-left: -1px; }
.seg-joined .seg-btn:first-child { border-radius: 999px 0 0 999px; margin-left: 0; }
.seg-joined .seg-btn:last-child { border-radius: 0 999px 999px 0; }
.seg-joined .seg-btn[aria-current="true"] { position: relative; z-index: 1; }
.fuel-options { display: flex; flex-wrap: wrap; gap: .6rem 1.25rem; align-items: center; }
.fuel-others { margin: -.25rem 0 1rem; }
.fuel-highlights { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.fuel-hl { display: flex; flex-direction: column; gap: .1rem; min-width: 0; padding: .85rem 1rem; border-radius: var(--radius); border: 1px solid var(--border-soft); background: var(--card); box-shadow: var(--shadow); color: var(--text); text-decoration: none; }
a.fuel-hl:hover { border-color: var(--border); text-decoration: none; }
:root[data-theme="light"] a.fuel-hl { color: var(--text); }
.fuel-hl-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.fuel-hl-value { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.fuel-hl-sub { font-size: .82rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.fuel-hl.is-best { border-color: rgba(16, 185, 129, .5); }
.fuel-hl.is-best .fuel-hl-value { color: #6ee7b7; }
:root[data-theme="light"] .fuel-hl.is-best .fuel-hl-value { color: #047857; }
.fuel-views { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.fuel-views.view-both { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; }
.fuel-views.view-both .fuel-map-card { position: sticky; top: 1rem; }
.fuel-views.view-map .station-list { order: 2; }
.fuel-views.view-map .station:not(.is-active), .fuel-views.view-map .fuel-out-note { display: none; }
.station-list { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.station { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem .9rem; padding: .85rem 1rem; border-radius: var(--radius); border: 1px solid var(--border-soft); background: var(--card); box-shadow: var(--shadow); scroll-margin: 5rem; cursor: pointer; }
.station:hover { border-color: var(--border); }
.station.is-active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow); }
.station-name { display: flex; align-items: center; gap: .35rem; font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
.fav-mark { display: inline-flex; color: #fbbf24; }
.fav-mark .icon { width: 16px; height: 16px; fill: currentColor; }
.station-place { margin: .1rem 0 0; font-size: .84rem; color: var(--muted); }
.station-price { text-align: right; }
.station-price b { display: block; font-size: 1.3rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.station-price span { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.station-price.is-best b { color: #6ee7b7; }
:root[data-theme="light"] .station-price.is-best b { color: #047857; }
.station-price.is-stale b { color: var(--text-2); }
.station-fuels { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .35rem; }
.fuel-tag { font-size: .75rem; border-radius: 6px; padding: .1rem .45rem; background: var(--card-2); color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fuel-tag.is-stale { opacity: .7; }
.fuel-tag.is-out { background: rgba(220, 38, 38, .15); color: #fca5a5; text-decoration: line-through; }
:root[data-theme="light"] .fuel-tag.is-out { color: #b91c1c; }
.station-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.station-tags { display: flex; flex-wrap: wrap; gap: .3rem; min-width: 0; }
.station-actions { display: flex; align-items: center; gap: .35rem; margin-left: auto; }
.station-actions form { margin: 0; }
.star-btn { width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.star-btn:hover { color: #fbbf24; }
.star-btn .icon { width: 18px; height: 18px; }
.star-btn[aria-pressed="true"] { color: #fbbf24; border-color: rgba(251, 191, 36, .5); background: rgba(251, 191, 36, .1); }
.star-btn[aria-pressed="true"] .icon { fill: currentColor; }
.station-more { position: relative; }
.station-more > summary { list-style: none; width: 36px; height: 36px; border: 1px solid var(--border); }
.station-more > summary::-webkit-details-marker { display: none; }
.station-more .icon { width: 17px; height: 17px; }
.station-rename { display: flex; flex-direction: column; gap: .45rem; width: 280px; cursor: default; }
.station-rename label { font-size: .85rem; font-weight: 600; color: var(--text-2); }
.fuel-map-card { padding: 0; overflow: hidden; }
/* la carte forme son propre empilement : ses calques (z-index 400 à 1000) restent sous le menu, la barre du haut et la barre du bas */
.fuel-map { position: relative; z-index: 0; isolation: isolate; height: min(68vh, 620px); min-height: 320px; background: var(--card-2); }
.view-map .fuel-map { height: min(72vh, 680px); }
.fuel-map.leaflet-container { font: inherit; background: var(--card-2); }
.fuel-map .leaflet-control-attribution { font-size: .68rem; background: rgba(255, 255, 255, .85); color: #374151; }
.fuel-map .leaflet-control-attribution a { color: #0369a1; }
.fuel-map .leaflet-bar a { background: var(--card); color: var(--text); border-bottom-color: var(--border); }
.fuel-map .leaflet-bar a:hover { background: var(--card-2); }
.fuel-marker { background: none; border: 0; }
.fuel-pin { position: absolute; left: 0; top: 0; transform: translate(-50%, calc(-100% - 7px)); display: block; padding: .15rem .45rem; border-radius: 7px; background: #ffffff; color: #111827; border: 1px solid rgba(17, 24, 39, .25); font: 800 .78rem/1.3 system-ui, sans-serif; font-variant-numeric: tabular-nums; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); cursor: pointer; }
.fuel-pin::after { content: ""; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 6px solid transparent; border-bottom: 0; border-top-color: #ffffff; }
.fuel-pin.is-fav { border-color: #f59e0b; }
.fuel-pin.is-best { background: #059669; color: #ffffff; border-color: #047857; }
.fuel-pin.is-best::after { border-top-color: #059669; }
.fuel-marker.is-active .fuel-pin { background: var(--primary); color: var(--on-primary); border-color: var(--primary-hover); transform: translate(-50%, calc(-100% - 7px)) scale(1.12); }
.fuel-marker.is-active .fuel-pin::after { border-top-color: var(--primary); }
.fuel-wait .empty, .fuel-locating .empty { padding: 2.5rem 1rem; }
.fuel-choice { display: flex; flex-direction: column; gap: 1rem; }
.fuel-choice-head h3 { margin: 0 0 .25rem; font-size: 1.1rem; }
.fuel-choice-head p { margin: 0; }
.fuel-choice-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .85rem; }
.fuel-choice-opt { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; margin: 0; padding: 1rem; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--card-2); }
.fuel-choice-opt h4 { margin: 0; font-size: .98rem; display: flex; align-items: center; gap: .45rem; }
.fuel-choice-opt h4 .icon { width: 18px; height: 18px; color: var(--accent); }
.fuel-choice-opt .hint { margin: 0; }
.fuel-choice-opt .fuel-locate-msg { margin: 0; }
.fuel-choice-city { display: flex; gap: .5rem; width: 100%; }
.fuel-choice-city input { flex: 1 1 auto; min-width: 0; }
.fuel-choice-city .btn { flex-shrink: 0; }
.fuel-choice-tip { display: flex; gap: .45rem; align-items: flex-start; margin: 0; }
.fuel-choice-tip .icon { width: 15px; height: 15px; flex-shrink: 0; margin-top: 3px; }
.fuel-spinner { margin-bottom: .25rem; }
.fuel-sources { margin-top: 1.25rem; }
@media (max-width: 900px) {
  .fuel-views.view-both { grid-template-columns: minmax(0, 1fr); }
  .fuel-views.view-both .fuel-map-card { position: static; order: -1; }
  .fuel-views.view-both .fuel-map { height: 300px; min-height: 0; }
  .view-map .fuel-map { height: 58vh; }
}
@media (max-width: 640px) {
  .fuel-search .btn span { display: none; }
  .fuel-filters { gap: .7rem; }
  /* filtres sur une ligne qui défile horizontalement */
  .fuel-filters > .seg, .fuel-options { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -1.25rem; padding: 0 1.25rem 2px; }
  .fuel-filters > .seg::-webkit-scrollbar, .fuel-options::-webkit-scrollbar { display: none; }
  /* bord droit estompé : d'autres choix suivent en faisant glisser */
  .fuel-filters > .seg, .fuel-options { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent); padding-right: 2.5rem; }
  .fuel-options { gap: .9rem; }
  .fuel-options .seg { flex-wrap: nowrap; flex-shrink: 0; }
  .seg-note { display: none; }
  .fuel-vehicle select { min-height: 38px; padding-block: .4rem; }
  .fuel-highlights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fuel-highlights > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .fuel-hl { padding: .7rem .8rem; }
  .fuel-hl-value { font-size: 1.15rem; }
  .station { padding: .75rem .8rem; }
  .station-price b { font-size: 1.15rem; }
  .station-rename { width: min(280px, calc(100vw - 48px)); }
}
@media (prefers-reduced-motion: reduce) { .fuel-search .btn.is-busy .icon { animation: none; } }

/* ---------- Saisie d'un plein : choix de la station ---------- */
.fuel-fields { margin-bottom: 1rem; }
.station-pick { display: flex; align-items: center; gap: .75rem; padding: .7rem .85rem; border-radius: var(--radius-sm); border: 1px dashed var(--border); margin-bottom: 1rem; }
.station-pick.is-set { border-style: solid; border-color: var(--primary); background: var(--primary-soft); }
.station-pick-icon { color: var(--muted); display: inline-flex; }
.station-pick.is-set .station-pick-icon { color: var(--accent-2); }
.station-pick-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.station-pick-text strong { overflow-wrap: anywhere; }
.station-pick-text span { font-size: .82rem; color: var(--muted); }
.station-pick-actions { display: flex; align-items: center; gap: .25rem; flex-shrink: 0; }
.station-pick-fuels { display: flex; flex-wrap: wrap; gap: .35rem; margin: -.5rem 0 1rem; }
.station-pick-fuels button { font: inherit; font-size: .78rem; padding: .2rem .55rem; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--text-2); cursor: pointer; font-variant-numeric: tabular-nums; }
.station-pick-fuels button[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--text); font-weight: 700; }
.station-pick-fuels button:disabled { text-decoration: line-through; opacity: .6; cursor: not-allowed; }
.quick-form .station-pick, .quick-form .station-pick-fuels { margin-bottom: 0; }
.quick-form .station-pick-fuels { margin-top: -.25rem; }
.field.is-auto input { border-color: rgba(16, 185, 129, .6); }
.station-sheet { width: min(560px, 100%); max-width: 100%; max-height: min(86vh, 760px); padding: 0; border: 1px solid var(--border-soft); border-radius: 16px; background: var(--card); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, .45); }
.station-sheet::backdrop { background: rgba(3, 7, 18, .6); }
.station-sheet[open] { display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; gap: .5rem; padding: .9rem 1rem .5rem; }
.sheet-head h2 { flex: 1; font-size: 1.05rem; }
.sheet-search { display: flex; gap: .5rem; padding: 0 1rem .6rem; }
.sheet-search input { flex: 1; min-width: 0; }
.sheet-body { overflow-y: auto; padding: 0 1rem 1rem; display: flex; flex-direction: column; gap: .45rem; overscroll-behavior: contain; }
.sheet-group { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: .4rem; }
.sheet-msg { font-size: .88rem; color: var(--text-2); padding: .5rem 0; display: flex; align-items: center; gap: .6rem; }
.sheet-note { font-size: .78rem; color: var(--muted); margin: .3rem 0 0; }
.pick { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem .75rem; width: 100%; padding: .65rem .8rem; border-radius: var(--radius-sm); border: 1px solid var(--border-soft); background: var(--bg); color: var(--text); text-align: left; font: inherit; cursor: pointer; }
:root[data-theme="light"] .pick { background: #fff; }
.pick:hover, .pick:focus-visible { border-color: var(--primary); }
.pick.is-current { border-color: var(--primary); background: var(--primary-soft); }
.pick-name { font-weight: 700; display: flex; align-items: center; gap: .3rem; overflow-wrap: anywhere; }
.pick-name .icon { width: 14px; height: 14px; color: #fbbf24; fill: currentColor; }
.pick-sub { font-size: .8rem; color: var(--muted); }
.pick-price { grid-column: 2; grid-row: 1 / span 2; align-self: center; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pick-price small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); }
@media (max-width: 640px) {
  .station-sheet { margin: auto 0 0; width: 100%; border-radius: 18px 18px 0 0; max-height: 88vh; border-bottom: 0; }
  .station-pick:not(.is-set) { flex-wrap: wrap; }
  .station-pick:not(.is-set) .station-pick-text { flex-basis: calc(100% - 3rem); }
  .station-pick:not(.is-set) .station-pick-actions { margin-left: auto; }
  .station-pick.is-set [data-station-open-label] { display: none; }
  .station-pick-fuels { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .station-pick-fuels button { flex-shrink: 0; white-space: nowrap; }
  .station-pick.is-set [data-station-open] { padding-inline: .55rem; }
}

/* ---------- Visionneuse des pièces jointes ---------- */
html.viewer-open, html.viewer-open body { overflow: hidden; }
.viewer { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0b0f17; color: #f3f4f6; color-scheme: dark; }
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: rgba(3, 7, 18, .9); }
.viewer-bar { display: flex; align-items: center; gap: .5rem; padding: calc(.55rem + env(safe-area-inset-top)) calc(.75rem + env(safe-area-inset-right)) .55rem calc(.9rem + env(safe-area-inset-left)); background: #111827; border-bottom: 1px solid rgba(255, 255, 255, .08); flex-shrink: 0; }
.viewer-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.viewer-title strong { font-size: .98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-title span { font-size: .78rem; color: #9ca3af; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; min-width: 40px; padding: .45rem .8rem; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .18); background: transparent; color: #f3f4f6; font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; flex-shrink: 0; }
:root[data-theme="light"] a.viewer-btn, a.viewer-btn:visited { color: #f3f4f6; }
.viewer-btn:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.viewer-btn[disabled] { opacity: .6; cursor: progress; }
.viewer-close { padding: .45rem; border-color: transparent; background: rgba(255, 255, 255, .1); }
.viewer-close .icon { width: 22px; height: 22px; }
.viewer-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 1rem calc(1rem + env(safe-area-inset-right)) calc(3.5rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left)); outline: none; }
.viewer-body.is-image { display: grid; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
.viewer-stage { display: grid; place-items: center; min-width: 0; min-height: 0; }
.viewer-image { display: block; max-width: 100%; max-height: calc(100vh - 7rem); max-height: calc(100dvh - 7rem); object-fit: contain; background: #fff; cursor: zoom-in; }
.viewer-body.is-zoomed .viewer-image { max-width: none; max-height: none; width: min(200%, 2400px); cursor: zoom-out; }
.viewer-pages { display: flex; flex-direction: column; align-items: center; gap: .9rem; width: 100%; max-width: 980px; margin: 0 auto; }
.viewer-body.is-zoomed .viewer-pages { width: 200%; max-width: none; }
.viewer-page { position: relative; width: 100%; margin: 0; background: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .55); cursor: zoom-in; }
.viewer-body.is-zoomed .viewer-page { cursor: zoom-out; }
.viewer-page img { display: block; width: 100%; height: auto; }
.viewer-page:not(.is-loaded) { min-height: 160px; background: #e5e7eb; }
.viewer-page:not(.is-loaded)::after { content: ""; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 3px solid #cbd5e1; border-top-color: var(--primary); animation: job-spin .75s linear infinite; }
.viewer-page.is-broken { display: grid; place-items: center; min-height: 120px; background: #1f2937; color: #fca5a5; box-shadow: none; }
.viewer-count { position: absolute; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: .3rem .8rem; border-radius: 999px; background: rgba(17, 24, 39, .88); border: 1px solid rgba(255, 255, 255, .12); color: #f9fafb; font-size: .82rem; font-weight: 700; font-variant-numeric: tabular-nums; pointer-events: none; }
.viewer-loading { display: flex; flex-direction: column; align-items: center; gap: .75rem; padding: 18vh 1rem; color: #d1d5db; }
.viewer-other { max-width: 440px; margin: 12vh auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1rem; color: #d1d5db; }
.viewer-other > .icon { width: 56px; height: 56px; stroke-width: 1.5; color: #9ca3af; }
.viewer-other p { margin: 0; }
.viewer-other .btn { color: #fff; }
.viewer-note { max-width: 980px; margin: 0 auto .9rem; padding: .6rem .85rem; border-radius: 8px; background: rgba(245, 158, 11, .15); color: #fcd34d; font-size: .86rem; }
.viewer-text { max-width: 980px; margin: 0 auto; padding: 1rem 1.1rem; border-radius: 8px; background: #111827; border: 1px solid rgba(255, 255, 255, .08); color: #e5e7eb; font: .85rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .viewer-bar { gap: .35rem; }
  .viewer-btn span { display: none; }
  .viewer-btn { padding: .45rem; }
  .viewer-body { padding-left: calc(.5rem + env(safe-area-inset-left)); padding-right: calc(.5rem + env(safe-area-inset-right)); padding-top: .5rem; }
  .viewer-pages { gap: .6rem; }
}
@media (prefers-reduced-motion: reduce) { .viewer-page:not(.is-loaded)::after { animation-duration: 2s; } }
@media print { .viewer { display: none !important; } }

/* ---------- Liste des dépenses : intertitres par mois, liste compacte sur téléphone ---------- */
.month-name { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.month-name::first-letter { text-transform: uppercase; }
.month-total { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.month-total b { color: var(--text); font-weight: 700; }
.table tr.month-row th { background: var(--surface-3); padding: 9px 14px; border-top: 1px solid var(--border-soft); }
.table tr.month-row th { text-align: left; }
.table tr.month-row th .month-total { float: right; }
.expense-list { display: none; }
/* liste compacte : téléphone et tablette (le tableau demande la largeur d'un ordinateur) */
@media (max-width: 1023px) {
  .expense-table { display: none; }
  .expense-list { display: flex; flex-direction: column; gap: .5rem; }
  .x-month { display: flex; flex-direction: column; gap: .35rem; }
  .x-month-head { position: sticky; top: var(--topbar-h); z-index: 4; display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; padding: .5rem .25rem .25rem; background: var(--bg); }
  .x-list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
  .x-row { position: relative; display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; column-gap: .65rem; row-gap: .05rem; padding: .65rem .8rem; border-top: 1px solid var(--border-soft); }
  .x-row:first-child { border-top: 0; }
  .x-row .dot { grid-row: 1; margin: .45rem 0 0; }
  .x-title { grid-column: 2; min-width: 0; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  a.x-title, :root[data-theme="light"] a.x-title { color: var(--text); text-decoration: none; }
  /* toute la ligne ouvre la modification ; les pastilles restent cliquables par-dessus */
  a.x-title::after { content: ""; position: absolute; inset: 0; }
  .x-row.is-link:hover, .x-row.is-link:focus-within { background: var(--card-2); }
  a.x-title:focus-visible { outline: none; }
  .x-row.is-link:has(a.x-title:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
  .x-amount { grid-column: 3; grid-row: 1; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .x-meta { grid-column: 2 / 4; min-width: 0; font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .x-extra { grid-column: 2 / 4; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; margin-top: .15rem; font-size: .8rem; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 0; }
  .x-extra .chip { position: relative; z-index: 1; margin: 0; }
  /* filtres resserrés : deux colonnes, la recherche se lance avec la touche Entrée du clavier */
  .expense-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem .7rem; padding: .85rem; }
  .expense-filters .field { min-width: 0; gap: .2rem; }
  .expense-filters .field > label { font-size: .78rem; }
  .expense-filters input, .expense-filters select { min-height: 38px; padding: .4rem .6rem; }
  .expense-filters .field.grow { grid-column: 1 / -1; }
  .expense-filters .filters-go { display: none; }
  /* dépenses récurrentes resserrées */
  .recurring-card { padding: .85rem; margin-bottom: .9rem; }
  .recurring-card > summary { font-size: .95rem; gap: .35rem; }
  .recurring-card > summary .muted { font-size: .85rem; }
  .recurring-card .list-row { align-items: flex-start; padding: .55rem 0; gap: .5rem; }
  .recurring-card .list-row strong { font-size: .95rem; }
  .recurring-card .list-row .badge { font-size: .7rem; padding: .05rem .45rem; }
  .recurring-card .list-row .small { font-size: .78rem; }
  .recurring-card .row-end { gap: .1rem; }
  .recurring-card .row-end .icon-btn { width: 34px; height: 34px; }
  .hide-mobile { display: none; }
}

/* ==========================================================================
   Recherche globale (loupe du tableau de bord)
   ========================================================================== */
.head-with-search { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex: 1 1 260px; min-width: 0; }
.search-open { flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.search-open:hover, .search-open:focus-visible { border-color: var(--primary); color: var(--accent); }
.search-open .icon { width: 22px; height: 22px; }
.search-open-page { overflow: hidden; }
.search-dialog { position: fixed; inset: 0; z-index: 70; display: flex; justify-content: center; align-items: flex-start; }
.search-backdrop { position: absolute; inset: 0; background: rgba(3, 7, 18, .6); }
.search-panel { position: relative; width: min(680px, 100%); max-height: min(80vh, 760px); margin-top: 8vh; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, .5); display: flex; flex-direction: column; overflow: hidden; }
.search-bar { display: flex; align-items: center; gap: .5rem; padding: .75rem; border-bottom: 1px solid var(--border-soft); }
.search-field { flex: 1; min-width: 0; display: flex; align-items: center; gap: .5rem; background: var(--card-2); border: 1px solid var(--primary); border-radius: 10px; padding: 0 .7rem; }
.search-field .icon { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.search-field input { flex: 1; min-width: 0; background: none; border: 0; color: var(--text); font-size: 1rem; padding: .65rem 0; outline: none; box-shadow: none; }
.search-close { background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; padding: .4rem; }
.search-chips { display: flex; gap: .4rem; overflow-x: auto; padding: .6rem .75rem 0; scrollbar-width: thin; }
.search-chips:empty { display: none; }
.chip-btn { flex-shrink: 0; border: 1px solid var(--border); background: var(--card-2); color: var(--text-2); border-radius: 999px; padding: .25rem .7rem; font-size: .8rem; font-weight: 600; cursor: pointer; }
.chip-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.search-count { margin: 0; padding: .45rem .9rem 0; font-size: .78rem; color: var(--muted); min-height: 1.4rem; }
.search-results { flex: 1; overflow-y: auto; padding: .25rem .5rem 1rem; display: flex; flex-direction: column; gap: .75rem; }
.search-group-title { margin: .4rem .4rem .2rem; font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; font-weight: 700; }
.search-hit { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: .65rem; padding: .55rem .5rem; border-radius: 10px; color: var(--text); text-decoration: none; }
.search-hit:hover, .search-hit:focus-visible { background: var(--card-2); text-decoration: none; }
:root[data-theme="light"] a.search-hit { color: var(--text); }
.search-hit-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--primary-soft); color: var(--accent); display: grid; place-items: center; }
.search-hit-icon .icon { width: 18px; height: 18px; }
.search-hit-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.search-hit-title { font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.search-hit-sub { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.search-hit-snippet { margin-top: .25rem; font-size: .8rem; color: var(--text-2); background: var(--card-2); border-left: 2px solid var(--primary); padding: .25rem .5rem; border-radius: 0 6px 6px 0; overflow-wrap: anywhere; }
.search-results mark { background: rgba(250, 204, 21, .35); color: inherit; border-radius: 3px; padding: 0 1px; }
:root[data-theme="light"] .search-results mark { background: #fde68a; }
.search-empty { padding: 1.5rem .75rem; color: var(--muted); text-align: center; display: flex; flex-direction: column; gap: .6rem; align-items: center; }
.search-empty-title { margin: 0; font-weight: 600; color: var(--text-2); font-size: .85rem; }
.search-chips-inline { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }
.search-hit.is-active { background: var(--card-2); box-shadow: inset 0 0 0 1px var(--primary); }
@media (max-width: 720px) {
  .search-panel { width: 100%; max-height: none; height: 100%; margin-top: 0; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
}
/* PC : barre de recherche dans l'en-tête, résultats dans un panneau sous la barre */
.head-tools { display: flex; gap: .85rem; flex-wrap: wrap; align-items: flex-end; }
.search-inline { position: relative; width: 340px; }
.search-inline-field { position: relative; }
.search-inline-field > .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search-inline-field input { padding-left: 2.3rem; padding-right: 2.2rem; }
.search-inline-field input::-webkit-search-cancel-button { cursor: pointer; }
.search-kbd { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); min-width: 1.4rem; text-align: center; font: 600 .75rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 .3rem; background: var(--card-2); pointer-events: none; }
.search-inline input:focus ~ .search-kbd, .search-inline input:not(:placeholder-shown) ~ .search-kbd { display: none; }
.search-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; width: min(620px, calc(100vw - 2rem)); max-height: min(72vh, 680px); display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .45); overflow: hidden; }
.search-pop[hidden] { display: none; }
.search-pop.align-left { right: auto; left: 0; }
.search-pop .search-results { padding-bottom: .6rem; }
:root[data-theme="light"] .search-pop { box-shadow: 0 20px 50px rgba(15, 23, 42, .18); }


/* ==========================================================================
   Rappels constructeur
   ========================================================================== */
.recalls h2 .icon { color: var(--amber); }
.recall { border: 1px solid rgba(245, 158, 11, .45); background: rgba(245, 158, 11, .08); border-radius: 12px; padding: .9rem 1rem; display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.recall.is-concerned { border-color: rgba(220, 38, 38, .5); background: rgba(220, 38, 38, .07); }
.recall .badge { align-self: flex-start; }
.recall h3 { margin: 0; font-size: 1rem; }
.recall p { margin: 0; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; }
.checks li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: .5rem; color: var(--text-2); }
.checks .icon { width: 16px; height: 16px; margin-top: 2px; }
.checks .ok .icon { color: var(--green); }
.checks .unknown .icon { color: var(--muted); }
.recall-links, .recall-answers .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.recall-answers { display: flex; flex-direction: column; gap: .4rem; }
.recalls-done summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.recall-alerts { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.recall-alert { display: flex; gap: .7rem; align-items: flex-start; padding: .75rem 1rem; border-radius: 12px; border: 1px solid rgba(245, 158, 11, .45); background: rgba(245, 158, 11, .08); color: var(--text); text-decoration: none; }
.recall-alert:hover { border-color: #f59e0b; text-decoration: none; }
:root[data-theme="light"] a.recall-alert { color: var(--text); }
.recall-alert > .icon { width: 20px; height: 20px; color: var(--amber); flex-shrink: 0; margin-top: 2px; }
.recall-alert > span { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }

/* ==========================================================================
   Agenda
   ========================================================================== */
.cal-apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; }
.cal-apps .btn { justify-content: center; }
#cal-link { word-break: break-all; font-size: .8rem; }

/* ==========================================================================
   Compte et sécurité : appareils connectés (en direct) et activité récente
   ========================================================================== */
[data-devices] .card-head { flex-wrap: wrap; }
[data-devices] .card-head > div:first-child { flex: 1 1 240px; min-width: 0; }
.devices-summary { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .15rem 0 0; }
.live { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: live-pulse 2s infinite; }
.live.is-refresh .live-dot { animation: none; background: var(--accent); }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .55); } 70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
.devices { display: flex; flex-direction: column; }
.device { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: .75rem; align-items: center; padding: .75rem 0; border-top: 1px solid var(--border-soft); transition: background-color .8s, opacity .3s; }
.device:first-child { border-top: 0; }
.device.is-new { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.device.is-leaving { opacity: 0; }
.device-icon { position: relative; width: 44px; height: 44px; border-radius: 12px; background: var(--card-2); color: var(--text-2); display: grid; place-items: center; }
.device-icon .icon { width: 22px; height: 22px; }
.device-dot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--green); border: 2px solid var(--card); }
.device-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.device-name { font-weight: 650; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.device-status { display: inline-flex; align-items: center; gap: .35rem; font-size: .84rem; color: var(--muted); }
.device-status .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.device-status.is-online { color: #6ee7b7; }
:root[data-theme="light"] .device-status.is-online { color: #047857; }
.device-meta { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.device-actions { display: flex; justify-content: flex-end; }
.device-actions form { margin: 0; }
.revoke-confirm { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; font-size: .84rem; color: var(--text-2); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.activity { display: flex; flex-direction: column; }
.activity-day { font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: .7rem 0 .15rem; }
.activity-day:first-child { padding-top: 0; }
.activity-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: .65rem; align-items: center; padding: .5rem 0; border-top: 1px solid var(--border-soft); }
.activity-day + .activity-row { border-top: 0; }
.activity-row.is-new { animation: activity-in .3s ease; }
@keyframes activity-in { from { opacity: 0; transform: translateY(4px); } }
.activity-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--card-2); color: var(--text-2); }
.activity-icon .icon { width: 16px; height: 16px; }
.activity-icon.tone-ok { color: #6ee7b7; background: rgba(16, 185, 129, .14); }
.activity-icon.tone-bad { color: #fca5a5; background: rgba(239, 68, 68, .14); }
.activity-icon.tone-warn { color: #fcd34d; background: rgba(245, 158, 11, .14); }
.activity-icon.tone-info { color: var(--accent); background: var(--primary-soft); }
:root[data-theme="light"] .activity-icon.tone-ok { color: #047857; }
:root[data-theme="light"] .activity-icon.tone-bad { color: #b91c1c; }
:root[data-theme="light"] .activity-icon.tone-warn { color: #92400e; }
.activity-main { display: flex; flex-direction: column; min-width: 0; }
.activity-title { font-weight: 600; font-size: .9rem; }
.activity-meta { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.activity-time { font-size: .8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.activity-more { display: flex; justify-content: center; gap: .6rem; flex-wrap: wrap; padding-top: .5rem; }
.activity-more:empty { display: none; }
.activity-more .icon { transform: rotate(90deg); }
.activity-skeleton { height: 44px; width: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--card-2), var(--border-soft), var(--card-2)); background-size: 200% 100%; animation: activity-shimmer 1s linear infinite; }
@keyframes activity-shimmer { to { background-position: -200% 0; } }
.page-toast { position: fixed; left: 50%; bottom: 1.5rem; z-index: 66; transform: translate(-50%, 10px); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  display: flex; gap: .5rem; align-items: center; max-width: calc(100vw - 24px); background: var(--text); color: var(--bg); border-radius: 10px; padding: .6rem .9rem; font-size: .88rem; box-shadow: 0 16px 40px rgba(0, 0, 0, .35); }
.page-toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.page-toast .icon { width: 16px; height: 16px; }
@media (max-width: 767px) { .page-toast { bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 14px); } }
@media (max-width: 560px) {
  .device { grid-template-columns: 40px minmax(0, 1fr); }
  .device-icon { width: 40px; height: 40px; }
  .device-actions { grid-column: 2; justify-content: flex-start; }
  .revoke-confirm { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) { .live-dot, .activity-skeleton, .activity-row.is-new { animation: none; } .device, .page-toast { transition: none; } }
