:root {
  --fondo: #f4f6f9; --panel: #ffffff; --texto: #16202c; --suave: #5b6878; --borde: #d8dee6;
  --marca: #0f2a4a; --acento: #1d6fd6; --resalte: #e8f0fc; --sombra: 0 6px 24px rgba(15, 42, 74, .12);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #10151c; --panel: #18202a; --texto: #e7edf4; --suave: #9aa8b8; --borde: #2c3846;
    --marca: #0b1d33; --acento: #5aa0ff; --resalte: #1f2d3f; --sombra: 0 6px 24px rgba(0, 0, 0, .45);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fondo); color: var(--texto); }
[hidden] { display: none !important; }
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.cabecera { position: sticky; top: 0; z-index: 5; background: var(--marca); color: #fff; padding: 12px 16px 10px; }
.cabecera h1 { margin: 0 0 8px; font-size: 1.05rem; font-weight: 600; letter-spacing: .02em; }
.buscador { position: relative; max-width: 760px; }
#q { width: 100%; font-size: 1.1rem; padding: 12px 14px; border: 0; border-radius: 10px; background: #fff; color: #16202c; }
#q:focus { outline: 3px solid var(--acento); }
.estado { margin: 6px 0 0; font-size: .85rem; opacity: .85; }

.resultados { position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 4px; list-style: none;
  background: var(--panel); color: var(--texto); border: 1px solid var(--borde); border-radius: 10px; box-shadow: var(--sombra);
  max-height: min(70vh, 560px); max-height: min(70dvh, 560px); overflow-y: auto; overscroll-behavior: contain; }
.resultados li { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 8px; cursor: pointer; min-height: 56px; }
.resultados li[aria-selected="true"], .resultados li:hover { background: var(--resalte); }
.resultados img, .resultados .vacia { width: 48px; height: 48px; flex: none; object-fit: contain; background: #fff; border-radius: 6px; border: 1px solid var(--borde); }
.resultados .vacia { display: grid; place-items: center; font-size: .7rem; color: #4f5b68; }
.resultados .txt { min-width: 0; }
.resultados .n { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resultados .s { font-size: .82rem; color: var(--suave); font-variant-numeric: tabular-nums; }
.resultados .mas { justify-content: center; min-height: 0; color: var(--suave); font-size: .85rem; cursor: default; }
.resultados .mas:hover { background: none; }

.ficha { max-width: 1100px; margin: 16px auto; padding: 0 16px 32px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) {
  .ficha { grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr); grid-template-areas: "foto datos" "tira datos"; align-items: start; }
  .principal { grid-area: foto; } .tira { grid-area: tira; } .datos { grid-area: datos; position: sticky; top: 130px; }
}
.principal { margin: 0; background: #fff; border-radius: 12px; border: 1px solid var(--borde); overflow: hidden; }
.principal a { display: block; }
.principal img { display: block; width: 100%; height: auto; max-height: 72vh; object-fit: contain; background: #fff; }
.principal figcaption { padding: 6px 12px; font-size: .82rem; color: #5b6878; border-top: 1px solid #e3e8ee; background: #fafbfc; }
.tira { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.tira:empty { display: none; }
.tira button { flex: none; padding: 0; border: 2px solid var(--borde); border-radius: 8px; background: #fff; cursor: pointer; overflow: hidden; }
.tira button[aria-pressed="true"] { border-color: var(--acento); }
.tira img { display: block; width: 72px; height: 72px; object-fit: contain; }

.datos { background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; padding: 16px; }
.datos h2:focus { outline: none; }
.datos h2 { margin: 2px 0 6px; font-size: 1.25rem; line-height: 1.25; overflow-wrap: anywhere; }
.sku { margin: 0; color: var(--suave); }
.sku strong { color: var(--texto); font-size: 1.15rem; font-variant-numeric: tabular-nums; user-select: all; }
.categoria { margin: 0 0 14px; color: var(--suave); font-size: .9rem; }
.categoria:empty { display: none; }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; }
.acciones button, .boton { font: inherit; font-size: .95rem; padding: 10px 14px; min-height: 44px; border-radius: 9px; border: 1px solid var(--borde);
  background: var(--panel); color: var(--texto); text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; }
#copiar { background: var(--acento); border-color: var(--acento); color: #fff; }
.boton[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.sin-foto { color: var(--suave); }

.aviso { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); margin: 0; padding: 10px 16px; border-radius: 999px;
  background: #16202c; color: #fff; font-size: .9rem; box-shadow: var(--sombra); }
