:root {
  --paper: #ffffff;
  --well: #f4f3f1;
  --ink: #141414;
  --muted: #6f6f6f;
  --hair: #e4e4e2;

  --st-available: #1f8a4c;
  --st-low: #c07a12;
  --st-ask: #3a6fb0;
  --st-incoming: #a3a3a3;

  --font: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --t-xs: 0.8125rem;
  --t-s: 0.9375rem;
  --t-m: 1.0625rem;
  --t-l: 1.375rem;
  --t-xl: 1.75rem;

  --gutter: 16px;
  --r: 4px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-s);
  line-height: 1.5;
  font-feature-settings: "tnum";
}
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p, figure { margin: 0; }
a { color: inherit; }

.wrap { width: 100%; max-width: 1360px; margin: 0 auto; padding: 0 var(--gutter); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ---------- Encabezado ---------- */
.top { border-bottom: 1px solid var(--hair); background: var(--paper); }
.topbar { display: flex; flex-direction: column; gap: 2px; padding-top: 18px; padding-bottom: 6px; }
.brand { text-decoration: none; font-weight: 600; font-size: var(--t-m); letter-spacing: -0.01em; }
.freshness { font-size: var(--t-xs); color: var(--muted); white-space: nowrap; }
.freshness:empty { display: none; }

.toolbar { display: flex; align-items: center; gap: 20px; padding-top: 10px; }
.search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 44px;
  border-bottom: 1px solid var(--ink); color: var(--muted);
}
.search input { flex: 1; min-width: 0; border: 0; background: transparent; height: 100%; color: var(--ink); outline: none; padding: 0; }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.text-btn { border: 0; background: none; padding: 8px 0; color: var(--muted); white-space: nowrap; }
.text-btn:hover { color: var(--ink); }

