/* =====================================================================
   Sistema de Despachos — estilos
   ===================================================================== */
:root {
  --azul: #1e3a5f;
  --azul-2: #2c5282;
  --azul-claro: #e8eef6;
  --verde: #0f766e;
  --verde-claro: #e6f4f1;
  --rojo: #b42318;
  --rojo-claro: #fdecea;
  --ambar: #a15c07;
  --fondo: #f3f5f8;
  --tarjeta: #ffffff;
  --borde: #d9dee6;
  --borde-2: #e9edf2;
  --texto: #1c2430;
  --texto-2: #5b6575;
  --radio: 10px;
  --sombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --fuente: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 var(--fuente); color: var(--texto); background: var(--fondo); }
a { color: var(--azul-2); }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-2); }
small { color: var(--texto-2); }
[hidden] { display: none !important; }

/* ---------- barra superior ---------- */
.barra {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--azul); color: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .15);
}
.marca { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 650; white-space: nowrap; }
.marca-logo {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: #fff; color: var(--azul); font-weight: 800; font-size: 13px; letter-spacing: -.02em;
}
.marca-esfera { width: 40px; height: 42px; object-fit: contain; }
.login-logo { width: 96px; height: 100px; object-fit: contain; flex: none; }
.marca-logo.grande { width: 48px; height: 48px; font-size: 18px; border-radius: 12px; background: var(--azul); color: #fff; }
#menu { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
#menu a { color: #cfdbea; text-decoration: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-weight: 500; }
#menu a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
#menu a.activo { color: #fff; background: rgba(255, 255, 255, .16); }
.usuario { display: flex; align-items: center; gap: 12px; color: #cfdbea; white-space: nowrap; }
.usuario .btn-link { color: #fff; }

main#vista { max-width: 1320px; margin: 0 auto; padding: 24px; }
.cargando, .cargando-pagina { padding: 48px; text-align: center; color: var(--texto-2); }

/* ---------- encabezados de pantalla ---------- */
.encabezado { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.volver { display: inline-block; font-size: 13px; text-decoration: none; margin-bottom: 4px; color: var(--texto-2); }
.volver:hover { color: var(--azul-2); }

/* ---------- tarjetas y formularios ---------- */
.tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; margin: 0 0 16px; }
.tarjeta.sin-relleno { padding: 0; overflow: hidden; }
fieldset.tarjeta { min-width: 0; }
fieldset.tarjeta legend { float: left; width: 100%; padding: 0 0 12px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--azul); }
fieldset.tarjeta legend + * { clear: both; }

.campos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.campos-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ancho-2 { grid-column: span 2; }
.ancho-4 { grid-column: 1 / -1; }
.par { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--texto-2); min-width: 0; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--texto); }
.req { color: var(--rojo); }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--texto); width: 100%;
  padding: 8px 10px; border: 1px solid var(--borde); border-radius: 8px; background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--azul-2); box-shadow: 0 0 0 3px rgba(44, 82, 130, .15); }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
