/* DSD CORE — tema ERP empresarial: fondo turquesa claro, tarjetas KPI blancas, azul corporativo (shell, launchpad, diálogos). */
:root {
  --bg: #e6f3f5; --bg-grad: linear-gradient(180deg, #b9e0e8 0%, #d3ecf0 22%, #e9f5f7 60%, #f2f8f9 100%);
  --surface: #ffffff; --surface-2: #f3f6f8; --hover: #e8f1f8; --select: #dcecfa;
  --text: #22313f; --text-2: #3d4b58; --muted: #5f6f7d; --border: #dfe5e9; --border-2: #b8c3cc; --field: #7d8b97;
  --brand: #0a6ed1; --brand-2: #085caf; --brand-dark: #054a8d; --brand-soft: #e3f0fc; --brand-ink: #ffffff;
  --shell: #ffffff; --shell-text: #22313f; --side-bg: #f6f8f9;
  --up: #2b9a3d; --down: #d9363e;
  --c1: #1f77c4; --c2: #e8743b; --c3: #19a979; --c4: #945ecf; --c5: #c9a400; --c6: #d6457a;
  --amber: #b44f00; --amber-soft: #fff3b8; --blue: #0064d9; --blue-soft: #e5f0fa; --violet: #7800a4; --violet-soft: #f8e6ff;
  --cyan: #046c7a; --cyan-soft: #dafdf5; --green: #256f3a; --green-soft: #f5fae5; --orange: #c35500; --orange-soft: #fff8d6;
  --red: #aa0808; --red-soft: #ffeaf4; --gray: #556b82; --gray-soft: #eff1f2;
  --sh0: 0 0 .125rem rgba(34, 53, 72, .15), 0 .125rem .5rem rgba(34, 53, 72, .15);
  --sh1: 0 0 .125rem rgba(34, 53, 72, .15), 0 .5rem 1rem rgba(34, 53, 72, .15);
  --sh2: 0 0 .125rem rgba(34, 53, 72, .15), 0 1rem 2rem rgba(34, 53, 72, .15);
  --shadow: var(--sh0); --shadow-lg: var(--sh2);
  --r: 6px; --r-sm: 6px; --side: 15rem; --shell-h: 3.25rem;
  --ease: cubic-bezier(.4, 0, .2, 1);
}
/* Tema oscuro opcional (menú de usuario → Tema oscuro) */
:root[data-theme="dark"] {
    --bg: #12171c; --bg-grad: linear-gradient(180deg, #0f2a33 0%, #12191f 40%, #12171c 100%);
    --surface: #1d232a; --surface-2: #232a31; --hover: #2b333c; --select: #18293d;
    --text: #eaecee; --text-2: #c9d0d6; --muted: #a9b4be; --border: #333c46; --border-2: #5b6874; --field: #8396a8;
    --brand: #4db1ff; --brand-2: #79c6ff; --brand-dark: #a6e0ff; --brand-soft: #14304c; --brand-ink: #10161c;
    --shell: #1d232a; --shell-text: #eaecee; --side-bg: #1a2026; --up: #6fd36b; --down: #ff7a7a;
    --c1: #4da3ff; --c2: #ff9a5c; --c3: #3fd0a0; --c4: #b98cf0; --c5: #e3c23a; --c6: #f07aa6;
    --amber: #ffc847; --amber-soft: #3a2c00; --blue: #4db1ff; --blue-soft: #14304c; --violet: #e397ff; --violet-soft: #3a1a47;
    --cyan: #4ce0c8; --cyan-soft: #0f3b38; --green: #97dd40; --green-soft: #213516; --orange: #ffab3d; --orange-soft: #3d2a10;
    --red: #ff8888; --red-soft: #4a1a24; --gray: #a9b4be; --gray-soft: #2b333c;
    --sh0: 0 0 .125rem rgba(0, 0, 0, .5), 0 .125rem .5rem rgba(0, 0, 0, .5);
    --sh1: 0 0 .125rem rgba(0, 0, 0, .5), 0 .5rem 1rem rgba(0, 0, 0, .5);
    --sh2: 0 0 .125rem rgba(0, 0, 0, .5), 0 1rem 2rem rgba(0, 0, 0, .55);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.4 "72", "72full", -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-grad) fixed, var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 700; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .small { font-size: 12px; } .strong { font-weight: 700; }
.hide { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-dark); outline-offset: 1px; }

/* ── Shell bar ── */
.shell { position: fixed; z-index: 60; top: 0; left: 0; right: 0; height: var(--shell-h); background: var(--shell); color: var(--shell-text);
  display: flex; align-items: center; gap: .5rem; padding: 0 .75rem; box-shadow: var(--sh0); }
