/* ==========================================================================
   Tianguis Hermosillo · Sistema de diseño «Nocturno»
   --------------------------------------------------------------------------
   Un solo archivo, dos temas:
     · :root               → tema CLARO (crema + marrón + terracota #C4592A)
     · [data-theme="dark"] → tema NOCTURNO (valores exactos de la maqueta)
   El tema se aplica con data-theme en <html>:
     · _theme_init.html (parcial anti-flash, va en <head> antes de este CSS)
     · theme.js (interruptor con localStorage 'tianguis-theme')
   Fuentes autoalojadas en static/fonts/ — nada de Google Fonts en runtime.
   ========================================================================== */

/* ---------- Fuentes autoalojadas (woff2 local) ---------- */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url('fonts/fraunces-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url('fonts/fraunces-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url('fonts/fraunces-normal-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 600 700;
  font-display: swap;
  src: url('fonts/fraunces-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 600 700;
  font-display: swap;
  src: url('fonts/fraunces-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 600 700;
  font-display: swap;
  src: url('fonts/fraunces-italic-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/outfit-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/outfit-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens · tema CLARO (default) ---------- */
:root {
  color-scheme: light;

  /* Fondos y superficies */
  --bg: #F7F0E3;              /* crema base */
  --bg-deep: #EFE5D3;         /* crema profundo (pozos, zonas hundidas) */
  --surface: #FFFDF8;         /* superficie elevada */
  --card-top: #FFFCF4;        /* gradiente tarjeta, arriba */
  --card-bottom: #F4EAD7;      /* gradiente tarjeta, abajo */

  /* Líneas cálidas */
  --line: rgba(42, 29, 18, .10);
  --line-strong: rgba(42, 29, 18, .18);

  /* Textos (crema = tinta principal en claro) */
  --crema: #2A1D12;           /* marrón oscuro, principal */
  --crema-soft: #6E5843;       /* secundario */
  --dim: #8A7360;             /* tenuo, placeholders, metadatos */

  /* Acento terracota */
  --terra: #C4592A;           /* botones, chips activos — buen contraste sobre crema */
  --terra-bright: #B54E23;    /* precio, «Hermosillo», tab activa (más profundo = legible) */
  --terra-ink: #FFF5E9;       /* texto sobre terracota */
  --glow: rgba(196, 89, 42, .20);
  --terra-wash: rgba(196, 89, 42, .10);       /* fondo píldora ubicación */
  --terra-wash-line: rgba(196, 89, 42, .32); /* borde píldora ubicación */
  --terra-faint: rgba(196, 89, 42, .28);     /* regla del hero, tramo medio */

  /* Barra inferior e imágenes */
  --tabbar-bg: rgba(255, 253, 248, .92);
  --img-bg: #EFE5D2;          /* placeholder de foto */

  /* Hero: UN solo degradado multi-parada (crema → tinte terracota pálido → fondo).
     Transiciones largas, termina EXACTO en --bg: sin corte ni costura. */
  --hero-a: #FBF3E2;
  --hero-b: #F6E3C8;          /* tinte terracota pálido */
  --hero-c: #F7F0E3;          /* = --bg */

  /* Sombras */
  --shadow-card: 0 10px 26px rgba(42, 29, 18, .12), inset 0 1px 0 rgba(255, 255, 255, .85);
  --shadow-search: inset 0 2px 8px rgba(42, 29, 18, .05), 0 6px 18px rgba(42, 29, 18, .08);

  /* Radios (16–26) + auxiliares */
  --r-2xs: 11px;              /* botón filtro del buscador */
  --r-xs: 12px;               /* botón WhatsApp */
  --r-sm: 16px;               /* buscador */
  --r-md: 18px;               /* tarjeta de producto */
  --r-lg: 22px;
  --r-xl: 26px;               /* contenedores grandes */
  --r-pill: 999px;            /* chips, píldoras */

  /* Tipografía */
  --font-body: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --fs-kicker: 11.5px;
  --fs-h1: 34px;
  --fs-h2: 19px;
  --fs-meta: 12.5px;
  --fs-chip: 13.5px;
  --fs-search: 14.5px;
  --fs-name: 15px;
  --fs-price: 15px;
  --fs-puesto: 12px;
  --fs-wa: 13px;
  --fs-tab: 10.5px;

  /* Espaciado */
  --sp-1: 6px;
  --sp-2: 10px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 22px;
}

/* ---------- Tokens · tema NOCTURNO (valores EXACTOS de la maqueta) ---------- */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #26160E;
  --bg-deep: #1E100A;
  --surface: #2F1B12;
  --card-top: #3A2519;
  --card-bottom: #2E1B11;

  --line: rgba(244, 214, 183, .09);
  --line-strong: rgba(244, 214, 183, .16);

  --crema: #F4E7D4;
  --crema-soft: #CBB49B;
  --dim: #AD937A;

  --terra: #E97C4F;
  --terra-bright: #F2915F;
  --terra-ink: #331108;
  --glow: rgba(233, 124, 79, .30);
  --terra-wash: rgba(233, 124, 79, .13);
  --terra-wash-line: rgba(233, 124, 79, .34);
  --terra-faint: rgba(233, 124, 79, .25);

  --tabbar-bg: rgba(30, 16, 10, .92);
  --img-bg: #2A180F;

  /* Hero: UN solo degradado multi-parada, transiciones largas, termina en --bg */
  --hero-a: #33200F;
  --hero-b: #2C1A0F;
  --hero-c: #26160E;          /* = --bg */

  --shadow-card: 0 10px 26px rgba(15, 8, 4, .45), inset 0 1px 0 rgba(255, 217, 178, .08);
  --shadow-search: inset 0 2px 8px rgba(12, 6, 3, .45), 0 6px 18px rgba(15, 8, 4, .35);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--crema);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.app {
  max-width: 430px;
  margin: 0 auto;
  /* R5: 124px — la barra mide ~63px (hasta ~77px con fuentes de sistema
     grandes, donde la holgura de los 108px heredados caía a ~31px y se
     leía como solape); esto garantiza ≥47px de aire bajo el contenido. */
  padding: 0 var(--sp-4) calc(124px + env(safe-area-inset-bottom));
}

/* ---------- Hero ----------
   Degradado: UNA sola pasada multi-parada (0% → 46% → 100%) entre tonos
   vecinos y larga distancia — imposible que aparezca una línea. No hay dos
   degradados apilados con paradas distintas (el defecto de la maqueta).
   El resplandor radial va aparte en ::before, con blur, y se funde con el
   fondo. --hero-c == --bg, así la costura hero→página es invisible.
   R2a: FULL-BLEED de borde a borde. Antes el hero vivía dentro de .app
   (max-width 430px + padding lateral) y el fondo de la página se asomaba
   como BARRAS verticales a los costados, además el radio inferior recortaba
   el degradado. margin-inline: calc(50% - 50vw) saca el bloque del padding
   Y del max-width: el degradado pisa el viewport completo a cualquier ancho
   (360/390/430 y escritorio). El padding lateral se redeclara aquí para que
   el contenido siga alineado con el resto de .app. Sin radios: nada
   recorta el degradado. */
.hero {
  position: relative;
  margin-inline: calc(50% - 50vw);
  /* R2b: safe-area superior (barra de estado en PWA/APK, viewport-fit=cover). */
  padding: calc(34px + env(safe-area-inset-top)) var(--sp-4) 6px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--hero-a) 0%, var(--hero-b) 46%, var(--hero-c) 100%);
}
.hero::before {
  content: "";
  position: absolute;
  inset: -70px -80px 0 0;
  pointer-events: none;
  background: radial-gradient(58% 62% at 24% 16%, var(--glow), transparent 68%);
  filter: blur(3px);
}
.hero > * { position: relative; }
.kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 var(--sp-2);
  color: var(--dim);
  font-size: var(--fs-kicker);
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.kicker .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--terra);
  box-shadow: 0 0 10px var(--glow);
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 640;
  font-size: var(--fs-h1);
  line-height: 1.04;
  letter-spacing: -.02em;
  margin: 0 0 14px;
}
.hero h1 em {
  font-style: italic;
  font-weight: 600;
  color: var(--terra-bright);
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding-bottom: var(--sp-5);
}
.loc {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: var(--terra-wash);
  border: 1px solid var(--terra-wash-line);
  color: var(--crema);
  font-size: var(--fs-chip);
  font-weight: 600;
}
.loc svg { width: 15px; height: 15px; color: var(--terra-bright); }
.sched {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--crema-soft);
  font-size: 13px;
  font-weight: 500;
}
.sched svg { width: 15px; height: 15px; color: var(--dim); }
.hero-rule {
  height: 1px;
  border: 0;
  margin: 0 0 var(--sp-5);
  background: linear-gradient(90deg, var(--terra) 0%, var(--terra-faint) 34%, transparent 78%);
}

