/* ==========================================================================
   Quincaillerie — système de design « outil d'atelier »
   Tokens + composants. Tailwind (CDN) sert aux mises en page ponctuelles.
   ========================================================================== */

:root {
  /* Couleurs */
  --ink: #14181F;
  --ink-2: #1D232C;
  --ink-3: #2A313B;
  --paper: #F4F2EE;
  --surface: #FFFFFF;
  --line: #E4E0D8;
  --line-strong: #D2CDC3;
  --hover: #F8F6F2;
  --accent: #D9480F;        /* indicateurs, barre active, anneau de focus */
  --accent-600: #C03F0C;    /* fonds porteurs de texte (contraste AA 5,3:1) */
  --accent-700: #A3350A;
  --accent-soft: #FBEDE6;
  --steel: #5C6670;
  --muted: #8A929B;
  --ok: #2F7D4F;      --ok-soft: #EDF6F0;
  --warn: #B7791F;    --warn-ink: #8A5A12;  --warn-soft: #FBF3E2;
  --danger: #B42318;  --danger-soft: #FDEDEB;

  /* Forme */
  --r-sm: 6px;
  --r-md: 10px;
  --shadow-float: 0 12px 32px -12px rgba(20, 24, 31, .22), 0 2px 6px -2px rgba(20, 24, 31, .08);

  /* Dimensions */
  --sb-w: 232px;
  --sb-w-c: 64px;
  --top-h: 56px;
  --row-h: 44px;
  --bottom-h: 64px;

  /* Mouvement */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 170ms;

  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.num, .tabular, input.num { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
a { color: inherit; }
.link { color: var(--accent-600); font-weight: 500; text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 2px; }
.text-steel { color: var(--steel); }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn-ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.ico {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.ico-sm { width: 16px; height: 16px; }
.ico-xs { width: 14px; height: 14px; }

kbd, .kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  font: 500 11px/1 var(--font);
  color: var(--steel); background: var(--surface);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
}

.skip-link { position: absolute; left: 8px; top: -40px; z-index: 100; padding: 8px 12px; background: var(--ink); color: #fff; border-radius: var(--r-sm); }
.skip-link:focus { top: 8px; }

/* ---------- Application : sidebar / topbar / contenu ---------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sb-w);
  display: flex; flex-direction: column;
  background: var(--ink); color: #C7CCD3;
  transition: width var(--dur) var(--ease);
}
.sb-brand {
  height: var(--top-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; color: #fff; font-weight: 600; font-size: 14px; letter-spacing: -.01em;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  white-space: nowrap; overflow: hidden; text-decoration: none;
}
.brand-mark {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
}
.brand-mark .ico { width: 16px; height: 16px; stroke-width: 1.75; }
.sb-nav { flex: 1; overflow-y: auto; padding: 8px 8px 16px; scrollbar-width: thin; scrollbar-color: var(--ink-3) transparent; }
.sb-section {
  padding: 16px 10px 6px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: #7D8691; white-space: nowrap;
}
.sb-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  height: 36px; padding: 0 10px; margin: 1px 0;
  border-radius: var(--r-sm);
  color: #C7CCD3; font-size: 13.5px; font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  width: 100%;
}
.sb-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.sb-item[aria-current="page"] { background: rgba(255, 255, 255, .08); color: #fff; }
.sb-item[aria-current="page"]::before {
  content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.sb-item[aria-current="page"] .ico { color: #fff; }
.sb-item .ico { color: #98A1AB; }
.sb-label { overflow: hidden; text-overflow: ellipsis; }
.sb-foot { padding: 8px; border-top: 1px solid rgba(255, 255, 255, .06); }

.sb-collapsed .sidebar { width: var(--sb-w-c); }
.sb-collapsed .sb-label, .sb-collapsed .sb-brand-name { display: none; }
.sb-collapsed .sb-section { padding: 10px 0 4px; font-size: 0; }
.sb-collapsed .sb-section::after { content: ""; display: block; height: 1px; margin: 0 10px; background: rgba(255, 255, 255, .08); }
.sb-collapsed .sb-item { justify-content: center; padding: 0; }
.sb-collapsed .sb-brand { justify-content: center; padding: 0; }
.sb-collapsed .sb-toggle-ico { transform: scaleX(-1); }

.app-main { margin-left: var(--sb-w); min-width: 0; transition: margin-left var(--dur) var(--ease); }
.sb-collapsed .app-main { margin-left: var(--sb-w-c); }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: rgba(244, 242, 238, .94);
  backdrop-filter: saturate(1.2) blur(6px);
  border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--steel); min-width: 0; white-space: nowrap; }
.crumb a { text-decoration: none; }
.crumb a:hover { color: var(--ink); }
.crumb .ico { width: 14px; height: 14px; color: var(--muted); }
.crumb [aria-current] { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }
.gsearch { position: relative; width: 280px; }
.gsearch .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.gsearch input { height: 34px; padding-left: 34px; padding-right: 34px; background: var(--surface); }
.gsearch kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.topbar-date { font-size: 13px; color: var(--steel); white-space: nowrap; }

.umenu { position: relative; }
.umenu-btn {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 4px;
  border-radius: var(--r-sm); font-size: 13px; font-weight: 500;
  transition: background var(--dur) var(--ease);
}
.umenu-btn:hover, .umenu-btn[aria-expanded="true"] { background: rgba(20, 24, 31, .05); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--ink); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.pop.open { opacity: 1; transform: none; pointer-events: auto; }
.pop-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.pop-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 36px; padding: 0 10px; border-radius: var(--r-sm);
  font-size: 13px; text-decoration: none; color: var(--ink);
}
.pop-item:hover { background: var(--hover); }

.content { max-width: 1440px; margin: 0 auto; padding: 24px 32px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 24px; line-height: 30px; font-weight: 600; letter-spacing: -.02em; }
.page-sub { margin-top: 2px; font-size: 13px; color: var(--steel); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Navigation mobile */
.bottomnav { display: none; }
.topbar-brand { display: none; }

/* ---------- Boutons ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border-radius: var(--r-sm); border: 1px solid transparent;
  font: 500 14px/1 var(--font); white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform 80ms var(--ease);
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent-600); color: #fff; }
.btn-primary:hover { background: var(--accent-700); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--hover); border-color: #C2BCB0; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: rgba(20, 24, 31, .05); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #962015; }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn-lg { height: 48px; padding: 0 20px; font-size: 16px; font-weight: 600; }
.btn-xl { height: 56px; padding: 0 20px; font-size: 17px; font-weight: 600; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn .kbd { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); color: #fff; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  color: var(--ink); animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after, .btn-danger.is-loading::after { color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Champs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 500; color: var(--ink); }
.label .opt { font-weight: 400; color: var(--steel); }
.hint { font-size: 12px; color: var(--steel); }
.field-error { font-size: 12px; color: var(--danger); display: flex; gap: 6px; align-items: center; }
.input {
  width: 100%; height: 38px; padding: 0 11px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font: 400 14px/1.2 var(--font);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder { color: var(--muted); }
.input:hover { border-color: #BFB9AD; }
.input:focus, .input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 72, 15, .16); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, .15); }
select.input {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235C6670' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 16px;
}
input[type="date"].input { padding-right: 8px; }
.input-lg { height: 48px; font-size: 16px; padding: 0 14px; }
.input-sm { height: 32px; font-size: 13px; padding: 0 8px; }
.input.num { text-align: right; }
.input-affix { position: relative; }
.input-affix > .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-affix > .input { padding-left: 38px; }
.input-affix > .input-lg { padding-left: 42px; }
.input-affix > .input-lg + .ico, .input-affix > .ico:first-child { left: 14px; }
.input-affix .suffix { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--steel); pointer-events: none; }
.input-affix .suffix-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* ---------- Puces de filtre ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chip:hover { border-color: #BFB9AD; background: var(--hover); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .count { font-size: 12px; color: var(--steel); }
.chip[aria-pressed="true"] .count, .chip.is-active .count { color: #B8BEC6; }

/* ---------- Onglets ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  position: relative; height: 40px; padding: 0 12px;
  font-size: 14px; font-weight: 500; color: var(--steel); text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }

/* ---------- Segmenté ---------- */
.seg { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); padding: 2px; }
.seg-in { position: absolute; opacity: 0; pointer-events: none; }
.seg-btn {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 0 10px; border-radius: 4px;
  font-size: 13px; font-weight: 500; color: var(--steel); cursor: pointer; white-space: nowrap; text-align: center;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg-btn:hover { color: var(--ink); background: var(--hover); }
.seg-in:checked + .seg-btn { background: var(--ink); color: #fff; }
.seg-in:focus-visible + .seg-btn { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg-lg .seg-btn { min-height: 44px; font-size: 14px; }
.seg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.seg button.seg-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); min-width: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.card-title { font-size: 14px; font-weight: 600; letter-spacing: -.005em; display: flex; align-items: center; gap: 8px; }
.card-title .count { font-weight: 500; color: var(--steel); }
.card-body { padding: 16px; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 13px; }

/* Barre d'outils */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1 1 220px; min-width: 0; }
.toolbar-sep { width: 1px; height: 24px; background: var(--line); }

/* ---------- Indicateurs (KPI) ---------- */
.kpis { display: grid; grid-template-columns: repeat(var(--kpi-cols, 5), minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
/* séparateurs 1px quel que soit le nombre de colonnes (les bords extérieurs sont rognés) */
.kpi { padding: 16px 20px; min-width: 0; box-shadow: -1px 0 0 var(--line), 0 -1px 0 var(--line); }
.kpi-label { font-size: 13px; color: var(--steel); }
.kpi-value { margin-top: 6px; font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--steel); letter-spacing: 0; }
.kpi-sub { margin-top: 4px; font-size: 12px; line-height: 16px; color: var(--steel); display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; }
.delta-up { color: var(--ok); }
.delta-down { color: var(--danger); }
.delta-up .ico, .delta-down .ico { width: 14px; height: 14px; }

/* ---------- Tableaux ---------- */
.tbl-wrap { overflow: auto; max-height: calc(100vh - 240px); }
.tbl-wrap.no-max { max-height: none; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.tbl th {
  position: sticky; top: 0; z-index: 1;
  height: 38px; padding: 0 12px;
  background: #FAF9F6; border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 600; color: var(--steel); text-align: left; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .04em;
}
.tbl th:first-child, .tbl td:first-child { padding-left: 16px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 16px; }
.tbl td { height: var(--row-h); padding: 6px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background var(--dur) var(--ease); }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tbody tr.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.tbl tbody tr.is-muted td { color: var(--muted); }
.tbl .num, .tbl th.num { text-align: right; }
.tbl .actions { text-align: right; white-space: nowrap; width: 1%; }
.tbl .actions > * { vertical-align: middle; }
.tbl .actions form { display: inline; }
.cell-main { font-weight: 500; }
.cell-sub { font-size: 12px; color: var(--steel); margin-top: 1px; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.th-sort .ico { width: 14px; height: 14px; opacity: .5; }
.th-sort:hover { color: var(--ink); }
th[aria-sort] .th-sort { color: var(--ink); }
th[aria-sort] .th-sort .ico { opacity: 1; color: var(--accent); }
th[aria-sort="descending"] .th-sort .ico { transform: scaleY(-1); }
.tbl-foot { display: flex; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--steel); }
.bar-cell { display: flex; align-items: center; gap: 10px; }
.bar { height: 6px; border-radius: 3px; background: var(--accent); opacity: .85; min-width: 2px; }

/* ---------- Pastilles ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill-warn::before { background: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-neutral { background: #EFEDE8; color: var(--steel); }
.pill-ink { background: var(--ink); color: #fff; }
.pill-ink::before { display: none; }

/* ---------- Jauge ---------- */
.gauge { display: inline-block; width: 72px; height: 4px; border-radius: 2px; background: #ECE9E3; overflow: hidden; vertical-align: middle; }
.gauge > span { display: block; height: 100%; border-radius: 2px; transition: width 300ms var(--ease); }
.gauge-ok > span { background: var(--ok); }
.gauge-warn > span { background: var(--warn); }
.gauge-danger > span { background: var(--danger); min-width: 3px; }

/* ---------- Listes compactes ---------- */
.list > li, .list .li { display: flex; align-items: center; gap: 12px; min-height: var(--row-h); padding: 8px 16px; border-bottom: 1px solid var(--line); }
.list > li:last-child, .list > li:last-child .li { border-bottom: 0; }
.list > li:has(> .li) { padding: 0; border-bottom: 0; }
.list > li:has(> .li) > .li { border-bottom: 1px solid var(--line); }
.list > li:last-child:has(> .li) > .li { border-bottom: 0; }
.list a.li { text-decoration: none; transition: background var(--dur) var(--ease); }
.list a.li:hover { background: var(--hover); }

/* ---------- État vide ---------- */
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 32px 20px; color: var(--steel); }
.empty p { font-size: 14px; max-width: 42ch; }
.empty-ico { width: 28px; height: 28px; color: var(--muted); stroke-width: 1.25; }
.empty-center { align-items: center; text-align: center; }

/* ---------- Squelette ---------- */
.skeleton { position: relative; overflow: hidden; background: #ECE9E3; border-radius: var(--r-sm); }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: translateX(-100%); animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 12px 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
  font-size: 14px; line-height: 20px;
  opacity: 0; transform: translateY(-6px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}
.toast.in { opacity: 1; transform: none; }
.toast > .ico { margin-top: 1px; }
.toast-ok > .ico { color: var(--ok); }
.toast-err > .ico { color: var(--danger); }
.toast-warn > .ico { color: var(--warn); }
.toast span { flex: 1; }
.toast-x { color: var(--muted); border-radius: 4px; }
.toast-x:hover { color: var(--ink); }
.toast-err { border-left: 3px solid var(--danger); }

/* ---------- Modale & tiroir (<dialog>) ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: rgba(20, 24, 31, .38); }
.modal {
  width: min(440px, calc(100vw - 32px)); padding: 0; margin: auto;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--shadow-float);
}
.modal[open] { animation: pop-in 180ms var(--ease); }
.modal-body { padding: 20px 20px 8px; }
.modal-title { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.modal-text { margin-top: 6px; color: var(--steel); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 20px; }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }

.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0;
  width: min(440px, 100vw); max-width: 100vw; height: 100%; max-height: 100%;
  padding: 0; border: 0; border-left: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-float);
}
.drawer[open] { display: flex; flex-direction: column; animation: slide-in 200ms var(--ease); }
.drawer > form { display: flex; flex-direction: column; height: 100%; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; padding: 0 12px 0 20px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.drawer-title { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-shrink: 0; background: var(--surface); }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: 100%;
  max-height: 85vh; padding: 0 0 env(safe-area-inset-bottom); border: 0;
  border-radius: 14px 14px 0 0; background: var(--surface); box-shadow: var(--shadow-float);
}
.sheet[open] { animation: sheet-in 200ms var(--ease); }
.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 8px auto 4px; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Grilles de formulaire ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.callout { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); font-size: 13px; line-height: 18px; }
.callout .ico { margin-top: 0; }
.callout-warn { background: var(--warn-soft); color: var(--warn-ink); }
.callout-info { background: #F1EFEA; color: var(--steel); }
.callout-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Graphique ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--steel); font-variant-numeric: tabular-nums; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .area { fill: var(--accent); opacity: .08; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt circle { fill: var(--surface); stroke: var(--accent); stroke-width: 2; opacity: 0; transition: opacity var(--dur) var(--ease); }
.chart .pt .tip { opacity: 0; transition: opacity var(--dur) var(--ease); pointer-events: none; }
.chart .pt .tip rect { fill: var(--ink); }
.chart .pt .tip text { fill: #fff; font-size: 11px; }
.chart .pt .vline { stroke: var(--line-strong); stroke-dasharray: 2 3; opacity: 0; }
.chart .pt:hover circle, .chart .pt:hover .tip, .chart .pt:hover .vline { opacity: 1; }
.chart .pt.last circle { opacity: 1; }
.chart .hit { fill: transparent; }

/* ==========================================================================
   Caisse
   ========================================================================== */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.pos-left { min-width: 0; }
.pos-search .input { height: 52px; font-size: 16px; padding-left: 44px; padding-right: 92px; border-radius: var(--r-sm); }
.pos-search > .ico { left: 15px; width: 20px; height: 20px; }
.pos-search .suffix { right: 12px; display: flex; gap: 4px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
.pcard {
  position: relative; text-align: left;
  display: flex; flex-direction: column; gap: 2px;
  min-height: 104px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform 80ms var(--ease);
}
.pcard:hover { border-color: #C9C3B7; }
.pcard:active { transform: scale(.985); }
.pcard.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pcard.is-out { background: #FAF9F7; }
.pcard.is-out .pcard-name, .pcard.is-out .pcard-price { color: var(--muted); }
.pcard-name { font-size: 14px; font-weight: 500; line-height: 18px; overflow-wrap: anywhere; }
.pcard-ref { font-size: 12px; color: var(--steel); }
.pcard-foot { margin-top: auto; padding-top: 8px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 8px; }
.pcard-price { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.pcard-stock { font-size: 12px; color: var(--steel); display: flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-danger { background: var(--danger); }
.pcard-sk { min-height: 104px; border-radius: var(--r-md); }

.ticket { position: sticky; top: calc(var(--top-h) + 16px); display: flex; flex-direction: column; max-height: calc(100vh - var(--top-h) - 32px); }
.tk-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 52px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.tk-lines { flex: 1 1 auto; overflow-y: auto; min-height: 96px; }
.tk-line {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px;
  padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line);
  transition: background 600ms var(--ease);
}
.tk-line.flash { background: var(--accent-soft); transition: none; }
.tk-line.is-over { background: var(--warn-soft); }
.tk-line.leaving { opacity: 0; transform: translateX(8px); transition: opacity 150ms var(--ease), transform 150ms var(--ease); }
.tk-name { font-size: 14px; font-weight: 500; line-height: 18px; }
.tk-meta { font-size: 12px; color: var(--steel); }
.tk-line.is-over .tk-meta { color: var(--warn-ink); font-weight: 500; }
.tk-del { align-self: start; width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--r-sm); color: var(--muted); }
.tk-del:hover { background: var(--danger-soft); color: var(--danger); }
.tk-row2 { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); }
.qty button { width: 32px; height: 32px; display: grid; place-items: center; color: var(--steel); }
.qty button:hover { color: var(--ink); background: var(--hover); }
.qty input { width: 48px; height: 32px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; font: 500 14px var(--font); font-variant-numeric: tabular-nums; background: transparent; }
.qty input:focus { outline: none; background: var(--accent-soft); }
.tk-x { font-size: 12px; color: var(--muted); }
.tk-price { width: 92px; height: 32px; padding: 0 8px; text-align: right; font-variant-numeric: tabular-nums; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; font: 400 14px var(--font); color: var(--steel); }
.tk-price:hover { border-color: var(--line-strong); }
.tk-price[readonly] { cursor: default; border-color: transparent !important; box-shadow: none !important; background: transparent !important; color: var(--steel) !important; }
.tk-price:focus { outline: none; border-color: var(--accent); background: var(--surface); color: var(--ink); box-shadow: 0 0 0 3px rgba(217, 72, 15, .16); }
.tk-price:not([readonly]) { border-color: var(--line); background: var(--surface); }
.tk-row3 { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; min-height: 26px; }
.tk-surplus { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border: 1px dashed var(--line-strong); border-radius: 999px; font-size: 12px; font-weight: 500; color: var(--steel); }
.tk-surplus:hover { border-color: var(--accent); color: var(--accent); }
.tk-surplus-box { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--steel); flex-wrap: wrap; }
.tk-surplus-box > span:first-child { font-weight: 600; color: var(--ok, #1a7f37); }
.tk-surplus-in { width: 76px; height: 28px; padding: 0 8px; text-align: right; border: 1px solid var(--accent); border-radius: var(--r-sm); background: var(--surface); font: 500 13px var(--font); color: var(--ink); font-variant-numeric: tabular-nums; }
.tk-surplus-in:focus { outline: none; box-shadow: 0 0 0 3px rgba(217, 72, 15, .16); }
.tk-surplus-info { color: var(--muted); }
.tk-sub { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tk-empty { padding: 28px 16px; color: var(--steel); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.tk-sum { border-top: 1px solid var(--line); padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; background: var(--surface); border-radius: 0 0 var(--r-md) var(--r-md); }
.tk-rowline { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.tk-rowline .input { width: 132px; height: 34px; }
.tk-total { display: flex; align-items: baseline; justify-content: space-between; padding: 10px 0; border-top: 1px dashed var(--line-strong); border-bottom: 1px dashed var(--line-strong); }
.tk-total .v { font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tk-keys { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--steel); }
.tk-keys span { display: inline-flex; align-items: center; gap: 4px; }
.tk-bar { display: none; }
.tk-close { display: none; }
.tk-backdrop { display: none; }

/* ==========================================================================
   Facture
   ========================================================================== */
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 40px 44px; max-width: 820px; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--ink); }
.doc-ident { display: flex; gap: 14px; align-items: flex-start; }
.doc-logo { max-width: 72px; max-height: 72px; object-fit: contain; }
.doc-coord { margin-top: 6px; font-size: 12px; line-height: 17px; color: var(--steel); }
.doc-mentions { margin-top: 24px; font-size: 12px; line-height: 17px; color: var(--steel); }
.doc-shop { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.doc-kind { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--steel); }
.doc-no { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.doc-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 20px 0; }
.doc-meta dt { font-size: 12px; color: var(--steel); text-transform: uppercase; letter-spacing: .04em; }
.doc-meta dd { margin-top: 2px; font-weight: 500; }
.doc-tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc-tbl th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--steel); padding: 8px 0; border-bottom: 1px solid var(--line-strong); }
.doc-tbl td { padding: 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-tbl .num { padding-left: 16px; text-align: right; }
.doc-tbl th.num { text-align: right; }
.doc-totals { margin: 20px 0 0 auto; width: 300px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.doc-totals > div { display: flex; justify-content: space-between; gap: 16px; }
.doc-totals .grand { padding: 10px 0; margin: 4px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); font-size: 18px; font-weight: 600; }
.doc-foot { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--steel); display: flex; justify-content: space-between; gap: 16px; }
.doc-ticket-only { display: none; }

body.fmt-ticket .doc { max-width: 80mm; padding: 16px 14px; font-size: 12px; }
body.fmt-ticket .doc-head { flex-direction: column; align-items: center; text-align: center; gap: 6px; padding-bottom: 10px; border-bottom-style: dashed; }
body.fmt-ticket .doc-head .text-right { text-align: center; }
body.fmt-ticket .doc-ident { display: flex; gap: 14px; align-items: flex-start; }
body.fmt-ticket .doc-shop { font-size: 16px; }
body.fmt-ticket .doc-no { font-size: 14px; }
body.fmt-ticket .doc-meta { grid-template-columns: 1fr; gap: 2px; padding: 10px 0; font-size: 12px; }
body.fmt-ticket .doc-meta > div { display: flex; justify-content: space-between; }
body.fmt-ticket .doc-meta dd { margin: 0; }
body.fmt-ticket .doc-tbl { font-size: 12px; }
body.fmt-ticket .doc-tbl thead, body.fmt-ticket .doc-a4-only { display: none; }
body.fmt-ticket .doc-ticket-only { display: block; }
body.fmt-ticket .doc-tbl td { padding: 5px 0; border-bottom-style: dashed; }
body.fmt-ticket .doc-totals { width: 100%; font-size: 12px; }
body.fmt-ticket .doc-totals .grand { font-size: 15px; border-style: dashed; }
body.fmt-ticket .doc-foot { flex-direction: column; align-items: center; text-align: center; gap: 2px; margin-top: 16px; }

/* ==========================================================================
   Connexion
   ========================================================================== */

/* ==========================================================================
   Mouvement réduit
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1279px) {
  .pos { grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }
  .gsearch { width: 220px; }
  .kpis { --kpi-cols: 3 !important; }
}

@media (max-width: 1023px) {
  .content { padding: 20px 20px 40px; }
  .topbar { padding: 0 16px; }
  .topbar-date { display: none; }
  /* Caisse : ticket en panneau coulissant */
  .pos { grid-template-columns: minmax(0, 1fr); }
  .ticket {
    position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; top: auto;
    max-height: 88vh; border-radius: 14px 14px 0 0; border-bottom: 0;
    transform: translateY(105%); transition: transform 220ms var(--ease);
    box-shadow: var(--shadow-float);
  }
  .ticket.open { transform: none; }
  .tk-close { display: inline-flex; }
  .tk-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(20, 24, 31, .38); }
  .tk-backdrop.open { display: block; }
  .tk-bar {
    position: fixed; z-index: 50; left: 12px; right: 12px; bottom: 12px;
    display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 8px 0 16px;
    background: var(--ink); color: #fff; border-radius: var(--r-md); box-shadow: var(--shadow-float);
    font-size: 14px; font-weight: 500;
  }
  .tk-bar .v { margin-left: auto; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .tk-bar .go { height: 40px; padding: 0 14px; border-radius: var(--r-sm); background: var(--accent-600); display: flex; align-items: center; font-weight: 600; }
  .pos-left { padding-bottom: 72px; }
  .tk-keys, .pos-search .suffix, #btn-encaisser kbd { display: none; }
  .pos-search .input { padding-right: 14px; }
}

@media (max-width: 767px) {
  .sidebar { display: none; }
  .app-main, .sb-collapsed .app-main { margin-left: 0; }
  .content { padding: 16px 14px calc(var(--bottom-h) + 24px); }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-brand { display: flex; align-items: center; }
  .crumb, .topbar [data-sb-toggle] { display: none; }
  .gsearch { width: auto; flex: 1; }
  .gsearch kbd { display: none; }
  .umenu-name { display: none; }
  .page-title { font-size: 20px; line-height: 26px; }
  .page-head { align-items: center; margin-bottom: 16px; }

  .bottomnav {
    position: fixed; z-index: 45; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .bn-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 500; color: var(--steel); text-decoration: none; position: relative; }
  .bn-item[aria-current="page"] { color: var(--ink); }
  .bn-item[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--accent); border-radius: 0 0 2px 2px; }
  .bn-item .ico { width: 20px; height: 20px; }

  .tk-bar { bottom: calc(var(--bottom-h) + 10px + env(safe-area-inset-bottom)); }
  .pos-left { padding-bottom: 80px; }
  .pgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .kpis { --kpi-cols: 2 !important; }
  .kpi { padding: 14px 16px; }
  .kpi-value { font-size: 22px; line-height: 28px; }

  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }

  /* Tableaux -> cartes */
  .tbl-wrap { max-height: none; overflow: visible; }
  .tbl-cards thead { display: none; }
  .tbl-cards, .tbl-cards tbody { display: block; }
  .tbl-cards tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .tbl-cards tbody tr:last-child { border-bottom: 0; }
  .tbl-cards td { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: auto; padding: 0 !important; border: 0; font-size: 13px; }
  .tbl-cards td[data-label]::before { content: attr(data-label); color: var(--steel); font-size: 12px; font-weight: 400; }
  .tbl-cards td.c-main { grid-column: 1; font-size: 14px; display: block; min-width: 0; }
  .tbl-cards td.c-aside { grid-column: 2; grid-row: 1; justify-content: flex-end; font-weight: 600; }
  .tbl-cards td.c-full, .tbl-cards td[data-label] { grid-column: 1 / -1; }
  .tbl-cards td.actions { grid-column: 1 / -1; width: auto; justify-content: flex-end; padding-top: 4px !important; }
  .tbl-cards td.c-hide-m { display: none; }

  .doc { padding: 20px 16px; }
  .doc-head { flex-direction: column; }
  .doc-meta { grid-template-columns: 1fr 1fr; }
  .doc-totals { width: 100%; }


  .toasts { top: auto; bottom: calc(var(--bottom-h) + 12px); right: 12px; left: 12px; width: auto; }
}

/* ==========================================================================
   Impression
   ========================================================================== */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .bottomnav, .page-head, .no-print, .toasts, .tk-bar { display: none !important; }
  .app-main, .sb-collapsed .app-main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  .doc { border: 0; border-radius: 0; padding: 0; max-width: none; }
  body.fmt-ticket .doc { max-width: none; padding: 0; }
  .doc-tbl tr { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ==========================================================================
   Aide
   ========================================================================== */
.aide-resume { color: var(--steel); margin-bottom: 10px; }
.aide-etapes { list-style: none; counter-reset: etape; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; }
.aide-etapes li { counter-increment: etape; position: relative; padding-left: 32px; line-height: 21px; }
.aide-etapes li::before {
  content: counter(etape); position: absolute; left: 0; top: 0;
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.aide-etapes b { font-weight: 600; }
.aide-astuce { display: flex; gap: 8px; margin-top: 12px; padding: 8px 10px; border-radius: var(--r-sm); background: #F1EFEA; color: var(--steel); font-size: 13px; line-height: 18px; }
.aide-astuce .ico { color: var(--warn); margin-top: 1px; }
.aide-lien { margin-top: 14px; }
.print-only { display: none; }
.aide-tiroir-sujet + .aide-tiroir-sujet { border-top: 1px solid var(--line); padding-top: 20px; }
.aide-tiroir-titre { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.aide-tiroir-titre .ico { color: var(--accent); }

/* Guide de démarrage */
.guide-barre { height: 6px; border-radius: 3px; background: #ECE9E3; overflow: hidden; }
.guide-barre > span { display: block; height: 100%; background: var(--ok); border-radius: 3px; transition: width 300ms var(--ease); }
.guide-etape { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px; border-top: 1px solid var(--line); text-decoration: none; }
a.guide-etape:hover { background: var(--hover); }
.guide-coche { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; border: 1.5px solid var(--line-strong); color: transparent; }
.guide-etape.fait .guide-coche { background: var(--ok); border-color: var(--ok); color: #fff; }
.guide-etape.fait .guide-txt { color: var(--steel); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.guide-etape .ico.go { color: var(--muted); margin-left: auto; }

/* Astuce de première visite */
.bienvenue { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; margin-bottom: 16px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r-md); background: var(--surface); }
.bienvenue ol { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 6px; font-size: 13px; color: var(--steel); counter-reset: b; list-style: none; padding: 0; }
.bienvenue li { counter-increment: b; }
.bienvenue li::before { content: counter(b) ". "; font-weight: 600; color: var(--ink); }

@media print {
  .print-only { display: block; margin-bottom: 8px; }
}

/* ---------- Pastilles de rappel dans le menu ---------- */
.nb {
  margin-left: auto; flex-shrink: 0;
  min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums;
  background: #4A525C; color: #fff;
}
.nb-danger { background: var(--danger); }
.nb-warn { background: var(--warn); color: #fff; }
.pop-item .nb-info, .sheet .nb-info { background: var(--line); color: var(--ink); }
.sb-collapsed .sb-item .nb { position: absolute; top: 4px; right: 6px; min-width: 8px; width: 8px; height: 8px; padding: 0; font-size: 0; }
.sb-collapsed .sb-item .nb-info { display: none; }
.bn-item .nb { position: absolute; top: 4px; left: calc(50% + 4px); margin: 0; height: 16px; min-width: 16px; padding: 0 4px; font-size: 10px; }
.bn-item .nb-info { display: none; }
.nb-dot { position: absolute; top: 7px; left: calc(50% + 7px); width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

/* ---------- Actions rapides (tableau de bord) ---------- */
.raccourcis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1023px) { .raccourcis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.raccourci {
  display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 14px 16px;
  background: var(--surface, #fff); border: 1px solid var(--line); border-radius: var(--r-md, 10px);
  color: var(--ink); text-decoration: none; position: relative;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.raccourci:hover { border-color: var(--ink); box-shadow: 0 2px 8px rgba(20, 24, 31, .08); }
.raccourci:active { transform: translateY(1px); }
.raccourci:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.raccourci-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--paper); flex-shrink: 0; }
.raccourci-ico .ico { width: 20px; height: 20px; }
.raccourci.principal { background: var(--ink); border-color: var(--ink); color: #fff; }
.raccourci.principal .raccourci-ico { background: #C03F0C; color: #fff; }
.raccourci.principal .raccourci-sub { color: #B8BEC6; }
.raccourci-txt { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.raccourci-titre { font-weight: 600; font-size: 15px; }
.raccourci-sub { font-size: 12.5px; color: var(--steel); }
.raccourci .nb { position: absolute; top: 10px; right: 10px; }

/* ---------- « Plus d'options » repliables ---------- */
.plus-options > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 500; color: var(--steel); padding: 4px 0; border-radius: var(--r-sm);
}
.plus-options > summary::-webkit-details-marker { display: none; }
.plus-options > summary:hover { color: var(--ink); }
.plus-options > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.plus-options > summary .ico { width: 16px; height: 16px; transition: transform var(--dur) var(--ease); }
.plus-options[open] > summary .ico { transform: rotate(180deg); }
.plus-options > summary .resume { color: var(--muted, #8A919A); font-weight: 400; }
.plus-options-corps { display: flex; flex-direction: column; gap: 14px; padding-top: 12px; }
.suggestion { font-size: 12.5px; color: var(--steel); display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.suggestion .ico { width: 14px; height: 14px; color: var(--accent); }

/* ---------- Cloche de notifications (en-tête) ---------- */
.notif-btn { position: relative; }
.notif-nb {
  position: absolute; top: 2px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
  background: var(--warn); color: #fff; box-shadow: 0 0 0 2px var(--paper);
}
.notif-nb.is-urgent { background: var(--danger); }
.notif-pop { width: 340px; max-width: calc(100vw - 24px); max-height: min(70vh, 520px); overflow-y: auto; }
.notif-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border-radius: var(--r-sm); text-decoration: none; color: var(--ink); }
.notif-item:hover, .notif-item:focus-visible { background: var(--hover); outline: none; }
.notif-item + .notif-item { margin-top: 2px; }
.notif-ico { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; display: grid; place-items: center; }
.notif-ico .ico { width: 16px; height: 16px; }
.notif-danger { background: var(--danger-soft); color: var(--danger); }
.notif-warn { background: var(--warn-soft); color: var(--warn-ink); }
.notif-info { background: var(--paper); color: var(--steel); }
.notif-titre { display: block; font-size: 13.5px; font-weight: 600; }
.notif-detail { display: block; font-size: 12.5px; color: var(--steel); margin-top: 2px; line-height: 1.4; }
.notif-vide { display: flex; align-items: center; gap: 8px; padding: 14px 10px; font-size: 13px; color: var(--steel); }
.notif-vide .ico { color: var(--ok); }
@media (max-width: 767px) { .notif-pop { position: fixed; left: 12px; right: 12px; top: calc(var(--top-h, 56px) + 4px); width: auto; } }

/* ==========================================================================
   Téléphone : pages allégées
   ========================================================================== */
.tb-dates-toggle { display: none; }
@media (max-width: 767px) {
  .m-hide { display: none !important; }

  /* En-tête de page : sous-titre plus discret, boutons secondaires en icône */
  .page-sub { font-size: 13px; }
  .page-actions { gap: 8px; }
  .m-icon { font-size: 0; gap: 0; width: 40px; padding: 0; justify-content: center; }
  .m-icon .ico-sm { display: none; }

  /* Filtres : une seule ligne qui défile, dates repliées */
  .toolbar { gap: 10px; }
  .toolbar .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -2px; padding: 2px; max-width: 100%; }
  .toolbar .chips::-webkit-scrollbar { display: none; }
  .toolbar .chips { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); padding-right: 24px; }
  .toolbar .chip { flex-shrink: 0; }
  .tb-dates-toggle { display: inline-flex; }
  .tb-dates-toggle[aria-expanded="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
  .toolbar.has-dates:not(.dates-open) .tb-date { display: none !important; }

  /* Chiffres clés : plus compacts, une ligne chacun */
  .kpi { padding: 12px 14px; }
  .kpi-label { font-size: 12px; }
  .kpi-value { font-size: 20px; line-height: 26px; margin-top: 4px; }
  .kpi-value small { font-size: 12px; }
  .kpi-sub { font-size: 11.5px; display: block; }
  .kpis > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* Actions rapides : titre seul */
  .raccourcis { gap: 8px; }
  .raccourci { min-height: 56px; padding: 10px 12px; gap: 10px; }
  .raccourci-ico { width: 32px; height: 32px; border-radius: 8px; }
  .raccourci-ico .ico { width: 18px; height: 18px; }
  .raccourci-titre { font-size: 14px; line-height: 18px; }
  .raccourci-sub { display: none; }
  .raccourci .nb { top: 6px; right: 6px; }

  /* Cartes de liste : deux colonnes compactes, la carte entière est cliquable */
  .tbl-cards tbody tr { position: relative; padding: 12px 14px; }
  .tbl-cards td.c-m1 { grid-column: 1; justify-content: flex-start; }
  .tbl-cards td.c-m2 { grid-column: 2; justify-content: flex-end; padding-top: 0 !important; }
  .tbl-cards td.c-m1[data-label]::before, .tbl-cards td.c-m2[data-label]::before { margin-right: 2px; }
  .tbl-cards td.c-m1 + td.c-m2 { grid-row: auto; }
  .tbl-cards td.c-main a.link::after { content: ""; position: absolute; inset: 0; }
  .tbl-cards .m-stretch { position: absolute; inset: 0; width: auto; height: auto; opacity: 0; border-radius: 0; z-index: 0; }
  .tbl-cards td.actions:has(.m-stretch) { padding: 0 !important; height: 0; }
  .tbl-cards td form, .tbl-cards td .btn:not(.m-stretch), .tbl-cards td a:not(.link) { position: relative; z-index: 1; }
  .tbl-cards td[data-ecart]:empty { display: none; }

  /* Clôture : les modes sans mouvement sont masqués (laissés vides = exacts) */
  .clo-tbl tr.is-muted { display: none; }

  /* Astuce de la caisse : boutons sous le texte */
  .bienvenue { flex-wrap: wrap; padding: 12px 14px; }
  .bienvenue > .flex-1 { flex: 1 1 calc(100% - 40px); }
  .bienvenue ol { flex-direction: column; gap: 2px; }
  .bienvenue-actions { width: 100%; justify-content: flex-end; }
}

/* ==========================================================================
   Page de connexion
   ========================================================================== */
.page-login { background: var(--paper); }
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(380px, 5fr) minmax(0, 7fr); }
.login-side {
  position: relative; overflow: hidden; color: #C7CCD3; background: var(--ink);
  padding: 44px 52px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
/* trame discrète : grille d'atelier */
.login-side::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(160deg, #000 0%, transparent 75%); -webkit-mask-image: linear-gradient(160deg, #000 0%, transparent 75%);
}
.login-side::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.login-side > * { position: relative; }
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-mark { width: 44px; height: 44px; border-radius: 10px; }
.login-mark .ico { width: 22px; height: 22px; }
.login-logo { width: 52px; height: 52px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.login-shop { color: #fff; font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -.01em; }
.login-activite { font-size: 13px; color: #98A1AB; margin-top: 2px; }
.login-titre { color: #fff; font-size: 34px; line-height: 42px; font-weight: 600; letter-spacing: -.025em; max-width: 440px; }
.login-list { display: flex; flex-direction: column; gap: 18px; margin-top: 32px; max-width: 420px; }
.login-list li { display: flex; gap: 14px; align-items: flex-start; font-size: 13.5px; line-height: 19px; color: #98A1AB; }
.login-list li b { display: block; color: #E6E9ED; font-weight: 600; margin-bottom: 1px; }
.login-list .ico { flex-shrink: 0; width: 34px; height: 34px; padding: 8px; border-radius: 8px; background: rgba(255,255,255,.06); color: #F08A5D; }
.login-coord { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: #7D8691; }
.login-coord span + span::before { content: ""; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: #4A525C; vertical-align: middle; margin: -2px 18px 0 -12px; }

.login-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 32px 24px; gap: 24px; }
.login-form {
  width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 36px 36px 28px;
  box-shadow: 0 1px 2px rgba(20,24,31,.04), 0 12px 32px -12px rgba(20,24,31,.12);
}
.login-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.login-head-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--paper); color: var(--ink); margin-bottom: 8px; }
.login-head-ico .ico { width: 20px; height: 20px; }
.login-h1 { font-size: 24px; line-height: 30px; font-weight: 600; letter-spacing: -.02em; }
.login-sub { font-size: 14px; line-height: 20px; color: var(--steel); }
.login-btn { gap: 8px; margin-top: 4px; }
.login-btn .ico { transition: transform var(--dur) var(--ease); }
.login-btn:hover .ico { transform: translateX(2px); }
.login-aide { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 18px; color: var(--steel); padding-top: 16px; border-top: 1px solid var(--line); }
.login-aide .ico { flex-shrink: 0; margin-top: 1px; color: var(--muted); }
.login-pied { font-size: 12px; color: var(--muted); text-align: center; }

@media (max-width: 1023px) {
  .login { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-side { padding: 20px 20px 22px; gap: 0; }
  .login-side::after { width: 100%; height: 3px; bottom: auto; }
  .login-pitch, .login-coord { display: none; }
  .login-shop { font-size: 18px; line-height: 24px; }
  .login-mark { width: 40px; height: 40px; }
  .login-main { justify-content: flex-start; padding: 24px 16px 20px; }
  .login-form { padding: 24px 20px 20px; border-radius: 12px; }
  .login-h1 { font-size: 22px; line-height: 28px; }
}

/* ==========================================================================
   Facture et ticket à l'écran sur téléphone
   ========================================================================== */
@media screen and (max-width: 767px) {
  .page-actions .seg-btn { padding: 0 10px; }
  .doc { padding: 18px 16px; border-radius: 12px; }
  .doc-head { flex-direction: column; gap: 14px; padding-bottom: 16px; }
  body:not(.fmt-ticket) .doc-head .text-right { text-align: left; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--paper); border-radius: 8px; }
  .doc-shop { font-size: 17px; }
  .doc-no { font-size: 18px; }
  .doc-meta { grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px 0; }
  .doc-meta > div:nth-child(2) { grid-column: 1 / -1; order: -1; }
  .doc-meta dt { font-size: 11px; }
  /* Lignes : désignation + « 2 sac × 4 800 » dessous, montant à droite */
  .doc-tbl .doc-a4-only, .doc-tbl th.doc-a4-only { display: none; }
  .doc-tbl .doc-ticket-only { display: block; font-size: 12.5px; margin-top: 2px; }
  .doc-tbl { font-size: 14px; }
  .doc-tbl td.num { white-space: nowrap; font-weight: 600; }
  .doc-totals { width: 100%; }
  .doc-totals .grand { font-size: 17px; }
  .doc-foot { flex-direction: column; gap: 4px; margin-top: 24px; }
  body.fmt-ticket .doc { max-width: none; }
}
/* Vente au détail : case « conditionnement », bascule d'unité sur les lignes du panier */
.check-inline { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; flex-wrap: wrap; }
.check-inline input { width: 16px; height: 16px; accent-color: var(--accent-600); }
.cond-box { padding: 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); background: #FAF9F6; }
.tk-unit { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; height: 26px; }
.tk-unit button { padding: 0 10px; font-size: 12px; font-weight: 500; color: var(--steel); background: transparent; }
.tk-unit button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.pcard-cond { font-size: 11px; color: var(--steel); }

/* Prix libre : prix à taper en caisse ; alerte vente à perte */
.pcard-price.is-libre { font-size: 13px; font-weight: 500; color: var(--steel); }
.tk-line.is-noprice .tk-price { border-color: var(--warn-ink, #9a6700); background: #FFF8E6; }
.tk-line.is-noprice .tk-meta { color: var(--warn-ink, #9a6700); font-weight: 500; }
.tk-line.is-perte .tk-meta { color: var(--danger); font-weight: 500; }
.tk-line.is-perte .tk-price { border-color: var(--danger); }
/* Ligne à prix libre : la case prix doit se voir */
.tk-line.is-libre .tk-x { color: var(--steel); font-weight: 500; }
.tk-line.is-libre .tk-price { width: 104px; height: 36px; font-weight: 600; font-size: 15px; color: var(--ink); border-color: var(--line-strong); }
.tk-line.is-libre .tk-price::placeholder { color: var(--warn-ink, #9a6700); font-weight: 600; }
