/* ════════════════════════════════════════════════════════════
   MarketGarrido PWA — estilos globales
   Paleta: azul Larimar ERP + acento naranja
   ════════════════════════════════════════════════════════════ */

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

:root {
  --primary:      #1e3a8a;
  --primary-dark: #12205c;
  --primary-soft: #DBEAFE;
  --primary-tint: #EFF6FF;
  --accent:       #ff6a3d;
  --accent-soft:  #FEF3C7;
  --surface:      #FAFAF7;
  --card:         #FFFFFF;
  --text:         #1F2937;
  --text-soft:    #4B5563;
  --muted:        #6B7280;
  --border:       #E5E7EB;
  --border-soft:  #F3F4F6;
  --danger:       #DC2626;
  --warning:      #D97706;
  --info:         #3b82f6;
  --success:      #10B981;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(30,58,138,0.10);
  --shadow-lg: 0 12px 32px rgba(30,58,138,0.15);

  --radius-sm: 10px;
  --radius:    16px;
  --radius-lg: 22px;

  --bottombar-h: calc(64px + env(safe-area-inset-bottom));
  --topbar-h:    64px;
}

html, body {
  height: 100%;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100dvh;
  padding-top: var(--topbar-h);
  padding-bottom: var(--bottombar-h);
  background:
    radial-gradient(ellipse 600px 300px at top right, rgba(219,234,254,0.5) 0%, transparent 70%),
    radial-gradient(ellipse 400px 200px at bottom left, rgba(234,88,12,0.05) 0%, transparent 70%),
    var(--surface);
}

button { font-family: inherit; cursor: pointer; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ─────────────  Splash  ───────────── */
#splash {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: grid; place-items: center;
  z-index: 9999;
  color: white;
  text-align: center;
  transition: opacity 0.3s, visibility 0.3s;
}
#splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }

/* Logo MarketGarrido en splash */
.splash-mark {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  font-size: 38px;
  margin-bottom: 8px;
  color: #fff;
  letter-spacing: -0.02em;
  position: relative;
  display: inline-block;
  padding-bottom: 8px;
}
.splash-mark::after {
  content: '';
  position: absolute;
  left: 5%;
  right: 0;
  bottom: 2px;
  height: 6px;
  background: var(--accent);
  border-radius: 999px;
  transform: skewX(-3deg);
  width: 90%;
  box-shadow: 0 2px 8px rgba(234,88,12,0.5);
}

.splash-name {
  font-family: 'Manrope', sans-serif;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.05em;
  opacity: 0.85;
  text-transform: uppercase;
  margin-top: 4px;
}

.splash-spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  margin-top: 28px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────  Top bar  ───────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.topbar-right { display: flex; gap: 4px; }
.topbar-greet {
  font-size: 13px; color: var(--muted); font-weight: 500;
}
.topbar-suc {
  font-weight: 700; font-size: 15px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  background: transparent; border: none; color: var(--text);
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--border-soft); }

/* ─────────────  Bottom bar  ───────────── */
.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottombar-h);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-soft);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}
.navtab {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  position: relative;
  transition: color 0.15s;
}
.navtab svg { width: 22px; height: 22px; }
.navtab.active { color: var(--primary); }
.navtab.active::before {
  content: '';
  position: absolute; top: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}
/* ─────────────  Botón flotante WhatsApp  ───────────── */
.fab-whatsapp {
  position: fixed;
  right: 16px;
  bottom: calc(var(--bottombar-h) + 14px);
  width: 54px; height: 54px;
  background: #25D366;
  color: white;
  border-radius: 50%;
  display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
  z-index: 150;
  transition: transform 0.15s;
}
.fab-whatsapp:active { transform: scale(0.94); }