/* ---------- Buscador ---------- */
.search {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 13px 14px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-search);
}
.search svg.lens { width: 19px; height: 19px; color: var(--dim); flex: 0 0 auto; }
.search .ph { flex: 1; color: var(--dim); font-size: var(--fs-search); letter-spacing: .01em; }
.search input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--crema);
  font-family: inherit;
  font-size: var(--fs-search);
  letter-spacing: .01em;
}
.search input::placeholder { color: var(--dim); }
.search .filter {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: none;
  border-radius: var(--r-2xs);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--terra);
  color: var(--terra-ink);
  box-shadow: 0 4px 12px var(--glow);
}
.search .filter svg { width: 17px; height: 17px; }

/* ---------- Chips ---------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 20px 2px var(--sp-2);
  margin: 0 -2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  user-select: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 9px var(--sp-4);
  border-radius: var(--r-pill);
  font-family: inherit;
  font-size: var(--fs-chip);
  font-weight: 500;
  color: var(--crema-soft);
  background: transparent;
  border: 1px solid var(--line-strong);
  transition: transform .15s ease;
}
.chip:active { transform: scale(.95); }
.chip.active {
  background: var(--terra);
  border-color: transparent;
  color: var(--terra-ink);
  font-weight: 600;
  box-shadow: 0 6px 16px var(--glow);
}

/* ---------- Encabezado de sección ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: var(--sp-5) 2px var(--sp-3);
}
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-h2);
  letter-spacing: -.01em;
  margin: 0;
}
.section-head span { color: var(--dim); font-size: var(--fs-meta); font-weight: 500; }

/* ---------- Tarjetas de producto ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}
.card {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-md);
  overflow: hidden;
  position: relative;
  background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  transition: transform .15s ease;
}
.card:active { transform: scale(.98); }
a.card { color: inherit; text-decoration: none; }
.card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--img-bg);
}
.card .no-photo {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--img-bg);
  color: var(--dim);
  font-size: 13px;
  font-weight: 500;
}
.card .photo-count {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: rgba(15, 8, 4, .55);
  color: #F4E7D4;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}
.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: var(--sp-3) var(--sp-3) 13px;
}
.name {
  margin: 0;
  font-size: var(--fs-name);
  font-weight: 600;
  line-height: 1.28;
  color: var(--crema);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 38px;
}
.price {
  margin: 0;
  color: var(--terra-bright);
  font-size: var(--fs-price);
  font-weight: 700;
  letter-spacing: .02em;
}
.puesto {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--dim);
  font-size: var(--fs-puesto);
  font-weight: 500;
  line-height: 1.3;
}
.puesto svg { width: 13px; height: 13px; flex: 0 0 auto; }
.card .desc {
  margin: 0;
  color: var(--crema-soft);
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Insignias (disponible/agotado, condición, categoría) ---------- */
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--crema-soft);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-active {
  border-color: var(--terra-wash-line);
  background: var(--terra-wash);
  color: var(--terra-bright);
}
.badge-off {
  border-color: var(--line);
  color: var(--dim);
}

