/* Panel del vendedor y páginas de autenticación. */

.app-header { border-bottom: 1px solid var(--color-border-soft); background: var(--color-bg); position: sticky; top: 0; z-index: 100; }
.app-header__inner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); padding-top: var(--space-2); padding-bottom: var(--space-2); }
.brand { font-weight: 800; color: var(--color-text); text-decoration: none; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-1); flex: 1 1 auto; }
.nav a { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--target-min); padding: 0 var(--space-3); border-radius: var(--radius); text-decoration: none; color: var(--color-text); }
.nav a[aria-current="page"] { background: var(--color-info-bg); color: #0a3a6b; font-weight: 700; }
.app-main { padding-top: var(--space-6); padding-bottom: var(--space-8); }

.page-head { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.page-head h1 { margin: 0; }
.section { margin-bottom: var(--space-6); }
.actions-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.grid-2 { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
.hint { color: var(--color-muted); font-size: var(--text-sm); }
.empty { padding: var(--space-6); text-align: center; background: var(--color-surface); border-radius: var(--radius); }

.stat-grid { display: grid; gap: var(--space-4); grid-template-columns: 1fr; margin-bottom: var(--space-4); }
.stat { display: grid; text-decoration: none; color: var(--color-text); }
.stat__value { font-size: 2rem; font-weight: 800; }
.stat__label { color: var(--color-muted); }

/* Filtros por estado (Pedidos, Productos). Spec 009 (FR-O01 a FR-O05; RO-02 a RO-04): la fila salta
   de línea, cada filtro queda completo (sin el overflow-wrap: anywhere de .app-main), 44 px de
   alto, y el activo se marca también con un borde inferior (box-shadow, para no cambiar su alto). */
.tabs { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.tabs a { display: inline-flex; align-items: center; flex: 0 0 auto; min-height: var(--target-min); padding: var(--space-2) var(--space-3); border-radius: var(--radius); text-decoration: none; white-space: nowrap; overflow-wrap: normal; }
.tabs a[aria-current="page"] { background: var(--color-info-bg); font-weight: 700; box-shadow: inset 0 -3px 0 currentColor; }

.product-list, .catalog-list, .picker, .zones__list, .photos__list, .order-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.product-item, .catalog-item { display: flex; gap: var(--space-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.product-item img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius); }
.product-item__nophoto { width: 64px; height: 64px; display: grid; place-items: center; background: var(--color-surface); border-radius: var(--radius); font-size: 1.5rem; }
.product-item__info { display: grid; flex: 1 1 200px; min-width: 0; }

.plan-usage { padding: var(--space-2) var(--space-3); background: var(--color-surface); border-radius: var(--radius); }
.plan-usage--full { background: var(--color-warning-bg); color: var(--color-warning-text); }

.contact-row { display: grid; gap: var(--space-2); grid-template-columns: 1fr; border: 1px solid var(--color-border-soft); border-radius: var(--radius); padding: var(--space-3); margin: 0 0 var(--space-2); }
.contacts-list { display: grid; }
.logo-row { display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; }
.logo-preview img { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--color-border-soft); border-radius: var(--radius); }
.form--inline { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-end; }
.form--inline .field { flex: 1 1 160px; }

.photos__list { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.photos__item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); }
.photos__actions { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }

.share__row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.share__row input { flex: 1 1 260px; min-width: 0; padding: var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius); }

.seller-offers { display: grid; gap: var(--space-4); }
.seller-offer__head { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; justify-content: space-between; }
.seller-offer__head h3 { margin: 0; font-size: var(--text-base); }
.seller-offer--interest { border-color: var(--color-danger); }
.seller-offer__form { display: grid; gap: var(--space-3); }
.seller-offer .table input[type="number"] { width: 6rem; }
.flag-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-1); }

.picker__item { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-2); border-bottom: 1px solid var(--color-border-soft); }
.picker__item.is-filtered { display: none; }

.auth-header { padding-top: var(--space-4); }
.auth-card h1 { margin-bottom: var(--space-4); }
.auth-links { margin-top: var(--space-4); text-align: center; }
.btn-row { display: flex; gap: var(--space-2); }

