/* LYNX ERP — sistema visual v5.7 (claro y minimalista). */
:root{
  --brand:#f47721;          /* logo, foco, progreso */
  --action:#c2540c;         /* botones principales: texto blanco legible (4.6:1) */
  --action-hover:#a8470a;
  --brand-soft:#fdebdc;
  --brand-ink:#9a4208;
  --bg:#f6f7f9;
  --surface:#ffffff;
  --border:#e7e9ee;
  --border-strong:#d4d8de;
  --line:#f1f2f4;
  --text:#1d2026;
  --text-2:#4b5563;
  --muted:#6b7280;
  --hover:#f3f4f6;
  --radius:12px;
  --radius-sm:9px;
  --shadow-pop:0 12px 32px rgba(17,24,39,.16);
  --side-w:256px;
  --side-w-collapsed:72px;
  --top-h:64px;
  --font:Inter,system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
}
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--text);font:14px/1.5 var(--font)}
a{color:var(--action);text-decoration:none}
a:hover{color:var(--action-hover);text-decoration:underline}
img{max-width:100%}
h1,h2,h3{letter-spacing:-.015em}
:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
.lx-skip{position:absolute;left:-999px;top:8px;z-index:100;background:var(--surface);padding:8px 12px;border-radius:8px}
.lx-skip:focus{left:8px}

/* ---------- Estructura ---------- */
.lx-app{display:flex;min-height:100vh}
.lx-side{position:sticky;top:0;height:100vh;flex:0 0 var(--side-w);width:var(--side-w);display:flex;flex-direction:column;gap:2px;padding:16px 12px;background:var(--surface);border-right:1px solid var(--border);overflow-y:auto;overflow-x:hidden;transition:flex-basis .18s ease,width .18s ease;z-index:40}
.lx-body{flex:1 1 auto;min-width:0;display:flex;flex-direction:column}
.lx-main{width:100%;max-width:1320px;padding:28px 32px 56px}
.lx-top{position:sticky;top:0;z-index:30;display:flex;align-items:center;gap:12px;min-height:var(--top-h);padding:10px 28px;background:rgba(255,255,255,.92);backdrop-filter:saturate(1.4) blur(8px);border-bottom:1px solid var(--border)}

