/* ==========================================================================
   Fontanges Stock — feuille de style
   Vert profond, doré discret, fond crème. Pensé d'abord pour le téléphone.
   ========================================================================== */
:root {
  --green-900: #13261D;
  --green-800: #1F3A2E;
  --green-700: #2A4D3D;
  --green-100: #E5ECE7;
  --gold: #B08D57;
  --gold-soft: #EFE4CF;
  --cream: #F6F2EA;
  --paper: #FFFFFF;
  --ink: #1D2420;
  --muted: #6E756F;
  --line: #E6E0D4;
  --line-soft: #F0EBE1;

  --c-sortie: #A3423A;     --c-sortie-bg: #F8E9E6;
  --c-entree: #2E7D4F;     --c-entree-bg: #E4F2E9;
  --c-transfert: #2F5D7C;  --c-transfert-bg: #E3EDF4;
  --c-inventaire: #8A6A2F; --c-inventaire-bg: #F4ECDA;
  --c-warn: #C0662B;       --c-warn-bg: #FBEDE2;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(19, 38, 29, .05), 0 4px 16px rgba(19, 38, 29, .06);
  --shadow-lg: 0 10px 40px rgba(19, 38, 29, .18);
  --serif: "Inter", Arial, Calibri, "Segoe UI", sans-serif;
  --sans: "Inter", Arial, Calibri, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar: 248px;
  --bottom-nav: 68px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.45;
  color: var(--ink); background: var(--cream);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-family: var(--serif); font-size: 30px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; color: var(--green-800); }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
p { margin: 0; }
.ic { flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 600; margin-bottom: 4px; }
[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   Structure
   -------------------------------------------------------------------------- */
.main { max-width: 1180px; margin: 0 auto; padding: 20px 16px calc(var(--bottom-nav) + 28px); }
.sidebar { display: none; }

.bottom-nav {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  height: calc(var(--bottom-nav) + env(safe-area-inset-bottom));
  padding: 6px 8px env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.bottom-nav a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); font-weight: 500; }
.bottom-nav a.on { color: var(--green-800); }
.bottom-nav a.on::before { content: ""; position: absolute; top: -7px; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--gold); }
.bottom-nav .dot { position: absolute; top: -4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--c-warn); color: #fff; font-size: 10px; font-style: normal; font-weight: 700; display: grid; place-items: center; }
.fab {
  justify-self: center; width: 58px; height: 58px; margin-top: -26px; border: 0; border-radius: 50%;
  background: var(--green-800); color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 18px rgba(31, 58, 46, .35), 0 0 0 5px var(--cream);
  transition: transform .15s;
}
.fab:active { transform: scale(.94); }

