/* ==========================================================================
   FF · Caisse — système de design commun (caisse + suivi)
   Thèmes : [data-theme="light"] / [data-theme="dark"] posés sur <html>.
   ========================================================================== */

:root {
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bebas Neue", "DM Sans", Impact, sans-serif;

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-full: 999px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  --topbar-h: 64px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --t-fast: 120ms;
  --t: 200ms;

  /* Marque */
  --brand-500: #e8a838;
  --brand-600: #d18f1c;
  --brand-700: #a86f0f;
}

/* ---------- Thème clair ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f4f1;
  --bg-grad: radial-gradient(1200px 500px at 0% -10%, rgba(232, 168, 56, 0.10), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f3f0ec;
  --surface-3: #ebe7e1;
  --surface-hover: #f7f5f2;
  --border: #e7e2db;
  --border-strong: #d6cfc5;
  --text: #1b1916;
  --text-2: #57514a;
  --text-3: #8a8279;
  --accent: #d18f1c;
  --accent-strong: #b97a0e;
  --accent-soft: #fbf0dc;
  --accent-ink: #1b1209;
  --on-accent: #1b1209;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf1e2;
  --danger: #c2321f;
  --danger-soft: #fdecea;
  --info: #1d4ed8;
  --info-soft: #e8eefd;
  --cb: #4338ca;
  --cb-soft: #ecebfd;
  --esp: #15803d;
  --esp-soft: #e7f6ec;
  --shadow-sm: 0 1px 2px rgba(27, 25, 22, 0.06), 0 1px 1px rgba(27, 25, 22, 0.04);
  --shadow-md: 0 6px 18px -6px rgba(27, 25, 22, 0.14), 0 2px 6px rgba(27, 25, 22, 0.05);
  --shadow-lg: 0 24px 60px -18px rgba(27, 25, 22, 0.28), 0 6px 18px rgba(27, 25, 22, 0.08);
  --ring: 0 0 0 3px rgba(209, 143, 28, 0.35);
  --scrim: rgba(27, 25, 22, 0.38);
  --topbar-bg: rgba(255, 255, 255, 0.82);
  /* Repères de catégories */
  --hue-0: #d18f1c;
  --hue-1: #dc4b3a;
  --hue-2: #1f9d63;
  --hue-3: #2b7fd6;
  --hue-4: #7c5ce0;
  --hue-5: #d6457f;
  --hue-6: #138f8f;
  --hue-7: #7a8f1a;
}

/* ---------- Thème sombre ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0d0c;
  --bg-grad: radial-gradient(1200px 500px at 0% -10%, rgba(232, 168, 56, 0.08), transparent 60%);
  --surface: #171614;
  --surface-2: #1f1d1a;
  --surface-3: #292622;
  --surface-hover: #1c1a18;
  --border: #2a2724;
  --border-strong: #3a3631;
  --text: #f4f1ed;
  --text-2: #bdb6ad;
  --text-3: #857e75;
  --accent: #f0ab3c;
  --accent-strong: #f6bd60;
  --accent-soft: rgba(240, 171, 60, 0.14);
  --accent-ink: #f6c46e;
  --on-accent: #1b1209;
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.13);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.13);
  --cb: #a5b4fc;
  --cb-soft: rgba(165, 180, 252, 0.14);
  --esp: #4ade80;
  --esp-soft: rgba(74, 222, 128, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 22px -8px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 28px 70px -20px rgba(0, 0, 0, 0.8), 0 8px 22px rgba(0, 0, 0, 0.45);
  --ring: 0 0 0 3px rgba(240, 171, 60, 0.4);
  --scrim: rgba(0, 0, 0, 0.6);
  --topbar-bg: rgba(14, 13, 12, 0.8);
  --hue-0: #f0ab3c;
  --hue-1: #f2715f;
  --hue-2: #4cc68d;
  --hue-3: #63a7f0;
  --hue-4: #a48cf5;
  --hue-5: #ef7aa8;
  --hue-6: #3cc2c2;
  --hue-7: #b5cc45;
}

/* Taille d'affichage (réglage) */
html[data-scale="sm"] { font-size: 14px; }
html,
html[data-scale="md"] { font-size: 16px; }
html[data-scale="lg"] { font-size: 18px; }

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body.app {
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "tnum" 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

html.theme-anim body.app,
html.theme-anim body.app * {
  transition: background-color var(--t) var(--ease), border-color var(--t) var(--ease),
    color var(--t) var(--ease), fill var(--t) var(--ease) !important;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); }
::selection { background: var(--accent-soft); }

