/* Inventario — hoja de estilos.
   Sistema "Paper UI": papel cálido, Georgia solo para títulos y números grandes,
   un único acento azul marino, líneas finas en lugar de sombras, tonos pastel con significado.
   Todo color sale de los tokens de :root y [data-theme="dark"]. */

:root {
  color-scheme: light;
  --ink: #22231f;
  --muted: #6d6f67;
  --faint: #85867e;
  --paper: #f5f4ef;
  --surface: #fff;
  --glass: #fffdfcf2;
  --fill: #faf9f6;
  --fill2: #f3f2ed;
  --chip: #eeede8;
  --sel: #f0f4f8;
  --line: #deddd5;
  --line-soft: #ebeae5;
  --track: #dad9d3;
  --navy: #202940;
  --accent-ink: #fff;
  --accent2: #275e8d;
  --brand-ink: #fff0ad;
  --ok: #35633a;
  --coral: #ffdfd4;
  --blue: #ddebfa;
  --yellow: #fff0ad;
  --green: #dcefdc;
  --tone-ink: #22231f;
  --warn-bg: #fff7d8;
  --warn-line: #dfc95d;
  --warn-ink: #806f22;
  --danger: #a3341f;       /* texto y borde de acciones destructivas */
  --scrim: #22231f73;
  --shadow: #00000026;
  --viewer: #0d0c0bf2;     /* fondo del visor de fotos */
  --print-ink: #000;       /* solo para etiquetas impresas */
  --print-paper: #fff;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #ece9e3;
  --muted: #a5a199;
  --faint: #8d8a83;
  --paper: #191817;
  --surface: #232220;
  --glass: #232220f2;
  --fill: #1e1d1b;
  --fill2: #2b2926;
  --chip: #34312b;
  --sel: #25303d;
  --line: #393630;
  --line-soft: #2f2d28;
  --track: #3d3a34;
  --navy: #89b0ef;
  --accent-ink: #12161d;
  --accent2: #89b0ef;
  --brand-ink: #1b2233;
  --ok: #7dc98b;
  --coral: #402b24;
  --blue: #233245;
  --yellow: #3d3520;
  --green: #26361f;
  --tone-ink: #ece9e3;
  --warn-bg: #3a3320;
  --warn-line: #6d5e2a;
  --warn-ink: #e0cd83;
  --danger: #f09a86;
  --scrim: #0d0c0bb3;
  --shadow: #00000073;
  --viewer: #0d0c0bf2;
}

/* ---------------------------------------------------------------- base */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.4 "Avenir Next", Avenir, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}
body.modal-open { overflow: hidden; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
h1, h2, h3, .display { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: var(--accent2); }
code { font-size: .85em; background: var(--chip); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: 9px; }

.ic { width: 20px; height: 20px; flex: none; }
.faint { color: var(--faint); }
.muted { color: var(--muted); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } * { transition: none !important; } }

.eyebrow, .head > div > span, .field > small, .mhead small {
  font-size: 11px; letter-spacing: .1em; font-weight: 800; color: var(--faint); text-transform: none;
}

