:root {
  --navy: #1b2f57; --navy-2: #243b69; --orange: #f0801e; --orange-dk: #d96a0a;
  --bg: #f3f5f9; --card: #fff; --line: #e2e7ef; --text: #1a2332; --muted: #6a7789;
  --green: #1e8e3e; --green-bg: #e5f4ea; --amber: #a85d00; --amber-bg: #fdf0cf;
  --red: #c62828; --red-bg: #fde8e8; --blue: #2f5597; --blue-bg: #e8f0fb; --gray-bg: #eceff4;
  --r: 12px; --shadow: 0 1px 2px rgba(20,35,60,.06), 0 4px 14px rgba(20,35,60,.05);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
#app { display: flex; height: 100vh; height: 100dvh; }
.topbar, .scrim { display: none; }

/* ---------- barra lateral ---------- */
.side { width: 236px; background: var(--navy); color: #dbe4f5; display: flex; flex-direction: column; flex: 0 0 236px; }
.brand { background: #fff; padding: 14px 18px; display: flex; justify-content: center; border-bottom: 4px solid var(--orange); }
.brand img { height: 46px; max-width: 100%; object-fit: contain; }
#nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 3px; flex: 1; overflow: auto; }
#nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #c9d6ee; text-decoration: none; font-weight: 500; cursor: pointer; transition: background .12s; }
#nav a svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
#nav a.on { background: rgba(240,128,30,.18); color: #fff; box-shadow: inset 3px 0 0 var(--orange); }
#nav .badge { margin-left: auto; background: var(--orange); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.side-foot { padding: 12px 14px 14px; border-top: 1px solid rgba(255,255,255,.1); font-size: 12px; }
.conn { display: flex; align-items: center; gap: 8px; color: #b5c3de; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #8896b3; }
.conn.ok .dot { background: #3ecf6e; box-shadow: 0 0 0 3px rgba(62,207,110,.2); }
.conn.bad .dot { background: #ff6b6b; box-shadow: 0 0 0 3px rgba(255,107,107,.25); }
.who { margin-top: 10px; }
.who label { display: block; color: #8fa0c2; margin-bottom: 3px; }
.who select { width: 100%; background: #243b69; border: 1px solid #36507f; color: #fff; border-radius: 8px; padding: 6px 8px; }
.ver { margin-top: 10px; color: #7487ad; }
.quit { margin-top: 10px; width: 100%; background: transparent; border: 1px solid rgba(255,255,255,.28); color: #c9d6ee; border-radius: 8px; padding: 7px 8px; cursor: pointer; font-weight: 600; }
.quit:hover { background: rgba(255,255,255,.08); color: #fff; }
.bye { max-width: 460px; margin: 14vh auto 0; text-align: center; color: var(--navy); padding: 0 20px; }
.bye img { width: 220px; margin-bottom: 24px; } .bye h1 { margin-bottom: 8px; } .bye p { color: var(--muted); font-size: 15px; }

/* ---------- sesión (modo servidor) ---------- */
.me { margin-top: 10px; } .me[hidden] { display: none; }
.me-card { display: flex; align-items: center; gap: 10px; padding: 8px; margin: 0 -8px; border-radius: 10px; text-decoration: none; color: inherit; }
.me-card:hover, .me-card:focus-visible { background: rgba(255,255,255,.08); outline: none; }
.me-av { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--orange); color: #fff; font-weight: 700; font-size: 15px; display: grid; place-items: center; }
.me-tx { min-width: 0; display: flex; flex-direction: column; }
.me-name { color: #fff; font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role { color: #8fa0c2; margin-top: 1px; font-size: 12px; }
.me-out { margin-top: 8px; width: 100%; background: transparent; border: 1px solid rgba(255,255,255,.28); color: #c9d6ee; border-radius: 8px; padding: 7px 8px; cursor: pointer; font-weight: 600; font-size: 12.5px; }
.me-out:hover { background: rgba(255,255,255,.08); color: #fff; }
.gate { position: fixed; inset: 0; z-index: 300; background: var(--bg); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; overflow: auto; }
.gate-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 28px 28px 24px; }
.gate-card img { display: block; width: 190px; max-width: 70%; margin: 0 auto 18px; }
.gate-card h1 { font-size: 22px; color: var(--navy); text-align: center; margin-bottom: 4px; }
.gate-card .sub { color: var(--muted); text-align: center; margin-bottom: 18px; font-size: 14px; }
.gate-card .banner { margin-bottom: 14px; border-radius: 9px; }
.gate-err { background: var(--red-bg); color: var(--red); border-radius: 9px; padding: 9px 12px; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
.gate-err[hidden] { display: none; }
.role-pick { display: grid; gap: 8px; margin-bottom: 12px; }
.role-pick label { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; cursor: pointer; }
.role-pick label:has(input:checked) { border-color: var(--blue); background: var(--blue-bg); }
.role-pick b { display: block; color: var(--navy); } .role-pick span { color: var(--muted); font-size: 12.5px; }

/* ---------- contenido ---------- */
.main { flex: 1; overflow: auto; padding: 26px 30px 40px; position: relative; }
.banner { background: var(--red-bg); color: var(--red); border: 1px solid #f3b9b9; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; color: var(--navy); letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px 20px; }
.card h2 { font-size: 15px; color: var(--navy); margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }                          /* sin esto una tarjeta con un campo o un texto largo ensancha la columna y la pantalla */
input[type=file] { max-width: 100%; }
.help, .card p { overflow-wrap: anywhere; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: minmax(300px, 400px) 1fr; align-items: start; }
.g-conteo { grid-template-columns: 260px 1fr; align-items: start; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g2, .g-main { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .g-conteo { grid-template-columns: 1fr; } .g3 { grid-template-columns: 1fr 1fr; } .g3 > .card { grid-column: 1 / -1; } }

/* ---------- controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 15px; border-radius: 9px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; color: var(--navy); transition: .12s; white-space: nowrap; }
.btn:hover { border-color: #c5cfdf; background: #f8fafd; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primary:hover { background: var(--orange-dk); border-color: var(--orange-dk); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--red); border-color: #f0c2c2; }
.btn.danger:hover { background: var(--red-bg); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.lg { padding: 12px 22px; font-size: 15px; border-radius: 11px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--gray-bg); }
label.f { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.in, .sel, .ta { width: 100%; background: #fff; border: 1px solid #cfd8e6; border-radius: 9px; padding: 8px 11px; outline: none; transition: border .12s, box-shadow .12s; }
.in:focus, .sel:focus, .ta:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,85,151,.15); }
.in.big { font-size: 20px; padding: 13px 16px; font-weight: 600; letter-spacing: .3px; }
.in.num { text-align: right; font-variant-numeric: tabular-nums; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; } .row > * { flex: 1; min-width: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--gray-bg); border-radius: 11px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; padding: 11px; border-radius: 8px; font-weight: 700; cursor: pointer; color: var(--muted); font-size: 15px; }
.seg button.on.in-ent { background: var(--green); color: #fff; box-shadow: var(--shadow); }
.seg button.on.in-sal { background: var(--orange); color: #fff; box-shadow: var(--shadow); }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- tablas ---------- */
.tablewrap { overflow: auto; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
table.t { width: 100%; border-collapse: collapse; }
.t th { position: sticky; top: 0; background: #f6f8fc; text-align: left; font-size: 11.5px; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 9px 12px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover td { background: #f7faff; }
.t .r { text-align: right; font-variant-numeric: tabular-nums; } .t .c { text-align: center; }
.t .code { font-weight: 700; color: var(--navy); font-family: Consolas, "Cascadia Mono", monospace; white-space: nowrap; }
.t tr.voided td { color: #9aa5b6; text-decoration: line-through; }
.t tr.reversal td { background: #faf5ff; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; color: var(--muted); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .in, .toolbar .sel { width: auto; min-width: 150px; }
.toolbar .grow { flex: 1; min-width: 220px; }

/* ---------- chips ---------- */
.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.chip.OK, .chip.green { background: var(--green-bg); color: var(--green); }
.chip.BAJO, .chip.amber { background: var(--amber-bg); color: var(--amber); }
.chip.AGOTADO, .chip.NEGATIVO, .chip.red { background: var(--red-bg); color: var(--red); }
.chip.INACTIVO, .chip.gray { background: var(--gray-bg); color: #5d6a7d; }
.chip.ENTRADA { background: var(--green-bg); color: var(--green); }
.chip.SALIDA { background: #fdebd7; color: var(--orange-dk); }

/* ---------- tablero ---------- */
.kpi { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 18px; border-left: 4px solid var(--blue); }
.kpi .lab { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 26px; font-weight: 700; color: var(--navy); margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.kpi.amber { border-color: #e9a400; } .kpi.amber .val { color: var(--amber); }
.kpi.red { border-color: var(--red); } .kpi.red .val { color: var(--red); }
.kpi.green { border-color: var(--green); }
.kpi .small { font-size: 12px; color: var(--muted); }
.qrow { display: flex; align-items: flex-start; gap: 12px; padding: 9px 0; border-bottom: 1px solid #eef1f6; }
.qrow:last-child { border-bottom: 0; }
.qrow .n { min-width: 34px; text-align: center; font-weight: 700; border-radius: 8px; padding: 2px 0; }
.qrow .n.ok { background: var(--green-bg); color: var(--green); } .qrow .n.bad { background: var(--red-bg); color: var(--red); }
.qrow .tx b { display: block; font-weight: 600; } .qrow .tx span { color: var(--muted); font-size: 12.5px; }
.bar { display: grid; grid-template-columns: 210px 1fr 110px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.bar .track { height: 12px; background: var(--gray-bg); border-radius: 99px; overflow: hidden; }
.bar .fill { height: 100%; background: linear-gradient(90deg, var(--blue), #5c8be0); border-radius: 99px; }
.bar .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .vl { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- ficha de producto / escaneo ---------- */
.pcard { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #fbfcfe; }
.pcard .code { font-family: Consolas, "Cascadia Mono", monospace; font-weight: 700; color: var(--navy); font-size: 15px; }
.pcard .desc { font-size: 17px; font-weight: 700; margin: 2px 0 6px; }
.pcard .meta { color: var(--muted); font-size: 13px; display: flex; gap: 14px; flex-wrap: wrap; }
.pcard .stock { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.pcard .stock b { font-size: 34px; color: var(--navy); font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.pcard .stock span { color: var(--muted); font-weight: 600; }
.pcard.warn { border-color: #f1c27a; background: #fffaf0; }
.pcard.bad { border-color: #efb1b1; background: #fff6f6; }
.suggest { position: relative; }
.suggest .list { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(20,35,60,.16); overflow: hidden; }
.suggest .item { padding: 8px 12px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.suggest .item:hover, .suggest .item.on { background: var(--blue-bg); }
.suggest .item .code { font-family: Consolas, monospace; font-weight: 700; color: var(--navy); font-size: 13px; }
.suggest .item .stk { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.okbox { background: var(--green-bg); border: 1px solid #b6dfc4; color: #14672c; border-radius: 12px; padding: 12px 16px; margin-top: 14px; }
.okbox b { font-size: 15px; }
.okbox ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- ventanas y avisos ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,25,45,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; animation: fade .12s; }
.modal { background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(10,20,40,.35); width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column; animation: pop .14s; }
.modal.wide { max-width: 860px; }
.modal-h { padding: 18px 22px 8px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.modal-h h2 { font-size: 18px; color: var(--navy); }
.modal-b { padding: 8px 22px 6px; overflow: auto; }
.modal-f { padding: 14px 22px 18px; display: flex; justify-content: flex-end; gap: 10px; }
.x { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; padding: 2px 8px; border-radius: 8px; }
.x:hover { background: var(--gray-bg); }
@keyframes fade { from { opacity: 0 } } @keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0 } }
#toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; align-items: flex-end; }
.toast { background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(10,20,40,.3); max-width: 420px; font-weight: 600; animation: pop .16s; }
.toast.ok { background: #14672c; } .toast.err { background: #b3261e; } .toast.warn { background: #a85d00; }
.codebig { font: 700 34px/1.1 Consolas, "Cascadia Mono", monospace; color: var(--navy); letter-spacing: 1px; text-align: center; padding: 18px; background: var(--blue-bg); border-radius: 12px; margin: 8px 0 12px; user-select: all; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; white-space: nowrap; border: 0; background: transparent; padding: 10px 16px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--navy); border-color: var(--orange); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); font-size: 12.5px; } .kv dd { margin: 0; font-weight: 600; }
.sessions { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow: auto; }
.sess { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; }
.sess:hover { border-color: #b9c6dd; } .sess.on { border-color: var(--orange); background: #fff8f1; }
.sess small { color: var(--muted); display: block; }

/* =====================================================================================
   ADAPTACIÓN A TODAS LAS PANTALLAS
   computador (> 900 px): menú fijo a la izquierda · tablet y celular (<= 900 px): barra superior + menú que se desliza
   celular (<= 720 px): tablas como tarjetas, ventanas desde abajo, campos grandes
   ===================================================================================== */
@media (max-width: 900px) {
  #app { flex-direction: column; }
  .topbar { display: flex; align-items: center; gap: 8px; flex: none; min-height: 54px; padding: env(safe-area-inset-top) 10px 0 6px; background: #fff; border-bottom: 3px solid var(--orange); position: relative; z-index: 50; }
  .tb-btn { flex: none; width: 44px; height: 44px; border: 0; background: transparent; border-radius: 10px; display: grid; place-items: center; color: var(--navy); cursor: pointer; }
  .tb-btn:hover, .tb-btn:focus-visible { background: var(--gray-bg); outline: none; }
  .tb-btn svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
  .tb-logo { height: 30px; flex: none; }
  .tb-title { margin-left: auto; font-weight: 700; color: var(--navy); font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tb-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #9aa5b6; margin-right: 6px; }
  .tb-dot.ok { background: #2fbf64; } .tb-dot.bad { background: #e5484d; }
  .side { position: fixed; z-index: 160; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); flex: none; transform: translateX(-102%); visibility: hidden;
          transition: transform .2s ease, visibility 0s linear .2s; padding-bottom: env(safe-area-inset-bottom); }
  body.menu-open .side { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: 8px 0 30px rgba(10,20,40,.35); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 150; background: rgba(15,25,45,.5); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.menu-open .scrim { opacity: 1; pointer-events: auto; }
  body.menu-open { overflow: hidden; }
  #nav a { padding: 13px 12px; }
  .main { padding: 18px 18px 36px; padding-bottom: calc(36px + env(safe-area-inset-bottom)); }
}
@media (max-width: 720px) {
  body { font-size: 15px; }
  .main { padding: 14px 12px 32px; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
  .page-head { align-items: flex-start; gap: 10px; margin-bottom: 14px; }
  .page-head h1 { font-size: 20px; }
  .page-head > div:first-child { flex: 1 1 100%; }
  .actions { width: 100%; } .actions .btn { flex: 1 1 auto; }
  .card { padding: 14px; }
  .grid { gap: 12px; }
  .row { flex-wrap: wrap; } .row > * { flex: 1 1 150px; }
  .kpi { padding: 11px 13px; } .kpi .val { font-size: 21px; }
  .bar { grid-template-columns: 1fr auto; row-gap: 4px; }
  .bar .nm { grid-column: 1; } .bar .vl { grid-column: 2; grid-row: 1; } .bar .track { grid-column: 1 / -1; grid-row: 2; }
  .kv { grid-template-columns: 1fr; gap: 0; } .kv dt { margin-top: 10px; } .kv dd { overflow-wrap: anywhere; }
  .codebig { font-size: 24px; padding: 14px; letter-spacing: .5px; }
  .pcard .stock b { font-size: 30px; }
  .toolbar { gap: 8px; }
  .toolbar > * { flex: 1 1 140px; } .toolbar .in, .toolbar .sel { width: 100%; min-width: 0; } .toolbar .grow { flex: 1 1 100%; min-width: 0; }
  .pager { flex-wrap: wrap; justify-content: center; }
  .in, .sel, .ta { font-size: 16px; }                      /* con 16 px el celular no hace zoom al tocar un campo */
  .in.big { font-size: 20px; }
  .btn { min-height: 42px; } .btn.sm { min-height: 36px; padding: 6px 12px; }
  .seg button { padding: 13px; }
  .tabs button { padding: 12px 14px; }
  .gate { padding: 5vh 12px 12px; } .gate-card { padding: 22px 18px; }
  /* ventanas: suben desde abajo y ocupan el ancho */
  .overlay { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; max-height: 92dvh; }
  .modal-h { padding: 16px 16px 6px; } .modal-b { padding: 8px 16px; }
  .modal-f { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); flex-wrap: wrap; } .modal-f .btn { flex: 1 1 auto; }
  #toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); align-items: stretch; } .toast { max-width: none; }
  /* tablas -> tarjetas (las marca stackTables en ui.js) */
  .tablewrap.stack { border: 0; background: transparent; overflow: visible; border-radius: 0; }
  table.t.stack, table.t.stack tbody { display: block; width: 100%; }
  table.t.stack thead { display: none; }
  table.t.stack tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; margin-bottom: 10px; box-shadow: var(--shadow); }
  table.t.stack tbody tr.reversal { background: #faf5ff; }
  table.t.stack tbody tr.click:active { background: #f1f6ff; }
  table.t.stack td { display: block; padding: 0; border: 0; background: transparent !important; min-width: 0 !important; text-align: left !important; overflow-wrap: anywhere; }
  table.t.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); text-decoration: none; }
  table.t.stack td:first-child, table.t.stack td.wide, table.t.stack td.empty, table.t.stack td.act { grid-column: 1 / -1; }
  table.t.stack td:first-child::before { display: none; }
  table.t.stack td:first-child { font-size: 15px; }
  table.t.stack td.act { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
  table.t.stack td.empty { text-align: center !important; padding: 12px 6px; color: var(--muted); }
  table.t.stack td .in { width: 100% !important; }
  /* cantidad + unidad + botones: el campo ocupa su propia línea */
  .qty-row { flex-wrap: wrap; }
  .qty-row .in { flex: 1 1 100%; max-width: none !important; }
  .qty-row .btn { flex: 1 1 auto; }
}
@media (pointer: coarse) { .btn, .seg button { min-height: 42px; } #nav a { min-height: 46px; } }

@media print {
  .side, .actions, .toolbar, .pager, #toasts, .no-print { display: none !important; }
  body, .main { background: #fff; padding: 0; overflow: visible; } #app { display: block; height: auto; }
  .card { box-shadow: none; padding: 0; }
}
.okbox.warn { background: var(--amber-bg); border-color: #efd28a; color: var(--amber); margin-top: 0; padding: 9px 12px; border-radius: 9px; font-weight: 600; font-size: 13px; }
