.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-height);
  min-height: var(--touch-min);
  padding: 0 var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  user-select: none;
}

.btn--block { width: 100%; }

.btn--primary {
  background: var(--blue-primary);
  color: var(--text-on-dark);
}

.btn--primary:hover:not(:disabled),
.btn--primary:focus-visible:not(:disabled) {
  background: var(--blue-bright);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn--ghost {
  background: transparent;
  color: var(--blue-primary);
}

.btn--ghost:hover:not(:disabled),
.btn--ghost:focus-visible:not(:disabled) {
  background: var(--blue-ice);
}

.btn:disabled {
  background: var(--neutral-disabled-bg);
  color: var(--neutral-disabled-text);
  cursor: not-allowed;
}

.btn[data-loading="true"] .btn__label { visibility: hidden; }
.btn[data-loading="true"]::after {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 700ms linear infinite;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__label {
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}

.field__label[data-optional]::after {
  content: " (opcional)";
  font-weight: var(--fw-regular);
  color: var(--text-tertiary);
}

.field__helper {
  font-size: var(--fs-micro);
  color: var(--text-tertiary);
}

.field__error {
  font-size: var(--fs-micro);
  color: var(--red-critical);
  min-height: 16px;
}

.input,
.select {
  height: var(--input-height);
  min-height: var(--touch-min);
  padding: 0 var(--space-4);
  border: 1px solid var(--border-divider);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-size: var(--fs-body);
  color: var(--text-primary);
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input::placeholder {
  color: var(--neutral-disabled-text);
}

.input:focus,
.select:focus {
  border-color: var(--blue-primary);
  border-width: 2px;
  box-shadow: var(--shadow-focus);
  outline: none;
}

.field[data-invalid="true"] .input,
.field[data-invalid="true"] .select {
  border-color: var(--red-critical);
  border-width: 2px;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  min-height: var(--touch-min);
  padding: var(--space-2) 0;
}

.checkbox__input {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 2px solid var(--border-divider);
  border-radius: 6px;
  background: var(--bg-surface);
  cursor: pointer;
  position: relative;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.checkbox__input:checked {
  background: var(--blue-primary);
  border-color: var(--blue-primary);
}

.checkbox__input:checked::after {
  content: "";
  position: absolute;
  left: 6px; top: 2px;
  width: 6px; height: 11px;
  border: solid var(--text-on-dark);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox__input:focus-visible {
  box-shadow: var(--shadow-focus);
  outline: none;
}

.checkbox__label {
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  line-height: 1.4;
}

.checkbox__label a {
  color: var(--blue-primary);
  font-weight: var(--fw-semibold);
  text-decoration: underline;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}

.segmented__option {
  display: flex;
  align-items: center;
  min-height: var(--touch-min);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-divider);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  cursor: pointer;
  font-size: var(--fs-body);
  text-align: left;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.segmented__option[aria-pressed="true"] {
  border-color: var(--blue-primary);
  border-width: 2px;
  background: var(--blue-ice);
  font-weight: var(--fw-semibold);
  color: var(--blue-primary);
}

.segmented__option:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
}

.card--summary {
  background: linear-gradient(135deg, var(--blue-deep), var(--blue-primary));
  color: var(--text-on-dark);
  border-radius: var(--radius-xl);
}

.toast-region {
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  right: var(--space-4);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  border-left-width: 4px;
  border-left-style: solid;
  background: var(--bg-surface);
  box-shadow: var(--shadow-card);
  pointer-events: auto;
  animation: toast-in var(--transition-base);
}

.toast--success { border-left-color: var(--green-success); color: var(--green-success); }
.toast--error { border-left-color: var(--red-critical); color: var(--red-critical); background: var(--red-critical-bg); }
.toast--info { border-left-color: var(--blue-primary); color: var(--blue-primary); background: var(--blue-ice); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.sync-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sync-dot[data-state="online"] { background: var(--green-success); animation: pulse 2s ease-in-out infinite; }
.sync-dot[data-state="offline"] { background: var(--text-tertiary); }
.sync-dot[data-state="syncing"] { background: var(--amber-warning); animation: pulse 1s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.sync-indicator__count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--amber-warning);
  color: var(--text-on-dark);
  font-size: var(--fs-micro);
  font-weight: var(--fw-bold);
  line-height: 18px;
  text-align: center;
}

.price-dual {
  display: inline-flex;
  flex-direction: column;
  align-items: baseline;
  gap: var(--space-1);
}

.price-dual__primary {
  font-size: var(--fs-money-lg);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1;
}

.price-dual__secondary {
  font-size: var(--fs-subtitle);
  font-weight: var(--fw-regular);
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.price-dual--inline { flex-direction: row; align-items: baseline; gap: var(--space-2); }
.price-dual--inline .price-dual__primary { font-size: var(--fs-subtitle); }
.price-dual--inline .price-dual__secondary { font-size: var(--fs-caption); }

.link {
  color: var(--blue-primary);
  font-weight: var(--fw-semibold);
  cursor: pointer;
}

.link:hover, .link:focus-visible { color: var(--blue-bright); text-decoration: underline; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-divider);
}

.app-header__brand {
  font-size: var(--fs-subtitle);
  font-weight: var(--fw-bold);
  color: var(--blue-deep);
}

.divider {
  height: 1px;
  background: var(--border-divider);
  border: 0;
  margin: var(--space-6) 0;
}

/* ============================================================
   SPRINT 2 — POS · Carrito · Cobro
   ============================================================ */

:root {
  --nav-h: 64px;
  --header-h: 56px;
  --cart-bar-h: 76px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- App screen layout (header sticky + bottom fixed elements) --- */
.app-screen {
  min-height: 100dvh;
  background: var(--bg-page);
}

.app-screen .app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  padding: 0 var(--space-4);
  gap: var(--space-3);
}

.app-header__back {
  width: var(--touch-min);
  height: var(--touch-min);
  margin-left: calc(var(--space-2) * -1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--blue-deep);
  border-radius: var(--radius-md);
}

.app-header__back:hover,
.app-header__back:focus-visible { background: var(--blue-ice); }

.app-header__title {
  font-size: var(--fs-subtitle);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header__brand {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header__right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Scrollable body that clears the fixed bottom chrome */
.app-body {
  padding: var(--space-4);
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--space-6));
}

.app-screen[data-cart="filled"] .app-body {
  padding-bottom: calc(var(--nav-h) + var(--cart-bar-h) + var(--safe-bottom) + var(--space-6));
}

/* --- Search bar --- */
.search-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 25;
  background: var(--bg-page);
  padding: var(--space-3) var(--space-4);
}

.search-input {
  height: var(--input-height);
  width: 100%;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-divider);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-size: var(--fs-body);
}

.search-input:focus {
  border-color: var(--blue-primary);
  border-width: 2px;
  box-shadow: var(--shadow-focus);
  outline: none;
}

/* --- Rate banner (BRAND: ámbar = requiere atención) --- */
.rate-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 var(--space-4) var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: #FEF3E2;
  border-left: 4px solid var(--amber-warning);
  color: #92400E;
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
}

/* --- Product grid --- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

@media (min-width: 600px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}

/* --- ProductCard (BRAND §3.2) --- */
.product-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  text-align: left;
  position: relative;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.product-card:active:not(:disabled) { transform: scale(0.97); }
.product-card:focus-visible { outline: 2px solid var(--blue-primary); outline-offset: 2px; }

.product-card--low { border-color: var(--red-critical); border-width: 2px; }
.product-card--out { cursor: not-allowed; }

.product-card__media {
  aspect-ratio: 1;
  background: var(--blue-ice);
}

.product-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-card__img--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.product-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  flex: 1;
}