/* ---------------------------------------------------------------- barra superior */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.bar { height: 58px; max-width: 980px; margin: auto; padding: 0 16px; display: flex; align-items: center; gap: 10px; }
.brand { flex: none; display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand em {
  background: var(--navy); color: var(--brand-ink); font: 22px Georgia, serif; font-style: normal;
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; flex: none;
}
.brand b { display: block; white-space: nowrap; font-weight: 800; }
.brand small { display: block; font-size: 13px; color: var(--muted); }

.statuschip {
  margin-left: auto; flex: 0 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; max-width: 52vw;
  border: 0; border-radius: 20px; padding: 6px 12px; font-size: 13px; font-weight: 800; color: var(--tone-ink);
}
.statuschip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.statuschip .ic { width: 16px; height: 16px; }
.t-green { background: var(--green); } .t-yellow { background: var(--yellow); }
.t-coral { background: var(--coral); } .t-blue { background: var(--blue); }

.syncbtn { min-height: 40px; flex: none; }
@media (max-width: 520px) { .brand span { display: none; } .syncbtn { padding: 0 12px; } .statuschip { max-width: none; padding: 6px 10px; } .syncbtn { font-size: 15px; } }
@media (max-width: 340px) { .syncbtn span { display: none; } }

body.logged-out .topbar, body.logged-out .bottombar, body.logged-out #view { display: none; }

/* ---------------------------------------------------------------- contenido */

.content { max-width: 980px; margin: auto; padding: 22px 16px calc(110px + env(safe-area-inset-bottom)); outline: 0; }
.head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; gap: 14px; }
.head h1 { font: 32px/1.1 Georgia, serif; margin: 6px 0 6px; }
.head p { margin: 0; color: var(--muted); }
.head > button { flex: none; }
.h-detail { font: 30px/1.12 Georgia, serif; margin: 4px 0 8px; overflow-wrap: anywhere; }
.lead { margin: 0; font-size: 17px; }
.hint { color: var(--muted); font-size: 14px; margin: 12px 2px; }
.center { text-align: center; }
.desc { color: var(--muted); margin: 10px 0 0; white-space: pre-line; }

/* ---------------------------------------------------------------- botones */

.primary, .soft, .danger {
  border: 0; border-radius: 11px; min-height: 48px; padding: 10px 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; white-space: nowrap; text-decoration: none;
}
.primary { background: var(--navy); color: var(--accent-ink); }
.soft { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.danger { background: var(--surface); border: 1px solid var(--danger); color: var(--danger); }
.danger-t { color: var(--danger); }
.big { min-height: 54px; font-size: 17px; }
.wide { width: 100%; margin-top: 14px; }
.square { width: 52px; min-height: 52px; padding: 0; flex: none; }
.linkbtn {
  border: 0; background: none; color: var(--accent2); font-weight: 700; padding: 8px 0; min-height: 40px;
  display: inline-flex; align-items: center; gap: 4px;
}
.linkbtn .ic { width: 16px; }
.pillbtn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 8px 12px;
  font-weight: 700; font-size: 14px; white-space: nowrap; min-height: 40px;
}
.icon-btn { border: 0; background: var(--chip); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.backlink {
  display: inline-flex; align-items: center; gap: 2px; border: 0; background: none; color: var(--accent2);
  font-weight: 700; padding: 4px 0 12px; min-height: 40px; margin-left: -4px;
}
.backlink .ic { width: 18px; }

/* Botón grande de escaneo en Inicio */
.scanbig { width: 100%; justify-content: flex-start; gap: 14px; padding: 16px 18px; min-height: 76px; border-radius: 15px; margin-bottom: 14px; text-align: left; }
.scanbig .ic { width: 32px; height: 32px; }
.scanbig b { display: block; font-size: 19px; }
.scanbig small { display: block; font-weight: 600; opacity: .8; font-size: 14px; white-space: normal; }

/* ---------------------------------------------------------------- búsqueda */

.search {
  border: 1px solid var(--line); background: var(--fill); border-radius: 11px; min-height: 52px;
  display: flex; align-items: center; gap: 10px; padding: 0 14px; flex: 1; color: var(--muted);
}
.search input { border: 0; outline: 0; background: none; width: 100%; font-size: 17px; color: var(--ink); min-height: 48px; }
.search:focus-within { border-color: var(--navy); background: var(--surface); }
.search.big { margin-bottom: 16px; }
.searchrow { display: flex; gap: 8px; margin-bottom: 16px; }
.searchrow .search { margin: 0; }

/* ---------------------------------------------------------------- métricas */

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 20px; }
.tone { border: 0; text-align: left; padding: 16px 18px; border-radius: 15px; font-weight: 700; font-size: 14px; color: var(--tone-ink); }
.tone b { font: 30px Georgia, serif; margin-right: 8px; }
.t0 { background: var(--coral); } .t1 { background: var(--blue); } .t2 { background: var(--yellow); } .t3 { background: var(--green); }
.metrics.two-up { grid-template-columns: 1fr 1fr; margin-top: 16px; }

