/* Base común con la demo de back office (mismo sistema visual).
   En control de calidad: ámbar = la etiqueta y lo que baja de grado; petróleo = lo que sube. */
:root {
  --paper: #f5f7f9;
  --surface: #ffffff;
  --ink: #16212c;
  --muted: #586472;
  --line: #d8dee6;
  --side: #10323a;
  --consignor: #0c5b66;
  --consignor-soft: #9ccdd3;
  --shop: #e9a70d;
  --shop-soft: #f8dc8e;
  --shop-ink: #7a5200;
  --ok: #1d7a4c;
  --danger: #b3261e;
  --radius: 6px;
  --font: Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', source-sans-pro, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.45;
}
h1, h2, h3, p, dl, dd, ul { margin: 0; }
h1 { font-size: 1.7rem; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.6rem; }
h3 { font-size: 0.95rem; font-weight: 700; margin: 1.1rem 0 0.4rem; }
a { color: var(--consignor); text-underline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.875rem; }
:focus-visible { outline: 3px solid var(--shop); outline-offset: 2px; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: #fff; padding: 1.25rem 1rem; }
.brand { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1.75rem; }
.brand-mark {
  width: 1.7rem; height: 1.1rem; flex: none;
  background: radial-gradient(circle at 0.42rem 50%, var(--side) 0.13rem, transparent 0.15rem), var(--shop);
  clip-path: polygon(0.45rem 0, 100% 0, 100% 100%, 0.45rem 100%, 0 50%);
}
.brand-name { font-weight: 700; line-height: 1.2; }
.brand-badge { font-size: 0.8rem; color: var(--consignor-soft); }
.nav { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.nav a {
  color: #dbe8ea; text-decoration: none; padding: 0.5rem 0.65rem; border-radius: var(--radius);
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255, 255, 255, 0.08); }
.nav a[aria-current='page'] { background: rgba(255, 255, 255, 0.12); color: #fff; border-left-color: var(--shop); font-weight: 700; }
.main { padding: 2rem 2.25rem 4rem; max-width: 68rem; width: 100%; }
.main > section { margin-top: 2rem; }
.page-head, .section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.section-head { align-items: center; margin-bottom: 0.6rem; }
.section-head h2 { margin: 0; }
.page-meta { margin-top: 0.35rem; color: var(--muted); }
.back { display: inline-block; margin-bottom: 0.75rem; font-size: 0.9rem; }
.back::before { content: '‹ '; }
.narrow { max-width: 34rem; }

/* ---------- Demo: franja de contexto y recorrido ---------- */
.strip {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem 1.5rem; flex-wrap: wrap;
  margin: -0.75rem 0 1.5rem; padding-bottom: 0.7rem; border-bottom: 1px solid var(--line); font-size: 0.875rem; color: var(--muted);
}
.strip-links { display: inline-flex; gap: 1.1rem; white-space: nowrap; }
.strip-contact { font-weight: 700; }
.coach {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.1rem; padding: 0.7rem 0.9rem;
  background: #fff6da; border-left: 4px solid var(--shop); border-radius: var(--radius); font-weight: 600;
}
.coach-done { background: #e6f3ec; border-left-color: var(--ok); }
.coach span { flex: 1 1 16rem; }
.tour { margin-top: 1.25rem; padding: 1.1rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--shop); border-radius: var(--radius); }
.tour .section-head { align-items: flex-start; }
.tour .section-head h2 { margin-bottom: 0.15rem; }
.tour-steps { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; }
.tour-step { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.7rem; align-items: start; padding: 0.8rem 0.9rem; background: var(--paper); border-radius: var(--radius); }
.tour-step > div { display: flex; flex-direction: column; }
.tour-step .btn { grid-column: 2; justify-self: start; margin-top: 0.3rem; }
.tour-num { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 700; font-size: 0.9rem; }
.tour-step.is-done .tour-num { background: var(--ok); }
.tour-cta { margin-top: 0.9rem; }
.tour + .totals { margin-top: 1.5rem; }

/* ---------- Superficies ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.main > .panel { margin-top: 1.5rem; }
.empty { color: var(--muted); padding: 0.9rem 0; }
.notice {
  background: #e6f3ec; color: #12512f; border-left: 4px solid var(--ok);
  padding: 0.55rem 0.8rem; border-radius: var(--radius); margin-bottom: 1.1rem;
}
.notes { margin-top: 0.9rem; padding-left: 0.7rem; border-left: 3px solid var(--line); color: var(--muted); }

/* ---------- Botones y formularios ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; color: var(--ink);
  background: var(--surface); border: 1px solid #b9c2cd; border-radius: var(--radius);
  padding: 0.42rem 0.85rem; min-height: 2.4rem;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--consignor); border-color: var(--consignor); color: #fff; }
.btn-primary:hover { background: #094a53; border-color: #094a53; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--consignor); }
.btn-quiet:hover { border-color: var(--line); }
label { display: block; font-weight: 600; font-size: 0.9rem; margin-top: 0.85rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: 0.3rem; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid #b9c2cd; border-radius: var(--radius); padding: 0.45rem 0.6rem; min-height: 2.4rem;
}
input[type='range'] { padding: 0; border: 0; min-height: 1.8rem; accent-color: var(--shop); background: transparent; }
.input-suffix { display: flex; align-items: center; gap: 0.4rem; max-width: 8rem; }
.input-suffix span { margin-top: 0.3rem; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid { align-items: end; }
form.panel { margin-bottom: 1rem; }
.form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1.1rem; }
.form-error { color: var(--danger); font-weight: 600; margin-top: 0.8rem; }
.filters { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; margin: 1.25rem 0 0.9rem; }
.filters label { margin-top: 0; }
.filters .grow { flex: 1 1 16rem; }

/* ---------- Pestañas y paginación ---------- */
.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-top: 1.25rem; border-bottom: 1px solid var(--line); }
.tab {
  font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); background: transparent;
  border: 0; border-bottom: 3px solid transparent; padding: 0.5rem 0.8rem; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--consignor); }