fieldset:disabled input, fieldset:disabled select, input:disabled {
  background: transparent; border-color: transparent; color: var(--texto); padding-left: 0; padding-right: 0;
  -webkit-text-fill-color: var(--texto); opacity: 1;
}
fieldset:disabled input::placeholder { color: transparent; }
fieldset:disabled select { appearance: none; }
.modo-edicion fieldset:disabled input { background: #fff; }
.con-boton { display: flex; gap: 8px; }
.con-boton input { flex: 1; }

.filtros { display: grid; grid-template-columns: minmax(240px, 2.4fr) repeat(5, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.filtros .ancho-2 { grid-column: auto; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 14px; line-height: 1;
  padding: 10px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-pri { background: var(--azul-2); color: #fff; }
.btn-pri:hover:not(:disabled) { background: var(--azul); }
.btn-sec { background: #fff; color: var(--texto); border-color: var(--borde); }
.btn-sec:hover:not(:disabled) { background: var(--azul-claro); border-color: #c4d0e0; }
.btn-peligro { background: var(--rojo); color: #fff; }
.btn-peligro-suave { color: var(--rojo); }
.btn-peligro-suave:hover:not(:disabled) { background: var(--rojo-claro); border-color: #f3c2bd; }
.btn-chico { padding: 6px 10px; font-size: 13px; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--azul-2); cursor: pointer; text-align: left; }
.btn-link:hover { text-decoration: underline; }
.btn-icono {
  display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 6px; background: none; color: var(--texto-2); cursor: pointer; font-size: 14px;
}
.btn-icono:hover { background: var(--rojo-claro); color: var(--rojo); }
.pulso { box-shadow: 0 0 0 3px rgba(44, 82, 130, .25); }
.solo-edicion { visibility: hidden; }
.modo-edicion .solo-edicion { visibility: visible; }

.menu-desplegable { position: relative; }
.menu-opciones {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 300px;
  background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: 0 10px 30px rgba(16, 24, 40, .15);
  padding: 6px;
}
.menu-opciones a { display: block; padding: 9px 12px; border-radius: 6px; text-decoration: none; color: var(--texto); }
.menu-opciones a:hover { background: var(--azul-claro); }

/* ---------- tablas ---------- */
.tabla-scroll { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tabla th { text-align: left; font-size: 12px; font-weight: 700; color: var(--texto-2); text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid var(--borde); white-space: nowrap; }
.tabla td { padding: 9px 12px; border-bottom: 1px solid var(--borde-2); vertical-align: middle; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla-click tbody tr[data-id] { cursor: pointer; }
.tabla-click tbody tr[data-id]:hover, .tabla-click tbody tr[data-id]:focus { background: var(--azul-claro); outline: none; }
.tabla .num, .num { text-align: right; }
.tabla .vacio, .vacio { text-align: center; color: var(--texto-2); padding: 32px; }
.tabla tr.inactivo td { color: var(--texto-2); text-decoration: line-through; }
.nowrap { white-space: nowrap; }
.centro { text-align: center; }
.derecha { text-align: right; }
.mono { font-family: var(--mono); font-size: 13px; }
.recortar { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error { color: var(--rojo); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.chip-ok { background: var(--verde-claro); color: var(--verde); }
.chip-vacio { color: #b6bfcc; }
.paginador { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--borde); color: var(--texto-2); flex-wrap: wrap; }
.paginador > div { display: flex; align-items: center; gap: 12px; }

/* detalle editable dentro de la liquidación */
.tabla-detalle th { background: none; padding: 6px 8px; }
.tabla-detalle td { padding: 4px 8px; border-bottom: 1px solid var(--borde-2); }
.tabla-detalle tfoot td { border: 0; padding-top: 10px; }
.tabla-detalle tfoot strong { font-size: 15px; }
.tabla-detalle input { padding: 6px 8px; }
.tabla-detalle .fila-vacia td { color: var(--texto-2); padding: 12px 8px; font-style: italic; }
.col-cod { width: 72px; color: var(--texto-2); }
.col-monto { width: 170px; }
.col-x { width: 36px; text-align: center; }

/* ---------- combo con búsqueda ---------- */
.combo { position: relative; }
.combo-lista {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 40; margin: 0; padding: 4px; list-style: none;
  max-height: 300px; overflow-y: auto; background: #fff; border: 1px solid var(--borde); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, .16); min-width: 280px;
}
label .combo-lista { font-weight: 400; }
.combo-lista li { padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--texto); font-size: 14px; display: flex; justify-content: space-between; gap: 12px; }
.combo-lista li small { white-space: nowrap; }
.combo-lista li.activo { background: var(--azul-claro); }
.combo-lista li.vacio { color: var(--texto-2); cursor: default; }

/* ---------- liquidación ---------- */
.liq-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.liq-lateral { position: sticky; top: 72px; }
.totales dl { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; margin: 0; font-variant-numeric: tabular-nums; }
.totales dt { color: var(--texto-2); align-self: center; }
.totales dt label { font-size: 14px; font-weight: 400; color: var(--texto-2); }
.totales dd { margin: 0; text-align: right; font-weight: 600; }
.totales dd input { width: 150px; padding: 6px 8px; font-weight: 600; }
.totales .sep { border-top: 1px solid var(--borde-2); padding-top: 8px; }
.totales .total { font-size: 17px; font-weight: 800; color: var(--azul); border-top: 2px solid var(--azul); padding-top: 10px; }
.son { margin: 12px 0 0; font-size: 12px; color: var(--texto-2); text-transform: uppercase; line-height: 1.4; }
.archivos { list-style: none; margin: 0 0 12px; padding: 0; }
.archivos li { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 8px 0; border-bottom: 1px solid var(--borde-2); }
.archivos li .btn-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archivos li small { grid-column: 1; }
.archivo-acciones { grid-row: 1 / span 2; grid-column: 2; display: flex; align-items: center; }
.archivo-acciones .btn-icono:first-child:hover { background: var(--azul-claro); color: var(--azul-2); }
.zona-subida {
  display: grid; place-items: center; min-height: 84px; padding: 12px; text-align: center; cursor: pointer;
  border: 2px dashed var(--borde); border-radius: var(--radio); color: var(--texto-2); font-weight: 500; font-size: 13px;
}
.zona-subida:hover, .zona-subida.encima { border-color: var(--azul-2); background: var(--azul-claro); color: var(--azul); }
.zona-subida.subiendo { opacity: .7; pointer-events: none; }
.ayuda { color: var(--texto-2); font-size: 13px; margin: 0 0 12px; }
.auditoria { color: var(--texto-2); font-size: 12px; text-align: center; }

/* ---------- pestañas ---------- */
.pestañas { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--borde); }
.pestañas button { font: inherit; font-weight: 600; padding: 10px 14px; border: 0; background: none; color: var(--texto-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.pestañas button[aria-selected=true] { color: var(--azul); border-bottom-color: var(--azul); }

/* ---------- reporte resumen ---------- */
.reporte-cabecera { display: none; }
.reporte-cliente h2 { color: var(--azul); }
.reporte-cliente h3 { margin-top: 16px; }
.tabla-reporte { margin-bottom: 8px; }
.tabla-reporte td { padding: 6px 12px; }
.tabla-reporte .fila-grupo td { background: #f8fafc; font-weight: 700; color: var(--azul); }
.tabla-reporte .subtotal td { font-weight: 600; color: var(--texto-2); border-bottom: 1px solid var(--borde); }
.tabla-reporte .total-anio td { font-weight: 800; border-top: 2px solid var(--azul); }
.total-cliente { text-align: right; font-size: 15px; margin: 8px 0 0; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--azul) 0%, #26476f 55%, var(--fondo) 55.1%); }
.login-caja { width: min(380px, 100%); background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 20px 50px rgba(16, 24, 40, .2); display: grid; gap: 14px; }
.login-marca { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.login-marca strong { display: block; font-size: 18px; }
.login-marca small { display: block; }
.login-caja .btn-pri { padding: 12px; }
.login-caja .btn-link { justify-self: center; font-size: 13px; }
.login-error { margin: 0; min-height: 1em; color: var(--rojo); font-size: 13px; text-align: center; }
.login-error:empty { display: none; }

/* ---------- diálogos y avisos ---------- */
.dialogo { border: 0; border-radius: 14px; padding: 0; box-shadow: 0 24px 60px rgba(16, 24, 40, .3); }
.dialogo::backdrop { background: rgba(16, 24, 40, .45); }
.dialogo header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 0; }
.dialogo h2 { margin: 0; }
.dialogo-cuerpo { padding: 16px 20px; }
.dialogo-cuerpo p { margin: 0; }
.dialogo footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--borde-2); }
.dialogo footer .izquierda { margin-right: auto; }
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: grid; gap: 8px; }
.toast { padding: 12px 16px; border-radius: 10px; color: #fff; background: var(--verde); box-shadow: 0 8px 24px rgba(16, 24, 40, .2); max-width: 420px; transition: opacity .4s, transform .4s; font-weight: 500; }
.toast-error { background: var(--rojo); }
.toast.fuera { opacity: 0; transform: translateY(8px); }
.error-caja { text-align: center; padding: 48px 16px; }

/* ---------- vista de impresión (pantalla) ---------- */
main#vista.vista-imprimir { max-width: none; padding: 0 0 40px; background: #e5e8ed; min-height: 100vh; }
.barra-impresion { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 10px 24px; background: var(--azul); color: #fff; }
.barra-impresion span { flex: 1; font-weight: 600; }
.barra-impresion .aviso { flex: 0 1 auto; font-weight: 400; color: #fde68a; }
.hojas { display: grid; gap: 24px; justify-content: center; padding: 24px 16px; }
.hoja {
  width: 210mm; min-height: 297mm; padding: 16mm 16mm 14mm; background: #fff; color: #111;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .15); display: flex; flex-direction: column; font-size: 12px;
}
.hoja-membrete { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 3px solid var(--azul); }
.membrete-empresa { display: flex; gap: 12px; align-items: center; }
.membrete-logo { width: 108px; height: 113px; object-fit: contain; margin: -7mm 0 -2mm -5mm; }
.membrete-logo.marca-logo { background: var(--azul); color: #fff; font-size: 20px; border-radius: 12px; }
.membrete-nombre { font-size: 20px; font-weight: 800; color: var(--azul); letter-spacing: -.01em; }
.membrete-sub { font-size: 12px; font-weight: 600; }
.membrete-datos { font-size: 10.5px; color: #555; margin-top: 2px; }
.membrete-doc { text-align: right; }
.membrete-titulo { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #555; max-width: 220px; margin-left: auto; }
.membrete-numero { font-size: 22px; font-weight: 800; color: var(--azul); }
.membrete-fecha { font-size: 11.5px; }
.hoja-cliente { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; margin: 12px 0; padding: 10px 12px; background: var(--azul-claro); border-radius: 6px; }
.hoja-cliente span, .hoja-datos span { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; color: #666; }
.hoja-cliente strong { font-size: 13px; }
.hoja-datos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px 14px; margin-bottom: 14px; }
.hoja-datos > div:first-child { grid-column: 1 / -1; }
.hoja-datos strong { font-weight: 600; font-size: 11.5px; }
.hoja-tabla { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.hoja-tabla th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-top: 1.5px solid #111; border-bottom: 1px solid #111; }
.hoja-tabla td { padding: 4.5px 8px; border-bottom: 1px solid #e3e3e3; }
.hoja-tabla .num { text-align: right; white-space: nowrap; }
.hoja-tabla .col-cod { width: 60px; color: #444; }
.hoja-pie { display: grid; grid-template-columns: 1fr 300px; gap: 20px; margin-top: 14px; align-items: start; break-inside: avoid; }
.hoja-letras { font-size: 11px; text-transform: uppercase; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; }
.hoja-letras span { display: block; font-size: 9.5px; color: #666; letter-spacing: .05em; margin-bottom: 2px; }
.hoja-totales { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.hoja-totales td { padding: 4px 0; }
.hoja-totales td small { color: #666; font-size: 9.5px; }
.hoja-totales .num { text-align: right; font-weight: 600; white-space: nowrap; }
.hoja-totales .total td { font-size: 14px; font-weight: 800; color: var(--azul); border-top: 2px solid var(--azul); padding-top: 7px; }
.hoja-firmas { margin-top: auto; padding-top: 36px; display: grid; grid-template-columns: 1fr 1fr; gap: 60px; text-align: center; font-size: 10.5px; color: #444; }
.linea-firma { border-top: 1px solid #333; margin-bottom: 4px; }
/* pie de página: eslogan + franjas + direcciones (ocupa todo el ancho de la hoja) */
.hoja-pie-pagina { margin: 18px -16mm -14mm; }
.hoja-eslogan { margin: 0 0 10px; text-align: center; font-weight: 700; font-size: 12px; letter-spacing: .02em; color: #222; }
.hoja-franjas { display: flex; height: 5px; background: #a9b6dc; }
.hoja-franjas i { display: block; }
.hoja-franjas i:nth-child(1) { margin-left: 8%; width: 7%; background: #2b3a9e; }
.hoja-franjas i:nth-child(2) { margin-left: 31%; width: 16%; background: #8494d0; }
.hoja-franjas i:nth-child(3) { width: 17%; background: #2b3a9e; }
.hoja-franjas i:nth-child(4) { display: none; }
.hoja-direcciones { margin-top: 4px; padding: 7px 10mm; background: #b8c3e6; text-align: center; font-size: 10.5px; font-weight: 600; color: #1d2340; line-height: 1.45; }
.hoja-banda { height: 9mm; background: #2b3a9e; }

/* ---------- impresión ---------- */
@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  .no-imprimir, .barra, .barra-impresion, #toasts { display: none !important; }
  .vista-imprimir { background: none; padding: 0; min-height: 0; }
  .hojas { display: block; padding: 0; }
  .hoja { box-shadow: none; width: auto; min-height: 297mm; break-after: page; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .hoja:last-child { break-after: auto; }
  /* reporte resumen */
  main#vista { padding: 12mm; max-width: none; }
  .reporte-cabecera { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 13px; }
  .tarjeta { box-shadow: none; border: 0; padding: 0; }
  .reporte-cliente { break-inside: auto; break-after: page; }
  .tabla-reporte { font-size: 11px; }
  .tabla-reporte a { color: inherit; text-decoration: none; }
}

/* ---------- pantallas chicas ---------- */
@media (max-width: 1100px) {
  .liq-grid { grid-template-columns: 1fr; }
  .liq-lateral { position: static; }
  .filtros { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 760px) {
  .barra { padding: 0 12px; gap: 12px; }
  .marca span:last-child, .usuario span { display: none; }
  main#vista { padding: 16px; }
  .campos { grid-template-columns: 1fr 1fr; }
  .campos .ancho-2 { grid-column: 1 / -1; }
  .filtros { grid-template-columns: 1fr 1fr; }
  .filtros .ancho-2 { grid-column: 1 / -1; }
  .col-monto { width: 120px; }
}

/* =====================================================================
   Módulos: panel, seguimiento, cobranzas, documentos, recibo
   ===================================================================== */
/* chips de estado y canal */
.chip.estado-abierto { background: #eef2f7; color: #475569; }
.chip.estado-documentacion { background: #fef3c7; color: #92400e; }
.chip.estado-oficializado { background: #e0e7ff; color: #3730a3; }
.chip.estado-levante { background: #cffafe; color: #155e75; }
.chip.estado-entregado { background: #dcfce7; color: #166534; }
.chip.estado-liquidado { background: #f1f5f9; color: #64748b; }
.chip.canal-verde { background: #dcfce7; color: #166534; }
.chip.canal-naranja { background: #ffedd5; color: #9a3412; }
.chip.canal-rojo { background: #fee2e2; color: #991b1b; }
.debe { color: var(--rojo); }
.a-favor { color: var(--verde); }
.demorado { color: var(--ambar); font-weight: 700; }

/* indicadores */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 16px; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); color: inherit; text-decoration: none; }
a.kpi:hover { border-color: #b8c6da; }
.kpi span { font-size: 12px; font-weight: 600; color: var(--texto-2); }
.kpi strong { font-size: 24px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi small { font-size: 12px; }

/* panel */
.panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.panel-grid .tarjeta { margin: 0; }
.tarjeta h3.sub { margin-top: 16px; }
.lista-estados { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lista-estados a { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-radius: 8px; text-decoration: none; color: inherit; }
.lista-estados a:hover { background: var(--azul-claro); }
.lista-simple { list-style: none; margin: 0; padding: 0; }
.lista-simple li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--borde-2); font-variant-numeric: tabular-nums; }
.lista-simple li:last-child { border-bottom: 0; }
.lista-simple a { text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista-simple a:hover { text-decoration: underline; }

/* tablero de seguimiento */
.tablero { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.columna { background: #e9edf3; border-radius: var(--radio); padding: 8px; min-height: 200px; transition: background .12s, box-shadow .12s; }
.columna.soltar-aca { background: var(--azul-claro); box-shadow: inset 0 0 0 2px var(--azul-2); }
.columna header { display: flex; align-items: center; gap: 8px; padding: 4px 4px 10px; font-weight: 700; font-size: 13px; }
.columna .contador { margin-left: auto; background: #fff; border-radius: 999px; padding: 1px 8px; font-size: 12px; color: var(--texto-2); }
.punto { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.punto.estado-abierto { background: #94a3b8; } .punto.estado-documentacion { background: #f59e0b; }
.punto.estado-oficializado { background: #6366f1; } .punto.estado-levante { background: #06b6d4; }
.punto.estado-entregado { background: #22c55e; } .punto.estado-liquidado { background: #cbd5e1; }
.columna-cuerpo { display: grid; gap: 8px; }
.columna-vacia { text-align: center; color: var(--texto-2); margin: 16px 0; }
.columna-nota { display: block; text-align: center; color: var(--texto-2); margin-top: 6px; }
.tarjeta-despacho { background: #fff; border-radius: 8px; padding: 10px; box-shadow: var(--sombra); cursor: grab; border-left: 4px solid transparent; font-size: 13px; }
.tarjeta-despacho:hover, .tarjeta-despacho:focus { outline: none; box-shadow: 0 0 0 2px var(--azul-2); }
.tarjeta-despacho.arrastrando { opacity: .4; }
.tarjeta-despacho.borde-verde { border-left-color: #22c55e; } .tarjeta-despacho.borde-naranja { border-left-color: #f97316; } .tarjeta-despacho.borde-rojo { border-left-color: #ef4444; }
.td-cab { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.td-cliente { font-weight: 600; margin-top: 2px; }
.td-desc { color: var(--texto-2); font-size: 12px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.td-pie { display: flex; justify-content: space-between; gap: 6px; margin-top: 6px; font-size: 11.5px; color: var(--texto-2); }

/* cobranzas */
.tarjeta-titulo { padding: 14px 16px 0; margin: 0 0 6px; }
.tabla td.concepto small { display: block; color: var(--texto-2); font-size: 12px; }
.tabla td.concepto a { text-decoration: none; color: inherit; }
.tabla td.concepto a:hover { text-decoration: underline; }
.mini-totales { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0 0 10px; font-variant-numeric: tabular-nums; }
.mini-totales dt { color: var(--texto-2); }
.mini-totales dd { margin: 0; text-align: right; font-weight: 600; }
.fila-botones { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* documentos e historial */
.doc-categoria { margin: 10px 0 2px; font-size: 12px; color: var(--azul); }
.doc-tipo { margin-bottom: 8px; }
.historial { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--borde); max-height: 320px; overflow-y: auto; }
.historial li { position: relative; padding: 0 0 10px 6px; display: grid; gap: 1px; font-size: 13px; }
.historial li::before { content: ''; position: absolute; left: -20px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--azul-2); }
.historial .hist-fecha { font-size: 11.5px; color: var(--texto-2); }
.historial small { color: var(--texto-2); }

/* los combos dentro de un diálogo no se recortan */
.dialogo, .dialogo-cuerpo { overflow: visible; }

/* recibo */
.hoja-recibos { min-height: 0; }
.recibo { padding: 2mm 0; }
.recibo-logo { width: 80px; height: 84px; margin: -4mm 0 0 -3mm; }
.recibo-monto { margin-top: 4px; font-size: 16px; font-weight: 800; border: 2px solid var(--azul); border-radius: 6px; padding: 4px 10px; display: inline-block; color: var(--azul); }
.recibo-texto { font-size: 13.5px; line-height: 1.8; margin: 16px 0 10px; }
.recibo-datos { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0 0 8px; font-size: 12px; }
.recibo-datos dt { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; color: #666; }
.recibo-datos dd { margin: 0; font-weight: 600; }
.recibo-pie { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 26px; font-size: 12px; }
.recibo-firma { width: 220px; text-align: center; color: #444; }
.recibo-firma i { display: block; border-top: 1px solid #333; margin-bottom: 4px; }
.recibo-copia { text-align: right; font-size: 10px; color: #888; margin: 6px 0 0; text-transform: uppercase; letter-spacing: .06em; }
.recibo-corte { border-top: 1.5px dashed #aaa; margin: 10mm -16mm; }

@media (max-width: 1100px) { .panel-grid { grid-template-columns: 1fr; } }
@media print {
  .tablero, .kpis a.kpi { break-inside: avoid; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi { box-shadow: none; }
}

/* =====================================================================
   Segunda etapa: presupuestos, vencimientos, accesos, portal
   ===================================================================== */
.chip.pres-borrador { background: #eef2f7; color: #475569; }
.chip.pres-enviado { background: #e0e7ff; color: #3730a3; }
.chip.pres-aceptado { background: #dcfce7; color: #166534; }
.chip.pres-rechazado { background: #fee2e2; color: #991b1b; }
input.destacado { font-size: 17px; font-weight: 700; color: var(--azul); }
textarea { resize: vertical; }
.ayuda-celda, .hoja-tabla td.calc { color: var(--texto-2); font-size: 12px; }
.hoja-nota { margin: 12px 0 0; font-size: 11.5px; padding: 8px 10px; background: var(--azul-claro); border-radius: 6px; }
.hoja-aviso { margin: 10px 0 0; font-size: 10px; color: #555; font-style: italic; }
.tarjeta-titulo .contador { margin-left: 6px; background: var(--azul-claro); border-radius: 999px; padding: 1px 8px; font-size: 12px; color: var(--azul); }

/* vencimientos */
.venc td { vertical-align: top; }
.venc small { display: block; color: var(--texto-2); font-size: 12px; }
.venc.vencido td:first-child strong, .venc.vencido .venc-cuando { color: var(--rojo); }
.venc.proximo .venc-cuando { color: var(--ambar); font-weight: 700; }
.venc.resuelto { opacity: .6; }
.tabla-venc { margin-bottom: 10px; font-size: 13px; }
.tabla-venc td { padding: 6px 4px; }
.alerta-venc { border-left: 4px solid var(--ambar); }
.alerta-venc h3 { display: flex; justify-content: space-between; align-items: center; }
.alerta-venc h3 .btn-link { font-size: 12px; text-transform: none; letter-spacing: 0; }

/* accesos */
.pasos ol { margin: 8px 0; padding-left: 20px; line-height: 1.7; }

/* portal del cliente */
.portal-datos { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.portal-datos span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-2); }
.encabezado h1 .chip { vertical-align: middle; font-size: 12px; }
@media (max-width: 760px) { .portal-datos { grid-template-columns: 1fr 1fr; } }
