:root {
  --brand: #132a63; /* bleu marine du logo */
  --brand-2: #1d4b9b;
  --brand-light: #3b86d6; /* bleu clair du logo */
  --accent: #f59e0b;
  --accent-ink: #1f1300;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e2e8f0;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #94a3b8;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.06);
  --sidebar: 248px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1220;
    --surface: #111a2b;
    --surface-2: #0e1626;
    --line: #22304a;
    --ink: #e5edf7;
    --ink-2: #a8b6cc;
    --muted: #6b7a93;
    --ok-bg: #0f2e1d;
    --warn-bg: #33250a;
    --bad-bg: #3a1212;
    --info-bg: #10244a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0b1220;
  --surface: #111a2b;
  --surface-2: #0e1626;
  --line: #22304a;
  --ink: #e5edf7;
  --ink-2: #a8b6cc;
  --muted: #6b7a93;
  --ok-bg: #0f2e1d;
  --warn-bg: #33250a;
  --bad-bg: #3a1212;
  --info-bg: #10244a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--info); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
/* liste « À faire » de la page Paiements */
.todo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.todo-row:first-child { border-top: 0; padding-top: 0; }
.todo-row[data-d] { cursor: pointer; }
.todo-row > .badge { min-width: 92px; text-align: center; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

/* ---------- Layout ---------- */
.app { min-height: 100%; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: var(--brand); color: #dbe7f5; display: flex; flex-direction: column;
  padding: calc(16px + var(--safe-t)) 12px 16px; z-index: 20; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--brand); display: grid; place-items: center; font-weight: 900; font-size: 18px; }
/* logo officiel sur cartouche blanc (le logo est bleu marine, illisible sur fond sombre) */
.brand-logo { display: block; background: #fff; border-radius: 12px; padding: 10px 12px; margin: 2px 4px 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); }
.brand-logo img { display: block; width: 100%; height: auto; }
.brand-sub { color: #8fb0d6; font-size: 11px; text-align: center; margin: 0 0 14px; letter-spacing: 0.3px; }
.logo-card { display: block; background: #fff; border-radius: 14px; padding: 14px 18px; margin: 0 auto 16px; max-width: 300px; }
.logo-card img { display: block; width: 100%; height: auto; }
.logo-sm { height: 34px; width: auto; display: block; }
.brand b { font-size: 16px; letter-spacing: 0.5px; display: block; }
.brand small { color: #8fb0d6; font-size: 11px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: #c7d6ea; font-weight: 500; margin-bottom: 2px; position: relative;
}
.nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, 0.13); color: #fff; }
.nav a .ico { width: 22px; text-align: center; font-size: 17px; }
.nav .sep { height: 1px; background: rgba(255, 255, 255, 0.1); margin: 10px 8px; }
.nav .count { margin-left: auto; background: var(--accent); color: var(--brand); border-radius: 999px; font-size: 11px; font-weight: 800; padding: 1px 7px; }
.sidebar .me { margin-top: auto; padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); font-size: 13px; }
.sidebar .me a { color: #8fb0d6; }
.sidebar .me .app-version { margin-top: 6px; font-size: 11px; opacity: 0.75; }

.main { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; gap: 12px; align-items: center;
  padding: calc(10px + var(--safe-t)) 24px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.topbar .search { flex: 1; max-width: 560px; position: relative; }
.topbar .search input { width: 100%; padding: 10px 14px 10px 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.topbar .search::before { content: '🔍'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: 0.6; }
.topbar .mobile-brand { display: none; font-weight: 800; color: var(--brand); letter-spacing: 0.4px; }
.topbar .mobile-brand img { height: 30px; width: auto; display: block; background: #fff; border-radius: 8px; padding: 3px 6px; }
.icon-btn { position: relative; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; width: 42px; height: 42px; display: grid; place-items: center; cursor: pointer; font-size: 18px; flex-shrink: 0; }
.icon-btn .dot { position: absolute; top: -4px; right: -4px; background: var(--bad); color: #fff; border-radius: 999px; font-size: 10px; font-weight: 800; padding: 1px 5px; min-width: 18px; text-align: center; }
.content { padding: 22px 24px 40px; width: 100%; max-width: 1400px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); margin-bottom: 8px; font-size: 14px; }

.tabbar { display: none; }
.offline-bar { display: none; background: var(--warn); color: #fff; text-align: center; font-size: 13px; padding: 6px 12px; font-weight: 600; }
.offline-bar.show { display: block; }
.demo-bar { background: var(--info-bg); color: var(--info); font-size: 13px; padding: 8px 12px; border-radius: 10px; }

@media (max-width: 1023px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar { padding: calc(8px + var(--safe-t)) 14px 8px; }
  .topbar .mobile-brand { display: block; }
  .topbar .search { display: none; }
  .topbar .search.open { display: block; position: absolute; left: 10px; right: 10px; top: calc(8px + var(--safe-t)); max-width: none; }
  .content { padding: 16px 14px calc(96px + var(--safe-b)); }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b));
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--ink-2); padding: 4px 0; border-radius: 10px; position: relative; }
  .tabbar a .ico { font-size: 21px; line-height: 1; }
  .tabbar a.active { color: var(--brand); font-weight: 700; }
  :root[data-theme='dark'] .tabbar a.active, .tabbar a.active { color: var(--accent); }
  h1 { font-size: 21px; }
}

/* ---------- Cartes & éléments ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.pad0 { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; }
.stat { display: flex; gap: 12px; align-items: center; cursor: pointer; transition: transform 0.12s; }
.stat:hover { transform: translateY(-1px); }
.stat .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--surface-2); border: 1px solid var(--line); flex-shrink: 0; }
.stat .v { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat .l { color: var(--ink-2); font-size: 13px; }
.money-hero { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: 0; }
.money-hero .l { color: #b9cde6; }
.money-hero .big { font-size: 30px; font-weight: 800; margin: 4px 0 8px; }
.money-hero .bar { height: 8px; background: rgba(255, 255, 255, 0.15); border-radius: 99px; overflow: hidden; }
.money-hero .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.dotst { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dotst.ok { background: var(--ok); } .dotst.warn { background: var(--warn); } .dotst.bad { background: var(--bad); } .dotst.info { background: var(--info); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); padding: 10px 16px; border-radius: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; min-height: 42px; transition: filter 0.12s, transform 0.05s;
}
.btn:hover { filter: brightness(0.97); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 6px 11px; min-height: 34px; font-size: 13px; border-radius: 10px; }
.btn.lg { padding: 14px 22px; min-height: 52px; font-size: 16px; }
.btn.block { width: 100%; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); } }
:root[data-theme='dark'] .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.quick a { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: 14px; }
.quick a span { font-size: 22px; }
.quick a:hover { border-color: var(--accent); }

/* ---------- Listes & tableaux ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--ink); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--surface-2); }
.item .av { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-size: 20px; flex-shrink: 0; overflow: hidden; }
.item .av img { width: 100%; height: 100%; object-fit: cover; }
.item .t { font-weight: 650; }
.item .s { color: var(--ink-2); font-size: 13px; }
.alert-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); margin-bottom: 8px; }
.alert-item.warning { border-left: 4px solid var(--warn); }
.alert-item.danger { border-left: 4px solid var(--bad); }
.alert-item.info { border-left: 4px solid var(--info); }
.alert-item .ai { font-size: 20px; }
.empty { padding: 30px 16px; text-align: center; color: var(--ink-2); }
.empty .big { font-size: 36px; margin-bottom: 6px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-2); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
table.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
table.t tfoot td { font-weight: 800; background: var(--surface-2); }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 18px; }
.kv div small { display: block; color: var(--ink-2); font-size: 12px; }
.kv div b { font-weight: 650; word-break: break-word; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 600; color: var(--ink-2); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button .n { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; font-size: 11px; padding: 0 6px; margin-left: 4px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 9px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Formulaires ---------- */
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.form h3 { grid-column: 1 / -1; margin-top: 8px; color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field label .req { color: var(--bad); }
.input, .field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface);
  min-height: 44px; outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
.field textarea { min-height: 90px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; background: var(--surface); user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.check:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }

/* ---------- Modale & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade 0.15s; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); animation: pop 0.18s; }
.modal.wide { max-width: 900px; }
.modal.full { max-width: 1200px; height: calc(100vh - 32px); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); gap: 10px; }
.modal-b { padding: 18px; overflow-y: auto; flex: 1; }
.modal-f { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@media (max-width: 640px) {
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal, .modal.wide, .modal.full { max-width: none; border-radius: 18px 18px 0 0; max-height: 94vh; }
  .modal.full { height: 94vh; }
  .modal-f { padding-bottom: calc(14px + var(--safe-b)); }
  .modal-f .btn { flex: 1; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(12px) scale(0.98); opacity: 0; } }
.toasts { position: fixed; top: calc(14px + var(--safe-t)); right: 14px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 28px)); }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 500; animation: pop 0.2s; cursor: pointer; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.warn { background: var(--warn); color: #fff; }

/* ---------- QR / transfert ---------- */
.qr-box { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; justify-content: center; }
.qr-box .qr { width: 240px; height: 240px; padding: 12px; background: #fff; border-radius: 16px; border: 1px solid var(--line); }
.qr-box .qr svg { width: 100%; height: 100%; display: block; }
.pulse { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); } 70% { box-shadow: 0 0 0 12px rgba(245, 158, 11, 0); } 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); } }
.choice { display: grid; gap: 10px; }
.choice button { display: flex; gap: 14px; align-items: center; text-align: left; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
.choice button:hover { border-color: var(--accent); }
.choice button .ci { font-size: 28px; }
.choice button b { display: block; }
.choice button small { color: var(--ink-2); }

/* ---------- État des lieux ---------- */
.wizard-steps { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.wizard-steps::-webkit-scrollbar { display: none; }
.wizard-steps button { flex: 1; min-width: 110px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 9px 10px; text-align: left; cursor: pointer; }
.wizard-steps button small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.wizard-steps button b { font-size: 13px; }
.wizard-steps button.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.wizard-steps button.done small { color: var(--ok); }
.zone-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.zone-tabs button { border: 1px solid var(--line); background: var(--surface); padding: 9px 14px; border-radius: 11px; font-weight: 650; cursor: pointer; position: relative; }
.zone-tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.zone-tabs button .n { position: absolute; top: -7px; right: -7px; background: var(--bad); color: #fff; border-radius: 99px; font-size: 10px; padding: 1px 6px; }
.sketch-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; }
@media (max-width: 900px) { .sketch-wrap { grid-template-columns: 1fr; } }
.sketch { position: relative; width: 100%; aspect-ratio: 2 / 1; background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.sketch svg, .sketch canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.sketch canvas { z-index: 2; }
.sketch .markers { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.sketch.mode-mark { cursor: crosshair; }
.sketch.mode-draw { cursor: crosshair; }
.marker { position: absolute; transform: translate(-50%, -50%); width: 28px; height: 28px; border-radius: 50%; background: var(--bad); color: #fff; font-weight: 800; font-size: 13px; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); pointer-events: auto; cursor: pointer; }
.marker.old { background: #64748b; }
.marker.sel { outline: 3px solid var(--accent); }
.tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tools .btn.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.dmg { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--surface); }
.dmg.sel { border-color: var(--accent); }
.dmg .n { width: 24px; height: 24px; border-radius: 50%; background: var(--bad); color: #fff; display: inline-grid; place-items: center; font-size: 12px; font-weight: 800; flex-shrink: 0; }
.dmg.old .n { background: #64748b; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.thumb { position: relative; width: 74px; height: 74px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .x { position: absolute; top: 3px; right: 3px; background: rgba(0, 0, 0, 0.6); color: #fff; border: 0; border-radius: 50%; width: 22px; height: 22px; font-size: 12px; cursor: pointer; }
.thumb.add { display: grid; place-items: center; font-size: 26px; border-style: dashed; color: var(--ink-2); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photo-slot { border: 1px dashed var(--line); border-radius: 14px; overflow: hidden; background: var(--surface-2); aspect-ratio: 4/3; position: relative; display: grid; place-items: center; cursor: pointer; text-align: center; color: var(--ink-2); }
.photo-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-slot .lbl { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(0, 0, 0, 0.7)); color: #fff; font-size: 12px; font-weight: 700; padding: 14px 8px 6px; }
.fuel { display: flex; gap: 4px; }
.fuel button { flex: 1; height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-weight: 700; font-size: 12px; color: var(--ink-2); }
.fuel button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sig { border: 2px dashed var(--line); border-radius: 14px; background: #fff; position: relative; touch-action: none; height: 200px; }
.sig canvas { width: 100%; height: 100%; display: block; border-radius: 12px; }
.sig .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #94a3b8; pointer-events: none; font-size: 14px; }
.sig img { width: 100%; height: 100%; object-fit: contain; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare > div { padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); text-align: center; }
.compare b { font-size: 26px; display: block; }

/* ---------- Scanner ---------- */
.scan-stage { position: relative; background: #111; border-radius: 14px; overflow: hidden; touch-action: none; }
.scan-stage canvas { display: block; width: 100%; height: auto; }
.scan-stage .h { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: rgba(245, 158, 11, 0.35); border: 3px solid var(--accent); touch-action: none; }
.pages { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.pages .pg { flex: 0 0 auto; width: 84px; height: 118px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); position: relative; background: #fff; }
.pages .pg img { width: 100%; height: 100%; object-fit: cover; }
.pages .pg span { position: absolute; bottom: 2px; left: 4px; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; }

/* ---------- Carte GPS ---------- */
.map { width: 100%; height: 520px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; z-index: 1; }
.map.small { height: 260px; }
.gps-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; }
@media (max-width: 1023px) { .gps-layout { grid-template-columns: 1fr; } .map { height: 420px; } }
.veh-pin { background: var(--brand); color: #fff; border-radius: 999px; padding: 3px 8px 3px 4px; font-size: 11px; font-weight: 800; white-space: nowrap; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); display: inline-flex; align-items: center; gap: 4px; }
.veh-pin.moving { background: var(--ok); }
.veh-pin.offline { background: #64748b; }
.veh-pin i { font-style: normal; width: 18px; height: 18px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); display: grid; place-items: center; font-size: 11px; }
.leaflet-div-icon { background: none !important; border: 0 !important; }

/* ---------- Versements ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day { border: 1px solid var(--line); border-radius: 12px; padding: 8px 6px; text-align: center; background: var(--surface); cursor: pointer; }
.day small { display: block; color: var(--ink-2); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.day .st { font-size: 20px; margin: 2px 0; }
.day .am { font-size: 11px; font-weight: 700; color: var(--ink-2); }
.day.paid { background: var(--ok-bg); border-color: transparent; }
.day.missed { background: var(--bad-bg); border-color: transparent; }
.day.partial { background: var(--warn-bg); border-color: transparent; }
.day.rest, .day.off, .day.none { opacity: 0.6; }
.day.today { outline: 2px solid var(--accent); }

/* ---------- Connexion ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, var(--brand-2), var(--brand) 60%); }
.auth .card { width: 100%; max-width: 420px; padding: 28px; }
.logo-big { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: var(--brand); font-weight: 900; font-size: 30px; display: grid; place-items: center; margin: 0 auto 12px; }

.loading { display: grid; place-items: center; padding: 60px; color: var(--ink-2); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }

.dossier { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.dossier > div { display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.dossier .ok { color: var(--ok); }
.dossier .ko { color: var(--warn); }

/* Historique (fiche locataire) */
.tl { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.tl:first-of-type { border-top: 0; }
.tl .ti { flex: 0 0 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.tl > div { min-width: 0; flex: 1; }
.tl s { text-decoration-thickness: 1px; }

/* Mise en route d'un contrat : caution → état des lieux → signature → remise */
.onb { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.onb > div { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.onb .num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--line); color: var(--ink); }
.onb .done { border-color: transparent; background: var(--ok-bg); }
.onb .done .num { background: var(--ok); color: #fff; }
.onb .current { border: 2px solid var(--accent); }
.onb .current .num { background: var(--accent); color: var(--accent-ink); }
.onb .locked { opacity: 0.55; }
.onb .acts { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 6px; }
@media (max-width: 900px) { .onb { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .onb { grid-template-columns: 1fr; } }

@media print {
  .sidebar, .topbar, .tabbar, .btn, .no-print { display: none !important; }
  .main { margin: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* avenants (changement de véhicule) */
.am-block { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--bg-soft, transparent); }
.am-block .dossier { grid-template-columns: 1fr; gap: 6px; }
.am-block .dossier > div { flex-wrap: wrap; }
.am-block .dossier .grow { min-width: 180px; }
.vdocs { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.vdocs > div { flex-wrap: wrap; }
.vdocs .grow { min-width: 120px; }

/* discussion d'un sinistre */
.chat-msgs { max-height: 460px; min-height: 140px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 6px 2px 10px; }
.chat-day { align-self: center; font-size: 11px; color: var(--muted); background: var(--line); border-radius: 999px; padding: 2px 10px; margin: 4px 0; }
.chat-msg { max-width: 82%; align-self: flex-start; display: flex; flex-direction: column; gap: 2px; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-who { font-size: 12px; }
.chat-role { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; margin-left: 4px; }
.chat-msg.staff .chat-role { color: var(--accent); border-color: var(--accent); }
.chat-bubble { background: var(--line); border-radius: 14px 14px 14px 4px; padding: 8px 12px; font-size: 14px; line-height: 1.4; word-break: break-word; }
.chat-msg.mine .chat-bubble { background: #1d4f9c; color: #fff; border-radius: 14px 14px 4px 14px; }
.chat-msg.mine .chat-bubble a { color: #fff; }
.chat-time { font-size: 11px; color: var(--muted); }
.chat-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chat-imgs img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; cursor: zoom-in; }
.chat-doc { display: block; margin-top: 6px; font-size: 13px; }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 10px; }
.chat-compose textarea { flex: 1; resize: none; min-height: 40px; }
.chat-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chat-files .chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 10px; }
.chat-files .chip button { border: 0; background: none; color: inherit; cursor: pointer; }
.chat-toast { display: flex; flex-direction: column; gap: 2px; text-decoration: none; background: var(--ink); color: var(--bg); border-left: 4px solid var(--accent); cursor: pointer; max-width: 340px; }
.chat-toast span { font-size: 13px; opacity: .9; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chat-toast small { font-size: 11px; opacity: .7; }

/* ---------- Mode démonstration : visite guidée et bulles d'aide ---------- */
body.tour-guided [data-tour-hide], body.tour-guided .nav .sep,
body.tour-guided .topbar .search, body.tour-guided #search-toggle, body.tour-guided .topbar a[href='#/alerts'] { display: none !important; }
.tour-back { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.55); z-index: 150; }
.tour-spot { position: fixed; z-index: 150; border-radius: 12px; pointer-events: none; box-shadow: 0 0 0 3px var(--accent), 0 0 0 9999px rgba(2, 6, 23, 0.4); transition: left 0.2s, top 0.2s, width 0.2s, height 0.2s; }
.tour-bubble { position: fixed; z-index: 160; width: 340px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow-y: auto; background: var(--surface); color: var(--ink); border: 2px solid var(--accent); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(2, 6, 23, 0.35); padding: 14px 16px; }
.tour-bubble.center { width: 440px; }
.tour-bubble h3 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }
.tour-bubble p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.tour-prog { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px; color: var(--accent); margin-bottom: 4px; }
.tour-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tour-links { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; }
.tour-links a { color: var(--muted); }
.tour-min { display: none; }
@media (max-width: 699px) {
  .tour-bubble { font-size: 15px; }
  .tour-bubble p { font-size: 15px; }
  .tour-bubble.dock-bottom, .tour-bubble.dock-top { left: 8px !important; right: 8px; width: auto; max-height: 42vh; padding: 12px 14px; }
  .tour-bubble.dock-bottom { top: auto !important; bottom: calc(72px + var(--safe-b)); }
  .tour-bubble.dock-top { top: calc(8px + var(--safe-t)) !important; }
  /* bouton réduire / agrandir */
  .tour-bubble:not(.center) .tour-min { display: grid; place-items: center; float: right; width: 34px; height: 34px; margin: -4px -6px 4px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); font-size: 16px; cursor: pointer; }
  .tour-min::before { content: '▾'; }
  .tour-bubble.min .tour-min::before { content: '▴'; }
  .tour-bubble.min p, .tour-bubble.min .tour-links { display: none; }
  .tour-bubble.min h3 { margin: 0; }
  .tour-bubble.min .tour-acts { margin-top: 8px; }
}
.tour-tip { position: fixed; z-index: 160; width: 260px; background: var(--ink); color: var(--bg); font-size: 13px; line-height: 1.45; padding: 10px 12px; border-radius: 10px; box-shadow: 0 8px 24px rgba(2, 6, 23, 0.3); pointer-events: none; }
.tour-fab { position: fixed; z-index: 90; left: 16px; bottom: calc(16px + var(--safe-b)); border: 0; border-radius: 999px; padding: 10px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 13px; cursor: pointer; box-shadow: 0 6px 18px rgba(2, 6, 23, 0.25); }
.tour-fab.second { bottom: calc(62px + var(--safe-b)); background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
@media (max-width: 1023px) { .tour-fab { bottom: calc(76px + var(--safe-b)); } .tour-fab.second { bottom: calc(122px + var(--safe-b)); } }
.tour-help { display: flex; gap: 12px; align-items: flex-start; background: var(--info-bg); border: 1px solid var(--info); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; color: var(--ink); }
.tour-help .ico { font-size: 20px; }
body.tour-explore .nav a[data-key]::after { content: 'ⓘ'; margin-left: auto; padding-left: 6px; opacity: 0.45; font-size: 12px; }
body.tour-explore .nav a[data-key='alerts']::after { content: none; }

/* ---------- Petits écrans (téléphone) ---------- */
@media (max-width: 640px) {
  /* onglets : on voit qu'il y en a d'autres (dégradé à droite), plus compacts */
  .tabs { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .tabs button { padding: 10px 10px; font-size: 14px; }
  /* fiches : deux colonnes au lieu d'une longue liste */
  .kv { grid-template-columns: 1fr 1fr; gap: 10px 14px; }
  /* cases à étapes / documents : bouton sous le texte quand la place manque */
  .dossier { grid-template-columns: 1fr; }
  .dossier > div { flex-wrap: wrap; }
  .dossier > div .grow { min-width: 150px; }
  /* en-tête de page : boutons sur toute la largeur, plus faciles à toucher */
  .page-head > .row { width: 100%; }
  .page-head > .row .btn { flex: 1 1 auto; justify-content: center; }
  .card-head { flex-wrap: wrap; gap: 6px; }
  .grid.c4 { grid-template-columns: 1fr 1fr; }
  .grid > * { min-width: 0; }
  .grid.c4 > a.card { padding: 12px; gap: 8px !important; }
  .grid.c4 > a.card b { font-size: 14px; }
  .alert-item { flex-wrap: wrap; }
  .chat-msg { max-width: 92%; }
  .chat-imgs img { width: 96px; height: 72px; }
  .list .item { flex-wrap: wrap; }
}