@media (min-width: 768px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .contact-row { grid-template-columns: 160px 1fr 2fr auto; align-items: end; }
  .flag-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Pedidos y notificaciones (US2, US5) */
.order-alerts { position: fixed; right: var(--space-4); top: calc(var(--target-min) + var(--space-6)); z-index: 800; display: grid; gap: var(--space-2); max-width: min(360px, calc(100vw - 2rem)); }
.order-alert { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; border-left: 4px solid var(--color-success); }
.order-row { display: grid; gap: var(--space-1); }
.dl { display: grid; gap: var(--space-2); margin: 0; }
.dl dt { color: var(--color-muted); font-size: var(--text-sm); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.history { padding-left: var(--space-6); }
.cart__totals { margin: var(--space-3) 0 0; display: grid; gap: var(--space-1); }
.cart__totals div { display: flex; justify-content: space-between; }
.cart__totals dd { margin: 0; font-weight: 600; }
.cart__total dd { font-size: var(--text-lg); font-weight: 800; }
.stars { display: flex; gap: var(--space-1); border: 0; padding: 0; margin: 0; }
.stars label { display: inline-flex; align-items: center; justify-content: center; min-width: var(--target-min); min-height: var(--target-min); border: 1px solid var(--color-border); border-radius: var(--radius); cursor: pointer; }
.stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.stars input:checked + span { font-weight: 800; color: var(--color-primary); }
.stars input:focus-visible + span { outline: 3px solid var(--color-focus); outline-offset: 2px; }
/* Chat (US7) */
.chat-layout { display: grid; gap: var(--space-4); }
.chat-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.chat-list__item { justify-content: flex-start; text-align: left; display: block; }
.chat-list__item[aria-current="true"] { border-color: var(--color-primary); background: var(--color-info-bg); }
.chat-messages { list-style: none; margin: 0; padding: var(--space-2); display: grid; gap: var(--space-2); max-height: 50vh; overflow-y: auto; background: var(--color-surface); border-radius: var(--radius); }
.chat-msg { max-width: 85%; padding: var(--space-2) var(--space-3); border-radius: var(--radius); overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-msg--mine { justify-self: end; background: var(--color-primary); color: var(--color-on-primary); }
.chat-msg--theirs { justify-self: start; background: var(--color-bg); border: 1px solid var(--color-border-soft); }
.chat-form { display: grid; gap: var(--space-2); margin-top: var(--space-2); }
.chat-form textarea { width: 100%; padding: var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius); }
.buyer-chat summary { cursor: pointer; font-weight: 600; min-height: var(--target-min); display: flex; align-items: center; }
@media (min-width: 768px) { .chat-layout { grid-template-columns: 280px 1fr; } }
/* ===================================================================================
 * Spec 003: armado de catálogos móvil primero (pasos 1 y 2), filtros, hoja inferior,
 * barra de acción, deshacer, vista previa y categorías.
 * =================================================================================== */
.badge--draft { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.badge--draft::before { content: "✎"; }
.badge--paused { background: var(--color-warning-bg); color: var(--color-warning-text); }
.badge--paused::before { content: "⏸"; }

/* Barra de acción inferior fija (FR-M26). */
.action-bar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; gap: var(--space-2); justify-content: flex-end;
  padding: var(--space-2) var(--space-4) calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
  margin: var(--space-4) calc(-1 * var(--space-4)) 0;
  background: var(--color-bg); border-top: 1px solid var(--color-border-soft);
  box-shadow: 0 -4px 12px rgba(31, 35, 40, 0.06);
}
.action-bar .btn { flex: 1 1 0; min-height: var(--target-min); justify-content: center; }
@media (min-width: 768px) { .action-bar .btn { flex: 0 0 auto; } }

/* Paso 1 */
.more-options { margin: var(--space-4) 0; }
.more-options > summary { cursor: pointer; min-height: var(--target-min); display: flex; align-items: center; font-weight: 600; }

/* Paso 2 */
.builder__head { display: grid; gap: var(--space-2); }
.builder__back { margin: 0; }
.builder__title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.builder__title h1 { font-size: var(--text-xl); margin: 0; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.builder__meta { margin: 0; color: var(--color-muted); font-size: var(--text-sm); }
.builder__tools { display: flex; gap: var(--space-2); position: sticky; top: 0; z-index: 10; background: var(--color-bg); padding: var(--space-2) 0; }
.builder__tools input[type="search"] { flex: 1 1 auto; min-width: 0; min-height: var(--target-min); }
.builder__body { display: block; }
@media (min-width: 1024px) {
  .builder__body { display: grid; grid-template-columns: 280px 1fr; gap: var(--space-6); align-items: start; }
  .builder__tools [data-action="filters-open"] { display: none; }
}

.filter-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.filter-chips:empty { display: none; }
.filter-chip {
  display: inline-flex; align-items: center; gap: var(--space-1); min-height: 36px; padding: 0 var(--space-3);
  border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface); color: var(--color-text); font-size: var(--text-sm);
}

.pick-list { list-style: none; margin: 0; padding: 0; }
.pick-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-2);
  min-height: 72px; padding: var(--space-2) 0; border-bottom: 1px solid var(--color-border-soft);
}
.pick-row__main { display: flex; align-items: center; gap: var(--space-3); min-width: 0; background: none; border: 0; padding: 0; text-align: left; color: inherit; font: inherit; }
.pick-row__main:disabled { cursor: default; opacity: 1; }
.pick-row__photo { flex: 0 0 56px; width: 56px; height: 56px; border-radius: var(--radius); overflow: hidden; background: var(--color-surface); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--color-muted); }
.pick-row__photo img { width: 100%; height: 100%; object-fit: cover; }
.pick-row__text { display: grid; min-width: 0; }
.pick-row__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-row__meta { color: var(--color-muted); font-size: var(--text-sm); }
.pick-row__carts { justify-self: start; margin-top: var(--space-1); }
.pick-row__toggle { min-height: var(--target-min); min-width: 7.5rem; justify-content: center; }
.pick-row__toggle .pick-row__icon::before { content: "+"; font-weight: 700; margin-right: var(--space-1); }
.pick-row__toggle.is-added { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success); }
.pick-row__toggle.is-added .pick-row__icon::before { content: "✓"; }
.pick-row__error { grid-column: 1 / -1; margin: 0; }
.pick-row__error:empty { display: none; }

