/* Stock Motocash — palette reprise de la maquette validée (artifact « Stock Motocash »). */
:root {
  --bg: #f3f5f6; --surface: #ffffff; --ink: #15202b; --muted: #5b6873; --line: #dde3e7;
  --accent: #d9480f; --accent-soft: #fdebe2;
  --ok: #1f7a4d; --ok-bg: #e3f4ea; --res: #1d5fa8; --res-bg: #e2edf9;
  --wait: #8a5a00; --wait-bg: #fff1c7; --trial: #6b46c1; --trial-bg: #eee8fb;
  --fix: #a15c00; --fix-bg: #fbf0dc; --sea: #0f7686; --sea-bg: #dff2f4;
  --old: #b42318; --old-bg: #fde8e6;
  --display: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1519; --surface: #172026; --ink: #e6ecef; --muted: #93a1ab; --line: #26323a;
    --accent: #ff7a3d; --accent-soft: #3a2016;
    --ok: #5fd394; --ok-bg: #163327; --res: #7db4f0; --res-bg: #16283d;
    --wait: #f5c84c; --wait-bg: #3a2f10; --trial: #b79cf5; --trial-bg: #2a2140;
    --fix: #f0b45a; --fix-bg: #372a14; --sea: #5fcfdc; --sea-bg: #12313a;
    --old: #ff8a7f; --old-bg: #3b1a18;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--body); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: .01em; line-height: 1.1; }
h1 { font-size: clamp(26px, 5vw, 36px); margin: 0 0 12px; text-transform: uppercase; }
h2 { font-size: 22px; margin: 26px 0 10px; }
.vin { font-family: var(--mono); font-size: 13px; letter-spacing: .02em; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Couleurs des marques et des sites */
:root {
  --cfmoto: #0b74c4; --qjmotor: #7b3fb5; --zontes: #e08a00;
  --s-motocash: #d9480f; --s-mpn: #1565c0; --s-mps: #d32f2f;
  --nuit: #101a24;
}
@media (prefers-color-scheme: dark) { :root { --cfmoto: #4aa8ef; --qjmotor: #b88cf0; --zontes: #ffb340; --s-mpn: #5b9df0; --s-mps: #ff6b6b; --nuit: #0a1016; } }
body { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, var(--bg)) 0, var(--bg) 320px) no-repeat, var(--bg); }

/* En-tête et navigation */
.entete { background: var(--nuit); color: #fff; position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 10px rgba(0,0,0,.18); border-bottom: 3px solid var(--accent); }
.entete-haut { max-width: 1180px; margin: 0 auto; padding: 10px 16px 0; display: flex; align-items: center; gap: 12px; }
.logo { font-family: var(--display); font-size: 24px; font-weight: 700; text-transform: uppercase; color: #fff; letter-spacing: .02em; }
.logo:hover { text-decoration: none; }
.logo span { color: var(--accent); }
.qui { margin-left: auto; font-size: 13px; color: #b9c4cc; display: flex; gap: 10px; align-items: center; }
.qui form { margin: 0; }
.lien-bouton { background: none; border: 0; color: #ffb38a; font: inherit; cursor: pointer; padding: 0; }
.onglets { max-width: 1180px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.onglets::-webkit-scrollbar { display: none; }
.onglets a { padding: 10px 11px 9px; color: #b9c4cc; font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -3px; }
.onglets a:hover { text-decoration: none; color: #fff; }
.onglets a.actif { color: #fff; border-color: #fff; }

/* Repère de site : la bande du haut prend la couleur du site regardé */
.entete { border-bottom-width: 6px; transition: border-color .2s, background .2s; }
body.theme-mpn { --theme: var(--s-mpn); }
body.theme-mps { --theme: var(--s-mps); }
body.theme-motocash { --theme: var(--s-motocash); }
body[class*="theme-"] .entete { border-bottom-color: var(--theme); background: linear-gradient(90deg, var(--nuit) 55%, color-mix(in srgb, var(--theme) 55%, var(--nuit))); }
.repere-site { display: none; font: 700 15px var(--display); letter-spacing: .08em; text-transform: uppercase; color: #fff; padding: 3px 10px; border-radius: 6px; background: var(--theme); }
body.theme-mpn .repere-site::after { content: "MPN · Saint-Denis"; }
body.theme-mps .repere-site::after { content: "MPS · Saint-Pierre"; }
body.theme-motocash .repere-site::after { content: "Entrepôt Motocash"; }
body[class*="theme-"] .repere-site { display: inline-block; }
body[class*="theme-"] .seg a.actif { background: var(--theme); }
body[class*="theme-"] .kpi.actif { border-color: var(--theme); box-shadow: inset 0 0 0 1px var(--theme); }
@media (max-width: 480px) { .qui span { display: none; } }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; text-align: center; }

.page { max-width: 1180px; margin: 0 auto; padding: 16px 16px 60px; }
.messages { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.messages li { padding: 10px 12px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); font-weight: 500; }
.messages li.error { background: var(--old-bg); color: var(--old); }

/* Indicateurs */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: inherit; display: block; }
.kpi:hover { text-decoration: none; border-color: var(--muted); }
.kpi.actif { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.kpi .n { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.kpi { border-left: 5px solid var(--ink); }
.kpis .kpi:nth-child(2) { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok-bg) 55%, var(--surface)); }
.kpis .kpi:nth-child(2) .n { color: var(--ok); }
.kpis .kpi:nth-child(3) { border-left-color: var(--res); background: color-mix(in srgb, var(--res-bg) 55%, var(--surface)); }
.kpis .kpi:nth-child(3) .n { color: var(--res); }
.kpi.attention { border-left-color: var(--wait); background: color-mix(in srgb, var(--wait-bg) 55%, var(--surface)); }
.kpi.attention .n { color: var(--wait); }
.kpi.alerte { border-left-color: var(--old); background: color-mix(in srgb, var(--old-bg) 55%, var(--surface)); }
.kpi.alerte .n { color: var(--old); }

/* Barre de filtres */
.filtres { position: sticky; top: 88px; z-index: 5; background: var(--bg); padding: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.seg { display: flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 2px; }
.seg a { color: var(--muted); font-weight: 500; font-size: 14px; padding: 6px 11px; border-radius: 6px; }
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a.actif { background: var(--accent); color: #fff; }
.seg a small { opacity: .7; margin-left: 3px; }
select, input, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-width: 100%; }
input[type=search] { flex: 1 1 200px; min-width: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.compte { font-size: 13px; color: var(--muted); margin-left: auto; }

/* Cartes par modèle */
.marque { margin: 20px 0 8px; font-family: var(--display); font-size: 20px; font-weight: 700; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; display: flex; align-items: center; gap: 10px; }
.marque::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.carte { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.carte h3 { margin: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 22px; }
.carte h3 small { font-family: var(--body); font-size: 12.5px; font-weight: 500; color: var(--muted); }
.sites { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 10px 0 8px; }
.site { background: var(--bg); border-radius: 6px; padding: 5px 6px; text-align: center; }
.site .v { font-family: var(--display); font-size: 20px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.site .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.site.zero .v { color: var(--line); }
.site.s-motocash:not(.zero) { background: color-mix(in srgb, var(--s-motocash) 12%, var(--surface)); }
.site.s-motocash:not(.zero) .v { color: var(--s-motocash); }
.site.s-mpn:not(.zero) { background: color-mix(in srgb, var(--s-mpn) 12%, var(--surface)); }
.site.s-mpn:not(.zero) .v { color: var(--s-mpn); }
.site.s-mps:not(.zero) { background: color-mix(in srgb, var(--s-mps) 12%, var(--surface)); }
.site.s-mps:not(.zero) .v { color: var(--s-mps); }
.puce.site-motocash { color: #fff; background: var(--s-motocash); border: 0; }
.puce.site-mpn { color: #fff; background: var(--s-mpn); border: 0; }
.puce.site-mps { color: #fff; background: var(--s-mps); border: 0; }
/* Une couleur par marque */
.m-cfmoto { --marque: var(--cfmoto); } .m-qjmotor { --marque: var(--qjmotor); } .m-zontes { --marque: var(--zontes); }
h2.marque[class*="m-"] { color: var(--marque); }
h2.marque[class*="m-"]::before { content: ""; width: 6px; height: 22px; border-radius: 3px; background: var(--marque); }
h2.marque[class*="m-"]::after { background: linear-gradient(90deg, var(--marque), transparent); opacity: .5; }
.carte[class*="m-"] { border-top: 4px solid var(--marque); box-shadow: 0 1px 3px rgba(16, 26, 36, .06); }
.carte[class*="m-"] h3 { color: var(--ink); }
.carte { transition: box-shadow .15s, transform .15s; }
.carte:hover { box-shadow: 0 6px 18px rgba(16, 26, 36, .12); }
.couleurs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12.5px; color: var(--muted); }
.pastille { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--line); vertical-align: -1px; margin-right: 4px; }
.carte details { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.carte summary { cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 500; }
.mini { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.mini li { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }

/* Puces d'état */
.puce { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.p-dispo { color: var(--ok); background: var(--ok-bg); }
.p-resa { color: var(--res); background: var(--res-bg); }
.p-attente { color: var(--wait); background: var(--wait-bg); }
.p-essai { color: var(--trial); background: var(--trial-bg); }
.p-remise { color: var(--fix); background: var(--fix-bg); }
.p-neutre { color: var(--muted); background: var(--bg); border: 1px solid var(--line); }
.p-mer { color: var(--sea); background: var(--sea-bg); }
.p-alerte { color: var(--old); background: var(--old-bg); }
.age-orange { color: var(--fix); font-weight: 600; }
.age-rouge { color: var(--old); font-weight: 700; }

/* Tableaux */
.tableau { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.large { min-width: 760px; }

/* Liste en cartes sur téléphone */
@media (max-width: 640px) {
  .liste-motos table, .liste-motos thead, .liste-motos tbody, .liste-motos tr, .liste-motos td { display: block; }
  .liste-motos thead { display: none; }
  .liste-motos tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .liste-motos td { border: 0; padding: 2px 0; }
  .liste-motos td[data-l]::before { content: attr(data-l) " : "; color: var(--muted); font-size: 12.5px; }
  .liste-motos td.num { text-align: left; }
  .large { min-width: 0; }
}

/* Fiches, formulaires */
.bloc { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.fiche { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 18px; margin: 0; }
.fiche dt { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.fiche dd { margin: 2px 0 0; font-weight: 500; }
.titre-moto { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.titre-moto h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.bouton { display: inline-block; font: 600 15px var(--body); padding: 10px 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; text-align: center; }
.bouton:hover { text-decoration: none; filter: brightness(1.05); }
.bouton.second { background: var(--surface); color: var(--ink); border-color: var(--line); }
.bouton.danger { background: var(--surface); color: var(--old); border-color: var(--old); }
.bouton.petit { font-size: 13px; padding: 6px 10px; }
.formulaire { display: grid; gap: 14px; max-width: 560px; }
.formulaire label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.formulaire input, .formulaire select, .formulaire textarea { width: 100%; }
.formulaire .aide { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--old); font-size: 13px; font-weight: 500; }
.note { font-size: 13px; color: var(--muted); max-width: 75ch; }
.vide { padding: 36px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; }
.encart { padding: 10px 12px; border-radius: 8px; background: var(--wait-bg); color: var(--wait); font-size: 14px; margin-bottom: 12px; }

/* Réservations */
.resas { display: grid; gap: 10px; }
.resa { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 6px; }
.resa .haut { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.resa .refus { display: flex; gap: 6px; flex: 1 1 260px; }
.resa .refus input { flex: 1; min-width: 0; font-size: 14px; padding: 6px 8px; }

/* Tableau de bord */
.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.chiffre { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; border-top: 4px solid var(--accent); }
.grille .chiffre:nth-child(2) { border-top-color: var(--sea); }
.grille .chiffre:nth-child(3) { border-top-color: var(--old); }
.grille .chiffre:nth-child(4) { border-top-color: var(--res); }
.duel .camp:first-child { border-top: 5px solid var(--s-mpn); }
.duel .camp:first-child h3 { color: var(--s-mpn); }
.duel .camp:last-child { border-top: 5px solid var(--s-mps); }
.duel .camp:last-child h3 { color: var(--s-mps); }
th { background: color-mix(in srgb, var(--ink) 4%, var(--surface)); }
.bouton { box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 35%, transparent); }
.bouton.second, .bouton.danger { box-shadow: none; }
.chiffre .n { font-family: var(--display); font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.chiffre .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; }
.chiffre .s { font-size: 13px; color: var(--muted); margin-top: 4px; }
.barre { height: 10px; border-radius: 5px; background: var(--accent); min-width: 2px; }
.barre.b-1 { background: var(--ok); } .barre.b-2 { background: var(--wait); } .barre.b-3 { background: var(--fix); } .barre.b-4 { background: var(--old); } .barre.b-5 { background: var(--muted); }
.duel { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.duel .camp { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.duel .camp h3 { margin: 0 0 8px; font-size: 26px; }
.duel dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin: 0; font-size: 14px; }
.duel dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.duel dd.gagne { color: var(--ok); }

/* Droits */
.droits td.coche { text-align: center; }
.droits input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.droits tr.inactif td { opacity: .5; }
.connexion { max-width: 380px; margin: 8vh auto 0; }

@media (max-width: 820px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .filtres { top: 84px; } }
@media (max-width: 480px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compte { width: 100%; margin-left: 0; }
  .duel { grid-template-columns: 1fr; }
  .filtres { position: static; }
}