.ic {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Scrollbars discrètes */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  flex: none;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-5);
  background: var(--topbar-bg);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  gap: 10px;
  text-decoration: none;
  flex: none;
}
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--display);
  font-size: 1.45rem;
  line-height: 1;
  padding-top: 2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), var(--shadow-sm);
}
.brand-text {
  font-family: var(--display);
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  line-height: 1;
  padding-top: 3px;
}

.topbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  /* Peut se resserrer : seul le prénom du caissier se coupe alors (voir caissiers.css). */
  min-width: 0;
}

.clock {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  padding: 0 var(--sp-2);
  min-width: 4.5ch;
  text-align: center;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-full);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 0 currentColor;
}
.live[data-state="live"] .live-dot {
  background: var(--ok);
  animation: live-pulse 2.4s var(--ease) infinite;
}
.live[data-state="offline"] .live-dot { background: var(--danger); }
.live[data-state="offline"] { color: var(--danger); }
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Bouton icône */
.icon-btn {
  position: relative;
  flex: none;
  width: 40px;
  min-width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn .ic { width: 20px; height: 20px; }
.icon-btn.is-on { color: var(--accent); background: var(--accent-soft); }
.icon-btn .badge-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.6875rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid var(--surface);
}

/* Icône du thème courant */
.theme-ic { display: none; }
[data-theme-pref="light"] .theme-ic-light,
[data-theme-pref="dark"] .theme-ic-dark,
[data-theme-pref="auto"] .theme-ic-auto { display: block; }

.fs-off { display: none; }
html.is-fullscreen .fs-on { display: none; }
html.is-fullscreen .fs-off { display: block; }

/* Actions de la barre de caisse (En attente, Plein écran, Réglages, Son) : icône seule sur téléphone et
   tablette, icône + libellé court sur grand écran. Le nom accessible vient de l'aria-label du bouton.
   Si la barre manque de place (caissier en service, pastille de dépannage…), FFCaisseUI ajoute .serre-2 à
   la barre (fitTopbar, ui.js) : les libellés disparaissent plutôt que de pousser Réglages hors de l'écran. */
.icon-btn-label { display: none; }
@media (min-width: 1024px) {
  .topbar:not(.serre-2) .topbar-end .icon-btn.has-label {
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    white-space: nowrap;
  }
  .topbar:not(.serre-2) .topbar-end .icon-btn.has-label .icon-btn-label { display: inline; font-size: 0.8125rem; font-weight: 600; }
  .topbar:not(.serre-2) .topbar-end .icon-btn.has-label .ic { width: 18px; height: 18px; }
  /* Le nombre de commandes en attente suit le libellé au lieu de couvrir l'icône. */
  .topbar:not(.serre-2) .topbar-end .icon-btn.has-label .badge-dot { position: static; border: 0; }
}

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .seg-btn.is-on { background: var(--surface-3); }
.seg-btn .ic { width: 17px; height: 17px; }
.seg-sm .seg-btn { height: 32px; padding: 0 11px; font-size: 0.8125rem; }
.nav-seg .seg-btn { min-width: 112px; height: 40px; }

/* ---------- Boutons ---------- */
.btn {
  --btn-h: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 18px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast),
    transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.btn .ic { width: 18px; height: 18px; }

.btn-sm { --btn-h: 36px; padding: 0 12px; font-size: 0.8125rem; border-radius: 9px; }
.btn-sm .ic { width: 16px; height: 16px; }
.btn-lg { --btn-h: 56px; padding: 0 22px; font-size: 1.0625rem; border-radius: var(--r-md); }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(0, 0, 0, 0.12);
}
.btn-primary:hover { background: var(--accent-strong); border-color: transparent; }
/* Bouton principal indisponible : contour pointillé, sans couleur d'accent (lisible dans tous les thèmes). */
.btn-primary:disabled,
.btn-primary[aria-disabled="true"] {
  background: var(--surface-2);
  color: var(--text-3);
  border: 1px dashed var(--border-strong);
  box-shadow: none;
  opacity: 1;
}
.btn-primary:disabled .kbd,
.btn-primary[aria-disabled="true"] .kbd { display: none; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }

.btn-soft { background: var(--surface-2); border-color: transparent; }
.btn-soft:hover { background: var(--surface-3); border-color: transparent; }

.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); border-color: transparent; }
.btn-danger-soft { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger-soft:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); border-color: transparent; }

