:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--page);
  --text: #172936;
  --page: #f4f7fa;
  --surface: #fff;
  --band: #103756;
  --action: #07674e;
  --action-hover: #05543f;
  --navy: #103756;
  --blue: #146092;
  --muted: #506475;
  --line: #d8e2eb;
  --green: #07674e;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }
.wrap { width: min(100% - 48px, 1400px); margin-inline: auto; }
.header { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line); }
.header-content { display: flex; justify-content: space-between; align-items: center; min-height: 76px; gap: 16px; }
.header-content a { display: flex; align-items: center; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.logo { display: block; width: 175px; max-height: 49px; object-fit: contain; object-position: left center; }
.whatsapp-link {
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #087b4a;
  color: #fff;
}
.whatsapp-link:hover { background: #06653d; }
main { min-height: 78vh; padding-block: 28px 38px; }
.intro { margin-bottom: 20px; font-size: clamp(1.65rem, 3.5vw, 2.35rem); letter-spacing: -.04em; color: var(--navy); }
.filters { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: 12px; }
.filters label { display: grid; min-width: 0; gap: 5px; font-size: .78rem; font-weight: 650; color: var(--navy); }
.filters input, .filters select { width: 100%; min-width: 0; height: 42px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; font-size: .9rem; font-weight: 450; }
.filters input { padding-inline-start: 38px; }
.search-field { position: relative; }
.search-field svg { position: absolute; inset: 12px auto auto 12px; color: var(--muted); pointer-events: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.results-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; }
.results-bar p, footer { color: var(--muted); font-size: .83rem; }
#reset { background: transparent; color: var(--blue); font-size: .84rem; font-weight: 650; border: 0; cursor: pointer; padding: 8px 0 8px 8px; }
.rubro + .rubro { margin-top: 24px; }
.rubro-title { display: flex; align-items: center; gap: 10px; color: #fff; background: var(--band); border-radius: 6px; padding: 9px 13px; font-size: .91rem; letter-spacing: .025em; }
.rubro-title small { color: #d9eaf7; font-size: .75rem; font-weight: 500; }
.category { content-visibility: auto; contain-intrinsic-size: auto 220px; margin-top: 12px; }
.category h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; padding: 4px 2px; color: var(--blue); font-size: .81rem; font-weight: 750; }
.category h3 small { color: var(--muted); font-weight: 500; }
.products { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; list-style: none; padding: 0; margin: 0; }
.product { display: flex; min-width: 0; flex-direction: column; justify-content: space-between; gap: 6px; padding: 10px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.product-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 6px; }
.product-details { display: grid; justify-items: start; gap: 5px; }
.product-name { overflow-wrap: anywhere; font-size: .79rem; font-weight: 650; line-height: 1.35; }
.product-price { color: var(--green); font-size: 1rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.product-code { font-size: .69rem; color: var(--muted); }
.product-photo {
  width: clamp(52px, 9vw, 108px);
  height: auto;
  aspect-ratio: 1.35;
  object-fit: contain;
  object-position: center top;
}
.product-order { margin-top: 3px; }
.order-primary, .order-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.order-primary { background: var(--action); color: #fff; }
.order-primary:hover { background: var(--action-hover); }
.order-secondary { border-color: var(--line); background: var(--surface); color: var(--navy); }
.order-secondary:hover { background: var(--page); }
#open-order { white-space: nowrap; }
#order-count {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--green);
  font-size: .72rem;
}
.order-add { width: 100%; }
.order-quantity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: .78rem;
  font-weight: 650;
  color: var(--navy);
}
.order-quantity input, .order-contact input, #order-message {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
}
.order-quantity input { width: 4rem; }
#order-dialog {
  width: min(620px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: clamp(14px, 4vw, 24px);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: var(--surface);
}
#order-dialog::backdrop { background: #10375699; }
.order-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.order-heading h2 { color: var(--navy); font-size: 1.4rem; }
.order-close { min-width: 40px; padding: 0; font-size: 1.35rem; }
#order-empty, .order-note { color: var(--muted); font-size: .9rem; line-height: 1.5; }
.order-items { display: grid; gap: 8px; margin: 0 0 18px; padding: 0; list-style: none; }
.order-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.order-item-name { display: grid; gap: 3px; overflow-wrap: anywhere; font-size: .84rem; }
.order-item-name small { color: var(--muted); }
.order-contact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.order-contact legend { padding: 0 5px; color: var(--navy); font-size: .9rem; font-weight: 700; }
.order-contact label { display: grid; gap: 5px; font-size: .82rem; font-weight: 650; color: var(--navy); }
.order-note { margin: 12px 0; }
.order-submit { width: 100%; min-height: 44px; }
.order-copy { margin-top: 12px; font-size: .88rem; }
#order-message { margin-block: 8px; resize: vertical; }
#order-copy-status { margin-top: 6px; color: var(--muted); }
.empty { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 24px; text-align: center; color: var(--muted); }
footer { padding: 16px 0; border-top: 1px solid var(--line); background: var(--surface); }
@media (max-width: 960px) { .products { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 650px) {
  .wrap { width: calc(100% - 28px); }
  .header-content { min-height: 64px; }
  .logo { width: 147px; }
  main { padding-block: 20px 30px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .search, .filters label:last-child { grid-column: 1 / -1; }
  .filters input, .filters select { font-size: 1rem; }
  .products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product { padding: 9px; }
}
@media (max-width: 420px) {
  .header-content, .header-actions { gap: 8px; }
  .logo { width: clamp(90px, 33vw, 138px); }
  .whatsapp-link { width: 40px; height: 40px; }
  #open-order { padding-inline: 8px; }
  .order-item { grid-template-columns: minmax(0, 1fr) auto; }
  .order-item-name { grid-column: 1 / -1; }
  .order-contact { grid-template-columns: 1fr; }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #e6edf4;
  --page: #12171d;
  --surface: #1c242d;
  --navy: #d8eafe;
  --blue: #8bc9fa;
  --muted: #b2c2d1;
  --line: #3b4958;
  --green: #80dfb4;
  --band: #243e55;
  --action: #07674e;
  --action-hover: #087858;
}
.theme-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--navy);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--page); }
.theme-moon {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: currentColor;
  mask-image: radial-gradient(circle 9px at 73% 25%, transparent 91%, #000 100%);
}
.theme-sun {
  position: relative;
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}
.theme-sun::before {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
  box-shadow: 0 -9px, 0 9px, -9px 0, 9px 0,
    -6px -6px, 6px -6px, -6px 6px, 6px 6px;
  content: "";
}
.theme-sun, [data-theme="dark"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: block; }
[data-theme="dark"] .logo { background: #dce5ed; border-radius: 5px; padding: 3px 5px; }
[data-theme="dark"] #order-dialog::backdrop { background: #000b; }
@media (max-width: 420px) {
  .theme-toggle { width: 40px; height: 40px; }
  .header-content > a { min-width: 0; }
  .logo { max-width: 100%; }
}