/* ---------------------------------------------------------------- tarjetas y filas */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; padding: 6px 18px 12px; margin-bottom: 16px; }
.card.flush { padding-top: 0; padding-bottom: 0; }
.card.flush > .row:first-child { border-top: 0; }
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0 8px; }
.cardhead h2 { font: 21px Georgia, serif; margin: 0; }
.cardhead h2::first-letter { text-transform: uppercase; }
.cardhead small { color: var(--muted); }
.cardhead.sp { margin-top: 10px; border-top: 1px solid var(--line); }

.row {
  border: 0; border-top: 1px solid var(--line-soft); background: none; width: 100%; text-align: left;
  padding: 12px 0; min-height: 64px; display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none;
}
.cardhead + .row, .card > .row:first-child, .mlist > .row:first-child, .hint + .row { border-top-color: transparent; }
.row > span { flex: 1; min-width: 0; }
.row > span.thumb, .row > span.qtycell, .row > span.stack, .picker > span.thumb, .ccard > span.thumb, .person > span.thumb { flex: none; }
.row b, .row strong, .row small { display: block; }
.row b { overflow-wrap: anywhere; }
.row small { color: var(--muted); font-size: 14px; margin-top: 2px; }
.row small.faint { color: var(--faint); font-size: 13px; }
.row > .ic { color: var(--muted); }
.row.inactive { opacity: .6; }
.row .stack { flex: none; display: grid; gap: 6px; justify-items: end; }
button.row:active, a.row:active { background: var(--sel); }

.round { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; color: var(--tone-ink); }
.round.green { background: var(--green); } .round.coral { background: var(--coral); }
.round.blue { background: var(--blue); } .round.yellow { background: var(--yellow); }

.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: var(--yellow); color: var(--tone-ink); flex: none; font-style: normal; }

/* cantidades */
.qtycell { flex: none; text-align: right; display: grid; justify-items: end; line-height: 1.1; min-width: 64px; }
.qtycell b { font-size: 24px; }
.qtycell small { font-size: 13px; color: var(--muted); margin: 0; }
.qtycell .pend { font-style: normal; font-size: 12px; font-weight: 800; background: var(--yellow); color: var(--tone-ink); border-radius: 20px; padding: 1px 7px; margin-top: 4px; }
.mqty { flex: none; font-weight: 800; white-space: nowrap; }
.qty-s { font-style: normal; font-weight: 800; color: var(--muted); white-space: nowrap; }

/* ubicaciones del producto */
.locs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.locs i { font-style: normal; font-size: 13px; background: var(--fill2); border: 1px solid var(--line); border-radius: 20px; padding: 3px 9px; color: var(--ink); }
.locs i b { display: inline; }
.locs i.pend { background: var(--yellow); border-color: transparent; color: var(--tone-ink); }
.locs i.more { background: none; color: var(--muted); }
.locs.none { display: block; font-size: 13px; color: var(--faint); }

/* miniaturas */
.thumb {
  width: 52px; height: 52px; border-radius: 11px; overflow: hidden; flex: none; position: relative;
  background: var(--fill2); display: grid; place-items: center; border: 1px solid var(--line-soft);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.ph b { font: 22px Georgia, serif; color: var(--faint); }
.thumb.ph .ic { color: var(--faint); }
.thumb.sm { width: 40px; height: 40px; border-radius: 9px; }
.thumb.sm.ph b { font-size: 17px; }
.thumb.lg { width: 72px; height: 72px; border-radius: 14px; }
.thumb.xl { width: 96px; height: 96px; border-radius: 16px; }
.thumb.xl.ph b { font-size: 40px; }
.thumb .dot { position: absolute; right: 4px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--warn-line); border: 2px solid var(--surface); }