@media (min-width: 960px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 20;
    display: flex; flex-direction: column; padding: 22px 14px;
    background: var(--green-800); color: #DCE5DF;
  }
  .main { margin-left: var(--sidebar); padding: 32px 36px 48px; max-width: calc(1180px + var(--sidebar)); }
  body:not(.auth) .main { margin-left: var(--sidebar); }
  .bottom-nav { display: none; }
  .hide-lg { display: none !important; }
}
@media (max-width: 959px) { .hide-sm { display: none !important; } }

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 14px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-family: var(--serif); font-size: 26px; font-weight: 700; color: var(--green-900);
  background: linear-gradient(135deg, #D8BC86, var(--gold));
}
.brand-mark.lg { width: 64px; height: 64px; font-size: 40px; border-radius: 18px; margin: 0 auto 16px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-family: var(--serif); font-size: 22px; color: #fff; }
.brand-text small { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; font-weight: 500; color: #C7D3CB; transition: background .15s, color .15s; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.on { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.side-nav .pill { margin-left: auto; background: var(--c-warn); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 10px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.side-user div { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.side-user strong { color: #fff; font-size: 14px; }
.side-user small { font-size: 12px; color: #9DB0A4; }
.side-user .icon-btn { color: #C7D3CB; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--gold-soft); color: var(--green-800); font-weight: 700; }
.avatar.add { background: var(--green-100); }

/* --------------------------------------------------------------------------
   Éléments communs
   -------------------------------------------------------------------------- */
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card > h2 { margin-bottom: 14px; }
.card-flush { padding: 0; overflow: hidden; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
#zones > .section-head { margin-top: 6px; }
.link { color: var(--gold); font-weight: 600; font-size: 13px; }
.link:hover { text-decoration: underline; }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 500; margin-bottom: 12px; }
.crumb:hover { color: var(--green-800); }
.page-head { margin-bottom: 18px; }
.page-head h1 { margin-bottom: 4px; }
.page-head.row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.two-col { display: grid; gap: 16px; }
.two-col > * { min-width: 0; }
.two-col > .card { margin-bottom: 0; }
.two-col + * { margin-top: 16px; }
@media (min-width: 960px) {
  .two-col { grid-template-columns: 1fr 1fr; align-items: start; }
  .two-col-wide { grid-template-columns: 1.5fr 1fr; }
}
.empty { color: var(--muted); padding: 22px 18px; text-align: center; }
.empty.ok { color: var(--c-entree); display: flex; gap: 8px; justify-content: center; align-items: center; }
.empty a { color: var(--gold); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent;
  font: 600 14px var(--sans); cursor: pointer; white-space: nowrap;
  transition: transform .1s, background .15s, box-shadow .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--green-800); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-ghost { background: var(--paper); border-color: var(--line); color: var(--green-800); }
.btn-ghost:hover { border-color: var(--gold); }
.btn-lg { height: 54px; font-size: 16px; border-radius: 14px; }
.btn-sm { height: 34px; padding: 0 10px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-sortie { background: var(--c-sortie); color: #fff; }
.btn-entree { background: var(--c-entree); color: #fff; }
.btn-transfert { background: var(--c-transfert); color: #fff; }
.btn-inventaire { background: var(--c-inventaire); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--c-sortie); border-color: #EBCFCB; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 0; background: transparent; display: inline-grid; place-items: center; color: var(--muted); cursor: pointer; }
.icon-btn:hover:not(:disabled) { background: var(--line-soft); color: var(--green-800); }
.icon-btn:disabled { opacity: .3; cursor: default; }

.badge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
.badge-warn { background: var(--c-warn-bg); color: var(--c-warn); }
.zdot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }

/* Formulaires */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1; min-width: 0; }
.field > span, .label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.label { margin: 4px 0 8px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { min-width: 180px; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=date], input:not([type]), select {
  width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px;
  background: #FCFBF8; font: 15px var(--sans); color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236E756F' stroke-width='2'%3E%3Cpath d='m2 4 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176, 141, 87, .18); background: #fff; }
fieldset { border: 0; padding: 0; margin: 0; }
fieldset:disabled input { color: var(--muted); }
.check { display: flex; gap: 10px; align-items: center; margin: 4px 0 18px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--green-800); }
.form-actions { margin-top: 18px; display: flex; justify-content: flex-end; }

.search { position: relative; display: flex; align-items: center; flex: 1; }
.search .ic { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 42px; }
.toolbar { display: flex; gap: 12px; align-items: center; padding: 14px 14px 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 14px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 17px; border: 1px solid var(--line);
  background: var(--paper); font: 500 13px var(--sans); color: var(--ink); cursor: pointer;
}
.chip.on { background: var(--green-800); border-color: var(--green-800); color: #fff; }

/* Toasts */
.toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100% - 28px)); }
.toast { padding: 13px 16px; border-radius: 12px; font-weight: 500; font-size: 14px; box-shadow: var(--shadow-lg); background: var(--green-800); color: #fff; animation: toast-in .3s ease-out; }
.toast-error { background: var(--c-sortie); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }

/* --------------------------------------------------------------------------
   Tableau de bord
   -------------------------------------------------------------------------- */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.hero .muted { margin-top: 4px; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.kpi { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; gap: 12px; align-items: center; }
.kpi strong { display: block; font-size: 24px; font-weight: 700; line-height: 1.1; color: var(--green-800); font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--green-100); color: var(--green-800); flex: none; }
.kpi-warn .kpi-ic { background: var(--c-warn-bg); color: var(--c-warn); }
.kpi-warn strong { color: var(--c-warn); }

.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 26px; }
.actions-compact { grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; }
.action {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 16px 6px; border-radius: var(--radius); font-weight: 600; font-size: 13px;
  background: var(--paper); box-shadow: var(--shadow); transition: transform .12s, box-shadow .15s;
}
.action:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.action:active { transform: scale(.97); }
.action .ic { width: 46px; height: 46px; padding: 11px; border-radius: 14px; }
.action-sortie .ic { background: var(--c-sortie-bg); color: var(--c-sortie); }
.action-entree .ic { background: var(--c-entree-bg); color: var(--c-entree); }
.action-transfert .ic { background: var(--c-transfert-bg); color: var(--c-transfert); }
.action-inventaire .ic { background: var(--c-inventaire-bg); color: var(--c-inventaire); }
.action-produit .ic { background: var(--gold-soft); color: var(--green-800); }
@media (max-width: 520px) {
  .actions { grid-template-columns: repeat(4, 1fr); }
  .actions .action-produit { display: none; }
  .action { padding: 12px 4px; font-size: 12px; }
  .action .ic { width: 42px; height: 42px; padding: 10px; }
  h1 { font-size: 25px; }
}

.zone-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 26px; }
@media (min-width: 720px) { .zone-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
.zone-card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 4px;
  padding: 16px; border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.zone-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--zc); }
.zone-card::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--zc); opacity: .06; }
.zone-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.zone-card h3 { font-family: var(--serif); font-size: 17px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); margin-top: 8px; }
.zone-card p { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zone-top { display: flex; justify-content: space-between; align-items: flex-start; }
.zone-ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--zc); color: #fff; }
.zone-ic.sm { width: 38px; height: 38px; border-radius: 11px; flex: none; }
.zone-ic.add { background: var(--green-100); color: var(--green-800); }
.zone-stats { display: flex; gap: 14px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--muted); }
.zone-stats strong { color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }
.zone-go { position: absolute; right: 14px; bottom: 14px; color: var(--muted); }
@media (max-width: 520px) {
  .zone-card { padding: 14px; }
  .zone-card h3 { font-size: 19px; }
  .zone-ic { width: 42px; height: 42px; }
  .zone-go { display: none; }
}

