/* =====================================================================
   Lait Normandia (LN) — Design system
   Palette laiterie : lait, pâturage normand, beurre.
   ===================================================================== */
:root {
  --milk:        #FBFAF6;  /* fond général */
  --surface:     #FFFFFF;
  --pasture:     #1F5E3D;  /* vert primaire (pâturage) */
  --pasture-dk:  #16482F;
  --pasture-lt:  #E8F0EA;
  --butter:      #E4A93C;  /* accent beurre, usage rare */
  --ink:         #182018;
  --muted:       #6B7671;
  --line:        #E7E9E3;
  --danger:      #B23A2E;
  --radius:      14px;
  --shadow:      0 1px 2px rgba(24,32,24,.05), 0 8px 24px rgba(24,32,24,.06);
  --font-body:   'Inter', system-ui, -apple-system, sans-serif;
  --font-display:'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--milk);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* --- Marque ---------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { flex: 0 0 auto; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -.01em;
  line-height: 1;
}
.brand-name .ln-sub {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 3px;
}

/* =====================================================================
   PAGE DE CONNEXION
   ===================================================================== */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.auth-hero {
  background: linear-gradient(160deg, var(--pasture) 0%, var(--pasture-dk) 100%);
  color: #EAF2EC;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-hero .brand-name { color: #fff; }
.auth-hero .brand-name .ln-sub { color: #A9CBB5; }

.auth-hero-body { max-width: 380px; }
.auth-hero-body h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 40px;
  line-height: 1.08;
  letter-spacing: -.02em;
  margin-bottom: 16px;
}
.auth-hero-body h1 em {
  font-style: italic;
  color: var(--butter);
}
.auth-hero-body p { color: #B9D3C1; font-size: 15px; }

/* Grande goutte de lait, signature de la page */
.droplet {
  position: absolute;
  right: -60px;
  bottom: -40px;
  opacity: .12;
  width: 320px;
  height: 320px;
}

.auth-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card > .brand { display: none; }
.auth-card h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  margin-bottom: 6px;
}
.auth-card .lead { color: var(--muted); margin-bottom: 28px; }

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none;
  border-color: var(--pasture);
  box-shadow: 0 0 0 3px var(--pasture-lt);
}

.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  width: 100%;
  background: var(--pasture);
  color: #fff;
  font-size: 15px;
}
.btn-primary:hover { background: var(--pasture-dk); }
.btn-primary:disabled { opacity: .6; cursor: progress; }

.alert {
  display: none;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 18px;
  background: #FBEAE8;
  color: var(--danger);
  border: 1px solid #F0CFCB;
}
.alert.show { display: block; }

.auth-hint {
  margin-top: 22px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

/* =====================================================================
   COQUILLE APPLICATION (tableau de bord)
   ===================================================================== */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--pasture-dk);
  color: #CFE0D5;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 100vh;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 7px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }
.sidebar .brand { padding: 4px 8px 20px; }
.sidebar .brand-name { color: #fff; }
.sidebar .brand-name .ln-sub { color: #86AD94; }

.nav-label {
  font-size: 10.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #7BA189;
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: #CFE0D5;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--pasture); color: #fff; }
.nav-item .soon {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--pasture-dk);
  background: var(--butter);
  padding: 2px 6px;
  border-radius: 20px;
}

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 66px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}
.topbar h1 { font-size: 18px; font-weight: 600; }

.user-chip { display: flex; align-items: center; gap: 12px; }
.user-meta { text-align: right; line-height: 1.25; }
.user-meta .u-name { font-size: 14px; font-weight: 600; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  background: var(--pasture-lt);
  color: var(--pasture-dk);
  text-transform: capitalize;
}
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--pasture);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 15px;
}
.btn-ghost {
  background: none;
  border: 1.5px solid var(--line);
  color: var(--ink);
  padding: 8px 14px;
  font-size: 13px;
}
.btn-ghost:hover { border-color: var(--pasture); color: var(--pasture); }

.content { padding: 28px; overflow: auto; }