/* tarjetas de contenedor */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.ccard {
  display: flex; gap: 12px; align-items: center; text-align: left; padding: 12px; min-height: 96px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 15px; color: var(--ink);
}
.ccard > span { flex: 1; min-width: 0; }
.ccard b { display: block; font-size: 18px; overflow-wrap: anywhere; }
.ccard small { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; margin-top: 2px; }
.ccard small .ic { width: 14px; height: 14px; }
.ccard em { display: block; font-style: normal; font-size: 13px; color: var(--faint); margin-top: 4px; font-weight: 700; }

/* encabezado de detalle */
.person { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.person > span { min-width: 0; }
.person small.muted { display: flex; align-items: center; gap: 4px; font-size: 15px; }
.person small.muted .ic { width: 16px; height: 16px; }
.person.small { padding: 12px 0; }
.person.small b, .person.small small { display: block; }
.person.small small { color: var(--muted); }
.photo-btn { border: 0; padding: 0; background: none; border-radius: 16px; }

/* acciones de movimiento: grandes y al alcance del pulgar */
.moveactions {
  position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 5;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 16px;
  background: var(--paper); padding: 6px 0;
}
.moveactions button, .actiongrid button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 15px; min-height: 84px;
  display: grid; justify-items: center; align-content: center; gap: 6px; font-weight: 800; font-size: 16px; padding: 10px 4px; color: var(--ink);
}
.moveactions button:active, .actiongrid button:active { background: var(--sel); }
.actiongrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 0 6px; }
@media (max-width: 480px) { .actiongrid { grid-template-columns: repeat(2, 1fr); } }

.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 4px; }
.tools .soft { justify-content: flex-start; }

/* galería */
.gallery { margin-bottom: 16px; }
.hero {
  width: 100%; aspect-ratio: 4 / 3; max-height: 360px; border: 1px solid var(--line); border-radius: 17px;
  overflow: hidden; background: var(--fill2); padding: 0; display: grid; place-items: center; color: var(--faint);
}
.hero img { width: 100%; height: 100%; object-fit: contain; background: var(--fill2); }
.hero.ph { gap: 8px; align-content: center; font-weight: 700; aspect-ratio: 16 / 7; }
.hero.ph .ic { width: 34px; height: 34px; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 2px; }
.strip button { border: 2px solid transparent; padding: 0; background: none; border-radius: 12px; flex: none; }
.strip button.on { border-color: var(--navy); }
.strip .addph { width: 44px; height: 44px; border: 1px dashed var(--line); border-radius: 11px; display: grid; place-items: center; color: var(--muted); align-self: center; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips i { font-style: normal; font-size: 14px; font-weight: 700; background: var(--fill2); border: 1px solid var(--line); padding: 6px 11px; border-radius: 20px; display: inline-flex; gap: 5px; align-items: center; }
.chips i .ic { width: 15px; height: 15px; }
.chips.choose { margin-bottom: 4px; }
.chips.choose button { border: 1px solid var(--line); background: var(--fill2); border-radius: 20px; padding: 9px 13px; font-size: 15px; font-weight: 700; min-height: 42px; }
.chips.choose button.on { background: var(--navy); color: var(--accent-ink); border-color: transparent; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-style: normal; font-size: 13px; font-weight: 800; border-radius: 20px; padding: 5px 10px; color: var(--tone-ink); white-space: normal; }
.pill .ic { width: 15px; height: 15px; }
.pill.green { background: var(--green); } .pill.yellow { background: var(--yellow); }
.pill.coral { background: var(--coral); } .pill.blue { background: var(--blue); }

/* notas y avisos */
.note { background: var(--fill2); border-radius: 11px; padding: 12px 14px; font-size: 15px; color: var(--muted); margin: 0 0 14px; display: flex; gap: 8px; align-items: flex-start; }
.note .ic { width: 18px; margin-top: 1px; }
.note.warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }
.note.error { background: var(--coral); color: var(--tone-ink); }
.note.ok { background: var(--green); color: var(--tone-ink); }
.err { color: var(--danger); font-style: normal; font-size: 14px; font-weight: 700; }
small.err { display: block; }
.help { color: var(--muted); font-style: normal; font-size: 13px; display: flex; gap: 5px; align-items: flex-start; }
.help .ic { width: 15px; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty > .ic { width: 38px; height: 38px; color: var(--faint); }
.empty h3 { font: 22px Georgia, serif; color: var(--ink); margin: 10px 0 6px; }
.empty p { margin: 0 auto 16px; max-width: 360px; }
.empty.small { padding: 18px 8px; }
.empty.small p { margin-bottom: 8px; }
.empty.small > .ic { width: 26px; height: 26px; }
.loading { padding: 30px; text-align: center; color: var(--muted); }

/* movimientos */
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.chip-x { border: 0; background: var(--chip); border-radius: 20px; padding: 8px 10px 8px 14px; font-weight: 700; font-size: 14px; display: inline-flex; gap: 4px; align-items: center; min-height: 40px; }
.chip-x .ic { width: 15px; }
.mrow { min-height: 70px; }
.mrow.local b::after { content: " · pendiente"; font-weight: 700; color: var(--warn-ink); font-size: 13px; }
.pendcard { border-color: var(--warn-line); }
.exports { margin-top: 16px; }
.exports .soft { width: 100%; }

/* sincronización */
.statusbig { display: flex; gap: 14px; align-items: center; border-radius: 15px; padding: 16px; color: var(--tone-ink); }
.statusbig .ic { width: 30px; height: 30px; }
.statusbig b { font-size: 18px; display: block; }
.statusbig small { display: block; font-size: 14px; }
.tone-green { background: var(--green); } .tone-yellow { background: var(--yellow); }
.tone-coral { background: var(--coral); } .tone-blue { background: var(--blue); }
.card.attention { border-color: var(--warn-line); }
.conflict { border-top: 1px solid var(--line-soft); padding: 12px 0 14px; }
.conflict > .row { border: 0; padding-top: 0; min-height: 0; }
.conflict p { margin: 0 0 12px; background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--ink); padding: 12px; border-radius: 12px; font-size: 15px; }
.cactions { display: flex; flex-wrap: wrap; gap: 8px; }
.cactions .primary, .cactions .soft { min-height: 46px; flex: 1 1 auto; }

