:root {
  --primary: #e63946;
  --primary-dark: #c1121f;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a202c;
  --muted: #64748b;
  --border: #e2e8f0;
  --whatsapp: #25d366;
  --whatsapp-dark: #1da851;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 96px;
  line-height: 1.4;
}

.hidden {
  display: none !important;
}

/* Header */
.store-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  padding: 14px 16px 10px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 900px;
  margin: 0 auto 12px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.store-logo,
.store-logo-fallback {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.store-logo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
}

.brand-info h1 {
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.store-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.badge-open {
  background: #dcfce7;
  color: #166534;
}

.badge-closed {
  background: #fee2e2;
  color: #991b1b;
}

.badge-loading {
  background: #e2e8f0;
  color: #475569;
}

.hours-text {
  font-size: 0.78rem;
  color: var(--muted);
}

.btn-install {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

/* Search */
.search-box {
  max-width: 900px;
  margin: 0 auto 10px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.95rem;
  outline: none;
}

.search-box input:focus {
  border-color: var(--primary);
  background: #fff;
}

/* Category Tabs */
.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cat-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Main Container */
.container {
  max-width: 900px;
  margin: 16px auto;
  padding: 0 14px;
}

.state-box {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

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

.error-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #991b1b;
  margin-bottom: 6px;
}

.error-desc {
  font-size: 0.9rem;
}

/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

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

.product-card {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.product-img-wrap {
  width: 92px;
  height: 92px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.product-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.product-title {
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 3px;
}

.product-desc {
  font-size: 0.82rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.product-price {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-qty {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-qty.minus {
  background: #f1f5f9;
  color: var(--text);
}

.qty-num {
  min-width: 18px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
}

/* Floating Cart Bar */
.cart-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: linear-gradient(to top, rgba(246,247,249,1) 70%, rgba(246,247,249,0));
  z-index: 30;
}

.cart-bar-btn {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.cart-count-pill {
  background: rgba(255, 255, 255, 0.22);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
}

/* Modal / Bottom Sheet */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.22s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

.modal-header h2 {
  font-size: 1.1rem;
}

.btn-close {
  background: #f1f5f9;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
}

.modal-body {
  padding: 16px 20px 24px;
  overflow-y: auto;
}

.cart-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.cart-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cart-item-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.cart-item-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Form */
.checkout-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  background: #fff;
}

.totals-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 4px;
}

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

.total-row.total-final {
  font-size: 1.08rem;
  font-weight: 800;
  margin-bottom: 0;
  padding-top: 8px;
  border-top: 1px dashed #cbd5e1;
}

.btn-whatsapp {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 12px;
  background: var(--whatsapp);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}

.btn-whatsapp:active {
  background: var(--whatsapp-dark);
}
