/* Portal de bodega Distrijo — misma línea visual del panel admin actual */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --brand: #e65100;
    --brand-light: #fff3e0;
    --brand-dark: #bf360c;
    --sidebar-bg: #111827;
    --sidebar-text: #9ca3af;
    --sidebar-active-bg: rgba(230,81,0,0.15);
    --sidebar-active-text: #fb923c;
    --sidebar-width: 240px;
    --topbar-h: 60px;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --ok: #16a34a;
    --ok-light: #dcfce7;
    --warn: #d97706;
    --warn-light: #fef3c7;
    --bad: #dc2626;
    --bad-light: #fee2e2;
    --info: #2563eb;
    --info-light: #dbeafe;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,.10);
}

html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.right { text-align: right; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* ── Layout ───────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 50;
    transition: transform .2s;
}
.sidebar-logo {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo img { width: 38px; height: 38px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.sidebar-logo b { color: #fff; font-size: 15px; display: block; }
.sidebar-logo span { color: var(--sidebar-text); font-size: 11px; }
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-label { color: #4b5563; font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 12px 10px 6px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    margin-bottom: 2px;
}
.nav a i { font-size: 19px; }
.nav a:hover { background: rgba(255,255,255,.05); color: #e5e7eb; }
.nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.nav a .badge { margin-left: auto; }
.sidebar-user { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.06); color: var(--sidebar-text); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.sidebar-user b { color: #e5e7eb; display: block; font-size: 13px; }
.sidebar-user button { margin-left: auto; background: none; border: none; color: var(--sidebar-text); cursor: pointer; font-size: 20px; }

.main { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar .menu-btn { display: none; background: none; border: none; font-size: 24px; cursor: pointer; }
.content { padding: 24px; flex: 1; }
.backdrop { display: none; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 45; }
    .main { margin-left: 0; }
    .topbar { padding: 0 14px; }
    .topbar .menu-btn { display: block; }
    .content { padding: 14px; }
}

/* ── Componentes ──────────────────────────────────── */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card-head h2 { font-size: 15px; font-weight: 600; }
.card-body { padding: 18px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 13px; font-weight: 500;
    cursor: pointer;
    background: #fff;
    border-color: var(--border);
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn i { font-size: 16px; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-success { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-warn { background: var(--warn); color: #fff; border-color: var(--warn); }
.btn-danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-lg { padding: 14px 22px; font-size: 15px; font-weight: 600; border-radius: 12px; }
.btn-xl { padding: 20px 26px; font-size: 18px; font-weight: 700; border-radius: 14px; width: 100%; }
.btn-xl i { font-size: 24px; }
.btn-block { width: 100%; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; background: #f1f5f9; color: var(--text-muted); }
.b-cola { background: var(--info-light); color: var(--info); }
.b-alistando, .b-empacando, .b-despachando { background: var(--brand-light); color: var(--brand-dark); }
.b-alistado, .b-empacado { background: #ede9fe; color: #6d28d9; }
.b-en_espera { background: var(--warn-light); color: var(--warn); }
.b-despachado { background: var(--ok-light); color: var(--ok); }
.b-anulado { background: var(--bad-light); color: var(--bad); }
.b-novedad { background: var(--bad-light); color: var(--bad); }

label.f { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.input, select.input, textarea.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(230,81,0,.12); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 700px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
@media (max-width: 1100px) and (min-width: 701px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.t td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #f8fafc; }
.table-wrap { overflow-x: auto; }

.kpi { padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.kpi .ic { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; background: var(--brand-light); color: var(--brand); }
.kpi b { font-size: 24px; display: block; line-height: 1.1; }
.kpi span { color: var(--text-muted); font-size: 12px; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty i { font-size: 44px; display: block; margin-bottom: 8px; color: #cbd5e1; }

/* ── Toasts y modal ───────────────────────────────── */
#toasts { position: fixed; top: 14px; right: 14px; z-index: 300; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 28px); }
.toast { background: #1f2937; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-md); font-weight: 500; display: flex; gap: 8px; align-items: center; animation: tin .2s; }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
.toast.warn { background: var(--warn); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 900px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-head h3 { font-size: 16px; flex: 1; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ── Login ────────────────────────────────────────── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--sidebar-bg); }
.login .card { width: 100%; max-width: 380px; }
.login-logo { text-align: center; padding: 26px 20px 8px; }
.login-logo img { width: 84px; height: 84px; object-fit: contain; }
.login-logo h1 { font-size: 19px; margin-top: 10px; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 14px 0; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #cbd5e1; }
.pin-dots span.on { background: var(--brand); border-color: var(--brand); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button { padding: 16px; font-size: 22px; font-weight: 600; border-radius: 12px; border: 1px solid var(--border); background: #f8fafc; cursor: pointer; }
.keypad button:active { background: var(--brand-light); }

/* ── Cabecera de cliente (estaciones) ─────────────── */
.client-head { background: var(--sidebar-bg); color: #fff; border-radius: var(--radius-lg); padding: 14px 18px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.client-head .num { font-size: 22px; font-weight: 800; color: var(--sidebar-active-text); }
.client-head .who b { font-size: 15px; display: block; }
.client-head .who span { color: #cbd5e1; font-size: 12px; }
.client-head .meta { margin-left: auto; text-align: right; font-size: 12px; color: #cbd5e1; }
.progress { height: 8px; background: #e2e8f0; border-radius: 8px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); transition: width .25s; }
.progress.ok > div { background: var(--ok); }

/* ── Estación 1: tarjeta tipo swipe ───────────────── */
.pick-wrap { max-width: 520px; margin: 0 auto; }
.deck { position: relative; height: min(62vh, 560px); margin: 14px 0; touch-action: pan-y; user-select: none; }
.pcard {
    position: absolute; inset: 0;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(15,23,42,.15);
    border: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow: hidden;
    will-change: transform;
}
.pcard.next { transform: scale(.95) translateY(12px); opacity: .6; }
.pcard .shelf { position: absolute; top: 12px; left: 12px; background: var(--sidebar-bg); color: #fff; padding: 6px 12px; border-radius: 10px; font-weight: 800; font-size: 16px; z-index: 2; }
.pcard .shelf.none { background: var(--warn); }
.pcard .count { position: absolute; top: 12px; right: 12px; background: rgba(255,255,255,.95); padding: 5px 11px; border-radius: 10px; font-weight: 700; font-size: 12px; z-index: 2; box-shadow: var(--shadow); }
.pcard .img { flex: 1; min-height: 0; background: #f8fafc; display: flex; align-items: center; justify-content: center; }
.pcard .img img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.pcard .img .noimg { font-size: 70px; color: #cbd5e1; }
.pcard .info { padding: 14px 18px 16px; border-top: 1px solid var(--border); }
.pcard .info .code { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--text-muted); font-size: 13px; }
.pcard .info .name { font-weight: 700; font-size: 16px; line-height: 1.25; margin: 3px 0 8px; }
.pcard .qty { display: flex; align-items: baseline; gap: 8px; }
.pcard .qty b { font-size: 34px; color: var(--brand); line-height: 1; }
.pcard .qty .edited { color: var(--bad); font-weight: 700; }
.pcard .note { margin-top: 8px; background: var(--warn-light); color: #92400e; padding: 7px 10px; border-radius: 8px; font-size: 12px; }
.pcard .stamp { position: absolute; top: 30%; display: flex; align-items: center; gap: 6px; font-size: 30px; font-weight: 900; letter-spacing: .04em; padding: 6px 16px; border-radius: 12px; border: 5px solid; background: rgba(255,255,255,.92); opacity: 0; z-index: 4; pointer-events: none; }
.pcard .stamp i { font-size: 32px; }
.pcard .stamp.ok { left: 18px; color: var(--ok); border-color: var(--ok); transform: rotate(-14deg); }
.pcard .stamp.no { right: 18px; color: var(--bad); border-color: var(--bad); transform: rotate(14deg); }
.pcard .tint { position: absolute; inset: 0; opacity: 0; z-index: 3; pointer-events: none; }
.pcard .tint.ok { background: linear-gradient(90deg, transparent 30%, rgba(22,163,74,.28)); }
.pcard .tint.no { background: linear-gradient(270deg, transparent 30%, rgba(220,38,38,.28)); }
.pick-actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.round.no { background: var(--bad); border-color: var(--bad); color: #fff; }
.round.no i { color: #fff; }
.swipe-hint { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.swipe-hint .sh-no { color: var(--bad); font-weight: 700; }
.swipe-hint .sh-ok { color: var(--ok); font-weight: 700; }
.round { height: 62px; border-radius: 16px; border: 1px solid var(--border); background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--text-muted); cursor: pointer; box-shadow: var(--shadow); }
.round i { font-size: 24px; color: var(--text); }
.round.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.round.ok i { color: #fff; }
.swipe-hint { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 10px; }

.sum-line { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.sum-line img, .sum-line .ph { width: 48px; height: 48px; border-radius: 8px; object-fit: contain; background: #f8fafc; flex: none; display: flex; align-items: center; justify-content: center; color: #cbd5e1; font-size: 22px; }

/* ── Estación 2: lista de empaque ─────────────────── */
.scanbar { display: flex; gap: 8px; position: sticky; top: calc(var(--topbar-h) + 6px); z-index: 30; background: var(--bg); padding: 8px 0; }
.scanbar .input { font-size: 18px; padding: 13px 14px; }
.pack-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 14px; align-items: center; padding: 12px; border-bottom: 1px solid var(--border); transition: background .3s; }
.pack-row img, .pack-row .ph { width: 110px; height: 110px; object-fit: contain; border-radius: 12px; background: #f8fafc; display: flex; align-items: center; justify-content: center; font-size: 40px; color: #cbd5e1; }
.pack-row .desc b { display: block; font-size: 15px; line-height: 1.3; }
.pack-row .counter { text-align: center; min-width: 120px; }
.pack-row .counter .n { font-size: 30px; font-weight: 800; }
.pack-row .counter .n small { font-size: 16px; color: var(--text-muted); font-weight: 600; }
.pack-row.done { background: var(--ok-light); }
.pack-row.done .counter .n { color: var(--ok); }
.pack-row.flash { background: #fef9c3; }
.pack-row .steps { display: flex; gap: 6px; justify-content: center; margin-top: 6px; }
.pack-row .steps button { width: 36px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 18px; }
@media (max-width: 600px) {
    .pack-row { grid-template-columns: 72px 1fr; }
    .pack-row img, .pack-row .ph { width: 72px; height: 72px; }
    .pack-row .counter { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; }
    .pack-row .counter .steps { margin-top: 0; }
}
.finish-bar { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--border); padding: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; z-index: 30; }
@media (max-width: 600px) { .finish-bar { grid-template-columns: 1fr; } }
.state-banner { padding: 12px 16px; border-radius: 12px; font-weight: 700; display: flex; align-items: center; gap: 10px; font-size: 15px; }
.state-banner.ok { background: var(--ok-light); color: var(--ok); }
.state-banner.pend { background: var(--warn-light); color: #92400e; }

#camera-box { border-radius: 12px; overflow: hidden; background: #000; margin-bottom: 10px; }

/* ── Estación 3 ───────────────────────────────────── */
.addr { font-size: 15px; line-height: 1.5; }
.addr b { font-size: 17px; }
.box-input { display: flex; align-items: center; gap: 10px; }
.box-input button { width: 52px; height: 52px; font-size: 24px; border-radius: 12px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.box-input input { width: 110px; text-align: center; font-size: 26px; font-weight: 800; padding: 8px; }

/* ── Impresión de rótulos 10x15 ───────────────────── */
#print-area { display: none; }
@media print {
    @page { size: 100mm 150mm; margin: 0; }
    html, body { background: #fff !important; }
    body { background: #fff; }
    #app, #toasts, .modal-bg { display: none !important; }
    #print-area { display: block; }
}
.label {
    width: 100mm; height: 150mm;
    padding: 5mm;
    page-break-after: always;
    break-after: page;
    font-family: Arial, Helvetica, sans-serif;
    color: #000;
    display: flex; flex-direction: column;
    position: relative;
    overflow: hidden;
}
.label:last-child { page-break-after: auto; break-after: auto; }
.label .lb-top { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 2mm; }
.label .lb-brand { font-size: 10pt; font-weight: 700; line-height: 1.2; }
.label .lb-brand small { display: block; font-weight: 400; font-size: 7.5pt; }
.label .lb-box { border: 2.5px solid #000; border-radius: 2mm; padding: 1mm 3mm; text-align: center; font-weight: 900; font-size: 20pt; line-height: 1; }
.label .lb-box small { display: block; font-size: 7pt; font-weight: 700; letter-spacing: .05em; }
.label .lb-order { text-align: center; margin: 2mm 0 0; }
.label .lb-order small { font-size: 8pt; font-weight: 700; letter-spacing: .1em; }
.label .lb-order b { display: block; font-size: 34pt; font-weight: 900; line-height: 1; }
.label .lb-bar { text-align: center; }
.label .lb-bar svg { width: 86mm; height: 20mm; }
.label .lb-sec { border-top: 1.5px solid #000; padding: 2mm 0; font-size: 9pt; line-height: 1.3; }
.label .lb-sec .k { font-size: 7pt; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.label .lb-to { font-size: 11pt; }
.label .lb-to b { font-size: 13pt; display: block; }
.label .lb-city { font-size: 15pt; font-weight: 900; text-transform: uppercase; }
.label .lb-carrier { background: #000; color: #fff; text-align: center; font-size: 16pt; font-weight: 900; padding: 2mm; border-radius: 1.5mm; text-transform: uppercase; }
.label .lb-carrier small { display: block; font-size: 10pt; font-weight: 700; letter-spacing: .04em; }
.label .lb-foot { margin-top: auto; font-size: 7pt; display: flex; justify-content: space-between; border-top: 1px solid #000; padding-top: 1.5mm; }
.label.simple { justify-content: center; align-items: center; text-align: center; }
.label.simple .big { font-size: 48pt; font-weight: 900; line-height: 1; }
.label.simple .name { font-size: 14pt; font-weight: 700; margin: 4mm 0; }
.label.simple svg { width: 88mm; height: 34mm; }
.client-head .num .bod { display: block; font-size: 11px; font-weight: 600; color: #cbd5e1; letter-spacing: .02em; }

/* Nota de la línea escrita en Aliaddo */
.inote { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; font-weight: 600; font-size: 15px; display: flex; gap: 6px; align-items: flex-start; white-space: pre-line; }
.inote.sm { margin-top: 4px; padding: 3px 7px; font-size: 12px; display: inline-flex; }

/* ── Celular ──────────────────────────────────────── */
.main, .content { min-width: 0; }
.grid > * { min-width: 0; }
.topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar > * { flex-shrink: 0; }
.topbar h1, .topbar .grow { flex-shrink: 1; }
@media (max-width: 600px) {
    .topbar { gap: 8px; padding: 0 10px; }
    .topbar h1 { font-size: 16px; }
    #bodega-sel { max-width: 132px; padding: 8px 6px; font-size: 13px; }
    #top-actions .btn { padding: 9px 11px; }
    #top-actions .btn span { display: none; }
    #top-actions .btn i { font-size: 18px; }
    .content { padding: 10px; }

    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .kpi { padding: 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
    .kpi .ic { width: 36px; height: 36px; font-size: 19px; border-radius: 10px; }
    .kpi b { font-size: 22px; }

    .card-head.filtros { flex-wrap: wrap; }
    .card-head.filtros .grow { display: none; }
    .card-head.filtros h2 { flex: 1 0 100%; }
    .card-head.filtros select.input { flex: 1 1 40%; }
    .card-head.filtros input.input { flex: 1 1 55%; max-width: none !important; }

    .t th, .t td { padding: 9px 8px; }

    /* Lista de pedidos como tarjetas */
    table.t-cards, .t-cards tbody { display: block; }
    .t-cards thead { display: none; }
    .t-cards tr { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
    .t-cards td { padding: 0; border: 0; min-width: 0; }
    .t-cards .c-num { grid-row: 1; grid-column: 1; font-size: 15px; }
    .t-cards .c-est { grid-row: 1; grid-column: 2; justify-self: end; text-align: right; }
    .t-cards .c-cli { grid-row: 2; grid-column: 1 / -1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .t-cards .c-ciu { grid-row: 3; grid-column: 1; font-size: 12px; color: var(--text-muted); }
    .t-cards .c-bod { grid-row: 3; grid-column: 2; justify-self: end; font-size: 12px; color: var(--text-muted); }
    .t-cards .c-fecha { grid-row: 4; grid-column: 1; font-size: 12px; color: var(--text-muted); }
    .t-cards .c-lin { grid-row: 4; grid-column: 2; justify-self: end; font-size: 12px; color: var(--text-muted); }
    .t-cards .c-lock { grid-row: 5; grid-column: 1 / -1; font-size: 12px; }
    .t-cards .c-lock:empty { display: none; }

    /* Resumen por bodega como bloques */
    table.t-bod, .t-bod tbody { display: block; }
    .t-bod thead { display: none; }
    .t-bod tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
    .t-bod td { padding: 6px 8px; border: 0; background: #f8fafc; border-radius: 8px; text-align: left; font-size: 16px; font-weight: 600; }
    .t-bod td::before { content: attr(data-l); display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
    .t-bod td.c-name { grid-column: 1 / -1; background: none; padding: 0 0 2px; font-size: 15px; }
    .t-bod td.c-name::before { content: none; }

    /* Productos del detalle del pedido como bloques */
    table.t-lin, .t-lin tbody { display: block; }
    .t-lin thead { display: none; }
    .t-lin tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 6px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
    .t-lin td { padding: 0; border: 0; min-width: 0; }
    .t-lin .c-cod { grid-row: 1; grid-column: 1 / 3; font-weight: 600; }
    .t-lin .c-ubi { grid-row: 1; grid-column: 3; text-align: right; color: var(--text-muted); font-size: 12px; }
    .t-lin .c-ubi::before { content: "Ubic. "; }
    .t-lin .c-prod { grid-row: 2; grid-column: 1 / -1; }
    .t-lin td[data-l] { grid-row: 3; text-align: left; background: #f8fafc; border-radius: 6px; padding: 4px 8px; font-weight: 600; }
    .t-lin td[data-l]::before { content: attr(data-l); display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
}

/* Historial del pedido */
.timeline { border-left: 2px solid var(--border); margin-left: 9px; }
.tl-item { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0 6px 14px; position: relative; font-size: 13px; }
.tl-item > i { position: absolute; left: -11px; top: 6px; background: var(--card-bg); color: var(--brand); font-size: 18px; }
.tl-item > div { flex: 1; min-width: 0; padding-left: 8px; }
.tl-item > span { white-space: nowrap; }

/* Reportes */
.rep-card { text-align: left; padding: 16px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; font: inherit; color: inherit; }
.rep-card > i { font-size: 24px; color: var(--brand); }
.rep-card:hover { border-color: var(--brand); }
.rep-card.on { border-color: var(--brand); background: var(--brand-light); }

/* Aviso sin conexión */
#offline { position: fixed; left: 0; right: 0; bottom: 0; z-index: 300; background: var(--bad); color: #fff; font-weight: 600; font-size: 14px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; justify-content: center; text-align: center; }
body:has(#offline) .content { padding-bottom: 80px; }

/* Celular de borde a borde (app Android): la barra de estado y la de gestos no tapan el contenido.
   En el navegador estos márgenes valen 0. */
:root { --safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px)); --safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)); }
.topbar { height: calc(var(--topbar-h) + var(--safe-top)); padding-top: var(--safe-top); }
.sidebar { padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }
.scanbar { top: calc(var(--topbar-h) + var(--safe-top) + 6px); }
#toasts { top: calc(14px + var(--safe-top)); }
.finish-bar { padding-bottom: calc(12px + var(--safe-bottom)); }
.content { padding-bottom: calc(24px + var(--safe-bottom)); }
.login { padding-top: calc(20px + var(--safe-top)); padding-bottom: calc(20px + var(--safe-bottom)); }
.modal-bg { padding-top: calc(16px + var(--safe-top)); padding-bottom: calc(16px + var(--safe-bottom)); }

/* Hojas de contingencia: tamaño carta, una por pedido (los rótulos siguen en 10 x 15 cm) */
@page carta { size: letter; margin: 12mm; }
.hoja { page: carta; break-after: page; font-family: Arial, sans-serif; color: #000; font-size: 10.5pt; }
.hoja:last-child { break-after: auto; }
.hoja .h-top { display: flex; justify-content: space-between; align-items: center; border-bottom: 2.5px solid #000; padding-bottom: 6px; }
.hoja .h-num { font-size: 30pt; font-weight: 900; line-height: 1; }
.hoja .h-sub { font-size: 9.5pt; margin-top: 4px; }
.hoja .h-bar svg { width: 62mm; height: 17mm; }
.hoja .h-cli { padding: 8px 0; border-bottom: 1px solid #000; line-height: 1.45; }
.hoja .h-cli span { font-size: 9pt; }
.hoja .h-obs { font-size: 9.5pt; margin-top: 3px; font-style: italic; }
.hoja .h-t { width: 100%; border-collapse: collapse; margin-top: 10px; }
.hoja .h-t th { text-align: left; font-size: 8.5pt; text-transform: uppercase; border-bottom: 1.5px solid #000; padding: 5px 4px; }
.hoja .h-t td { border-bottom: 1px solid #999; padding: 6px 4px; vertical-align: top; }
.hoja .h-t .r { text-align: right; white-space: nowrap; }
.hoja .h-t .mono { font-family: Consolas, monospace; font-size: 9.5pt; }
.hoja .h-nota { font-size: 8.5pt; font-style: italic; margin-top: 2px; }
.hoja .h-box { display: inline-block; width: 15mm; height: 6mm; border: 1.2px solid #000; border-radius: 2px; vertical-align: middle; }
.hoja .h-campos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 14px; margin-top: 14px; }
.hoja .h-campo small { display: block; font-size: 8pt; text-transform: uppercase; font-weight: 700; }
.hoja .h-campo span { display: block; border-bottom: 1.2px solid #000; height: 8mm; }
.hoja .h-pie { margin-top: 14px; font-size: 8pt; border-top: 1px solid #000; padding-top: 5px; }

/* Ajustes: remitente general y por bodega */
.remitente + .remitente { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.remitente h4 { font-size: 14px; margin-bottom: 8px; }
.remitente input::placeholder { color: #94a3b8; font-style: italic; }
.pin-show { font-size: 40px; font-weight: 800; letter-spacing: .25em; text-align: center; margin: 18px 0 6px; padding: 14px; background: var(--brand-light); border-radius: 12px; }

/* Modo capacitación: violeta para que nunca se confunda con el portal real (naranja) */
body.capacitacion .topbar { background: #6d28d9; border-bottom-color: #5b21b6; color: #fff; }
body.capacitacion .topbar h1, body.capacitacion .topbar .menu-btn { color: #fff; }
body.capacitacion .sidebar { box-shadow: inset 4px 0 0 #7c3aed; }
.cap-chip { display: inline-flex; align-items: center; gap: 5px; background: #fff; color: #6d28d9; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 4px 10px; border-radius: 999px; }
.cap-box { margin: 10px 14px; padding: 12px; border-radius: 10px; background: #4c1d95; color: #ede9fe; font-size: 12px; line-height: 1.4; display: flex; flex-direction: column; gap: 8px; }
.cap-box b { font-size: 13px; color: #fff; display: flex; align-items: center; gap: 6px; }
.cap-box .btn { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); justify-content: center; }
.cap-login { background: #6d28d9; color: #fff; text-align: center; font-weight: 800; letter-spacing: .05em; padding: 12px 14px; border-radius: 12px 12px 0 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cap-login i { font-size: 26px; }
.cap-login span { font-weight: 500; letter-spacing: 0; font-size: 12px; opacity: .9; }
body.capacitacion .login { background: #2e1065; }
.cap-link { background: none; border: none; color: #6d28d9; font-weight: 600; font-size: 14px; cursor: pointer; padding: 6px; display: flex; align-items: center; justify-content: center; gap: 6px; }
body.capacitacion .topbar select { color: var(--text); }
.cap-chip { flex-shrink: 0; }
@media (max-width: 480px) { .cap-chip { padding: 3px 8px; font-size: 11px; } }
.cap-entrar { margin: 6px 14px 10px; padding: 9px 12px; border-radius: 10px; border: 1px dashed rgba(167,139,250,.6); background: none; color: #c4b5fd; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; }
