:root {
  --azul:        #1976d2;
  --azul-oscuro: #1a237e;
  --naranja:     #f57c00;
  --rojo:        #d32f2f;
  --verde:       #2e7d32;
  --gris:        #607d8b;
  --teal:        #00897b;
  --rosa:        #e91e63;
  --bg:          #f0f2f5;
  --texto:       #212121;
  --borde:       #e0e0e0;
  --sombra:      0 1px 6px rgba(0,0,0,.08);
}

/* ═══ Reset / base ════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px; background: var(--bg); color: var(--texto); line-height: 1.5;
}
input, textarea, select, button { font-family: inherit; font-size: inherit; }
a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: #e8f0fe; color: #1565c0;
  padding: 1px 5px; border-radius: 3px;
  font-family: monospace; font-size: 11.5px;
}

/* ═══ Header ══════════════════════════════════════════════════════════════ */
header.app {
  background: var(--azul-oscuro); color: #fff;
  padding: 0 22px; min-height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  position: sticky; top: 0; z-index: 100;
}
header.app h1 { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
header.app .sub { font-size: 11px; color: rgba(255,255,255,.7); margin-top: 2px; }

/* ═══ Contenedor principal ════════════════════════════════════════════════ */
.container { padding: 20px; max-width: 1500px; margin: 0 auto; }

/* ═══ Layout con menú lateral de módulos ══════════════════════════════════ */
.layout { display: flex; align-items: stretch; min-height: calc(100vh - 58px); }

.sidebar {
  flex: 0 0 220px; background: #fff;
  border-right: 1px solid var(--borde);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
}
.side-titulo {
  font-size: 11px; font-weight: 700; color: #9aa3ad;
  text-transform: uppercase; letter-spacing: .6px;
  padding: 4px 10px 8px;
}
.modulo {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; cursor: pointer;
  padding: 10px 12px; border: none; border-radius: 9px;
  background: transparent; color: #455a64;
  font-size: 14px; font-weight: 600; transition: background .15s, color .15s;
}
.modulo:hover { background: #f3f6fb; color: var(--azul-oscuro); }
.modulo.activa { background: var(--azul-oscuro); color: #fff; }
.modulo .ico { font-size: 17px; line-height: 1; }
.modulo.deshabilitado { color: #c2c8ce; cursor: not-allowed; font-weight: 500; }
.modulo.deshabilitado:hover { background: transparent; color: #c2c8ce; }

/* «Mis apps» (solo en el Inicio): enlaces a las otras apps de Artium, con el mismo
   aspecto de los ítems del menú. */
.sb-apps { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--borde); display: flex; flex-direction: column; gap: 3px; }
.sb-apps[hidden] { display: none; }
.sb-apps a.modulo { text-decoration: none; }
.sb-apps .ma-ordenar { font-size: 12px; opacity: .8; }

/* Editor del orden de las apps (solo superadmin): hoja inferior en el celular,
   ventana centrada desde 640px. Botones ↑/↓ de 44px. */
.ma-ov { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1000; display: flex; align-items: flex-end; justify-content: center; }
.ma-caja { background: #fff; width: 100%; max-width: 440px; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; }
@media (min-width: 640px) {
  .ma-ov { align-items: center; }
  .ma-caja { border-radius: 16px; }
}
.ma-cab { display: flex; flex-direction: column; margin-bottom: 10px; }
.ma-cab b { font-size: 16px; color: var(--azul-oscuro); }
.ma-cab small { color: var(--gris); font-size: 12.5px; }
.ma-fila { display: flex; align-items: center; gap: 8px; border: 1px solid var(--borde); border-radius: 10px; padding: 6px 8px; margin-bottom: 6px; min-height: 52px; }
.ma-n { width: 22px; text-align: center; color: var(--gris); font-weight: 700; font-size: 13px; flex: none; }
.ma-nom { flex: 1; min-width: 0; font-size: 14.5px; overflow-wrap: anywhere; }
.ma-fila button { width: 44px; height: 44px; border: 1px solid var(--borde); background: #fff; border-radius: 10px; font-size: 18px; cursor: pointer; flex: none; }
.ma-fila button:disabled { opacity: .3; cursor: default; }
.ma-pie { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.ma-est { font-size: 13px; color: var(--gris); min-width: 0; }
.ma-listo { min-height: 44px; padding: 0 20px; border: 0; border-radius: 10px; background: var(--azul); color: #fff; font-weight: 600; cursor: pointer; flex: none; }

.contenido {
  flex: 1 1 auto; min-width: 0;
  padding: 20px; max-width: 1500px; margin: 0 auto; width: 100%;
}
.modulo-panel        { display: none; }
.modulo-panel.activa { display: block; }

/* ═══ Home (landing con tarjetas por módulo) ══════════════════════════════ */
.home-wrap { max-width: 1100px; }
.home-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px; margin-top: 16px;
}
.home-card {
  display: flex; flex-direction: column; gap: 8px; padding: 18px;
  border: 1px solid var(--borde); border-radius: 14px; background: #fff;
  cursor: pointer; transition: box-shadow .15s, transform .15s, border-color .15s;
  text-align: left; box-shadow: var(--sombra);
}
.home-card:hover { box-shadow: 0 8px 22px rgba(0,0,0,.10); transform: translateY(-2px); border-color: #b9c4d6; }
.home-card .hc-ico { font-size: 30px; }
.home-card .hc-tit { font-weight: 700; font-size: 15px; color: var(--azul-oscuro); }
.home-card { position: relative; }
.home-card .hc-badge { position: absolute; top: 10px; right: 10px; min-width: 26px; height: 26px; padding: 0 8px;
  border-radius: 999px; background: #b42318; color: #fff; font-size: 13px; font-weight: 700;
  line-height: 26px; text-align: center; box-shadow: 0 0 0 3px #fff; }
.home-card .hc-nivel { align-self: flex-start; font-size: 11px; color: #fff; border-radius: 10px; padding: 1px 8px; }
.home-card.admin { background: linear-gradient(180deg, #fff, #f3f6ff); border-color: #c8d4ee; }

/* ═══ Buscador de usuarios (modal de permisos) ════════════════════════════ */
.pm-sug {
  position: absolute; left: 0; right: 0; z-index: 30;
  background: #fff; border: 1px solid var(--borde); border-radius: 8px;
  box-shadow: 0 8px 22px rgba(0,0,0,.14); max-height: 220px; overflow: auto; margin-top: 2px;
}
.pm-sug-item { padding: 8px 10px; cursor: pointer; font-size: 13px; }
.pm-sug-item:hover { background: #f3f6fb; }

/* ═══ Modo solo-lectura: oculta todo control de escritura ═════════════════ */
body[data-solover="1"] .btn.verde,
body[data-solover="1"] .btn.naranja,
body[data-solover="1"] .btn.rojo,
body[data-solover="1"] [data-write] { display: none !important; }

/* ≤900px: el menú lateral pasa a franja superior con scroll horizontal. */
@media (max-width: 900px) {
  #subnav { display: flex; gap: 6px; overflow-x: auto; }
  #sbTitulo { display: none !important; }
  .layout { flex-direction: column; min-height: 0; }
  .sidebar {
    flex: none; flex-direction: row; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--borde);
    padding: 8px; gap: 6px;
  }
  .side-titulo { display: none; }
  .modulo { width: auto; white-space: nowrap; padding: 8px 12px; }
  /* En la franja superior las apps van en la misma fila (con scroll propio), tras un separador. */
  .sb-apps { display: contents; }
  .sb-apps[hidden] { display: none; }
  .sb-apps a.modulo:first-of-type { border-left: 1px solid var(--borde); border-radius: 0 9px 9px 0; }
  .contenido { padding: 12px; }
}

/* ═══ Botones ═════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: 8px;
  background: var(--azul); color: #fff;
  font-weight: 600; font-size: 13px; cursor: pointer;
  transition: filter .15s, box-shadow .15s; white-space: nowrap;
}
.btn:hover  { filter: brightness(1.08); box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.btn:active { filter: brightness(.95); }
.btn.verde     { background: var(--verde); }
.btn.naranja   { background: var(--naranja); }
.btn.rojo      { background: var(--rojo); }
.btn.secundario{ background: #eceff1; color: #455a64; }
.btn.outline {
  background: transparent; color: #fff;
  border: 1.5px solid rgba(255,255,255,.6);
}
.btn.outline:hover { background: rgba(255,255,255,.12); box-shadow: none; }

/* Botones mini (acciones de tabla) */
.btn-mini {
  display: inline-block; padding: 3px 8px; margin: 1px;
  border: none; border-radius: 4px;
  background: var(--azul); color: #fff;
  font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: filter .15s; white-space: nowrap;
}
.btn-mini:hover    { filter: brightness(1.1); }
.btn-mini:disabled { opacity: .4; cursor: not-allowed; }
.btn-mini.ver            { background: var(--azul); }
.btn-mini.seg            { background: #6a1b9a; }
.btn-mini.cmp            { background: var(--verde); }
.btn-mini.wa             { background: #25d366; }
.btn-mini.pdf            { background: var(--rojo); }
.btn-mini.xml            { background: var(--naranja); }
.btn-mini.disputa-marcar { background: var(--rosa); }
.btn-mini.disputa-quitar { background: var(--teal); }

/* ═══ Tarjetas resumen ════════════════════════════════════════════════════ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.card {
  background: #fff; border-radius: 12px; padding: 16px;
  box-shadow: var(--sombra);
  display: flex; flex-direction: column; gap: 4px;
  border-top: 4px solid var(--azul-oscuro);
}
.card .label { font-size: 11px; color: #888; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.card .value { font-size: 22px; font-weight: 700; color: var(--azul-oscuro); }
.card .value.sm { font-size: 18px; }
.card .sub2  { font-size: 12px; color: #aaa; }
.card.azul    { border-top-color: var(--azul); }
.card.naranja { border-top-color: var(--naranja); }
.card.rojo    { border-top-color: var(--rojo); }
.card.negro   { border-top-color: #212121; }
.card.teal    { border-top-color: var(--teal); }
.card.teal .value { color: var(--teal); }

/* ═══ Acciones ════════════════════════════════════════════════════════════ */
.acciones {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 18px; align-items: center;
}
.buscador {
  padding: 8px 14px; border: 1.5px solid #ddd; border-radius: 8px;
  outline: none; width: 240px; margin-left: auto; transition: border-color .2s;
}
.buscador:focus { border-color: var(--azul); }

/* ═══ Pestañas ════════════════════════════════════════════════════════════ */
.tabs {
  display: flex; gap: 2px; background: #fff;
  border-radius: 10px; padding: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  margin-bottom: 16px; overflow-x: auto;
}
.tab {
  padding: 8px 18px; border-radius: 7px; border: none;
  background: transparent; font-size: 13px; font-weight: 600; color: #777;
  cursor: pointer; transition: background .15s, color .15s; white-space: nowrap;
}
.tab:hover  { background: #f5f5f5; color: #333; }
.tab.activa { background: var(--azul-oscuro); color: #fff; }

/* Cabecera de módulo (Radicación de Facturas) */
.modulo-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.modulo-titulo { font-size: 20px; font-weight: 800; color: var(--azul-oscuro); margin: 0; }

/* Sub-pestañas (Radicación: Nuevas / Historial) */
.subtabs { display: inline-flex; gap: 6px; background: #f1f3f4; padding: 4px; border-radius: 9px; }
.subtab {
  padding: 7px 14px; border-radius: 7px; border: none; background: transparent;
  font-size: 13px; font-weight: 600; color: #666; cursor: pointer; transition: background .15s, color .15s;
}
.subtab:hover  { color: #333; }
.subtab.activa { background: #fff; color: var(--azul-oscuro); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.subtab .cont {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  font-size: 11px; line-height: 17px; text-align: center; border-radius: 9px;
  background: rgba(0,0,0,.10); color: inherit;
}
.subtab.activa .cont { background: var(--azul); color: #fff; }

/* Enlaces de adjuntos en la tabla de radicación */
.rad-link {
  display: inline-block; margin: 1px 6px 1px 0; font-size: 12px; font-weight: 600;
  color: var(--azul); text-decoration: none; white-space: nowrap;
}
.rad-link:hover { text-decoration: underline; }
.rad-na { display: inline-block; margin-right: 6px; font-size: 11px; color: #bbb; }

/* Paneles */
.panel        { display: none; }
.panel.activa { display: block; }

/* ═══ Leyenda ═════════════════════════════════════════════════════════════ */
.leyenda {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin-bottom: 14px; align-items: center; font-size: 12px; color: #777;
}
.leyenda .item  { display: flex; align-items: center; gap: 5px; }
.leyenda .punto { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* ═══ Tablas ══════════════════════════════════════════════════════════════ */
.tabla-wrap {
  background: #fff; border-radius: 12px;
  overflow: hidden; overflow-x: auto; box-shadow: var(--sombra);
}
table { width: 100%; border-collapse: collapse; min-width: 720px; }
thead { background: #f5f7fa; }
th {
  padding: 12px 10px; font-size: 12px; font-weight: 700; color: #555;
  text-transform: uppercase; letter-spacing: .4px;
  text-align: left; border-bottom: 2px solid #e8ecf0;
  white-space: nowrap; cursor: pointer; user-select: none;
}
th:hover { background: #eef2f7; }
td { padding: 10px; border-bottom: 1px solid #f2f2f2; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfd; }
.num    { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.center { text-align: center; }
td.empty, .empty { text-align: center; padding: 32px; color: #bbb; font-style: italic; }
tr.row-disputa td       { background: #fce4ec !important; }
tr.row-disputa:hover td { background: #f8bbd0 !important; }
/* Columna de acciones pegada al borde derecho: visible siempre, aunque la tabla tenga scroll.
   Solo si la última celda trae botones — en Bolsa "Acciones" es una cantidad, no botones. */
.tabla-wrap > table:has(> tbody > tr > td:last-child button) > thead th:last-child,
.tabla-wrap > table:has(> tbody > tr > td:last-child button) > tbody > tr > td:last-child {
  position: sticky; right: 0; z-index: 1;
}
.tabla-wrap > table:has(> tbody > tr > td:last-child button) > thead th:last-child { background: #f5f7fa; }
.tabla-wrap > table:has(> tbody > tr > td:last-child button) > tbody > tr > td:last-child {
  background: #fff; box-shadow: -6px 0 8px -6px rgba(0,0,0,.18);
}
.tabla-wrap > table:has(> tbody > tr > td:last-child button) > tbody > tr:hover > td:last-child { background: #fafbfd; }

/* ═══ Badge ═══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; color: #fff; white-space: nowrap;
}

/* ═══ Gestión de Hoy ══════════════════════════════════════════════════════ */
.gestion-seccion {
  margin-bottom: 18px; border-radius: 12px;
  overflow: hidden; box-shadow: var(--sombra);
}
.gestion-seccion h4 { padding: 14px 18px; font-size: 14px; font-weight: 700; color: #fff; }
.gestion-seccion > *:not(h4) { background: #fff; padding: 14px 18px; }
.gestion-seccion.azul    h4 { background: var(--azul); }
.gestion-seccion.rojo    h4 { background: #c62828; }
.gestion-seccion.naranja h4 { background: var(--naranja); }
.gestion-seccion.gris    h4 { background: #546e7a; }
.vacio-mini { color: #bbb; font-style: italic; text-align: center; padding: 16px 0; font-size: 13px; }

/* ═══ KPIs ════════════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.kpi-card {
  background: #fff; border-radius: 12px; padding: 18px 16px;
  box-shadow: var(--sombra); border-left: 5px solid #ccc;
}
.kpi-titulo { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #888; margin-bottom: 8px; }
.kpi-valor  { font-size: 26px; font-weight: 800; line-height: 1.1; margin-bottom: 6px; }
.kpi-desc   { font-size: 11.5px; color: #999; line-height: 1.4; }
.kpi-seccion {
  background: #fff; border-radius: 12px; padding: 18px 20px;
  box-shadow: var(--sombra); margin-bottom: 16px;
}
.kpi-seccion h4 { font-size: 15px; font-weight: 700; color: var(--azul-oscuro); margin-bottom: 14px; }

/* ═══ Modales ═════════════════════════════════════════════════════════════ */
.modal-bg {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 2000;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-bg.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto; padding: 24px;
}
.modal.grande { max-width: 820px; }
.modal h3 { font-size: 17px; font-weight: 700; color: var(--azul-oscuro); margin-bottom: 8px; }
.modal > p { font-size: 13px; color: #607d8b; margin-bottom: 14px; }
.modal label { display: block; font-size: 12px; font-weight: 700; color: #555; margin-bottom: 5px; margin-top: 10px; text-transform: uppercase; letter-spacing: .3px; }
.modal input[type=text],
.modal input[type=email],
.modal input[type=date],
.modal input[type=number],
.modal input[type=password],
.modal select,
.modal textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--borde); border-radius: 8px;
  outline: none; transition: border-color .2s; resize: vertical;
}
.modal input:focus, .modal select:focus, .modal textarea:focus { border-color: var(--azul); }

/* Fila de botones dentro de modal */
.row {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 18px; flex-wrap: wrap;
}

/* Z-index modales apilados */
#modalDetalle     { z-index: 2100; }
#modalTipoMensaje { z-index: 2200; }
#modalCompromiso  { z-index: 2200; }
#modalDisputa     { z-index: 2200; }
#modalPlantillas  { z-index: 2200; }
#modalCred        { z-index: 2300; }
#modalGen         { z-index: 2400; }
#modalLogin {
  z-index: 8000;
  background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
}

/* ═══ Formularios en modales ══════════════════════════════════════════════ */
.form-inline { display: flex; flex-direction: column; gap: 4px; }
.form-inline > div { margin-bottom: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Varios compromisos a la vez: una tarjeta por compromiso (celular primero) */
.cmp-filas { display: flex; flex-direction: column; gap: 8px; }
.cmp-fila {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px; align-items: end; padding: 10px; border: 1px solid var(--borde, #d5dce4);
  border-radius: 10px; background: #fff;
}
.cmp-fila > div { min-width: 0; }
.cmp-fila .cmp-fac { grid-column: 1 / -1; }
.cmp-fila select, .cmp-fila input { width: 100%; min-width: 0; box-sizing: border-box; }
.cmp-fila .cmp-quitar {
  border: 0; background: transparent; color: var(--gris, #5c6b7a); font-size: 18px;
  width: 36px; height: 40px; cursor: pointer; border-radius: 8px;
}
.cmp-fila .cmp-quitar:hover { background: var(--gris-cl, #eef1f5); color: var(--err, #b42318); }
.cmp-acciones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.modal .cmp-cuotas { display: inline-flex; flex-wrap: nowrap; gap: 6px; align-items: center; }
.modal .cmp-cuotas select { width: auto; display: inline-block; margin: 0; }
.cmp-total { font-size: 13px; color: var(--gris, #5c6b7a); text-align: right; }
.cmp-total b { color: var(--texto, #1a2632); }
.check {
  display: flex !important; align-items: center; gap: 8px;
  text-transform: none !important; letter-spacing: normal !important;
  font-weight: 500 !important; color: #555 !important; margin-top: 12px !important;
}
.check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--azul); cursor: pointer; }

/* ═══ Modal: tipo de mensaje (radios) ═════════════════════════════════════ */
.radio-group { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.radio-opt {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border: 2px solid var(--borde); border-radius: 10px;
  cursor: pointer; transition: border-color .2s, background .2s;
}
.radio-opt:hover { border-color: var(--azul); background: #f5f9ff; }
.radio-opt:has(input:checked) { border-color: var(--azul); background: #e8f0fe; }
.radio-opt input[type=radio] { margin-top: 3px; width: 16px; height: 16px; cursor: pointer; accent-color: var(--azul); flex-shrink: 0; }
.radio-opt strong { font-size: 14px; color: var(--texto); }
.radio-desc { font-size: 12px; color: #777; margin-top: 2px; }

/* ═══ Modal detalle de cliente ════════════════════════════════════════════ */
.detalle-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1.5px solid #f0f0f0;
}
.detalle-head h3 { margin-bottom: 0; }
.detalle-head .total { font-size: 22px; font-weight: 800; color: var(--azul-oscuro); }

/* Sub-pestañas */
.sub-tabs {
  display: flex; gap: 2px; background: #f5f7fa;
  border-radius: 8px; padding: 3px; margin-bottom: 14px; overflow-x: auto;
}
.sub-tab {
  padding: 6px 14px; border-radius: 6px; border: none;
  background: transparent; font-size: 13px; font-weight: 600; color: #777;
  cursor: pointer; transition: background .15s, color .15s; white-space: nowrap;
}
.sub-tab:hover  { background: #fff; }
.sub-tab.activa { background: #fff; color: var(--azul-oscuro); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.sub-panel        { display: none; }
.sub-panel.activa { display: block; }

/* Grid de contacto */
.grid-contacto { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-contacto > div { display: flex; flex-direction: column; }
.grid-contacto label { margin-top: 0; }
.grid-contacto .full { grid-column: 1 / -1; }

/* Timeline (seguimientos / compromisos) */
.timeline { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.timeline li {
  background: #f9fafc; border-radius: 8px; padding: 12px 14px;
  border-left: 3px solid var(--azul); font-size: 13px; line-height: 1.5;
}
.timeline.cmp li { border-left-color: var(--verde); }
.timeline .meta { font-size: 11px; color: #999; margin-bottom: 4px; }

/* ═══ Overlay de carga ════════════════════════════════════════════════════ */
.overlay-carga {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 9000;
  align-items: center; justify-content: center; gap: 14px; flex-direction: column;
}
.overlay-carga.show { display: flex; }
.spinner {
  width: 44px; height: 44px;
  border: 4px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .8s linear infinite;
}
#overlayTexto { color: #fff; font-size: 15px; font-weight: 500; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ Login Microsoft ═════════════════════════════════════════════════════ */
.login-card { max-width: 420px; text-align: center; }
.login-card .btn-ms {
  display: inline-flex; align-items: center; gap: 10px; justify-content: center;
  width: 100%; margin-top: 18px; padding: 12px 16px;
  background: #2f2f2f; color: #fff; border: none; border-radius: 8px;
  font-weight: 600; font-size: 14px; cursor: pointer;
}
.login-card .btn-ms:hover { filter: brightness(1.15); }

/* ═══ Toasts ══════════════════════════════════════════════════════════════ */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9500;
  display: flex; flex-direction: column; gap: 8px; max-width: 380px;
}
.toast {
  padding: 12px 18px; border-radius: 8px; color: #fff; background: #323232;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); font-size: 13.5px;
  transition: opacity .3s; word-break: break-word;
}
.toast.ok  { background: var(--verde); }
.toast.err { background: #c62828; }

/* ═══ Responsive ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .container { padding: 12px; }
  header.app { padding: 0 12px; }
  header.app h1 { font-size: 15px; }
  header.app .sub { display: none; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card .value { font-size: 18px; }
  .tab { padding: 7px 11px; font-size: 12px; }
  .buscador { width: 100%; margin-left: 0; }
  .btn { padding: 7px 12px; font-size: 12px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row, .grid-contacto { grid-template-columns: 1fr; }
  .modal { max-width: 100%; padding: 20px 18px; }
}
@media (max-width: 600px) {
  /* La columna fija taparía media pantalla en un celular: se libera y los
     botones se alcanzan con el scroll horizontal de la tabla. */
  .tabla-wrap > table:has(> tbody > tr > td:last-child button) > thead th:last-child,
  .tabla-wrap > table:has(> tbody > tr > td:last-child button) > tbody > tr > td:last-child {
    position: static; box-shadow: none;
  }
}
@media (max-width: 480px) {
  .cards    { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .detalle-head { flex-direction: column; align-items: flex-start; }
}

/* ═══ Centro de Procesos (segundo plano) ════════════════════════════════ */
.centro-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 1400;
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: #1a237e; color: #fff; font-size: 22px; line-height: 1;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.centro-fab:hover { background: #283593; }
.centro-badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 10px; background: #d32f2f; color: #fff;
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.centro-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: 360px; max-width: 92vw;
  background: #fff; box-shadow: -4px 0 22px rgba(0,0,0,.18); z-index: 1401;
  transform: translateX(105%); transition: transform .25s ease; display: flex; flex-direction: column;
}
.centro-panel.show { transform: translateX(0); }
.centro-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: #1a237e; color: #fff; font-weight: 600;
}
.centro-cerrar { background: transparent; border: 0; color: #fff; font-size: 18px; cursor: pointer; }
.centro-lista { padding: 12px; overflow-y: auto; flex: 1; }
.proc-card {
  border: 1px solid #e6e6ea; border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #fafafc;
}
.proc-card .proc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.proc-card .proc-titulo { font-weight: 600; font-size: 14px; color: #222; }
.proc-estado { font-size: 11px; padding: 2px 8px; border-radius: 10px; color: #fff; white-space: nowrap; }
.proc-estado.corriendo { background: #1976d2; }
.proc-estado.ok        { background: #2e7d32; }
.proc-estado.error     { background: #d32f2f; }
.proc-bar { height: 8px; border-radius: 6px; background: #e6e6ea; overflow: hidden; margin: 9px 0 6px; }
.proc-bar > span { display: block; height: 100%; background: #1976d2; transition: width .2s ease; }
.proc-bar.ok > span { background: #2e7d32; }
.proc-bar.indet { position: relative; }
.proc-bar.indet > span { width: 35% !important; animation: procIndet 1.1s infinite ease-in-out; }
@keyframes procIndet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.proc-meta { font-size: 12px; color: #555; }
.proc-detalle { font-size: 11px; color: #888; margin-top: 4px; min-height: 14px; word-break: break-word; }
.proc-descartar { background: transparent; border: 0; color: #999; font-size: 12px; cursor: pointer; margin-top: 6px; padding: 0; }
.proc-descartar:hover { color: #555; text-decoration: underline; }

/* ═══ Scrollbar ═══════════════════════════════════════════════════════════ */
::-webkit-scrollbar       { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: #f0f0f0; border-radius: 10px; }
::-webkit-scrollbar-thumb { background: #bbb; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #999; }

/* ═══ Módulo Retenciones ══════════════════════════════════════════════════ */
.ret-uvt-chip { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--azul-oscuro);
  background: #e8f0fe; border: 1px solid #c5d6f7; padding: 4px 10px; border-radius: 20px; }
.badge.compra { background: #00695c; }
.badge.venta  { background: #6a1b9a; }
.ret-ajustada { font-size: 11px; color: var(--naranja); font-weight: 700; }

/* Modal de liquidación */
.ret-tipo { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 4px; }
.ret-radio { flex: 1 1 240px; display: flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1.5px solid var(--borde); border-radius: 9px; padding: 10px 12px; font-size: 13px;
  text-transform: none; letter-spacing: 0; font-weight: 500; color: #333; margin: 0; }
.ret-radio b { font-weight: 700; }
.ret-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; margin-top: 8px; }
.ret-grid > div { min-width: 0; }
.ret-grid label { margin-top: 0; }
.ret-cond { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 12px 0; padding: 10px 12px;
  background: #f7f9fc; border-radius: 9px; }
.ret-cond label { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px;
  text-transform: none; letter-spacing: 0; font-weight: 600; color: #444; }
.ret-cond input { width: auto !important; }
.ret-msg { font-size: 12.5px; color: #607d8b; }
.ret-msg.err { color: var(--rojo); font-weight: 700; }

.ret-detalle-titulo { font-size: 13px; font-weight: 700; color: var(--azul-oscuro);
  margin: 16px 0 8px; display: flex; align-items: center; gap: 10px; }
.ret-hint { font-size: 11.5px; color: #90a4ae; font-weight: 500; }
table.ret-detalle, table.ret-cfg { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ret-detalle th, table.ret-cfg th { background: #f1f5fb; text-align: left; padding: 7px 8px;
  font-size: 11px; text-transform: uppercase; color: #607d8b; letter-spacing: .3px; }
table.ret-detalle td, table.ret-cfg td { padding: 6px 8px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
.ret-num { width: 100% !important; padding: 6px 8px !important; text-align: right; }
.ret-suf { font-size: 11px; color: #90a4ae; }
.ret-notas { font-size: 11.5px; color: #78909c; margin: 8px 2px; line-height: 1.5; }
.ret-notas div { padding: 1px 0; }

.ret-totales { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.ret-totales > div { flex: 1 1 160px; background: #f7f9fc; border-radius: 9px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px; }
.ret-totales > div span { font-size: 11px; text-transform: uppercase; color: #90a4ae; letter-spacing: .3px; }
.ret-totales > div b { font-size: 17px; color: var(--azul-oscuro); }
.ret-totales .neto { background: #e8f5e9; }
.ret-totales .neto b { color: var(--verde); }

table.ret-cfg input, table.ret-cfg select { width: 100%; padding: 5px 7px; border: 1.5px solid var(--borde);
  border-radius: 6px; font-size: 12.5px; }
table.ret-cfg input[type=number] { text-align: right; }
.cfg-del { background: none; border: none; color: var(--rojo); cursor: pointer; font-size: 16px; }

@media (max-width: 768px) {
  .ret-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Retenciones: tabla de ítems + celdas editables por ítem ── */
table.ret-items { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.ret-items th { background: #f1f5fb; text-align: left; padding: 6px 6px; font-size: 10.5px;
  text-transform: uppercase; color: #607d8b; letter-spacing: .3px; }
table.ret-items td { padding: 4px 5px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
table.ret-items input, table.ret-items select { width: 100%; padding: 5px 6px;
  border: 1.5px solid var(--borde); border-radius: 6px; font-size: 12.5px; }
table.ret-items input[type=number] { text-align: right; }
table.ret-items td:nth-child(4), table.ret-items td:nth-child(5) { width: 110px; }
table.ret-items td:last-child { width: 30px; text-align: center; }

.ret-cell { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ret-ap { display: inline-flex; margin: 0; }
.ret-ap input { width: auto !important; margin: 0; }
.ret-num2 { width: 58px; padding: 4px 6px; text-align: right;
  border: 1.5px solid var(--borde); border-radius: 6px; font-size: 12px; }

/* ═══ Automatizaciones (paneles separados + on/off) ══════════════════════════ */
.auto-panel { background: #fff; border: 1px solid var(--borde); border-left: 4px solid var(--gris);
  border-radius: 10px; box-shadow: var(--sombra); padding: 16px 18px; margin-bottom: 14px; }
.auto-head { display: flex; align-items: center; gap: 10px; }
.auto-ico { font-size: 22px; }
.auto-nombre { font-weight: 700; color: var(--azul-oscuro); font-size: 15px; }
.auto-badge { color: #fff; padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.auto-desc { font-size: 12.5px; color: #555; margin: 8px 0 12px; }
.auto-cfg { background: #f7f9fc; border: 1px solid var(--borde); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; color: #333; }
.auto-cfg label { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.auto-num { width: 64px; padding: 5px 7px; border: 1.5px solid var(--borde); border-radius: 6px;
  font-size: 13px; text-align: center; }
.auto-sel { padding: 5px 7px; border: 1.5px solid var(--borde); border-radius: 6px; font-size: 13px; }
.auto-meta { font-size: 12px; color: #444; margin: 10px 0; }
.auto-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.auto-acts button { border: 0; border-radius: 6px; padding: 7px 13px; font-size: 12.5px;
  cursor: pointer; font-weight: 600; }
.auto-btn-save { background: var(--verde); color: #fff; }
.auto-btn-run  { background: var(--azul-oscuro); color: #fff; }
.auto-btn-info { background: #eceff1; color: #37474f; }
.auto-acts button:hover { opacity: .9; }
/* Interruptor ON/OFF */
.switch { position: relative; display: inline-block; width: 46px; height: 24px; margin-left: auto; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; cursor: pointer; background: #bdbdbd;
  border-radius: 24px; transition: .2s; }
.switch .slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--verde); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ── Checklist diario (Home + administración) ─────────────────────────────── */
.chk-box { border: 1px solid #c8d4ee; border-radius: 14px; background: linear-gradient(180deg, #fff, #f6f9ff);
  padding: 16px 18px; margin-top: 16px; }
.chk-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.chk-progress { height: 8px; background: #e6ebf4; border-radius: 6px; margin: 10px 0 12px; overflow: hidden; }
.chk-progress > div { height: 100%; width: 0; background: #2e7d32; border-radius: 6px; transition: width .3s; }
.chk-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.chk-item:hover { background: #eef3fb; }
.chk-item input { width: 18px; height: 18px; margin-top: 2px; accent-color: #2e7d32; cursor: pointer; flex: none; }
.chk-item .chk-tit { font-weight: 600; font-size: 14px; }
.chk-item.hecha .chk-tit { text-decoration: line-through; color: #7a8698; }
.chk-item .chk-desc { font-size: 12px; color: #5c6b7a; margin-top: 1px; }
.chk-done { font-size: 13px; color: #2e7d32; font-weight: 600; margin: 4px 0 0; }
.chk-dias label { display: inline-flex; align-items: center; gap: 4px; margin: 2px 10px 2px 0; font-size: 13px; }

/* ═══════════════════════════════════════════════════════════════════════════
   MÓDULO BOLSA — Portafolio e inversiones
   Mismo navy claro que el resto de Gestión Financiera. Antes era un tema oscuro
   petrol+ámbar y el usuario dijo que "los colores no ayudan": tenía razón, porque
   el ámbar se usaba de adorno y competía con el verde/rojo, que es el único color
   que aquí significa algo. Regla nueva: **el color solo informa** — verde = ganó,
   rojo = perdió, azul = acción, y todo lo demás en grises. Las variables siguen
   anidadas bajo `.bv`, así que el retema es este bloque y nada más.
   ═══════════════════════════════════════════════════════════════════════════ */
.bv {
  --bv-fondo:    #f0f2f5;
  --bv-sup:      #ffffff;
  --bv-sup2:     #f5f7fa;
  --bv-borde:    #e0e4e9;
  --bv-texto:    #212121;
  --bv-tenue:    #607d8b;
  --bv-ambar:    #1976d2;   /* el acento es el azul de la app; el ámbar era decorativo */
  --bv-ambar-os: #1a237e;
  --bv-verde:    #2e7d32;
  --bv-rojo:     #d32f2f;
  --bv-azul:     #1976d2;
  --bv-mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --bv-tit:  "Segoe UI Semibold", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --bv-cuerpo: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}
section.modulo-panel.bv {
  background: var(--bv-fondo); color: var(--bv-texto);
  font-family: var(--bv-cuerpo);
  margin: -16px; padding: 18px 20px 28px; min-height: calc(100vh - 58px);
}
.bv .bv-panel        { display: none; }
.bv .bv-panel.activa { display: block; }

.bv .bv-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 14px; flex-wrap: wrap; margin-bottom: 16px;
}
.bv .bv-titulo {
  font-family: var(--bv-tit); font-size: 21px; font-weight: 700;
  letter-spacing: -.3px; margin: 0; color: var(--bv-ambar-os);
}
.bv .bv-sub  { font-size: 12.5px; color: var(--bv-tenue); margin: 3px 0 0; max-width: 82ch; }
.bv .bv-lbl  { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--bv-tenue); margin-bottom: 4px; }
.bv .bv-mono { font-family: var(--bv-mono); font-variant-numeric: tabular-nums; }

/* Botones */
.bv .bv-btn {
  background: var(--bv-sup2); color: var(--bv-texto);
  border: 1px solid var(--bv-borde); border-radius: 8px;
  padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: filter .15s, border-color .15s;
}
.bv .bv-btn:hover      { filter: brightness(.97); border-color: var(--bv-azul); }
.bv .bv-btn.ambar      { background: var(--bv-ambar); color: #fff; border-color: var(--bv-ambar); }
.bv .bv-btn.verde      { background: #e8f5e9; color: var(--bv-verde); border-color: #a5d6a7; }
.bv .bv-btn.rojo       { background: #ffebee; color: var(--bv-rojo); border-color: #ef9a9a; }
.bv .bv-btn.mini       { padding: 3px 8px; font-size: 11.5px; border-radius: 6px; }

/* Tarjetas */
.bv .bv-card {
  background: var(--bv-sup); border: 1px solid var(--bv-borde);
  border-radius: 12px; padding: 15px 16px; margin-bottom: 14px;
}
.bv .bv-card-tit {
  font-family: var(--bv-tit); font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px; color: var(--bv-tenue);
  margin: 0 0 12px; display: flex; align-items: center; gap: 8px;
}
.bv .bv-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.bv .bv-chip {
  background: var(--bv-sup2); color: var(--bv-tenue); border: 1px solid var(--bv-borde);
  border-radius: 20px; padding: 1px 9px; font-size: 11px; font-family: var(--bv-mono);
}

/* Semáforo del gate de despliegue */
.bv .bv-gate {
  border-radius: 12px; padding: 14px 16px; margin-bottom: 14px;
  border: 1px solid var(--bv-borde); background: var(--bv-sup);
  display: flex; gap: 14px; align-items: flex-start;
}
.bv .bv-gate.verde { border-left: 5px solid var(--bv-verde); }
.bv .bv-gate.ambar { border-left: 5px solid var(--bv-ambar); }
.bv .bv-gate.rojo  { border-left: 5px solid var(--bv-rojo); }
.bv .bv-gate.sin-datos { border-left: 5px solid var(--bv-tenue); }
.bv .bv-gate-luz { width: 15px; height: 15px; border-radius: 50%; margin-top: 3px; flex: none; }
.bv .bv-gate-tit { font-family: var(--bv-tit); font-size: 15px; font-weight: 700; margin: 0 0 5px; }
.bv .bv-gate ul  { margin: 0; padding-left: 17px; font-size: 12.5px; color: var(--bv-tenue); }

/* KPIs */
.bv .bv-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 12px; margin-bottom: 14px; }
.bv .bv-kpi  { background: var(--bv-sup); border: 1px solid var(--bv-borde); border-radius: 12px; padding: 12px 14px; }
.bv .bv-kpi-lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--bv-tenue); }
.bv .bv-kpi-val { font-family: var(--bv-mono); font-size: 20px; font-weight: 600; margin-top: 5px; letter-spacing: -.5px; }
.bv .bv-kpi-pie { font-size: 11.5px; color: var(--bv-tenue); margin-top: 3px; }
.bv .pos { color: var(--bv-verde); }
.bv .neg { color: var(--bv-rojo); }
.bv .amb { color: var(--bv-ambar); }

/* Tablas */
.bv .bv-tabla-wrap { overflow: auto; border-radius: 9px; border: 1px solid var(--bv-borde); }
.bv table.bv-tabla { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.bv table.bv-tabla th {
  background: var(--bv-sup2); color: var(--bv-tenue); text-align: left;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700;
  padding: 8px 10px; position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
.bv table.bv-tabla td { padding: 7px 10px; border-top: 1px solid var(--bv-borde); vertical-align: top; }
.bv table.bv-tabla tbody tr:hover { background: #f4f8fd; }
.bv table.bv-tabla td.num, .bv table.bv-tabla th.num { text-align: right; font-family: var(--bv-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bv table.bv-tabla tr.grupo td { background: var(--bv-sup2); font-weight: 600; cursor: pointer; }
.bv table.bv-tabla tr.lote td  { color: var(--bv-tenue); font-size: 12px; }
.bv table.bv-tabla td.vacio    { text-align: center; color: var(--bv-tenue); padding: 18px; font-style: italic; }

/* Alertas */
.bv .bv-alertas { display: flex; flex-direction: column; gap: 8px; max-height: 330px; overflow: auto; }
.bv .bv-alerta {
  border-left: 3px solid var(--bv-tenue); background: var(--bv-sup2);
  border-radius: 7px; padding: 8px 11px;
}
.bv .bv-alerta.alta  { border-left-color: #f57c00; }
.bv .bv-alerta.media { border-left-color: var(--bv-azul); }
.bv .bv-alerta b     { font-size: 12.5px; display: block; }
.bv .bv-alerta span  { font-size: 11.5px; color: var(--bv-tenue); }

/* Formularios */
.bv .bv-input, .bv select.bv-input, .bv textarea.bv-input {
  width: 100%; background: var(--bv-fondo); color: var(--bv-texto);
  border: 1px solid var(--bv-borde); border-radius: 7px; padding: 7px 9px;
  font-size: 13px; font-family: var(--bv-mono);
}
.bv .bv-input:focus { outline: none; border-color: var(--bv-ambar); }
.bv textarea.bv-input { font-family: var(--bv-cuerpo); min-height: 62px; resize: vertical; }
.bv .bv-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 14px; }
.bv .bv-form .full { grid-column: 1 / -1; }
.bv .bv-nota {
  background: #fff8e1; border: 1px solid #ffe082;
  border-radius: 8px; padding: 9px 12px; font-size: 12.5px; color: #8a6d1f; margin: 10px 0;
}
.bv .bv-nota.info  { background: #e8f0fe; border-color: #bbd6f7; color: #14508f; }
.bv .bv-nota.error { background: #ffebee; border-color: #ef9a9a; color: #a62020; }
.bv .bv-nota ul { margin: 5px 0 0; padding-left: 18px; }

/* Modal del módulo (hereda el posicionamiento de .modal-bg y repinta el interior) */
.modal-bg.bv .bv-modal {
  background: var(--bv-sup); color: var(--bv-texto);
  border: 1px solid var(--bv-borde); font-family: var(--bv-cuerpo);
}
.modal-bg.bv .bv-modal h3 { font-family: var(--bv-tit); color: var(--bv-ambar-os); }
.modal-bg.bv .bv-modal label { color: var(--bv-tenue); }

/* Gráficos SVG */
.bv .bv-donut { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.bv .bv-leyenda { font-size: 12px; display: flex; flex-direction: column; gap: 5px; }
.bv .bv-leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 7px; }
.bv svg text { font-family: var(--bv-mono); }
.bv .bv-barra-fila { display: grid; grid-template-columns: 120px 1fr 96px; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.bv .bv-barra { height: 15px; border-radius: 3px; background: var(--bv-sup2); position: relative; overflow: hidden; }
.bv .bv-barra > i { position: absolute; top: 0; bottom: 0; display: block; }

/* ── Simplificación UX (ago-2026): un botón principal por vista + menú «⋯» ── */
.bv .bv-btn.principal {
  background: var(--bv-ambar); color: #fff; border-color: var(--bv-ambar);
  font-weight: 700;
}
/* Menú flotante (se monta en <body> con clase .bv para heredar las variables) */
.bv-menu-flotante {
  position: fixed; z-index: 3000;
  background: var(--bv-sup); border: 1px solid var(--bv-borde);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18);
  min-width: 210px; padding: 5px; display: flex; flex-direction: column;
  font-family: var(--bv-cuerpo);
}
.bv-menu-flotante button {
  background: transparent; border: 0; color: var(--bv-texto);
  text-align: left; padding: 9px 12px; font-size: 13px; border-radius: 7px; cursor: pointer;
}
.bv-menu-flotante button:hover { background: #e8f0fe; }
.bv-menu-flotante button.rojo { color: var(--bv-rojo); }
.bv-menu-flotante .separador { height: 1px; background: var(--bv-borde); margin: 4px 8px; }

/* Jerarquía de indicadores: un dato grande manda, los demás acompañan */
.bv .bv-kpi.hero { grid-column: span 2; border-color: #bbd6f7; background: #f7fbff; }
.bv .bv-kpi.hero .bv-kpi-val { font-size: 30px; }
@media (max-width: 700px) { .bv .bv-kpi.hero { grid-column: span 1; } }

/* Tablas: más aire por fila, sublíneas discretas */
.bv table.bv-tabla td { padding: 9px 10px; }

/* El hover global del tema claro (tbody tr:hover td → #fafbfd) pintaba las filas del
   módulo oscuro casi de blanco y la letra clara desaparecía. Se anula DENTRO de .bv
   con mayor especificidad y se deja un resaltado ámbar tenue que sí se ve. */
.bv table.bv-tabla tbody tr:hover td { background: #f4f8fd; }
.bv table.bv-tabla tbody tr.grupo:hover td { background: #e8f0fe; }
.bv table.bv-tabla th:hover { background: var(--bv-sup2); }

/* ── Tablero v8: la cuenta a la vista ──────────────────────────────────────────
   El usuario no entendía "PyG no realizado" ni "Realizado 2026", y con razón: son
   nombres de contador, no respuestas. La solución no fue renombrarlos sino MOSTRAR
   LA CUENTA: una fila de sumandos con sus signos que termina en el resultado. Si el
   número sorprende, se ve en qué sumando está la sorpresa sin preguntarle a nadie. */
.bv .bv-formula {
  display: flex; align-items: stretch; flex-wrap: wrap; gap: 4px;
  background: var(--bv-sup2); border: 1px solid var(--bv-borde);
  border-radius: 10px; padding: 12px 14px;
}
.bv .bv-paso { padding: 4px 10px; min-width: 118px; }
.bv .bv-paso-lbl { font-size: 11px; color: var(--bv-tenue); line-height: 1.3; }
.bv .bv-paso-val { font-family: var(--bv-mono); font-size: 16px; font-weight: 600; margin-top: 3px; white-space: nowrap; }
.bv .bv-signo {
  display: flex; align-items: center; font-size: 19px; font-weight: 700;
  color: var(--bv-tenue); padding: 0 2px;
}
.bv .bv-paso.total { border-left: 2px solid var(--bv-borde); margin-left: 6px; padding-left: 14px; }
.bv .bv-paso.total .bv-paso-val { font-size: 21px; }

/* Patrimonio por clase de bien: una fila por clase, NUNCA un rendimiento mezclado.
   Un avalúo anual y un cierre diario no promedian a nada que signifique algo. */
.bv .bv-clase-ico { font-size: 15px; margin-right: 6px; }

/* Avisos accionables (caja en rojo, falta un avalúo): el aviso trae su botón. */
.bv .bv-aviso {
  display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap;
  background: #fff8e1; border: 1px solid #ffe082; border-left: 4px solid #f57c00;
  border-radius: 9px; padding: 11px 14px; margin-bottom: 14px; font-size: 12.5px;
}
.bv .bv-aviso b { display: block; font-size: 13px; margin-bottom: 2px; color: #8a5a00; }
.bv .bv-aviso .crece { flex: 1; min-width: 260px; }

/* Barra de sub-pestañas propia del módulo (las del resto de la app son navy). */
.bv .bv-subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.bv .bv-subtab {
  background: transparent; border: 1px solid transparent; color: var(--bv-tenue);
  border-radius: 8px; padding: 6px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.bv .bv-subtab.activa { background: var(--bv-sup); border-color: var(--bv-borde); color: var(--bv-ambar-os); }

/* ── Tabla que se adapta al ancho que le den, sin barra horizontal ──
   `.bv-tabla-wrap` lleva `overflow:auto`, que está bien para las tablas anchas de
   operaciones: si no caben, se corren. Pero dentro de una columna estrecha (las dos
   de Concentración, al 50 % cada una) el resultado era una tabla cortada con barra,
   con el valor a medio mostrar y la columna del peso fuera de vista.

   LA CAUSA ERA UNA REGLA GLOBAL DE LA APP: `table { min-width: 720px }` (arriba, en
   la sección de tablas de Cartera) obliga a CUALQUIER tabla a medir 720 px, así que
   ni `width:100%` ni `table-layout:fixed` la bajaban de ahí; con `overflow:visible`
   se salía encima de la tabla vecina. Por eso el `min-width: 0` de abajo NO es
   decorativo: es lo único que suelta esa atadura. Misma familia que el bug del hover
   de agosto: el módulo vive dentro de una app con estilos globales, y hay que
   anularlos explícitamente. */
.bv .bv-tabla-fluida { overflow: visible; }
.bv .bv-tabla-fluida table.bv-tabla {
  table-layout: fixed; width: 100%;
  min-width: 0;        /* anula el `table { min-width: 720px }` global */
  max-width: 100%;
}
.bv .bv-tabla-fluida th, .bv .bv-tabla-fluida td { white-space: normal; overflow-wrap: anywhere; }
.bv .bv-tabla-fluida td.num, .bv .bv-tabla-fluida th.num { white-space: nowrap; overflow-wrap: normal; }
/* Con dos tablas hombro a hombro el mínimo por columna baja: si no caben, el grid
   pasa a una sola columna a lo ancho completo en vez de recortarlas. */
.bv .bv-grid-conc { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }

/* ═══ Cartera → Intereses de mora ═════════════════════════════════════════ */
.int-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.int-cards .card .sub2 { font-size: 11.5px; }
.int-barra { gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.int-subtabs { flex-wrap: wrap; }
.int-acciones { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.int-aviso { border-radius: 9px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; line-height: 1.5; }
.int-aviso.rojo  { background: #ffebee; color: #b71c1c; border: 1px solid #ffcdd2; }
.int-aviso.ambar { background: #fff8e1; color: #6d4c00; border: 1px solid #ffe082; }
.int-aviso.verde { background: #e8f5e9; color: #1b5e20; border: 1px solid #c8e6c9; }
.int-aviso.gris  { background: #f5f5f5; color: #455a64; border: 1px solid #e0e0e0; }
.int-aviso .btn-mini { margin-left: 6px; }
.int-chip { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700;
  color: #fff; white-space: nowrap; margin: 1px 0; }
.int-chip.azul { background: #1a237e; } .int-chip.verde { background: #2e7d32; } .int-chip.rojo { background: #c62828; }
.int-chip.gris { background: #78909c; } .int-chip.ambar { background: #f57c00; } .int-chip.morado { background: #6a1b9a; }
.int-sub { font-size: 11.5px; color: #888; font-weight: 400; }
.int-col-cli { min-width: 220px; }
#modalIntActivar .ret-radio, .int-datos .ret-radio, #modalIntActivar .ret-cond label {
  text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 13px; }
.int-excluida td { opacity: .55; }
.int-det-acciones { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px; }
.int-det-acciones .btn { padding: 7px 12px; font-size: 12.5px; }
.int-sim { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; font-size: 13px;
  background: #f3e5f5; border-radius: 9px; padding: 8px 12px; color: #4a148c; }
.int-sim input { width: auto !important; padding: 5px 8px; border: 1.5px solid #ce93d8; border-radius: 6px; }
.int-sim-res { flex-basis: 100%; }
.int-sim-res:empty { display: none; }
.int-check { display: inline-flex !important; align-items: center; gap: 6px; font-size: 12.5px; color: #444;
  margin: 0 16px 0 0 !important; text-transform: none !important; letter-spacing: 0 !important; font-weight: 500 !important; }
.int-check input { width: auto !important; margin: 0; }
.int-checks { display: flex; flex-wrap: wrap; gap: 6px 0; margin-top: 8px; }
.int-lbl { display: block; font-size: 12px; font-weight: 700; color: #555; margin: 10px 0 5px;
  text-transform: uppercase; letter-spacing: .3px; }
.int-inp { width: 100%; padding: 8px 10px; border: 1.5px solid var(--borde); border-radius: 8px; font-size: 13px;
  font-family: inherit; outline: none; }
.int-inp:focus { border-color: var(--azul); }
textarea.int-inp { resize: vertical; line-height: 1.45; }
.int-pl-tabla { margin: 8px 0 2px; padding: 8px 12px; border: 1.5px dashed #c5cae9; border-radius: 8px;
  background: #f5f7ff; color: #5c6bc0; font-size: 12px; text-align: center; }
.int-vars { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.int-var { border: 1px solid #d1c4e9; background: #f3e5f5; color: #4a148c; border-radius: 12px; padding: 2px 8px;
  font-size: 11px; cursor: pointer; font-family: monospace; }
.int-var:hover { background: #e1bee7; }
.int-previa { border: 1px solid var(--borde); border-radius: 8px; padding: 10px; max-height: 60vh; overflow: auto; background: #fafafa; }
/* El correo trae sus propios estilos en línea: que no le afecte el min-width global de las tablas de la app. */
.int-previa table { min-width: 0 !important; width: 100% !important; }
.int-previa th, .int-previa td { position: static !important; }
.int-tasas-head { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 12px; }
.int-modal-det { max-width: 980px; }
@media (max-width: 768px) {
  .int-acciones { margin-left: 0; width: 100%; }
  .int-acciones .btn { flex: 1 1 auto; }
  .int-cards { grid-template-columns: 1fr 1fr; }
}

/* ═══ Crear pendiente desde una factura o un cliente (tareas-crear.js, 6-oct-2026) ═══ */
.btn-mini.pend { background: #455a64; }
#modalTarea { z-index: 2400; }   /* encima de la ficha del cliente (2100) */
.tc-modal { max-width: 520px; }
.tc-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tc-cab h3 { margin: 2px 0 4px; }
.tc-origen { display: block; font-size: 12px; font-weight: 600; color: #607d8b; overflow-wrap: anywhere; }
.tc-x { flex: 0 0 auto; width: 36px; height: 36px; border: 0; border-radius: 10px; background: #f1f4f7; color: #455a64; font-size: 22px; line-height: 1; cursor: pointer; }
.tc-x:hover { background: #e3e8ee; }
.tc-ayuda { font-size: 13px; color: #607d8b; margin: 0 0 4px; }
.tc-error { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; background: #fdecea; color: #b71c1c; font-size: 13px; }
.tc-opc { font-weight: 400; text-transform: none; letter-spacing: 0; color: #90a4ae; }
.tc-dos { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.tc-modal textarea { font-family: inherit; font-size: 13px; line-height: 1.45; }
@media (max-width: 600px) {
  #modalTarea { padding: 0; align-items: flex-end; }
  .tc-modal { max-width: none; max-height: 92vh; border-radius: 16px 16px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
  .tc-dos { grid-template-columns: 1fr; }
  .tc-modal input, .tc-modal select, .tc-modal textarea { font-size: 16px !important; }   /* iOS no hace zoom */
  .tc-modal .row .btn { flex: 1; }
}
