@font-face {
  font-family: "Archivo Black";
  src: url("fonts/archivo-black.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #F6F3EE;
  --bg-2: #FFFFFF;
  --ink: #1B1B1B;
  --ink-2: #5B5650;
  --line: #E2DCD3;
  --accent: #F26B1D;
  --accent-ink: #FFFFFF;
  --wa: #128C7E;
  --amber: #B7791F;
  --amber-bg: #FBF1DC;
  --danger: #B3261E;
  --radius: 12px;
  --head: "Archivo Black", "Arial Black", Impact, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bar-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--body);
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom));
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
p { margin: 0; }
h1, h2 { font-family: var(--head); font-weight: 400; margin: 0; letter-spacing: -0.01em; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 3px solid var(--ink);
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 44px; height: 44px; object-fit: contain; }
.top h1 { font-size: 20px; line-height: 1.1; }
.meta { font-size: 13px; color: var(--ink-2); display: flex; gap: 10px; flex-wrap: wrap; }
.meta a { color: inherit; text-decoration: none; font-weight: 600; }
.meta a:empty, .meta span:empty { display: none; }
.pill {
  border: 2px solid var(--ink); background: var(--bg-2); border-radius: 999px;
  padding: 8px 12px; min-height: 44px; font-weight: 600; white-space: nowrap;
}
.badge {
  display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-size: 13px; line-height: 22px; text-align: center;
}

.main { max-width: 760px; margin: 0 auto; padding: 14px 16px 24px; }