.btn-ok { background: var(--ok); border-color: transparent; color: #fff; }
[data-theme="dark"] .btn-ok { color: #06240f; }

.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.6875rem;
  font-weight: 700;
  font-family: var(--font);
  line-height: 1;
}
.btn-primary .kbd {
  background: rgba(0, 0, 0, 0.12);
  border-color: rgba(0, 0, 0, 0.18);
  color: inherit;
}

/* ---------- Champs ---------- */
.field { display: grid; gap: 6px; }
.field > span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.input,
.field input,
.field textarea,
.field select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field textarea { height: auto; min-height: 80px; padding: 10px 14px; resize: vertical; }
.input:focus,
.field input:focus,
.field textarea:focus { border-color: var(--accent); box-shadow: var(--ring); outline: none; }
.input::placeholder,
.field input::placeholder { color: var(--text-3); }

.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search > .ic {
  position: absolute;
  left: 13px;
  width: 18px;
  height: 18px;
  color: var(--text-3);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 42px;
  padding: 0 40px 0 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.search input:focus { background: var(--surface); border-color: var(--accent); box-shadow: var(--ring); outline: none; }
.search input::-webkit-search-cancel-button { display: none; }
.search .search-kbd { position: absolute; right: 10px; pointer-events: none; }
/* Écran tactile ou étroit : pas de clavier, l'indication de touche ne sert à rien. */
@media (hover: none), (max-width: 900px) {
  .search .search-kbd { display: none; }
}
.search .search-clear {
  position: absolute;
  right: 6px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
}
.search .search-clear:hover { background: var(--surface-3); color: var(--text); }

/* ---------- Badges / tags ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.tag .ic { width: 13px; height: 13px; }
.tag-accent { background: var(--accent-soft); color: var(--accent-ink); }
[data-theme="light"] .tag-accent { color: var(--accent-strong); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-info { background: var(--info-soft); color: var(--info); }
.tag-cb { background: var(--cb-soft); color: var(--cb); }
.tag-esp { background: var(--esp-soft); color: var(--esp); }
.tag-tr { background: var(--surface-2); color: var(--text-2); }

/* ---------- Switch ---------- */
.switch { position: relative; display: inline-flex; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch-track {
  width: 46px;
  height: 28px;
  border-radius: 14px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background var(--t), border-color var(--t);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform var(--t) var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); border-color: transparent; }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }

/* Ordre d'empilement : barre haute 40 < barre FF 900 < panneau commande (téléphone) 1000 < tiroir < modales < toasts < calculatrice. */
/* ---------- Drawer (réglages) ---------- */
.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 1080;
  background: var(--scrim);
  animation: fade-in var(--t) var(--ease);
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1090;
  width: min(440px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 260ms var(--ease), visibility 0s linear 260ms;
}
.drawer.is-open {
  transform: none;
  visibility: visible;
  transition: transform 260ms var(--ease);
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.drawer-head h2 { margin: 0; font-size: 1.125rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-2) var(--sp-6) var(--sp-6); }
.drawer-foot { margin: var(--sp-6) 0 0; text-align: center; font-size: 0.75rem; color: var(--text-3); }

.set-group { padding: var(--sp-5) 0; border-bottom: 1px solid var(--border); }
.set-group:last-of-type { border-bottom: 0; }
.set-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 var(--sp-3);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
}
.set-switch { cursor: pointer; }
.set-link { cursor: pointer; border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-2); margin: 0 calc(var(--sp-2) * -1); width: calc(100% + var(--sp-4)); }
.set-link:hover { background: var(--surface-2); }
.set-link > .ic { color: var(--text-3); }
.set-label { display: grid; gap: 2px; min-width: 0; }
.set-label strong { font-size: 0.9375rem; font-weight: 600; }
.set-label span { font-size: 0.8125rem; color: var(--text-3); }
#scale-seg .seg-btn { min-width: 40px; height: 40px; }
#scale-seg .seg-btn[data-scale-set="sm"] { font-size: 0.75rem; }
#scale-seg .seg-btn[data-scale-set="md"] { font-size: 0.9rem; }
#scale-seg .seg-btn[data-scale-set="lg"] { font-size: 1.1rem; }
.set-danger .set-title { color: var(--danger); }