.navtab-cart { position: relative; }
.cart-badge {
  position: absolute; top: 4px; left: 50%; margin-left: 4px;
  background: var(--accent); color: white;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-size: 11px; font-weight: 700;
  border-radius: 9px;
  display: grid; place-items: center;
  border: 2px solid white;
}
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--accent); color: white;
  min-width: 16px; height: 16px; padding: 0 4px;
  font-size: 10px; font-weight: 700;
  border-radius: 8px;
  display: grid; place-items: center;
  border: 2px solid white;
}

/* ─────────────  Vista (contenedor)  ───────────── */
#view { padding: 16px; min-height: calc(100dvh - var(--topbar-h) - var(--bottombar-h)); }
.view-section { margin-bottom: 24px; }
.view-title {
  font-family: 'Fraunces', serif;
  font-weight: 700; font-size: 26px;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  color: var(--primary-dark);
}
.view-sub { color: var(--muted); font-size: 14px; margin-bottom: 16px; }

/* ─────────────  Cards genéricas  ───────────── */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
}
.card-row { display: flex; align-items: center; justify-content: space-between; }

/* ─────────────  Carrusel de banners  ───────────── */
.banner-carrusel{
  position: relative;
  margin: -4px -16px 16px;
  border-radius: 0;
  overflow: hidden;
  background: var(--primary-tint);
  aspect-ratio: 3 / 1;
}
.banner-track{
  display: flex;
  height: 100%;
  transition: transform .45s cubic-bezier(.4,0,.2,1);
  will-change: transform;
  touch-action: pan-y pinch-zoom;
}
.banner-slide{
  flex: 0 0 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  position: relative;
}
.banner-slide[data-link="ninguno"]{ cursor: default; }
.banner-dots{
  position: absolute;
  bottom: 8px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px;
  background: rgba(0,0,0,0.25);
  padding: 5px 8px; border-radius: 20px;
  backdrop-filter: blur(4px);
}
.banner-dot{
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transition: .2s; cursor: pointer;
}
.banner-dot.active{
  background: #fff;
  width: 18px; border-radius: 3px;
}

/* ─────────────  Catálogo  ───────────── */
.search-bar {
  display: flex; gap: 8px; align-items: center;
  background: var(--card); padding: 12px 14px;
  border-radius: 14px; border: 1px solid var(--border);
  margin-bottom: 16px;
}
.search-bar input {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 15px;
}
.search-bar svg { color: var(--muted); }

.cat-pills {
  display: flex; gap: 8px; overflow-x: auto;
  margin: 0 -16px 18px; padding: 0 16px;
  scrollbar-width: none;
}
.cat-pills::-webkit-scrollbar { display: none; }
.cat-pill {
  flex-shrink: 0;
  padding: 9px 16px;
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
  color: var(--text-soft);
  white-space: nowrap;
}
.cat-pill.active {
  background: var(--primary-dark); color: white;
  border-color: var(--primary-dark);
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  /* Deja espacio suficiente bajo la última fila para que no quede
     tapada por el botón flotante de WhatsApp ni por la barra inferior */
  margin-bottom: calc(var(--bottombar-h) + 70px);
}
@media (min-width: 640px) {
  .products-grid { grid-template-columns: repeat(3, 1fr); }
}

.product {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform 0.1s;
}
.product:active { transform: scale(0.98); }
.product-img {
  width: 100%; aspect-ratio: 1;
  background: var(--primary-tint) center/contain no-repeat;
  position: relative;
}
.product-img.no-img::before {
  content: '🛒'; position: absolute;
  inset: 0; display: grid; place-items: center;
  font-size: 36px; opacity: 0.4;
}
.product-info { padding: 10px 12px 12px; }
.product-name {
  font-size: 13px; font-weight: 600; line-height: 1.25;
  margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
}
.product-price {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 17px; color: var(--primary-dark);
  margin-top: 6px;
}
.product-add {
  margin-top: 8px;
  width: 100%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: none;
  padding: 8px;
  border-radius: 10px;
  font-weight: 700; font-size: 13px;
}
.product-add.in-cart {
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px;
}
.qty-btn {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(255,255,255,0.25); color: white;
  border: none; font-weight: 800; font-size: 16px;
}
.product-out {
  background: var(--border-soft); color: var(--muted);
  font-size: 12px; text-align: center; padding: 8px;
  border-radius: 10px; margin-top: 8px; font-weight: 600;
}