.search { margin-top: 0; transition: margin-top 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
.is-home .search { margin-top: max(24px, calc(50vh - 360px)); }
body:not(.is-home) .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
body:not(.is-home) .chips::-webkit-scrollbar { display: none; }
body:not(.is-home) .chip { flex: 0 0 auto; }
.hero-title {
  font-family: var(--head); font-size: clamp(26px, 7vw, 40px); line-height: 1.1; text-align: center;
  max-height: 120px; opacity: 1; margin: 0 0 18px; overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease, margin 0.35s ease;
}
body:not(.is-home) .hero-title { max-height: 0; opacity: 0; margin: 0; }
.is-home .chips { justify-content: center; }
.results { animation: rise 0.35s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.empty-home { padding: 18px 12px 0; }
@media (prefers-reduced-motion: reduce) {
  .search, .hero-title { transition: none; }
  .results { animation: none; }
}

.q {
  width: 100%; min-height: 56px; padding: 12px 16px;
  border: 3px solid var(--ink); border-radius: var(--radius); background: var(--bg-2);
  font-size: 18px; outline: none;
}
.q:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(242, 107, 29, 0.2); }
.q::-webkit-search-cancel-button { -webkit-appearance: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  border: 2px solid var(--line); background: var(--bg-2); border-radius: 999px;
  padding: 8px 14px; min-height: 40px; font-size: 14px; font-weight: 600; color: var(--ink);
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-count { color: var(--ink-2); font-weight: 400; margin-left: 4px; }
.chip[aria-pressed="true"] .chip-count { color: var(--accent-ink); opacity: 0.85; }

.status { margin: 14px 2px 6px; font-size: 14px; color: var(--ink-2); min-height: 20px; }
.status:empty { display: none; }
.error { margin: 24px 0; padding: 14px 16px; border-radius: var(--radius); background: #FBE3E1; color: var(--danger); font-weight: 600; }

.empty { text-align: center; padding: 48px 12px 24px; }
.empty-title { font-family: var(--head); font-size: 22px; margin-bottom: 8px; }
.empty-sub { color: var(--ink-2); font-size: 15px; }
.empty .chips { justify-content: center; margin-top: 14px; }

.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.row-main { min-width: 0; }
.row-desc { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.row-code { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.row-side { display: grid; justify-items: end; gap: 8px; align-content: start; }
.row-price { font-family: var(--head); font-size: 18px; white-space: nowrap; }
.row-price.quote { font-family: var(--body); font-size: 14px; color: var(--ink-2); font-weight: 600; }
.tag { display: inline-block; margin-top: 8px; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.tag-stock { background: var(--amber-bg); color: var(--amber); }

.qty { display: inline-flex; align-items: stretch; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; background: var(--bg-2); }
.qty-btn { width: 44px; min-height: 44px; border: 0; background: transparent; font-size: 20px; font-weight: 700; }
.qty-btn:active { background: var(--line); }
.qty-input { width: 56px; border: 0; border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); text-align: center; font-weight: 700; -moz-appearance: textfield; }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.btn {
  border: 0; border-radius: 10px; min-height: 44px; padding: 10px 16px;
  font-weight: 700; background: var(--accent); color: var(--accent-ink);
}
.btn:active { filter: brightness(0.92); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-add { padding-inline: 20px; }
.btn-add.added { background: var(--ink); }
.btn-secondary { background: var(--bg-2); color: var(--ink); border: 2px solid var(--ink); }
.btn-more { display: block; width: 100%; margin-top: 14px; background: var(--bg-2); color: var(--ink); border: 2px solid var(--ink); }
.btn-wa { width: 100%; background: var(--wa); font-size: 17px; min-height: 52px; margin-top: 8px; }
.link-btn { border: 0; background: none; color: var(--danger); font-weight: 600; padding: 6px 0; text-decoration: underline; }
.icon-btn { border: 0; background: none; font-size: 28px; line-height: 1; width: 44px; height: 44px; }

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 2px solid var(--ink);
}
.btn-help { background: var(--bg-2); color: var(--ink); border: 2px solid var(--ink); font-size: 14px; padding-inline: 10px; }
.btn-cart { font-size: 15px; }

.drawer {
  position: fixed; inset: 0; z-index: 30;
  background: var(--bg); overflow-y: auto;
  animation: up 0.18s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head {
  position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg); border-bottom: 3px solid var(--ink);
}
.drawer-head h2 { font-size: 22px; }
.drawer-body { max-width: 760px; margin: 0 auto; padding: 16px 16px 40px; display: grid; gap: 18px; }

.lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.line {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.line.missing { opacity: 0.6; }
.line-desc { font-weight: 600; overflow-wrap: anywhere; }
.line-code { color: var(--ink-2); font-size: 13px; }
.line-side { display: grid; justify-items: end; gap: 6px; }
.line-sub { font-family: var(--head); font-size: 16px; }

.totals { margin: 0; display: grid; gap: 6px; padding: 14px; background: var(--bg-2); border-radius: var(--radius); border: 1px solid var(--line); }
.totals div { display: flex; justify-content: space-between; gap: 12px; }
.totals dt { color: var(--ink-2); }
.totals dd { margin: 0; font-weight: 700; }
.totals .grand { border-top: 2px solid var(--ink); padding-top: 8px; margin-top: 4px; }
.totals .grand dt { color: var(--ink); font-weight: 700; }
.totals .grand dd { font-family: var(--head); font-size: 20px; }

.block { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
.block legend { font-family: var(--head); font-size: 17px; padding: 0; margin-bottom: 6px; }
.radio, .check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.radio input, .check input { width: 22px; height: 22px; accent-color: var(--accent); }
.sub { display: grid; gap: 10px; padding: 12px; border-left: 3px solid var(--accent); background: var(--bg-2); border-radius: 0 var(--radius) var(--radius) 0; }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field input { min-height: 46px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; background: var(--bg-2); font-size: 16px; font-weight: 400; color: var(--ink); }
.field input:focus { outline: none; border-color: var(--accent); }
.field input.invalid { border-color: var(--danger); }
.aviso { font-size: 14px; color: var(--amber); font-weight: 600; }
.aviso.error { color: var(--danger); background: none; padding: 0; margin: 0; }
.aviso:empty { display: none; }

@media (min-width: 640px) {
  .top { padding: 18px 24px 12px; }
  .top h1 { font-size: 24px; }
  .bottombar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); max-width: 760px; margin: 0 auto; left: 0; right: 0; border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); border-radius: 14px 14px 0 0; }
  .row { grid-template-columns: 1fr auto; }
  .row-side { grid-auto-flow: column; align-items: center; }
}