/* ---------- Botón WhatsApp ---------- */
.wa {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 0;
  border: none;
  border-radius: var(--r-xs);
  font-family: inherit;
  font-size: var(--fs-wa);
  font-weight: 600;
  background: var(--terra);
  color: var(--terra-ink);
  box-shadow: 0 6px 14px var(--glow);
  transition: filter .15s ease;
}
.wa:active { filter: brightness(1.1); }
.wa svg { width: 16px; height: 16px; }

/* ---------- Mapas Leaflet (R3) ----------
   Chrome compartido del mapa del tianguis (#map) y del mini-mapa del
   puesto (#mini-map): contenedor con tokens, controles y popups
   legibles en claro y en Nocturno.
   Las teselas de OpenStreetMap NO se oscurecen en modo Nocturno: quedan
   claras a propósito (comportamiento de OSM, no un defecto). Solo se
   viste el marco y los elementos de UI sobre el mapa.
   leaflet.css (CDN) carga DESPUÉS de este archivo en las páginas con
   mapa (el <link> vive en su head): todo lo que colisiona con él va
   scopeado bajo .map-frame para ganar por especificidad, no por orden. */
.map-frame {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;                    /* controles y atribución respetan el radio */
}
.leaflet-container.map-frame {
  background: var(--img-bg);           /* visible mientras cargan las teselas */
  font-family: var(--font-body);       /* gana a la Helvetica de leaflet.css */
}
.map-frame .leaflet-bar {
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-card);
}
/* Objetivos táctiles de Leaflet también a 44px (gana a .leaflet-bar a
   de 26px y a .leaflet-touch .leaflet-bar a de 30px). */