/* Panel de filtros lateral (RM-14). En 1024 px o más queda fijo junto a la lista. */
.filter-panel {
  margin: 0 0 0 auto; height: 100%; max-height: 100dvh; width: min(85vw, 400px); max-width: none;
  padding: 0; border: 0; border-left: 1px solid var(--color-border-soft); background: var(--color-bg); color: var(--color-text);
}
.filter-panel::backdrop { background: rgba(31, 35, 40, 0.4); }
.filter-panel[open] { animation: ta-slide-in var(--motion-base) ease-out; }
.filter-panel__form { display: flex; flex-direction: column; height: 100%; }
.filter-panel__head { display: flex; justify-content: space-between; align-items: center; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border-soft); }
.filter-panel__head h2 { font-size: var(--text-lg); margin: 0; }
.filter-panel__body { flex: 1 1 auto; overflow-y: auto; padding: var(--space-3) var(--space-4); }
.filter-panel__foot { display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--color-border-soft); }
.filter-panel__foot .btn { flex: 1 1 0; justify-content: center; min-height: var(--target-min); }
.filter-group { border: 0; margin: 0 0 var(--space-4); padding: 0; }
.filter-group legend { font-weight: 700; margin-bottom: var(--space-2); }
.filter-group__chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip-check { position: relative; }
.chip-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-check span { display: inline-flex; align-items: center; min-height: var(--target-min); min-width: var(--target-min); justify-content: center; padding: 0 var(--space-3); border: 1px solid var(--color-border); border-radius: 999px; }
.chip-check input:checked + span { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.chip-check input:checked + span::before { content: "✓ "; }
.chip-check input:focus-visible + span { outline: 3px solid var(--color-focus); outline-offset: 2px; }
@media (min-width: 1024px) {
  .filter-panel { position: static; display: block; width: auto; height: auto; max-height: none; border: 1px solid var(--color-border-soft); border-radius: var(--radius); animation: none; }
  .filter-panel [data-action="filters-close"], .filter-panel__foot [data-action="filters-apply"] { display: none; }
}

/* Hoja inferior (core/bottom-sheet.js) */
.sheet-dialog {
  margin: auto 0 0; width: 100%; max-width: 100%; max-height: 90dvh; padding: 0;
  border: 0; border-radius: 1rem 1rem 0 0; background: var(--color-bg); color: var(--color-text);
}
.sheet-dialog::backdrop { background: rgba(31, 35, 40, 0.4); }
.sheet-dialog[open] { display: flex; flex-direction: column; animation: ta-slide-up var(--motion-base) ease-out; }
.sheet-dialog__handle { width: 40px; height: 4px; border-radius: 2px; background: var(--color-border); margin: var(--space-2) auto 0; }
.sheet-dialog__head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--color-border-soft); }
.sheet-dialog__head h2 { font-size: var(--text-lg); margin: 0; min-width: 0; overflow-wrap: anywhere; }
.sheet-dialog__body { overflow-y: auto; padding: var(--space-4); padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); }
.sheet-dialog__body .seller-offer { box-shadow: none; border: 0; padding: 0; }
@media (min-width: 768px) {
  .sheet-dialog { margin: auto; max-width: 640px; border-radius: 1rem; }
}
.share-sheet__url { width: 100%; margin: var(--space-2) 0 var(--space-3); }
.reason-list { padding-left: var(--space-4); }

