/* Quai — interface. Inspiration : quai de chargement, marquage au sol jaune, étiquettes palettes. */
:root {
  --ink: #18212e;
  --ink-2: #243044;
  --ink-3: #33415a;
  --paper: #f3f4f1;
  --surface: #ffffff;
  --line: #d8dbd3;
  --line-soft: #e8eae4;
  --text: #18212e;
  --muted: #5d6675;
  --signal: #f2b705;
  --signal-soft: #fdf3cf;
  --ok: #1e7a4c;  --ok-soft: #e3f2ea;
  --warn: #a15c00; --warn-soft: #fbeedb;
  --bad: #b3261e; --bad-soft: #fbe6e4;
  --info: #2a5a8c; --info-soft: #e5eef7;
  --r: 6px;
  --font: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-cond: "Barlow Semi Condensed", "Barlow", "Arial Narrow", sans-serif;
  --hazard: repeating-linear-gradient(-45deg, var(--signal) 0 10px, var(--ink) 10px 20px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--text); font: 400 15px/1.5 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--info); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-cond); font-weight: 600; line-height: 1.2; margin: 0; }
h1 { font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 18px; }
code { background: var(--line-soft); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.strike { text-decoration: line-through; }
.lead { max-width: 72ch; color: var(--muted); margin: 0 0 16px; }
.back { margin: 0 0 12px; font-size: 14px; }
.back a { text-decoration: none; color: var(--muted); }
.warn-text { color: var(--warn); }
.late-text { color: var(--bad); font-weight: 600; }
.neg { color: var(--bad); } .pos { color: var(--ok); }

/* ---------- Coquille ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #c9d0db; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 14px; }
.brand-mark { width: 22px; height: 22px; border-radius: 3px; background: var(--hazard); flex: none; }
.brand-name { font: 700 22px/1 var(--font-cond); color: #fff; letter-spacing: .01em; }
.brand-tag { display: block; font: 500 12px/1.3 var(--font); color: #aab4c3; letter-spacing: 0; margin-top: 4px; }
.brand { align-items: flex-start; }
.brand-mark { margin-top: 1px; }
.side-tenant { padding: 0 20px 14px; font-size: 13px; color: #8f9aab; border-bottom: 1px solid var(--ink-2); }
.side nav { display: flex; flex-direction: column; padding: 10px 10px; gap: 1px; flex: 1; }
.side a { color: #c9d0db; text-decoration: none; padding: 8px 12px; border-radius: 4px; font-weight: 500; border-left: 3px solid transparent; }
.side a:hover { background: var(--ink-2); color: #fff; }
.side a.on { background: var(--ink-2); color: #fff; border-left-color: var(--signal); }
.side-foot { border-top: 1px solid var(--ink-2); padding: 10px; display: flex; flex-direction: column; gap: 1px; }
.side-foot small { display: block; color: #8f9aab; font-size: 12px; font-weight: 400; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 16px; padding: 18px 28px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.top h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: var(--r); font-size: 18px; padding: 4px 10px; cursor: pointer; }
.client-switch { display: flex; align-items: center; gap: 8px; }
.client-switch label { font-size: 13px; color: var(--muted); }
.client-switch select { font-weight: 600; min-width: 200px; }
.client-fixed { font: 600 15px var(--font-cond); padding: 6px 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); }
.content { padding: 24px 28px 96px; max-width: 1400px; width: 100%; }

.intervention { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 20px 10px 20px; background: var(--signal); color: var(--ink); font-weight: 500; border-bottom: 6px solid transparent; border-image: var(--hazard) 6; position: sticky; top: 0; z-index: 10; }
.intervention form { margin: 0; }

/* ---------- Blocs ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head .muted { font-size: 13px; }
details.panel > summary { cursor: pointer; list-style: none; margin: 0; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary h2::before { content: "▸ "; color: var(--muted); }
details.panel[open] > summary h2::before { content: "▾ "; }
details.panel[open] > summary { margin-bottom: 14px; }
.panel-bad { border-left: 4px solid var(--bad); }
.panel-warn { border-left: 4px solid var(--warn); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; align-items: start; }
.cols > .panel { margin-bottom: 0; }
.cols + .panel, .cols + .cols { margin-top: 18px; }
.empty { color: var(--muted); padding: 18px 0; margin: 0; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.plain li:last-child { border-bottom: 0; }

/* ---------- Tableau de bord ---------- */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; text-decoration: none; color: var(--text); border-top: 4px solid var(--line); }
a.tile:hover { border-color: var(--ink-3); color: var(--text); }
.tile strong { display: block; font: 700 40px/1 var(--font-cond); }
.tile span { display: block; margin-top: 6px; color: var(--muted); font-size: 14px; }
.tile-signal { border-top-color: var(--signal); }
.tile-bad { border-top-color: var(--bad); } .tile-bad strong { color: var(--bad); }
.tile-warn { border-top-color: var(--warn); } .tile-warn strong { color: var(--warn); }