/* menú Más */
.menu .row > .ic:first-child { width: 22px; height: 22px; }

/* checks */
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--navy); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 12px; padding-bottom: 6px; }

.steps ol { margin: 0; padding: 4px 0 10px 22px; display: grid; gap: 10px; }

/* ---------------------------------------------------------------- navegación inferior */

.bottombar {
  display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.bottombar button {
  position: relative; border: 0; background: none; display: grid; justify-items: center; align-content: center; gap: 2px;
  min-height: 60px; padding: 4px 2px; font-size: 11.5px; font-weight: 800; color: var(--faint); border-radius: 10px;
}
.bottombar svg { width: 24px; height: 24px; display: block; }
.bottombar button.active { color: var(--navy); }
.bottombar button > i {
  position: absolute; top: 2px; left: calc(50% + 4px); font-style: normal; font-size: 11px; font-weight: 800;
  background: var(--coral); color: var(--tone-ink); border-radius: 20px; padding: 1px 6px;
}
.bottombar .scanfab { color: var(--ink); }
.bottombar .scanfab span {
  width: 54px; height: 40px; border-radius: 14px; background: var(--navy); color: var(--accent-ink);
  display: grid; place-items: center;
}
.bottombar .scanfab svg { width: 26px; height: 26px; }

@media (min-width: 900px) {
  .content { padding-top: 34px; }
  .head h1 { font-size: 40px; }
  .bottombar { max-width: 620px; margin: 0 auto 14px; border: 1px solid var(--line); border-radius: 18px; }
}

/* ---------------------------------------------------------------- hojas modales */

.overlay { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; padding: 20px; z-index: 40; }
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: 19px; width: min(560px, 100%);
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px var(--shadow); overflow: hidden;
}
.mhead, .mfoot { flex: none; }
.modal.small { width: min(440px, 100%); }
.mhead { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.mhead > span { flex: 1; min-width: 0; }
.mhead small { display: block; }
.mhead h2 { font: 25px/1.15 Georgia, serif; margin: 4px 0 0; overflow-wrap: anywhere; }
.mbody { flex: 1 1 auto; min-height: 0; padding: 18px 20px; overflow: auto; display: grid; gap: 16px; align-content: start; overscroll-behavior: contain; }
.mfoot { border-top: 1px solid var(--line); padding: 12px 20px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.mfoot > .soft { flex: 1; }
.mfoot > .primary, .mfoot > .danger { flex: 2; }

.field { display: grid; gap: 6px; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); background: var(--fill); border-radius: 11px; padding: 12px; font-size: 17px; outline: 0; width: 100%; min-height: 50px;
}
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--navy); background: var(--surface); }
.field .invalid, .invalid { border-color: var(--danger) !important; }
.field .inline { display: flex; gap: 8px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }
.mlist { display: grid; }