.shell .brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 16px; padding: 0 .5rem; color: inherit; white-space: nowrap; }
.shell .brand:hover { text-decoration: none; }
.shell .logo { width: 28px; height: 28px; border-radius: 8px; background: #175aa5; display: grid; place-items: center; color: #fff; }
.shell .logo svg { width: 20px; height: 20px; }
.auth-hero .logo svg { width: 24px; height: 24px; }
.shell .app-title { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: .75rem; border-left: 1px solid var(--border); }
.shell .grow { flex: 1; }
.sbtn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; transition: background .15s; }
.sbtn:hover { background: var(--hover); } .sbtn svg.i { width: 18px; height: 18px; }
.sbtn .dotc { position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; border-radius: 8px; background: #d20a0a; color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; animation: popin .25s var(--ease); }
.shell .avatar { cursor: pointer; }
.rate-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.rate-chip.old { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.live { background: #30914c; box-shadow: 0 0 0 3px rgba(48, 145, 76, .2); animation: pulse 2s infinite; }
.dot.off { background: #d20a0a; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(48, 145, 76, 0); } }

/* ── Navegación lateral ── */
.app { padding-top: var(--shell-h); min-height: 100vh; }
.side { position: fixed; z-index: 50; top: var(--shell-h); bottom: 0; left: 0; width: var(--side); background: var(--side-bg); border-right: 1px solid var(--border);
  padding: .5rem; overflow-y: auto; overflow-x: hidden; transition: width .25s var(--ease), transform .25s var(--ease); }
.nav-label { font-size: 12px; font-weight: 700; color: var(--muted); padding: .75rem .75rem .25rem; white-space: nowrap; }
.nav a { display: flex; align-items: center; gap: .75rem; height: 2.5rem; padding: 0 .75rem; border-radius: 8px; color: var(--text); white-space: nowrap; margin: 1px 0; position: relative; transition: background .15s; }
.nav a:hover { background: var(--hover); text-decoration: none; }
.nav a.on { background: var(--select); color: var(--brand-2); font-weight: 700; }
.nav a.on::before { content: ""; position: absolute; left: 0; top: .5rem; bottom: .5rem; width: 3px; border-radius: 2px; background: var(--brand); }
.nav a svg.i { color: var(--muted); } .nav a.on svg.i { color: var(--brand-2); }
.nav a .count { margin-left: auto; background: var(--brand); color: var(--brand-ink); font-size: 11px; font-weight: 700; padding: 0 7px; border-radius: 99px; line-height: 18px; }
.main { margin-left: var(--side); transition: margin-left .25s var(--ease); min-width: 0; overflow-x: clip; }
.collapsed .side { width: 3.5rem; } .collapsed .main { margin-left: 3.5rem; }
.collapsed .side .nav-label, .collapsed .side .nav a span { display: none; }
.collapsed .side .nav a { justify-content: center; padding: 0; }
.scrim { position: fixed; inset: var(--shell-h) 0 0 0; background: rgba(0, 0, 0, .35); z-index: 45; animation: fade .2s; }

/* ── Página dinámica ── */
.page-head { background: transparent; padding: 1rem 2rem .25rem; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: .25rem; display: flex; gap: .375rem; align-items: center; }
.crumbs a { color: var(--brand-2); }
.page-head h1 { font-size: 20px; }
.view { padding: 1rem 2rem 3rem; max-width: 1600px; }
.view.enter { animation: slideIn .28s var(--ease); } .view.back { animation: slideBack .28s var(--ease); }
@keyframes slideIn { from { opacity: 0; transform: translateX(1.5rem); } }
@keyframes slideBack { from { opacity: 0; transform: translateX(-1.5rem); } }
@keyframes fade { from { opacity: 0; } }
@keyframes popin { from { transform: scale(.4); opacity: 0; } }
.tabbar { display: none; }

/* ── Launchpad ── */
.lp-section { margin: 1.25rem 0 .5rem; display: flex; align-items: baseline; gap: .75rem; }
.lp-section h2 { font-size: 16px; } .lp-section span { font-size: 12px; color: var(--muted); }
.tiles { display: flex; flex-wrap: wrap; gap: .5rem; }
.tile { width: 11rem; height: 11rem; border-radius: var(--r); background: var(--surface); box-shadow: var(--sh0); padding: 1rem; display: flex; flex-direction: column;
  color: var(--text); position: relative; cursor: pointer; transition: box-shadow .2s var(--ease), transform .12s var(--ease), background .15s;
  animation: tileIn .4s var(--ease) both; }
.tile:hover { box-shadow: var(--sh1); text-decoration: none; }
.tile:active { transform: scale(.97); background: var(--hover); }
.tile .tt { font-weight: 700; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding-right: 1.5rem; }
.tile .ts { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile .ti { position: absolute; top: 1rem; right: 1rem; color: var(--muted); }
.tile .tf { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: .5rem; }
.tile .tn { font-size: 2.25rem; font-weight: 300; line-height: 1; letter-spacing: -.02em; }
.tile .tn.good { color: var(--green); } .tile .tn.bad { color: var(--red); } .tile .tn.warn { color: var(--amber); }
.tile .tu { font-size: 12px; color: var(--muted); }
.tile .tbig svg.i { width: 2.25rem; height: 2.25rem; color: var(--brand); stroke-width: 1.5; }
.tile.wide { width: 22.5rem; }
.tile .step { position: absolute; left: 1rem; bottom: 1rem; font-size: 11px; font-weight: 700; color: var(--brand-2); }
.noanim .tile { animation: none; }
@keyframes tileIn { from { opacity: 0; transform: translateY(.5rem) scale(.98); } }
.process { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; padding: .75rem 1rem; background: var(--surface); border-radius: var(--r); box-shadow: var(--sh0); }
.process a { display: inline-flex; align-items: center; gap: .375rem; padding: .375rem .625rem; border-radius: 8px; color: var(--text); font-weight: 700; font-size: 13px; }
.process a:hover { background: var(--hover); text-decoration: none; }
.process a b { width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 11px; }
.process .arr { color: var(--muted); }

/* ── Componentes ── */
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh0); }
.card-h { display: flex; align-items: center; gap: .625rem; padding: .875rem 1rem; border-bottom: 1px solid var(--border); min-height: 3rem; }
.card-h h2, .card-h h3 { flex: 1; font-size: 16px; }
.card-b { padding: 1rem; }
.grid { display: grid; gap: 1rem; }
.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)); }
.span2 { grid-column: span 2; }
.row { display: flex; align-items: center; gap: .625rem; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.between { justify-content: space-between; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .375rem; height: 2.25rem; padding: 0 .75rem; border-radius: 8px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--brand-2); font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s; text-decoration: none !important; }
.btn:hover { background: var(--hover); } .btn:active { transform: scale(.98); background: var(--select); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.danger { color: var(--red); border-color: #ff8888; } .btn.danger:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 1.75rem; padding: 0 .5rem; font-size: 13px; }
.btn.lg { height: 2.75rem; padding: 0 1rem; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.icon-btn { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 8px; border: 0; background: transparent; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--hover); }

.field { display: flex; flex-direction: column; gap: .25rem; }
.field > span { font-size: 14px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; height: 2.25rem; padding: 0 .625rem; border: 1px solid var(--border-2); border-radius: 4px;
  box-shadow: inset 0 -1px 0 var(--field); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:hover { border-color: var(--field); background: var(--hover); }
.input:focus { outline: 2px solid var(--brand-dark); outline-offset: 0; border-color: var(--brand-dark); background: var(--surface); }
textarea.input { height: auto; min-height: 4.5rem; padding: .5rem .625rem; resize: vertical; }
.search { position: relative; } .search svg { position: absolute; left: .625rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 2.125rem; border-radius: 18px; box-shadow: none; background: var(--surface-2); border-color: transparent; }
.search .input:hover { border-color: var(--border-2); }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; flex-wrap: wrap; background: var(--surface); }
.seg button { border: 0; border-right: 1px solid var(--border-2); background: transparent; height: 2.125rem; padding: 0 .75rem; cursor: pointer; font-weight: 700; color: var(--brand-2); font-size: 13px; transition: background .12s; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--hover); }
.seg button.on { background: var(--brand); color: var(--brand-ink); }

/* Estado de objeto (tag) */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 1.25rem; padding: 0 .375rem; border-radius: 4px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--gray-soft); color: var(--gray); }
.s-pendiente, .s-borrador { background: var(--amber-soft); color: var(--amber); }
.s-picking, .s-enviada { background: var(--blue-soft); color: var(--blue); }
.s-preparado { background: var(--violet-soft); color: var(--violet); }
.s-en_ruta, .s-planificado { background: var(--cyan-soft); color: var(--cyan); }
.s-entregado, .s-cerrado, .s-venta, .s-recibida, .s-emitida, .s-facturado { background: var(--green-soft); color: var(--green); }
.s-parcial { background: var(--orange-soft); color: var(--orange); }
.s-rechazado, .s-faltante, .s-cupo, .s-vencido, .s-anulada { background: var(--red-soft); color: var(--red); }
.s-anulado, .s-sync { background: var(--gray-soft); color: var(--gray); }
.s-incompleto, .s-pronto { background: var(--orange-soft); color: var(--orange); }

/* Tabla */
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 13px; font-weight: 400; color: var(--muted); padding: .625rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface); white-space: nowrap; position: sticky; top: 0; }
.t td { padding: .625rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; height: 2.75rem; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr { transition: background .1s; }
.t tbody tr.click { cursor: pointer; } .t tbody tr.click:hover { background: var(--hover); }
.t tbody tr.click:active { background: var(--select); }
.t .r { text-align: right; }
.t td.num, .t td.r { white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty svg { width: 2.5rem; height: 2.5rem; opacity: .5; margin-bottom: .5rem; stroke-width: 1.5; }

/* KPIs */
.kpi { padding: 1rem; }
.kpi .label { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: .375rem; }
.kpi .value { font-size: 1.75rem; font-weight: 300; letter-spacing: -.01em; margin-top: .25rem; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: .125rem; }
.delta-up { color: var(--green); } .delta-down { color: var(--red); }

/* Flujo / pipeline */
.flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.flow .st { color: inherit; padding: .75rem 1rem; border-radius: 8px; background: var(--surface-2); position: relative; transition: background .15s; }
.flow .st:hover { background: var(--hover); text-decoration: none; }
.flow .st b { display: block; font-size: 1.75rem; font-weight: 300; }
.flow .st span { font-size: 12px; color: var(--muted); }
.flow .st::after { content: "›"; position: absolute; right: -8px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 18px; }
.flow .st:last-child::after { display: none; }

/* Gráfico de barras */
.bars { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: 8px; }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; }
.bars .b i { display: block; width: 100%; max-width: 32px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .8; transition: opacity .15s; transform-origin: bottom; animation: grow .6s var(--ease) both; }
.bars .b:hover i, .bars .b.today i { opacity: 1; }
@keyframes grow { from { transform: scaleY(0); } }
.bars .b .tip { position: absolute; bottom: calc(100% + 4px); background: var(--surface); color: var(--text); box-shadow: var(--sh1); font-size: 12px; padding: .375rem .5rem; border-radius: 8px; white-space: nowrap; pointer-events: none; opacity: 0; transform: translateY(4px); transition: .12s; z-index: 2; }
.bars .b:hover .tip { opacity: 1; transform: none; }
.bars-x { display: flex; gap: 2px; border-top: 1px solid var(--border); padding-top: 6px; }
.bars-x span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.hbar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }

/* Lista */
.list > * { border-bottom: 1px solid var(--border); }
.list > *:last-child { border-bottom: 0; }
.li { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; transition: background .1s; }
.li.click { cursor: pointer; } .li.click:hover { background: var(--hover); }

/* Kanban almacén */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(280px, 1fr)); gap: 1rem; align-items: start; }
.col { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh0); min-height: 200px; }
.col-h { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem; font-weight: 700; border-bottom: 1px solid var(--border); }
.col-h .n { margin-left: auto; font-size: 12px; background: var(--surface-2); padding: 0 8px; border-radius: 99px; line-height: 20px; }
.col-b { padding: .5rem; display: flex; flex-direction: column; gap: .5rem; }
.ocard { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .75rem; cursor: pointer; position: relative; transition: box-shadow .15s, transform .12s, border-color .15s; }
.ocard:hover { box-shadow: var(--sh1); border-color: transparent; }
.ocard:active { transform: scale(.99); }
.ocard.fresh { animation: fresh 2.5s ease-out; }
@keyframes fresh { 0% { box-shadow: 0 0 0 2px var(--brand); background: var(--brand-soft); } 100% { box-shadow: none; } }
.ocard .meta { display: flex; gap: .625rem; font-size: 12px; color: var(--muted); margin-top: .375rem; flex-wrap: wrap; align-items: center; }
.ocard .meta svg.i { width: 13px; height: 13px; }
.ocard input[type=checkbox] { position: absolute; top: .75rem; right: .75rem; width: 18px; height: 18px; accent-color: var(--brand); }