/* Deshacer (RM-12) */
.undo-bar {
  position: fixed; left: var(--space-4); right: var(--space-4); z-index: 30;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius);
  background: var(--color-text); color: var(--color-bg); box-shadow: var(--shadow);
}
.undo-bar[hidden] { display: none; }
.undo-bar .btn { color: var(--color-bg); border-color: var(--color-bg); background: transparent; }
@media (min-width: 768px) { .undo-bar { left: auto; max-width: 420px; } }

/* Menú de más acciones */
.menu { position: relative; }
.menu > summary { list-style: none; min-width: var(--target-min); justify-content: center; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 25; min-width: 220px; padding: var(--space-1); background: var(--color-bg); border: 1px solid var(--color-border-soft); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; }
.menu__item { min-height: var(--target-min); text-align: left; padding: 0 var(--space-3); background: none; border: 0; border-radius: var(--radius); color: var(--color-text); font: inherit; }
.menu__item:hover, .menu__item:focus-visible { background: var(--color-surface); }
.menu__item--danger { color: var(--color-danger); }

/* Categorías */
.category-list { list-style: none; margin: 0; padding: 0; }
.category-item { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-height: 56px; border-bottom: 1px solid var(--color-border-soft); }
.category-item__name { font-weight: 600; flex: 1 1 auto; }
.form--inline { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-end; }
.form--inline .field { flex: 1 1 200px; margin: 0; }
.combobox { position: relative; }
.combobox__list { position: absolute; left: 0; right: 0; z-index: 15; margin: 2px 0 0; padding: var(--space-1); list-style: none; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; }
.combobox__option { min-height: var(--target-min); display: flex; align-items: center; padding: 0 var(--space-3); border-radius: var(--radius); cursor: pointer; }
.combobox__option[aria-selected="true"], .combobox__option:hover { background: var(--color-surface); }

@keyframes ta-slide-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes ta-slide-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes ta-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .filter-panel[open], .sheet-dialog[open] { animation: ta-fade 100ms linear; }
}

/* Spec 003: logo y color de la tienda, vista previa (FR-M17 a FR-M24) */
.swatches { border: 0; padding: 0; margin: var(--space-4) 0 0; }
.swatches legend { font-weight: 700; margin-bottom: var(--space-2); }
.swatches__list { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.swatch { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--target-min); padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1); border: 1px solid var(--color-border-soft); border-radius: 999px; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch__chip { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--color-border); flex: 0 0 32px; }
.swatch__chip--neutral { background: #0B5CAD; }
.swatch__chip--custom { background: conic-gradient(#e53935, #fbc02d, #43a047, #1e88e5, #8e24aa, #e53935); }
.swatch:has(input:checked) { border: 2px solid var(--color-text); font-weight: 600; }
.swatch:has(input:checked) .swatch__label::before { content: "✓ "; }
.swatch:has(input:focus-visible) { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.swatches__custom { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-3); }
.swatches__custom input[type="color"] { width: var(--target-min); height: var(--target-min); padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius); }
.swatches__custom input[type="text"] { width: 9rem; font-family: ui-monospace, monospace; text-transform: uppercase; }
.dirty-tag { align-self: center; margin-right: auto; font-size: var(--text-sm); color: var(--color-warning-text); background: var(--color-warning-bg); border-radius: 999px; padding: 2px var(--space-2); }
.dirty-tag[hidden] { display: none; }

.preview-dialog { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; border: 0; background: var(--color-bg); color: var(--color-text); }
.preview-dialog::backdrop { background: rgba(31, 35, 40, 0.4); }
.preview-dialog[open] { display: flex; flex-direction: column; }
.preview-dialog__head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--color-border-soft); }
.preview-dialog__head h2 { margin: 0; font-size: var(--text-lg); margin-right: auto; }
.preview-dialog__body { flex: 1 1 auto; overflow-y: auto; }
@media (min-width: 1024px) {
  .preview-dialog { position: fixed; inset: 0 0 0 auto; width: 440px; height: 100vh; max-height: 100vh; border-left: 1px solid var(--color-border-soft); box-shadow: var(--shadow); z-index: 50; }
  .preview-dialog .offers-grid { grid-template-columns: repeat(2, 1fr); }
}