.summary { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.summary > div { padding: 12px 20px; border-right: 1px solid var(--line-soft); }
.summary > div:last-child { border-right: 0; }
.summary strong { display: block; font: 700 30px/1 var(--font-cond); }
.summary span { font-size: 13px; color: var(--muted); }
.summary .is-bad strong { color: var(--bad); }
.summary .is-warn strong { color: var(--warn); }

/* Chiffres de stock : l'élément fort de l'interface */
.stockline { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 0; margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.stockfig { padding: 16px 20px; border-right: 1px solid var(--line-soft); }
.stockfig:last-child { border-right: 0; }
.stockfig .lbl { display: block; font-size: 13px; color: var(--muted); }
.stockfig strong { display: block; font: 700 30px/1.15 var(--font-cond); margin: 4px 0 2px; }
.stockfig small { color: var(--muted); }
.stockfig-main { background: var(--ink); color: #fff; }
.stockfig-main .lbl, .stockfig-main small { color: #aab4c3; }
.stockfig-main strong { font-size: 38px; }
.stockfig-main.is-low { box-shadow: inset 0 -6px 0 var(--signal); }

.orderhead { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.orderhead > div { padding: 12px 20px; border-right: 1px solid var(--line-soft); }
.orderhead > div:last-child { border-right: 0; }
.orderhead .lbl { display: block; font-size: 12px; color: var(--muted); }
.orderhead strong { font: 700 20px var(--font-cond); }
.addr { font-style: normal; line-height: 1.6; margin-bottom: 10px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tbody tr:hover { background: #fafbf8; }
.table tfoot td { border-top: 2px solid var(--line); border-bottom: 0; font-weight: 600; }
.table .num { text-align: right; white-space: nowrap; }
.table .chk { width: 32px; }
.table-compact td, .table-compact th { padding: 6px 8px; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { display: inline-block; vertical-align: top; margin-left: 4px; }
.table td a { text-decoration: none; }
.table td a:hover { text-decoration: underline; }
tr.is-off td { color: var(--muted); }
tr.is-low td.dispo { color: var(--warn); }
tr.is-low { box-shadow: inset 4px 0 0 var(--signal); }
tr.is-short { box-shadow: inset 4px 0 0 var(--bad); }
tr.is-short td.dispo, tr.is-short td strong { color: var(--bad); }
tr.is-late { box-shadow: inset 4px 0 0 var(--bad); }
tr.is-intervention { background: var(--signal-soft); }
.spec td { font-weight: 500; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 3px; font-size: 12px; font-weight: 600; white-space: nowrap; vertical-align: 1px; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-signal { background: var(--signal); color: var(--ink); }

/* ---------- Formulaires ---------- */
input, select, textarea { font: inherit; color: var(--text); background: #fff; border: 1px solid #c3c8bf; border-radius: 4px; padding: 7px 10px; min-height: 38px; max-width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--ink-3); outline: 2px solid var(--signal); outline-offset: 0; }
input[type=checkbox], input[type=radio] { min-height: 0; width: 17px; height: 17px; accent-color: var(--ink); vertical-align: -3px; }
input:disabled, select:disabled, fieldset:disabled input, fieldset:disabled select { background: var(--paper); color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; padding: 3px 0; }
label.check.is-adjusted { font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; align-items: end; margin-bottom: 14px; }
.grid-form .span-2 { grid-column: span 2; }
.form-actions { grid-column: 1 / -1; }
.radios { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.radios label { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filters input[type=search] { min-width: 240px; }
.filters .w-wide { min-width: 320px; }
.w-full { width: 100%; }
.w-num { width: 90px; text-align: right; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px 18px; margin-bottom: 18px; }
.map-grid label span { font-weight: 500; }
.map-grid label.is-required span { font-weight: 700; }
.upload { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; }
.drop { flex-direction: row; align-items: center; gap: 12px; border: 2px dashed #c3c8bf; border-radius: var(--r); padding: 18px 20px; cursor: pointer; background: var(--paper); min-width: 320px; }
.drop:hover { border-color: var(--ink-3); }
.drop input { border: 0; background: none; padding: 0; min-height: 0; }
.drop span { color: var(--muted); }
.drop.has-file { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.inline-edit { display: inline-block; position: relative; }
.inline-edit > summary { list-style: none; }
.inline-edit > summary::-webkit-details-marker { display: none; }
.inline-edit[open] > form { position: absolute; right: 0; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px; width: 340px; text-align: left; box-shadow: 0 10px 30px rgba(24, 33, 46, .18); white-space: normal; margin-top: 6px; }
.actions-grid { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.actions-grid .inline-edit[open] > form { left: 0; right: auto; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 14px/1 var(--font); padding: 10px 16px; min-height: 38px; border-radius: 4px; border: 1px solid #c3c8bf; background: #fff; color: var(--text); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-small { padding: 6px 10px; min-height: 30px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-3); border-color: var(--ink-3); color: #fff; }
.btn-signal { background: var(--signal); border-color: #d9a300; color: var(--ink); }
.btn-signal:hover { background: #ffc61a; color: var(--ink); border-color: #b88a00; }
.btn-ink { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-ghost { color: var(--bad); }
.btn-danger-ghost:hover { border-color: var(--bad); color: var(--bad); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.sticky-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px 0; background: linear-gradient(to top, var(--paper) 70%, rgba(243, 244, 241, 0)); margin-top: 8px; z-index: 4; }
.sticky-actions .muted { margin-right: auto; }

/* ---------- Onglets et segments ---------- */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; }
.seg a { padding: 7px 14px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 14px; border-right: 1px solid var(--line-soft); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--ink); color: #fff; }
.seg a b { font-weight: 700; margin-left: 4px; }
.seg a.is-late:not(.on) { color: var(--bad); }
.seg-tabs { margin-bottom: 16px; }

/* ---------- Messages ---------- */
.flash { padding: 12px 16px; border-radius: var(--r); margin: 0 0 16px; border-left: 4px solid; }
.content > .flash:first-child { margin-top: 0; }
.main > .flash { margin: 16px 28px 0; }
.flash-ok { background: var(--ok-soft); border-color: var(--ok); }
.flash-warn { background: var(--warn-soft); border-color: var(--warn); }
.flash-bad { background: var(--bad-soft); border-color: var(--bad); }
.flash-signal { background: var(--signal-soft); border-color: var(--signal); }
.flash .btn { margin-left: 8px; }

/* ---------- Historique ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 14px; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--ink-3); }
.timeline s { color: var(--muted); }

.pager { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 14px; }
.pager a, .pager strong, .pager span { padding: 4px 10px; border-radius: 4px; border: 1px solid var(--line); text-decoration: none; font-size: 14px; }
.pager strong { background: var(--ink); color: #fff; border-color: var(--ink); }
.pager span { border: 0; }

/* ---------- Connexion ---------- */
.login-page { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.login-art { background: var(--ink); color: #aab4c3; padding: 36px 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art .brand { padding: 0; }
.login-art .brand-name { font-size: 30px; }
.login-art .brand-mark { width: 30px; height: 30px; }
.login-art p { font: 500 22px/1.35 var(--font-cond); color: #fff; max-width: 22ch; margin: 0; }
.dock { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: end; }
.dock-door { height: 160px; background: #0e141d; border: 3px solid var(--ink-3); border-bottom: 8px solid var(--signal); border-radius: 3px 3px 0 0; position: relative; overflow: hidden; }
.dock-door::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: var(--shut, 100%); background: repeating-linear-gradient(to bottom, var(--ink-2) 0 12px, var(--ink-3) 12px 14px); }
.dock-door span { position: absolute; top: 6px; left: 0; right: 0; text-align: center; font: 700 16px var(--font-cond); color: var(--signal); z-index: 1; }
.dock-door:nth-child(2) { --shut: 55%; } .dock-door:nth-child(5) { --shut: 30%; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px; }
.card-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.card-form h1 { font-size: 32px; }

/* ---------- Installation ---------- */
.install-page { padding: 32px 16px; }
.install { max-width: 760px; margin: 0 auto; }
.install .brand { padding: 0 0 20px; }
.install .brand-name { color: var(--ink); }
.install h1 { margin-bottom: 12px; }
.install h2 { margin-top: 8px; }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { padding: 4px 0; }
.checks .ok { color: var(--ok); } .checks .ko { color: var(--bad); font-weight: 600; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease; z-index: 30; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(24, 33, 46, .45); }
  .menu-btn { display: inline-block; }
  .top { padding: 12px 16px; flex-wrap: wrap; }
  .top h1 { font-size: 21px; }
  .client-switch { order: 3; width: 100%; }
  .client-switch label { display: none; }
  .client-switch select { min-width: 0; flex: 1; }
  .client-fixed { order: 3; }
  .content { padding: 16px 16px 96px; }
  .cols { grid-template-columns: 1fr; }
  .stockline { grid-template-columns: 1fr; }
  .stockfig { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .grid-form .span-2 { grid-column: auto; }
  .filters input[type=search], .filters .w-wide { min-width: 0; width: 100%; }
  .login-page { grid-template-columns: 1fr; }
  .login-art { padding: 24px; gap: 24px; }
  .dock { display: none; }
  .inline-edit[open] > form { position: fixed; left: 12px; right: 12px; top: 20%; width: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .side, .top, .sticky-actions, .intervention, .btn, .filters { display: none !important; }
  .shell { display: block; } .content { padding: 0; } .panel { border: 0; padding: 0; }
}
