/* Back-office Siako SAV : barre latérale sur ordinateur, barre du haut + menu sur téléphone et tablette.
   Couleurs du plan d'exécution : bleu Siako, orange (validations), vert (terminé). Aucune police à télécharger. */
:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --fg: #172033;
  --muted: #5b6577;
  --line: #dde3ee;
  --brand: #1d3a8a;
  --brand-2: #16306f;
  --brand-soft: #e8edf9;
  --brand-ink: #ffffff;
  --side: #14295f;
  --side-2: #1d3a8a;
  --side-fg: #e9eefb;
  --accent: #e8771e;
  --accent-soft: #fdf0e4;
  --accent-ink: #9a4a0a;
  --ok: #1f8a5c;
  --ok-soft: #e3f3eb;
  --warn: #9a6200;
  --warn-soft: #fbefd5;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --shade: rgba(10, 18, 40, .5);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.m0 { margin: 0; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }

/* Démarrage et connexion */
.boot, .auth { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 12px; padding: 24px 16px; background: var(--side); color: var(--side-fg); text-align: center; }
.boot img { width: 220px; height: auto; }
.auth-card { width: min(420px, 100%); background: var(--surface); color: var(--fg); border-radius: 16px; padding: 24px; text-align: left; box-shadow: 0 30px 60px -30px rgba(0,0,0,.6); }
.auth-card .logo { display: block; width: 200px; height: auto; margin: 0 auto 8px; }
.auth-card h1 { text-align: center; }
.auth-card p.lead { text-align: center; color: var(--muted); margin: -4px 0 16px; }
.auth .foot { font-size: 12px; opacity: .75; }
.auth .foot a { color: inherit; }

