body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}
.topbar-logo {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--amber-d);
  white-space: nowrap;
}
.topbar-logo span {
  color: var(--ink);
}
.session-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 0.65rem;
  font-weight: 800;
  white-space: nowrap;
  border: 1.5px solid;
  transition: all 0.2s;
}
.session-chip.ouverte {
  background: var(--green-l);
  border-color: #a7f3d0;
  color: #065f46;
}
.session-chip.fermee {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--ink3);
}
.session-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.session-chip.ouverte .dot {
  background: var(--green);
  animation: pulse 2s infinite;
}
.session-chip.fermee .dot {
  background: var(--ink4);
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}
.offline-chip {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 0.65rem;
  font-weight: 800;
  white-space: nowrap;
  background: var(--amber-l);
  border: 1.5px solid var(--border-d);
  color: var(--amber-dd);
}
.offline-chip.show {
  display: flex;
}
.offline-chip .sc {
  background: var(--amber-d);
  color: white;
  border-radius: var(--r-full);
  padding: 0 5px;
  font-size: 0.6rem;
  font-weight: 900;
  display: none;
}
.offline-chip .sc.show {
  display: inline;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-time {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink3);
  white-space: nowrap;
}
.btn-session {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 800;
  border: 1.5px solid;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-sans);
  transition: all var(--t-fast);
}
.btn-session.ouvrir {
  background: var(--amber-l);
  border-color: var(--border-d);
  color: var(--amber-dd);
}
.btn-session.ouvrir:hover {
  background: var(--amber);
  color: var(--ink);
}
.btn-session.fermer {
  background: var(--rust-l);
  border-color: #fca5a5;
  color: var(--rust);
}
.btn-session.fermer:hover {
  background: #fee2e2;
}
.btn-ico {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.btn-ico:hover {
  border-color: var(--rust);
  background: var(--rust-l);
}

/* SYNC BANNER */
.sync-banner {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--amber-l);
  border-bottom: 1.5px solid var(--border-d);
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--amber-dd);
  flex-shrink: 0;
}
.sync-banner.show {
  display: flex;
}
.sb-spin {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--amber-d);
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* STATS */
.stats-bar {
  display: flex;
  gap: 7px;
  padding: 7px 12px 5px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.stats-bar::-webkit-scrollbar {
  display: none;
}
.stat-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  padding: 3px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.stat-chip .sv {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--amber-d);
}
.stat-chip .sl {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ink3);
}

/* LAYOUT */
.main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}
.panel-produits {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* PILLS */
.cats-bar {
  display: flex;
  gap: 5px;
  padding: 7px 12px 5px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.cats-bar::-webkit-scrollbar {
  display: none;
}
.cat-pill {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px 11px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--ink3);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.cat-pill.active {
  background: var(--amber);
  border-color: var(--amber-d);
  color: var(--ink);
}

/* GRILLE */
.produits-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.produits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  gap: 8px;
}
.prod-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  position: relative;
  transition: all 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.prod-card:hover {
  border-color: var(--amber);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.prod-card:active {
  transform: scale(0.94);
}
.prod-card.in-panier {
  border-color: var(--amber-d);
  background: var(--amber-l);
}
.prod-card.rupture {
  opacity: 0.4;
  pointer-events: none;
}
.prod-card .p-ico {
  font-size: 2rem;
  line-height: 1;
}
.prod-card .p-nom {
  font-size: 0.72rem;
  font-weight: 900;
  color: var(--ink);
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
}
.prod-card .p-prix {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--amber-d);
}
.prod-card .p-stock {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--r-full);
  color: var(--ink3);
  background: var(--surface2);
}
.prod-card .p-stock.bas {
  color: var(--amber-dd);
  background: var(--amber-l);
}
.prod-card .p-stock.zero {
  color: var(--rust);
  background: var(--rust-l);
}
.qty-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--amber-d);
  border: 2px solid white;
  font-size: 0.65rem;
  font-weight: 900;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0);
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.prod-card.in-panier .qty-badge {
  opacity: 1;
  transform: scale(1);
}
@keyframes flash-add {
  0% {
    background: var(--amber-l);
  }
  100% {
    background: var(--surface);
  }
}
.prod-card.flash {
  animation: flash-add 0.22s ease;
}
.empty-grid {
  grid-column: 1/-1;
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.empty-grid .ei {
  font-size: 3rem;
  opacity: 0.3;
}
.empty-grid .et {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink2);
}
.empty-grid .es {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink3);
}
.skel-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    var(--surface2) 50%,
    var(--border) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* PANIER DESKTOP */
