/* ===== Módulo de Cobranza ===== */
#vista-cobranza .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#vista-cobranza .muted { color: var(--gris-texto); }
#vista-cobranza code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.cb-banner { border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.cb-banner.prueba { background: #fff8e1; color: #8a6100; border: 1px solid #f3dc9a; }
.cb-banner.real { background: #fdecea; color: #a52a1e; border: 1px solid #f5c6cb; }
.cb-banner b { font-weight: 700; }

.cb-subnav { display: flex; gap: 8px; margin-bottom: 16px; }
.cb-subnav button { padding: 8px 16px; border: 1px solid var(--gris-borde); background: white; border-radius: 20px; font-size: 13.5px; cursor: pointer; color: var(--gris-texto); font-weight: 600; }
.cb-subnav button.activo { background: var(--azul-medio); border-color: var(--azul-medio); color: white; }

.cb-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.cb-kpi { background: white; border: 1px solid var(--gris-borde); border-left-width: 4px; border-radius: 10px; padding: 12px 14px; cursor: pointer; transition: box-shadow .15s; }
.cb-kpi:hover { box-shadow: 0 2px 10px rgba(28,43,60,.08); }
.cb-kpi.activo { box-shadow: 0 0 0 2px var(--acento); }
.cb-kpi .n { font-size: 24px; font-weight: 700; line-height: 1.1; }
.cb-kpi .l { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--gris-texto); margin-top: 2px; }
.cb-kpi .m { font-size: 12px; color: var(--gris-texto); margin-top: 4px; min-height: 15px; }
.cb-kpi.k-bad { border-left-color: #d6455d; } .cb-kpi.k-warn { border-left-color: #e0a526; } .cb-kpi.k-ok { border-left-color: #2e8b57; }
.cb-kpi.k-violet { border-left-color: #8b6fe0; } .cb-kpi.k-info { border-left-color: #9fb3c8; } .cb-kpi.k-contact { border-left-color: #3d7ab8; }

.cb-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.cb-toolbar input[type=text] { flex: 1; min-width: 220px; padding: 9px 12px; border: 1px solid var(--gris-borde); border-radius: 7px; font-size: 14px; }
.cb-btn { padding: 9px 16px; border: 1px solid var(--gris-borde); background: white; border-radius: 7px; font-size: 13.5px; cursor: pointer; color: var(--azul-oscuro); font-weight: 600; }
.cb-btn:hover { background: #f5f7fa; }
.cb-btn.primario { background: var(--azul-medio); color: white; border-color: var(--azul-medio); }
.cb-btn.primario:hover { background: var(--acento); }
.cb-btn.verde { background: var(--verde); color: white; border-color: var(--verde); }
.cb-btn.verde:hover { background: #256b45; }
.cb-btn.peligro { color: var(--rojo); border-color: #f0c4be; }
.cb-btn.chico { padding: 5px 10px; font-size: 12.5px; }
.cb-btn:disabled { opacity: .5; cursor: not-allowed; }

.cb-tabla-wrap { overflow-x: auto; }
#vista-cobranza table.cb-tabla td, #vista-cobranza table.cb-tabla th { padding: 9px 10px; }
.cb-fila { cursor: pointer; }
.cb-fila:hover td { background: #f8fafc; }
.cb-nombre { font-weight: 600; }
.cb-sub { font-size: 12px; color: var(--gris-texto); }
.cb-tag-pend { display: inline-block; background: #fdecea; color: #a52a1e; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 8px; margin-left: 6px; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: #e4f6ec; color: #1e7b46; } .pill.warn { background: #fdf1dd; color: #8a5a00; }
.pill.bad { background: #fde9ec; color: #b0283f; } .pill.info { background: #eef2f7; color: #5a6b7d; }
.pill.violet { background: #f0ebfd; color: #6a4fc4; } .pill.azul { background: #e6f0fa; color: #2c5f93; }

/* Cajón lateral */
.cb-overlay { position: fixed; inset: 0; background: rgba(20,30,45,.35); display: none; z-index: 50; justify-content: flex-end; }
.cb-overlay.abierto { display: flex; }
.cb-overlay.cb-center { justify-content: center; align-items: center; z-index: 60; }
.cb-drawer { width: min(760px, 96vw); background: #f5f7fa; height: 100%; overflow-y: auto; box-shadow: -8px 0 30px rgba(0,0,0,.18); display: flex; flex-direction: column; }
.cb-drawer-head { background: var(--azul-oscuro); color: white; padding: 18px 22px; position: sticky; top: 0; z-index: 2; }
.cb-drawer-head .t { font-size: 17px; font-weight: 700; padding-right: 30px; }
.cb-drawer-head .s { font-size: 12.5px; color: #9fb3c8; margin-top: 3px; }
.cb-drawer-head .x { position: absolute; right: 16px; top: 14px; background: transparent; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 1; }
.cb-tabs { display: flex; gap: 2px; background: white; border-bottom: 1px solid var(--gris-borde); padding: 0 14px; position: sticky; top: 76px; z-index: 1; }
.cb-tabs button { padding: 12px 14px; border: none; background: transparent; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--gris-texto); border-bottom: 3px solid transparent; }
.cb-tabs button.activo { color: var(--azul-medio); border-bottom-color: var(--azul-medio); }
.cb-drawer-body { padding: 20px 22px 40px; }
.cb-card { background: white; border: 1px solid var(--gris-borde); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.cb-card h3 { margin: 0 0 12px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--gris-texto); }

.cb-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.cb-grid.tres { grid-template-columns: repeat(3, 1fr); }
.cb-campo label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--gris-texto); font-weight: 600; margin-bottom: 5px; }
.cb-campo input, .cb-campo select, .cb-campo textarea, .cb-celda-input { width: 100%; padding: 8px 10px; border: 1px solid var(--gris-borde); border-radius: 6px; font-size: 13.5px; font-family: inherit; }
.cb-campo textarea { resize: vertical; min-height: 70px; }
.cb-campo input:focus, .cb-campo select:focus, .cb-campo textarea:focus, .cb-celda-input:focus { outline: none; border-color: var(--acento); }
.cb-check { display: flex; align-items: center; gap: 7px; font-size: 13.5px; }
.cb-resumen-estado { font-size: 13.5px; line-height: 1.7; }

.cb-tabla-mini { width: 100%; border-collapse: collapse; font-size: 13px; }
.cb-tabla-mini th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--gris-texto); padding: 6px 6px; border-bottom: 1px solid var(--gris-borde); }
.cb-tabla-mini td { padding: 6px 6px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
.cb-celda-input { padding: 6px 8px; font-size: 13px; }
.cb-acciones { white-space: nowrap; display: flex; gap: 5px; align-items: center; }
a.cb-wa { display: inline-block; padding: 5px 9px; border-radius: 6px; background: #25d366; color: white; font-size: 12px; font-weight: 700; text-decoration: none; }
a.cb-wa.off { background: #c9d2db; pointer-events: none; }

.cb-previa { background: #fafbfc; border: 1px dashed var(--gris-borde); border-radius: 8px; padding: 12px; }
.cb-linea { padding: 8px 0; border-bottom: 1px solid #eef1f5; font-size: 13px; }
.cb-linea:last-child { border-bottom: none; }

/* Modal */
.cb-modal { background: white; border-radius: 12px; padding: 24px; width: min(560px, 94vw); max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.cb-modal h3 { margin: 0 0 12px; font-size: 16px; }
.cb-progreso { height: 8px; background: #e6ebf1; border-radius: 4px; overflow: hidden; margin: 12px 0; }
.cb-progreso > div { height: 100%; background: var(--verde); width: 0; transition: width .3s; }
.cb-lista-sel { max-height: 220px; overflow-y: auto; border: 1px solid var(--gris-borde); border-radius: 7px; }
.cb-lista-sel div { padding: 8px 12px; border-bottom: 1px solid #eef1f5; cursor: pointer; font-size: 13.5px; }
.cb-lista-sel div:hover { background: #f1f6fb; }

.cb-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--azul-oscuro); color: white; padding: 11px 20px; border-radius: 8px; font-size: 13.5px; z-index: 100; display: none; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.cb-toast.error { background: #a52a1e; }
.cb-toast.visible { display: block; }

@media (max-width: 1000px) { .cb-kpis { grid-template-columns: repeat(3, 1fr); } }

.cb-modal.ancho { width: min(860px, 96vw); }
.cb-modal details summary { cursor: pointer; font-size: 13px; color: var(--azul-medio); font-weight: 600; }
.cb-reporte ul { margin: 6px 0 0 18px; padding: 0; font-size: 13.5px; line-height: 1.7; }
.cb-reporte h4 { margin: 14px 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--gris-texto); }

/* ===== Etiquetas, marca de bitácora, «Por recuperar» y cajón con pie fijo ===== */
.cb-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.cb-chip { display: inline-flex; align-items: center; gap: 4px; background: #eef0fb; color: #3b3fc4; border-radius: 10px; font-size: 11px; font-weight: 600; padding: 2px 8px; max-width: 100%; overflow-wrap: anywhere; }
.cb-chip.mas { background: #eef2f7; color: #5a6b7d; }
.cb-chip button { border: none; background: transparent; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 0 0 2px; min-width: 18px; min-height: 18px; }
.cb-drawer-head .cb-chip { background: rgba(255, 255, 255, .16); color: #fff; }
.cb-etiquetas { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.cb-etiq-nueva { display: flex; gap: 8px; }
.cb-etiq-nueva input { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 6px; border: 1px solid #3d5570; background: rgba(255, 255, 255, .08); color: #fff; font-size: 13.5px; }
.cb-etiq-nueva input::placeholder { color: #9fb3c8; }
.cb-etiq-nueva input:focus { outline: none; border-color: #6fa6dc; }
.cb-etiq-nueva .cb-btn { background: transparent; color: #fff; border-color: #3d5570; white-space: nowrap; }

.cb-marca { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; cursor: pointer; vertical-align: middle; }
.cb-marca.t-Acuerdo { background: #e4f6ec; color: #1e7b46; } .cb-marca.t-Dificultad { background: #fde9ec; color: #b0283f; } .cb-marca.t-Comentario { background: #eef0fb; color: #3b3fc4; }
.cb-marca:focus-visible { outline: 2px solid var(--acento); }

.cb-tip { position: fixed; z-index: 120; width: min(360px, calc(100vw - 16px)); background: #1a2b3c; color: #fff; border-radius: 10px; padding: 12px 14px; font-size: 12.5px; line-height: 1.45; box-shadow: 0 10px 30px rgba(0, 0, 0, .32); display: none; }
.cb-tip.visible { display: block; }
.cb-tip .cb-sub { color: #9fb3c8; }
.cb-tip-t { font-weight: 700; margin-bottom: 6px; }
.cb-tip-i { padding: 7px 0; border-top: 1px solid rgba(255, 255, 255, .13); overflow-wrap: anywhere; }
.cb-tip-pie { margin-top: 8px; font-size: 11.5px; color: #9fb3c8; }
.cb-tip .cb-btn { color: #1a2b3c; }

.cb-recuperar { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--gris-borde); border-radius: 12px; padding: 10px 14px; background: #fafbfd; }
.cb-recuperar.on { background: #f0ebfd; border-color: #d7cbf7; }
.cb-recuperar .tx { min-width: 0; font-size: 13.5px; }
.cb-btn.violeta { background: #8b6fe0; border-color: #8b6fe0; color: #fff; } .cb-btn.violeta:hover { background: #7556d6; }
#vista-cobranza tr.cb-fila.recup td:first-child { box-shadow: inset 3px 0 0 #8b6fe0; }
.cb-filtro-etiqueta { padding: 9px 10px; border: 1px solid var(--gris-borde); border-radius: 7px; font-size: 13.5px; background: #fff; width: auto; min-width: 150px; }
.cb-scroll-x { overflow-x: auto; }

/* cajón: cabecera y pestañas fijas arriba, cuerpo con desplazamiento y «Por recuperar» siempre a la vista */
.cb-drawer { overflow: hidden; }
.cb-drawer-head { position: relative; flex: none; }
.cb-tabs { position: static; flex: none; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.cb-tabs::-webkit-scrollbar { display: none; }
.cb-tabs button { white-space: nowrap; }
.cb-drawer-body { flex: 1; min-height: 0; overflow-y: auto; }
.cb-drawer-foot { flex: none; border-top: 1px solid var(--gris-borde); background: #fff; padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }

/* ===== Celular y tableta ===== */
@media (max-width: 1000px) { .cb-kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 820px) {
  .cb-kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cb-kpi { padding: 10px 12px; } .cb-kpi .n { font-size: 21px; }
  .cb-banner { flex-direction: column; align-items: flex-start; gap: 4px; }
  .cb-subnav { overflow-x: auto; } .cb-subnav button { white-space: nowrap; }
  .cb-toolbar { gap: 8px; } .cb-toolbar input[type=text] { flex: 1 1 100%; min-width: 0; font-size: 16px; }
  .cb-toolbar .cb-btn { flex: 1 1 auto; } .cb-filtro-etiqueta { flex: 1 1 100%; font-size: 16px; }
  .cb-btn { min-height: 40px; }

  /* la cartera pasa a tarjetas */
  .cb-tabla-wrap { overflow-x: visible; }
  #vista-cobranza table.cb-tabla, #vista-cobranza table.cb-tabla tbody { display: block; width: 100%; margin-top: 0; }
  #vista-cobranza table.cb-tabla thead { display: none; }
  #vista-cobranza table.cb-tabla tr.cb-fila { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; position: relative; background: #fff; border: 1px solid var(--gris-borde); border-radius: 12px; padding: 12px 14px 12px 44px; margin-bottom: 10px; }
  #vista-cobranza table.cb-tabla tr.cb-fila td { display: block; border: none; padding: 0; min-width: 0; background: transparent !important; box-shadow: none !important; }
  #vista-cobranza tr.cb-fila.recup { border-left: 4px solid #8b6fe0; }
  #vista-cobranza table.cb-tabla td.col-chk { position: absolute; left: 14px; top: 14px; }
  #vista-cobranza table.cb-tabla td.col-chk input { width: 20px; height: 20px; }
  #vista-cobranza table.cb-tabla td.col-cliente { grid-column: 1 / -1; }
  #vista-cobranza table.cb-tabla td[data-label]::before { content: attr(data-label); display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--gris-texto); margin-bottom: 2px; }
  #vista-cobranza table.cb-tabla td.num { text-align: left; }
  #vista-cobranza table.cb-tabla tr:not(.cb-fila) { display: block; }
  #vista-cobranza table.cb-tabla td.vacio { display: block; text-align: center; }

  /* cajón y ventanas a pantalla completa */
  .cb-drawer { width: 100vw; box-shadow: none; }
  .cb-drawer-head { padding: 14px 16px; } .cb-drawer-head .t { font-size: 16px; }
  .cb-drawer-body { padding: 14px 14px 24px; }
  .cb-drawer-foot { padding-left: 12px; padding-right: 12px; }
  .cb-grid, .cb-grid.tres { grid-template-columns: 1fr; }
  .cb-campo input, .cb-campo select, .cb-campo textarea, .cb-celda-input, .cb-etiq-nueva input { font-size: 16px; }
  .cb-modal { width: calc(100vw - 16px); max-height: 92vh; padding: 18px; }
  .cb-modal.ancho { width: calc(100vw - 16px); }
  .cb-recuperar { padding: 8px 12px; gap: 10px; } .cb-recuperar .tx b { font-size: 13px; } .cb-recuperar .cb-btn { flex: none; padding: 9px 14px; }

  /* tablas pequeñas del cajón (contactos, pagos…) como tarjetas */
  .cb-tabla-mini, .cb-tabla-mini tbody { display: block; width: 100%; }
  .cb-tabla-mini thead { display: none; }
  .cb-tabla-mini tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px 0; border-bottom: 1px solid #eef1f5; }
  .cb-tabla-mini td { display: block; border: none; padding: 0; min-width: 0; }
  .cb-tabla-mini td[data-label]::before { content: attr(data-label); display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--gris-texto); margin-bottom: 2px; }
  .cb-tabla-mini td.num { text-align: left; }
  .cb-tabla-mini td.cb-acciones { grid-column: 1 / -1; flex-wrap: wrap; }
  .cb-tabla-mini td.cb-acciones .cb-btn, .cb-tabla-mini td.cb-acciones a { flex: 1 1 auto; text-align: center; }
}

/* tabla de cartera en escritorio: columnas compactas y sin cortes */
#vista-cobranza table.cb-tabla td, #vista-cobranza table.cb-tabla th { vertical-align: top; }
#vista-cobranza table.cb-tabla td:not(.col-cliente):not([data-label="Estado"]) { white-space: nowrap; }
#vista-cobranza table.cb-tabla td.col-cliente { min-width: 210px; }
.cb-periodo { display: none; }
@media (max-width: 820px) {
  .cb-periodo { display: block; }
  #vista-cobranza table.cb-tabla td:not(.col-cliente) { white-space: normal; }
}

/* paginación de la cartera (20 por página) */
.cb-pag { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 2px; font-size: 13px; color: var(--gris-texto); }
.cb-pag .info b { color: var(--azul-oscuro); }
.cb-pag .btns { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.cb-pag button { border: 1px solid var(--gris-borde); background: #fff; color: var(--azul-oscuro); border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer; min-width: 36px; }
.cb-pag button:hover:not(:disabled):not(.act) { background: #f0f4f9; }
.cb-pag button.act { background: var(--azul-medio); border-color: var(--azul-medio); color: #fff; cursor: default; }
.cb-pag button:disabled { opacity: .45; cursor: not-allowed; }
.cb-pag .pun { padding: 0 4px; }
@media (max-width: 820px) {
  .cb-pag { justify-content: center; text-align: center; }
  .cb-pag .btns button[data-p]:not(.act):not(:first-child):not(:last-child), .cb-pag .pun { display: none; }   /* en celular: Anterior · página actual · Siguiente */
  .cb-pag button { min-height: 40px; padding: 8px 16px; }
}