.welcome {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: var(--shadow);
  margin-bottom: 26px;
}
.welcome h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  margin-bottom: 6px;
}
.welcome p { color: var(--muted); max-width: 60ch; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.module-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.module-card .m-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.m-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--pasture-lt);
  display: grid; place-items: center;
}
.tag {
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px;
}
.tag.ready { background: var(--pasture-lt); color: var(--pasture-dk); }
.tag.soon  { background: #FBF0DA; color: #9A6C15; }
.module-card h3 { font-size: 15px; margin-bottom: 4px; }
.module-card p { font-size: 13px; color: var(--muted); }

/* --- Responsive : web étroit / mobile ------------------------------- */
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-card > .brand { display: flex; margin-bottom: 26px; }

  .layout { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    padding: 10px 12px;
  }
  .sidebar .brand { display: none; }
  .nav-label { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
  .nav-item .soon { display: none; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
}

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

/* =====================================================================
   CAISSE / POINT DE VENTE
   ===================================================================== */
.card-link { text-decoration: none; color: inherit; display: block; }
.card-link:hover .module-card { border-color: var(--pasture); }
.muted-text { color: var(--muted); font-size: 13.5px; }
.link {
  background: none; border: none; color: var(--pasture);
  font: inherit; font-weight: 600; cursor: pointer; padding: 0;
}
.link:hover { text-decoration: underline; }
.link-danger {
  background: none; border: none; color: var(--danger);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}

.pos-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }

.catalog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.catalog-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 20px; }
.btn-ghost.active { background: var(--pasture); color: #fff; border-color: var(--pasture); }

.cat-group { margin-bottom: 18px; }
.cat-title {
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 9px 2px;
}
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.prod-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.prod-add {
  background: none; border: none; cursor: pointer; text-align: left;
  padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 6px; font: inherit;
  transition: background .12s;
}
.prod-add:hover { background: var(--pasture-lt); }
.prod-name { font-weight: 600; font-size: 14.5px; color: var(--ink); }
.prod-price { font-weight: 700; color: var(--pasture); font-size: 15px; }
.stock-tag, .stock-pill {
  font-size: 11.5px; color: var(--muted);
  padding: 6px 14px; border-top: 1px solid var(--line); text-align: left;
}
.stock-pill { background: #F4F6F1; border: none; border-top: 1px solid var(--line);
  cursor: pointer; font: inherit; font-size: 11.5px; color: var(--pasture-dk); font-weight: 600; }
.stock-pill:hover { background: var(--pasture-lt); }
.stock-tag.low, .stock-pill.low { color: var(--danger); }

/* --- Panier --------------------------------------------------------- */
.cart-col { position: sticky; top: 20px; }
.cart {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: calc(100vh - 110px);
}
.cart-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.cart-head h3 { font-size: 16px; }
.cart-empty { padding: 28px 18px; text-align: center; color: var(--muted); font-size: 14px; }
.cart-lines { overflow-y: auto; padding: 6px 10px; flex: 1; }
.cart-line {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px; border-bottom: 1px solid var(--line); gap: 10px;
}
.cart-line:last-child { border-bottom: none; }
.cl-name { font-weight: 600; font-size: 14px; }
.cl-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 28px; height: 28px; border-radius: 8px; border: 1.5px solid var(--line);
  background: var(--surface); font-size: 16px; line-height: 1; cursor: pointer; color: var(--ink);
}
.stepper button:hover { border-color: var(--pasture); color: var(--pasture); }
.stepper span { min-width: 18px; text-align: center; font-weight: 600; }