/* ─────────────  Carrito  ───────────── */
.cart-empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.cart-empty .emoji { font-size: 64px; margin-bottom: 16px; }
.cart-item {
  display: grid; grid-template-columns: 60px 1fr auto;
  gap: 12px; align-items: center;
  background: var(--card); padding: 12px;
  border-radius: var(--radius); margin-bottom: 8px;
  border: 1px solid var(--border-soft);
}
.cart-item-img {
  width: 60px; height: 60px; border-radius: 12px;
  background: var(--primary-tint) center/contain no-repeat;
}
.cart-item-name { font-size: 14px; font-weight: 600; line-height: 1.3; }
.cart-item-price {
  font-size: 13px; color: var(--muted); margin-top: 2px;
  font-weight: 500;
}
.cart-item-qty {
  display: flex; align-items: center; gap: 8px;
  background: var(--primary-tint);
  border-radius: 999px; padding: 4px;
}
.cart-item-qty button {
  width: 28px; height: 28px; border-radius: 50%;
  background: white; border: 1px solid var(--border);
  color: var(--primary-dark); font-weight: 700;
}
.cart-item-qty .n { font-weight: 700; font-size: 14px; min-width: 18px; text-align: center; }

.cart-summary {
  background: var(--card); border-radius: var(--radius);
  padding: 18px; border: 1px solid var(--border-soft);
  margin-top: 16px;
}
.cart-line {
  display: flex; justify-content: space-between; padding: 6px 0;
  font-size: 14px; color: var(--text-soft);
}
.cart-line.total {
  border-top: 1px solid var(--border);
  margin-top: 6px; padding-top: 12px;
  font-weight: 700; font-size: 17px; color: var(--text);
}
.cart-line.total .num {
  font-family: 'Fraunces', serif; color: var(--primary-dark);
}