.product-card__name {
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card__badge {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  background: var(--blue-primary);
  color: var(--text-on-dark);
  font-size: var(--fs-micro);
  font-weight: var(--fw-bold);
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-card__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-card__overlay-text {
  color: var(--text-on-dark);
  font-weight: var(--fw-bold);
  font-size: var(--fs-caption);
}

.price-dual--card { flex-direction: column; gap: 0; }
.price-dual--card .price-dual__primary { font-size: var(--fs-body); }
.price-dual--card .price-dual__secondary { font-size: var(--fs-micro); }

/* --- Cart bar (BRAND §4: barra inferior de carrito) --- */
.cart-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  z-index: 28;
  height: var(--cart-bar-h);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  background: var(--blue-deep);
  color: var(--text-on-dark);
  cursor: pointer;
  border: 0;
  width: 100%;
  text-align: left;
}

.cart-bar__count {
  font-size: var(--fs-caption);
  color: var(--text-on-dark-muted);
  flex-shrink: 0;
}

.cart-bar__total {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.cart-bar__total-bs { font-size: var(--fs-subtitle); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.cart-bar__total-usd { font-size: var(--fs-micro); color: var(--text-on-dark-muted); font-variant-numeric: tabular-nums; }

.cart-bar__cta {
  flex-shrink: 0;
  background: var(--blue-primary);
  color: var(--text-on-dark);
  font-weight: var(--fw-semibold);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  pointer-events: none;
}

/* --- FAB (BRAND §4: botón flotante +) --- */
.fab {
  position: fixed;
  right: var(--space-4);
  bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--space-4));
  z-index: 29;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--blue-primary);
  color: var(--text-on-dark);
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(29, 78, 216, 0.4);
}