.cart-foot { padding: 14px 18px; border-top: 1px solid var(--line); }
.pay-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.pay-btn {
  padding: 8px 4px; border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 9px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.pay-btn.active { border-color: var(--pasture); background: var(--pasture-lt); color: var(--pasture-dk); }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.cart-total strong { font-size: 22px; font-family: var(--font-display); color: var(--pasture-dk); }

/* --- Dernières ventes ---------------------------------------------- */
.recent {
  margin-top: 24px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px;
}
.recent h3 { font-size: 16px; margin-bottom: 10px; }
.recent-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.recent-row:last-child { border-bottom: none; }
.rr-ref { font-weight: 600; font-size: 14px; }
.rr-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.rr-right { display: flex; align-items: center; gap: 16px; }

/* --- Modales -------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; background: rgba(24,32,24,.5);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 300;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 360px; max-width: 100%; max-height: 92vh; overflow: auto; padding: 22px;
}
.modal-card.sm { width: 340px; }
.modal-card.wide { width: 720px; }
.modal-card h3 { font-size: 17px; margin-bottom: 6px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; min-width: 120px; }
.modal-actions .btn-primary { width: auto; }

/* --- Ticket (aperçu 80 mm) ----------------------------------------- */
.ticket {
  font-family: 'Courier New', monospace; color: #111;
  background: #fff; width: 300px; margin: 0 auto; padding: 6px 10px;
}
.ticket .t-center { text-align: center; }
.ticket .t-bold { font-weight: 700; }
.ticket .t-lg { font-size: 14px; }
.ticket .t-sm { font-size: 11px; color: #333; }
.ticket .t-row { display: flex; justify-content: space-between; font-size: 12px; margin: 2px 0; gap: 10px; }
.ticket .t-sep { border-top: 1px dashed #999; margin: 7px 0; }
.ticket .t-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ticket .t-table th, .ticket .t-table td { text-align: left; padding: 2px 0; vertical-align: top; }
.ticket .t-table .r { text-align: right; white-space: nowrap; }

/* --- Impression thermique 80 mm ------------------------------------ */
@media print {
  body * { visibility: hidden !important; }
  #printTicket, #printTicket * { visibility: visible !important; }
  #printTicket {
    position: absolute; left: 0; top: 0; width: 80mm; margin: 0; padding: 4mm;
  }
  @page { size: 80mm auto; margin: 0; }
}

/* --- Responsive caisse --------------------------------------------- */
@media (max-width: 900px) {
  .pos-layout { grid-template-columns: 1fr; }
  .cart-col { position: static; }
  .cart { max-height: none; }
}

.empty-note {
  background: var(--surface); border: 1px dashed var(--line); border-radius: 12px;
  padding: 22px; color: var(--muted); font-size: 14px; line-height: 1.6;
}
.empty-note.error { border-color: #E7B7B0; background: #FBEAE8; color: var(--danger); }
.empty-note code { background: rgba(0,0,0,.06); padding: 1px 6px; border-radius: 5px; font-size: 13px; }

/* =====================================================================
   TABLEAU DE BORD & RAPPORTS
   ===================================================================== */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.panel-head h3 { font-size: 16px; }

.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; border-left: 4px solid var(--line);
}
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 600; margin-top: 6px; color: var(--ink); }
.kpi-pasture { border-left-color: var(--pasture); }
.kpi-butter  { border-left-color: var(--butter); }
.kpi-danger  { border-left-color: var(--danger); }
.kpi-danger .kpi-value { color: var(--danger); }
.kpi-ink     { border-left-color: var(--pasture-lt); }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.chart-wrap { width: 100%; }

.top-list { display: flex; flex-direction: column; gap: 12px; }
.top-row { display: grid; grid-template-columns: 1fr 90px auto; align-items: center; gap: 12px; }
.top-name { font-size: 13.5px; font-weight: 500; }
.top-bar { height: 8px; background: var(--pasture-lt); border-radius: 6px; overflow: hidden; }
.top-bar span { display: block; height: 100%; background: var(--pasture); border-radius: 6px; }
.top-qty { font-weight: 700; font-size: 14px; text-align: right; white-space: nowrap; }
.top-qty small { color: var(--muted); font-weight: 500; }

/* Tables de données */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line);
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .r { text-align: right; }
.data-table td.neg { color: var(--danger); font-weight: 700; }
.data-table td.warn { color: #9A6C15; font-weight: 700; }
.table-scroll { overflow-x: auto; }

/* Rapports : contrôles */
.report-controls { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.report-controls .field { margin-bottom: 0; }
.report-controls select, .report-controls input[type=date] {
  font: inherit; padding: 10px 12px; border: 1.5px solid var(--line);
  border-radius: 10px; background: var(--surface);
}
.report-controls .btn-primary { width: auto; padding: 11px 22px; }
.result-summary { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.export-actions { display: flex; gap: 8px; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* =====================================================================
   MODULES DE GESTION (formulaires, badges, toasts)
   ===================================================================== */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field.checkbox { display: flex; align-items: center; }
.field.checkbox label { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; margin: 0; }
.field.checkbox input { width: 18px; height: 18px; accent-color: var(--pasture); }
.modal-card .field select,
.modal-card .field input[type=text],
.modal-card .field input[type=number],
.modal-card .field input[type=password] {
  width: 100%; font: inherit; padding: 11px 13px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface);
}
.modal-card .field select:focus,
.modal-card .field input:focus { outline: none; border-color: var(--pasture); box-shadow: 0 0 0 3px var(--pasture-lt); }

.pill { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.pill.on  { background: var(--pasture-lt); color: var(--pasture-dk); }
.pill.off { background: #F0EDE6; color: var(--muted); }

.achat-total { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 14px; }
.achat-total strong { font-family: var(--font-display); font-size: 20px; color: var(--pasture-dk); }

.ln-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--pasture-dk); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 500; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw;
}
.ln-toast.show { opacity: 1; transform: translate(-50%, 0); }
.ln-toast.err { background: var(--danger); }

/* Mouvements de caisse : badges et montants colorés */
.pill.out { background: #FBE9E7; color: var(--danger); }
.data-table td.pos { color: var(--pasture); font-weight: 600; }

/* ============================================================
   Module Clients — onglets, alertes, fiche, caisse crédit
   ============================================================ */

/* Onglets */
.tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 4px 0 16px; border-bottom: 1px solid var(--line);
}
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: 600 14px/1 'Inter', sans-serif; color: var(--muted);
  padding: 10px 14px; border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); background: var(--cream-2, #f2efe6); }
.tab.active { color: var(--pasture); border-bottom-color: var(--pasture); }
.tab-pane { display: block; }

/* En-tête de fiche client */
.client-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.client-head h2 { margin: 0 0 6px; font-family: 'Fraunces', serif; color: var(--pasture); }

/* Panneau d'alertes recouvrement */
.alert-panel { border-left: 4px solid var(--butter, #E4A93C); }
.alert-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 4px; border-top: 1px solid var(--line);
}
.alert-row:first-of-type { border-top: 0; }
.alert-row.late { color: #9a2b2b; }
.alert-when { font-weight: 600; font-size: 13px; white-space: nowrap; }
.alert-row.late .alert-when { color: #c0392b; }

/* Pastille prospect */
.pill.prospect { background: #e6efff; color: #2b52a3; }

/* Sélecteur client + infos dans la caisse */
.cart-client { padding: 10px 0; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.cart-client label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.cart-client select { width: 100%; }
.client-info { margin-top: 6px; font-size: 13px; font-weight: 600; }
.client-info .neg { color: #c0392b; }
.client-info .pos { color: var(--pasture); }

/* Champs vente à crédit */
.credit-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 10px; margin: 8px 0; border: 1px dashed var(--butter, #E4A93C);
  border-radius: 10px; background: #fffaf0;
}
.credit-fields .field { margin: 0; }
.credit-fields label { font-size: 12px; }

/* Défilement horizontal des tableaux */
.table-scroll { overflow-x: auto; }

/* ============================================================
   Clôture de caisse (rapport Z)
   ============================================================ */
.z-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.z-block.info { background: var(--cream-2, #f2efe6); }
.z-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; }
.z-row.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; font-size: 1.05rem; }
.z-row.pos strong { color: var(--pasture); }
.z-row.neg strong { color: #c0392b; }

.cloture-count { margin-top: 6px; }
.ecart-line { display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; margin: 4px 0 12px; border-radius: 10px; background: var(--cream-2, #f2efe6); font-size: 1.05rem; }
.ecart-line .pos { color: var(--pasture); }
.ecart-line .neg { color: #c0392b; }
.ecart-line .warn { color: var(--butter, #E4A93C); }

.data-table td.warn, .kpi-value.warn, strong.warn { color: #b8860b; }

/* Pastille "bientôt périmé" (stock & DLC) */
.pill.warn { background: #fff3d6; color: #8a6100; }

/* ============================================================
   Tableau de bord — tuiles d'échéances créances
   ============================================================ */
.echeance-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.echeance-tile {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  transition: transform .08s ease, box-shadow .12s ease; background: #fff;
}
.echeance-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.echeance-tile.is-empty { opacity: .55; }
.echeance-tile .et-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.echeance-tile .et-value { font-family: 'Fraunces', serif; font-size: 1.3rem; margin: 4px 0; }
.echeance-tile .et-sub { font-size: 12px; color: var(--muted); }
.echeance-tile.tile-danger { border-left: 4px solid #c0392b; }
.echeance-tile.tile-butter { border-left: 4px solid var(--butter, #E4A93C); }
.echeance-tile.tile-ink    { border-left: 4px solid var(--pasture); }
.creances-all { color: var(--pasture); font-weight: 600; text-decoration: none; border-bottom: 1px dashed currentColor; }
.creances-all:hover { opacity: .8; }

/* Caisse — remise */
.remise-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.remise-row label { font-size: 13px; font-weight: 600; color: var(--muted); }
.remise-row input { flex: 1; min-width: 0; }
.remise-unit { width: 90px; text-align: left; }
.cart-total.sub { color: var(--muted); font-size: .95rem; }
.cart-total.remise-line { color: #c0392b; }

/* Page Exports */
.export-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.export-actions .btn { width: auto; }

/* Droits d'accès — mot de passe temporaire */
.temp-result { margin: 12px 0; padding: 12px 14px; border: 1px solid var(--pasture); border-radius: 10px; background: #eef6f0; }
.temp-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.temp-code { font-family: 'Courier New', monospace; font-size: 1.4rem; font-weight: bold; color: var(--pasture); margin: 4px 0; user-select: all; }
.temp-msg { font-size: 13px; color: #555; }
.perm-select { min-width: 180px; }

/* Promotions */
.promo-tag { display:inline-block; margin-left:6px; padding:1px 6px; border-radius:6px;
  background:#c0392b; color:#fff; font-size:10px; font-weight:700; letter-spacing:.5px; vertical-align:middle; }
.prod-old { margin-left:6px; color:var(--muted); text-decoration:line-through; font-size:.8em; font-weight:400; }
.prod-tile.promo { outline:1px solid #f0c9c1; }
.promo-input.saved { border-color: var(--pasture); background:#eef6f0; }

/* Multi-caisse */
.caisse-select { padding:8px 10px; border:1px solid var(--line); border-radius:8px; background:#fff; font-weight:600; }
.aff-row { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px solid var(--line); }
.aff-row > span { flex:1; }
.aff-def { display:flex; align-items:center; gap:4px; font-size:13px; color:var(--muted); font-weight:400; }

/* Bouton danger (suppression) */
.btn-danger { background:#c0392b; color:#fff; border:1px solid #c0392b; }
.btn-danger:hover { background:#a93226; }

/* Affectation : ligne "Tout sélectionner" */
.aff-row.aff-all { border-bottom:2px solid var(--line); }

/* Promotions — ciblage caisses */
.promo-caisses { max-height:180px; overflow:auto; border:1px solid var(--line); border-radius:8px; padding:6px 10px; margin-bottom:10px; }

/* ============================================================
   Menu latéral en groupes repliables
   ============================================================ */
.nav-group { display: flex; flex-direction: column; }
.nav-group-head {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; border: none; background: none; cursor: pointer;
  font-family: inherit; color: #7BA189;
  font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; font-weight: 700;
  padding: 12px 12px 6px;
}
.nav-group-head:hover { color: #A9C7B5; }
.nav-group-head .chev { transition: transform .18s ease; opacity: .8; }
.nav-group.open .nav-group-head .chev { transform: rotate(180deg); }
.nav-group-items { display: none; flex-direction: column; gap: 4px; }
.nav-group.open .nav-group-items { display: flex; }

/* En écran étroit (barre horizontale), on déplie tout et on masque les entêtes de groupe */
@media (max-width: 860px) {
  .nav-group-head { display: none; }
  .nav-group-items { display: flex !important; flex-direction: row; }
}

/* ============================================================
   Cloche de notifications
   ============================================================ */
.notif-wrap { position: relative; margin-right: 6px; display: flex; align-items: center; }
.notif-bell {
  position: relative; background: none; border: 1px solid var(--line);
  border-radius: 10px; padding: 7px; cursor: pointer; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
}
.notif-bell:hover { background: #f3f1ea; }
.notif-badge {
  position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 9px; background: #c0392b; color: #fff;
  font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-width: 90vw;
  max-height: 70vh; overflow: auto; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); z-index: 60;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff;
}
.notif-list { display: flex; flex-direction: column; }
.notif-item {
  display: block; padding: 10px 14px; border-bottom: 1px solid #f0eee7;
  text-decoration: none; color: var(--ink);
}
.notif-item:hover { background: #f7f5ef; }
.notif-item.unread { background: #eef6f0; }
.notif-item.alerte { background: #fff7ed; }
.notif-item.alerte.danger { background: #fdecea; }
.ni-title { font-weight: 600; font-size: 14px; }
.ni-msg { font-size: 13px; color: #555; margin-top: 1px; }
.ni-date { font-size: 11px; color: var(--muted); margin-top: 2px; }
.notif-empty { padding: 20px 14px; text-align: center; color: var(--muted); }
.notif-foot { display: block; padding: 11px 14px; text-align: center; font-size: 13px;
  color: var(--pasture); text-decoration: none; border-top: 1px solid var(--line);
  position: sticky; bottom: 0; background: #fff; }
.notif-foot:hover { background: #f3f1ea; }

/* Centrage colonnes préférences */
.data-table th.c, .data-table td.c { text-align: center; }

/* Bouton "activé" (notifications navigateur) */
.btn.ok { background:#eef6f0; color:var(--pasture); border-color:var(--pasture); }

/* ============================================================
   Recherche produit + images produit
   ============================================================ */
.prod-search { margin: 0 0 12px; }
.prod-search input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 14.5px; font-family: inherit; background: #fff;
}
.prod-search input:focus { outline: none; border-color: var(--pasture); }

/* Image sur la tuile de caisse */
.prod-img {
  display: block; width: 100%; height: 84px; border-radius: 8px;
  background-size: cover; background-position: center; margin-bottom: 8px;
  background-color: #f0eee7;
}

/* Vignette dans la liste produits */
.thumb {
  display: inline-block; width: 34px; height: 34px; border-radius: 7px;
  background-size: cover; background-position: center; background-color: #f0eee7;
  vertical-align: middle;
}
.thumb.empty { background-color: #ece9e0; }

/* Sélecteur d'image dans le formulaire produit */
.img-picker { display: flex; align-items: center; gap: 14px; }
.img-preview {
  width: 74px; height: 74px; border-radius: 10px; border: 1px dashed var(--line);
  background-size: cover; background-position: center; background-color: #f7f5ef; flex: 0 0 auto;
}
.img-preview.has { border-style: solid; }
.img-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* ============================================================
   Responsive TÉLÉPHONE (≤ 640px) — sidebar en tiroir + barre compacte
   (la mise en page tablette ≥ 641px n'est pas modifiée)
   ============================================================ */
.nav-toggle { display: none; }
.sidebar-backdrop { display: none; }
.sidebar-logout { display: none; }

@media (max-width: 640px) {
  /* --- Sidebar en tiroir hors-écran --- */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 82%; max-width: 320px; height: 100%;
    flex-direction: column; align-items: stretch; gap: 6px;
    overflow-y: auto; overflow-x: hidden;
    padding: 18px 14px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
  }
  .layout.nav-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .sidebar .brand { display: flex; margin-bottom: 10px; }
  .nav-label { display: block; }
  .nav-group-head { display: flex; }
  .nav-group-items { display: none !important; flex-direction: column; }
  .nav-group.open .nav-group-items { display: flex !important; }
  .nav-item { width: 100%; white-space: normal; }
  .nav-item .soon { display: inline; }

  /* --- Fond sombre + hamburger --- */
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45);
    opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 199;
  }
  .layout.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: 1px solid var(--line); border-radius: 9px;
    padding: 6px; cursor: pointer; color: var(--ink); flex: 0 0 auto;
  }

  /* --- Barre du haut compacte --- */
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar h1 { flex: 1; min-width: 0; font-size: 1.1rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .user-chip .user-meta { display: none; }     /* nom/rôle masqués (l'avatar suffit) */
  .user-chip #logoutBtn { display: none; }      /* déconnexion déplacée dans le tiroir */

  /* Déconnexion en bas du tiroir */
  .sidebar-logout {
    display: flex; align-items: center; gap: 10px; margin-top: 12px;
    padding: 11px 12px; border: none; border-radius: 9px; cursor: pointer;
    background: rgba(255,255,255,.08); color: #ffd9d3; font-family: inherit;
    font-size: 14.5px; font-weight: 500; width: 100%; text-align: left;
  }

  /* --- Caisse : en-tête catalogue --- */
  .catalog-head { flex-wrap: wrap; gap: 8px; }
  .caisse-select { width: 100%; }
  .prod-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

  /* --- Modales pleine largeur --- */
  .modal-card, .modal-card.sm, .modal-card.wide { width: 94vw; }
  .content { padding: 14px; }
}

/* ============================================================
   Caisse — catalogue défilant (desktop/tablette) + panier en
   feuille du bas (téléphone)
   ============================================================ */
/* Éléments de la feuille du bas : masqués hors téléphone */
.cart-bar, .cart-backdrop, .cart-close { display: none; }

/* Desktop & tablette : seul le catalogue défile (pas tout l'écran) */
@media (min-width: 641px) {
  #catalogue { max-height: calc(100vh - 236px); overflow-y: auto; padding-right: 6px; }
  .cart-col { max-height: calc(100vh - 40px); }
  .cart { max-height: 100%; }
}

/* Écrans étroits (caisse en une colonne, y compris pliable déplié) : panier en feuille du bas */
@media (max-width: 900px) {
  .cart-col {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 150;
    margin: 0; max-height: 86vh;
    transform: translateY(100%); transition: transform .28s ease;
  }
  body.cart-open .cart-col { transform: translateY(0); }
  .cart { max-height: 86vh; overflow-y: auto; border-radius: 16px 16px 0 0;
          box-shadow: 0 -8px 30px rgba(0,0,0,.28); display: block; }
  /* La liste des articles prend sa hauteur naturelle (c'est .cart qui défile) */
  .cart-lines { display: block; flex: none; overflow-y: visible; }
  .cart-head { position: sticky; top: 0; background: #fff; z-index: 1; }
  .cart-close { display: inline-flex; margin-left: auto; background: none; border: none;
                font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }

  /* Barre panier fixe en bas (ouvre la feuille) */
  .cart-bar {
    display: flex; align-items: center; gap: 10px; width: 100%;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 149;
    padding: 12px 16px; border: none; cursor: pointer;
    background: var(--pasture); color: #fff; font-family: inherit; font-size: 15px;
  }
  body.cart-open .cart-bar { display: none; }
  .cb-count { background: #fff; color: var(--pasture); border-radius: 50%;
              min-width: 24px; height: 24px; display: inline-flex; align-items: center;
              justify-content: center; font-weight: 700; font-size: 13px; }
  .cb-total { margin-left: auto; font-weight: 700; font-size: 1.05rem; }
  .cb-caret { opacity: .85; }

  .cart-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45);
                   opacity: 0; pointer-events: none; transition: opacity .28s; z-index: 148; }
  body.cart-open .cart-backdrop { opacity: 1; pointer-events: auto; }

  /* De la place sous le catalogue pour ne pas masquer les derniers produits */
  .pos-layout { padding-bottom: 66px; }
}

/* Caisse — monnaie à rendre */
.rendu-line strong { color: var(--pasture); }
#cashFields { margin-bottom: 8px; }

/* Tableau de bord — répartition des paiements (anneau) */
.pm-box { min-height: 170px; }
.pm-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; padding: 6px 4px; }
.pm-center-t { font-family: var(--font-display); font-weight: 700; font-size: 26px; fill: var(--pasture); }
.pm-center-s { font-size: 11px; fill: var(--muted); }
.pm-legend { display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 190px; }
.pm-leg { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink); }
.pm-dot { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.pm-name { flex: 1; }
.pm-val { color: var(--muted); font-size: 12.5px; }

/* Gestion des catégories */
.cat-add { display: flex; gap: 8px; }
.cat-add input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; }
.cat-actions .link, .cat-actions .link-danger { margin-left: 8px; }
.cat-actions .link[disabled] { opacity: .3; cursor: default; }

/* Session de caisse — bannière d'état */
.sess-banner { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border-radius: 10px; margin-bottom: 14px; font-size: 13.5px; line-height: 1.4; }
.sess-banner.open { background: #E8F0EA; border: 1px solid #BcdCc7; color: #16482F; }
.sess-banner.closed { background: #FBEEDF; border: 1px solid #F0D6A9; color: #7a5a1e; }
.sess-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex: 0 0 auto; }
.sess-banner.open .sess-dot { background: #1F5E3D; box-shadow: 0 0 0 3px rgba(31,94,61,.18); }
.sess-banner.closed .sess-dot { background: #E4A93C; box-shadow: 0 0 0 3px rgba(228,169,60,.2); }
#openBox #rouvrirBtn { margin-top: 8px; }

/* Caisse fermée — bandeau de blocage */
.caisse-closed { grid-column: 1 / -1; background: #FBEEDF; border: 1px solid #F0D6A9;
  color: #7a5a1e; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.caisse-closed a { color: var(--pasture); font-weight: 600; }
.offline-banner { grid-column: 1 / -1; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px;
  font-size: 14px; background: #EAF2EC; border: 1px solid #C9E0D0; color: #235c3c; }
.offline-banner.warn { background: #FBEEDF; border-color: #F0D6A9; color: #7a5a1e; }
.offline-banner.err { background: #FBEAEA; border-color: #F0C0C0; color: #8a2c2c; }

/* Tableau de bord — filtre caisse */
.dash-filter { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.dash-filter label { font-size: 13px; color: var(--muted); font-weight: 600; }
.dash-filter select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-family: inherit; background: #fff; min-width: 200px; }

/* Champ de recherche des listes */
.search-input { width: 100%; box-sizing: border-box; padding: 10px 14px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 9px; font-family: inherit; font-size: 14px;
  background: #fff; }
.search-input:focus { outline: none; border-color: var(--pasture); box-shadow: 0 0 0 3px rgba(31,94,61,.12); }

/* Journal d'audit */
.audit-details { max-width: 420px; font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.data-table code { font-size: 12px; background: rgba(31,94,61,.08); padding: 2px 6px; border-radius: 5px; }

/* Pagination des listes */
.pager-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.pager-top .pager-size { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; background: #fff; }
.pager-top .pager-count { margin-left: auto; }
.pager-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pager-btns { display: flex; align-items: center; gap: 6px; }
.pager-btns button { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-family: inherit; font-size: 13px; cursor: pointer; color: var(--ink); }
.pager-btns button:hover:not(:disabled) { border-color: var(--pasture); color: var(--pasture); }
.pager-btns button:disabled { opacity: .45; cursor: default; }
.pager-page { padding: 0 6px; font-weight: 600; color: var(--ink); }

/* Sélecteur d'actualisation automatique (à côté des tuiles) */
.auto-refresh { display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.auto-refresh select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-family: inherit; font-size: 13px; }
.auto-refresh select:focus { outline: none; border-color: var(--pasture); box-shadow: 0 0 0 3px rgba(31,94,61,.12); }

/* Confirmation d'encaissement */
.confirm-summary { margin: 6px 0 10px; display: flex; flex-direction: column; gap: 6px; }
.confirm-summary .cs-total { display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.confirm-summary .cs-total strong { font-size: 24px; font-family: var(--font-display); color: var(--pasture-dk); }

/* Transferts entre dépôts */
.transfer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .transfer-grid { grid-template-columns: 1fr; } }
.btn-icon { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 30px; height: 30px;
  cursor: pointer; color: var(--muted); line-height: 1; }
.btn-icon:hover { border-color: var(--danger, #b3261e); color: var(--danger, #b3261e); }
.btn-link { background: none; border: none; padding: 0; color: var(--pasture); cursor: pointer; font: inherit; text-decoration: underline; }
.btn-link.danger { color: #b3261e; }
td.nowrap, .nowrap { white-space: nowrap; }

/* Actions sous une table de lignes (ajouter une ligne + valider) */
.line-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* Statut de validation des mouvements */
.mv-attente { color: #8a6100; font-size: 12px; margin-top: 4px; }
.mv-rejete  { color: var(--danger); font-size: 12px; margin-top: 4px; }
tr.row-rejete { opacity: .5; }
tr.row-attente td { background: #fffaf0; }

/* Jauges d'objectifs (tableau de bord) */
.obj-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 4px 0 18px; }
@media (max-width: 720px) { .obj-row { grid-template-columns: 1fr; } }
.obj-gauge { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.obj-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.obj-head strong { font-size: 20px; color: var(--pasture-dk); font-family: var(--font-display); }
.obj-head strong.ok { color: var(--pasture); }
.obj-bar { height: 10px; background: var(--line); border-radius: 6px; margin: 8px 0 6px; overflow: hidden; }
.obj-fill { height: 100%; background: var(--pasture); border-radius: 6px; transition: width .5s ease; }
.obj-fill.ok { background: linear-gradient(90deg, var(--pasture), #e0b84c); }
.obj-sub { font-size: 13px; color: var(--muted); }

/* Analyses — variations */
.kpi-sub.pos { color: var(--pasture); font-weight: 600; }
.kpi-sub.neg { color: var(--danger); font-weight: 600; }