/* ─────────────  Botones  ───────────── */
.btn {
  width: 100%; padding: 15px; font-size: 16px; font-weight: 700;
  font-family: inherit; border: none; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.06s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; box-shadow: 0 4px 14px rgba(30,58,138,0.25);
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; box-shadow: none; }
.btn-ghost {
  background: var(--card); color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger {
  background: #FEF2F2; color: var(--danger);
  border: 1px solid #FECACA;
}

/* ─────────────  Pedidos  ───────────── */
.order-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 10px;
  border: 1px solid var(--border-soft);
}
.order-row { display: flex; justify-content: space-between; align-items: flex-start; }
.order-id {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 16px; color: var(--primary-dark);
}
.order-date { font-size: 12px; color: var(--muted); margin-top: 2px; }
.order-total {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 18px; color: var(--text);
}
.badge {
  display: inline-block; padding: 4px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-pendiente   { background: var(--accent-soft); color: var(--warning); }
.badge-confirmado  { background: var(--primary-soft); color: var(--primary-dark); }
.badge-en_ruta     { background: #E0E7FF;            color: #4338CA; }
.badge-entregado   { background: #D1FAE5;            color: #065F46; }
.badge-rechazado, .badge-cancelado {
  background: #FEE2E2; color: var(--danger);
}

/* ─────────────  Mi Red — banner Club MarketGarrido  ───────────── */
.club-banner {
  background: linear-gradient(135deg, #b45309 0%, #78350f 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 20px 22px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.club-banner::before {
  content: '';
  position: absolute; top: -50px; right: -30px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 70%);
  border-radius: 50%;
}
.club-banner-badge {
  display: inline-block;
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.18);
  padding: 4px 10px; border-radius: 999px;
  margin-bottom: 10px;
}
.club-banner-title {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 22px; line-height: 1.2;
  margin-bottom: 4px;
}
.club-banner-sub {
  font-size: 13px; opacity: 0.85; font-weight: 600;
  margin-bottom: 14px;
  text-transform: capitalize;
}
.club-plan-pills {
  display: flex; gap: 8px;
}
.club-plan-pill {
  flex: 1;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 12px;
  padding: 8px 6px;
  text-align: center;
}
.club-plan-pill .pct {
  display: block;
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 20px;
}
.club-plan-pill .lbl {
  display: block;
  font-size: 10px; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px;
}

/* ─────────────  Mi Red — TARJETA HEADER (la estrella) ───────────── */
.calif-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 22px 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.calif-card::before {
  content: '';
  position: absolute; top: -40px; right: -40px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(234,88,12,0.30) 0%, transparent 70%);
  border-radius: 50%;
}
.calif-month {
  font-size: 13px; opacity: 0.85; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.calif-status {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px; margin-bottom: 14px;
}
.calif-amount {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 32px; letter-spacing: -0.02em;
}
.calif-divider { opacity: 0.5; }
.calif-meta { font-size: 16px; opacity: 0.85; font-weight: 600; }
.calif-progress {
  position: relative;
  height: 10px; background: rgba(255,255,255,0.2);
  border-radius: 999px; overflow: hidden;
  margin-bottom: 10px;
}
.calif-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #FCD34D 100%);
  border-radius: 999px;
  transition: width 0.6s ease-out;
}
.calif-msg {
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.calif-msg.ok::before { content: '✓'; }
.calif-msg.falta::before { content: '⚡'; }

/* Tarjeta consolidada de comisiones (con desglose en tap) */
.com-card {
  background: var(--card); border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 16px;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
}
.com-card-label {
  font-size: 13px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.com-card-amount {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 38px; letter-spacing: -0.02em;
  color: var(--primary-dark);
  margin: 4px 0 8px;
}
.com-card-tap {
  font-size: 12px; color: var(--primary);
  font-weight: 600;
}
.com-card-tap::after { content: ' ↓'; }

.com-detail {
  max-height: 0; overflow: hidden;
  transition: max-height 0.3s;
}
.com-card.open .com-detail { max-height: 400px; padding-top: 14px; }
.com-card.open .com-card-tap::after { content: ' ↑'; }
.com-line {
  display: flex; justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--border-soft);
  font-size: 14px;
}
.com-line:first-child { border-top: none; }
.com-line .label { color: var(--text-soft); }
.com-line .num {
  font-weight: 700; font-family: 'Fraunces', serif;
}

/* Niveles de la red (3 tarjetas) */
.levels-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-bottom: 16px;
}
.level-card {
  background: var(--card); border-radius: 14px;
  padding: 14px 10px; text-align: center;
  border: 1px solid var(--border-soft);
}
.level-pct {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 22px;
}
.level-1 .level-pct { color: var(--primary); }
.level-2 .level-pct { color: var(--info); }
.level-3 .level-pct { color: var(--accent); }
.level-amount {
  font-weight: 700; font-size: 13px; margin-top: 4px;
}
.level-people {
  font-size: 11px; color: var(--muted); margin-top: 2px;
}

/* Árbol */
.tree-toggle {
  display: flex; gap: 4px; margin-bottom: 14px;
  background: var(--card); border: 1px solid var(--border);
  padding: 4px; border-radius: 12px;
}
.tree-toggle button {
  flex: 1; padding: 9px; font-size: 13px; font-weight: 600;
  border: none; background: transparent; color: var(--muted);
  border-radius: 9px;
}
.tree-toggle button.active {
  background: var(--primary-dark); color: white;
}

.tree-node {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  margin-bottom: 6px; overflow: hidden;
}
.tree-node-row {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 12px; align-items: center;
  padding: 12px;
}
.tree-avatar {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--primary-tint); color: var(--primary-dark);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.tree-l2 .tree-avatar { background: #DBEAFE; color: var(--info); }
.tree-l3 .tree-avatar { background: var(--accent-soft); color: var(--warning); }
.tree-name { font-weight: 600; font-size: 14px; }
.tree-meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.tree-pill {
  font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-dark);
}
.tree-l2 .tree-pill { background: #DBEAFE; color: var(--info); }
.tree-l3 .tree-pill { background: var(--accent-soft); color: var(--warning); }
.tree-comm {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 14px; color: var(--primary-dark);
}
.tree-mini-bar {
  height: 3px; border-radius: 2px;
  background: var(--border-soft); overflow: hidden;
  margin-top: 6px;
}
.tree-mini-bar-fill {
  height: 100%; background: var(--primary);
  border-radius: 2px;
}
.tree-mini-bar.qual .tree-mini-bar-fill { background: var(--success); }

.share-card {
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--primary-soft) 100%);
  border-radius: var(--radius-lg);
  padding: 18px 18px;
  margin: 18px 0;
  display: flex; gap: 14px; align-items: center;
}
.share-code {
  flex: 1; min-width: 0;
}
.share-code .label {
  font-size: 11px; color: var(--text-soft); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.share-code .code {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 22px; color: var(--primary-dark);
  letter-spacing: 0.04em; margin-top: 2px;
}
.share-actions { display: flex; gap: 6px; }
.share-actions button {
  width: 42px; height: 42px; border-radius: 12px;
  background: white; border: none;
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}

/* ─────────────  Drawer  ───────────── */
.drawer { position: fixed; inset: 0; z-index: 200; }
.drawer-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(2px);
  animation: fadein 0.2s;
}
.drawer-panel {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: min(320px, 85vw);
  background: var(--card);
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top));
  animation: slidein 0.25s ease-out;
  display: flex; flex-direction: column;
}
@keyframes slidein {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}
@keyframes fadein {
  from { opacity: 0; } to { opacity: 1; }
}
.drawer-header {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 18px; border-bottom: 1px solid var(--border-soft);
  margin-bottom: 18px;
}
.avatar {
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; font-weight: 700; font-size: 20px;
  display: grid; place-items: center;
}
.drawer-name { font-weight: 700; font-size: 16px; }
.drawer-code { font-size: 12px; color: var(--muted); margin-top: 2px; }
.drawer-nav { display: flex; flex-direction: column; gap: 2px; }
.drawer-nav a {
  padding: 12px; border-radius: 10px;
  font-size: 15px; font-weight: 600;
  color: var(--text);
}
.drawer-nav a:active { background: var(--primary-tint); }