.picker {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; min-height: 64px;
  border: 1px solid var(--line); background: var(--fill); border-radius: 13px; padding: 8px 12px; color: var(--ink);
}
.picker > span { flex: 1; min-width: 0; }
.picker b, .picker small { display: block; }
.picker b { overflow-wrap: anywhere; }
.picker small { color: var(--muted); font-size: 14px; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--chip); border-radius: 13px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: none; border-radius: 10px; min-height: 44px; font-weight: 800; font-size: 15px; color: var(--muted); padding: 4px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: inset 0 -3px 0 var(--navy); }
.seg.four button { font-size: 14px; }

.availbox { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--fill2); border-radius: 13px; padding: 12px 14px; }
.availbox small { display: block; font-size: 11px; letter-spacing: .1em; font-weight: 800; color: var(--faint); }
.availbox b { font-size: 28px; }

.qtyrow { display: grid; grid-template-columns: 60px 1fr 60px; gap: 8px; }
.qtyrow .step { border: 1px solid var(--line); background: var(--surface); border-radius: 13px; display: grid; place-items: center; min-height: 64px; }
.qtyrow .step .ic { width: 24px; height: 24px; }
input.qty, .field input.qty {
  text-align: center; font: 32px Georgia, serif; min-height: 64px; padding: 6px; border-radius: 13px;
  border: 1px solid var(--line); background: var(--fill); width: 100%;
}
.qtyrow.invalid input.qty { border-color: var(--danger); }
.preview { margin: 4px 0 0; font-size: 15px; color: var(--muted); }
.preview.neg b { color: var(--danger); }

.photopick { display: flex; gap: 12px; align-items: center; }
.photopick .btns { display: grid; gap: 8px; flex: 1; }
.photopick .soft { justify-content: flex-start; }

.done { display: grid; justify-items: center; text-align: center; gap: 12px; padding: 18px 0; }
.donecheck { width: 72px; height: 72px; border-radius: 50%; background: var(--green); color: var(--tone-ink); display: grid; place-items: center; }
.donecheck .ic { width: 36px; height: 36px; }
.done p { margin: 0; font-size: 18px; }

.qa-head { display: flex; gap: 14px; align-items: center; }
.qa-head small { display: block; font-size: 11px; letter-spacing: .1em; font-weight: 800; color: var(--faint); }
.qa-head b { display: block; font-size: 30px; margin: 2px 0 4px; }

.plist { display: grid; }
.row.pick { min-height: 66px; }

/* escáner */
.modal.scan { width: min(520px, 100%); }
.scanbox { position: relative; background: var(--fill2); border-radius: 15px; overflow: hidden; min-height: 240px; }
.scan-region { width: 100%; }
.scan-region video { width: 100% !important; display: block; border-radius: 15px; }
.scan-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 18px; text-align: center; color: var(--muted); font-weight: 600; }
.scan-msg .ic { width: 32px; height: 32px; }
.scan-msg.error { background: var(--coral); color: var(--tone-ink); }