.app-screen[data-cart="filled"] .fab {
  bottom: calc(var(--nav-h) + var(--cart-bar-h) + var(--safe-bottom) + var(--space-4));
}

.fab:active { transform: scale(0.94); }

/* --- Bottom nav (BRAND §3.5) --- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-divider);
  box-shadow: var(--shadow-nav);
}

.bottom-nav__tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  color: var(--neutral-disabled-text);
  min-height: var(--touch-min);
}

.bottom-nav__tab.is-active { color: var(--blue-primary); }

.bottom-nav__indicator {
  position: absolute;
  top: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
}

.bottom-nav__tab.is-active .bottom-nav__indicator { background: var(--blue-primary); }

.bottom-nav__icon { font-size: 20px; line-height: 1; }
.bottom-nav__label { font-size: 11px; font-weight: var(--fw-semibold); }

/* --- Cart screen --- */
.cart-list { display: flex; flex-direction: column; gap: var(--space-3); }

.cart-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-3);
}

.cart-item__top {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.cart-item__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-item__img {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--blue-ice);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.cart-item__info { min-width: 0; flex: 1; }

.cart-item__name {
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cart-item__unit { font-size: var(--fs-micro); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

.cart-item__subtotal { font-size: var(--fs-subtitle); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }

.cart-item__remove {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  font-size: 20px;
}

.cart-item__remove:hover,
.cart-item__remove:focus-visible { background: var(--red-critical-bg); color: var(--red-critical); }

/* --- Qty stepper --- */
.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-divider);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.qty-stepper__btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: var(--fw-bold);
  color: var(--blue-primary);
  background: var(--bg-surface);
}

.qty-stepper__btn:disabled { color: var(--neutral-disabled-text); }
.qty-stepper__btn:active:not(:disabled) { background: var(--blue-ice); }

.qty-stepper__value {
  min-width: 36px;
  text-align: center;
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}

/* --- Cart summary / checkout footer --- */
.checkout-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: var(--space-4);
  padding-bottom: calc(var(--space-4) + var(--safe-bottom));
  background: var(--bg-surface);
  border-top: 1px solid var(--border-divider);
  box-shadow: var(--shadow-nav);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.checkout-footer__totals {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.checkout-footer__label { font-size: var(--fs-caption); color: var(--text-tertiary); }

.cart-screen .app-body {
  padding-bottom: calc(160px + var(--safe-bottom));
}

/* --- Payment method screen --- */
.payment-total {
  text-align: center;
  padding: var(--space-6) var(--space-4);
}

.payment-total__label { font-size: var(--fs-caption); color: var(--text-tertiary); margin-bottom: var(--space-2); }

.payment-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.payment-method {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  aspect-ratio: 1.3;
  background: var(--bg-surface);
  border: 1px solid var(--border-divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.payment-method:active:not(:disabled) { transform: scale(0.96); border-color: var(--blue-primary); }
.payment-method:focus-visible { outline: 2px solid var(--blue-primary); outline-offset: 2px; }
.payment-method:disabled { opacity: 0.5; }

.payment-method__icon { font-size: 36px; line-height: 1; }
.payment-method__label { font-size: var(--fs-body); font-weight: var(--fw-semibold); }

/* --- Success overlay (BRAND §4: checkmark animado) --- */
.success-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  animation: fade-in var(--transition-base);
}

.success-overlay__check {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--green-success);
  color: var(--text-on-dark);
  font-size: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: success-pop 400ms cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.success-overlay__title { font-size: var(--fs-title); font-weight: var(--fw-bold); }
.success-overlay__subtitle { font-size: var(--fs-body); color: var(--text-tertiary); }

@keyframes success-pop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Empty state --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-12) var(--space-6);
}

.empty-state__icon { font-size: 56px; line-height: 1; }
.empty-state__title { font-size: var(--fs-subtitle); font-weight: var(--fw-bold); }
.empty-state__message { max-width: 32ch; }
.empty-state .btn { margin-top: var(--space-2); }