/* =====================================================================
 * Spec 003 (FR-M25, FR-M26, FR-M28; RM-15): panel del vendedor en el celular.
 * Navegación inferior fija con zona segura; la barra de acción queda encima de ella;
 * con el teclado abierto (body.kb-open) se oculta la navegación.
 * ===================================================================== */
:root { --nav-h: 56px; --bar-h: 60px; }
.bottom-nav { display: none; }
.more-sheet { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.more-sheet__item { display: flex; align-items: center; width: 100%; min-height: 48px; padding: 0 var(--space-3); border-radius: var(--radius); border: 0; background: none; color: var(--color-text); font: inherit; text-decoration: none; text-align: left; }
.more-sheet__item:hover, .more-sheet__item:focus-visible { background: var(--color-surface); }
.more-sheet__item[aria-current="page"] { font-weight: 700; background: var(--color-info-bg); }
.more-sheet__item--danger { color: var(--color-danger); }

@media (max-width: 767.98px) {
  .app-header nav, .app-header [data-action="logout"] { display: none; }
  .bottom-nav {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    background: var(--color-bg); border-top: 1px solid var(--color-border-soft);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .bottom-nav ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); }
  .bottom-nav a, .bottom-nav button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    width: 100%; min-height: var(--nav-h); padding: 4px 2px; border: 0; background: none;
    color: var(--color-muted); font: inherit; font-size: 0.75rem; text-decoration: none;
  }
  .bottom-nav [aria-current="page"] { color: var(--color-primary); font-weight: 700; }
  .bottom-nav [aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 20%; right: 20%; height: 3px; border-radius: 0 0 3px 3px; background: var(--color-primary); }
  .bottom-nav .badge--count { position: absolute; top: 4px; right: calc(50% - 22px); font-size: 0.6875rem; min-width: 1.25rem; padding: 0 4px; }
  .app-main { padding-bottom: calc(var(--nav-h) + var(--bar-h) + env(safe-area-inset-bottom, 0px) + var(--space-4)); }
  .action-bar { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }
  .undo-bar { bottom: calc(var(--nav-h) + var(--bar-h) + env(safe-area-inset-bottom, 0px) + 8px); }

  body.kb-open .bottom-nav { display: none; }
  body.kb-open .action-bar { bottom: 0; }
  body.kb-open .app-main { padding-bottom: calc(var(--bar-h) + var(--space-4)); }
}

/* Celular en horizontal: barras más bajas y sin textos (siguen como nombre accesible). */
@media (max-width: 767.98px) and (orientation: landscape) and (max-height: 500px) {
  :root { --nav-h: 48px; --bar-h: 52px; }
  .bottom-nav__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Reflujo a 320 px y texto al 200 %: sin anchos fijos en el contenido. */
.app-main { max-width: 100%; overflow-wrap: anywhere; }
.app-main img { max-width: 100%; height: auto; }
.table-wrap { overflow-x: auto; }
/* Spec 002: precio anterior y porcentaje de descuento en la hoja de ajuste de la oferta. */
.discount-field__row { display: flex; gap: var(--space-2); align-items: center; }
.discount-field__row input { flex: 1 1 auto; min-width: 0; }
.badge--discount { background: var(--color-danger); color: #fff; font-weight: 800; }
/* Spec 002 (FR-V01 y FR-V04): foto cuadrada de la oferta y avisos de visibilidad. */
.seller-offer__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.seller-offer__photo { flex: 0 0 72px; width: 72px; height: 72px; border-radius: 0.5rem; overflow: hidden; background: var(--color-surface); display: flex; align-items: center; justify-content: center; }
.seller-offer__photo img { width: 100%; height: 100%; object-fit: cover; }
.seller-offer__initials { font-size: 1.5rem; font-weight: 700; color: var(--color-muted); }
.seller-offer__visibility .notice { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin: var(--space-2) 0; }
.seller-offer__photo-hint { margin: var(--space-1) 0; }
/* Spec 002 (FR-V06): ordenar productos del catálogo. */
.sort-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.sort-row { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); border: 1px solid var(--color-border-soft); border-radius: var(--radius); }
.sort-row__photo { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 0.375rem; overflow: hidden; background: var(--color-surface); }
.sort-row__photo img { width: 100%; height: 100%; object-fit: cover; }
.sort-row__name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
/* Spec 004: redes sociales e interruptor de avisos de ventas en «Mi tienda». */
.social-field__row { display: flex; gap: var(--space-2); align-items: center; }
.social-field__row input { flex: 1 1 auto; min-width: 0; }
.switch { display: inline-flex; align-items: center; gap: var(--space-3); min-height: var(--target-min); padding: 0; border: 0; background: none; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.switch__track { position: relative; flex: 0 0 48px; width: 48px; height: 28px; border-radius: 999px; background: var(--color-border); transition: background var(--motion-fast); }
.switch__thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform var(--motion-fast); }
.switch[aria-checked="true"] .switch__track { background: var(--color-success); }
.switch[aria-checked="true"] .switch__thumb { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; border-radius: 0.5rem; }
@media (prefers-reduced-motion: reduce) { .switch__track, .switch__thumb { transition: none; } }

/* =========================================================================
 * Spec 006 (RE-02 a RE-05): ventana de ajuste de la oferta por secciones.
 * ========================================================================= */
.seller-offer { display: grid; gap: var(--space-4); min-width: 0; }
.so-head {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0;
  background: var(--color-bg); border-bottom: 1px solid var(--color-border-soft);
}
.so-head__photo { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 12px; }
.so-head__text { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.so-head__name { margin: 0; font-size: var(--text-base); overflow-wrap: anywhere; }
.so-head__meta { margin: 0; font-size: var(--text-sm); color: var(--color-muted); overflow-wrap: anywhere; }
.so-head__status { flex: 0 0 auto; font-size: var(--text-sm); }
/* Dentro de la hoja, el título ya muestra el nombre: el encabezado queda fijo con foto y estado. */
.sheet-dialog__body .so-head {
  position: sticky; top: calc(-1 * var(--space-4)); z-index: 2;
  margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-4)) 0; padding: var(--space-3) var(--space-4);
}
.sheet-dialog__body .so-head__name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.so-alerts:empty { display: none; }
.so-alerts .notice { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-2); }