/* ---------- Modales ---------- */
.modal-root:empty { display: none; }
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: var(--scrim);
  animation: fade-in var(--t) var(--ease);
}
.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: pop-in 220ms var(--ease);
  overflow: hidden;
}
.modal-lg { width: min(760px, 100%); }
.modal-xl { width: min(980px, 100%); }
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-3) var(--sp-6);
}
.modal-head h2 { margin: 0; font-size: 1.1875rem; line-height: 1.3; }
.modal-head p { margin: 4px 0 0; color: var(--text-2); font-size: 0.875rem; }
.modal-head .icon-btn { margin-left: auto; margin-top: -4px; }
.modal-icon {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.modal-icon.is-danger { background: var(--danger-soft); color: var(--danger); }
.modal-icon .ic { width: 22px; height: 22px; }
.modal-body { padding: var(--sp-2) var(--sp-6) var(--sp-5); overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* Bouton à maintenir (confirmation forte) */
.btn-hold { position: relative; overflow: hidden; }
.btn-hold .hold-fill {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.22);
  transform-origin: left;
  transform: scaleX(0);
  pointer-events: none;
}
.btn-hold.is-holding .hold-fill { transform: scaleX(1); transition: transform var(--hold-ms, 1400ms) linear; }
.btn-hold > span { position: relative; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  left: 50%;
  top: calc(var(--topbar-h) + 12px);
  z-index: 1120;
  display: grid;
  gap: var(--sp-2);
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 12px 14px 12px 16px;
  border-radius: var(--r-md);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  font-size: 0.9375rem;
  pointer-events: auto;
  animation: toast-in 260ms var(--ease);
}
.toast.is-leaving { animation: toast-out 200ms var(--ease) forwards; }
.toast .ic { width: 20px; height: 20px; }
.toast-ok .ic { color: var(--ok); }
.toast-error .ic { color: var(--danger); }
.toast-info .ic { color: var(--accent); }
[data-theme="light"] .toast-ok .ic { color: #4ade80; }
[data-theme="light"] .toast-error .ic { color: #f87171; }
[data-theme="light"] .toast-info .ic { color: var(--brand-500); }
.toast-msg { flex: 1; min-width: 0; }
.toast-action {
  border: 0;
  background: rgba(127, 127, 127, 0.2);
  color: inherit;
  font-weight: 700;
  font-size: 0.8125rem;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
}

/* ---------- Raccourcis ---------- */
.shortcuts { display: grid; gap: 2px; margin: 0; }
.shortcuts > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.shortcuts > div:last-child { border-bottom: 0; }
.shortcuts dt { color: var(--text-2); }
.shortcuts dd { margin: 0; display: flex; gap: 4px; }

/* ---------- Liste des ruptures ---------- */
.stock-list { display: grid; gap: var(--sp-5); margin-top: var(--sp-3); }
.stock-cat h4 {
  margin: 0 0 var(--sp-2);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.stock-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.stock-row:hover { background: var(--surface-2); }
.stock-row.is-off .stock-name { color: var(--text-3); text-decoration: line-through; }
.stock-name { font-weight: 600; }

/* ---------- Bouton lien (caisse et suivi : « Prix carte », « Appliquer à la catégorie ») ---------- */
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  justify-self: start;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--info);
  font-size: 0.8125rem;
  font-weight: 600;
}
.link-btn .ic { width: 14px; height: 14px; }

/* ---------- TVA des produits ---------- */
.tva-list { display: grid; gap: var(--sp-4); margin-top: var(--sp-3); }
.tva-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--sp-3);
  padding: 6px 12px;
  border-radius: var(--r-sm);
}
.tva-row:hover { background: var(--surface-2); }
.tva-head { padding-block: 0; font-size: 0.75rem; font-weight: 700; color: var(--text-3); }
.tva-head:hover { background: none; }
.tva-head span { display: inline-flex; align-items: center; gap: 5px; min-width: 132px; }
.tva-head .ic { width: 14px; height: 14px; }
.tva-row-cat { background: var(--surface-2); }
.tva-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; font-weight: 600; }
.tva-row-cat .tva-name strong { font-size: 0.9375rem; }
.tva-chips { display: inline-flex; gap: 6px; min-width: 132px; }
.tva-chip {
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-2);
  font-weight: 650;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}
.tva-chip:hover { border-color: var(--accent); color: var(--text); }
.tva-chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tva-chip.is-inherited { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--text); }
@media (max-width: 640px) {
  .tva-row { grid-template-columns: 1fr 1fr; }
  .tva-name { grid-column: 1 / -1; }
  .tva-head span:first-child { display: none; }
  .tva-head span, .tva-chips { min-width: 0; }
}