/* Diálogos (abren con escala + desvanecimiento y cierran igual) */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1.25rem; animation: fade .2s var(--ease); }
.overlay.closing { animation: fadeOut .18s var(--ease) forwards; }
.overlay.closing .modal { animation: dlgOut .18s var(--ease) forwards; }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes dlgOut { to { opacity: 0; transform: scale(.94); } }
.modal { background: var(--surface); border-radius: var(--r); width: 100%; max-width: 640px; max-height: calc(100vh - 2.5rem); display: flex; flex-direction: column; box-shadow: var(--sh2); animation: dlgIn .22s var(--ease); overflow: hidden; }
.modal.wide { max-width: 980px; }
@keyframes dlgIn { from { transform: scale(.94); opacity: 0; } }
.modal-h { display: flex; align-items: center; gap: .625rem; padding: 0 1rem; min-height: 3rem; border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 var(--border); }
.modal-h h2 { flex: 1; font-size: 16px; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .625rem 0; }
.modal-b { padding: 1rem; overflow-y: auto; background: var(--surface); }
.modal-f { display: flex; gap: .5rem; justify-content: flex-end; padding: .5rem 1rem; min-height: 3rem; align-items: center; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* Popover (notificaciones, usuario, tasa) */
.popover { position: fixed; z-index: 90; top: calc(var(--shell-h) + 6px); right: .75rem; width: 22rem; max-width: calc(100vw - 1.5rem); max-height: 70vh; overflow: auto;
  background: var(--surface); border-radius: var(--r); box-shadow: var(--sh2); transform-origin: top right; animation: popIn .2s var(--ease); }
@keyframes popIn { from { opacity: 0; transform: scale(.92) translateY(-6px); } }
.popover .ph { padding: .75rem 1rem; font-weight: 700; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.notif { display: flex; gap: .625rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif:hover { background: var(--hover); }
.notif .ic { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-2); flex: none; }

/* Message toast (centrado abajo) */
.toasts { position: fixed; z-index: 200; bottom: 4rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
.toast { background: rgba(29, 45, 62, .92); color: #fff; padding: .75rem 1rem; border-radius: 8px; box-shadow: var(--sh1); display: flex; align-items: center; gap: .5rem; max-width: 26rem; animation: toastIn .25s var(--ease); pointer-events: auto; }
.toast.err { background: #aa0808; } .toast.ok svg { color: #97dd40; }
@keyframes toastIn { from { opacity: 0; transform: translateY(.75rem); } }

/* Indicador de carga (tres puntos) */
.busy { display: flex; justify-content: center; gap: .375rem; padding: 3rem 0; }
.busy i { width: .5rem; height: .5rem; border-radius: 50%; background: var(--brand); animation: busy 1.2s infinite ease-in-out both; }
.busy i:nth-child(1) { animation-delay: -.32s; } .busy i:nth-child(2) { animation-delay: -.16s; }
@keyframes busy { 0%, 80%, 100% { transform: scale(.4); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

/* Timeline */
.tl { position: relative; padding-left: 20px; }
.tl::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl .ev { position: relative; padding-bottom: 12px; animation: tileIn .3s var(--ease) both; }
.tl .ev::before { content: ""; position: absolute; left: -19px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); }

/* Login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: #175aa5; color: #fff; padding: 3rem; display: flex; flex-direction: column; gap: 1.75rem; justify-content: center; }
.auth-hero h1 { font-size: 2.25rem; font-weight: 300; max-width: 32rem; line-height: 1.2; }
.auth-hero p { font-size: 16px; opacity: .9; max-width: 30rem; margin: 0; }
.auth-hero .brand { display: flex; gap: .625rem; align-items: center; font-weight: 700; font-size: 18px; }
.auth-hero .brand small { display: block; font-weight: 400; font-size: 12px; opacity: .8; }
.auth-hero .logo { width: 36px; height: 36px; border-radius: 10px; background: rgba(255, 255, 255, .2); display: grid; place-items: center; }
.auth-flow { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-weight: 700; font-size: 13px; }
.auth-flow span { background: rgba(255, 255, 255, .14); padding: .375rem .75rem; border-radius: 99px; display: inline-flex; align-items: center; gap: .375rem; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; background: var(--surface); }
.auth-form .box { width: 100%; max-width: 380px; animation: tileIn .4s var(--ease); }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.demo-grid button { text-align: left; padding: .625rem .75rem; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface); cursor: pointer; display: flex; gap: .5rem; align-items: center; font-weight: 700; color: var(--brand-2); transition: background .12s; }
.demo-grid button:hover { background: var(--hover); }

/* Campo móvil (preventa / reparto) */
.cart-bar { position: sticky; bottom: 0; margin: 1rem -2rem -3rem; padding: .625rem 2rem; background: var(--surface); box-shadow: 0 -1px 0 var(--border), 0 -.25rem .75rem rgba(34, 53, 72, .08); display: flex; align-items: center; gap: .75rem; z-index: 5; }
.prod { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; }
.prod .ph { width: 2.5rem; height: 2.5rem; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; flex: none; }
.stepper button { width: 2.375rem; height: 2.375rem; border: 0; background: var(--surface); cursor: pointer; font-size: 18px; font-weight: 700; color: var(--brand-2); }
.stepper button:active { background: var(--select); }
.stepper input { width: 2.75rem; height: 2.375rem; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; background: var(--surface); font-weight: 700; -moz-appearance: textfield; outline: none; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stop { display: flex; gap: .75rem; padding: .875rem 1rem; align-items: flex-start; transition: background .1s; }
.stop.click:hover, .stop[data-c]:hover { background: var(--hover); }
.stop .seq { width: 1.875rem; height: 1.875rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--surface-2); flex: none; }
.stop.done .seq { background: var(--green-soft); color: var(--green); }
.chips { display: flex; gap: .375rem; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips button { border: 1px solid var(--border-2); background: var(--surface); height: 2rem; padding: 0 .75rem; border-radius: 99px; font-weight: 700; font-size: 13px; white-space: nowrap; cursor: pointer; color: var(--text-2); transition: background .12s; }
.chips button:hover { background: var(--hover); }
.chips button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
/* Message strip */
.banner { padding: .625rem .875rem; border-radius: 8px; display: flex; gap: .625rem; align-items: center; margin-bottom: .875rem; border: 1px solid; }
.banner.warn { background: var(--amber-soft); color: var(--text); border-color: #e76500; } .banner.warn svg { color: #e76500; }
.banner.info { background: var(--brand-soft); color: var(--text); border-color: var(--brand); } .banner.info svg { color: var(--brand); }
.banner.err { background: var(--red-soft); color: var(--text); border-color: #d20a0a; } .banner.err svg { color: #d20a0a; }
.banner.ok { background: var(--green-soft); color: var(--text); border-color: var(--green); } .banner.ok svg { color: var(--green); }
.progress { height: .375rem; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand); transition: width .5s var(--ease); }

/* Documento imprimible (factura / orden de compra) */
.doc { background: #fff; color: #000; font: 12px/1.35 Arial, Helvetica, sans-serif; padding: 1.5rem; border-radius: 4px; }
.doc h1 { font-size: 18px; } .doc table { width: 100%; border-collapse: collapse; }
.doc th, .doc td { border: 1px solid #999; padding: 4px 6px; } .doc th { background: #eee; text-align: left; }
.doc .r { text-align: right; } .doc .box { border: 1px solid #999; padding: 6px 8px; }
.doc .head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.doc .tot td { border: 0; padding: 2px 6px; }
.doc .void { color: #c00; font-size: 28px; font-weight: 700; border: 3px solid #c00; display: inline-block; padding: 2px 12px; transform: rotate(-8deg); }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kanban { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .side { transform: translateX(-105%); width: 17rem; }
  .nav-open .side { transform: none; box-shadow: var(--sh2); }
  .main, .collapsed .main { margin-left: 0; }
  .collapsed .side .nav-label, .collapsed .side .nav a span { display: initial; }
  .shell .app-title, .shell .conn span, .hide-m { display: none !important; }
  .only-m { display: inline !important; }
  .page-head { padding: .75rem 1rem .5rem; }
  .view { padding: .75rem 1rem 6rem; }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow { grid-template-columns: repeat(2, 1fr); } .flow .st::after { display: none; }
  .tile { width: calc(33.333% - .34rem); height: 8rem; padding: .75rem; } .tile.wide { width: calc(66.666% - .17rem); } .tile .tn { font-size: 1.75rem; }
  .tile .ti { top: .75rem; right: .75rem; }
  .tabbar { display: flex; position: fixed; z-index: 50; bottom: 0; left: 0; right: 0; background: var(--surface); box-shadow: 0 -1px 0 var(--border); padding: .25rem .25rem calc(.25rem + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .25rem 0; font-size: 11px; font-weight: 700; color: var(--muted); position: relative; border-radius: 8px; }
  .tabbar a.on { color: var(--brand-2); background: var(--select); }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a .count { position: absolute; top: 0; left: 55%; background: #d20a0a; color: #fff; font-size: 10px; padding: 0 5px; border-radius: 99px; }
  .tabbar svg.i { width: 22px; height: 22px; }
  .cart-bar { position: fixed; bottom: calc(3.75rem + env(safe-area-inset-bottom)); left: 0; right: 0; margin: 0; padding: .625rem 1rem; }
  .overlay { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { max-width: none; border-radius: 1rem 1rem 0 0; max-height: 92vh; animation: sheetIn .28s var(--ease); }
  .overlay.closing .modal { animation: sheetOut .2s var(--ease) forwards; }
  @keyframes sheetIn { from { transform: translateY(100%); } }
  @keyframes sheetOut { to { transform: translateY(100%); } }
  .auth { grid-template-columns: 1fr; } .auth-hero { padding: 1.75rem 1.25rem; gap: .875rem; } .auth-hero h1 { font-size: 1.625rem; } .auth-hero p { font-size: 14px; }
  .t th, .t td { padding: .5rem .625rem; }
  .toasts { bottom: 5rem; width: calc(100% - 2rem); } .toast { width: 100%; }
  .cart-bar ~ * { margin-bottom: 4rem; }
}
@media (min-width: 861px) { .only-m { display: none !important; } }

/* ── Tarjeta KPI con tendencia (▲ verde / ▼ rojo) ── */
.kc { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh0); padding: .875rem 1rem; display: flex; flex-direction: column; min-height: 8.5rem; color: var(--text); animation: tileIn .35s var(--ease) both; }
a.kc:hover { text-decoration: none; box-shadow: var(--sh1); }
.kc .kt { font-size: 13px; font-weight: 700; }
.kc .kv { margin-top: auto; display: flex; align-items: center; gap: .375rem; font-size: 2.25rem; font-weight: 300; line-height: 1; letter-spacing: -.01em; }
.kc .kv .tri { font-size: 1.25rem; }
.kc .kv.up { color: var(--up); } .kc .kv.down { color: var(--down); } .kc .kv.info { color: var(--brand); }
.kc .ku { font-size: 12px; color: var(--muted); margin-top: .25rem; }
.kc .kf { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-top: .25rem; }
.kc .kd { font-weight: 700; } .kc .kd.up { color: var(--up); } .kc .kd.down { color: var(--down); }
.kgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: .75rem; }

/* ── Gráficos: dona y barras horizontales ── */
.donut-wrap { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex: none; }
.donut path { stroke: var(--surface); stroke-width: 2; transition: transform .15s var(--ease); transform-origin: 75px 75px; cursor: default; }
.donut path:hover { transform: scale(1.04); }
.legend { display: flex; flex-direction: column; gap: .375rem; font-size: 12px; flex: 1; min-width: 150px; }
.legend div { display: flex; align-items: center; gap: .5rem; }
.legend i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.legend span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars { display: flex; flex-direction: column; gap: .5rem; }
.hbars .hb { display: grid; grid-template-columns: minmax(6rem, 40%) 1fr auto; gap: .5rem; align-items: center; font-size: 12px; }
.hbars .hb span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars .hb i { display: block; height: 14px; border-radius: 0 4px 4px 0; background: var(--c1); transform-origin: left; animation: growX .6s var(--ease) both; }
@keyframes growX { from { transform: scaleX(0); } }
.vbars { display: flex; align-items: flex-end; gap: .75rem; height: 150px; border-bottom: 1px solid var(--border); padding: 0 .5rem; }
.vbars .vb { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; position: relative; cursor: pointer; }
.vbars .vb i { width: 100%; max-width: 48px; background: var(--c1); border-radius: 4px 4px 0 0; min-height: 2px; animation: grow .6s var(--ease) both; transform-origin: bottom; }
.vbars .vb b { font-size: 11px; font-weight: 700; }
.vbars .vb.on i { background: var(--brand-dark); }
.vbars-x { display: flex; gap: .75rem; padding: 4px .5rem 0; } .vbars-x span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }

/* ── Estado de cuenta: 4 tarjetas + gráfico compacto en la misma fila ── */
.st-top { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(17rem, 1.5fr); gap: .75rem; margin-bottom: 1rem; align-items: stretch; }
.st-top .kc { min-height: 0; }
.st-chart { display: flex; flex-direction: column; padding: .75rem 1rem .5rem; }
.st-chart .kt { font-size: 13px; font-weight: 700; margin-bottom: .25rem; }
.vbars.sm { height: 82px; gap: .5rem; padding: 0 .25rem; }
.vbars.sm .vb b { font-size: 10px; }
.vbars.sm .vb i { max-width: 34px; }
.vbars.sm + .vbars-x { gap: .5rem; padding: 2px .25rem 0; } .vbars.sm + .vbars-x span { font-size: 10px; white-space: nowrap; }
.st-mid { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); gap: 1rem; margin-bottom: 1rem; align-items: start; }
@media (max-width: 1250px) { .st-top { grid-template-columns: repeat(4, minmax(0, 1fr)); } .st-top .st-chart { grid-column: 1 / -1; } }
@media (max-width: 860px) { .st-top { grid-template-columns: repeat(2, minmax(0, 1fr)); } .st-mid { grid-template-columns: 1fr; } }

/* ── Íconos circulares (app móvil) ── */
.circles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem .5rem; padding: 1rem .5rem; background: var(--surface); border-radius: var(--r); box-shadow: var(--sh0); margin-bottom: 1rem; }
.circle { display: flex; flex-direction: column; align-items: center; gap: .375rem; color: var(--brand); font-size: 12px; font-weight: 700; text-align: center; border: 0; background: none; cursor: pointer; padding: 0; }
.circle:hover { text-decoration: none; }
.circle .cc { width: 3.5rem; height: 3.5rem; border-radius: 50%; border: 2px solid var(--brand); display: grid; place-items: center; position: relative; background: var(--surface); transition: background .15s, transform .1s; }
.circle:active .cc { transform: scale(.94); background: var(--brand-soft); }
.circle .cc svg.i { width: 1.5rem; height: 1.5rem; stroke-width: 1.6; }
.circle .bd { position: absolute; top: -4px; right: -8px; background: #d9363e; color: #fff; font-size: 10px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 5px; border: 2px solid var(--surface); }

@media (max-width: 860px) {
  .shell { background: #175aa5; color: #fff; box-shadow: none; } /* un solo color, sin degradado */
  .shell .sbtn { color: #fff; } .shell .sbtn:hover { background: rgba(255, 255, 255, .15); }
  .shell .logo { background: rgba(255, 255, 255, .18); }
  .rate-chip { background: rgba(255, 255, 255, .15); border-color: transparent; color: #fff; }
  .rate-chip.old { background: #ffcf5c; color: #3a2a00; }
  .kgrid { grid-template-columns: repeat(2, 1fr); } .kc { min-height: 7rem; } .kc .kv { font-size: 1.75rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Impresión: solo el documento */
@media print {
  body { background: #fff; }
  body.printing > *:not(.print-root) { display: none !important; }
  .print-root { display: block !important; }
  .print-root .doc { padding: 0; }
  .shell, .side, .tabbar, .toolbar, .page-head .btn, .toasts { display: none !important; }
  .main { margin: 0 !important; } .app { padding: 0; }
  @page { size: letter; margin: 12mm; }
}
.print-root { display: none; }

/* ── Escáner con cámara ── */
.scan-box { position: relative; background: #000; border-radius: var(--r); overflow: hidden; aspect-ratio: 4 / 3; max-height: 50vh; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: #ff3b3b; box-shadow: 0 0 8px #ff3b3b; animation: scanY 1.8s ease-in-out infinite alternate; }
@keyframes scanY { from { top: 30%; } to { top: 70%; } }
.scan-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; text-align: center; padding: 1rem; font-size: 13px; pointer-events: none; }
.scan-msg:empty { display: none; }
.hit { animation: hit 1s ease-out; } @keyframes hit { from { background: var(--green-soft); } }
.pick-ok { background: var(--green-soft) !important; }

/* ── Barra de anclas del Inicio (estilo Fiori): áreas del usuario; tocar desplaza hasta el grupo ── */
/* Franja fija con el mismo fondo de la página: lo que se desplaza pasa por debajo sin verse cortado detrás de la barra */
.anchor-wrap { position: sticky; top: var(--shell-h); z-index: 20; margin: -1rem -2rem 0; padding: 1rem 2rem .75rem;
  background: var(--bg-grad) fixed, var(--bg); }
.anchor-bar { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none;
  padding: 0 .5rem; background: var(--surface); border-radius: var(--r); box-shadow: var(--sh0); }
.main.is-home .page-head { display: none; }
.main.is-home .view { padding-top: 1rem; padding-bottom: 45vh; } /* espacio para que también los últimos grupos suban hasta la barra */
.anchor-bar::-webkit-scrollbar { display: none; }
.anchor-bar button { position: relative; flex: none; display: inline-flex; align-items: center; gap: .4rem; height: 2.75rem; padding: 0 .875rem;
  border: 0; background: transparent; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--text-2); transition: color .15s; }
.anchor-bar button svg.i { color: var(--muted); transition: color .15s; }
.anchor-bar button:hover { color: var(--brand-2); }
.anchor-bar button::after { content: ""; position: absolute; left: .625rem; right: .625rem; bottom: 0; height: 3px; border-radius: 3px 3px 0 0;
  background: var(--brand); transform: scaleX(0); transition: transform .2s var(--ease); }
.anchor-bar button.on { color: var(--brand-2); } .anchor-bar button.on svg.i { color: var(--brand); }
.anchor-bar button.on::after { transform: scaleX(1); }
.lp-group { scroll-margin-top: calc(var(--shell-h) + 4.75rem); border-radius: var(--r); }
.lp-group.flash > .lp-section h2 { animation: secFlash 1.2s var(--ease); }
@keyframes secFlash { 0%, 40% { color: var(--brand); } }
.anchor-wrap + .lp-group .lp-section { margin-top: .5rem; }

/* ── Buscador de productos (tarjetas en lugar de la lista nativa) ── */
.pp-wrap { position: relative; }
.pp-box { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0; max-height: 22rem; overflow-y: auto;
  background: var(--surface); border-radius: var(--r); box-shadow: var(--sh2); border: 1px solid var(--border); padding: .25rem; }
.pp-item { display: flex; align-items: center; gap: .75rem; padding: .5rem .625rem; border-radius: 8px; cursor: pointer; }
.pp-item:hover, .pp-item.on { background: var(--hover); }
.pp-item.on { box-shadow: inset 3px 0 0 var(--brand); }
.pp-item.taken { opacity: .6; }
.pp-av { width: 2.25rem; height: 2.25rem; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand-2); font-weight: 700; font-size: 12px; }
.pp-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-name mark, .pp-sub mark { background: var(--amber-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.pp-right { text-align: right; font-size: 13px; flex: none; line-height: 1.3; }
.pp-low { color: var(--red); }
.pp-empty { padding: 1rem; text-align: center; color: var(--muted); font-size: 13px; }

/* ── Clientes de una ruta (asignación en bloque) ── */
.rc-list { max-height: 45vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.li.rc { cursor: pointer; gap: .625rem; padding: .5rem .75rem; }
.li.rc:hover { background: var(--hover); }
.li.rc input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }

/* ── Tasa BCV: oficial (bcv.org.ve) o manual ── */
.bcv-box { padding: .875rem 1rem; box-shadow: none; border: 1px solid var(--border); background: var(--surface-2); }
.bcv-ic { width: 2.25rem; height: 2.25rem; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-2); flex: none; }
details.manual > summary { cursor: pointer; padding: .25rem 0; list-style-position: inside; }

/* ── Suscripción de la empresa ── */
.sub-head { display: flex; align-items: center; gap: 1rem; padding: 1rem; flex-wrap: wrap; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .75rem; }
.plan { position: relative; text-align: left; background: var(--surface); border: 2px solid var(--border); border-radius: var(--r); padding: 1rem; cursor: pointer;
  box-shadow: var(--sh0); transition: border-color .15s, transform .1s; color: var(--text); font: inherit; }
.plan:hover { border-color: var(--brand); } .plan:active { transform: scale(.98); }
.plan.on { border-color: var(--brand); background: var(--brand-soft); }
.plan-t { font-weight: 700; }
.plan-p { font-size: 1.75rem; font-weight: 300; margin: .25rem 0 .125rem; }
.plan-off { position: absolute; top: .625rem; right: .625rem; background: var(--up); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; }
.pay-box { border: 1px solid var(--border); border-radius: 8px; padding: .625rem .75rem; background: var(--surface-2); }
.pay-row { display: flex; align-items: center; gap: .5rem; font-size: 13px; padding: 2px 0; min-height: 1.75rem; }
.pay-row > span { color: var(--muted); min-width: 6.5rem; } .pay-row > b { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pay-row .icon-btn { width: 1.75rem; height: 1.75rem; }
.lock { max-width: 30rem; margin: 2rem auto; padding: 2rem 1.5rem; text-align: center; }
.lock-ic { width: 3.5rem; height: 3.5rem; margin: 0 auto 1rem; border-radius: 50%; display: grid; place-items: center; background: var(--red-soft); color: var(--red); }
.lock-ic svg.i { width: 1.75rem; height: 1.75rem; }

/* ── Consola de la plataforma ── */
.pf .shell .brand { cursor: default; }
.pf-main { padding: calc(var(--shell-h) + 1rem) 2rem 3rem; max-width: 1400px; margin: 0 auto; }
.pf-tabs { margin-bottom: 1rem; }
.pf-tabs .count { margin-left: .25rem; background: #d20a0a; color: #fff; font-size: 10px; padding: 0 6px; border-radius: 99px; }
@media (max-width: 860px) { .pf-main { padding: calc(var(--shell-h) + .75rem) 1rem 2rem; } }

/* ── Perfiles y autorizaciones (matriz por cargo) ── */
.pm-head { display: flex; align-items: center; gap: .75rem; padding: .875rem 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.pm-legend { display: flex; flex-wrap: wrap; gap: .375rem 1.25rem; font-size: 12px; margin: 0 0 1rem .25rem; }
.pm-legend > span { display: inline-flex; align-items: center; gap: .375rem; }
.pm-sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.pm-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); vertical-align: middle; }
.pm-area { margin-bottom: 1rem; }
.pm-table th { white-space: nowrap; font-size: 12px; }
.pm-table td { vertical-align: top; padding: .5rem .5rem; }
.pm-act { min-width: 15rem; } .pm-act > div:first-child { font-weight: 700; }
.pm-cell { position: relative; min-width: 8.25rem; }
.pm-cell.chg::after { content: ""; position: absolute; top: .375rem; right: .25rem; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.pm-na { color: var(--muted); text-align: center; }
.pm-sel { height: 2rem; font-size: 12px; font-weight: 700; padding: 0 .375rem; border-left-width: 4px; }
.m-direct { border-left-color: var(--up) !important; } .pm-sw.m-direct { background: var(--up); }
.m-limit { border-left-color: #e8a400 !important; } .pm-sw.m-limit { background: #e8a400; }
.m-approval { border-left-color: var(--c2) !important; } .pm-sw.m-approval { background: var(--c2); }
.m-no { border-left-color: var(--border-2) !important; color: var(--muted); } .pm-sw.m-no { background: var(--border-2); }
.pm-lim { display: flex; align-items: center; gap: .25rem; margin-top: .25rem; font-size: 12px; color: var(--muted); }
.pm-lim .input { height: 1.75rem; font-size: 12px; text-align: right; }
.pm-chips { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; margin-top: .375rem; }
.chip { border: 1px solid var(--border-2); background: var(--surface); border-radius: 99px; height: 1.625rem; padding: 0 .5rem; font-size: 11px; font-weight: 700; color: var(--muted); cursor: pointer; }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-2); }
.chip.fixed { cursor: default; display: inline-flex; align-items: center; }
@media (max-width: 600px) {
  .pm-legend .muted { display: none; }
  .t:not(.keep) td.pm-na { display: none; }
  .pm-act { min-width: 0; }
  .pm-cell { min-width: 0; } .pm-cell.chg::after { top: 0; }
}

/* ── Recepción: OC por recibir como tarjetas; movimientos plegables ── */
.rcv-grid { align-items: start; }
.po-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .75rem; }
.po-card { padding: .875rem; border-left: 4px solid var(--brand); }
.po-card.today { border-left-color: #e76500; } .po-card.late { border-left-color: #d20a0a; }
details.moves > summary { list-style: none; cursor: pointer; }
details.moves > summary::-webkit-details-marker { display: none; }
details.moves > summary svg.i:last-child { transform: rotate(90deg); transition: transform .2s var(--ease); color: var(--muted); }
details.moves[open] > summary svg.i:last-child { transform: rotate(-90deg); }
details.moves:not([open]) > summary { border-bottom: 0; }

/* ── Menú lateral en el teléfono: usuario arriba, sus acciones al pie (como Gmail o Instagram) ── */
.side-user { display: flex; align-items: center; gap: .75rem; padding: .75rem .625rem 1rem; margin: -.5rem -.5rem .25rem; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--brand-soft), transparent); }
.side-user .avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 14px; }
.side-acts { border-top: 1px solid var(--border); margin-top: .75rem; padding-top: .5rem; }
.side-acts a.out, .side-acts a.out svg.i { color: var(--red); }
@media (max-width: 860px) {
  .shell #me { display: none; }
  .side { display: flex; flex-direction: column; padding-bottom: calc(.5rem + env(safe-area-inset-bottom)); z-index: 58; }
  .scrim { z-index: 57; } /* el menú abierto cubre también las pestañas de abajo */
  .side-acts a { height: auto; min-height: 2.5rem; padding-block: .375rem; white-space: normal; }
  .side-acts a .badge { margin-left: .25rem; }
  .side > .nav:not(.side-acts) { flex: 1 0 auto; }
}

/* ── Reparto: resumen delgado fijo, próxima parada destacada, pendientes/entregadas en pestañas ── */
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ship { overflow: clip; }
.ship-h { position: sticky; top: var(--shell-h); z-index: 6; background: var(--surface); padding: .625rem .875rem 0; border-bottom: 1px solid var(--border); }
@media (max-width: 860px) { .main.is-root .page-head { display: none; } .main.is-root .view { padding-top: .75rem; } }
.ship-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .375rem; font-size: 11px; color: var(--muted); line-height: 1.2; }
.ship-kpis > span { display: flex; flex-direction: column; min-width: 0; }
.ship-kpis > span:nth-child(2) { text-align: center; } .ship-kpis > span:last-child { text-align: right; }
.ship-kpis b { color: var(--text); font-size: 15px; white-space: nowrap; }
.progress.thin { height: 3px; border-radius: 0; margin: .5rem -.875rem 0; }
.next-stop { margin: .75rem .875rem; padding: .75rem; border-radius: 10px; background: var(--brand-soft); border: 1px solid var(--brand); cursor: pointer; }
.next-stop .btn { height: 2.5rem; }
.ship-tools { display: flex; gap: .5rem; align-items: center; padding: .5rem .875rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ship-tools .search { flex: 1 1 8rem; } .ship-tools .search .input { height: 2rem; }
.seg.sm button { height: 1.875rem; padding: 0 .625rem; font-size: 12px; }
.stop.dl { padding: .625rem .875rem; gap: .625rem; cursor: pointer; }
.stop.dl .seq { width: 1.625rem; height: 1.625rem; font-size: 12px; }
.dl-tags { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin-top: 2px; }
.dl-tags:empty { display: none; }
.settle { margin-bottom: 12px; }
.ship-done { padding: .75rem .875rem; margin-bottom: .5rem; cursor: pointer; color: var(--text); }
.ship-done svg.i { color: var(--green); } .ship-done svg.i:last-child { color: var(--muted); }

/* ── Línea de producto en la toma de pedido (presentación + cantidad) ── */
.prod-ctl { display: flex; align-items: center; gap: .5rem; flex: none; }
.pk { display: inline-flex; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; flex: none; }
.pk button { border: 0; border-right: 1px solid var(--border-2); background: var(--surface); height: 2.375rem; padding: 0 .625rem; font-weight: 700; font-size: 12px; color: var(--brand-2); cursor: pointer; white-space: nowrap; }
.pk button:last-child { border-right: 0; }
.pk button.on { background: var(--brand); color: var(--brand-ink); }
.prod .inc:empty { display: none; }

/* Texto de ayuda que se pliega en pantallas pequeñas (toca para leer completo) */
.banner .more { display: none; }

/* ═════════ Tableta y teléfono (≤ 860 px): menos texto guía, más contenido ═════════ */
@media (max-width: 860px) {
  /* Encabezado de página: migas solo en sub-pantallas (sirven para volver) */
  .crumbs:not(.sub) { display: none; }
  .crumbs.sub > :not(:last-child) { display: none; }
  .crumbs.sub > a:last-child::before { content: "‹ "; font-weight: 700; }
  .crumbs.sub > a:last-child { font-size: 13px; font-weight: 700; }
  .page-head { padding: .625rem 1rem .25rem; } .page-head h1 { font-size: 18px; }
  .view { padding-top: .5rem; }
  /* Encabezados de tarjeta: el título nunca se parte por culpa del subtítulo; el subtítulo pasa abajo en una línea */
  .card-h { flex-wrap: wrap; row-gap: 0; padding: .625rem .875rem; min-height: 2.75rem; }
  .card-h h2, .card-h h3 { flex: 1 1 0%; font-size: 15px; min-width: 0; }
  .card-h > span.muted, .card-h > .small.muted { order: 9; flex: 1 1 100%; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card-b { padding: .875rem; }
  /* Mensajes de ayuda: dos líneas; tocar el mensaje lo despliega */
  .banner { padding: .5rem .75rem; font-size: 13px; gap: .5rem; margin-bottom: .625rem; }
  .banner.info > span, .banner.info > .grow, .banner.info > div:not(.row) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .banner.info.open > span, .banner.info.open > .grow, .banner.info.open > div { -webkit-line-clamp: unset; display: block; }
  .banner.info { cursor: pointer; }
  /* Filtros segmentados: una sola fila deslizable en vez de 3 renglones */
  .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .seg::-webkit-scrollbar, .chips::-webkit-scrollbar { display: none; }
  .seg button { flex: none; }
  .toolbar { gap: .375rem; margin-bottom: .75rem; }
  .toolbar > .search { flex: 1 1 11rem; }
  /* Inicio */
  .lp-section { margin: 1rem 0 .375rem; } .lp-section span { display: none; }
  .anchor-wrap { display: none; } /* en el teléfono se desliza directo por los grupos */
  .main.is-home .view { padding-top: .75rem; padding-bottom: 6rem; }
  .process { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: .5rem; gap: 0; }
  .process::-webkit-scrollbar { display: none; }
  .process a { flex: none; font-size: 12px; padding: .375rem .5rem; }
  /* KPI: dos por fila en vez de uno debajo de otro */
  .grid:has(> .card.kpi) { grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .625rem; }
  .card.kpi { padding: .75rem; } .kpi .label { font-size: 12px; } .kpi .value { font-size: 1.375rem; }
  .kc { padding: .75rem; } .kc .kt { font-size: 12px; }
  /* Tablero de almacén: columnas deslizables con imán */
  .kanban { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .5rem; gap: .75rem; }
  .kanban > .col { scroll-snap-align: start; min-height: 0; }
  /* Íconos circulares más compactos */
  .circles { gap: .75rem .25rem; padding: .75rem .25rem; }
  .circle .cc { width: 3rem; height: 3rem; } .circle .cc svg.i { width: 1.375rem; height: 1.375rem; }
  /* Inicio de sesión: el formulario a la vista sin desplazarse */
  .auth-hero { padding: 1.25rem 1.25rem 1rem; gap: .5rem; }
  .auth-hero h1 { font-size: 1.25rem; } .auth-hero p, .auth-flow { display: none; }
  .auth-form { align-items: flex-start; padding-top: 1.25rem; }
  /* Pestañas inferiores: etiqueta en una sola línea */
  .tabbar a span:not(.count) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 2px; }
  .empty { padding: 1.5rem 1rem; } .empty svg { width: 2rem; height: 2rem; }
  .modal-b { padding: .875rem; }
  .modal-f .btn { flex: 1 1 auto; }
}

/* ═════════ Teléfono (≤ 600 px) ═════════ */
@media (max-width: 600px) {
  .g2, .g3 { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .tile { width: calc(50% - .25rem); height: 7.25rem; } .tile.wide { width: 100%; }
  .tile .tt { font-size: 13px; } .tile .tn { font-size: 1.5rem; } .tile .tbig svg.i { width: 1.75rem; height: 1.75rem; }
  .kanban { grid-auto-columns: 88%; }
  /* Tablas → tarjetas: cada fila es un bloque con pares "etiqueta / valor" en dos columnas */
  table.t:not(.keep) thead { display: none; }
  table.t:not(.keep), .t:not(.keep) tbody, .t:not(.keep) tfoot { display: block; }
  .t:not(.keep) tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .375rem .75rem; padding: .625rem .875rem; border-bottom: 1px solid var(--border); position: relative; }
  .t:not(.keep) tr:last-child { border-bottom: 0; }
  .t:not(.keep) td { display: block; padding: 0; border: 0; height: auto; min-width: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .t:not(.keep) td.num, .t:not(.keep) td.r { white-space: normal; }
  .t:not(.keep) td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-weight: 400; line-height: 1.2; }
  .t:not(.keep) td:first-child { font-weight: 700; }
  .t:not(.keep) td[data-label="#"]::before { content: "#"; display: inline; font-size: inherit; color: inherit; font-weight: 700; }
  .tile .ts { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .t:not(.keep) td[data-label=""], .t:not(.keep) td[colspan], .t:not(.keep) td.wide-m { grid-column: 1 / -1; }
  .t:not(.keep) td .badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .t:not(.keep) td[data-label=""]:has(.btn, .icon-btn) { justify-self: end; }
  .t:not(.keep) td:has(> input[type=checkbox]:only-child) { position: absolute; top: .625rem; right: .875rem; }
  .t:not(.keep) tr:has(> td > input[type=checkbox]:only-child) { padding-right: 2.5rem; }
  .t:not(.keep) td:empty { display: none; }
  .t:not(.keep) td .input { width: 100%; }
  .table-wrap:has(> table.t:not(.keep)) { overflow-x: visible; }
  /* Línea de producto: nombre arriba, presentación y cantidad abajo */
  .prod { flex-wrap: wrap; row-gap: .5rem; padding: .625rem .875rem; }
  .prod .grow { flex: 1 1 calc(100% - 3.5rem); }
  .prod-ctl { flex: 1 1 100%; justify-content: flex-end; padding-left: 3.25rem; }
  .prod-ctl .pk { margin-right: auto; }
  .kgrid { gap: .5rem; }
  .row.wrap > .banner.grow { flex: 1 1 100%; }
  .row.wrap > .banner.grow + .btn { flex: 1 1 100%; }
  .li .badge { display: inline; white-space: normal; height: auto; line-height: 1.7; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
  .li .badge b { white-space: nowrap; }
  .modal-f { padding: .5rem .75rem calc(.5rem + env(safe-area-inset-bottom)); }
}

/* ── Cambios masivos de productos ── */
.only-m { display: none; }
.t th.selc, .t td.selc { width: 2.5rem; padding-right: 0; cursor: pointer; }
.t input[type="checkbox"] { width: 1.05rem; height: 1.05rem; cursor: pointer; accent-color: var(--brand); }
.t tbody tr.selected { background: var(--select); }
.selbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .5rem .75rem; margin-top: .75rem; border: 1px solid var(--brand); background: var(--brand-soft); border-radius: 8px; position: sticky; bottom: .75rem; z-index: 5; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.selbar[hidden] { display: none; }
.mass-opts { display: grid; gap: .5rem; }
.mass-opt { display: flex; gap: .75rem; align-items: flex-start; text-align: left; width: 100%; padding: .875rem 1rem; border: 1px solid var(--border-2); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; font: inherit; }
.mass-opt:hover { background: var(--hover); border-color: var(--brand); }
.mass-opt > svg { flex: none; width: 1.375rem; height: 1.375rem; color: var(--brand); margin-top: 2px; }
.mass-opt b { display: block; } .mass-opt span { display: block; font-size: 13px; color: var(--muted); }
.mass-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: .5rem; margin-bottom: .75rem; }
.mass-sum > div { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; background: var(--surface-2); }
.mass-sum b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; } .mass-sum span { font-size: 12px; color: var(--muted); }
.mass-sum .bad b { color: var(--red, #bb0000); }
.mass-list { max-height: 46vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.mass-list[hidden], .modal .field[hidden], .modal .row[hidden] { display: none; }
.mass-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .5rem; }
.mass-modes label { display: flex; gap: .5rem; align-items: flex-start; padding: .625rem .75rem; border: 1px solid var(--border-2); border-radius: 8px; cursor: pointer; }
.mass-modes label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.mass-modes input { margin-top: 3px; accent-color: var(--brand); }
.mass-modes b { display: block; font-size: 14px; } .mass-modes span { font-size: 12px; color: var(--muted); }
.chips button:disabled { opacity: .45; cursor: default; }
@media (max-width: 640px) { .selbar { bottom: calc(.5rem + env(safe-area-inset-bottom)); } .selbar .btn.sm { padding: 0 .5rem; } }

/* ── Mapa de clientes y vendedores ── */
.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.map-card { position: relative; overflow: hidden; padding: 0; min-width: 0; }
#map { height: calc(100dvh - 230px); min-height: 440px; background: var(--surface-2); z-index: 0; }
.map-side { display: grid; gap: 1rem; max-height: calc(100dvh - 230px); overflow-y: auto; overflow-x: hidden; min-width: 0; }
.map-side .card-h { padding: .75rem 1rem; }
.mp-li { width: 100%; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.mp-li:disabled { cursor: default; opacity: .6; }
.mp-miss { max-height: 320px; overflow: auto; }
.mp-miss .li { gap: .5rem; }
.map-legend { position: absolute; left: .5rem; bottom: .5rem; z-index: 500; display: flex; flex-wrap: wrap; gap: .25rem .75rem; max-width: calc(100% - 1rem);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .375rem .625rem; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.map-legend:empty { display: none; }
.map-legend i, .mp .dot { display: inline-block; width: .625rem; height: .625rem; border-radius: 50%; margin-right: .3rem; vertical-align: -1px; }
.map-pick { position: absolute; top: .5rem; left: 50%; transform: translateX(-50%); z-index: 600; display: flex; align-items: center; gap: .5rem;
  width: min(560px, calc(100% - 1rem)); background: var(--surface); border: 1px solid var(--brand); border-radius: 8px; padding: .5rem .75rem; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.map-pick[hidden] { display: none; }
.map-attr { margin-top: .5rem; }
.mpin { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #fff;
  background: var(--brand); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.mpin svg { width: 16px; height: 16px; }
.mpin.drv { background: #6b4fd1; }
.mpin.stale { background: #8796a5; }
.mpin.live { box-shadow: 0 0 0 4px rgba(46,160,67,.35), 0 2px 8px rgba(0,0,0,.35); }
.mpin.sm { width: 30px; height: 30px; border-width: 2px; flex: none; }
.mp { min-width: 200px; line-height: 1.45; }
.mp-act { display: flex; gap: .75rem; margin-top: .375rem; }
.mp-act button { border: 0; background: none; color: var(--brand); font: inherit; font-size: 12px; font-weight: 700; padding: 0; cursor: pointer; }
.mp-act a { font-size: 12px; font-weight: 700; }
.maplibregl-map { font: inherit; }
.maplibregl-popup-content { border-radius: 8px; padding: .625rem .75rem; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
:root[data-theme="dark"] .maplibregl-popup-content { background: var(--surface); color: var(--text); }
:root[data-theme="dark"] .maplibregl-popup-tip { border-top-color: var(--surface); border-bottom-color: var(--surface); }
.mpin { cursor: pointer; }
@media (max-width: 900px) {
  .map-wrap { grid-template-columns: minmax(0, 1fr); }
  #map { height: 62dvh; min-height: 360px; }
  .map-side { max-height: none; }
  .map-tools .input#rt { max-width: none !important; flex: 1 1 100%; }
}
.mass-list { overflow-x: hidden; }
.mass-list .t { width: 100%; }
.mass-list .t td { white-space: normal; overflow-wrap: anywhere; height: auto; }

/* ── Metas de vendedores ── */
.gl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.gl-card { padding: 1rem; }
.gl-head { display: flex; align-items: center; gap: .625rem; margin-bottom: .75rem; }
.gl-head .avatar { width: 2.25rem; height: 2.25rem; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 13px; background: var(--brand-soft); color: var(--brand-2); }
.gl-body { display: grid; gap: .5rem; }
.gl-row { display: grid; gap: .25rem; }
.gl-lbl { display: flex; justify-content: space-between; gap: .5rem; font-size: 13px; }
.gl-lbl > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-lbl b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.gl-bar { position: relative; height: .5rem; border-radius: 4px; background: var(--surface-2); overflow: visible; }
.gl-bar i { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.gl-bar i.full { background: var(--green); }
.gl-bar i.warn { background: var(--amber); }
.gl-bar i.late { background: var(--red); }
.gl-bar s { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); opacity: .55; border-radius: 1px; }
.gl-st { font-size: 12px; font-weight: 700; padding: .125rem .5rem; border-radius: 99px; white-space: nowrap; background: var(--gray-soft); color: var(--gray); }
.gl-st.ok { background: var(--green-soft); color: var(--green); }
.gl-st.warn { background: var(--amber-soft); color: var(--amber); }
.gl-st.bad { background: var(--red-soft); color: var(--red); }
.gl-sub { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 1rem 0 .375rem; }
.gl-act { max-height: 40vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.gl-act .li { width: 100%; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.gl-act .li:disabled { cursor: default; opacity: .6; }
.gl-f { gap: .5rem; flex-wrap: wrap; }
.gl-line { display: flex; align-items: center; gap: .5rem; width: 100%; margin-bottom: .75rem; padding: .5rem .75rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; text-align: left; border-left: 4px solid var(--brand); }
.gl-line > svg:first-child { width: 1rem; height: 1rem; color: var(--brand); flex: none; }
.gl-line.verde, .gl-line.cumplida { border-left-color: var(--green); }
.gl-line.amarillo { border-left-color: var(--amber); }
.gl-line.rojo { border-left-color: var(--red); }
.gl-foco { color: var(--orange); font-weight: 800; }

/* ── Historial del cliente (ficha) ── */
.ch-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.ch-k { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; background: var(--surface-2); min-width: 0; }
.ch-k > span { display: block; font-size: 12px; color: var(--muted); }
.ch-k b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-k > small { display: block; font-size: 11px; color: var(--muted); }
[data-hp] .table-wrap { max-height: 46vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
@media (max-width: 640px) { .ch-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ── Respaldos ── */
.bk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin: 1rem 0; }
.bk-card { display: flex; gap: .875rem; padding: 1rem; align-items: flex-start; }
.bk-card h3 { margin: 0 0 .25rem; }
.bk-card p { margin: 0 0 .75rem; }
.bk-ic { flex: none; width: 2.5rem; height: 2.5rem; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.bk-ic svg { width: 1.25rem; height: 1.25rem; }
.pf-slug { color: var(--brand-2); font-weight: 600; }