.map-frame .leaflet-bar a,
.map-frame.leaflet-touch .leaflet-bar a {
  width: 44px; height: 44px; line-height: 44px; font-size: 1.4rem;
  color: var(--crema); background: var(--surface);
}
.map-frame .leaflet-bar a:hover { background: var(--bg-deep); color: var(--crema); }
/* Popups con tokens del sistema (tianguis y puestos): legibles en ambos
   temas. Sombra propia, más nítida que la de las tarjetas: el popup
   flota sobre las teselas claras y necesita borde de contraste. */
.map-frame .leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--crema);
  box-shadow: 0 6px 20px rgba(42, 29, 18, .35), 0 2px 6px rgba(42, 29, 18, .18);
}
.map-frame .leaflet-popup-tip { background: var(--surface); }
.map-frame .leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.45; }
.map-frame .leaflet-popup-content a { color: var(--terra-bright); font-weight: 600; }
/* Atribución: chip discreto en la esquina inferior derecha. */
.map-frame .leaflet-control-attribution {
  padding: 3px 8px;
  background: var(--tabbar-bg);
  color: var(--dim);
  font-size: 10.5px;
}
.map-frame .leaflet-control-attribution a { color: var(--terra-bright); }

/* ---------- Panel del locatario (R4) ----------
   Las páginas del panel (Mi puesto, detalle propio, QR, formularios de
   puesto y producto, registro) migraron a base_public.html. Este bloque
   les da su chrome con los mismos tokens en claro y Nocturno: botones,
   filas de acciones, tarjetas de puesto, tarjetas de producto con
   acciones, avisos flash/error y formularios. Los estilos de formulario
   van scopeados bajo .form-card para no tocar el buscador del sistema ni
   ninguna página de comprador.
   La zona de peligro (eliminar, inactivo, errores) usa un rojo ladrillo
   propio del panel definido aquí; los tokens base no se tocan. */

/* Rojo de peligro del panel: legible sobre crema y sobre Nocturno. */
:root {
  --danger: #A02C1C;
  --danger-soft: rgba(160, 44, 28, .08);
  --danger-line: rgba(160, 44, 28, .38);
}
[data-theme="dark"] {
  --danger: #F09070;
  --danger-soft: rgba(240, 144, 112, .12);
  --danger-line: rgba(240, 144, 112, .42);
}

/* Botones: 48px de objetivo táctil (44px el .small), radio 12, terracota. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--r-xs);
  background: var(--terra);
  color: var(--terra-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 16px var(--glow);
  transition: filter .15s ease, transform .08s ease;
}
.btn:active { filter: brightness(1.08); transform: scale(.98); }
.btn.secondary {
  background: var(--surface);
  color: var(--crema);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}
.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger-line);
  box-shadow: none;
}
.btn.small { min-height: 44px; padding: 9px 14px; font-size: 13px; border-radius: var(--r-2xs); }
@media (max-width: 640px) {
  .btn:not(.small) { width: 100%; }
  .product .actions .btn.small { flex: 1 1 calc(50% - 4px); }
}

/* Filas de acciones (era .grid del chrome Shopp): flex con wrap; los
   <form> se estiran para que su botón llene el hueco. */
.btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-4) 0; }
.btn-row > * { flex: 1 1 10.5rem; min-width: 0; }
.btn-row form { display: flex; }

/* Lista de puestos ("Mis puestos"). */
.stall-list { display: grid; gap: var(--sp-3); margin-top: var(--sp-4); }
.stall-card {
  padding: var(--sp-4);
  background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}
