:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --dark: #111827;
  --accent: #0f766e;
  --accent2: #115e59;
  --danger: #b91c1c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--dark);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.topbar h1 { margin: 0; font-size: 20px; }
.topbar p { margin: 3px 0 0; color: #d1d5db; font-size: 13px; }
.cart-button {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  padding: 8px 12px;
  min-width: 104px;
  cursor: pointer;
  font-size: 13px;
}
.cart-button:hover { background: var(--accent2); }

.container { max-width: 1100px; margin: 0 auto; padding: 14px; }
.filters {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
}
#searchInput {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 16px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chips button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}
.chips.small button { font-size: 13px; padding: 6px 10px; }
.chips button.active { background: var(--dark); color: white; border-color: var(--dark); }

.section { margin-bottom: 18px; }
.section h2 { font-size: 18px; margin: 10px 4px; }
.hidden { display: none; }
.products { display: grid; gap: 10px; }

.product-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 10px;
}
.product-img {
  width: 82px;
  height: 82px;
  border-radius: 10px;
  background: #eef2f7;
  object-fit: cover;
  border: 1px solid var(--line);
}
.placeholder {
  width: 82px;
  height: 82px;
  border-radius: 10px;
  background: #eef2f7;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  border: 1px solid var(--line);
}
.product-info h3 { margin: 0 0 4px; font-size: 15px; line-height: 1.25; }
.meta { color: var(--muted); font-size: 12px; margin: 2px 0; }
.price { margin: 6px 0; font-size: 16px; font-weight: bold; }
.obs { color: var(--muted); font-size: 12px; margin: 4px 0; }
.out { color: var(--danger); font-weight: bold; }
.variation-box { margin: 8px 0; }
.variation-label { display:block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.variation-options { display:flex; gap: 6px; flex-wrap: wrap; }
.variation-options button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 6px 8px;
  cursor:pointer;
  font-size: 13px;
}
.variation-options button.active { background: var(--accent); color: white; border-color: var(--accent); }
.buy-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.qty-input {
  width: 92px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 8px;
  font-size: 15px;
}
.add-btn {
  flex: 1;
  border: 0;
  background: var(--accent);
  color: white;
  height: 38px;
  border-radius: 9px;
  font-weight: bold;
  cursor: pointer;
}
.add-btn:disabled { background: #9ca3af; cursor: not-allowed; }
.qty-help { font-size: 11px; color: var(--muted); margin-top: 3px; }

.cart-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 390px;
  max-width: 94vw;
  height: 100vh;
  background: white;
  z-index: 30;
  box-shadow: -4px 0 18px rgba(0,0,0,.25);
  padding: 14px;
  overflow-y: auto;
  transition: right .25s ease;
}
.cart-drawer.open { right: 0; }
.overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.35); z-index:20; }
.overlay.open { display:block; }
.cart-head { display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--line); padding-bottom:8px; }
.cart-head h2 { margin:0; }
.cart-head button { border:0; background:#eee; border-radius:8px; padding:8px 10px; cursor:pointer; }
.cart-items { margin: 12px 0; display:grid; gap:8px; }
.cart-item { border:1px solid var(--line); border-radius:10px; padding:8px; }
.cart-item strong { display:block; font-size:14px; }
.cart-item small { color:var(--muted); display:block; margin-top:2px; }
.cart-item-row { display:flex; justify-content:space-between; gap:8px; align-items:center; margin-top:6px; }
.remove { border:0; background:#fee2e2; color:#991b1b; border-radius:8px; padding:6px 8px; cursor:pointer; }
.cart-summary { border-top:1px solid var(--line); padding-top:10px; }
.customer-box { margin-top:14px; display:grid; gap:8px; }
.customer-box h3 { margin:0 0 4px; }
.customer-box input {
  height:40px;
  border:1px solid var(--line);
  border-radius:9px;
  padding:0 10px;
  font-size:14px;
}
.actions { display:grid; gap:8px; margin:14px 0 20px; }
.actions button, .secondary {
  height:42px;
  border:0;
  border-radius:10px;
  cursor:pointer;
  font-weight:bold;
}
.actions button { background: var(--accent); color:white; }
.secondary { background:#e5e7eb; color:var(--text); }
footer { text-align:center; color:var(--muted); font-size:12px; padding:20px; }

@media (min-width: 760px) {
  .products { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1100px) {
  .products { grid-template-columns: 1fr 1fr 1fr; }
}
@media print {
  body * { visibility:hidden; }
  #cartDrawer, #cartDrawer * { visibility:visible; }
  #cartDrawer { position:absolute; inset:0; width:100%; max-width:100%; box-shadow:none; }
  .cart-head button, .actions, #clearCart { display:none; }
}

/* Melhorias V4 */
.qty-control {
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}
.qty-control button {
  height: 38px;
  border: 1px solid var(--line);
  background: #f9fafb;
  border-radius: 9px;
  cursor: pointer;
  font-weight: bold;
  color: var(--dark);
}
.qty-control button:active { transform: scale(.98); }
.qty-control .qty-input {
  width: 100%;
  text-align: center;
  font-weight: bold;
}
.add-btn.full {
  width: 100%;
  margin-top: 8px;
}
.topbar h1 {
  letter-spacing: .5px;
}
.variation-options button:not(.active) {
  background: #f9fafb;
}
@media (max-width: 420px) {
  .topbar { padding: 12px; }
  .topbar h1 { font-size: 18px; }
  .cart-button { min-width: 96px; padding: 7px 9px; }
  .product-card { grid-template-columns: 74px 1fr; }
  .product-img, .placeholder { width: 74px; height: 74px; }
}