/* ─────────────  Sheet (modal de abajo)  ───────────── */
.sheet { position: fixed; inset: 0; z-index: 300; }
.sheet-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4); animation: fadein 0.2s;
}
.sheet-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px 32px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
  max-height: 85dvh; overflow-y: auto;
  animation: slideup 0.25s ease-out;
}
@keyframes slideup {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.sheet-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: -12px auto 16px;
}
.sheet-title {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 22px; margin-bottom: 12px;
  color: var(--primary-dark);
}
.suc-item {
  display: block; padding: 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  margin-bottom: 8px;
  cursor: pointer;
}
.suc-item.selected {
  border-color: var(--primary);
  background: var(--primary-tint);
}
.suc-item .name { font-weight: 700; font-size: 15px; }
.suc-item .addr { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ─────────────  Toast  ───────────── */
.toast {
  position: fixed; bottom: calc(var(--bottombar-h) + 16px);
  left: 16px; right: 16px;
  background: var(--text);
  color: white;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px; font-weight: 600;
  z-index: 400;
  animation: toastin 0.3s ease-out;
  box-shadow: var(--shadow-lg);
}
.toast.success { background: var(--primary); }
.toast.error   { background: var(--danger); }
@keyframes toastin {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ─────────────  Empty / loading  ───────────── */
.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty .emoji { font-size: 56px; margin-bottom: 14px; opacity: 0.6; }
.empty .ttl { font-weight: 700; font-size: 17px; color: var(--text); margin-bottom: 4px; }
.empty .sub { font-size: 14px; }
.skeleton {
  background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Form fields (dentro de la app) */
.form-field { margin-bottom: 14px; }
.form-field label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}
.form-field input, .form-field textarea, .form-field select {
  width: 100%; padding: 13px;
  font-size: 16px; font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: 12px; background: var(--surface); color: var(--text);
}
.form-field textarea { resize: vertical; min-height: 70px; }
.form-field input:focus, .form-field textarea:focus, .form-field select:focus {
  outline: none; border-color: var(--primary); background: white;
}

/* ─────────────────────────────────────────────
   Tap-to-add: producto entero es tappable
   ───────────────────────────────────────────── */
.product-tappable {
  cursor: pointer;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: rgba(30,58,138,0.1);
  transition: transform 0.1s ease, box-shadow 0.15s;
}
.product-tappable.in-cart {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.product-tappable:active {
  transform: scale(0.97);
}
.product-tappable.bump {
  animation: bump 0.3s ease-out;
}
@keyframes bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.06); box-shadow: 0 8px 24px rgba(30,58,138,0.25); }
  100% { transform: scale(1); }
}
.product-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.product-add-hint {
  margin-top: 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 8px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.product-add-hint .add-icon {
  font-size: 16px;
  font-weight: 900;
}

.product-badge {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--primary);
  color: white;
  min-width: 28px; height: 28px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
  box-shadow: 0 2px 8px rgba(30,58,138,0.4);
  border: 2px solid white;
}

