:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-text: #1c2230;
  --color-text-muted: #6b7280;
  --color-primary: #f7941d;
  --color-primary-dark: #c96f00;
  --color-primary-tint: #fff3e0;
  --color-accent: #e8590c;
  --color-border: #e3e5ea;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-hover: 0 8px 20px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

body.no-scroll {
  overflow: hidden;
}

.site-header {
  background: var(--color-primary);
  color: #fff;
}

.header-inner {
  max-width: min(1800px, 97vw);
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-cart {
  position: relative;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-cart:hover {
  background: rgba(255,255,255,0.22);
}

.cart-count {
  display: inline-block;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 4px;
}

.brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.logo {
  display: inline-block;
  text-decoration: none;
  line-height: 0;
}

.logo img {
  height: 48px;
  width: auto;
  display: block;
}

.tagline {
  margin: 4px 0 0;
  font-size: 0.95rem;
  opacity: 0.85;
}

.container {
  max-width: min(1800px, 97vw);
  margin: 0 auto;
  padding: 20px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: end;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 180px;
  min-width: 160px;
}

.filter-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.filter-group input,
.filter-group select {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--color-text);
}

.filter-group input:focus,
.filter-group select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.btn-clear {
  padding: 10px 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  height: 41px;
}

.btn-clear:hover {
  background: #f0f1f3;
}

.results-bar {
  margin-bottom: 14px;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-photo-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #fafbfc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}

.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.card-body {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card-name {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
  min-height: 2.4em;
}

.card-sku {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin: 0;
}

.card-rubro {
  font-size: 0.72rem;
  color: var(--color-primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0;
}

.price-contado {
  margin-top: 6px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-text);
}

.price-contado small {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.card-actions {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  gap: 8px;
}

.card-actions button {
  flex: 1;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--color-border);
}

.btn-view-plans {
  background: #fff;
  color: var(--color-primary-dark);
}

.btn-view-plans:hover {
  background: var(--color-primary-tint);
}

.btn-add-quick {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.btn-add-quick:hover {
  background: var(--color-primary-dark);
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin: 28px 0;
}

.btn-load-more {
  padding: 12px 28px;
  border: none;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-load-more:hover {
  background: var(--color-primary-dark);
}

.empty-state, .error-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 40px 0;
}

.error-state {
  color: #b3261e;
}

.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 2px 0;
}

.site-footer a {
  color: var(--color-primary-dark);
  font-weight: 600;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* ---------- overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.55);
  z-index: 40;
}

.overlay[hidden],
.modal[hidden],
.cart-drawer[hidden] {
  display: none;
}

/* ---------- modal producto ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 20px 20px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
}

.modal-photo {
  aspect-ratio: 1 / 1;
  max-height: 260px;
  background: #fafbfc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 14px;
}

.modal-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
}

.modal-name {
  font-size: 1.15rem;
  margin: 0 0 4px;
}

.modal-sku {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.modal-contado {
  background: var(--color-primary-tint);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-primary-dark);
}

.modal-contado small {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.plan-blocks {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.plan-block {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 14px;
}

.plan-block-title {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--color-primary);
}

.freq-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 3px 0;
}

.freq-label {
  color: var(--color-text-muted);
}

.freq-value {
  font-weight: 700;
}

.modal-buy {
  border-top: 1px solid var(--color-border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-buy label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.modal-buy select,
.modal-buy input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.modal-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.pay-schedule {
  margin: -4px 0 0;
  font-size: 0.78rem;
  color: var(--color-primary-dark);
  background: var(--color-primary-tint);
  border-radius: 6px;
  padding: 6px 10px;
}

.qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.date-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qty-stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.qty-stepper button {
  width: 34px;
  height: 34px;
  border: none;
  background: #f0f1f3;
  font-size: 1.1rem;
  cursor: pointer;
}

.qty-stepper input {
  width: 48px;
  text-align: center;
  border: none;
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  height: 34px;
}

/* ---------- carrito ---------- */

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  background: var(--color-surface);
  z-index: 55;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(0,0,0,0.15);
}

.cart-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.cart-drawer-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.cart-drawer-header .modal-close {
  position: static;
}

.cart-plan-summary {
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
  background: #fafbfc;
}

.cart-plan-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.88rem;
  margin-bottom: 6px;
}

.btn-choose-plan {
  width: 100%;
  padding: 9px;
  border: 1px solid var(--color-primary);
  border-radius: 8px;
  background: #fff;
  color: var(--color-primary-dark);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 4px;
}

.btn-choose-plan:hover {
  background: var(--color-primary-tint);
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.cart-empty {
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 40px;
}

.cart-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.cart-item img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #fafbfc;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  flex-shrink: 0;
}

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

.cart-item-name {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
}

.cart-item-mode {
  margin: 2px 0 6px;
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.cart-item-schedule {
  margin: 0 0 6px;
  font-size: 0.7rem;
  color: var(--color-primary-dark);
  background: var(--color-primary-tint);
  border-radius: 5px;
  padding: 4px 7px;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-item-qty button {
  width: 24px;
  height: 24px;
  border: 1px solid var(--color-border);
  background: #f0f1f3;
  border-radius: 4px;
  cursor: pointer;
}

.cart-item-remove {
  margin-left: auto;
  background: none;
  border: none;
  color: #b3261e;
  font-size: 0.72rem;
  cursor: pointer;
  width: auto !important;
  height: auto !important;
}

.cart-item-subtotal {
  font-weight: 800;
  font-size: 0.85rem;
  white-space: nowrap;
}

.cart-footer {
  border-top: 1px solid var(--color-border);
  padding: 14px 20px 20px;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.btn-whatsapp {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: #25d366;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 8px;
}

.btn-whatsapp:disabled {
  background: #a9d9c1;
  cursor: not-allowed;
}

.btn-pdf {
  width: 100%;
  padding: 11px;
  border: 1px solid var(--color-primary);
  border-radius: 8px;
  background: #fff;
  color: var(--color-primary-dark);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 8px;
}

.btn-pdf:disabled {
  border-color: var(--color-border);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.btn-clear-cart {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  color: var(--color-text-muted);
  cursor: pointer;
}

/* ---------- responsive ---------- */

@media (max-width: 480px) {
  .filters {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-group {
    flex: none;
    min-width: 0;
  }

  .header-inner {
    flex-direction: row;
    justify-content: space-between;
  }

  .logo img {
    height: 34px;
  }

  .tagline {
    font-size: 0.78rem;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }

  .card-name {
    font-size: 0.85rem;
    min-height: 2.2em;
  }

  .card-actions {
    flex-direction: column;
  }

  .modal-content {
    padding: 20px 14px 16px;
    max-height: 95vh;
  }

  .cart-drawer {
    width: 100%;
  }
}