/* ---------- Animations ---------- */
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px) scale(0.98); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ---------- Responsive topbar ---------- */
@media (max-width: 1100px) {
  .brand-text { display: none; }
  .clock { display: none; }
}
@media (max-width: 820px) {
  .topbar { gap: var(--sp-2); padding: 0 var(--sp-3); }
  /* Icône au-dessus d'un mot court : on reconnaît l'onglet sans lire. */
  .nav-seg .seg-btn {
    flex-direction: column;
    gap: 2px;
    height: 44px;
    min-width: 56px;
    padding: 2px 6px;
    font-size: 0.6875rem;
  }
  /* Le point seul à l'œil ; l'état (« En direct », « Hors ligne »…) reste lu par les lecteurs d'écran. */
  .live-text {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .live { padding: 0 10px; }
}

/* Ordinateur portable peu haut (≤ 820 px) : barre du haut plus basse, plus de place pour le travail. */
@media (max-height: 820px) and (min-width: 901px) {
  :root { --topbar-h: 52px; }
  .topbar .brand-text { font-size: 1rem; }
}

/* Téléphone (375 px) : barre du haut et fenêtres tiennent dans l'écran (aucun effet au-delà de 480 px). */
@media (max-width: 480px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .brand { display: none; }
  .topbar-end { gap: 0; min-width: 0; }
  .nav-seg .seg-btn { min-width: 48px; padding: 2px 4px; font-size: 0.6875rem; }
  .topbar-end .icon-btn { width: 40px; height: 40px; position: relative; }
  /* Zone de toucher de 44 px sans élargir la barre. */
  .topbar-end .icon-btn::after { content: ""; position: absolute; inset: -2px; }
  #btn-fullscreen { display: none; }
  .live { padding: 0 8px; }
  .modal-scrim { grid-template-columns: minmax(0, 1fr); padding: var(--sp-2); }
  .modal-head { padding: var(--sp-4) var(--sp-3) var(--sp-2) var(--sp-4); }
  .modal-body { padding: var(--sp-2) var(--sp-4) var(--sp-4); }
  .modal-foot { flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); }
  .modal .seg { flex-wrap: wrap; max-width: 100%; }
}

/* Pastille « Dépannage jusqu'à … » (appareil en dépannage) : quand la place manque (téléphone,
   tablette en portrait, téléphone couché), elle passe à la ligne au lieu de pousser Réglages
   hors de l'écran ; les autres éléments de la barre gardent leur taille. */
#poste-depannage {
  flex: 0 1 auto;
  min-width: 0;
  height: auto;
  min-height: 24px;
  padding-block: 3px;
  border-radius: 12px;
  line-height: 1.15;
  white-space: normal;
  text-align: center;
  text-wrap: balance;
  overflow: hidden;
}
#poste-depannage ~ * { flex-shrink: 0; }
@media (max-width: 600px) {
  #poste-depannage { padding-inline: 7px; font-size: 0.6875rem; }
}
@media (max-width: 480px) {
  #poste-depannage { margin-right: 4px; }
}

/* ---------- Impression ---------- */
@media print {
  body.app { overflow: visible; background: #fff; color: #000; display: block; }
  .topbar, .toasts, .drawer, .drawer-scrim, .no-print { display: none !important; }
}

/* ---------- Choix des tickets à réimprimer ---------- */
.ticket-choice { display: grid; gap: var(--sp-2); }
.ticket-opt {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.ticket-opt:hover, .ticket-opt:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.ticket-opt:active { transform: scale(0.98); }
.ticket-opt > span:nth-child(2) { flex: 1; display: grid; gap: 1px; }
.ticket-opt small { color: var(--text-3); }
.ticket-opt-ic { width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--surface-2); color: var(--accent); flex: none; }

/* SIRET absent ou invalide : bandeau fixe sous l'en-tête (la vente serait refusée). */
.bandeau-siret {
  flex: none;
  margin: 0;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--danger) 14%, var(--bg));
  color: var(--text);
  border-bottom: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  font-size: 0.875rem;
}
.bandeau-siret a { color: inherit; font-weight: 700; margin-left: 6px; }

/* ---------- Mode hors ligne (hors-ligne.js) ---------- */
.hl-bandeau {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 60;
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  background: var(--info-soft);
  color: var(--info);
  font: 600 0.95rem/1.2 var(--font);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  max-width: calc(100vw - 2 * var(--sp-4));
}
.hl-bandeau.is-hors-ligne { background: var(--danger-soft); color: var(--danger); }
.hl-bandeau.is-bloque { outline: 2px solid var(--danger); }
.hl-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.hl-table th, .hl-table td { padding: var(--sp-2); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.hl-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hl-moyens { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--sp-2); }
.hl-moyens .btn { min-height: 4rem; font-size: 1.05rem; }
.hl-note { margin-top: var(--sp-3); color: var(--danger); }