.lines { padding-top: 14px; }
.lines-scroll { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.lines-scroll::-webkit-scrollbar { display: none; }
.line-chip {
  flex: none; border: 0; background: none; padding: 0 0 12px; font-size: var(--t-s); color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.line-chip:hover { color: var(--ink); }
.line-chip[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); font-weight: 500; }

.notice { margin-top: 16px; }
.notice p { font-size: var(--t-xs); color: var(--muted); border-left: 2px solid var(--st-low); padding-left: 12px; }

/* ---------- Layout ---------- */
.layout { padding-top: 24px; padding-bottom: 96px; }

/* ---------- Filtros ---------- */
.filters {
  position: fixed; inset: 0; z-index: 40; background: var(--paper);
  display: flex; flex-direction: column; transform: translateY(100%); visibility: hidden;
  transition: transform 0.25s ease, visibility 0s linear 0.25s;
}
.filters.open { transform: none; visibility: visible; transition: transform 0.25s ease; }
.filters-head { display: flex; align-items: center; justify-content: space-between; padding: 14px var(--gutter); border-bottom: 1px solid var(--hair); }
.filters-head h2 { font-size: var(--t-m); font-weight: 600; }
.filters-body { flex: 1; overflow-y: auto; padding: 0 var(--gutter) 24px; }
.filters-foot { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 12px var(--gutter); border-top: 1px solid var(--hair); }

.icon-btn { border: 0; background: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; margin-right: -8px; }
.icon-btn:hover { background: var(--well); }
.btn-solid { border: 0; background: var(--ink); color: #fff; border-radius: var(--r); height: 44px; padding: 0 22px; font-weight: 500; }
.btn-solid:hover { background: #000; }

.facet { border: 0; margin: 0; padding: 20px 0 8px; border-bottom: 1px solid var(--hair); }
.facet:last-child { border-bottom: 0; }
.facet legend { padding: 0; font-weight: 600; font-size: var(--t-xs); color: var(--muted); margin-bottom: 8px; }
.facet-options { display: flex; flex-direction: column; align-items: flex-start; padding-bottom: 8px; }
.facet select {
  width: 100%; height: 40px; border: 0; border-bottom: 1px solid var(--hair); border-radius: 0; background: var(--paper);
  padding: 0; margin-bottom: 8px;
}

.opt { display: inline-flex; align-items: center; gap: 10px; border: 0; background: none; padding: 6px 0; color: var(--ink); text-align: left; line-height: 1.3; }
.opt::before {
  content: ""; width: 16px; height: 16px; flex: none; border: 1px solid var(--hair); border-radius: 3px;
  background: var(--paper) center / 10px no-repeat;
}
.opt[aria-pressed="true"]::before {
  border-color: var(--ink); background-color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.5 5 9l4.5-6' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.opt:hover::before { border-color: var(--ink); }
.opt:disabled { color: var(--muted); opacity: 0.55; cursor: default; }
.opt:disabled::before { border-color: var(--hair); }
.opt .n { color: var(--muted); }

.swatches { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; }
.swatches .opt { gap: 8px; }
.swatches .opt::before { display: none; }
.lens, .rim { width: 14px; height: 14px; border-radius: 50%; background: var(--sw); flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.swatches .opt[aria-pressed="true"] { font-weight: 600; }
.swatches .opt[aria-pressed="true"] .lens, .swatches .opt[aria-pressed="true"] .rim { outline: 1.5px solid var(--ink); outline-offset: 2px; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st, var(--st-ask)); flex: none; display: inline-block; }
[data-s="available"] { --st: var(--st-available); }
[data-s="low"] { --st: var(--st-low); }
[data-s="ask"] { --st: var(--st-ask); }
[data-s="incoming"] { --st: var(--st-incoming); }
.opt[data-s]::before { display: none; }
.opt[data-s][aria-pressed="true"] { font-weight: 600; }
.opt[data-s][aria-pressed="false"] .dot { opacity: 0.35; }

/* ---------- Resultados ---------- */
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.count { color: var(--muted); }
.sort select { border: 0; background: none; color: var(--muted); padding: 0; text-align: right; }
.sort select:hover { color: var(--ink); }

.active { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 4px; }
.active:empty { display: none; }
.chip-x { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 0; font-size: var(--t-s); }
.chip-x svg { color: var(--muted); }
.chip-x:hover svg { color: var(--ink); }
.active .text-btn { padding: 4px 0; }

.group { padding-top: 28px; content-visibility: auto; contain-intrinsic-size: auto 560px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-bottom: 14px; }
.group-head h2 { font-size: var(--t-m); font-weight: 600; letter-spacing: -0.01em; }
.group-head span { font-size: var(--t-xs); color: var(--muted); text-align: right; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 16px; }
.card { text-decoration: none; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.well { background: var(--well); border-radius: var(--r); aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; margin-bottom: 8px; }
.well img { width: 100%; height: 100%; object-fit: contain; }
.well.blend img { mix-blend-mode: multiply; }
.card:hover .card-title { text-decoration: underline; text-underline-offset: 3px; }
.card-title { font-size: var(--t-s); font-weight: 600; line-height: 1.3; }
.card-desc { font-size: var(--t-xs); color: var(--muted); line-height: 1.4; }
.status { display: flex; align-items: center; gap: 7px; font-size: var(--t-xs); margin-top: 4px; }
.sizes { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: var(--t-xs); color: var(--muted); }
.sizes li { display: inline-flex; align-items: center; gap: 5px; }

.empty { padding: 56px 0; }
.empty p { margin-bottom: 16px; color: var(--muted); max-width: 40ch; }

.foot { color: var(--muted); font-size: var(--t-xs); padding-top: 16px; padding-bottom: 32px; border-top: 1px solid var(--hair); }
.foot p { max-width: 70ch; }

/* ---------- Botón flotante de filtros (mobile) ---------- */
.fab {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30;
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 20px; border: 0; border-radius: 22px;
  background: var(--ink); color: #fff; font-weight: 500; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.fab-n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #fff; color: var(--ink); font-size: var(--t-xs); font-weight: 600; }
.fab-n[hidden] { display: none; }

/* ---------- Diálogos ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%; max-height: 92dvh;
  border-radius: 12px 12px 0 0; background: var(--paper); color: var(--ink);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.35); }
.dialog-inner { padding: 12px var(--gutter) 24px; overflow-y: auto; max-height: 92dvh; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dialog-head h2 { font-size: var(--t-l); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.dialog-head h2:focus { outline: none; }
.dialog-kicker { color: var(--muted); font-size: var(--t-xs); }
.detail { display: grid; gap: 20px; grid-template-areas: "well" "info" "campaign"; }
.detail > .well { grid-area: well; aspect-ratio: auto; min-height: 200px; margin: 0; }
.detail > .well img { height: auto; max-height: 360px; }
.detail .info { grid-area: info; display: grid; gap: 18px; align-content: start; }
.detail .campaign { grid-area: campaign; border-radius: var(--r); max-height: 240px; width: auto; }
.specs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 0; font-size: var(--t-s); }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; }
.size-table { width: 100%; border-collapse: collapse; }
.size-table th, .size-table td { text-align: left; padding: 8px 0; border-bottom: 1px solid var(--hair); }
.size-table th { font-weight: 500; color: var(--muted); font-size: var(--t-xs); }
.size-table td .status { font-size: var(--t-s); margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.btn-wa { display: inline-flex; align-items: center; height: 44px; padding: 0 20px; border-radius: var(--r); background: var(--ink); color: #fff; text-decoration: none; font-weight: 500; }
.btn-wa:hover { background: #000; }
.btn-copy { border: 0; background: none; padding: 8px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.btn-copy:hover { color: var(--ink); }
.sizes-guide { width: 100%; height: auto; }

/* ---------- Tablet ---------- */
@media (min-width: 640px) {
  :root { --gutter: 28px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px 20px; }
  .brand { font-size: var(--t-l); }
  .topbar { flex-direction: row; align-items: baseline; justify-content: space-between; gap: 16px; padding-top: 24px; }
  .freshness { text-align: right; }
  dialog.sheet { margin: auto; width: min(800px, calc(100% - 56px)); border-radius: 8px; }
  .dialog-inner { padding: 20px 28px 28px; }
  .detail { grid-template-columns: 1.15fr 1fr; grid-template-areas: "well info" "campaign info"; align-items: start; }
}

/* ---------- Escritorio ---------- */
@media (min-width: 1000px) {
  :root { --gutter: 40px; }
  .layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 48px; align-items: start; padding-top: 32px; }
  .filters {
    position: sticky; top: 24px; z-index: 1; transform: none; visibility: visible;
    max-height: calc(100vh - 48px); transition: none; background: transparent;
  }
  .filters-head, .filters-foot, .fab { display: none; }
  .filters-body { padding: 0 8px 24px 0; }
  .facet:first-child { padding-top: 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 36px 24px; }
  .group { padding-top: 36px; }
}

@media (min-width: 1200px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); gap: 56px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .filters, .filters.open { transition: none; }
}