.lx-brand{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:40px;padding:0 4px 16px}
.lx-logo{display:flex;align-items:center;gap:10px;color:var(--text);font-weight:700;font-size:17px;white-space:nowrap}
.lx-logo:hover{text-decoration:none;color:var(--text)}
.lx-logo small{font-weight:500;font-size:12px;color:var(--muted)}
.mark{display:inline-grid;place-items:center;flex:0 0 34px;width:34px;height:34px;border-radius:9px;background:var(--brand);color:#fff;font-weight:700;font-size:17px}

/* Menú lateral */
.lx-nav{display:flex;flex-direction:column;gap:2px}
.lx-group>summary{list-style:none;display:flex;align-items:center;gap:12px;min-height:40px;padding:0 10px;border-radius:8px;cursor:pointer;color:#374151;font-weight:500;user-select:none}
.lx-group>summary::-webkit-details-marker{display:none}
.lx-group>summary:hover{background:var(--hover)}
.lx-group>summary svg{flex:0 0 20px}
.lx-group-label{flex:1 1 auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.lx-chev{display:inline-grid;color:#9ca3af;transition:transform .15s ease}
.lx-group[open] .lx-chev{transform:rotate(90deg)}
.lx-group.is-active>summary{color:var(--brand-ink);font-weight:600}
.lx-sub{display:flex;flex-direction:column;gap:1px;margin:2px 0 6px 21px;padding-left:8px;border-left:1px solid #eceef1}
.lx-sub a{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:34px;padding:0 10px;border-radius:7px;color:var(--text-2);font-size:13.5px;font-weight:500}
.lx-sub a:hover{background:var(--hover);color:var(--text);text-decoration:none}
.lx-sub a.is-current{background:var(--brand-soft);color:var(--brand-ink);font-weight:600}
.lx-count{min-width:20px;padding:0 6px;border-radius:999px;background:var(--brand-soft);color:var(--brand-ink);font-size:11.5px;font-weight:600;text-align:center;line-height:20px}
.lx-side-foot{margin-top:auto;padding:16px 8px 0;font-size:12px;color:var(--muted)}

/* Menú colapsado (escritorio) */
.lx-collapsed .lx-side{flex-basis:var(--side-w-collapsed);width:var(--side-w-collapsed)}
.lx-collapsed .lx-hide-collapsed,.lx-collapsed .lx-sub{display:none}
.lx-collapsed .lx-brand{justify-content:center;padding-inline:0}
.lx-collapsed .lx-group>summary{justify-content:center;padding:0}

/* Barra superior */
.lx-icon-btn{display:inline-grid;place-items:center;flex:0 0 40px;width:40px;height:40px;padding:0;border:0;border-radius:10px;background:transparent;color:var(--text-2);cursor:pointer;position:relative}
.lx-icon-btn:hover{background:var(--hover);color:var(--text)}
.lx-toggle{margin-left:-8px}
.lx-crumbs{display:flex;align-items:center;gap:8px;flex:1 1 auto;min-width:0;font-size:13.5px;color:var(--muted);white-space:nowrap;overflow:hidden}
.lx-crumbs a{color:var(--muted)}
.lx-crumbs a:hover{color:var(--action-hover)}
.lx-crumbs [aria-current]{color:var(--text);font-weight:600;overflow:hidden;text-overflow:ellipsis}
.lx-dot{position:absolute;top:9px;right:10px;width:8px;height:8px;border-radius:999px;background:var(--brand);box-shadow:0 0 0 2px #fff}
.lx-user{position:relative}
.lx-user>summary{list-style:none;display:flex;align-items:center;gap:10px;height:40px;padding:0 8px 0 4px;border-radius:10px;cursor:pointer}
.lx-user>summary::-webkit-details-marker{display:none}
.lx-user>summary:hover{background:var(--hover)}
.lx-avatar{display:inline-grid;place-items:center;width:32px;height:32px;border-radius:999px;background:var(--brand-soft);color:var(--brand-ink);font-weight:600;font-size:12.5px}
.lx-user-name{font-size:13px;font-weight:600;max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lx-menu-pop{position:absolute;right:0;top:calc(100% + 6px);min-width:240px;padding:6px;background:var(--surface);border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow-pop);z-index:60}
.lx-menu-head{display:flex;flex-direction:column;padding:8px 10px 10px;border-bottom:1px solid var(--line);margin-bottom:4px}
.lx-menu-head span{font-size:12.5px;color:var(--muted);overflow:hidden;text-overflow:ellipsis}
.lx-menu-pop a,.lx-menu-pop button{display:flex;align-items:center;gap:10px;width:100%;min-height:38px;padding:0 10px;border:0;border-radius:8px;background:transparent;color:var(--text);font:inherit;font-size:13.5px;text-align:left;cursor:pointer}
.lx-menu-pop a:hover,.lx-menu-pop button:hover{background:var(--hover);text-decoration:none;color:var(--text)}
.lx-menu-pop form{margin:0}

.lx-only-mobile{display:none !important}
.lx-backdrop{display:none}

/* ---------- Encabezado de página ---------- */
.pagehead{margin-bottom:24px}
.pagehead h1{margin:0;font-size:24px;font-weight:650}
.pagehead p{margin:4px 0 0;color:var(--muted)}

/* ---------- Tarjetas y bloques ---------- */
.panel,.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:20px 24px;margin-bottom:20px;min-width:0}
.panel>h2:first-child,.card>h2:first-child{margin-top:0}
.panel h2,.card h2{margin:0 0 16px;font-size:15px;font-weight:600}
.panel h3,.card h3{margin:16px 0 10px;font-size:14px;font-weight:600}
.grid,.split,.two-col{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,320px),1fr));gap:20px;align-items:start}
.two-col{grid-template-columns:minmax(0,1.1fr) minmax(0,.9fr)}
.grid>.panel,.split>.panel,.two-col>.panel{margin-bottom:0}
.muted{color:var(--muted);font-size:13px;margin:10px 0}
.empty{color:var(--muted);text-align:center;padding:32px 0}
.history{border-bottom:1px solid var(--line);padding:13px 0;display:grid;gap:3px}
.history span,.history small{color:var(--muted)}
.legacy-raw{max-height:290px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;background:var(--bg);border-radius:10px;padding:14px;font-size:12px}

/* ---------- Formularios ---------- */
input,select,textarea{font:inherit;color:var(--text);background:var(--surface);border:1px solid #e1e4e8;border-radius:var(--radius-sm);min-width:0;max-width:100%}
input:not([type=checkbox]):not([type=radio]):not([type=file]),select{height:40px;padding:0 12px}
input[type=file]{padding:8px;height:auto}
textarea{padding:10px 12px;width:100%;min-height:90px;resize:vertical}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 3px rgba(244,119,33,.18)}
input[type=checkbox],input[type=radio]{width:18px;height:18px;accent-color:var(--action);vertical-align:middle}
input:disabled,select:disabled,textarea:disabled{background:var(--hover);color:var(--muted)}
.lx-main label{display:flex;flex-direction:column;gap:6px;font-size:13px;font-weight:500;color:var(--text)}
.lx-main label:has(> input[type=checkbox]),.lx-main label:has(> input[type=radio]){flex-direction:row;align-items:center;gap:8px;font-weight:400}
.lx-main form{margin:0}
.lx-main form+form{margin-top:12px}
.form,.formgrid{display:grid;gap:16px}
.formgrid{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));align-items:end}
.lx-main .panel>form:not(.inline):not([style]){display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));gap:14px 16px;align-items:end}
.lx-main .panel>form:not(.inline):not([style])>p,.lx-main .panel>form:not(.inline):not([style])>h3,.lx-main .panel>form:not(.inline):not([style])>table,.lx-main .panel>form:not(.inline):not([style])>.tablewrap,.lx-main .panel>form:not(.inline):not([style])>div,.lx-main .panel>form:not(.inline):not([style])>label:has(textarea){grid-column:1/-1}
.lx-main .panel>form:not(.inline):not([style])>p{margin:0}
.lx-main .panel>form:not(.inline):not([style])>button{justify-self:start}
.actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px;margin-top:10px}

