/* ==========================================================================
   WMS — design system
   Identité : bleu institutionnel, une couleur par flux
   (Inbound = bleu, Outbound = ambre, In Warehouse = vert).
   ========================================================================== */

:root {
  /* Marque & navigation */
  --nav-900: #0a1f33;
  --nav-800: #0d2a45;
  --nav-700: #143a5e;
  --primary: #1d6fb0;
  --primary-600: #175b91;
  --primary-50: #edf5fc;
  --primary-100: #d7e8f7;

  /* Flux */
  --in: #1d6fb0;      --in-bg: #edf5fc;
  --out: #c06a1e;     --out-bg: #fdf3e9;
  --wh: #1b8a5f;      --wh-bg: #eaf7f1;

  /* Neutres */
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e2e8ee;
  --line-strong: #cbd5df;
  --text: #13273b;
  --text-2: #3c5368;
  --muted: #5d7186;
  --subtle: #8a9aab;

  /* États */
  --success: #1b8a5f; --success-bg: #eaf7f1;
  --danger: #c23b3b;  --danger-bg: #fdeeee;
  --warning: #b8770f; --warning-bg: #fdf5e4;

  /* Ancienneté du stock */
  --age-ok: #1b8a5f; --age-warn: #b8770f; --age-late: #d0601c; --age-crit: #c23b3b;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 39, 61, .06);
  --shadow: 0 1px 2px rgba(16, 39, 61, .05), 0 8px 24px rgba(16, 39, 61, .06);
  --shadow-lg: 0 24px 60px rgba(10, 31, 51, .22);
  --ring: 0 0 0 3px rgba(29, 111, 176, .22);
  --ease: cubic-bezier(.22, .8, .24, 1);

  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
.icon { width: 18px; height: 18px; flex: none; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: #fff; padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }

/* ---------- Shell ---------- */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px;
  color: #c9d7e4;
  background: linear-gradient(180deg, var(--nav-800) 0%, var(--nav-900) 100%);
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; margin-bottom: 4px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: #fff; background: linear-gradient(135deg, #2f86cc, #1a5d95); box-shadow: 0 6px 16px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.2); }
.brand-mark .icon { width: 20px; height: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { color: #fff; font-size: 17px; letter-spacing: .04em; }
.brand-text small { font-size: 11.5px; color: #8fa7bd; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { margin: 14px 10px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #6f89a2; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: 10px;
  font-size: 13.5px; font-weight: 550; color: #c9d7e4;
  transition: background .18s ease, color .18s ease;
}
.nav-link .icon { color: #7f9bb5; transition: color .18s ease; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link:hover .icon { color: #c9d7e4; }
.nav-link.active { background: rgba(255,255,255,.1); color: #fff; }
.nav-link.active .icon { color: #6cb4ec; }
.nav-link.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: #6cb4ec; }

.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07); }
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.user-meta b { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { font-size: 11.5px; color: #8fa7bd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 50%; font-size: 12.5px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #3a8fd0, #1d5f95); }
.user-card .icon-btn { color: #9fb5ca; }
.user-card .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.sidebar-scrim { display: none; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); transition: background .15s ease, color .15s ease; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  height: 64px; padding: 0 28px;
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.crumb b { color: var(--text); font-weight: 650; }
.crumb-sep { width: 14px; height: 14px; color: var(--subtle); }
.quick-search { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
.quick-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--subtle); }
.quick-search input { width: 100%; height: 38px; padding: 0 40px 0 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 13.5px; outline: none; transition: border-color .15s, box-shadow .15s, background .15s; }
.quick-search input:focus { background: #fff; border-color: var(--primary); box-shadow: var(--ring); }
.quick-search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font: 600 11px var(--font); color: var(--subtle); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; background: #fff; }
.top-meta { display: flex; align-items: center; gap: 10px; }
.top-date { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.top-date .icon { width: 16px; height: 16px; }

.content { padding: 28px; max-width: 1640px; width: 100%; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- En-tête de page ---------- */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 22px; }
.page-header h1 { font-size: 26px; font-weight: 700; color: var(--text); }
.page-header p { margin: 6px 0 0; color: var(--muted); font-size: 14px; max-width: 720px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--primary); margin-bottom: 6px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.btn .icon { width: 17px; height: 17px; }
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--subtle); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(23,91,145,.3), inset 0 1px 0 rgba(255,255,255,.12); }
.btn.primary:hover:not(:disabled) { background: var(--primary-600); border-color: var(--primary-600); }
.btn.out { background: var(--out); border-color: var(--out); color: #fff; }
.btn.out:hover:not(:disabled) { background: #a65a16; border-color: #a65a16; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 34px; padding: 0 11px; font-size: 13px; }
.btn.full { width: 100%; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 0; background: none; color: var(--primary); font-size: 13px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-btn .icon { width: 15px; height: 15px; }
.link-btn.danger { color: var(--danger); }

/* ---------- Alertes & toasts ---------- */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: 18px; border-radius: 11px; border: 1px solid; font-size: 13.5px; animation: fadeUp .3s var(--ease) both; }
.alert > .icon { margin-top: 1px; }
.alert > span { flex: 1; }
.alert.success { background: var(--success-bg); border-color: #bfe5d3; color: #135f42; }
.alert.error { background: var(--danger-bg); border-color: #f2c7c7; color: #8f2626; }
.alert.info { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary-600); }
.alert-close { border: 0; background: none; color: inherit; opacity: .6; padding: 0; display: grid; }
.alert-close:hover { opacity: 1; }
.alert-close .icon { width: 16px; height: 16px; }

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 11px; background: var(--nav-800); color: #fff; font-size: 13.5px; box-shadow: var(--shadow-lg); animation: fadeUp .25s var(--ease) both; }

/* ---------- Tableau de bord ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  padding: 18px 18px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s;
}
a.kpi:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--line-strong); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; }
.kpi-icon .icon { width: 19px; height: 19px; }
.kpi.in .kpi-icon { background: var(--in-bg); color: var(--in); }
.kpi.out .kpi-icon { background: var(--out-bg); color: var(--out); }
.kpi.wh .kpi-icon { background: var(--wh-bg); color: var(--wh); }
.kpi.stock .kpi-icon { background: #f1eefb; color: #6449b8; }
.kpi-value { font-size: 32px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 6px; }
.kpi-value small { font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi-note { font-size: 12.5px; color: var(--muted); }
.kpi-note b { color: var(--text-2); font-weight: 600; }

.kpi-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.dash-grid.even { grid-template-columns: 1fr 1fr; }

.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-wrap { padding: 8px 18px 14px; }
.flow-chart { width: 100%; height: auto; display: block; }
.flow-chart .grid-line { stroke: var(--line); stroke-width: 1; }
.flow-chart .axis-label { fill: var(--subtle); font-size: 11px; font-family: var(--font); }
.flow-chart .bar-in { fill: var(--in); }
.flow-chart .bar-out { fill: var(--out); }
.flow-chart rect { transition: opacity .15s; }
.flow-chart g.day:hover rect { opacity: .75; }

.aging { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 14px; }
.aging-row { display: grid; grid-template-columns: 92px 1fr 44px; align-items: center; gap: 12px; font-size: 13px; }
.aging-row span:first-child { color: var(--text-2); }
.aging-row b { text-align: right; font-variant-numeric: tabular-nums; }
.aging-track { height: 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.aging-fill { height: 100%; border-radius: 99px; transform-origin: left; animation: grow .8s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.aging-total { display: flex; justify-content: space-between; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 13px; color: var(--muted); }

.recent-list { padding: 6px 8px 8px; }
.recent-row { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px; border: 0; border-radius: 10px; background: none; text-align: left; transition: background .15s; }
.recent-row:hover { background: var(--surface-2); }
.recent-row .dot { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; }
.recent-row .dot .icon { width: 17px; height: 17px; }
.recent-row .dot.in { background: var(--in-bg); color: var(--in); }
.recent-row .dot.out { background: var(--out-bg); color: var(--out); }
.recent-row b { display: block; font-size: 13.5px; font-weight: 650; }
.recent-row small { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-row > span:nth-child(2) { min-width: 0; }
.recent-row time { font-size: 12.5px; color: var(--muted); white-space: nowrap; text-align: right; }
.recent-row time b { display: inline; color: var(--text); font-size: 13px; }

/* ---------- Panneaux ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 20px; }
.dash-grid .panel { margin-bottom: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 15.5px; font-weight: 650; }
.panel-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- Filtres ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.filters .search-field { position: relative; flex: 1 1 280px; }
.filters .search-field .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--subtle); }
.filters .search-field input { padding-left: 34px; width: 100%; }
.filters input, .filters select { height: 38px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; font-size: 13.5px; outline: none; transition: border-color .15s, box-shadow .15s; }
.filters input:focus, .filters select:focus { border-color: var(--primary); box-shadow: var(--ring); }
.filters .date-range { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.filters .btn { height: 38px; }

/* ---------- Tableaux ---------- */
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.table-count b { font-weight: 650; }
.table-tools { display: flex; gap: 4px; }
.table-wrap { overflow: auto; max-height: calc(100vh - 290px); min-height: 220px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.data-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.data-table th {
  position: sticky; top: 0; z-index: 3;
  padding: 10px 12px; text-align: left; white-space: nowrap;
  background: #f5f7fa; color: var(--muted);
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid #edf1f5; color: var(--text-2); white-space: nowrap; vertical-align: middle; background: #fff; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover td { background: #f7fafd; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .t-num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .t-strong { color: var(--text); font-weight: 600; }
.data-table .t-clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.data-table .t-muted { color: var(--subtle); }
/* Colonne dossier figée à gauche */
.data-table .sticky-col { position: sticky; left: 0; z-index: 2; box-shadow: 1px 0 0 var(--line); }
.data-table th.sticky-col { z-index: 4; }
.sgl-link { display: inline-flex; align-items: center; gap: 7px; border: 0; padding: 0; background: none; font-weight: 650; color: var(--primary); font-size: 13px; }
.sgl-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.sgl-link .icon { width: 15px; height: 15px; opacity: .55; }
.data-table.compact td { padding-top: 6px; padding-bottom: 6px; }
.data-table.compact th { padding-top: 7px; padding-bottom: 7px; }
.data-table .col-hidden { display: none; }
.admin-table tbody tr { cursor: default; }
.admin-table td { white-space: normal; }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.pill .icon { width: 13px; height: 13px; }
.pill.ok { background: var(--success-bg); border-color: #c4e6d6; color: #146a48; }
.pill.off { background: var(--danger-bg); border-color: #f2cccc; color: #9b2c2c; }
.pill.sys { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary-600); }
.age { display: inline-block; min-width: 46px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 650; text-align: center; font-variant-numeric: tabular-nums; }
.age-ok { background: var(--success-bg); color: #146a48; }
.age-warn { background: var(--warning-bg); color: #8a5a07; }
.age-late { background: #fdeee3; color: #a64a12; }
.age-crit { background: var(--danger-bg); color: #9b2c2c; }

.stock-bar { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.stock-bar .track { flex: 1; height: 6px; border-radius: 99px; background: #e9eef3; overflow: hidden; }
.stock-bar .fill { height: 100%; border-radius: 99px; background: var(--wh); }
.stock-bar b { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 650; }

/* ---------- Menu déroulant ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 240px; max-height: 360px; overflow: auto; padding: 6px; border-radius: 12px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-lg); display: none; }
.dropdown-menu.open { display: block; animation: fadeUp .18s var(--ease) both; }
.dropdown-menu label { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.dropdown-menu label:hover { background: var(--surface-2); }
.dropdown-menu .menu-foot { display: flex; justify-content: space-between; padding: 8px 9px 4px; margin-top: 4px; border-top: 1px solid var(--line); }

/* ---------- États vides ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 44px 20px; text-align: center; color: var(--muted); font-size: 13.5px; white-space: normal; }
.empty-state .empty-icon { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 6px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); color: var(--subtle); }
.empty-state .empty-icon .icon { width: 24px; height: 24px; }
.empty-state strong { color: var(--text); font-size: 15px; font-weight: 650; }
.empty-state .btn { margin-top: 10px; }
.data-table tr.empty-row { cursor: default; }
.data-table tr.empty-row:hover td { background: #fff; }

/* ---------- Modales ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(8, 24, 40, .48);
  backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden;
  transition: opacity .2s ease, visibility .2s;
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal {
  width: min(760px, 100%); max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(.985);
  transition: transform .25s var(--ease);
}
.modal-backdrop.open .modal { transform: none; }
.modal:focus { outline: none; }
.modal.large { width: min(1080px, 100%); }
.modal.small { width: min(480px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px 24px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 19px; font-weight: 700; }
.modal-head p { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 18px 18px; }
.modal-foot.center { justify-content: center; }
.modal-foot .foot-note { margin-right: auto; font-size: 12.5px; color: var(--muted); }
body.modal-open { overflow: hidden; }
.loading-box { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 50px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--primary); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulaires ---------- */
.form-section { margin-bottom: 22px; }
.form-section:last-child { margin-bottom: 0; }
.form-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.form-section-head .step { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; background: var(--primary-50); color: var(--primary); font-size: 12px; font-weight: 700; }
.form-section-head h3 { font-size: 14px; font-weight: 650; }
.form-section-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.span-all { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field label .req { color: var(--danger); margin-left: 2px; }
.field small { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: #fff; font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field textarea { height: auto; min-height: 76px; padding: 9px 12px; resize: vertical; line-height: 1.45; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--subtle); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: var(--ring); }
.field input[readonly] { background: var(--surface-2); color: var(--muted); }
.field input:user-invalid, .field textarea:user-invalid { border-color: var(--danger); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 48px; }
.input-suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12.5px; color: var(--subtle); pointer-events: none; }

.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 22px; border: 1.5px dashed var(--line-strong); border-radius: 12px; background: var(--surface-2); text-align: center; color: var(--muted); font-size: 13px; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-50); }
.dropzone .icon { width: 24px; height: 24px; color: var(--primary); margin-bottom: 4px; }
.dropzone b { color: var(--text); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.attachment-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.attachment-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 13px; }
.attachment-item .icon { color: var(--primary); }
.attachment-item > div { flex: 1; min-width: 0; }
.attachment-item b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-item small { color: var(--muted); font-size: 12px; }
.attachment-item a, .attachment-item button { flex: none; }

/* Recherche de référence (Outbound) */
.reference-box { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; padding: 16px; border-radius: 14px; background: linear-gradient(135deg, var(--out-bg), #fff 70%); border: 1px solid #f3dcc4; margin-bottom: 18px; }
.reference-box .field input { height: 46px; font-size: 16px; font-weight: 600; letter-spacing: .02em; }
.reference-box .btn { height: 46px; }
.ref-message { display: flex; align-items: center; gap: 7px; min-height: 20px; font-size: 13px; color: var(--muted); grid-column: 1 / -1; }
.ref-message .icon { width: 16px; height: 16px; }
.ref-message.ok { color: var(--success); }
.ref-message.err { color: var(--danger); }
.locked-step { opacity: .45; pointer-events: none; filter: grayscale(.4); transition: opacity .25s, filter .25s; }
.dossier-card { display: grid; grid-template-columns: 1.2fr 2fr; gap: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 22px; }
.dossier-main { padding: 16px 18px; background: var(--surface-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.dossier-main .sgl { font-size: 20px; font-weight: 750; letter-spacing: -.01em; }
.dossier-main .client { font-size: 13.5px; color: var(--muted); }
.dossier-stock { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.dossier-stock .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.dossier-stock .row b { color: var(--text); font-variant-numeric: tabular-nums; }
.dossier-stock .track { height: 8px; border-radius: 99px; background: #e4eaf0; overflow: hidden; }
.dossier-stock .fill { height: 100%; background: var(--wh); border-radius: 99px; transition: width .4s var(--ease); }
.dossier-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; padding: 16px 18px; }
.fact { min-width: 0; }
.fact span { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--subtle); }
.fact b { display: block; font-size: 13.5px; font-weight: 550; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Fiche dossier ---------- */
.record-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 20px; border-radius: 14px; margin-bottom: 18px; color: #fff; background: linear-gradient(135deg, var(--nav-700), var(--nav-900)); }
.record-banner.in { background: linear-gradient(135deg, #1d6fb0, #134d7c); }
.record-banner.out { background: linear-gradient(135deg, #c06a1e, #8c4a11); }
.record-banner.wh { background: linear-gradient(135deg, #1b8a5f, #11603f); }
.record-banner .sgl { font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
.record-banner .sub { font-size: 13.5px; opacity: .85; margin-top: 2px; }
.record-banner .status { padding: 6px 12px; border-radius: 99px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.record-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.record-stat { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.record-stat span { display: block; font-size: 12px; color: var(--muted); }
.record-stat b { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.record-section { margin-bottom: 18px; }
.record-section h3 { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.record-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.record-field { padding: 10px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; }
.record-field:nth-child(3n) { border-right: 0; }
.record-field span { display: block; font-size: 11.5px; color: var(--subtle); font-weight: 600; }
.record-field b { display: block; font-size: 13.5px; font-weight: 550; color: var(--text); white-space: pre-line; word-break: break-word; }
.record-field.wide { grid-column: 1 / -1; border-right: 0; }

/* ---------- Confirmation ---------- */
.confirm-box { text-align: center; }
.confirm-icon { width: 64px; height: 64px; margin: 4px auto 14px; display: grid; place-items: center; border-radius: 50%; background: var(--success-bg); color: var(--success); box-shadow: 0 0 0 8px rgba(27,138,95,.07); animation: pop .45s var(--ease) both; }
.confirm-icon .icon { width: 30px; height: 30px; stroke-width: 2.4; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.confirm-box h2 { font-size: 19px; }
.confirm-box p { margin: 6px 0 16px; color: var(--muted); font-size: 13.5px; }
.summary { text-align: left; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.summary-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 14px; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.summary-row:last-child { border-bottom: 0; }
.summary-row b { color: var(--muted); font-weight: 550; }
.summary-row span { font-weight: 650; text-align: right; }

/* ---------- Administration ---------- */
.admin-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.user-cell { display: flex; align-items: center; gap: 11px; }
.user-cell .avatar { width: 32px; height: 32px; font-size: 12px; }
.user-cell b { display: block; color: var(--text); font-weight: 600; }
.user-cell small { display: block; color: var(--muted); font-size: 12.5px; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.row-actions .icon-btn.danger:hover { color: var(--danger); background: var(--danger-bg); }
.inline-form { display: inline; margin: 0; }
.role-list { display: flex; flex-direction: column; }
.role-editor { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.role-editor:last-child { border-bottom: 0; }
.role-editor-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.role-editor-head .field { flex: 1; }
.perm-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.switch { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); font-size: 13px; cursor: pointer; transition: background .15s, border-color .15s; }
.switch:hover { background: var(--surface-2); }
.switch input { appearance: none; width: 32px; height: 18px; flex: none; margin: 0; border-radius: 99px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .18s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .18s var(--ease); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(14px); }
.switch input:disabled { opacity: .6; cursor: not-allowed; }
.switch:has(input:checked) { border-color: var(--primary-100); background: var(--primary-50); }
.role-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

/* ---------- Authentification ---------- */
.auth-body { min-height: 100vh; background: var(--bg); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); }
.auth-visual {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px 56px; color: #fff;
  background: radial-gradient(1000px 500px at 85% -10%, rgba(76,155,220,.35), transparent 60%), linear-gradient(160deg, var(--nav-700), var(--nav-900) 70%);
}
.auth-visual::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(180deg, transparent, #000 40%, transparent); pointer-events: none; }
.auth-visual > * { position: relative; z-index: 1; }
.auth-visual .brand { border: 0; padding: 0; }
.auth-hero h1 { font-size: 40px; line-height: 1.12; font-weight: 750; letter-spacing: -.025em; max-width: 520px; }
.auth-hero p { margin: 14px 0 0; font-size: 16px; color: #b5c8da; max-width: 460px; }
.flow-steps { display: flex; align-items: center; gap: 10px; margin-top: 36px; flex-wrap: wrap; }
.flow-step { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(4px); }
.flow-step .kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.flow-step.in .kpi-icon { background: rgba(108,180,236,.2); color: #8cc6f3; }
.flow-step.wh .kpi-icon { background: rgba(73,201,146,.18); color: #6fd9ac; }
.flow-step.out .kpi-icon { background: rgba(240,160,90,.2); color: #f4b57d; }
.flow-step b { display: block; font-size: 13.5px; }
.flow-step small { display: block; font-size: 12px; color: #9fb5ca; }
.flow-arrow { color: #5d7c99; }
.auth-foot { font-size: 12.5px; color: #7f9bb5; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: min(400px, 100%); }
.auth-card h2 { font-size: 26px; font-weight: 750; }
.auth-card > p { margin: 6px 0 24px; color: var(--muted); }
.auth-card .field { margin-bottom: 16px; }
.auth-card .btn { height: 44px; margin-top: 6px; }
.auth-card .install-note { margin-top: 18px; font-size: 13px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 44px; }
.password-wrap .icon-btn { position: absolute; right: 3px; top: 2px; }
.cred-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

/* ---------- Écran d'accueil (après connexion uniquement) ---------- */
.app-splash { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; color: #fff; background: linear-gradient(160deg, var(--nav-700), var(--nav-900)); transition: opacity .45s var(--ease), visibility .45s; }
.app-splash.hide { opacity: 0; visibility: hidden; }
.splash-card { text-align: center; }
.splash-logo { width: 64px; height: 64px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 18px; background: linear-gradient(135deg, #2f86cc, #1a5d95); box-shadow: 0 16px 40px rgba(0,0,0,.3); animation: pop .5s var(--ease) both; }
.splash-logo .icon { width: 30px; height: 30px; }
.splash-title { font-size: 20px; font-weight: 700; }
.splash-sub { font-size: 13.5px; color: #9fb5ca; margin-top: 4px; }
.splash-line { width: 140px; height: 3px; margin: 18px auto 0; border-radius: 9px; overflow: hidden; background: rgba(255,255,255,.12); }
.splash-line span { display: block; height: 100%; width: 40%; border-radius: 9px; background: #6cb4ec; animation: loadline 1s var(--ease) infinite; }
@keyframes loadline { from { transform: translateX(-110%); } to { transform: translateX(300%); } }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-layout { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-100%); transition: transform .28s var(--ease); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(8,24,40,.45); opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
  body.sidebar-open .sidebar-scrim { opacity: 1; visibility: visible; }
  .menu-btn { display: inline-grid; margin-left: -8px; }
  .dash-grid, .dash-grid.even { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dossier-card { grid-template-columns: 1fr; }
  .dossier-main { border-right: 0; border-bottom: 1px solid var(--line); }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}
@media (max-width: 720px) {
  .topbar { padding: 0 16px; gap: 10px; }
  .crumb span, .crumb-sep, .top-meta { display: none; }
  .quick-search kbd { display: none; }
  .content { padding: 18px 16px; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header h1 { font-size: 22px; }
  .page-actions .btn { width: 100%; }
  .kpi-grid, .kpi-grid.three { grid-template-columns: 1fr; }
  .form-grid, .form-grid.two, .form-grid.three, .perm-list, .dossier-facts, .record-fields, .record-stats { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .record-field { border-right: 0; }
  .reference-box { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.large, .modal.small { width: 100%; max-height: 94vh; border-radius: 18px 18px 0 0; }
  .modal-foot { border-radius: 0; }
  .filters .date-range { flex: 1 1 100%; }
  .filters .date-range input { flex: 1; }
  .table-toolbar { flex-wrap: wrap; }
}

/* ---------- Pages de liste : en-tête figé, seules les lignes défilent ----------
   Titre, filtres, barre d’outils et en-têtes de colonnes restent en place ;
   le défilement se fait uniquement dans la zone des données. */
.data-table thead th { box-shadow: inset 0 -1px 0 var(--line); }
@media (min-width: 1025px) and (min-height: 600px) {
  body.page-list { height: 100vh; overflow: hidden; }
  body.page-list .app-shell { height: 100vh; min-height: 0; }
  body.page-list .main { height: 100vh; overflow: auto; }
  body.page-list .content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding-top: 22px; padding-bottom: 20px; }
  body.page-list .content > * { flex-shrink: 0; }
  body.page-list .page-header { margin-bottom: 16px; }
  body.page-list .list-panel { flex: 1 1 0; min-height: 260px; display: flex; flex-direction: column; margin-bottom: 0; }
  body.page-list .list-panel .table-wrap { flex: 1 1 auto; min-height: 0; max-height: none; }
  body.page-list .kpi-grid { margin-bottom: 16px; }
  body.page-list .kpi { padding: 12px 16px; gap: 0; }
  body.page-list .kpi-icon { width: 30px; height: 30px; }
  body.page-list .kpi-value { font-size: 24px; margin-top: 0; }
  body.page-list .kpi-note { display: none; }
}
/* Écrans plus petits : la page défile, mais l’en-tête des colonnes reste visible dans le tableau. */
@media (max-width: 1024px), (max-height: 599px) {
  .table-wrap { max-height: calc(100vh - 120px); }
}

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

/* ---------- Impression de la fiche dossier ---------- */
@media print {
  body.printing > *:not(#recordModal) { display: none !important; }
  body.printing #recordModal { position: static; display: block; opacity: 1; visibility: visible; background: none; padding: 0; backdrop-filter: none; }
  body.printing #recordModal .modal { width: 100%; max-height: none; box-shadow: none; transform: none; }
  body.printing #recordModal .modal-foot, body.printing #recordModal .icon-btn { display: none; }
  body.printing .modal-body { overflow: visible; }
  .record-banner { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