.stall-card h2 {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: 640;
  line-height: 1.25;
  margin: 0 0 var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.stall-card h2 a { color: var(--crema); text-decoration: none; }
.stall-meta { margin: 0 0 6px; color: var(--crema-soft); font-size: 13.5px; }

/* Tarjetas de producto del panel: como las del comprador (.card) pero con
   fila de acciones (editar / eliminar) al pie. */
.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
.product {
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.product .thumb { position: relative; }
.product .thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--img-bg);
}
.product .no-photo {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--img-bg);
  color: var(--dim);
  font-size: 13px;
  font-weight: 500;
}
.product .photo-count {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: rgba(15, 8, 4, .55);
  color: #F4E7D4;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}
.product .body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: var(--sp-3) var(--sp-3) 13px;
}
.product .title {
  font-size: var(--fs-name);
  font-weight: 600;
  line-height: 1.28;
  color: var(--crema);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 38px;
}
.product .price {
  color: var(--terra-bright);
  font-size: var(--fs-price);
  font-weight: 700;
  letter-spacing: .02em;
}
.product .meta { display: flex; flex-wrap: wrap; gap: 5px; }
.product .desc {
  color: var(--crema-soft);
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product .actions { display: flex; gap: 8px; margin-top: auto; }

/* Insignia de inactivo (agotado ya tiene .badge-off del sistema). */
.badge-inactive {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

/* Encabezados de sección sueltos (Administración, Tus datos…). */
.section-title {
  margin: var(--sp-5) 2px var(--sp-3);
  color: var(--dim);
  font-size: var(--fs-meta);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .16em;
}

/* Avisos flash (éxito) y error del panel. */
.flash {
  margin: 0 0 var(--sp-4);
  padding: 12px 16px;
  border-radius: var(--r-sm);
  background: var(--terra-wash);
  border: 1px solid var(--terra-wash-line);
  color: var(--crema);
  font-weight: 600;
  font-size: 13.5px;
}
.error {
  margin: 0 0 var(--sp-4);
  padding: 12px 16px;
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  color: var(--danger);
  font-weight: 600;
  font-size: 13.5px;
}

/* Tarjeta de contenido del panel (QR en el detalle, formularios). */
.panel-card {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}

/* Formularios: SOLO bajo .form-card (el buscador y demás páginas
   públicas no se enteran). Campos de 48px, foco terracota. */
.form-card { max-width: 34rem; }
/* R5: variante para tarjetas de administración que llevan inputs pero
   necesitan todo el ancho (cola de pagos: foto del ticket + tabla). */
.form-card.wide { max-width: none; }
.form-card label {
  display: block;
  margin: 0 0 6px;
  color: var(--crema-soft);
  font-size: var(--fs-meta);
  font-weight: 600;
}
.form-card input:not([type="checkbox"]),
.form-card select,
.form-card textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  background: var(--surface);
  color: var(--crema);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 14.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-card input:focus,
.form-card select:focus,
.form-card textarea:focus {
  outline: none;
  border-color: var(--terra);
  box-shadow: 0 0 0 3px var(--glow);
}
.form-card input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  min-height: 0;
  accent-color: var(--terra);
}
.form-card textarea { min-height: 96px; }
.form-card input[type="file"] { padding: 10px 12px; }
.form-card select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%238A7360' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: .7rem;
  padding-right: 2.3rem;
}
[data-theme="dark"] .form-card select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%23AD937A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
}
.field { margin-bottom: var(--sp-4); }
.checkbox-row { display: flex; align-items: center; gap: 10px; }
.checkbox-row label { margin: 0; color: var(--crema); font-size: 14px; font-weight: 500; }
.form-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: flex-start; }
.form-row > * { flex: 1 1 12rem; min-width: 0; }
.geo-status { color: var(--dim); font-size: 12.5px; min-height: 1.3rem; margin-top: 8px; }

/* Hoja del QR imprimible del panel. Fondo blanco SIEMPRE en la imagen:
   el código se escanea sobre blanco, en cualquier tema. */
.qr-sheet {
  text-align: center;
  max-width: 26rem;
  margin: var(--sp-4) auto 0;
  padding: var(--sp-5) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
}
.qr-sheet img.qr {
  width: 320px;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
}
.qr-sheet .url {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
}
/* (La regla @media print del QR vive en panel_qr.html: es el único
   estilo de esa página y el test fija que la página lo cargue.) */

/* ---------- Barra inferior fija (blur) ----------
   R2b: grid-auto-flow en lugar de repeat(5, 1fr): la barra real lleva
   entre 2 y 5 pestañas según el contexto (portada: 2; tianguis: 5). */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 430px);
  z-index: 50;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
  background: var(--tabbar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 5px 0 3px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: var(--fs-tab);
  font-weight: 500;
  color: var(--dim);
  user-select: none;
  cursor: pointer;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--terra-bright); font-weight: 600; }
.tab.active svg { filter: drop-shadow(0 2px 8px var(--glow)); }