.qty-n {
  font-weight: 800;
  font-size: 15px;
  min-width: 24px;
  text-align: center;
  color: white;
}

/* ─────────────────────────────────────────────
   Vista "Repetir compra" (sheet con checkboxes)
   ───────────────────────────────────────────── */
.repetir-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.repetir-item.selected {
  border-color: var(--primary);
  background: var(--primary-tint);
}
.repetir-item.unavailable {
  opacity: 0.55;
  cursor: not-allowed;
  background: #FEF2F2;
  border-color: #FECACA;
}

/* ═══════════════════════════════════════════════════════
   DESKTOP LAYOUT  (≥ 900px)
   Sidebar izquierda fija + header con brand + grid amplio
   ═══════════════════════════════════════════════════════ */

@media (min-width: 900px) {

  :root {
    --sidebar-w:   240px;
    --topbar-h:    68px;
    --bottombar-h: 0px;
  }

  /* ── Body: desplazar contenido a la derecha del sidebar ── */
  body {
    padding-bottom: 0;
    padding-left: var(--sidebar-w);
  }

  /* ── Topbar: ocupa todo el ancho (sidebar incluido) ── */
  .topbar {
    padding: 0 28px 0 0;
  }

  /* Brand / logo (oculto en móvil, visible aquí) */
  .topbar-brand {
    display: flex !important;
    align-items: center;
    gap: 10px;
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: 100%;
    padding: 0 22px;
    border-right: 1px solid var(--border-soft);
    font-family: 'Fraunces', serif;
    font-weight: 800;
    font-size: 18px;
    color: var(--primary-dark);
    letter-spacing: -0.02em;
    white-space: nowrap;
  }
  .topbar-brand-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 10px;
    display: grid; place-items: center;
    font-size: 17px;
    flex-shrink: 0;
  }

  /* Ocultar menú hamburguesa y botón buscar en desktop */
  #btn-menu   { display: none; }
  #btn-buscar { display: none; }

  /* ── Bottombar → Sidebar izquierda ── */
  .bottombar {
    top: var(--topbar-h);
    bottom: 0;
    right: auto;
    width: var(--sidebar-w);
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    border-top: none;
    border-right: 1px solid var(--border-soft);
    padding: 16px 0 0;
    overflow-y: auto;
  }

  /* Navtabs: fila horizontal (ícono + label) */
  .navtab {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 12px;
    margin: 2px 10px;
    width: auto;
    position: relative;
    transition: background 0.15s, color 0.15s;
  }
  .navtab:hover { background: var(--primary-tint); color: var(--primary-dark); }
  .navtab svg  { width: 20px; height: 20px; flex-shrink: 0; }

  /* Indicador activo: borde izquierdo en lugar de top */
  .navtab.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
  }
  .navtab.active::before {
    top: 50%; left: -10px;
    transform: translateY(-50%);
    width: 4px; height: 24px;
    border-radius: 0 4px 4px 0;
  }

  /* Cart badge en sidebar: al final de la fila */
  .navtab-cart { position: relative; }
  .cart-badge  {
    position: static;
    margin-left: auto;
    border: none;
    min-width: 20px; height: 20px;
    font-size: 11px;
  }

  /* FAB de WhatsApp: en desktop no hay bottombar abajo, solo margen fijo */
  .fab-whatsapp {
    bottom: 24px;
  }

  /* Footer del sidebar (logout, cambiar suc) */
  .sidebar-footer {
    display: flex !important;
    flex-direction: column;
    margin-top: auto;
    padding: 0 0 16px;
  }
  .sidebar-sep {
    height: 1px;
    background: var(--border-soft);
    margin: 10px 10px 8px;
  }
  .sidebar-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    margin: 2px 10px;
    border-radius: 12px;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-soft);
    cursor: pointer;
    width: auto;
    text-align: left;
    transition: background 0.15s, color 0.15s;
  }
  .sidebar-btn:hover { background: var(--border-soft); color: var(--text); }
  .sidebar-btn svg   { flex-shrink: 0; }

  /* ── View: área principal ── */
  #view {
    padding: 28px 36px;
    min-height: calc(100dvh - var(--topbar-h));
  }

  /* ── Grid de productos: 4 columnas ── */
  .products-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  /* ── Banner: aspecto más panorámico ── */
  .banner-carrusel {
    aspect-ratio: 4 / 1;
    margin: 0 0 20px;
    border-radius: var(--radius-lg);
  }

  /* ── Familias: pills de texto (sin ícono de carpeta) ──
     Prefijo #view para ganar especificidad sobre estilos
     inline inyectados por catalogo.js                    */
  #view .fam-circulos-wrap {
    flex-wrap: wrap;
    overflow-x: visible;
    gap: 8px;
    padding: 12px 0 14px;
    scroll-snap-type: none;
  }
  #view .fam-circulo {
    flex-direction: row;
    min-width: auto;
    padding: 8px 18px;
    background: var(--primary-tint);
    border-radius: 22px;
    border: 1.5px solid var(--primary-soft);
    gap: 0;
    scroll-snap-align: none;
    transition: background 0.15s, border-color 0.15s;
  }
  #view .fam-circulo:hover:not(.activo) {
    background: var(--primary-soft);
    border-color: var(--primary);
  }
  #view .fam-circulo.activo {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(30,58,138,0.25);
    transform: none;
  }
  #view .fam-circulo-lbl {
    font-size: 0.85rem;
    font-weight: 700;
    max-width: none;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    color: var(--text-soft);
  }
  #view .fam-circulo:hover:not(.activo) .fam-circulo-lbl { color: var(--primary-dark); }
  #view .fam-circulo.activo .fam-circulo-lbl { color: white; }

  /* ── Toast: desplazado del sidebar ── */
  .toast {
    bottom: 24px;
    left: calc(var(--sidebar-w) + 24px);
    right: 24px;
  }

  /* ── Imágenes: cover para llenar el cuadrado sin espacio vacío ── */
  .product-img { background-size: cover; }

  /* ── Hover en tarjeta de producto ── */
  .product-tappable:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
  }
  .product-tappable:active { transform: scale(0.99); }

  /* ── Drawer: oculto (el sidebar lo reemplaza) ── */
  #drawer { display: none !important; }
}

