/* ==========================================================================
   Páginas COA por producto (coa-*.html) — destino de los QR de las etiquetas.
   Generadas por scripts/build_coa_qr.py. Cada página define --c / --c2
   (color de la etiqueta del producto) en <body style="...">.
   ========================================================================== */
:root {
  --ink: #0b1f33;
  --ink2: #3b5166;
  --muted: #6a7e91;
  --line: #e2e8ee;
  --bg: #f3f6f9;
  --ok: #128a5b;
  --ok-bg: #e9f7f0;
  --ok-line: #bfe5d1;
  --warn: #9a5a00;
  --warn-bg: #fff5e3;
  --warn-line: #f2d6a2;
  --c: #0f7095;
  --c2: #0b3c5d;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }
.i { width: 1.15em; height: 1.15em; flex: none; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px; }
.print-only { display: none; }

/* ---------- Barra superior ---------- */
.top { background: #fff; border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.top .logo img { height: 40px; width: auto; }
.top .site {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600; color: var(--ink2); text-decoration: none;
}
.top .site:hover { color: var(--c2); }

/* ---------- Gemelo de la etiqueta ---------- */
.hero { padding: 26px 0 6px; }
.kicker {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 12px; font-size: 12.5px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--c2);
}
.label {
  position: relative; overflow: hidden;
  background: #fff; border: 1px solid var(--line); border-radius: 22px;
  padding: 22px 22px 32px;
  box-shadow: 0 22px 44px -28px rgba(11, 31, 51, .45);
}
.label::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 10px;
  background: linear-gradient(90deg, var(--c2), var(--c));
}
.label .mol { position: absolute; right: -18px; top: -14px; width: 190px; color: var(--c2); opacity: .07; pointer-events: none; }
.label .brand { font-weight: 800; font-size: 16px; letter-spacing: .01em; line-height: 1; }
.label .brand sup { font-size: 9px; }
.label .brand small { display: block; margin-top: 4px; font-size: 10px; font-weight: 500; letter-spacing: .4em; }
/* --n = número de caracteres del nombre: el tamaño se ajusta para que quepa en una línea. */
.label h1 {
  margin: 14px 0 4px;
  font-size: clamp(30px, calc((100vw - 84px) / (var(--n, 8) * .74)), 80px);
  font-weight: 900; line-height: .95; letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.label .sub { margin: 4px 0 0; font-size: 11.5px; letter-spacing: .3em; text-transform: uppercase; color: var(--ink2); }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 16px; }