.panel-panier {
  width: 285px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panier-head {
  padding: 11px 12px 9px;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}
.panier-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.panier-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink);
}
.panier-badge {
  background: var(--amber);
  color: var(--ink);
  font-size: 0.62rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: var(--r-full);
}
.btn-annuler {
  width: 100%;
  margin-top: 7px;
  padding: 6px;
  border: 1.5px solid #fca5a5;
  border-radius: var(--r-sm);
  background: var(--rust-l);
  color: var(--rust);
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--t-fast);
}
.btn-annuler:hover:not(:disabled) {
  background: #fee2e2;
}
.btn-annuler:disabled {
  opacity: 0.38;
  pointer-events: none;
}
.panier-liste {
  flex: 1;
  overflow-y: auto;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.panier-vide {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink3);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  padding: 16px;
}
.panier-vide .pv-ico {
  font-size: 2.2rem;
  opacity: 0.3;
}
.panier-item {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 7px 8px;
  animation: fadeSlide 0.14s ease;
}
.pi-ico {
  font-size: 1.1rem;
  flex-shrink: 0;
}
.pi-info {
  flex: 1;
  min-width: 0;
}
.pi-nom {
  font-size: 0.72rem;
  font-weight: 900;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pi-sub {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ink3);
}
.pi-ctrl {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.pi-btn {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 900;
  color: var(--ink2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.pi-btn:hover {
  background: var(--amber-l);
  border-color: var(--amber);
}
.pi-btn.m:hover {
  background: var(--rust-l);
  border-color: #fca5a5;
}
.pi-qty {
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--ink);
  min-width: 18px;
  text-align: center;
}
.panier-footer {
  border-top: 2px solid var(--border);
  padding: 10px 12px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.total-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink);
}
.total-val {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--amber-d);
}
.btn-valider {
  width: 100%;
  padding: 13px;
  border-radius: var(--r-md);
  border: none;
  background: var(--amber);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all var(--t-fast);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.38);
}
.btn-valider:hover:not(:disabled) {
  background: var(--amber-d);
}
.btn-valider:active:not(:disabled) {
  transform: scale(0.98);
}
.btn-valider:disabled {
  opacity: 0.4;
  pointer-events: none;
}
.btn-vider {
  width: 100%;
  padding: 7px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--ink3);
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn-vider:hover {
  border-color: var(--rust);
  color: var(--rust);
  background: var(--rust-l);
}

/* MOBILE BAR */
.mobile-bar {
  display: none;
  position: fixed;
  bottom: 62px;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 2px solid var(--border);
  padding: 9px 14px;
  padding-bottom: max(9px, env(safe-area-inset-bottom));
  align-items: center;
  gap: 10px;
  z-index: 50;
  box-shadow: 0 -4px 18px rgba(120, 70, 10, 0.12);
}
.mb-info {
  flex: 1;
}
.mb-count {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink3);
}
.mb-total {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--amber-d);
}
.btn-panier {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 11px 16px;
  border-radius: var(--r-md);
  background: var(--amber);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 900;
  border: none;
  cursor: pointer;
  position: relative;
  transition: background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.btn-panier:hover {
  background: var(--amber-d);
}
.bp-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--rust);
  border: 2px solid white;
  font-size: 0.58rem;
  font-weight: 900;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* BOTTOM SHEET */
.bs {
  position: fixed;
  inset: 0;
  bottom: 60px;
  z-index: 80;
  pointer-events: none;
}
.bs.open {
  pointer-events: all;
}
.bs-bg {
  position: absolute;
  inset: 0;
  background: rgba(28, 18, 9, 0.5);
  opacity: 0;
  transition: opacity 0.25s;
}
.bs.open .bs-bg {
  opacity: 1;
}
.bs-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.34, 1, 0.64, 1);
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
}
.bs.open .bs-panel {
  transform: translateY(0);
}
.bs-handle {
  width: 38px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}
.bs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
}
.bs-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
}
.bs-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--ink2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bs-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bs-footer {
  padding: 10px 16px;
  border-top: 1.5px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.bs-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bs-total-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ink);
}
.bs-total-val {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--amber-d);
}

/* MODALS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 18, 9, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  padding: 16px;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 22px;
  width: 100%;
  max-width: 400px;
  transform: translateY(20px);
  transition: transform 0.22s cubic-bezier(0.34, 1, 0.64, 1);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-overlay.open .modal {
  transform: translateY(0);
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
}
.modal-sub {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink3);
  margin-top: 2px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.btn-mc {
  flex: 1;
  padding: 11px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ink2);
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn-mc:hover {
  border-color: var(--ink2);
}
.btn-mok {
  flex: 2;
  padding: 11px;
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 900;
  cursor: pointer;
  transition: all var(--t-fast);
  color: white;
}
.btn-mok.green {
  background: var(--green);
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.3);
}
.btn-mok.green:hover {
  background: #047857;
}
.btn-mok.rust {
  background: var(--rust);
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.3);
}
.btn-mok.rust:hover {
  background: #b91c1c;
}
.num-wrap {
  display: flex;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
  transition: border-color var(--t-fast);
}
.num-wrap:focus-within {
  border-color: var(--amber);
}
.num-btn {
  width: 44px;
  height: 46px;
  border: none;
  background: var(--surface2);
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--ink2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--t-fast);
}
.num-btn:hover {
  background: var(--border);
}
.num-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
  padding: 10px 4px;
}
.recap-session {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.rs-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink2);
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 7px 10px;
}
.rs-row.hi {
  background: var(--amber-l);
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--ink);
}

/* RESPONSIVE */
@media (max-width: 680px) {
  .panel-panier {
    display: none;
  }
  .mobile-bar {
    display: flex;
  }
  .main {
    padding-bottom: 72px;
  }
  .produits-grid {
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 7px;
  }
  .prod-card {
    padding: 10px 6px 8px;
  }
  .prod-card .p-ico {
    font-size: 1.7rem;
  }
  .prod-card .p-nom {
    font-size: 0.68rem;
  }
}
@media (max-width: 400px) {
  .produits-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 900px) {
  .panel-panier {
    width: 305px;
  }
  .produits-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}
