:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --primary: #0f7cff;
  --accent: #00a6b8;
  --danger: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 48px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1, h2 { margin: 0; }

h1 {
  font-size: clamp(22px, 4vw, 34px);
  line-height: 1.05;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 700;
}

.primary, .search-band button, .cart-button {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.whatsapp-link {
  display: block;
  margin-top: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  background: #128c7e;
  color: white;
  text-align: center;
  text-decoration: none;
  font-weight: 800;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 24px) 40px;
}

.search-band {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
  background: white;
}

.status, .small-status {
  color: var(--muted);
  min-height: 24px;
}

.small-status.error { color: var(--danger); }

.category-bar {
  display: flex;
  gap: 8px;
  margin: 0 0 14px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.category-bar button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  white-space: nowrap;
}

.category-bar button.active {
  background: var(--text);
  border-color: var(--text);
  color: white;
}

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

.product {
  min-height: 260px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.image-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #eef2f6;
}

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

.image-frame span {
  display: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.image-frame.missing span {
  display: block;
}

.product-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 10px;
  gap: 8px;
}

.product-name {
  min-height: 42px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.barcode {
  color: var(--muted);
  font-size: 12px;
}

.price {
  margin-top: auto;
  font-size: 18px;
  font-weight: 800;
}

.cart-panel {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 5;
  width: min(420px, 100vw);
  padding: 16px;
  overflow: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px rgba(16, 24, 40, .18);
}

.load-more {
  display: block;
  width: min(360px, 100%);
  margin: 22px auto 0;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.cart-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.cart-row strong { display: block; }

.field {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  font-weight: 700;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  padding: 16px 0;
  font-size: 18px;
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .search-band { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