.tab-count { display: inline-block; min-width: 1.5rem; text-align: center; font-size: 0.8rem; padding: 0.05rem 0.4rem; border-radius: 999px; background: #e8eef4; color: #2c3e50; margin-left: 0.2rem; }
.tab-alert .tab-count { background: var(--shop-soft); color: var(--shop-ink); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; margin-top: 0.7rem; }
.pager .muted { margin-right: 0.4rem; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:disabled:hover { border-color: #b9c2cd; }
.ref { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub { color: var(--muted); font-size: 0.82rem; }
.totals + section { margin-top: 1.5rem; }
.page-head + .totals { margin-top: 1.25rem; }

/* ---------- Tablas ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table th, .table td { padding: 0.6rem 0.8rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table th { font-size: 0.8rem; font-weight: 600; color: var(--muted); white-space: nowrap; background: #fafbfc; }
.table tbody tr:hover td { background: #fafcfd; }
.table th.num, .table td.num { text-align: right; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.row-link { font-weight: 700; }
.cell-item { display: flex; align-items: center; gap: 0.7rem; }
.table-items .cell-item, .table-due .cell-item { min-width: 13rem; }
.table-items th { white-space: normal; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions .btn + .btn { margin-left: 0.25rem; }
.item-name { font-weight: 600; }
/* Un botón que se lee como un enlace: abre la ficha del artículo. */
.link { font: inherit; color: inherit; background: none; border: 0; padding: 0; min-height: 0; cursor: pointer; text-align: left; }
.link.item-name { font-weight: 600; }
.link:hover { color: var(--consignor); text-decoration: underline; text-underline-offset: 2px; }
.ends { display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.item-skus { margin-top: 0.15rem; font-size: 0.85rem; }
.item-lot { font-size: 0.85rem; }
.cat {
  width: 2.3rem; height: 2.3rem; flex: none; padding: 0.4rem; border-radius: var(--radius);
  background: var(--paper); border: 1px solid var(--line);
  fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}

.photo { padding: 0; object-fit: cover; stroke: none; background: var(--surface); }
.photo-large { display: block; width: 100%; max-width: 16rem; height: auto; max-height: 16rem; object-fit: contain; margin: 0.8rem 0 0.2rem; }
.photo-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.8rem; }
.btn-file { display: inline-flex; align-items: center; margin-top: 0; font-size: 1rem; }
.btn-file:focus-within { outline: 3px solid var(--shop); outline-offset: 2px; }
.file-hidden { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; opacity: 0; overflow: hidden; }
.head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.panel-title { margin: 0 0 0.3rem; font-size: 1.05rem; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
input[type='file'] { padding: 0.35rem; }
textarea { font-family: ui-monospace, 'Cascadia Mono', Menlo, Consolas, monospace; font-size: 0.85rem; white-space: pre; overflow-x: auto; }
textarea[name='notes'] { font: inherit; white-space: normal; }
#import-preview { margin-top: 1rem; }
.table-import td { vertical-align: top; }
.row-error td { background: #fdf1f0; }
.row-error td:last-child { color: var(--danger); font-weight: 600; }
.import-summary { margin-top: 0.8rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.row-problem { color: var(--danger); font-weight: 600; }

/* La referencia propia, con forma de etiqueta colgante. */
.sku {
  display: inline-block; font-size: 0.8rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--shop-ink);
  background: radial-gradient(circle at 0.5rem 50%, var(--surface) 0.12rem, transparent 0.14rem), var(--shop-soft);
  padding: 0.05rem 0.45rem 0.05rem 0.95rem;
  clip-path: polygon(0.4rem 0, 100% 0, 100% 100%, 0.4rem 100%, 0 50%);
}

.badge { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.badge-on_sale { background: #e8eef4; color: #2c3e50; }
.badge-sold { background: #e6f3ec; color: #12512f; }
.badge-paid { background: #dcebed; color: #0a4a53; }
.badge-returned, .badge-closed { background: #eceff2; color: var(--muted); }
.badge-ended { background: var(--shop-soft); color: var(--shop-ink); }
.badge-time { background: #e8eef4; color: #2c3e50; }
.page-meta .badge { margin-left: 0.5rem; }

/* ---------- Condiciones y reparto ---------- */
.terms { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 2rem; align-items: start; }
.terms label:first-child { margin-top: 0; }
.fee-fixed { font-size: 1.3rem; font-weight: 700; margin-top: 0.2rem; }
.share-labels { display: flex; justify-content: space-between; font-size: 0.875rem; font-weight: 700; }
.who-consignor { color: var(--consignor); }
.who-shop { color: var(--shop-ink); }

.split { margin-top: 0.6rem; }
.split-bar { display: flex; height: 1.15rem; border-radius: 3px; overflow: hidden; background: var(--line); }
.seg { flex-basis: 0; min-width: 0; transition: flex-grow 160ms ease-out; }
.seg-min { background: var(--consignor); }
.seg-cx { background: var(--consignor-soft); }
.seg-sx { background: var(--shop-soft); }
.seg-fee { background: var(--shop); }
.split-sides { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.55rem; }
.split-sides > div { display: flex; flex-direction: column; }
.split-right { text-align: right; align-items: flex-end; }
.split-who { font-size: 0.82rem; font-weight: 700; }
.split-sides strong { font-size: 1.35rem; line-height: 1.2; }
.split-sides small { color: var(--muted); font-size: 0.8rem; }

.totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 0.9rem; }
.totals > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; }
.totals dt { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.totals dt.who-consignor { color: var(--consignor); }
.totals dt.who-shop { color: var(--shop-ink); }
.totals dd { font-size: 1.5rem; font-weight: 700; line-height: 1.25; }
#lot-account > .muted { margin-top: 0.6rem; }

.totals-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.section-head h2 .tab-count { vertical-align: middle; }
.count-alert { background: var(--shop-soft); color: var(--shop-ink); }
.due { color: var(--shop-ink); font-weight: 700; }
.more { margin-top: 0.6rem; color: var(--muted); }
.early { margin-top: 0.6rem; padding: 0.5rem 0.7rem; background: #fff6da; border-left: 4px solid var(--shop); border-radius: var(--radius); }
.big { font-size: 1.4rem; font-weight: 700; }
.listings { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 0.15rem; }
.listings .due { font-size: 0.82rem; }
.listings .badge { margin-bottom: 0.1rem; }
.listings > span { white-space: nowrap; }
.pick { flex: none; width: 1.1rem; height: 1.1rem; min-height: 0; margin: 0; padding: 0; display: inline-block; accent-color: var(--consignor); }
.th-pick { display: inline-flex; align-items: center; gap: 0.7rem; }
.bulk {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.6rem; padding: 0.55rem 0.8rem;
  background: #e3f0f1; border: 1px solid var(--consignor-soft); border-radius: var(--radius); position: sticky; top: 0.5rem; z-index: 1;
}
.bulk[hidden] { display: none; }
.bulk strong { margin-right: 0.3rem; }
.bulk select { width: auto; margin-top: 0; }
.bulk .btn-quiet { margin-left: auto; }

/* ---------- Línea de tiempo del acuerdo ---------- */
.timeline { margin-top: 1.25rem; }
.tl-bar { position: relative; display: flex; gap: 2px; }
.tl-seg {
  flex-basis: 0; min-width: 0; padding: 0.35rem 0.6rem; font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line);
}
.tl-seg:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.tl-seg:nth-last-child(2) { border-radius: 0 var(--radius) var(--radius) 0; }
.tl-seg.is-past { background: #e6ebf0; border-color: #e6ebf0; }
.tl-seg.is-now { background: var(--consignor); border-color: var(--consignor); color: #fff; }
.tl-mark { position: absolute; top: -0.35rem; bottom: -0.35rem; width: 3px; margin-left: -1.5px; background: var(--shop); border-radius: 2px; }
.tl-mark::before { content: ''; position: absolute; top: -0.25rem; left: 50%; width: 0.6rem; height: 0.6rem; margin-left: -0.3rem; border-radius: 50%; background: var(--shop); }
.tl-ends { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.45rem; font-size: 0.85rem; color: var(--muted); }
.tl-ends strong { color: var(--ink); }

/* ---------- Bloques plegables ---------- */
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '+'; display: inline-block; width: 1.1rem; font-weight: 700; color: var(--consignor); }
details[open] > summary::before { content: '–'; }
.terms-box { margin-top: 0.9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.terms-box > summary { padding: 0.65rem 0.9rem; color: var(--muted); }
.terms-box > summary strong { color: var(--ink); margin-right: 0.3rem; }
.terms-box > .terms { padding: 0.4rem 1.1rem 1.1rem; border-top: 1px solid var(--line); }
.history-box { margin-top: 0.4rem; border-top: 1px solid var(--line); }
.history-box > summary { padding: 0.6rem 0; font-weight: 600; }
.lot-money > .muted, #lot-account > .muted { margin-top: 0.5rem; }
.dialog-head { align-items: flex-start; }
.dialog-head .cat { width: 3.2rem; height: 3.2rem; }
.dialog-foot { align-items: center; border-top: 1px solid var(--line); padding-top: 0.9rem; }
.push-right { margin-left: auto; }

.listings-form { margin-top: 0.9rem; padding: 0.2rem 0.9rem 0.9rem; background: var(--paper); border-radius: var(--radius); }
.listings-form h3 { margin-top: 0.7rem; }
.listings-form .form-actions { margin-top: 0.7rem; }
.listing-row { display: grid; grid-template-columns: minmax(0, 1fr) 9rem; align-items: center; gap: 0.75rem; padding: 0.3rem 0; }
.listing-row input:not([type='checkbox']) { margin-top: 0; }
.check { display: flex; align-items: center; gap: 0.5rem; margin-top: 0; font-weight: 600; }
.check input { width: 1.1rem; height: 1.1rem; min-height: 0; margin: 0; flex: none; accent-color: var(--consignor); }
.fixed { padding: 0.45rem 0.6rem; color: var(--muted); }

/* ---------- Documentos ---------- */
.doc-tools { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.doc-tools .back { margin: 0; }
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2.25rem 2.5rem; max-width: 52rem; overflow-x: auto; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 2px solid var(--ink); padding-bottom: 1rem; }
.doc-shop { font-weight: 700; color: var(--muted); }
.doc-ref { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.doc-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem 2rem; margin: 1.25rem 0 0.5rem; }
.doc-facts dt { font-size: 0.8rem; color: var(--muted); }
.doc h2 { margin: 1.6rem 0 0.5rem; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.doc-table th, .doc-table td { text-align: left; padding: 0.4rem 0.5rem 0.4rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-table th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.doc-table .num { text-align: right; padding-right: 0; white-space: nowrap; }
.doc-table tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); }
.doc-empty { color: var(--muted); }
.doc-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 1.75rem; padding: 0.9rem 1.1rem; background: #e3f0f1; border-radius: var(--radius); font-weight: 700; }
.doc-total strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; color: var(--consignor); }
.doc-note { margin-top: 1rem; font-size: 0.82rem; color: var(--muted); }

/* ---------- Diálogos ---------- */
dialog {
  border: 0; border-radius: 10px; padding: 1.5rem; width: min(34rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem);
  color: var(--ink); box-shadow: 0 18px 50px rgba(16, 50, 58, 0.28);
}
dialog::backdrop { background: rgba(16, 50, 58, 0.45); }
dialog h2 { font-size: 1.25rem; margin-bottom: 0.4rem; }
dialog .cell-item { margin: 0.5rem 0 0.2rem; }
dialog .cell-item h2 { margin-bottom: 0.2rem; }
[data-out='new-lot-example'], [data-out='sell-preview'] { margin-top: 0.9rem; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 1rem; margin: 1rem 0 0.6rem; }
.facts dt { font-size: 0.8rem; color: var(--muted); }
.history { list-style: none; padding: 0; }
.history li { padding: 0.3rem 0; border-top: 1px solid var(--line); font-size: 0.92rem; }
.history li span { display: inline-block; min-width: 6.5rem; }
.history li:first-child { border-top: 0; }

/* ---------- Pantallas medianas ---------- */
@media (max-width: 72rem) {
  .totals-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell { grid-template-columns: 10.5rem minmax(0, 1fr); }
  .main { padding: 1.5rem 1.25rem 3rem; }
  .table th, .table td { padding: 0.55rem 0.5rem; }
  .cell-actions .btn { padding: 0.35rem 0.6rem; }
}

/* ---------- Pantallas estrechas ---------- */
@media (max-width: 58rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: flex; align-items: center; gap: 1rem; padding: 0.6rem 0.9rem; position: sticky; top: 0; z-index: 2; }
  .brand { margin: 0; }
  .brand-badge { display: none; }
  .nav { flex-direction: row; overflow-x: auto; margin-left: auto; }
  .nav a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; padding: 0.4rem 0.55rem; }
  .nav a[aria-current='page'] { border-bottom-color: var(--shop); }
  .main { padding: 1.25rem 0.9rem 3rem; }
  h1 { font-size: 1.4rem; }
  .terms { grid-template-columns: 1fr; gap: 1.25rem; }
  .totals { grid-template-columns: 1fr; gap: 0.5rem; }
  .tour-steps { grid-template-columns: 1fr; }
  .strip { margin-top: -0.25rem; }
  .totals-4 { grid-template-columns: 1fr; }
  .doc { padding: 1.25rem 1rem; }
  .doc-facts { grid-template-columns: 1fr; }
  .doc-table { font-size: 0.82rem; }
  .totals > div { display: flex; justify-content: space-between; align-items: baseline; }
  .totals dd { font-size: 1.2rem; }
  .form-grid { grid-template-columns: 1fr; }

  /* Cada fila de tabla pasa a ser una ficha. */
  .table, .table tbody, .table tr, .table td { display: block; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table { background: transparent; border: 0; }
  .table tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.8rem; margin-bottom: 0.6rem; }
  .table td, .table td.num { border: 0; padding: 0.2rem 0; text-align: right; white-space: normal; display: flex; justify-content: space-between; gap: 1rem; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 0.85rem; text-align: left; flex: none; }
  .table td.cell-first { display: block; text-align: left; padding-bottom: 0.4rem; }
  .table td.cell-ref { justify-content: flex-start; font-size: 1.05rem; padding-bottom: 0.3rem; }
  .tl-seg { padding: 0.3rem 0.4rem; font-size: 0.75rem; }
  .tl-ends { font-size: 0.8rem; }
  .bulk .btn-quiet { margin-left: 0; }
  .table tbody tr:hover td { background: transparent; }
  .table td .sub { text-align: right; }
  .table td.cell-actions { justify-content: flex-end; padding-top: 0.45rem; }
  .table td:empty { display: none; }
}

@media print {
  .side, .no-print, .notice, dialog { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; }
  .doc { border: 0; padding: 0; max-width: none; }
  .doc-total { background: none; border: 2px solid #000; }
}

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

/* ---------- Control de calidad ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.nav-count { display: inline-block; min-width: 1.3rem; text-align: center; font-size: 0.75rem; font-weight: 700; padding: 0 0.35rem; margin-left: 0.25rem; border-radius: 999px; background: var(--shop); color: var(--side); }
.grade { display: inline-grid; place-items: center; min-width: 2.1rem; height: 1.6rem; padding: 0 0.35rem; border-radius: var(--radius); background: #e8eef4; color: var(--ink); font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.move { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.move-down .grade:last-child { background: var(--shop-soft); color: var(--shop-ink); }
.move-up .grade:last-child { background: var(--consignor-soft); color: #0a4a53; }
span.move-down { color: var(--shop-ink); font-weight: 700; }
span.move-up { color: var(--consignor); font-weight: 700; }
.move.move-down, .move.move-up { color: var(--muted); font-weight: 400; }
.rate { display: inline-flex; align-items: center; gap: 0.6rem; width: 100%; min-width: 9rem; }
.rate-bar { flex: 1; height: 0.55rem; border-radius: 999px; background: #e8eef4; overflow: hidden; }
.rate-bar > span { display: block; height: 100%; background: var(--shop); border-radius: 999px; }
.rate .num { width: 3rem; text-align: right; font-weight: 700; }
.cell-rate { width: 40%; }
.table-watch .cell-rate { width: 55%; }
.totals dd small { font-size: 0.95rem; color: var(--muted); font-weight: 600; margin-left: 0.25rem; }

/* Escanear */
.scan label { margin-top: 0; }
.scan-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.scan-row input { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.03em; max-width: 18rem; }
.scan .hint { margin-top: 0.45rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-top: 0.45rem; }
.chip { font: inherit; font-size: 0.85rem; cursor: pointer; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 0.15rem 0.65rem; text-decoration: none; min-height: 0; }
.chip:hover { border-color: var(--ink); }
.notice-error { background: #fdf1f0; color: var(--danger); border-left-color: var(--danger); margin-top: 1rem; }
.notice-soft { background: #eef3f7; color: var(--ink); border-left-color: #9fb3c4; }

/* Ficha del artículo y formulario */
.main > .panel.inspect { margin-top: 1rem; }
.inspect-item { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.cat-large { width: 6rem; height: 6rem; padding: 1rem; }
.inspect-title { margin: 0.35rem 0 0.1rem; font-size: 1.25rem; }
.facts { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; margin-top: 0.6rem; font-size: 0.9rem; }
.facts dt { color: var(--muted); font-size: 0.8rem; }
.facts dd { font-weight: 600; }
.tagged { background: #fff6da; border-left: 4px solid var(--shop); border-radius: var(--radius); padding: 0.7rem 0.9rem; font-size: 0.92rem; }
.tagged h3 { margin: 0 0 0.35rem; }
.tagged p + p { margin-top: 0.3rem; }
.inspect .notice { margin: 1rem 0 0; }
.inspect-form { margin-top: 1.1rem; border-top: 1px solid var(--line); padding-top: 0.4rem; }
.grade-picker { border: 0; margin: 0.6rem 0 0; padding: 0; min-width: 0; }
.grade-picker legend { font-weight: 700; padding: 0; margin-bottom: 0.45rem; }
.grade-options { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0.4rem; }
.grade-option { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 0.1rem; padding: 0.5rem 0.2rem; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: center; font-weight: 400; }
.grade-option input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; margin: 0; }
.grade-letter { font-size: 1.15rem; font-weight: 700; }
.grade-name { font-size: 0.72rem; color: var(--muted); line-height: 1.15; }
.grade-option:hover { border-color: var(--ink); }
.grade-option.is-tag { border-style: dashed; border-color: var(--shop); }
.grade-option:has(input:checked) { background: var(--consignor); border-color: var(--consignor); border-style: solid; color: #fff; }
.grade-option:has(input:checked) .grade-name { color: #dbe8ea; }
.grade-option:has(input:focus-visible) { outline: 3px solid var(--shop); outline-offset: 2px; }
.inspect-form textarea { font: inherit; white-space: normal; }
/* Las columnas del formulario empiezan a la misma altura aunque una tenga más frases rápidas. */
.inspect-form .form-grid { align-items: start; }
.cell-notes { max-width: 20rem; font-size: 0.9rem; }

/* Estadísticas */
.tabs + .totals { margin-top: 1.25rem; }
.table-stats th:first-child { width: 28%; }
.stats-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; margin-top: 2rem; }
.stats-pair > section { margin: 0; }
.table-matrix th, .table-matrix td { text-align: center; padding: 0.45rem 0.3rem; }
.heat-1 { background: #fff1c9; }
.heat-2 { background: #fbdf95; }
.heat-3 { background: #f6c65a; }
.heat-4 { background: #e9a70d; color: #fff; }
.heat-same { box-shadow: inset 0 0 0 2px var(--consignor-soft); }
.heat-same.heat-1, .heat-same.heat-2, .heat-same.heat-3, .heat-same.heat-4 { background: #dcebed; color: var(--ink); }
.weeks { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0.5rem; align-items: end; height: 11rem; padding: 0.5rem 0 0; }
.week { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 0.3rem; height: 100%; }
.week-bar { width: 100%; max-width: 2.6rem; background: var(--consignor-soft); border-radius: 4px 4px 0 0; display: flex; align-items: flex-end; min-height: 2px; }
.week-bar > span { display: block; width: 100%; background: var(--shop); border-radius: 4px 4px 0 0; }
.week .sub { font-size: 0.72rem; white-space: nowrap; }
.real-list { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.real-list li + li { margin-top: 0.3rem; }
.main > .panel.narrow + .panel.narrow { margin-top: 1rem; }
.dialog-body { max-width: 26rem; }

@media (max-width: 72rem) {
  .inspect-item { grid-template-columns: auto minmax(0, 1fr); }
  .tagged { grid-column: 1 / -1; }
  .stats-pair { grid-template-columns: 1fr; }
}
.dir { white-space: nowrap; }
@media (max-width: 58rem) {
  .nav-count { margin-left: 0.15rem; }
  .brand-name { white-space: nowrap; font-size: 0.9rem; }
  .grade-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cat-large { width: 4.2rem; height: 4.2rem; padding: 0.7rem; }
  .scan-row input { max-width: none; }
  .rate { min-width: 0; max-width: 12rem; }
  .cell-rate, .table-watch .cell-rate { width: auto; }
  .cell-notes { max-width: none; text-align: right; }
  /* La matriz sigue siendo una cuadrícula, con desplazamiento si no cabe. */
  .table.table-matrix { display: table; border: 1px solid var(--line); background: var(--surface); }
  .table-matrix thead { position: static; width: auto; height: auto; overflow: visible; clip-path: none; display: table-header-group; }
  .table-matrix tbody { display: table-row-group; }
  .table-matrix tr { display: table-row; padding: 0; margin: 0; border: 0; border-radius: 0; background: transparent; }
  .table-matrix td, .table-matrix th, .table-matrix td.num { display: table-cell; text-align: center; padding: 0.4rem 0.2rem; border-bottom: 1px solid var(--line); }
  .weeks { height: 9rem; gap: 0.25rem; }
}
@media (max-width: 30rem) {
  .brand > div { display: none; }
}