/* Structure */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--side); color: var(--side-fg); display: flex; flex-direction: column; padding: 16px 12px; }
.side .brand { padding: 4px 8px 16px; }
.side .brand img { width: 170px; height: auto; display: block; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-fg); text-decoration: none; padding: 9px 10px; border-radius: 8px; font-weight: 600; font-size: 14px; opacity: .85; }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--side-2); opacity: 1; }
.nav a[aria-current="page"] { background: var(--side-2); opacity: 1; box-shadow: inset 3px 0 0 var(--accent); }
.nav .count { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; font-size: 12px; padding: 1px 8px; font-weight: 800; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(233,238,251,.18); font-size: 13px; }
.side .me b { display: block; }
.side .me span { opacity: .75; }
.topbar { display: none; }
.main { min-width: 0; padding: 22px 28px 48px; }
.main > .inner { max-width: 1180px; margin: 0 auto; }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); z-index: 70; transform: translateX(-102%); transition: transform .2s ease; }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: var(--shade); z-index: 65; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40; background: var(--side); color: var(--side-fg); padding: 10px 16px; }
  .topbar img { height: 30px; width: auto; }
  .topbar .menu { border: 1px solid rgba(233,238,251,.35); background: transparent; color: var(--side-fg); border-radius: 8px; padding: 6px 10px; font-weight: 700; }
  .topbar .t { margin-left: auto; font-size: 13px; font-weight: 600; opacity: .9; text-align: right; }
  .main { padding: 16px 16px 48px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

/* Typographie */
h1 { font-size: 24px; line-height: 1.15; margin: 0 0 4px; letter-spacing: -.2px; text-wrap: balance; }
h2 { font-size: 17px; margin: 0 0 10px; text-wrap: balance; }
h3 { font-size: 15px; margin: 0 0 6px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* Mise en page */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.stack > * { min-width: 0; }
.grid2 { display: grid; gap: 14px; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.grid-main { display: grid; gap: 14px; }
@media (min-width: 1040px) { .grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.panel > h2:first-child { margin-top: 0; }
.panel.accent { border: 2px solid var(--accent); background: var(--accent-soft); }
.panel.ok { border: 2px solid var(--ok); background: var(--ok-soft); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 9px; padding: 10px 16px; font-weight: 700; background: var(--brand); color: var(--brand-ink); text-decoration: none; white-space: nowrap; min-height: 42px; }
.btn:hover { background: var(--brand-2); }
.btn.accent { background: var(--accent); }
.btn.accent:hover { background: #d36813; }
.btn.ok { background: var(--ok); }
.btn.ghost { background: var(--surface); color: var(--fg); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--brand); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.btn.wa { background: #1f8a5c; }
.btn.sm { padding: 6px 11px; font-size: 13px; min-height: 34px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.link { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 700; text-decoration: underline; }

/* Indicateurs */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .kpis.six { grid-template-columns: repeat(6, minmax(0, 1fr)); } .kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; text-align: left; text-decoration: none; color: inherit; display: block; }
a.kpi:hover, button.kpi:hover { border-color: var(--brand); }
.kpi span { display: block; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kpi b { display: block; font-size: 26px; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.hot { border-color: var(--accent); background: var(--accent-soft); }
.kpi.hot b { color: var(--accent-ink); }
.kpi.bad { border-color: var(--bad); background: var(--bad-soft); }
.kpi.bad b { color: var(--bad); }
.kpi.good { border-color: var(--ok); background: var(--ok-soft); }

/* Pipeline des statuts */
.pipeline { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-bottom: 16px; }
@media (max-width: 700px) { .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pipe { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 10px; text-decoration: none; color: inherit; }
.pipe:hover { border-color: var(--brand); }
.pipe small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.pipe b { font-size: 20px; font-variant-numeric: tabular-nums; }
.pipe .bar { height: 4px; border-radius: 4px; background: var(--brand-soft); margin-top: 6px; overflow: hidden; }
.pipe .bar i { display: block; height: 100%; background: var(--brand); }

/* Listes de réparations */
.list { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-width: 0; text-align: left; width: 100%; color: inherit; text-decoration: none; }
a.item:hover { border-color: var(--brand); }
.item.new { border-left: 4px solid var(--accent); }
.item.late { border-left: 4px solid var(--bad); }
.item .t { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.item .s { font-size: 13px; color: var(--muted); min-width: 0; overflow-wrap: anywhere; grid-column: 1; }
.item .r { text-align: right; grid-row: 1 / span 2; grid-column: 2; display: grid; gap: 4px; justify-items: end; }
.empty { border: 1px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--fg); }

/* Étiquettes */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.tag.enregistre { background: var(--accent-soft); color: var(--accent-ink); }
.tag.devis_envoye { background: var(--warn-soft); color: var(--warn); }
.tag.pret, .tag.recupere, .tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.annule, .tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.grey { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* Formulaires */
.f { display: grid; gap: 5px; font-weight: 700; font-size: 14px; min-width: 0; }
.f .hint { font-weight: 400; font-size: 12px; color: var(--muted); }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid #c8d0de; border-radius: 9px; background: #fff; font-size: 15px; font-weight: 400; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(29,58,138,.15); }
.fields { display: grid; gap: 12px; }
@media (min-width: 700px) { .fields.c2 { grid-template-columns: 1fr 1fr; } .fields.c3 { grid-template-columns: 1fr 1fr 1fr; } .span2 { grid-column: span 2; } }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid #c8d0de; background: #fff; border-radius: 999px; padding: 5px 11px; font-weight: 600; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.err { color: var(--bad); font-weight: 700; margin: 0; }
.err:empty { display: none; }
.notice { border-radius: 10px; padding: 10px 12px; background: var(--brand-soft); color: var(--brand-2); font-size: 14px; margin: 0; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: #145c3d; }
.search { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search input { flex: 1 1 220px; }
.search select { flex: 0 1 200px; width: auto; }

/* Fiche réparation */
dl.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; white-space: pre-line; }
.stepper { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 6px 0 16px; list-style: none; padding: 0; }
.stepper li { font-size: 11px; font-weight: 700; color: var(--muted); text-align: center; }
.stepper li::before { content: ""; display: block; height: 6px; border-radius: 6px; background: var(--line); margin-bottom: 5px; }
.stepper li.done::before { background: var(--ok); }
.stepper li.now::before { background: var(--accent); }
.stepper li.now { color: var(--accent-ink); }
@media (max-width: 600px) { .stepper li span { display: none; } .stepper li.now span { display: inline; } .stepper { grid-template-columns: repeat(7, 1fr); } }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs a { display: block; width: 92px; height: 120px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.events li { display: grid; grid-template-columns: 12px 1fr; gap: 10px; font-size: 14px; }
.events li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--line); margin-top: 6px; }
.events li.status::before { background: var(--brand); }
.events li.note::before { background: var(--accent); }
.events li.decision::before { background: var(--ok); }
.events .w { color: var(--muted); font-size: 12px; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; background: var(--surface-2); }
.msg .b { font-size: 14px; white-space: pre-line; overflow-wrap: anywhere; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.t td.num, table.t th.num { text-align: right; }
table.t input { min-height: 36px; padding: 6px 8px; }
table.t input.n { width: 110px; text-align: right; }
table.t input.d { width: 70px; text-align: right; }

/* Graphique */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .grid { stroke: var(--line); }
.chart .b1 { fill: var(--brand); }
.chart .b2 { fill: var(--accent); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend .l1 { background: var(--brand); }
.legend .l2 { background: var(--accent); }
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) auto; gap: 10px; align-items: center; font-size: 14px; }
.hbar .track { height: 10px; background: var(--brand-soft); border-radius: 10px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--brand); border-radius: 10px; }

/* Fenêtres */
.sheet-bg { position: fixed; inset: 0; background: var(--shade); z-index: 90; display: grid; place-items: center; padding: 16px; }
.sheet { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 14px; padding: 18px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); }
.sheet.wide { width: min(860px, 100%); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; }
.sheet .close { border: 0; background: var(--surface-2); border-radius: 8px; width: 36px; height: 36px; font-size: 16px; }
@media (max-width: 600px) { .sheet-bg { place-items: end stretch; padding: 0; } .sheet { border-radius: 16px 16px 0 0; max-height: 92vh; width: 100%; } }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--fg); color: #fff; border-radius: 10px; padding: 10px 16px; font-weight: 700; z-index: 100; max-width: calc(100% - 32px); box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); }
.toast.alert { background: var(--accent); }
.bell { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 8px 12px; font-weight: 700; font-size: 13px; }
.bell[aria-pressed="true"] { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 9px 12px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.pw { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 20px; font-weight: 700; letter-spacing: 1px; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px; padding: 10px; text-align: center; }

/* Impression : bon de dépôt et reçu (A5) */
#printRoot { display: none; }
@media print {
  @page { size: A5 portrait; margin: 10mm; }
  body { background: #fff; }
  #app, #sheetRoot, #toast { display: none !important; }
  #printRoot { display: block; }
}
.doc { font-size: 11.5px; line-height: 1.4; color: #000; }
.doc .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; border-bottom: 2px solid #1d3a8a; padding-bottom: 6px; margin-bottom: 8px; }
.doc .head img { width: 150px; height: auto; }
.doc .head .shop { text-align: right; font-size: 10.5px; }
.doc h1 { font-size: 16px; margin: 0; letter-spacing: .06em; text-transform: uppercase; color: #1d3a8a; }
.doc .no { font-size: 22px; font-weight: 900; letter-spacing: .5px; margin: 2px 0 6px; }
.doc .cols { display: grid; grid-template-columns: 1fr 108px; gap: 10px; align-items: start; }
.doc .qr { text-align: center; font-size: 9.5px; }
.doc .qr svg { width: 108px; height: 108px; display: block; }
.doc table { width: 100%; border-collapse: collapse; margin: 4px 0 8px; }
.doc td { border: 1px solid #999; padding: 4px 6px; vertical-align: top; }
.doc td:first-child { width: 34%; background: #f1f3f8; font-weight: 700; }
.doc .big { font-size: 15px; font-weight: 800; }
.doc .terms { font-size: 9.5px; color: #333; border-top: 1px solid #999; padding-top: 6px; margin-top: 6px; }
.doc .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; font-size: 10.5px; }
.doc .sign div { border-top: 1px solid #000; padding-top: 4px; min-height: 40px; }
.doc .cut { border-top: 1px dashed #000; margin: 10px 0; text-align: center; font-size: 9px; }
.doc .stub { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.mt { margin-top: 12px; }
.f { align-content: start; }
.bell svg { width: 16px; height: 16px; vertical-align: -3px; }
.chart .b3 { fill: #9aa5b8; }
.legend .l3 { background: #9aa5b8; }
.grid-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.big-num { font-size: 26px; font-weight: 800; line-height: 1.2; margin-top: 2px; }
.split { display: grid; gap: 6px; }
.split div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.split div.total { border-top: 1px solid var(--line); padding-top: 6px; font-weight: 800; }
.parts-add { display: grid; grid-template-columns: minmax(0, 1fr) 72px auto; gap: 8px; align-items: end; }
a.notice { display: block; text-decoration: none; margin-bottom: 14px; font-weight: 600; }