/* ── 5 columnas en pantallas muy anchas ── */
@media (min-width: 1280px) {
  :root { --sidebar-w: 260px; }
  .products-grid { grid-template-columns: repeat(5, 1fr); }
}
.repetir-check {
  width: 24px; height: 24px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: grid; place-items: center;
  flex-shrink: 0;
  background: white;
}
.repetir-item.selected .repetir-check {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.repetir-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}
.repetir-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Switch / toggle ────────────────────────────────────────── */
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; cursor: pointer; font-size: 14px; color: var(--text);
}
.switch {
  position: relative; display: inline-block;
  width: 46px; height: 26px; flex-shrink: 0;
}
.switch input {
  opacity: 0; width: 0; height: 0;
}
.switch-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 999px;
  transition: background .15s;
}
.switch-slider::before {
  content: ""; position: absolute;
  height: 20px; width: 20px; left: 3px; top: 3px;
  background: white; border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.switch input:checked + .switch-slider {
  background: var(--success);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}
.switch input:disabled + .switch-slider {
  opacity: .5; cursor: not-allowed;
}
.repetir-qty-control {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border-radius: 999px;
  padding: 3px;
  border: 1px solid var(--border);
}
.repetir-qty-control button {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--border);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 14px;
}
.repetir-qty-control .n {
  font-weight: 700;
  font-size: 13px;
  min-width: 18px;
  text-align: center;
}
.repetir-warning {
  background: #FEF2F2;
  color: var(--danger);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─────────────────────────────────────────────
   Botón "Repetir esta compra" en la lista
   ───────────────────────────────────────────── */
.order-card-wrap {
  display: block;
}
.order-repeat-btn {
  width: 100%;
  background: var(--primary-tint);
  color: var(--primary-dark);
  border: 1px solid var(--border-soft);
  border-top: none;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  border-radius: 0 0 16px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}
.order-repeat-btn:active {
  background: var(--primary-soft);
}

/* ─────────────  Barra flotante de carrito (sticky)  ───────────── */
.sticky-cart-bar {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(var(--bottombar-h) + 14px);
  background: var(--primary-dark);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-lg);
  z-index: 140;
  cursor: pointer;
  animation: slideup 0.25s ease-out;
}
.sticky-cart-bar .scb-left { display: flex; align-items: center; gap: 10px; }
.sticky-cart-bar .scb-count {
  width: 30px; height: 30px; border-radius: 9px;
  background: rgba(255,255,255,0.18); color: #fff;
  font-weight: 800; font-size: 13px;
  display: grid; place-items: center;
}
.sticky-cart-bar .scb-label { color: #fff; font-weight: 700; font-size: 13.5px; }
.sticky-cart-bar .scb-total { color: #fff; font-weight: 800; font-family: 'Fraunces', serif; font-size: 15px; }
@media (min-width: 900px) {
  .sticky-cart-bar { left: calc(var(--sidebar-w) + 24px); right: 24px; bottom: 24px; }
}

/* ─────────────  Anillo de calificación (Mi Red)  ───────────── */
.calif-ring-wrap { display: flex; align-items: center; gap: 18px; }
.calif-ring-info .lbl { font-size: 12px; opacity: 0.75; font-weight: 600; }
.calif-ring-info .amt { font-family: 'Fraunces', serif; font-weight: 800; font-size: 20px; margin-top: 2px; }
.calif-ring-info .msg { font-size: 13px; font-weight: 600; margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.calif-ring-info .msg.ok::before { content: '✓'; }
.calif-ring-info .msg.falta::before { content: '⚡'; }

/* ─────────────  Badge "COMBO" en franja de ofertas  ───────────── */
.combo-card-tag {
  position: absolute; top: 6px; left: 6px;
  background: var(--accent); color: #fff;
  font-size: 9px; font-weight: 800; letter-spacing: 0.04em;
  padding: 3px 7px; border-radius: 6px; z-index: 1;
}