/* ---------------------------------------------------------------------------
   Gestion roues : interface de travail.
   Identité : gris acier bleuté, typographie condensée de panneaux routiers
   (Barlow), et l'étiquette d'emplacement jaune des rayonnages comme seul
   élément marqué.
--------------------------------------------------------------------------- */

@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url('/fonts/barlow-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url('/fonts/barlow-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url('/fonts/barlow-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 500; font-display: swap; src: url('/fonts/barlow-condensed-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url('/fonts/barlow-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url('/fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); }

:root {
  --ink: #17232f;
  --steel: #2d4b66;
  --steel-deep: #213a50;
  --steel-soft: #e3ebf2;
  --paper: #edf0f3;
  --surface: #ffffff;
  --line: #d3dae1;
  --line-strong: #aeb9c4;
  --muted: #566472;
  --tag: #f5c400;
  --tag-ink: #1d1700;
  --ok: #1b7448;
  --ok-soft: #dff1e7;
  --warn: #8f5200;
  --warn-soft: #fbecc9;
  --bad: #b3261e;
  --bad-soft: #f9e1df;
  --info: #28618f;
  --info-soft: #dfeaf4;
  --radius: 3px;
  --font: 'Barlow', 'Segoe UI', system-ui, sans-serif;
  --font-num: 'Barlow Condensed', 'Barlow', 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-num); font-weight: 600; margin: 0; line-height: 1.15; letter-spacing: 0.005em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 0.6em; }