/* visor de fotos */
.viewer { position: fixed; inset: 0; z-index: 60; background: var(--viewer); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: 82vh; border-radius: 10px; }
.viewer p { color: var(--paper); text-align: center; margin: 10px 0 0; }
[data-theme="dark"] .viewer p { color: var(--ink); }
.viewer small { opacity: .7; }

/* aviso breve */
.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 70;
  max-width: 520px; margin: auto; display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--navy); color: var(--accent-ink); border-radius: 13px; padding: 12px 14px; font-weight: 700;
  transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { transform: none; opacity: 1; pointer-events: auto; }
.toast > span { display: flex; gap: 8px; align-items: center; }
.toast.t-error { background: var(--coral); color: var(--tone-ink); }
.toast.t-warn { background: var(--yellow); color: var(--tone-ink); }
.toast button { border: 0; background: none; color: inherit; font-weight: 800; text-decoration: underline; min-height: 40px; }
body.modal-open .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ingreso */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.loginbox .sep { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; color: var(--muted); font-size: 12px; }
.loginbox .sep::before, .loginbox .sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.updatebar { position: fixed; left: 12px; right: 12px; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 60;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18); font-size: 14px; }
.updatebar button { flex: 0 0 auto; }
@media print { .updatebar { display: none; } }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.4; word-break: break-all; resize: vertical; }
.qrcard { background: #fff; padding: 12px; border-radius: 12px; display: block; }
.qrcard svg { display: block; width: 100%; height: auto; }
.loginbox { width: min(400px, 100%); display: grid; gap: 16px; }
.loginbox .brand { margin-bottom: 18px; }
.loginbox .brand em { width: 46px; height: 46px; font-size: 28px; border-radius: 14px; }
.loginbox .brand b { font-size: 19px; }
.loginbox h1 { font: 36px Georgia, serif; margin: 0; }
.loginbox .note { margin: 0; }

/* ---------------------------------------------------------------- teléfono */

@media (max-width: 800px) {
  .card { border-left: 0; border-right: 0; border-radius: 0; margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .metrics:not(.two-up) { display: block; margin-bottom: 18px; }
  .metrics:not(.two-up) .tone { display: flex; align-items: baseline; gap: 12px; width: 100%; background: none; border-radius: 0; border-top: 1px solid var(--line); padding: 10px 0; font-size: 16px; color: var(--ink); }
  .metrics:not(.two-up) .tone b { font-size: 26px; min-width: 40px; margin: 0; }
  .metrics:not(.two-up) .tone.t0 b { color: var(--danger); }
  .overlay { padding: 0; place-items: stretch; }
  .modal, .modal.small, .modal.scan { width: 100%; height: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; box-shadow: none; }
  .mhead { padding-top: calc(14px + env(safe-area-inset-top)); }
  .mfoot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .mfoot > .primary, .mfoot > .danger { order: -1; flex-basis: 100%; }
}

/* ---------------------------------------------------------------- etiquetas e impresión */

.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.label { background: var(--print-paper); color: var(--print-ink); border: 1px dashed var(--line); border-radius: 10px; padding: 14px; display: grid; justify-items: center; text-align: center; gap: 4px; }
.label .qr { width: 150px; height: 150px; }
.label .qr svg { width: 100%; height: 100%; }
.label b { font: 22px Georgia, serif; overflow-wrap: anywhere; }
.label small { font-size: 13px; }
.label code { background: none; font-size: 10px; padding: 0; color: var(--print-ink); }

@media print {
  @page { margin: 10mm; }
  body { background: var(--print-paper); }
  .topbar, .bottombar, .noprint, .toast, .skip { display: none !important; }
  .content { padding: 0; max-width: none; }
  .labels { grid-template-columns: repeat(3, 60mm); gap: 4mm; margin: 0; }
  .label { width: 60mm; height: 75mm; border: .3mm dashed var(--print-ink); border-radius: 2mm; break-inside: avoid; padding: 4mm; align-content: center; }
  .label .qr { width: 42mm; height: 42mm; }
}