/* ---------- Botones ---------- */
button,.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:40px;padding:0 14px;border:1px solid #e1e4e8;border-radius:var(--radius-sm);background:var(--surface);color:var(--text);font:inherit;font-weight:500;cursor:pointer;text-align:center;white-space:nowrap}
button:hover,.btn:hover{background:var(--hover);border-color:var(--border-strong);text-decoration:none;color:var(--text)}
.primary,button.primary,.btn.primary{background:var(--action);border-color:var(--action);color:#fff;font-weight:600}
.primary:hover,button.primary:hover,.btn.primary:hover{background:var(--action-hover);border-color:var(--action-hover);color:#fff}
.secondary{background:var(--surface)}
.danger{background:#b42318;border-color:#b42318;color:#fff}
.danger:hover{background:#912018;color:#fff}
.link,button.link{min-height:0;padding:0;border:0;background:none;color:var(--action);font-weight:500}
.link:hover,button.link:hover{background:none;color:var(--action-hover);text-decoration:underline}
.full{width:100%}
/* Acción suelta en un párrafo propio (p. ej. «Crear cotización», «← Ventas»): se muestra como botón. */
.lx-main>p>a:only-child{display:inline-flex;align-items:center;gap:6px;min-height:38px;padding:0 14px;border:1px solid #e1e4e8;border-radius:var(--radius-sm);background:var(--surface);color:var(--text);font-weight:500}
.lx-main>p>a:only-child:hover{background:var(--hover);border-color:var(--border-strong);text-decoration:none;color:var(--text)}
button:disabled,.btn[aria-disabled=true]{opacity:.5;cursor:not-allowed}

/* ---------- Barras de herramientas ---------- */
.toolbar,.search,.pager{display:flex;align-items:center;gap:12px}
.toolbar{justify-content:space-between;flex-wrap:wrap;margin-bottom:18px}
.search{flex:1;flex-wrap:wrap}
.search input{min-width:200px;flex:1}
.pager{justify-content:center;margin-top:20px}

/* ---------- Tablas ---------- */
.tablewrap{overflow-x:auto;margin:0 -24px;padding:0 24px}
table{width:100%;border-collapse:collapse;text-align:left}
th,td{padding:12px 12px;border-bottom:1px solid var(--line);vertical-align:top}
th:first-child,td:first-child{padding-left:0}
th:last-child,td:last-child{padding-right:0}
th{color:var(--muted);font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:.04em;white-space:nowrap;border-bottom-color:var(--border)}
td{font-size:14px}
tbody tr:hover td{background:#fafafb}
tbody tr:last-child td{border-bottom:0}
.lx-empty-row td{padding:28px 0;text-align:center;color:var(--muted)}
.lx-empty-row:hover td{background:none}
.num,td.num,th.num{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
td form{display:inline-flex;flex-wrap:wrap;gap:6px;align-items:center}
td button{min-height:32px;padding:0 10px;font-size:13px}
td input:not([type=checkbox]),td select{height:34px}

/* ---------- Estados y avisos ---------- */
.badge{display:inline-flex;align-items:center;gap:6px;height:24px;padding:0 10px;border-radius:999px;font-size:12.5px;font-weight:600;white-space:nowrap;line-height:1}
.badge::before{content:"";width:6px;height:6px;border-radius:999px;background:currentColor}
.badge-blue{background:#eaf1ff;color:#1d4ed8}
.badge-amber{background:#fff4e5;color:#9a4a00}
.badge-green{background:#e7f6ec;color:#166534}
.badge-violet{background:#f1ecff;color:#5b21b6}
.badge-gray{background:#eef0f3;color:#374151}
.badge-red{background:#fdecec;color:#b42318}
.notice,.error,.success,.info{display:block;padding:12px 14px;border-radius:10px;margin:0 0 16px;font-size:13.5px}
.notice{background:#fff4e5;color:#8a4500}
.error{background:#fdecec;color:#b42318}
.success{background:#e7f6ec;color:#166534}
.info{background:#eaf1ff;color:#1d4ed8}
.lx-toast{position:fixed;right:24px;bottom:24px;z-index:80;display:flex;align-items:center;gap:10px;max-width:min(440px,calc(100% - 32px));padding:12px 16px;border-radius:10px;background:#1f2937;color:#fff;box-shadow:var(--shadow-pop);font-size:13.5px;animation:lx-in .2s ease}
.lx-toast svg{color:#86efac;flex:0 0 18px}
.lx-toast.is-hiding{opacity:0;transform:translateY(8px);transition:.25s ease}
@keyframes lx-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}

/* Confirmación propia (reemplaza confirm() del navegador) */
.lx-modal{position:fixed;inset:0;z-index:90;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(17,24,39,.45)}
.lx-dialog{width:100%;max-width:440px;background:var(--surface);border-radius:14px;padding:24px;box-shadow:0 24px 60px rgba(17,24,39,.25);display:flex;flex-direction:column;gap:12px}
.lx-dialog h2{margin:0;font-size:17px;font-weight:650}
.lx-dialog p{margin:0;color:var(--text-2)}
.lx-dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:8px}

/* ---------- Indicadores (dashboard) ---------- */
.dash-kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,200px),1fr));gap:16px}
.dash-kpis>div{padding:18px 20px;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);min-width:0}
.dash-kpis small{display:block;color:var(--muted);font-size:13px;font-weight:500}
.dash-kpis strong{display:block;font-size:clamp(20px,2.4vw,26px);font-weight:650;margin-top:6px;color:var(--text);font-variant-numeric:tabular-nums;letter-spacing:-.02em}
.dash-bar{margin:16px 0}
.dash-bar-label{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;font-size:13.5px}
.dash-track{height:8px;background:#eef0f3;border-radius:999px;overflow:hidden;margin-top:7px}
.dash-fill{height:100%;background:var(--brand);border-radius:999px}

.lx-main>p.lx-actions-row{display:flex;flex-wrap:wrap;gap:8px}

/* Agenda de entregas */
.lx-agenda{display:flex;flex-direction:column;gap:8px}
.lx-agenda-item{display:grid;grid-template-columns:72px 1fr;gap:14px;padding:12px 14px;border:1px solid var(--border);border-radius:12px;color:var(--text);text-decoration:none}
.lx-agenda-item:hover{border-color:var(--border-strong);background:#fafafb;color:var(--text);text-decoration:none}
.lx-agenda-time{display:flex;flex-direction:column;font-weight:700;font-size:16px;font-variant-numeric:tabular-nums}
.lx-agenda-time small{font-weight:500;color:var(--muted);font-size:12.5px}
.lx-agenda-body{display:flex;flex-direction:column;gap:2px;min-width:0}
.lx-agenda-body .muted{margin:0;font-size:13px}

/* Mapas y comprobantes */
.lx-map{height:420px;border:1px solid var(--border);border-radius:12px;margin:12px 0;z-index:1}
.lx-proof{max-width:min(360px,100%);border:1px solid var(--border);border-radius:10px}
.lx-qr{border:1px solid var(--border);border-radius:10px;background:#fff}

/* Fotos de producto */
.lx-gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:14px;margin-bottom:16px}
.lx-photo{margin:0;border:1px solid var(--border);border-radius:12px;overflow:hidden;background:var(--surface)}
.lx-photo.is-primary{border-color:var(--brand);box-shadow:0 0 0 2px rgba(244,119,33,.18)}
.lx-photo img{display:block;width:100%;aspect-ratio:1;object-fit:contain;background:#fff}
.lx-photo figcaption{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px;padding:8px 10px;border-top:1px solid var(--line)}
.lx-photo figcaption button{min-height:30px;font-size:12.5px;padding:0 8px}
.lx-thumb{display:block;width:44px;height:44px;border-radius:8px;object-fit:contain;background:#fff;border:1px solid var(--border)}
.lx-thumb-empty{background:var(--hover)}
td.lx-thumb-cell{width:56px}

/* Firmas y cuotas */
.signature-pad{display:block;width:100%;height:auto;max-width:480px;border:1px solid #cdd2d9;border-radius:10px;background:#fff;touch-action:none;margin:12px 0}
.sign{display:grid;gap:8px}
.installment-line{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr));gap:12px;align-items:end;margin-bottom:10px}

/* ---------- Inicio de sesión ---------- */
.login{display:grid;min-height:100vh;place-items:center;padding:16px;background:var(--bg)}
.login-card{width:min(400px,100%);background:var(--surface);border:1px solid var(--border);border-radius:16px;padding:36px 32px;box-shadow:0 12px 40px rgba(17,24,39,.06);display:grid;gap:16px}
.login-card .brand{display:flex;align-items:center;gap:10px;font-weight:700;font-size:20px}
.login-card .brand small{font-size:12px;color:var(--muted);font-weight:500}
.login-card h1{margin:8px 0 0;font-size:22px;font-weight:650}
.login-card p{margin:0 0 4px;color:var(--muted)}
.login-card label{display:flex;flex-direction:column;gap:6px;font-size:13px;font-weight:500}
.login-card .primary{height:44px}

/* ---------- Celular y tablet ---------- */
@media (max-width:767px){
  .lx-only-mobile{display:inline-grid !important}
  .lx-only-desktop{display:none !important}
  .lx-side{position:fixed;left:0;top:0;bottom:0;height:auto;width:288px;flex:none;transform:translateX(-105%);transition:transform .2s ease;box-shadow:none}
  .lx-collapsed .lx-side{width:288px}
  .lx-collapsed .lx-hide-collapsed{display:revert}
  .lx-collapsed .lx-sub{display:flex}
  .lx-collapsed .lx-brand{justify-content:space-between;padding:0 4px 16px}
  .lx-collapsed .lx-group>summary{justify-content:flex-start;padding:0 10px}
  .lx-drawer .lx-side{transform:none;box-shadow:0 0 40px rgba(17,24,39,.25)}
  .lx-drawer .lx-backdrop{display:block;position:fixed;inset:0;z-index:35;border:0;padding:0;border-radius:0;background:rgba(17,24,39,.45)}
  .lx-drawer body{overflow:hidden}
  .lx-top{padding:10px 16px;gap:8px}
  .lx-main{padding:20px 16px 96px}
  .pagehead h1{font-size:21px}
  .panel,.card{padding:16px;border-radius:12px}
  .tablewrap{margin:0 -16px;padding:0 16px}
  .two-col{grid-template-columns:1fr}
  .dash-kpis{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .dash-kpis>div{padding:14px}
  .toolbar .btn,.toolbar button{flex:1 1 auto}
  .lx-toast{left:16px;right:16px;bottom:16px;max-width:none}
  button,.btn{min-height:44px}
  /* Tablas como tarjetas apiladas: cada celda muestra su encabezado (JS agrega data-label). */
  table.lx-stack thead{display:none}
  table.lx-stack,table.lx-stack tbody,table.lx-stack tr,table.lx-stack td{display:block;width:100%}
  table.lx-stack tr{border:1px solid var(--border);border-radius:12px;padding:6px 14px;margin-bottom:10px;background:var(--surface)}
  table.lx-stack tbody tr:hover td{background:none}
  table.lx-stack td{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;padding:8px 0;border-bottom:1px solid var(--line);text-align:right}
  table.lx-stack td:last-child{border-bottom:0}
  table.lx-stack td::before{content:attr(data-label);flex:0 0 40%;color:var(--muted);font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:.03em;text-align:left}
  table.lx-stack td[data-label=""]::before{display:none}
  table.lx-stack td[data-label=""]{justify-content:flex-end}
  table.lx-stack td form{justify-content:flex-end}
  table.lx-stack tr.lx-empty-row td{justify-content:center;text-align:center}
}

/* ---------- Impresión ---------- */
@media print{
  .lx-side,.lx-top,.lx-toast,.lx-backdrop,.noprint{display:none !important}
  body{background:#fff}
  .lx-main{padding:0;max-width:none}
  .panel,.card{border:0;padding:0;break-inside:avoid}
}
.lx-agenda-body>.badge{align-self:flex-start}
/* V6.4: pestañas de reportes */
.lx-tabs{display:flex;gap:6px;overflow-x:auto;padding:2px 0 4px;margin:0 0 16px;scrollbar-width:thin}
.lx-tabs a{flex:0 0 auto;padding:8px 14px;border:1px solid var(--border);border-radius:999px;background:var(--surface);color:var(--text-2);font-weight:500;white-space:nowrap}
.lx-tabs a:hover{background:var(--hover);text-decoration:none;color:var(--text)}
.lx-tabs a[aria-current=page]{background:var(--brand-soft);border-color:var(--brand);color:var(--brand-ink)}
.lx-filters{display:flex;flex-wrap:wrap;gap:12px;align-items:end}
/* V6.5: punto de venta */
.pos-layout{display:grid;grid-template-columns:minmax(0,1fr) 380px;gap:20px;align-items:start}
.pos-cart{position:sticky;top:calc(var(--top-h) + 16px)}
.pos-cart h2{margin-top:0}.pos-cart h2+*{margin-top:0}
.pos-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:14px}
.pos-card{display:flex;flex-direction:column;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);overflow:hidden}
.pos-card.is-out{opacity:.75}
.pos-img{aspect-ratio:4/3;background:var(--hover);display:grid;place-items:center}.pos-img img{width:100%;height:100%;object-fit:contain;background:#fff}
.pos-body{display:flex;flex-direction:column;gap:2px;padding:10px 12px;flex:1}
.pos-name{font-weight:600;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.pos-price{font-size:17px;font-weight:700;margin-top:4px;font-variant-numeric:tabular-nums}
.pos-stock{color:#166534}.pos-out{color:#b42318}
.pos-add{display:flex;gap:6px;padding:0 12px 12px}.pos-add button{flex:1}
.pos-qty{width:64px;text-align:right}
.pos-customer{padding:10px 12px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--brand-soft);margin-bottom:16px}
.pos-matches{list-style:none;padding:0;margin:8px 0 12px}.pos-matches li{padding:6px 0;border-bottom:1px solid var(--line)}
.pos-new{margin:8px 0 18px}.pos-new summary{cursor:pointer;color:var(--action);font-weight:600}
.pos-lines{list-style:none;padding:0;margin:0 0 10px}
.pos-lines li{display:grid;grid-template-columns:1fr auto auto;gap:4px 10px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line)}
.pos-lines li>.link{grid-column:1/-1;justify-self:start;padding:0}
.pos-total{display:flex;justify-content:space-between;align-items:baseline;font-size:18px;margin-top:14px}.pos-total strong{font-size:22px}
.pos-usd{margin:2px 0 12px;text-align:right}
.pos-jump{position:fixed;left:16px;right:16px;bottom:16px;z-index:20;padding:12px;border-radius:12px;background:var(--action);color:#fff;text-align:center;font-weight:600;box-shadow:var(--shadow-pop)}
.pos-jump:hover{color:#fff;text-decoration:none}
@media (max-width:1100px){.pos-layout{grid-template-columns:1fr}.pos-cart{position:static}}
@media (max-width:640px){.pos-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.pos-add{flex-wrap:wrap}.pos-add .pos-qty{width:100%}}
/* V6.5: mapas de entregas */
.lx-geo{height:300px;border-radius:var(--radius-sm);border:1px solid var(--border);margin:6px 0}
.lx-route-map{height:380px;border-radius:var(--radius);border:1px solid var(--border);margin-bottom:16px}
.lx-pin{background:none;border:0}.lx-pin span{display:grid;place-items:center;width:28px;height:28px;border-radius:50%;border:2px solid #fff;background:var(--action);color:#fff;font-weight:700;font-size:12px;box-shadow:0 2px 6px rgba(0,0,0,.3)}
/* V6.5.1: ventana «Nuevo cliente» */
dialog.lx-dlg{border:0;padding:0;background:transparent;width:calc(100% - 32px);max-width:480px;overflow:visible}
dialog.lx-dlg::backdrop{background:rgba(17,24,39,.45)}
dialog.lx-dlg .lx-dialog{max-width:none}
dialog.lx-dlg label{display:flex;flex-direction:column;gap:6px;font-weight:500}
dialog.lx-dlg .split{display:grid;grid-template-columns:1fr 1fr;gap:12px}
@media (max-width:480px){dialog.lx-dlg .split{grid-template-columns:1fr}}
.lx-field-row{grid-column:1/-1;display:flex;align-items:flex-end;gap:8px}.lx-field-row>label{flex:1;min-width:0}
.lx-field-row>.secondary{white-space:nowrap}
.lx-nc-note{display:block;grid-column:1/-1;margin:-4px 0 10px;color:#166534;font-size:13px}
[hidden]{display:none !important}
/* V6.5.2: mapa en ventana emergente */
dialog.lx-map-dlg{max-width:760px}
.lx-map-head{display:flex;justify-content:space-between;align-items:center;gap:12px}
.lx-map-box{height:min(60vh,460px);border-radius:var(--radius-sm);border:1px solid var(--border)}
label.check{display:flex;flex-direction:row;align-items:flex-start;gap:10px;font-weight:400;margin:6px 0}label.check input{margin-top:3px;width:auto}

/* ---------- V6.7 Subida de archivos: vista previa y progreso ---------- */

/* ---------- V6.7 Unidades vendidas (serie y garantía de la marca) ---------- */
.lx-units{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,300px),1fr));gap:14px;margin-bottom:8px}
.lx-unit{border:1px solid var(--border);border-radius:var(--radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0}
.lx-unit-head{display:flex;justify-content:space-between;gap:8px;align-items:baseline;flex-wrap:wrap}
.lx-unit-head .muted{margin:0}
.lx-unit-meta{margin:0;font-size:13px}
.lx-unit-card{display:flex;gap:10px;align-items:center;color:var(--text)}
.lx-unit-card:hover{text-decoration:none}
.lx-unit-card img,.lx-file-pdf{flex:0 0 72px;width:72px;height:72px;border-radius:8px;border:1px solid var(--border);object-fit:cover}
.lx-file-pdf{display:grid;place-items:center;background:var(--brand-soft);color:var(--brand-ink);font-weight:700}
.lx-unit-form{display:grid;grid-template-columns:minmax(0,1fr);gap:10px}
.lx-unit-form label{min-width:0}
.lx-unit-form input{width:100%}
.lx-unit-form button{justify-self:start}

/* V6.9 Campos obligatorios y avisos en línea */
.lx-req{color:#b42318;margin-left:3px;font-weight:700}
.lx-inline-form{display:inline-block;margin:6px 0 0 8px}

/* ---------- V6.9 Vender ---------- */
.v-layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(280px,360px);gap:20px;align-items:start}
@media (max-width:1000px){.v-layout{grid-template-columns:minmax(0,1fr)}}
.v-main,.v-side{min-width:0}
.v-searchbar{position:relative;display:flex;gap:8px}
.v-searchbar input[name=q],.v-searchbar input[name=cq]{flex:1 1 auto;min-width:0;height:46px;font-size:16px}
.v-search .v-searchbar input[name=q]{height:52px;font-size:17px}
.v-wh{margin-top:12px;max-width:420px}
.v-suggest{position:absolute;left:0;right:0;top:calc(100% + 4px);z-index:40;margin:0;padding:6px;list-style:none;background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius);box-shadow:var(--shadow-pop);max-height:420px;overflow:auto}
.v-sug{display:flex;gap:10px;align-items:center;padding:8px;border-radius:8px;cursor:pointer}
.v-sug[aria-selected=true],.v-sug:hover{background:var(--brand-soft)}
.v-sug img,.v-sug-noimg{flex:0 0 44px;width:44px;height:44px;border-radius:8px;object-fit:cover;background:var(--line)}
.v-sug-body{display:flex;flex-direction:column;min-width:0;font-size:13.5px}
.v-sug-body strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.v-sug-stock{font-size:12.5px;color:var(--text-2)}
.v-empty{padding:10px;color:var(--muted)}
.v-results{display:grid;gap:12px}
.v-card{display:flex;gap:14px;border:1px solid var(--border);border-radius:var(--radius);padding:14px;min-width:0}
.v-card-img{flex:0 0 88px;width:88px;height:88px;border-radius:10px;background:var(--line);overflow:hidden}
.v-card-img img{width:100%;height:100%;object-fit:cover}
.v-card-body{flex:1 1 auto;min-width:0}
.v-card-body h3{margin:0;font-size:15px}
.v-card-body .muted{margin:2px 0 6px}
.v-price{margin:0 0 8px;font-size:17px;font-weight:700}
.v-chips{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}
.v-chip{display:inline-flex;gap:4px;align-items:center;padding:3px 10px;border-radius:999px;background:var(--line);font-size:12.5px}
.v-chip.v-here{background:#e7f6ec;color:#166534}
.v-chip.v-none{color:var(--muted)}
.v-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.v-add{display:flex;gap:6px;align-items:center}
.v-qty{width:64px}
.v-list{list-style:none;margin:0;padding:0;display:grid;gap:10px}
.v-list li{display:flex;justify-content:space-between;gap:10px;align-items:center;border-bottom:1px solid var(--line);padding-bottom:10px;min-width:0}
.v-list li>div:first-child{min-width:0}
.v-row{display:flex;gap:8px;align-items:center;flex-shrink:0}
.v-total{font-size:16px;margin:12px 0}
.v-final{display:grid;gap:12px;margin-top:14px}
.v-final .btn.primary{justify-content:center}
.v-new summary{cursor:pointer;font-weight:600;color:var(--action);margin:8px 0}
.v-customer{margin:0 0 6px}
.v-note .v-span{grid-column:1/-1}
.v-note fieldset{border:0;padding:0;margin:0;display:flex;gap:18px;flex-wrap:wrap}
.v-note legend{font-weight:600;font-size:13px;margin-bottom:6px}
.lx-main .v-radio{flex-direction:row;align-items:center;gap:8px}
@media (max-width:560px){.v-card{flex-direction:column}.v-card-img{width:100%;height:160px;flex-basis:auto}.v-searchbar{flex-wrap:wrap}}

/* ---------- V6.9 Estación de impresión ---------- */
.ps-head{display:flex;justify-content:space-between;gap:16px;flex-wrap:wrap;align-items:center}
.ps-status{display:flex;gap:12px;align-items:center}
.ps-dot{width:14px;height:14px;border-radius:50%;background:var(--border-strong);flex:0 0 14px}
.ps-dot.is-ok{background:#16a34a;box-shadow:0 0 0 4px #dcfce7}.ps-dot.is-err{background:#dc2626;box-shadow:0 0 0 4px #fee2e2}
.ps-controls{display:flex;gap:14px;align-items:center;flex-wrap:wrap}
.lx-main .ps-switch{flex-direction:row;align-items:center;gap:8px;font-weight:600}
.ps-new td{background:#fff7ed}
.ps-steps{margin:0;padding-left:20px;display:grid;gap:6px}
.ps-frame{position:absolute;width:1px;height:1px;border:0;left:-9999px;top:0}
.lx-check-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:6px 14px;margin-top:8px}
.lx-main .lx-check-grid label,.lx-main fieldset>label{flex-direction:row;align-items:center;gap:8px;font-weight:400}

/* ---------- V6.9 Registrar compra ---------- */
.pd-span{grid-column:1/-1}
.lx-main .pd-check{flex-direction:row;align-items:center;gap:8px;font-weight:400}
.pd-lines{display:grid;gap:12px}
.pd-line{display:grid;grid-template-columns:minmax(0,2.4fr) minmax(90px,.6fr) minmax(110px,.8fr) minmax(90px,.6fr) auto;gap:12px;align-items:start;border:1px solid var(--border);border-radius:var(--radius);padding:12px}
.pd-prod{position:relative;display:grid;gap:6px;min-width:0}
.pd-prod button.link{justify-self:start}
.pd-new{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.pd-new input[name$="[new_name]"]{grid-column:1/-1}
.pd-sub{display:flex;flex-direction:column;gap:6px;padding-top:4px;font-size:13px}
.pd-serials{grid-column:1/-1}
.pd-remove{align-self:center}
.pd-total{font-size:16px}
@media (max-width:760px){.pd-line{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.pd-prod,.pd-serials{grid-column:1/-1}}

/* ---------- V6.9 Indicadores (cuentas por pagar, panel del analista, libro de caja) ---------- */
.lx-kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,190px),1fr));gap:12px;margin-bottom:20px}
.lx-kpi{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:14px 16px;display:flex;flex-direction:column;gap:4px;min-width:0}
.lx-kpi span{font-size:12.5px;color:var(--muted);font-weight:500}
.lx-kpi strong{font-size:22px;letter-spacing:-.02em;font-variant-numeric:tabular-nums}
.lx-kpi small{font-size:12px;color:var(--text-2)}
.lx-kpi.is-bad strong{color:#b42318}.lx-kpi.is-good strong{color:#166534}
.lx-meter{height:8px;border-radius:999px;background:var(--line);overflow:hidden;margin-top:4px}
.lx-meter>i{display:block;height:100%;background:var(--brand);border-radius:999px}

/* ---------- V6.9 Mis entregas ---------- */
.md-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,420px),1fr));gap:16px}
.md-card{margin:0;display:grid;gap:10px}
.md-head{display:flex;justify-content:space-between;gap:10px;align-items:flex-start}
.md-when,.md-addr,.md-cond{margin:0}
.md-addr{font-size:15px}
.md-actions{display:flex;flex-wrap:wrap;gap:8px}
.md-items{margin:0;padding-left:18px;display:grid;gap:4px}
.md-cond{font-size:13px;color:var(--text-2)}
.md-photos{display:flex;flex-wrap:wrap;gap:8px}
.md-photos img{width:84px;height:84px;object-fit:cover;border-radius:8px;border:1px solid var(--border)}
.md-photo-form{display:grid;gap:8px;border-top:1px solid var(--line);padding-top:10px}
.md-photo-form button{justify-self:start}
.cr-preview{max-width:520px}
.cr-preview td,.cr-preview th{padding:6px 10px}

/* ---------- V6.9 Panel del analista ---------- */
.an-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,420px),1fr));gap:20px;align-items:start}
.an-big{font-size:26px;font-weight:700;margin:0 0 6px;font-variant-numeric:tabular-nums}
.an-goal{display:grid;gap:4px;min-width:0}
.an-goal .lx-meter{position:relative;overflow:visible}
.an-goal .lx-meter>i{border-radius:4px}
.an-pace{position:absolute;top:-3px;bottom:-3px;width:2px;background:var(--text-2);border-radius:1px}
.an-list{list-style:none;margin:0;padding:0;display:grid;gap:12px}
.an-list li{display:grid;gap:4px}
.an-bars{display:flex;align-items:flex-end;gap:3px;height:180px;padding:8px 0 0;border-bottom:1px solid var(--border);margin-bottom:10px}
.an-bar{position:relative;flex:1 1 0;min-width:6px;height:100%;display:flex;flex-direction:column;justify-content:flex-end;align-items:center;outline:none}
.an-bar>i{display:block;width:100%;max-width:26px;background:var(--brand);border-radius:4px 4px 0 0}
.an-bar>span{position:absolute;bottom:-20px;font-size:11px;color:var(--muted)}
.an-bar:hover>i,.an-bar:focus>i{background:var(--action)}
.an-bar:hover::after,.an-bar:focus::after{content:attr(data-tip);position:absolute;bottom:calc(100% + 6px);left:50%;transform:translateX(-50%);background:var(--text);color:#fff;font-size:12px;padding:5px 8px;border-radius:6px;white-space:nowrap;z-index:5;pointer-events:none}
.an-bars+details{margin-top:24px}
td.r,th.r{text-align:right;font-variant-numeric:tabular-nums}
.v-searchbar{align-items:stretch}
.v-searchbar input[name=q],.v-searchbar input[name=cq]{width:100%;max-width:none}
.v-searchbar button{flex:0 0 auto;height:auto}

/* ===== V7.0 ===== */
.txt-bad{color:#b42318;font-weight:600}.txt-good{color:#166534;font-weight:600}
.pre-line{white-space:pre-line}
/* Cobro combinado */
.pay-lines{display:flex;flex-direction:column;gap:10px;margin:10px 0}
.pay-line{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1.4fr) auto;gap:10px;align-items:end;padding:10px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--bg)}
.pay-line .pay-remove{align-self:end}
.pay-total{font-weight:600;padding:8px 12px;border-radius:var(--radius-sm);background:var(--bg);border:1px solid var(--border)}
.pay-total.is-good{color:#166534;border-color:#86efac;background:#f0fdf4}.pay-total.is-bad{color:#b42318;border-color:#fca5a5;background:#fef2f2}
@media (max-width:720px){.pay-line{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.pay-line label:nth-child(3){grid-column:1/-1}}
/* Gastos */
.exp-fixed-form{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.exp-fixed-form input,.exp-fixed-form select{width:auto;min-width:0;max-width:9.5em;padding:6px 8px}
.exp-matrix tfoot th,.hr-payroll tfoot th{border-top:2px solid var(--border-strong)}
/* RRHH */
.hr-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:12px}
.hr-card{display:flex;gap:12px;align-items:flex-start;padding:12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);color:inherit;text-decoration:none;min-width:0}
.hr-card:hover{border-color:var(--border-strong);background:var(--hover)}
.hr-card img,.hr-avatar{width:64px;height:64px;border-radius:50%;object-fit:cover;flex:0 0 auto}
.hr-avatar{display:inline-flex;align-items:center;justify-content:center;background:var(--brand-soft);color:var(--brand-ink);font-weight:700;font-size:24px}
.hr-avatar-lg,.hr-photo{width:120px;height:120px;border-radius:50%;object-fit:cover;font-size:44px}
.hr-card-body{display:flex;flex-direction:column;gap:2px;min-width:0}.hr-card-body>*{overflow-wrap:anywhere}
.hr-photo-row{display:flex;gap:16px;align-items:center;flex-wrap:wrap}
.hr-thumb{width:36px;height:36px;border-radius:50%;object-fit:cover}
.hr-fieldset{border:1px solid var(--border);border-radius:var(--radius-sm);padding:10px 12px;display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:10px}
.hr-fieldset legend{padding:0 6px;font-weight:600;color:var(--text-2)}
.hr-bar-col{width:40%;min-width:80px}.hr-bar{display:block;height:10px;border-radius:5px;background:var(--brand);min-width:2px}
.hr-payroll input{width:6.5em;padding:5px 6px;text-align:right}.hr-payroll input[name$="[notes]"]{text-align:left;width:9em}
.hr-cal{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px;margin-bottom:16px}
.hr-cal-h{font-size:12px;font-weight:600;color:var(--muted);text-align:center;padding:4px 0}
.hr-cal-d{min-height:76px;border:1px solid var(--border);border-radius:var(--radius-sm);padding:4px;display:flex;flex-direction:column;gap:2px;background:var(--surface);min-width:0}
.hr-cal-d.is-empty{border:0;background:transparent}.hr-cal-d.is-today{border-color:var(--brand);box-shadow:inset 0 0 0 1px var(--brand)}.hr-cal-d.is-sunday{background:var(--bg)}
.hr-cal-n{font-size:12px;color:var(--muted)}
.hr-cal-p{display:block;font-size:12px;padding:1px 5px;border-radius:4px;background:#fff4e5;color:#8a4b00;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-decoration:none}
@media (max-width:600px){.hr-cal-d{min-height:54px;padding:2px}.hr-cal-p{font-size:10px;padding:0 3px}}
/* Exhibición */
.dp-form{display:flex;flex-wrap:wrap;gap:8px;align-items:end}.dp-form label{font-size:12px}.dp-form input,.dp-form select{width:auto;max-width:11em}
.dp-reviews{display:flex;flex-direction:column;gap:10px}
.dp-review{display:flex;gap:12px;align-items:flex-start;padding:10px;border:1px solid var(--border);border-radius:var(--radius-sm)}
.dp-review img{width:120px;height:90px;object-fit:cover;border-radius:6px}.dp-review p{margin:4px 0 0}
/* Análisis de inventario y Vender */
.inv-two{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,420px),1fr));gap:16px}
.inv-matrix td,.inv-matrix th{white-space:nowrap}
.v-lost{margin-top:6px}.v-lost span{font-size:13px}
.hr-fieldset label{display:flex;flex-direction:column;gap:6px;align-items:stretch}.hr-fieldset label input{width:100%}