.so-form { display: grid; gap: var(--space-6); }
.so-sec { display: grid; gap: var(--space-2); min-width: 0; }
.so-sec h4 { margin: 0; font-size: 1rem; font-weight: 700; }
.so-sec > .hint { margin: 0; }
.so-sec .field { margin: 0; }
.so-check { align-items: center; min-height: var(--target-min); margin-top: var(--space-1); }
.so-check input { margin-top: 0; flex: 0 0 auto; }
.so-check__hint { margin: 0; }

/* Destacar: opciones táctiles (RE-03). */
.so-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
@media (max-width: 359px) { .so-chips { grid-template-columns: 1fr; } }
.so-chip {
  position: relative; display: flex; align-items: center; gap: var(--space-2); min-height: 48px;
  padding: var(--space-2) var(--space-3); border: 1.5px solid var(--color-border-soft); border-radius: 12px;
  background: var(--color-bg); cursor: pointer; font-weight: 600; transition: border-color var(--motion-fast), background-color var(--motion-fast);
}
.so-chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.so-chip__icon { display: grid; place-items: center; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 8px; background: var(--color-surface); color: var(--color-primary); font-size: 0.9375rem; }
.so-chip__label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.so-chip::after { content: ""; flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--color-border); }
.so-chip:has(input:checked) { border: 2px solid var(--color-primary); background: var(--color-info-bg); }
.so-chip:has(input:checked)::after { content: "✓"; display: grid; place-items: center; border-color: var(--color-primary); background: var(--color-primary); color: #fff; font-size: 0.75rem; font-weight: 800; }
.so-chip:has(input:checked) .so-chip__icon { background: var(--color-primary); color: #fff; }
.so-chip--state .so-chip__icon { color: #57606a; }
.so-chip--state:has(input:checked) { border-color: #57606a; background: #EEF0F2; }
.so-chip--state:has(input:checked)::after { border-color: #57606a; background: #57606a; }
.so-chip--state:has(input:checked) .so-chip__icon { background: #57606a; color: #fff; }
.so-chip:has(input:focus-visible) { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.so-chip:has(input:disabled) { opacity: 0.6; cursor: not-allowed; }

/* Tallas y cantidades: filas (RE-05). */
.so-variants { list-style: none; margin: 0; padding: 0; border: 1px solid var(--color-border-soft); border-radius: 12px; }
.so-variant { display: grid; grid-template-columns: auto minmax(0, 1fr) 88px; align-items: center; gap: var(--space-3); padding: var(--space-3); }
.so-variant + .so-variant { border-top: 1px solid var(--color-border-soft); }
.so-variant__text { display: grid; min-width: 0; }
.so-variant__name { font-weight: 600; overflow-wrap: anywhere; }
.so-variant__text small { color: var(--color-muted); }
.so-variant__qty input { width: 100%; min-height: var(--target-min); padding: var(--space-1) var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius); text-align: center; font-weight: 700; }
.so-variant.is-off .so-variant__text, .so-variant.is-off .so-variant__qty { opacity: 0.55; }
.so-switch { position: relative; display: inline-flex; align-items: center; width: 48px; height: var(--target-min); cursor: pointer; }
.so-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.so-switch__track { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--color-border); transition: background var(--motion-fast); }
.so-switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform var(--motion-fast); }
.so-switch input:checked + .so-switch__track { background: var(--color-success); }
.so-switch input:checked + .so-switch__track::after { transform: translateX(18px); }
.so-switch input:focus-visible + .so-switch__track { outline: 3px solid var(--color-focus); outline-offset: 2px; }

/* Acciones fijas abajo (FR-E07). */
.so-actions { display: flex; justify-content: flex-start; padding: var(--space-3) 0 0; border-top: 1px solid var(--color-border-soft); background: var(--color-bg); }
.sheet-dialog__body .so-actions {
  position: sticky; bottom: calc(-1 * var(--space-4) - env(safe-area-inset-bottom, 0px)); z-index: 2;
  margin: 0 calc(-1 * var(--space-4)) calc(-1 * var(--space-4)); padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
}
@media (prefers-reduced-motion: reduce) { .so-chip, .so-switch__track, .so-switch__track::after { transition: none; } }
.discount-field__row .badge--discount { flex: 0 0 auto; white-space: nowrap; }

/* =========================================================================
 * Spec 006 (RE-06 a RE-08): cabecera, filas y filtros de la página del catálogo.
 * ========================================================================= */
.state-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: var(--text-sm); border: 1px solid transparent; }
.state-badge--publicado { background: #DAFBE1; color: #116329; border-color: #A7E3B6; }
.state-badge--borrador { background: #EEF2F7; color: #24405E; border-color: #C9D6E5; }
.state-badge--despublicado { background: #FFF4D6; color: #7A4A00; border-color: #F1D58A; }
.state-badge--vencido { background: #EEF0F2; color: #57606a; border-color: #D0D7DE; }
.builder__stats { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-2) 0 var(--space-3); padding: 0; list-style: none; }
.builder__stats > li { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border-radius: 999px; background: var(--color-surface); font-size: var(--text-sm); color: var(--color-text); }
.builder__stats > li[hidden] { display: none; }
.builder__stat-btn { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; font: inherit; font-weight: 700; color: var(--color-warning-text); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
#attention-stat { background: var(--color-warning-bg); }

.pick-row { border-radius: 12px; border-left: 4px solid transparent; transition: background-color var(--motion-fast); }
.pick-row.is-in-catalog { border-left-color: var(--color-primary); background: var(--color-info-bg); }
.pick-row__photo, .pick-row__photo img { width: 56px; height: 56px; border-radius: 12px; }
.pick-row__photo img { object-fit: cover; }
.pick-row__name { font-weight: 700; }
.pick-row__toggle { min-height: var(--target-min); white-space: nowrap; }
.pick-row__attention { display: inline-block; margin-top: 2px; font-size: var(--text-sm); font-weight: 700; color: var(--color-warning-text); }
.pick-row__attention[hidden] { display: none; }
.filter-result-count { display: inline-block; margin: var(--space-1) 0 0; }
.filter-result-count:empty { display: none; }
@media (max-width: 767px) { .builder__list { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); } }
@media (prefers-reduced-motion: reduce) { .pick-row { transition: none; } }

/* Spec 008 (FR-L19, FR-L26): producto principal y miniatura del enlace en "Compartir". */
.badge--main { display: inline-flex; align-items: center; gap: 4px; background: #FFF4D6; color: #6B4A00; border: 1px solid #F2D27A; font-weight: 600; }
.pick-row__text .badge--main { justify-self: start; width: max-content; }
.so-main { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-1) 0 0; font-size: var(--text-sm); color: var(--color-text-muted, #57606a); }
.so-make-main { margin-top: var(--space-1); }
.share-sheet__og { margin: var(--space-3) 0; }
.share-sheet__og img { display: block; width: 100%; height: auto; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: 12px; border: 1px solid var(--color-border-soft); }
.share-sheet__og figcaption { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--color-text-muted, #57606a); }

/* Spec 011 (FR-A01 a FR-A05, FR-A24): hoja "Atributos" de una categoría. Marcas con texto, controles de 44 px. */
.attr-sheet { display: grid; gap: var(--space-3); }
.attr-sheet__warn { margin: 0; padding: var(--space-2) var(--space-3); border-radius: var(--radius); background: #FFF4D6; color: #6B4A00; border: 1px solid #F2D27A; }
.attr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.attr-item { display: grid; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--color-border-soft); border-radius: var(--radius); }
.attr-item__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); min-width: 0; }
.attr-item__name { font-weight: 700; overflow-wrap: anywhere; }
.attr-item .actions-row, .attr-option { flex-wrap: wrap; }
.attr-item .btn--sm { min-height: var(--target-min); }
.attr-options { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.attr-option { display: flex; align-items: center; gap: var(--space-2); padding-left: var(--space-3); border-left: 3px solid var(--color-border-soft); }
.attr-option > span { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; }
.attr-option-add { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.attr-option-add input { flex: 1 1 10rem; min-width: 0; min-height: var(--target-min); padding: var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius); }
.attr-form { border-top: 1px solid var(--color-border-soft); padding-top: var(--space-3); }
.attr-form__title { font-size: var(--text-base); margin: 0 0 var(--space-2); }
.category-item .btn--sm { min-height: var(--target-min); }

/* Spec 011 (FR-A11, FR-A12, FR-A24): atributos y variantes por atributos en el formulario del producto. */
.product-attributes, .variant-axes { border: 1px solid var(--color-border-soft); border-radius: var(--radius); padding: var(--space-3); margin: var(--space-3) 0; }
.product-attributes__fields { display: grid; gap: var(--space-2) var(--space-4); }
@media (min-width: 768px) { .product-attributes__fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.variant-axes__groups { display: grid; gap: var(--space-3); margin-bottom: var(--space-3); }
.axis { border: 0; margin: 0; padding: 0; min-width: 0; }
.axis legend { font-weight: 700; margin-bottom: var(--space-1); }
.axis__options { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.axis__option { align-items: center; min-height: var(--target-min); padding: 0 var(--space-3); border: 1px solid var(--color-border); border-radius: 999px; cursor: pointer; }
.axis__option:has(input:checked) { border-color: var(--color-primary); background: var(--color-info-bg); font-weight: 600; }
#combos-table th[scope="row"] { font-weight: 600; overflow-wrap: anywhere; }
#combos-table input[type="number"] { width: 6.5rem; min-height: var(--target-min); }
#combos-table .check { justify-content: center; min-height: var(--target-min); align-items: center; }
#combos-table thead th { white-space: nowrap; overflow-wrap: normal; }

/* "Variantes y existencias reales" responsivo (corrección 2026-11-22). Un fieldset no se encoge por
   debajo de su contenido (min-width: min-content por defecto): sin esto, la tabla ensanchaba toda la
   página en el celular. Por debajo de 640 px, cada variante es una tarjeta con sus etiquetas visibles:
   Talla y Color arriba, Existencias y ✕ abajo. */
.variants, .product-attributes { min-width: 0; }
@media (max-width: 639px) {
  #variants-table, #variants-table tbody { display: block; width: 100%; }
  #variants-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  #variants-table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "size color" "stock remove";
    gap: var(--space-2) var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border-soft);
  }
  #variants-table td { display: block; min-width: 0; padding: 0; border: 0; }
  #variants-table td:nth-child(1) { grid-area: size; }
  #variants-table td:nth-child(2) { grid-area: color; }
  #variants-table td:nth-child(3) { grid-area: stock; }
  #variants-table td:nth-child(4) { grid-area: remove; align-self: end; justify-self: end; }
  #variants-table td label.visually-hidden {
    position: static !important; display: block; width: auto; height: auto; margin: 0 0 4px; overflow: visible; clip: auto;
    white-space: normal; font-size: var(--text-sm); font-weight: 600;
  }
  #variants-table input { width: 100%; min-width: 0; min-height: var(--target-min); }
  #variants-table [data-action="remove-variant"] { min-width: var(--target-min); min-height: var(--target-min); }
}
@media (max-width: 399px) {
  #combos-table th, #combos-table td { padding: var(--space-2) 4px; }
  #combos-table input[type="number"] { width: 4.25rem; }
}
/* Desde 640 px la tabla de variantes se ajusta al ancho disponible: los campos ocupan su columna
   (antes medían 183 px fijos y la tabla, 657 px, no cabía entre 640 y 767 px). */
@media (min-width: 640px) {
  #variants-table { width: 100%; table-layout: fixed; }
  #variants-table th:last-child, #variants-table td:last-child { width: 3.5rem; }
  #variants-table input { width: 100%; min-width: 0; box-sizing: border-box; }
}