.alert-list, .mlist, .stock-list, .settings-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.alert-list li:first-child { border-top: 0; }
.alert-list strong { display: block; font-size: 14px; }
.alert-list small { color: var(--muted); font-size: 12px; }
.gauge { width: 70px; height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; flex: none; }
.gauge i { display: block; height: 100%; background: var(--c-warn); border-radius: 3px; }
.qty-warn { font-weight: 700; color: var(--c-warn); font-variant-numeric: tabular-nums; white-space: nowrap; }
.qty-warn small { font-weight: 500; color: var(--muted); }

.mrow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.mrow:first-child { border-top: 0; }
.mrow-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.mrow-main { flex: 1; min-width: 0; }
.mrow-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mrow-title a:hover { color: var(--gold); }
.mrow-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mrow-qty { font-weight: 700; font-variant-numeric: tabular-nums; background: none !important; }
.mnote { font-size: 12.5px; color: var(--muted); font-style: italic; padding: 0 0 10px 46px; margin-top: -6px; }
.mt-entree { background: var(--c-entree-bg); color: var(--c-entree); }
.mt-sortie { background: var(--c-sortie-bg); color: var(--c-sortie); }
.mt-transfert { background: var(--c-transfert-bg); color: var(--c-transfert); }
.mt-inventaire { background: var(--c-inventaire-bg); color: var(--c-inventaire); }

/* --------------------------------------------------------------------------
   Page zone
   -------------------------------------------------------------------------- */
