:root {
  --bg: #FFFFFF;
  --surface: #F5F5F7;
  --border: #E5E5EA;
  --text: #111111;
  --muted: #52525B;
  --action: #00A844;
  --action-active: #008A38;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px));
}

.shell {
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: 1rem;
}

@media (min-width: 768px) {
  .shell {
    padding-inline: 2rem;
  }
}

/* Header Mínimo con Tipografía Mayor */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding-block: 0.9rem;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.6vw, 1.7rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

.brand span {
  font-size: clamp(0.9rem, 1.5vw, 1rem);
  color: var(--muted);
  font-weight: 600;
}

.search {
  flex: 1 1 280px;
  max-width: 460px;
}

.search input {
  width: 100%;
  height: 48px;
  padding: 0 1rem;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background-color: var(--surface);
  font-family: var(--font);
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--text);
}

.search input:focus {
  outline: none;
  background-color: var(--bg);
  border-color: var(--text);
}

/* Filtros más grandes y legibles */
.filters {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  margin-top: 0.8rem;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 1.1rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background-color: var(--bg);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.filter-btn[aria-pressed="true"] {
  background-color: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* Grilla Responsiva */
.grid {
  padding-top: 1.35rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

@media (min-width: 680px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
  }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.5rem;
  }
}

.card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.8rem;
  background-color: var(--bg);
}

.card-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 165px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-price {
  margin: 0.25rem 0 0 0;
  font-size: clamp(1.2rem, 2.2vw, 1.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.card-title {
  margin: 0.25rem 0 0 0;
  font-size: clamp(0.95rem, 1.6vw, 1.06rem);
  font-weight: 700;
  line-height: 1.32;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.64em;
}

.card-meta {
  margin: 0.2rem 0 0 0;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--muted);
}

/* Botón Agregar y Stepper con fuente más grande */
.btn-add {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-add:hover {
  background-color: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.stepper {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  background-color: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.35rem;
}

.step-btn {
  width: 40px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--bg);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
}

.step-qty {
  font-size: 1.02rem;
  font-weight: 800;
}

/* LEY DE FITTS: Único CTA Principal en la Zona del Pulgar */
.thumb-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  padding: 0.75rem 1rem calc(0.8rem + env(safe-area-inset-bottom, 0px)) 1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.96) 40%, #FFFFFF 100%);
  pointer-events: none;
}

.cta-primary {
  pointer-events: auto;
  width: 100%;
  max-width: 500px;
  height: 62px;
  margin-inline: auto;
  border: none;
  border-radius: 16px;
  background-color: var(--action);
  color: #FFFFFF;
  padding: 0 1.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font);
  font-size: 1.08rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 168, 68, 0.3);
}

.cta-primary:active {
  background-color: var(--action-active);
}

.cta-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Modales Nativos (<dialog>) */
dialog[open] {
  opacity: 1;
  transform: translateY(0);

  @starting-style {
    opacity: 0;
    transform: translateY(24px);
  }
}

dialog {
  opacity: 0;
  transform: translateY(24px);
  margin: auto 0 0 0;
  width: 100%;
  max-width: 100%;
  max-height: 92dvh;
  border: none;
  border-radius: 22px 22px 0 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  overflow-y: auto;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.16);

  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.2s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

@media (min-width: 640px) {
  dialog {
    margin: auto;
    width: min(500px, calc(100% - 2rem));
    max-width: 500px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.16);
  }
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.48);
}

.modal-head {
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 800;
}

.btn-close {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background-color: var(--surface);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.modal-body {
  padding: 1.25rem 1.35rem calc(1.35rem + env(safe-area-inset-bottom, 0px)) 1.35rem;
}

.cart-list {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1.15rem;
}

.cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.98rem;
}

.form-minimal {
  display: grid;
  gap: 0.85rem;
}

.form-minimal input,
.form-minimal select {
  width: 100%;
  height: 52px;
  padding: 0 1rem;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background-color: var(--surface);
  font-family: var(--font);
  font-size: 1.04rem;
  color: var(--text);
}

.form-minimal input:focus,
.form-minimal select:focus {
  outline: none;
  background-color: var(--bg);
  border-color: var(--text);
}

.totals {
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 0.4rem;
  font-size: 0.98rem;
}

.totals-line {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.totals-line.final {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  padding-top: 0.35rem;
}

/* Pie Legal Mínimo */
.legal-footer {
  margin-top: 3rem;
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.84rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  background-color: var(--surface);
  padding: 0.3rem;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.mode-btn {
  height: 44px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
}

.mode-btn[aria-pressed="true"] {
  background-color: var(--text);
  color: var(--bg);
}

.pickup-banner {
  padding: 0.8rem 1rem;
  border-radius: 12px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.94rem;
  color: var(--text);
  line-height: 1.4;
}
