:root {
--navy: #1c3643; --navy-2: #2f5468; --navy-3: #e9eef1; --naranja: #ef7a2c; --naranja-2: #d8691f;
--ink: #1b2430; --ink-2: #4a5563; --ink-3: #8a94a3;
--line: #d9dfe7; --bg: #f3f5f8; --card: #ffffff;
--ok: #1a7f4b; --ok-bg: #e5f5ec; --warn: #b26a00; --warn-bg: #fff4e0; --bad: #b3261e; --bad-bg: #fdecea;
--radius: 12px; --tap: 48px;
--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy-2); }
h1 { font-size: 1.35rem; margin: 0 0 .5rem; } h2 { font-size: 1.1rem; margin: 1rem 0 .5rem; } h3 { font-size: 1rem; margin: .75rem 0 .35rem; }
.muted { color: var(--ink-2); } .small { font-size: .85rem; } .tiny { font-size: .78rem; color: var(--ink-3); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.oculto { display: none !important; }
#app { min-height: 100vh; display: flex; flex-direction: column; }
header.top { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
header.top .bar { display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem; min-height: 56px; }
header.top .logo img { height: 26px; display: block; }
header.top .logo small { display: block; font-weight: 400; opacity: .75; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; margin-top: 2px; }
header.top .alm { margin-left: auto; background: rgba(255,255,255,.14); border: 0; color: #fff; border-radius: 8px; padding: .35rem .6rem; font-size: .85rem; max-width: 46vw; }
header.top .btn-icon { background: transparent; border: 0; color: #fff; font-size: 1.3rem; padding: .3rem .5rem; cursor: pointer; }
main { flex: 1; padding: 1rem .9rem 5.5rem; max-width: 1080px; width: 100%; margin: 0 auto; }
nav.bottom { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); display: flex; z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
nav.bottom a { flex: 1; text-align: center; padding: .5rem .2rem .45rem; text-decoration: none; color: var(--ink-2); font-size: .72rem; }
nav.bottom a .ic { display: block; font-size: 1.3rem; line-height: 1.2; }
nav.bottom a.activa { color: var(--naranja); font-weight: 600; }
.menu-lateral { display: none; }
@media (min-width: 900px) {
#app { flex-direction: row; }
header.top { position: fixed; left: 0; top: 0; bottom: 0; width: 240px; }
header.top .bar { flex-direction: column; align-items: flex-start; }
header.top .alm { margin-left: 0; max-width: 100%; width: 100%; }
.menu-lateral { display: block; padding: .5rem 0; }
.menu-lateral a { display: block; color: #fff; text-decoration: none; padding: .6rem .9rem; opacity: .85; }
.menu-lateral a.activa, .menu-lateral a:hover { background: rgba(255,255,255,.12); opacity: 1; box-shadow: inset 4px 0 0 var(--naranja); }
main { margin-left: 240px; padding: 1.25rem 1.5rem 2rem; max-width: none; }
nav.bottom { display: none; }
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: .9rem; }
.card.compacta { padding: .7rem .85rem; }
.fila { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.fila.entre { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
@media (max-width: 600px) { .grid3 { grid-template-columns: 1fr 1fr; } .grid2.apilar { grid-template-columns: 1fr; } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap); padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--naranja); background: var(--naranja); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:not(:disabled):hover { background: var(--naranja-2); border-color: var(--naranja-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sec { background: #fff; color: var(--navy); border-color: var(--navy); }
.btn.sec:not(:disabled):hover { background: var(--navy-3); border-color: var(--navy); }
.btn.suave { background: var(--navy-3); color: var(--navy); border-color: var(--navy-3); }
.btn.peligro { background: var(--bad); border-color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.chico { min-height: 36px; padding: .3rem .7rem; font-size: .85rem; border-radius: 8px; }
.btn.bloque { width: 100%; }
.btn.grande { min-height: 84px; font-size: 1.1rem; flex-direction: column; }
.btn.grande .ic { font-size: 1.8rem; }
label.campo { display: block; margin-bottom: .7rem; }
label.campo > span, .etiqueta { display: block; font-size: .8rem; color: var(--ink-2); margin-bottom: .25rem; font-weight: 600; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password], input[type=search], select, textarea {
width: 100%; min-height: var(--tap); padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy-2); outline-offset: 0; border-color: var(--navy-2); }
input[type=number] { font-variant-numeric: tabular-nums; }
textarea { min-height: 72px; resize: vertical; }
.chk { display: flex; align-items: center; gap: .5rem; min-height: var(--tap); }
.chk input { width: 22px; height: 22px; }
table.tabla { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.tabla th, table.tabla td { padding: .5rem .45rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.tabla th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); background: #fafbfc; position: sticky; top: 0; }
table.tabla tr.clic { cursor: pointer; } table.tabla tr.clic:hover { background: var(--navy-3); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--navy-3); color: var(--navy); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.gris { background: #eceff3; color: var(--ink-2); }
.semaforo { border-radius: var(--radius); padding: 1rem; color: #fff; display: flex; align-items: center; gap: .9rem; margin-bottom: .9rem; }
.semaforo.ok { background: var(--ok); } .semaforo.bad { background: var(--bad); }
.semaforo .n { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-bottom: .9rem; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; }
.kpi .v { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; } .kpi .t { font-size: .78rem; color: var(--ink-2); }
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { padding: .6rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: .6rem; align-items: center; }
.lista li:last-child { border-bottom: 0; }
.lista li.clic { cursor: pointer; }
.aviso { padding: .7rem .9rem; border-radius: 10px; margin-bottom: .8rem; font-size: .92rem; }
.aviso.info { background: var(--navy-3); color: var(--navy); } .aviso.ok { background: var(--ok-bg); color: var(--ok); } .aviso.warn { background: var(--warn-bg); color: var(--warn); } .aviso.bad { background: var(--bad-bg); color: var(--bad); }
.tacha { text-decoration: line-through; color: var(--ink-3); }
.linea-mov { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; margin-bottom: .5rem; background: #fafbfc; }
.busq { position: relative; }
.busq .res { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; z-index: 30; max-height: 260px; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.busq .res div { padding: .55rem .7rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.busq .res div:hover, .busq .res div.sel { background: var(--navy-3); }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 10px; z-index: 60; max-width: 92vw; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }
@media (min-width: 900px) { .toast { bottom: 24px; } }
.modal-fondo { position: fixed; inset: 0; background: rgba(10,20,35,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; border-radius: 16px 16px 0 0; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; padding: 1rem 1rem 1.2rem; }
@media (min-width: 700px) { .modal-fondo { align-items: center; } .modal { border-radius: 16px; } }
.login { max-width: 400px; margin: 8vh auto; }
.login .marca { text-align: center; margin-bottom: 1.2rem; }
.login .marca img { width: 260px; max-width: 80%; }
.login .marca .sub { color: var(--ink-2); margin-top: .5rem; letter-spacing: .1em; text-transform: uppercase; font-size: .78rem; }
.cargando { text-align: center; padding: 2rem; color: var(--ink-2); }
.acciones { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .8rem; }
.acciones .btn { flex: 1; min-width: 140px; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: .8rem; overflow-x: auto; }
.tabs a { padding: .55rem .8rem; text-decoration: none; color: var(--ink-2); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.activa { color: var(--navy); border-bottom-color: var(--naranja); font-weight: 600; }
.resumen dt { font-size: .78rem; color: var(--ink-2); margin-top: .5rem; } .resumen dd { margin: 0; font-weight: 600; }
.paso { display: flex; gap: .6rem; align-items: baseline; margin-bottom: .4rem; }
.paso b { background: var(--naranja); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; flex: none; }
@media print {
header.top, nav.bottom, .no-print, .toast { display: none !important; }
main { margin: 0; padding: 0; } .card { border: 0; box-shadow: none; page-break-inside: avoid; }
body { background: #fff; }
}

/* Sugerencias de cliente (Comercial) */
.campo { position: relative; }
.sugerencias { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; z-index: 30; max-height: 260px; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.sugerencias div { padding: .55rem .7rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.sugerencias div:last-child { border-bottom: 0; }
.sugerencias div:hover { background: var(--navy-3); }

/* ---------- Comercial: totales, documento imprimible, KPIs ---------- */
.totales { margin: .8rem 0; }
.resumen dt.grande, .resumen dd.grande { font-size: 1.15rem; }
.resumen dd.grande b { color: var(--navy); }
.tabla tr.total td { border-top: 2px solid var(--navy); font-weight: 700; }
.tabla.compacta td, .tabla.compacta th { padding: .35rem .4rem; }
.kpi.malo .v { color: #b3261e; }

.documento { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.4rem; margin-top: 1rem; }
.doc-cab { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; border-bottom: 2px solid var(--naranja); padding-bottom: .9rem; }
.doc-emisor { display: flex; gap: .8rem; align-items: flex-start; font-size: .8rem; line-height: 1.45; }
.doc-logo { height: 54px; width: auto; }
.doc-numero { border: 2px solid var(--navy); border-radius: 8px; padding: .5rem .9rem; text-align: center; min-width: 200px; }
.doc-tipo { font-size: .72rem; letter-spacing: .06em; color: var(--navy); font-weight: 700; }
.doc-codigo { font-size: 1.1rem; font-weight: 700; color: var(--naranja-2); margin-top: .15rem; }
.doc-datos { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: .25rem .7rem; margin: .9rem 0; font-size: .82rem; }
.doc-datos dt { font-weight: 700; color: var(--navy); }
.doc-datos dd { margin: 0; }
.doc-items { font-size: .82rem; }
.doc-items thead th { background: var(--navy); color: #fff; }
.doc-pie { display: flex; justify-content: space-between; gap: 1.5rem; margin-top: 1rem; align-items: flex-start; }
.doc-nota { font-size: .74rem; color: #555; max-width: 55%; line-height: 1.5; }
.doc-totales { min-width: 230px; display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; font-size: .85rem; }
.doc-totales dt { text-align: right; }
.doc-totales dd { margin: 0; text-align: right; }
.doc-totales dt.grande, .doc-totales dd.grande { font-size: 1.1rem; border-top: 2px solid var(--navy); padding-top: .3rem; margin-top: .2rem; }

@media (max-width: 640px) {
  .doc-datos { grid-template-columns: auto 1fr; }
  .doc-cab { flex-direction: column; }
  .doc-pie { flex-direction: column; }
  .doc-nota { max-width: 100%; }
  .doc-totales { min-width: 0; width: 100%; }
}
@media print {
  .documento { border: 0; padding: 0; margin: 0; }
  .top, .bottom, .no-print, #nav-inferior, #cabecera { display: none !important; }
  .tabla, .documento { page-break-inside: avoid; }
}