.dose {
  display: inline-block; transform: skewX(-12deg);
  padding: 3px 18px; border-radius: 8px;
  background: linear-gradient(90deg, var(--c2), var(--c));
  color: #fff; font-size: 26px; font-weight: 800; line-height: 1.3;
}
.dose span { display: inline-block; transform: skewX(12deg); }
.chip { padding: 4px 14px; border: 1.5px solid #c7d1db; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--ink2); }
.ruo { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; line-height: 1.2; text-transform: uppercase; color: var(--ink2); }
.storage {
  display: flex; align-items: center; gap: 8px; margin-top: 16px;
  font-size: 14px; color: var(--ink2);
}
.storage strong { color: var(--ink); }

/* ---------- Estado ---------- */
.status {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 18px; border-radius: 16px;
  background: var(--ok-bg); border: 1px solid var(--ok-line); color: #0b4a32;
}
.status .badge { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--ok); color: #fff; flex: none; }
.status .badge .i { width: 22px; height: 22px; }
.status strong { display: block; font-size: 17px; line-height: 1.3; }
.status span { display: block; margin-top: 2px; font-size: 14.5px; color: #2a5e47; }
.status.pending { background: var(--warn-bg); border-color: var(--warn-line); color: #5f3700; }
.status.pending .badge { background: var(--warn); }
.status.pending span { color: #74501a; }

/* ---------- Layout ---------- */
.layout {
  display: grid; gap: 18px; padding-top: 18px; padding-bottom: 40px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "a" "r" "b";
}
.col-a { grid-area: a; display: grid; gap: 14px; align-content: start; }
.col-b { grid-area: b; display: grid; gap: 22px; align-content: start; }
.side { grid-area: r; }
@media (min-width: 920px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 420px;
    grid-template-rows: auto 1fr;
    grid-template-areas: "a r" "b r";
    column-gap: 28px;
  }
  .side { position: sticky; top: 20px; align-self: start; }
  .placeholder { aspect-ratio: 1600 / 2360; }
}
.sec-title { font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }

/* ---------- Resultados ---------- */
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px 16px 14px; min-width: 0; }
.metric:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
.metric .k { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.metric .v {
  margin-top: 4px; font-size: clamp(26px, 7vw, 34px); font-weight: 800; line-height: 1.1; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; color: var(--c2);
}
.metric .s { margin-top: 4px; font-size: 13.5px; color: var(--ink2); }
.metric.purity { background: linear-gradient(160deg, #fff 55%, var(--ok-bg)); }
.metric.purity .v { color: var(--ok); }

/* ---------- Botones ---------- */
.actions { display: grid; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 12px 16px; border-radius: 14px; border: 1.5px solid transparent;
  font: inherit; font-size: 16px; font-weight: 700; line-height: 1.2; text-align: center; text-decoration: none;
  cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--c); outline-offset: 2px; }
.btn.primary { background: var(--c2); color: #fff; box-shadow: 0 12px 26px -14px var(--c2); }
.btn.primary:hover { background: var(--ink); }
.btn.secondary { background: #fff; color: var(--ink); border-color: #cfd8e1; }
.btn.secondary:hover { border-color: var(--c2); color: var(--c2); }
.btn.wa { background: #1f9e55; color: #fff; }
.btn.wa:hover { background: #178446; }
.btn small { display: block; font-size: 12px; font-weight: 500; opacity: .8; }
.row2 .btn { gap: 8px; padding: 12px 10px; font-size: 15px; white-space: nowrap; }

/* ---------- Clave de verificación ---------- */
.keybox {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 18px; border-radius: 16px; background: var(--ink); color: #fff;
}
.keybox .k { font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #9fb6c6; }
.keybox code {
  display: block; margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(19px, 5.4vw, 24px); font-weight: 700; letter-spacing: .1em;
}
.keybox button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, .25); border-radius: 12px; background: rgba(255, 255, 255, .08);
  color: #fff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.keybox button:hover { background: rgba(255, 255, 255, .16); }
.keynote { margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.keynote a { color: var(--c2); font-weight: 600; }

/* ---------- Pasos ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: s; }
.steps li { display: flex; gap: 12px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; font-size: 15px; }
.steps li::before {
  counter-increment: s; content: counter(s);
  display: grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 50%; background: var(--c2); color: #fff; font-size: 14px; font-weight: 800;
}
.steps b { display: block; }
.steps span { color: var(--ink2); font-size: 14px; }

/* ---------- Ficha ---------- */
.facts { margin: 0; padding: 2px 16px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 15px; }
.facts div:first-child { border-top: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- Informe original ---------- */
.report { margin: 0; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 18px; }
.report a { position: relative; display: block; overflow: hidden; border-radius: 10px; border: 1px solid var(--line); }
.report img { width: 100%; height: auto; }
.report .zoom {
  position: absolute; right: 10px; bottom: 10px;
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  background: rgba(11, 31, 51, .86); color: #fff; font-size: 13px; font-weight: 600;
}
.report figcaption { display: flex; justify-content: space-between; gap: 10px; padding: 10px 4px 2px; font-size: 13px; color: var(--muted); }
.report figcaption b { color: var(--ink); }

/* ---------- Pendiente ---------- */
.pending-card { padding: 20px; background: #fff; border: 1px dashed #d4c29e; border-radius: 18px; }
.pending-card h2 { font-size: 20px; }
.pending-card p { margin-top: 6px; color: var(--ink2); }
.pending-card ul { margin: 12px 0 0; padding-left: 20px; color: var(--ink2); font-size: 15px; }
.pending-card li + li { margin-top: 4px; }
.placeholder {
  display: grid; place-items: center; gap: 10px; min-height: 220px; padding: 24px;
  border-radius: 10px; border: 1px dashed #cfd8e1; text-align: center; color: var(--muted);
  background: repeating-linear-gradient(135deg, #fafbfc 0 14px, #f4f6f8 14px 28px);
}
.placeholder .i { width: 40px; height: 40px; color: #b3c0cc; }
.placeholder b { display: block; color: var(--ink2); font-size: 16px; }

/* ---------- Enlaces ---------- */
.links { display: grid; gap: 10px; }
.links a, .links button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  font: inherit; font-weight: 700; color: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.links a:hover, .links button:hover { border-color: var(--c2); color: var(--c2); }
.links .arrow { margin-left: auto; color: var(--muted); }

.disclaimer { display: flex; gap: 10px; font-size: 13px; line-height: 1.55; color: var(--muted); }
.disclaimer .i { margin-top: 2px; }

/* ---------- Pie ---------- */
.foot { padding: 26px 0 34px; background: #fff; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.foot .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.foot img { height: 30px; width: auto; }
.foot a { color: var(--ink2); font-weight: 600; text-decoration: none; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }

/* ---------- Aviso flotante ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 50; transform: translate(-50%, 20px);
  padding: 11px 18px; border-radius: 12px; background: var(--ink); color: #fff;
  font-size: 14.5px; font-weight: 600; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .4);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* ---------- Imprimir / Guardar como PDF ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .top, .actions, .links, .steps-sec, .toast, .no-print, .report .zoom { display: none !important; }
  .print-only { display: block; }
  .wrap { max-width: none; padding: 0; }
  .hero { padding: 0; }
  .label { box-shadow: none; padding: 14px 16px 22px; }
  .label h1 { font-size: 40px; }
  .label::after, .dose, .status, .status .badge, .metric.purity { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Página 1: resumen completo · Página 2: informe original del laboratorio */
  .layout { display: flex; flex-direction: column; gap: 0; padding: 8px 0 0; }
  .col-a { order: 1; } .col-b { order: 2; } .side { order: 3; break-before: page; }
  .col-a, .col-b { display: block; }
  .col-a > *, .col-b > * { margin-bottom: 8px; }
  .sec-title { margin-bottom: 6px; }
  .metric { padding: 10px 14px; }
  .metric .v { font-size: 22px; }
  .facts div { padding: 6px 0; font-size: 12px; }
  .keybox { padding: 10px 14px; background: #fff; color: var(--ink); border: 1px solid var(--line); }
  .keybox .k { color: var(--muted); }
  .keybox button, .keynote { display: none; }
  .storage { margin-top: 8px; }
  .report { border: 0; padding: 0; }
  .report a { border: 0; }
  .report img { width: auto; max-width: 100%; max-height: 262mm; margin: 0 auto; }
  .foot { display: none; }
  .print-only { font-size: 10.5px; color: var(--muted); }
}
