:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --sidebar: #f8fafc;
  --ink: #0f172a;
  --mute: #475569;
  --line: #dce3ec;
  --line-strong: #c2ccd9;
  --accent: #0f766e;
  --accent-hover: #0b5c56;
  --accent-soft: #ecfdf5;
  --accent-ink: #065f46;
  --go: #047857;
  --go-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;
  --info: #1d4ed8;
  --info-soft: #eff6ff;
  --radius: 12px;
  --radius-sm: 8px;
  --focus: 0 0 0 3px rgba(15, 118, 110, .28);
  --shadow-float: 0 12px 32px rgba(15, 23, 42, .16);
}
html.dark {
  color-scheme: dark;
  --bg: #0b111a;
  --surface: #121b28;
  --surface-alt: #172233;
  --sidebar: #0e1622;
  --ink: #f1f5f9;
  --mute: #94a3b8;
  --line: #233145;
  --line-strong: #334660;
  --accent: #14b8a6;
  --accent-hover: #0d9488;
  --accent-soft: rgba(20, 184, 166, .14);
  --accent-ink: #5eead4;
  --go: #34d399;
  --go-soft: rgba(52, 211, 153, .14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .14);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, .14);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, .14);
  --focus: 0 0 0 3px rgba(20, 184, 166, .34);
  --shadow-float: 0 14px 36px rgba(0, 0, 0, .55);
}

*, *::before, *::after { box-sizing: border-box; }
::selection { background: var(--accent-soft); color: var(--accent-ink); }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  caret-color: var(--accent);
}
a { color: var(--accent); text-underline-offset: 3px; }
h1 { font-size: 1.375rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; margin: 4px 0 12px; text-wrap: balance; }
h2 { font-size: 1.02rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; margin: 22px 0 10px; color: var(--ink); }
.carte > h2:first-child { margin-top: 0; }
.sous { color: var(--mute); font-size: .875rem; }
.immat, .num, td, dd { font-variant-numeric: tabular-nums; }
.immat {
  font: 700 .98rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .04em;
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--line-strong);
  color: var(--ink);
}

/* Icons */
.ico { width: 18px; height: 18px; flex: 0 0 18px; stroke: currentColor; fill: none; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; }

/* App Shell — mobile top bar + bottom tabs, desktop sticky sidebar + workspace */
#app { min-height: 100dvh; }
.shell { display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1rem; letter-spacing: -.015em; }
.brand-dot {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: .9rem;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 6px 11px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface-alt); color: var(--ink);
  font: 500 .86rem/1 system-ui, sans-serif; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s;
}
.chip-btn:hover { border-color: var(--line-strong); background: var(--bg); }
.kbd { font: 600 .72rem ui-monospace, monospace; padding: 2px 5px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--mute); background: var(--surface); }

.sidebar { display: none; }
.contenu {
  flex: 1;
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 16px 14px calc(78px + env(safe-area-inset-bottom));
}
.mobile-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.mobile-nav a, .mobile-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 46px; padding: 4px 2px; border: 0; background: transparent;
  color: var(--mute); text-decoration: none; font: 600 .7rem/1.1 system-ui, sans-serif; border-radius: 8px; cursor: pointer;
}
.mobile-nav a[aria-current="page"], .mobile-nav a.cta-mob { color: var(--accent); }
.mobile-nav a.cta-mob { background: var(--accent-soft); }

/* Mobile drawer menu for secondary links */
.drawer-bg { position: fixed; inset: 0; z-index: 30; background: rgba(15, 23, 42, .45); display: flex; justify-content: flex-end; }
.drawer { width: min(300px, 84vw); background: var(--surface); height: 100%; padding: 18px 14px; overflow-y: auto; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }

/* Desktop Sidebar Shell */
@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar {
    grid-column: 1; grid-row: 1 / -1;
    position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 6px;
    padding: 14px 12px;
    background: var(--sidebar);
    border-right: 1px solid var(--line);
  }
  .topbar { grid-column: 2; grid-row: 1; padding: 10px 24px; }
  .topbar .topbar-brand { display: none; }
  .contenu { grid-column: 2; grid-row: 2; padding: 22px 24px 56px; }
  .mobile-nav { display: none; }
}
.side-head { display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: .98rem; letter-spacing: -.015em; }
.side-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 12px; margin-bottom: 10px; border-radius: 10px;
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; font-size: .9rem;
  transition: background .15s;
}
.side-cta:hover { background: var(--accent-hover); }
.side-grp { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); padding: 12px 10px 4px; }
.nav-lien {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--mute); text-decoration: none; font-weight: 500; font-size: .9rem;
  transition: background .15s, color .15s;
}
.nav-lien:hover { background: var(--bg); color: var(--ink); }
.nav-lien[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-badge { margin-left: auto; font-size: .74rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.user-pill { padding: 8px 10px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); font-size: .82rem; }
.user-pill strong { display: block; color: var(--ink); }

/* Toast messages */
#msg { position: fixed; right: 16px; bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 40; display: flex; flex-direction: column; gap: 8px; max-width: 380px; pointer-events: none; }
@media (min-width: 960px) { #msg { bottom: 20px; } }
#msg p {
  margin: 0; padding: 11px 14px; border-radius: 10px;
  background: #0f172a; color: #f8fafc; font-weight: 500; font-size: .9rem;
  box-shadow: var(--shadow-float);
}
html.dark #msg p { background: #e2e8f0; color: #0f172a; }
#msg p.erreur { background: var(--bad); color: #fff; }

/* Surfaces & KPI strip (single declared elevation: 1px border, no ghost shadows) */
.carte {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  margin-bottom: 12px;
}
a.carte { transition: border-color .15s, background .15s; }
a.carte:hover { border-color: var(--accent); background: var(--surface-alt); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
}
.kpi-lbl { font-size: .8rem; color: var(--mute); font-weight: 500; }
.kpi-val { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-sub { font-size: .78rem; color: var(--mute); }
.kpi.alerte { border-color: var(--warn); background: var(--warn-soft); }
.kpi.alerte .kpi-lbl, .kpi.alerte .kpi-sub { color: var(--warn); }

/* Buttons & Controls */
button, .bouton, label.bouton {
  font: 600 .9rem/1.2 system-ui, sans-serif;
  min-height: 42px; padding: 9px 14px; border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  cursor: pointer; text-align: center; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .15s, border-color .15s, color .15s;
}
button:hover, .bouton:hover, label.bouton:hover { border-color: var(--accent); color: var(--accent); }
button.plein, .bouton.plein, label.bouton.plein {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
button.plein:hover, .bouton.plein:hover, label.bouton.plein:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
button.actif { background: var(--ink); border-color: var(--ink); color: var(--surface); }
button.danger { border-color: var(--bad); color: var(--bad); background: var(--surface); }
button.danger:hover { background: var(--bad-soft); }
button:disabled { opacity: .48; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, label.bouton:focus-within {
  outline: none; box-shadow: var(--focus);
}
.large { display: flex; width: 100%; margin-top: 10px; }

/* Badges */
.pastille {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .76rem; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-alt); border: 1px solid var(--line); color: var(--mute); white-space: nowrap;
}
.pastille.ok { color: var(--go); background: var(--go-soft); border-color: transparent; }
.pastille.afaire { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pastille.retard { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.pastille.navette { color: var(--info); background: var(--info-soft); border-color: transparent; }

/* Rows, Grids, Forms, Tables */
.ligne { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.actions-ligne { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.actions-ligne button, .actions-ligne .bouton { min-height: 34px; padding: 6px 10px; font-size: .83rem; }
.onglets { display: flex; gap: 6px; margin: 10px 0; background: var(--surface); border: 1px solid var(--line); padding: 4px; border-radius: 10px; }
.onglets button { flex: 1; border: 0; min-height: 36px; background: transparent; color: var(--mute); }
.onglets button.actif { background: var(--accent); color: #fff; }

form.champs label, .champs label { display: block; margin-top: 11px; font-size: .84rem; font-weight: 600; color: var(--mute); }
input, select, textarea {
  font: inherit; width: 100%; min-height: 42px; margin-top: 4px; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[type=checkbox] { width: auto; min-height: 0; margin: 0 8px 0 0; accent-color: var(--accent); }
input[type=file].cache { position: absolute; opacity: 0; width: 1px; height: 1px; }
.consent { display: flex !important; align-items: flex-start; gap: 6px; font-weight: 400 !important; color: var(--ink) !important; margin-top: 14px !important; }
.deux { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 12px; align-items: end; }
.deux > * { min-width: 0; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: .92rem; }
dt { color: var(--mute); }
dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-weight: 500; }
meter { width: 100%; height: 8px; margin-top: 8px; border-radius: 99px; overflow: hidden; }
table.donnees { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.donnees th, table.donnees td { padding: 9px 6px; border-top: 1px solid var(--line); text-align: right; }
table.donnees th:first-child { text-align: left; }
table.donnees thead th { border-top: 0; color: var(--mute); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }

/* Photos & Proof */
table.photos { width: 100%; border-collapse: collapse; }
table.photos th { text-align: left; font-size: .82rem; color: var(--mute); padding: 6px; }
table.photos td { vertical-align: top; padding: 8px 6px; width: 50%; border-top: 1px solid var(--line); }
.vignette { display: inline-block; margin: 0 8px 8px 0; font-size: .75rem; color: var(--mute); text-decoration: none; }
.vignette img { display: block; width: 120px; height: 90px; object-fit: cover; border-radius: 8px; background: var(--surface-alt); border: 1px solid var(--line); }
ul.angles { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
ul.angles li { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; font-weight: 500; }
ul.angles li.fait { border-color: var(--go); background: var(--go-soft); color: var(--go); }
ul.angles li.courant { border-color: var(--accent); box-shadow: var(--focus); font-weight: 700; }
ul.journal { padding-left: 18px; color: var(--mute); font-size: .86rem; line-height: 1.6; }
details summary { cursor: pointer; padding: 6px 0; font-weight: 600; color: var(--accent); }
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.galerie figure { margin: 0; }
.galerie img { width: 100%; border-radius: 8px; display: block; }
.galerie figcaption { font-size: .8rem; color: var(--mute); margin-top: 4px; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .83rem; background: var(--surface-alt); border: 1px solid var(--line); padding: 10px; border-radius: 8px; max-height: 300px; overflow: auto; }
p.erreur { color: var(--bad); font-weight: 600; }
p.erreur:empty { display: none; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 12px 0 0; padding: 6px 14px 14px; }
fieldset legend { font-weight: 600; font-size: .86rem; color: var(--ink); padding: 0 6px; }
fieldset label { color: var(--ink) !important; font-weight: 500 !important; display: flex !important; align-items: center; }

/* Today columns, Navette & Big Screen */
.outils { display: grid; gap: 10px; margin-bottom: 12px; }
.recherche { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.colonnes section:not(.actif) { display: none; }
.colonnes h2 { display: none; }
.col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 10px; }
.col-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.navette-cols, .ecran-cols { display: grid; gap: 16px; margin-top: 12px; }
.ecran-barre { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 14px; }
.grand-ecran { max-width: none; padding: 18px 22px; }
.grand-ecran .immat { font-size: 1.15rem; padding: 3px 9px; }

/* Printable windshield card */
.carton-print { background: #fff; color: #0f172a; border: 2px solid #0f172a; border-radius: 12px; padding: 24px; max-width: 540px; margin: 16px auto; }
.carton-print .grosse-immat { font: 800 2.3rem ui-monospace, monospace; letter-spacing: 2px; text-align: center; border: 2px solid #0f172a; border-radius: 8px; padding: 10px; margin: 14px 0; }
.carton-print .cle-place { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: center; margin: 14px 0; }
.carton-print .cle-place div { border: 1px solid #0f172a; border-radius: 8px; padding: 10px; font-size: .8rem; font-weight: 600; }
.carton-print .cle-place strong { display: block; font-size: 1.65rem; margin-top: 2px; }

/* Command palette Ctrl+K */
.modal-k { position: fixed; inset: 0; background: rgba(15, 23, 42, .52); z-index: 35; display: flex; align-items: flex-start; justify-content: center; padding: 64px 14px; }
.modal-k > div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; width: 100%; max-width: 560px; box-shadow: var(--shadow-float); max-height: 75vh; overflow: auto; }

/* Login & Public Booking */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-box { width: 100%; max-width: 400px; }
.public-wrap { max-width: 680px; margin: 0 auto; padding: 20px 14px 56px; }
.public-head { margin-bottom: 16px; }
.public-head h1 { font-size: 1.6rem; margin-bottom: 4px; }
.devis-carte { background: var(--accent-soft); border-color: var(--accent); }
.devis-carte dt { color: var(--accent-ink); }
.devis-carte dd { color: var(--ink); font-weight: 700; }
.mention { color: var(--mute); font-size: .85rem; margin-top: 24px; }

/* Super-Admin Console */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86rem; }
.filtre-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filtre-bar input { flex: 1 1 220px; margin-top: 0; }
.filtre-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.filtre-pills button { min-height: 36px; padding: 6px 12px; font-size: .84rem; }
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 12px; }
.client-card { display: flex; flex-direction: column; gap: 10px; margin-bottom: 0; }
.client-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.client-meta div { display: flex; flex-direction: column; gap: 2px; }
.client-meta span { font-size: .74rem; color: var(--mute); }
.client-meta strong { font-size: .95rem; font-variant-numeric: tabular-nums; }
.secret-box { background: var(--go-soft); border: 1px solid var(--go); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.secret-box h2 { margin-top: 0; color: var(--go); }
.code-bloc { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; margin-top: 6px; }
.code-bloc pre { margin: 0; }
.mobile-nav.admin-mob { grid-template-columns: repeat(3, 1fr); }

@media (min-width: 960px) {
  .outils { grid-template-columns: 1.2fr 1fr auto; align-items: center; }
  .onglets { display: none; }
  .colonnes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .colonnes section:not(.actif) { display: block; }
  .colonnes h2 { display: flex; margin: 6px 0 10px; }
  .navette-cols, .ecran-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .etroit { max-width: 780px; }
}

@media print {
  .sidebar, .topbar, .mobile-nav, .outils, .onglets, .modal-k, #msg, button, .bouton, form { display: none !important; }
  .shell { display: block !important; }
  .contenu { padding: 0 !important; max-width: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .carte { border: 0; border-bottom: 1px solid #999; border-radius: 0; }
  .colonnes { display: block !important; }
  .colonnes section, .colonnes h2 { display: block !important; }
  .carton-print { border: 2px solid #000; margin: 0; max-width: none; }
}