a { color: var(--steel); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }
[hidden] { display: none !important; }
.boot { padding: 3rem; text-align: center; color: var(--muted); }
.num, .money { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: 0.01em; }
.money { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.87rem; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 0.9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ structure */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--ink);
  color: #dbe4ec;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.1rem 0 0.9rem;
}
.brand { padding: 0 1.2rem 1.1rem; font-family: var(--font-num); font-size: 1.55rem; font-weight: 700; color: #fff; line-height: 1; }
.brand small { display: block; font-family: var(--font); font-size: 0.78rem; font-weight: 400; color: #8fa2b4; margin-top: 0.35rem; }
.nav { display: flex; flex-direction: column; margin-top: 0.3rem; }
.nav a {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 1.2rem;
  color: #c3d0dc;
  text-decoration: none;
  border-left: 4px solid transparent;
  font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav a[aria-current='page'] { background: rgba(255, 255, 255, 0.09); color: #fff; border-left-color: var(--tag); }
.nav a:focus-visible { outline-color: var(--tag); outline-offset: -2px; }
.nav .sep { height: 1px; background: rgba(255, 255, 255, 0.12); margin: 0.6rem 1.2rem; }
.side-foot { margin-top: auto; padding: 0.8rem 1.2rem 0; border-top: 1px solid rgba(255, 255, 255, 0.12); font-size: 0.87rem; }
.side-foot .who { color: #fff; font-weight: 500; }
.side-foot .live { display: flex; align-items: center; gap: 0.45rem; color: #8fa2b4; margin: 0.25rem 0 0.6rem; }
.dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #6b7b8a; display: inline-block; }
.dot.on { background: #4cc38a; }
.dot.off { background: #e0675d; }
.side-foot button { background: none; border: 0; color: #c3d0dc; padding: 0.2rem 0; cursor: pointer; display: inline-flex; gap: 0.4rem; align-items: center; }
.side-foot button:hover { color: #fff; text-decoration: underline; }
.side-foot button:focus-visible { outline-color: var(--tag); }

.main { padding: 1.5rem 2rem 3rem; min-width: 0; }
.view-head { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.view-head h1 { margin-right: auto; }
.view-head .sub { color: var(--muted); margin-top: 0.2rem; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 0.5rem 0.8rem; gap: 0.4rem; }
  .brand { padding: 0 0.8rem 0 0; }
  .brand small { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; margin: 0; }
  .nav a { padding: 0.45rem 0.7rem; border-left: 0; border-bottom: 3px solid transparent; }
  .nav a[aria-current='page'] { border-bottom-color: var(--tag); }
  .nav .sep { display: none; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; gap: 0.8rem; align-items: center; }
  .side-foot .live { margin: 0; }
  .main { padding: 1rem 0.9rem 2.5rem; }
}

/* ------------------------------------------------------------------ boutons et champs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:hover { background: var(--steel-soft); border-color: var(--steel); }
.btn.primary { background: var(--steel); border-color: var(--steel-deep); color: #fff; }
.btn.primary:hover { background: var(--steel-deep); }
.btn.danger { color: var(--bad); border-color: #d9a6a2; }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: #8a1b15; color: #fff; }
.btn.danger.solid:hover { background: #8f1d17; }
.btn.small { padding: 0.28rem 0.6rem; font-size: 0.87rem; }
.btn.icon { padding: 0.32rem; }
.btn.flat { border-color: transparent; background: transparent; }
.btn.flat:hover { background: var(--steel-soft); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn svg, .icon-svg { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.field > label, .field > .lbl { font-size: 0.87rem; font-weight: 500; color: var(--muted); }
.field .hint { font-size: 0.82rem; color: var(--muted); }
input[type='text'], input[type='email'], input[type='tel'], input[type='date'], input[type='number'], input[type='password'], input[type='search'], select, textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 2.3rem;
}
textarea { min-height: 4.6rem; resize: vertical; }
input:disabled, select:disabled, textarea:disabled { background: #f3f5f7; color: #3c4854; }
input[type='checkbox'], input[type='radio'] { width: 1.05rem; height: 1.05rem; accent-color: var(--steel); }
.check { display: flex; align-items: center; gap: 0.5rem; }
.check label { font-size: 1rem; color: var(--ink); font-weight: 400; }
.grid { display: grid; gap: 0.8rem 1rem; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid .span2 { grid-column: span 2; }
.grid .span3 { grid-column: span 3; }
.grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } .grid .span2, .grid .span3 { grid-column: auto; } }

fieldset { border: 0; padding: 0; margin: 0 0 1.1rem; min-width: 0; }
legend { font-family: var(--font-num); font-weight: 600; font-size: 1.1rem; padding: 0; margin-bottom: 0.55rem; }
details.more { margin: 0 0 1.1rem; }
details.more > summary { cursor: pointer; font-family: var(--font-num); font-weight: 600; font-size: 1.1rem; margin-bottom: 0.55rem; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 0.42rem 0.85rem; cursor: pointer; font-weight: 500; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--steel-soft); }
.seg button[aria-pressed='true'] { background: var(--steel); color: #fff; }
.seg button:focus-visible { outline-offset: -3px; }

.tabs { display: flex; gap: 0.2rem; border-bottom: 2px solid var(--line); margin-bottom: 1.2rem; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 0.55rem 0.95rem; font-weight: 500; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; color: var(--muted); }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--steel); }

/* ------------------------------------------------------------------ tableaux */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel.pad { padding: 1.1rem 1.2rem; }
.toolbar { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.9rem; }
.toolbar .search { position: relative; flex: 1 1 18rem; max-width: 26rem; }
.toolbar .search svg { position: absolute; left: 0.6rem; top: 50%; transform: translateY(-50%); width: 1.05rem; height: 1.05rem; stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round; }
.toolbar .search input { padding-left: 2.1rem; }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; background: var(--surface); }
.tbl th { text-align: left; font-weight: 500; font-size: 0.87rem; color: var(--muted); padding: 0.55rem 0.8rem; border-bottom: 2px solid var(--line-strong); white-space: nowrap; background: #f6f8fa; position: sticky; top: 0; }
.tbl td { padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: #f3f7fa; }
.tbl tbody tr:focus-visible { outline: 2px solid var(--steel); outline-offset: -2px; }
.tbl .right, .tbl th.right { text-align: right; }
.tbl td.num { white-space: nowrap; }
.tbl .name { font-weight: 500; }
.tbl-foot { padding: 0.7rem 0.8rem; display: flex; gap: 1rem; align-items: center; color: var(--muted); border: 1px solid var(--line); border-top: 0; background: var(--surface); }
.empty { padding: 2.6rem 1rem; text-align: center; color: var(--muted); background: var(--surface); border: 1px solid var(--line); }
.empty strong { display: block; color: var(--ink); font-family: var(--font-num); font-size: 1.25rem; font-weight: 600; margin-bottom: 0.3rem; }

/* ------------------------------------------------------------------ pastilles */
.badge { display: inline-block; padding: 0.08rem 0.55rem; border-radius: 999px; font-size: 0.82rem; font-weight: 500; background: #e7ebef; color: #35424f; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.grey { background: #e7ebef; color: #4a5865; }

/* Étiquette d'emplacement : la plaque jaune des rayonnages (seul élément marqué de l'interface) */
.tag {
  display: inline-block;
  min-width: 3.4rem;
  padding: 0.12rem 1rem;
  text-align: center;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  color: var(--tag-ink);
  background:
    radial-gradient(circle at 0.5rem 50%, rgba(29, 23, 0, 0.55) 0.12rem, transparent 0.17rem),
    radial-gradient(circle at calc(100% - 0.5rem) 50%, rgba(29, 23, 0, 0.55) 0.12rem, transparent 0.17rem),
    var(--tag);
  border-radius: 2px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
  white-space: nowrap;
}
.tag.none { background: #e7ebef; color: var(--muted); box-shadow: none; font-weight: 500; font-family: var(--font); font-size: 0.87rem; padding: 0.1rem 0.7rem; }
.size { font-family: var(--font-num); font-weight: 600; font-size: 1.02rem; letter-spacing: 0.02em; white-space: nowrap; }

/* ------------------------------------------------------------------ boîtes de dialogue */
dialog { border: 0; padding: 0; border-radius: 6px; width: min(46rem, 94vw); max-height: 92vh; box-shadow: 0 18px 60px rgba(10, 20, 30, 0.35); color: var(--ink); background: var(--surface); }
dialog.wide { width: min(66rem, 96vw); }
dialog.narrow { width: min(30rem, 94vw); }
dialog::backdrop { background: rgba(18, 30, 42, 0.55); }
dialog[open] { animation: pop 0.14s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.dlg { display: flex; flex-direction: column; max-height: 92vh; }
.dlg-head { display: flex; align-items: center; gap: 1rem; padding: 0.9rem 1.2rem; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin-right: auto; }
.dlg-body { padding: 1.1rem 1.2rem; overflow: auto; }
.dlg-foot { display: flex; gap: 0.6rem; padding: 0.8rem 1.2rem; border-top: 1px solid var(--line); background: #f6f8fa; align-items: center; flex-wrap: wrap; }
.dlg-foot .spacer { margin-right: auto; }
.pdf-frame { width: 100%; height: 72vh; border: 1px solid var(--line); background: #6b7783; }

.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 50; max-width: min(26rem, 92vw); }
.toast { background: var(--ink); color: #fff; padding: 0.65rem 0.95rem; border-radius: var(--radius); box-shadow: 0 6px 24px rgba(10, 20, 30, 0.3); border-left: 5px solid #6fa8d6; animation: pop 0.14s ease-out; }
.toast.ok { border-left-color: #4cc38a; }
.toast.error { border-left-color: #ee7d73; }
.banner { padding: 0.65rem 0.95rem; border-radius: var(--radius); border: 1px solid; margin-bottom: 0.9rem; display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); border-color: #e3c37a; color: #5d3600; }
.banner.info { background: var(--info-soft); border-color: #a9c6df; color: #173f5f; }
.banner .grow { flex: 1 1 14rem; }
.error-text { color: var(--bad); font-weight: 500; }

/* ------------------------------------------------------------------ connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--ink); }
.login-box { width: min(25rem, 100%); background: var(--surface); border-radius: 6px; padding: 1.8rem 1.7rem 1.6rem; }
.login-box h1 { font-size: 2.3rem; margin-bottom: 0.2rem; }
.login-box .tagline { color: var(--muted); margin-bottom: 1.3rem; }
.login-box .field + .field { margin-top: 0.8rem; }
.login-box .btn { width: 100%; margin-top: 1.2rem; padding: 0.65rem; }

/* ------------------------------------------------------------------ accueil */
.work { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; align-items: start; }
@media (max-width: 1100px) { .work { grid-template-columns: 1fr; } }
.work h2 { margin: 0 0 0.5rem; }
.glance { display: flex; flex-wrap: wrap; gap: 0.4rem 1.6rem; margin-bottom: 1.3rem; font-size: 1.05rem; }
.glance strong { font-family: var(--font-num); font-size: 1.35rem; font-weight: 700; }
.shortcuts { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.4rem; }

/* ------------------------------------------------------------------ éditeur de document */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1.2rem; align-items: start; }
@media (max-width: 1150px) { .doc-layout { grid-template-columns: 1fr; } }
.doc-side { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: 1rem; }
@media (max-width: 1150px) { .doc-side { position: static; } }
.doc-title { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; margin-right: auto; }
.doc-title h1 .no { color: var(--steel); }
.lines { width: 100%; border-collapse: collapse; }
.lines th { text-align: left; font-weight: 500; font-size: 0.82rem; color: var(--muted); padding: 0.3rem 0.35rem; border-bottom: 2px solid var(--line-strong); white-space: nowrap; }
.lines td { padding: 0.35rem 0.35rem; vertical-align: top; border-bottom: 1px solid var(--line); }
.lines input, .lines select { min-height: 2.05rem; padding: 0.3rem 0.45rem; }
.lines .c-desc { min-width: 15rem; }
.lines .c-desc input + input { margin-top: 0.25rem; font-size: 0.9rem; color: var(--muted); }
.lines .c-qty { width: 4.6rem; }
.lines .c-unit { width: 4.2rem; }
.lines .c-price { width: 6.6rem; }
.lines .c-rem { width: 4.4rem; }
.lines .c-tva { width: 5.2rem; }
.lines .c-tot { width: 6.6rem; text-align: right; padding-top: 0.7rem; }
.lines .c-act { width: 5.6rem; white-space: nowrap; }
.lines input.money-in { text-align: right; font-family: var(--font-num); font-weight: 600; font-size: 1.05rem; }
.lines input[type='number'] { text-align: right; }
.line-tools { display: flex; gap: 0.6rem; margin-top: 0.8rem; flex-wrap: wrap; align-items: center; }
.menu { position: relative; }
.menu-list { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 16rem; max-height: 18rem; overflow: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(10, 20, 30, 0.2); padding: 0.25rem 0; }
.menu-list button { display: flex; width: 100%; justify-content: space-between; gap: 1rem; text-align: left; border: 0; background: none; padding: 0.45rem 0.8rem; cursor: pointer; }
.menu-list button:hover, .menu-list button:focus-visible { background: var(--steel-soft); outline: none; }
.menu-list .price { font-family: var(--font-num); font-weight: 600; }
.sum { padding: 1rem 1.1rem; }
.sum dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 1rem; }
.sum dt { color: var(--muted); }
.sum dd { margin: 0; text-align: right; font-family: var(--font-num); font-weight: 600; font-size: 1.08rem; font-variant-numeric: tabular-nums; }
.sum .total { border-top: 2px solid var(--ink); margin-top: 0.4rem; padding-top: 0.5rem; }
.sum .total dt { color: var(--ink); font-weight: 600; }
.sum .total dd { font-size: 1.6rem; }
.sum .due dd { color: var(--steel); font-size: 1.4rem; }
.actions { display: flex; flex-direction: column; gap: 0.5rem; padding: 1rem 1.1rem; }
.actions .btn { justify-content: flex-start; width: 100%; }
.actions .hr { height: 1px; background: var(--line); margin: 0.3rem 0; }
.combo { position: relative; }
.combo-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(10, 20, 30, 0.2); max-height: 17rem; overflow: auto; padding: 0.2rem 0; margin: 0; list-style: none; }
.combo-list li { padding: 0.45rem 0.7rem; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; }
.combo-list li[aria-selected='true'], .combo-list li:hover { background: var(--steel-soft); }
.combo-list li.new { border-top: 1px solid var(--line); color: var(--steel); font-weight: 500; }
.locked-note { display: flex; gap: 0.6rem; align-items: center; }

/* ------------------------------------------------------------------ paramètres */
.settings-sec { max-width: 52rem; }
.branch { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem 1rem; margin-bottom: 1rem; background: var(--surface); }
.branch h3 { margin-bottom: 0.6rem; }
.art-table input, .art-table select { min-height: 2rem; padding: 0.25rem 0.45rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.toolbar select { width: auto; min-width: 11rem; }