.zone-hero {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 22px; margin-bottom: 14px; border-radius: 20px; color: #fff;
  background: linear-gradient(135deg, var(--zc), color-mix(in srgb, var(--zc) 70%, #000));
  box-shadow: var(--shadow-lg);
}
.zone-hero::after { content: ""; position: absolute; right: -60px; bottom: -80px; width: 240px; height: 240px; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); box-shadow: 0 0 0 30px rgba(255,255,255,.04); }
.zone-hero h1 { color: #fff; }
.zone-hero p { opacity: .8; font-size: 14px; }
.zone-hero-ic { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: rgba(255,255,255,.16); flex: none; }
.zone-hero-stats { display: flex; gap: 8px; position: relative; z-index: 1; }
.zone-hero-stats div { background: rgba(255,255,255,.14); padding: 8px 14px; border-radius: 12px; text-align: center; }
.zone-hero-stats strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.zone-hero-stats small { font-size: 11px; opacity: .85; }
.zone-hero-stats .warn { background: rgba(255, 200, 150, .28); }
@media (max-width: 640px) {
  .zone-hero { padding: 18px; }
  .zone-hero-ic { width: 52px; height: 52px; }
  .zone-hero-stats { width: 100%; }
  .zone-hero-stats div { flex: 1; }
}

.stock-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line-soft); transition: background .3s; }
.stock-row.is-low { background: linear-gradient(90deg, var(--c-warn-bg), transparent 60%); }
.stock-row.is-low .step-val b { color: var(--c-warn); }
.stock-row.flash { background: var(--gold-soft); }
.stock-name strong { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock-name small { display: block; color: var(--muted); font-size: 12px; }
a.stock-name:hover strong { color: var(--gold); }
.stepper { display: flex; align-items: center; gap: 4px; flex: none; }
.step {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper);
  display: grid; place-items: center; cursor: pointer; color: var(--green-800); transition: background .12s, transform .1s;
}
.step:hover { background: var(--green-100); }
.step:active { transform: scale(.92); }
.step:disabled { opacity: .35; }
.step-val { min-width: 62px; text-align: center; line-height: 1.1; }
.step-val b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.step-val small { font-size: 11px; color: var(--muted); }
.add-to-zone { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); background: #FCFBF8; }
.add-to-zone select { flex: 1; }
.total { text-align: right; line-height: 1.15; flex: none; }
.total b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.total small { font-size: 11px; color: var(--muted); }
.total .badge { margin-top: 4px; }
.chev { color: var(--muted); }
.zone-pills { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.zpill { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: color-mix(in srgb, var(--zc) 10%, #fff); color: var(--zc); font-weight: 500; }
.zpill b { font-weight: 700; }

/* --------------------------------------------------------------------------
   Mouvement
   -------------------------------------------------------------------------- */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin-bottom: 16px; border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); }
.seg a { display: flex; align-items: center; justify-content: center; gap: 6px; height: 44px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg a.on.seg-sortie { background: var(--c-sortie); color: #fff; }
.seg a.on.seg-entree { background: var(--c-entree); color: #fff; }
.seg a.on.seg-transfert { background: var(--c-transfert); color: #fff; }
@media (min-width: 960px) { .move-form, .seg { max-width: 760px; } }
.step-card h2 { display: flex; align-items: center; gap: 10px; }
.step-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--green-800); color: #fff; font-size: 13px; }
.zone-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.zpick input { position: absolute; opacity: 0; pointer-events: none; }
.zpick span {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--paper); font-weight: 500; font-size: 14px; cursor: pointer; transition: .12s;
}
.zpick span .ic { color: var(--zc); }
.zpick em { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 600; }
.zpick input:checked + span { border-color: var(--zc); background: var(--zc); color: #fff; }
.zpick input:checked + span .ic, .zpick input:checked + span em { color: #fff; }
.zpick input:disabled + span { opacity: .35; cursor: not-allowed; }
.zpick input:focus-visible + span { box-shadow: 0 0 0 3px rgba(176, 141, 87, .35); }

.product-pick { display: grid; gap: 6px; margin-top: 10px; max-height: 340px; overflow-y: auto; padding: 2px; }
@media (min-width: 720px) { .product-pick { grid-template-columns: 1fr 1fr; max-height: 420px; } }
.ppick { position: relative; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; border: 1.5px solid var(--line); cursor: pointer; transition: .12s; }
.ppick input { position: absolute; opacity: 0; pointer-events: none; }
.ppick-body { flex: 1; min-width: 0; }
.ppick strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ppick small { color: var(--muted); font-size: 12px; }
.ppick-check { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--line); color: transparent; flex: none; }
.ppick:has(input:checked) { border-color: var(--green-800); background: var(--green-100); }
.ppick:has(input:checked) .ppick-check { background: var(--green-800); border-color: var(--green-800); color: #fff; }

.big-stepper { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 6px 0 14px; }
.step-lg { width: 60px; height: 60px; border-radius: 18px; }
.big-val { text-align: center; }
.big-val input { width: 140px; height: 70px; text-align: center; font-size: 40px; font-weight: 700; border-radius: 16px; font-variant-numeric: tabular-nums; padding: 0; }
.big-val small { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.presets { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 10px; }
.hint { text-align: center; font-size: 13px; color: var(--muted); min-height: 18px; margin-bottom: 14px; }
.hint.err { color: var(--c-sortie); font-weight: 600; }
.has-sticky .main { padding-bottom: calc(var(--bottom-nav) + 100px); }
.sticky-submit {
  position: sticky; bottom: calc(var(--bottom-nav) + 10px + env(safe-area-inset-bottom)); z-index: 10;
  padding: 12px 0 0; background: linear-gradient(transparent, var(--cream) 30%);
}
.card-flush .sticky-submit { padding: 12px 14px 14px; background: var(--paper); border-top: 1px solid var(--line); bottom: calc(var(--bottom-nav) + env(safe-area-inset-bottom)); }
@media (min-width: 960px) { .sticky-submit { bottom: 16px; } .card-flush .sticky-submit { bottom: 0; } }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Inventaire */
.inv-input { width: 92px !important; text-align: center; font-weight: 700; font-size: 17px !important; flex: none; }
.inv-row.changed .inv-input { border-color: var(--c-inventaire); background: var(--c-inventaire-bg); }
.inv-diff { font-weight: 700; font-size: 13px; min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.inv-diff.pos { color: var(--c-entree); }
.inv-diff.neg { color: var(--c-sortie); }
.inv-summary { font-size: 13px; color: var(--muted); white-space: nowrap; font-weight: 600; }

/* Produit */
.zone-table { display: grid; gap: 2px; }
.zt-head, .zt-row { display: grid; grid-template-columns: 1fr 90px 110px; gap: 10px; align-items: center; }
.zt-head { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 0 8px 6px; }
.zt-row { padding: 6px 8px; border-radius: 10px; }
.zt-row.is-low { background: var(--c-warn-bg); }
.zt-row.is-low .zt-qty b { color: var(--c-warn); }
.zt-zone { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; }
.zt-qty b { font-size: 17px; font-variant-numeric: tabular-nums; }
.zt-row input { height: 40px; text-align: center; }
.danger-zone { display: flex; justify-content: flex-end; margin-top: 8px; }

/* Historique */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters select { flex: 1 1 160px; width: auto; }
.filters .date { display: flex; align-items: center; gap: 6px; flex: 1 1 160px; font-size: 13px; color: var(--muted); }
.filters .btn { flex: none; }

/* Réglages */
.settings-list li { border-top: 1px solid var(--line-soft); }
.settings-list li:first-child { border-top: 0; }
.settings-list li.is-off { opacity: .55; }
.settings-list summary { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; list-style: none; }
.settings-list summary::-webkit-details-marker { display: none; }
.settings-list summary strong { display: block; font-size: 14.5px; }
.settings-list summary small { color: var(--muted); font-size: 12.5px; }
.settings-list details[open] summary { padding-bottom: 6px; }
.inline { display: inline-flex; gap: 2px; }
.inline.right { display: flex; justify-content: flex-end; padding-bottom: 14px; }
.sub-form { padding: 14px; margin: 4px 0 10px; border-radius: 12px; background: #FCFBF8; border: 1px solid var(--line-soft); }
.swatches, .icon-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch input, .icon-pick input { position: absolute; opacity: 0; }
.swatch i { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 3px #fff; border: 2px solid transparent; }
.swatch input:checked + i { border-color: var(--c); }
.icon-pick span { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; border: 1.5px solid var(--line); background: var(--paper); cursor: pointer; color: var(--muted); }
.icon-pick input:checked + span { border-color: var(--green-800); color: var(--green-800); background: var(--green-100); }

/* Feuille d'actions rapides (mobile) */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(19, 38, 29, .45); animation: fade .2s; }
.sheet-panel {
  position: absolute; inset: auto 0 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  background: var(--paper); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-lg); animation: slide-up .25s cubic-bezier(.2, .9, .3, 1);
}
.sheet-panel h3 { font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--green-800); margin: 8px 0 16px; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.qa { display: flex; flex-direction: column; gap: 2px; padding: 16px; border-radius: 16px; }
.qa .ic { margin-bottom: 8px; }
.qa strong { font-size: 16px; }
.qa small { font-size: 12px; opacity: .75; }
.qa-sortie { background: var(--c-sortie-bg); color: var(--c-sortie); }
.qa-entree { background: var(--c-entree-bg); color: var(--c-entree); }
.qa-transfert { background: var(--c-transfert-bg); color: var(--c-transfert); }
.qa-inventaire { background: var(--c-inventaire-bg); color: var(--c-inventaire); }
@keyframes slide-up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* Connexion */
.auth { background: radial-gradient(circle at 20% 0%, var(--green-700), var(--green-900) 60%); min-height: 100vh; }
.auth .main { display: grid; place-items: center; min-height: 100vh; padding: 20px; margin: 0 auto; }
.auth-card { width: min(420px, 100%); background: var(--paper); border-radius: 24px; padding: 34px 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand h1 { margin-bottom: 8px; }
.auth-card .muted.small { margin-top: 16px; }

/* ==========================================================================
   V4 — tableaux, valorisation, entrées, lignes multiples
   ========================================================================== */
.nowrap { white-space: nowrap; }
.mt { margin-top: 18px; }
.pad { padding: 12px 18px 16px; }
.strong { font-weight: 600; }
.show-sm { display: none; }
@media (max-width: 959px) { .show-sm { display: block; } td.show-sm { display: table-cell; } }
.cap { font-weight: 500; color: var(--gold); }
.h1-cap { font-family: var(--sans); font-size: 18px; font-weight: 600; color: var(--gold); vertical-align: middle; margin-left: 4px; padding: 3px 10px; border-radius: 20px; background: var(--gold-soft); }
.cap-pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 8px; background: var(--line-soft); color: var(--ink); white-space: nowrap; }
.badge-gold { background: var(--gold-soft); color: #7A5C2A; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: #9C7A47; }
.evlink { color: var(--c-transfert); font-weight: 600; }
.evlink:hover { text-decoration: underline; }

/* Tableaux */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FCFBF8; white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table td small { display: block; font-size: 12px; color: var(--muted); }
.table td .badge { margin-top: 3px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr[data-href] { cursor: pointer; transition: background .12s; }
.table tbody tr[data-href]:hover { background: #FBF8F2; }
.table tbody tr.is-low td:first-child { box-shadow: inset 3px 0 0 var(--c-warn); }
.table tbody tr.is-low { background: linear-gradient(90deg, var(--c-warn-bg), transparent 55%); }
.table tbody tr.is-zero { color: var(--muted); }
.table tbody tr.is-unvalued td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.table tfoot td { padding: 12px 14px; font-weight: 700; background: var(--green-100); color: var(--green-800); }
.table tfoot .num { text-align: right; }
.table .chev, .table .actions-cell { width: 1%; text-align: right; color: var(--muted); }
.table .actions-cell .btn { margin-left: 4px; }
.table-compact td, .table-compact th { padding: 8px 6px; }
.table-compact th:first-child, .table-compact td:first-child { padding-left: 0; }
.inline-note { color: var(--gold); font-size: 11px; display: inline-flex !important; align-items: center; gap: 2px; }
.price-input { width: 110px !important; height: 40px !important; text-align: right; display: inline-block; }
@media (max-width: 640px) {
  .table { font-size: 13.5px; }
  .table th, .table td { padding: 10px 8px; }
  .table th:first-child, .table td:first-child { padding-left: 14px; }
  .table .chev { display: none; }
}

/* KPI */
.kpi em { display: block; font-style: normal; font-size: 11.5px; color: var(--gold); font-weight: 600; margin-top: 2px; }
a.kpi { transition: transform .15s, box-shadow .15s; }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-main strong { font-size: 28px; }
.kpi-gold .kpi-ic { background: var(--gold-soft); color: #7A5C2A; }
.kpi-gold strong { color: #7A5C2A; }
.kpis-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) { .kpis-3 { grid-template-columns: 1fr; } }
.actions-3 { grid-template-columns: repeat(3, 1fr) !important; }
.actions-3 .action { flex-direction: row; justify-content: center; gap: 12px; font-size: 15px; padding: 14px; }
@media (max-width: 520px) { .actions-3 .action { flex-direction: column; gap: 6px; font-size: 12.5px; } }

/* Cartes de zone */
.zone-units { font-size: 13px; color: var(--muted); margin-top: 6px; }
.zone-units strong { font-size: 22px; color: var(--ink); font-variant-numeric: tabular-nums; margin-right: 2px; }
.zone-value { font-size: 12.5px; font-weight: 600; color: var(--gold); padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .zone-units strong { font-size: 19px; } .zone-card h3 { font-size: 15px; line-height: 1.2; } }

/* Événements */
.ev-date { width: 48px; flex: none; text-align: center; font-size: 11px; color: var(--muted); line-height: 1.1; text-transform: uppercase; padding: 6px 0; border-radius: 10px; background: var(--line-soft); }
.ev-date b { display: block; font-size: 19px; color: var(--green-800); }
.stock-row.is-off { opacity: .55; }

/* Entrée : zone de réception obligatoire */
.reception-alert { display: flex; gap: 12px; padding: 12px 14px; margin-bottom: 14px; border-radius: 12px; background: #FBE9E7; color: #8E2B22; border: 1px solid #F0C4BE; }
.reception-alert strong { display: block; font-size: 14px; }
.reception-alert p { font-size: 13px; color: #8E2B22; opacity: .9; }
.zone-pick-required { padding: 10px; border: 1.5px dashed #E3A49B; border-radius: 14px; }
.zone-pick-required:has(input:checked) { border-color: transparent; padding: 0; }
.locked-zone { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 16px; border-radius: 12px; background: color-mix(in srgb, var(--zc) 8%, #fff); border: 1px solid color-mix(in srgb, var(--zc) 25%, #fff); color: var(--zc); }
.locked-zone div { flex: 1; }
.locked-zone small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.locked-zone strong { font-size: 16px; color: var(--ink); }

/* Sélecteur de références et lignes */
button.ppick { font: inherit; color: inherit; background: var(--paper); text-align: left; width: 100%; }
.ppick:hover { border-color: var(--green-700); }
.ppick-check { color: var(--green-800); }
.ppick.picked { border-color: var(--green-800); background: var(--green-100); }
.ppick.picked .ppick-check { background: var(--green-800); border-color: var(--green-800); color: #fff; }
.hint-zone { padding: 6px 0; }
.lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.line { border: 1.5px solid var(--line); border-radius: 14px; padding: 12px; background: #FCFBF8; animation: toast-in .2s ease-out; }
.line.err { border-color: #E3A49B; background: #FDF4F2; }
.line-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.line-head strong { display: block; font-size: 15px; }
.line-head small { color: var(--muted); font-size: 12px; }
.line-body { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.line-qty { width: 76px !important; height: 44px !important; text-align: center; font-size: 20px !important; font-weight: 700; padding: 0 !important; }
.line .step { width: 44px; height: 44px; }
.line-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.line-price { display: flex; align-items: center; gap: 8px; margin-left: auto; position: relative; }
.line-price span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.line-price input { width: 120px; height: 44px; text-align: right; padding-right: 28px; }
.line-price em { position: absolute; right: 12px; font-style: normal; color: var(--muted); }
.line-msg { font-size: 12.5px; color: var(--c-sortie); font-weight: 600; margin-top: 6px; }
.line-msg:empty { display: none; }
@media (max-width: 640px) { .line-price { margin-left: 0; width: 100%; } .line-price input { flex: 1; width: auto; } }
.seg a:not(.on):hover { color: var(--green-800); background: var(--line-soft); }

/* Inventaire */
.inv-head { display: grid; grid-template-columns: 1fr 70px 50px 92px; gap: 12px; padding: 4px 14px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.inv-head span:not(:first-child) { text-align: center; }
.inv-exp { width: 70px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.inv-diff { width: 50px; flex: none; }
@media (max-width: 520px) { .inv-head { display: none; } .inv-exp { display: none; } }

/* Fiche référence */
.zt-4 { grid-template-columns: 1fr 70px 110px 80px !important; }
.zt-2 { grid-template-columns: 1fr 110px !important; }
.zt-head:has(+ .zt-4), .zone-table .zt-head { grid-template-columns: 1fr 70px 110px 80px; }
.zt-row.is-zero { opacity: .5; }
.zt-row .num, .zt-head .num { text-align: right; }
a.zt-zone:hover { color: var(--gold); }
.details-card summary { list-style: none; cursor: pointer; }
.details-card summary::-webkit-details-marker { display: none; }
.details-card summary h2 { display: flex; align-items: center; gap: 8px; color: var(--green-800); }

/* Feuille mobile : liens secondaires */
.sheet-links { display: grid; gap: 2px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.sheet-links a { display: flex; align-items: center; gap: 10px; padding: 11px 6px; font-weight: 500; color: var(--green-800); border-radius: 10px; }
.sheet-links a:hover { background: var(--line-soft); }
.roles-help { padding-left: 18px; margin: 12px 0 0; display: grid; gap: 4px; }
@media (min-width: 960px) { .table .show-sm { display: none !important; } }

/* Logo du château */
.brand { flex-direction: column; align-items: center; gap: 6px; padding: 6px 8px 18px; }
.brand img { width: 100%; max-width: 190px; height: auto; display: block; }
.brand-app { font-size: 10.5px; font-weight: 700; letter-spacing: .32em; text-transform: uppercase; color: var(--gold); padding-left: .32em; }
.auth-logo { display: block; width: 230px; max-width: 80%; height: auto; margin: 0 auto 18px; }
.auth-brand h1 { font-size: 24px; }
.mobile-top { display: none; }
@media (max-width: 959px) {
  .mobile-top { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 25;
    padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top)); background: var(--green-800); color: #fff; }
  .mobile-top a { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 500; letter-spacing: -.01em; }
  .mobile-top img { height: 34px; width: auto; }
  .mobile-top b { color: var(--gold); font-weight: 700; }
  .avatar.sm { width: 30px; height: 30px; font-size: 13px; }
}

/* Création d'une référence à la volée */
.create-ref-btn { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 10px; padding: 12px 14px; border-radius: 12px;
  border: 1.5px dashed var(--gold); background: #FBF6EC; color: #7A5C2A; font: 600 14px var(--sans); cursor: pointer; text-align: left; }
.create-ref-btn:hover { background: var(--gold-soft); }
.create-ref-btn b { color: var(--green-800); }
.create-ref { margin-top: 10px; padding: 14px; border-radius: 14px; border: 1.5px solid var(--gold); background: #FFFCF6; animation: toast-in .2s ease-out; }
.create-ref-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.create-ref-head strong { display: flex; align-items: center; gap: 8px; color: var(--green-800); }
.create-ref .field-row .field { min-width: 130px; }
.create-ref-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.create-hint { margin-top: 8px; }

/* Retour en arrière (administrateur) */
.badge-cancel { background: #EEE9E2; color: #6E756F; margin-left: 4px; text-decoration: none; }
.badge-admin { background: var(--green-100); color: var(--green-800); }
.mrow.is-cancelled { opacity: .55; }
.mrow.is-cancelled .mrow-title, .mrow.is-cancelled .mrow-qty { text-decoration: line-through; }
.table tr.is-cancelled td { color: var(--muted); }
.table tr.is-cancelled td:not(:last-child) { text-decoration: line-through; text-decoration-color: rgba(0,0,0,.35); }
.table tr.is-cancelled .badge { text-decoration: none; }
.cancel-banner { display: flex; gap: 8px; align-items: center; padding: 10px 12px; margin-bottom: 14px; border-radius: 10px; background: #EEE9E2; color: var(--muted); font-size: 13px; font-weight: 500; }
.undo-card { border: 1.5px solid var(--gold-soft); }
.undo-card h2 { display: flex; align-items: center; gap: 8px; }
.undo-list { list-style: none; margin: 12px 0 0; padding: 0; }
.undo-list > li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.undo-list > li:first-child { border-top: 0; }
.undo-list strong { display: block; font-size: 14px; }
.undo-list small { color: var(--muted); font-size: 12px; }
.undo-moves { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.undo-moves li { font-size: 12px; padding: 3px 9px; border-radius: 8px; background: var(--line-soft); }
.undo-card .undo-list > li, .undo-confirm { align-items: center; }
.btn-undo { background: var(--paper); border-color: var(--line); color: var(--c-sortie); }
.btn-undo:hover { border-color: var(--c-sortie); background: var(--c-sortie-bg); }
.btn-undo-strong { background: var(--c-sortie); color: #fff; }
.undo-warning { display: flex; gap: 14px; padding: 16px 18px; margin-bottom: 16px; border-radius: 14px; background: #FDF1E8; border: 1px solid #F2CDAE; color: #8A4A1B; }
.undo-warning strong { display: block; font-size: 15px; margin-bottom: 4px; }
.undo-warning p { font-size: 13.5px; }
.undo-confirm { margin-top: 16px; }
.table small.up { display: inline; color: var(--c-entree); font-weight: 700; }
.table small.down { display: inline; color: var(--c-sortie); font-weight: 700; }
@media (max-width: 520px) { .undo-list .btn-sm { padding: 0 8px; } }
