/* =====================================================
   Casa Camejo — Main Stylesheet
   Green Theme · DS Intelligence © 2025
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ───────────────────────────────── */
:root {
  /* Verdes de marca Camejo (tomados del logo oficial) */
  --primary:          #2fae42;
  --primary-dark:     #17953c;
  --primary-darker:   #335943;
  --primary-light:    #e2f6e4;
  --primary-xlight:   #f1faf2;
  --accent:           #4ec44b;
  --accent-dim:       #b7e8bc;

  /* Fondo menta claro + sidebar verde oscuro Camejo */
  --bg:               #F9FFF5;
  --brand-dark:       #335943;
  --sidebar-bg:       #ffffff;
  --sidebar-hover:    rgba(51,89,67,0.07);
  --sidebar-active:   #24452f;
  --card-bg:          #ffffff;

  --text-primary:     #15241a;
  --text-secondary:   #3b4a40;
  --text-muted:       #6b7c70;
  --text-hint:        #9aa89e;

  --border:           #eaf0e8;
  --border-light:     #f3f7f1;

  /* Semántica refinada — tonos suaves y cohesivos con el verde */
  --danger:           #d6453d;
  --danger-dark:      #b1352e;
  --danger-light:     #fdeceb;
  --danger-border:    #f6d2cf;
  --warning:          #c2820a;
  --warning-light:    #fbf3df;
  --warning-border:   #efdcae;
  --info:             #4d7c5f;
  --info-light:       #e9f1ec;
  --info-border:      #cfe0d6;
  --success:          #1f8b3d;
  --success-light:    #e2f6e4;
  --success-border:   #d3eda1;

  --shadow-xs:        0 1px 2px rgba(21,41,26,0.04);
  --shadow-sm:        0 2px 8px rgba(21,41,26,0.05);
  --shadow-md:        0 6px 18px rgba(21,41,26,0.07);
  --shadow-lg:        0 12px 30px rgba(21,41,26,0.09);
  --shadow-xl:        0 24px 48px rgba(21,41,26,0.12);

  --radius:           12px;
  --radius-lg:        16px;
  --radius-xl:        20px;
  --radius-2xl:       26px;
  --radius-full:      9999px;

  --sidebar-width:    236px;
  --sidebar-width-collapsed: 68px;
  --topbar-height:    46px;
  --transition:       0.18s ease;

  /* Tarjetas blancas sólidas (look limpio de la referencia) */
  --glass-bg:         #ffffff;
  --glass-border:     #eef3ec;
  --glass-blur:       0px;
}

/* ── Reset ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Scroll funcional pero sin barra visible (se ve más limpio) */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0 !important; height: 0 !important; display: none; }
html { font-size: 16px; scroll-behavior: smooth; overflow-x: clip; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
  max-width: 100vw;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Layout ──────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--text-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition), width var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 0; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  position: relative;
}

.sidebar-logo-img {
  /* Logo horizontal de Camejo — el PNG tiene fondo blanco, igual que el sidebar */
  width: 92px;
  height: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-logo-text { flex: 1; min-width: 0; overflow: hidden; }
.sidebar-logo-text h2 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
}

.sidebar-logo-text p {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
}

.sidebar-collapse-btn {
  background: #eef4ec;
  border: none;
  color: #335943;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.sidebar-collapse-btn:hover { background: #dcecd9; color: #24402f; }
.sidebar-collapse-btn svg { transition: transform var(--transition); }

.sidebar-nav {
  flex: 1;
  padding: 10px 9px;
}

.nav-section-label {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-hint);
  padding: 8px 10px 3px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  border-radius: 9px;
  transition: all var(--transition);
  position: relative;
  text-decoration: none;
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
}
.nav-text { overflow: hidden; text-overflow: ellipsis; }

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #24402f;
  text-decoration: none;
}

.nav-link.active {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.nav-link.active::before { content: none; }

.nav-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-link.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  background: #f3f8f2;
  border: 1px solid var(--border-light);
}

.user-avatar {
  width: 34px;
  height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info #user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.user-info #user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.logout-btn {
  background: none;
  border: none;
  color: var(--text-hint);
  padding: 5px;
  border-radius: 6px;
  transition: all var(--transition);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logout-btn:hover { color: var(--danger); background: var(--danger-light); }

/* ── Sidebar colapsado (solo iconos) ─────────────── */
body.sidebar-collapsed .sidebar { width: var(--sidebar-width-collapsed); }
body.sidebar-collapsed .main-content { margin-left: var(--sidebar-width-collapsed); }

body.sidebar-collapsed .sidebar-logo-text,
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .nav-section-label,
body.sidebar-collapsed .user-info,
body.sidebar-collapsed .logout-btn {
  opacity: 0;
  width: 0;
  pointer-events: none;
  display: none;
}

body.sidebar-collapsed .sidebar-logo {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 14px 6px;
}

body.sidebar-collapsed .sidebar-logo-img {
  width: 100%;
  max-width: 52px;
}
body.sidebar-collapsed .sidebar-collapse-btn {
  background: #eef4ec;
  width: 30px;
  height: 26px;
}
body.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

body.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 9px 0;
  gap: 0;
}
body.sidebar-collapsed .nav-link.active::before { display: none; }

body.sidebar-collapsed .sidebar-nav { padding: 10px 8px; }
body.sidebar-collapsed .user-card { justify-content: center; padding: 8px; }

/* Tooltip flotante al pasar el cursor en modo colapsado */
body.sidebar-collapsed .nav-link::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) scale(0.9);
  background: #0f172a;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  z-index: 200;
  box-shadow: var(--shadow-md);
}
body.sidebar-collapsed .nav-link:hover::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* ── Main Content ────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.page-content > * { max-width: 100%; }

/* ── Topbar ──────────────────────────────────────── */
.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius);
  transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--border-light); color: var(--text-primary); }
.sidebar-toggle svg { display: block; }

.topbar-title { display: none; }   /* sin título de página */

/* Header compacto: fecha + notificaciones a la derecha */
.topbar-notif { position: relative; flex-shrink: 0; }
.topbar-notif-btn {
  position: relative;
  width: 30px; height: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.topbar-notif-btn svg { width: 16px; height: 16px; }
.topbar-notif-btn:hover { background: var(--border-light); color: var(--text-primary); }
.topbar-notif-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 800;
  border-radius: 99px; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--card-bg);
}
.topbar-notif-badge.hidden { display: none; }
.topbar-notif-panel {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 340px; max-width: 88vw;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 300; overflow: hidden; display: none;
}
.topbar-notif-panel.open { display: block; }
.topbar-notif-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
  font-size: 13px; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: 7px;
}
.topbar-notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 11px 16px; border-bottom: 1px solid var(--border-light);
  text-decoration: none; color: inherit; transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--border-light); text-decoration: none; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.notif-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.notif-empty { padding: 26px 16px; text-align: center; color: var(--text-muted); font-size: 12.5px; }

.topbar-date {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(0,0,0,0.04);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-left: auto;
}

.page-content {
  flex: 1;
  padding: 20px;
}

/* ── KPI Cards ───────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;        /* todas las filas con la misma altura */
  gap: 10px;
  margin-bottom: 18px;
}
.kpi-grid .kpi-card { height: 100%; }

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 9px 11px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
/* Tarjeta destacada (verde oscuro con acento lima) */
.kpi-card.featured {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}
.kpi-card.featured .kpi-value,
.kpi-card.featured .kpi-label { color: #fff; }
.kpi-card.featured .kpi-icon { background: var(--accent); color: var(--brand-dark); }
.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kpi-icon {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  flex-shrink: 0;
  color: var(--primary-dark);
}
.kpi-icon svg { width: 13px; height: 13px; }

.kpi-icon.danger {
  background: var(--danger-light);
  color: var(--danger);
}
.kpi-icon.warning {
  background: var(--warning-light);
  color: var(--warning);
}
.kpi-icon.info {
  background: var(--info-light);
  color: var(--info);
}

.kpi-value {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 1px;
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-label {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.25;
}

.kpi-trend {
  font-size: 12px;
  font-weight: 600;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
/* Delta tipo píldora (estilo referencia) */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.delta.up   { background: var(--success-light); color: var(--success); }
.delta.down { background: var(--danger-light);  color: var(--danger); }

/* ── Charts ──────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg { color: var(--primary); }

.card-body { padding: 20px; }

.chart-container {
  position: relative;
  height: 260px;
}

/* ── Donut moderno con leyenda lateral ───────────── */
.donut-layout {
  display: flex;
  align-items: center;
  gap: 18px;
}
.donut-canvas-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  flex-shrink: 0;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.donut-center-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}
.donut-center-lbl {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.donut-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}
.donut-legend-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
}
.donut-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex-shrink: 0;
}
.donut-legend-label { color: var(--text-secondary); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.donut-legend-val   { font-weight: 700; color: var(--text-primary); }
.donut-legend-monto { font-weight: 700; color: var(--text-primary); font-size: 11.5px; min-width: 62px; text-align: right; white-space: nowrap; }
.donut-legend-pct   { color: var(--text-muted); font-size: 11px; min-width: 32px; text-align: right; }
.donut-legend-total { border-top: 1px solid var(--border-light); margin-top: 3px; padding-top: 6px; }
.donut-legend-total .donut-legend-label { font-weight: 700; color: var(--text-primary); }
@media (max-width: 1100px) { .donut-layout { flex-direction: column; } .donut-legend { width: 100%; } }

/* ── Stats Row (mora breakdown etc.) ─────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 9px 11px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-card-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-card-value {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-card.danger .stat-card-value { color: var(--danger); }
.stat-card.warning .stat-card-value { color: var(--warning); }
.stat-card.success .stat-card-value { color: var(--primary); }
.stat-card.info .stat-card-value { color: var(--info); }

/* ── Aging Cards ─────────────────────────────────── */
.aging-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

/* Cards de envejecimiento — minimalistas, liquid glass con tinte por bucket */
.aging-card {
  --c: #64748b;
  border-radius: 14px;
  padding: 12px 13px;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
  background: linear-gradient(155deg,
    color-mix(in srgb, var(--c) 12%, #fff) 0%,
    color-mix(in srgb, var(--c) 5%, #fff) 100%);
  backdrop-filter: blur(8px) saturate(150%);
  -webkit-backdrop-filter: blur(8px) saturate(150%);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255,255,255,0.7);
  transition: box-shadow var(--transition), transform var(--transition);
}
.aging-card:hover { box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.7); transform: translateY(-2px); }

.aging-card.al-dia    { --c: #2fae42; }
.aging-card.dias-1-7  { --c: #ca8a04; }
.aging-card.dias-8-30 { --c: #ea580c; }
.aging-card.dias-8-90 { --c: #dc2626; }
.aging-card.mas-90    { --c: #7f1d1d; }

.aging-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.aging-label::before {
  content: '';
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--c); flex-shrink: 0;
}

.aging-count {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 3px;
  letter-spacing: -0.02em;
  color: var(--c);
}

.aging-monto {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Bottom Grid ─────────────────────────────────── */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── Ejecutivo Cards ─────────────────────────────── */
.ejecutivos-grid { display: flex; flex-direction: column; gap: 10px; }

.ejecutivo-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  background: var(--bg);
  transition: background var(--transition), border-color var(--transition);
}
.ejecutivo-card:hover { background: var(--primary-xlight); border-color: var(--accent-dim); }

.ejecutivo-avatar {
  width: 38px;
  height: 38px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.ejecutivo-info { flex: 1; min-width: 0; }
.ejecutivo-info h4 { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.ejecutivo-info p  { font-size: 12px; color: var(--text-muted); }

.ejecutivo-stats { display: flex; gap: 16px; }
.stat { text-align: center; }
.stat-value { display: block; font-size: 13.5px; font-weight: 700; line-height: 1.3; }
.stat-label { font-size: 10px; color: var(--text-muted); letter-spacing: 0.03em; }

/* ── Tables ──────────────────────────────────────── */
.table-container {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
  flex-wrap: wrap;
}

.table-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-title svg { color: var(--primary); }

.table-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex: 1; }

.table-wrapper { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
/* Compact variant for wide tables like renovaciones */
.data-table.renov-table { font-size: 12.5px; }
.data-table.renov-table th, .data-table.renov-table td { padding: 8px 10px; }

.data-table thead tr {
  background: var(--border-light);
}

.data-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr:last-child td { border-bottom: none; }

.text-right  { text-align: right  !important; }
.text-center { text-align: center !important; }

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.badge-activo, .badge-pagado {
  background: var(--success-light);
  color: var(--success);
}
.badge-mora, .badge-atrasado {
  background: var(--danger-light);
  color: var(--danger);
}
.badge-liquidado {
  background: var(--border-light);
  color: var(--text-muted);
}
.badge-pendiente {
  background: var(--warning-light);
  color: var(--warning);
}
.badge-master {
  background: var(--primary-light);
  color: var(--primary-darker);
}
/* Tag para cuentas de cartera activa con +90 días de mora (candidatas a
   irrecuperables) — siguen pagando/activas, solo es una señal visual */
.badge-irr-candidato {
  background: #7f1d1d;
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  margin-left: 6px;
}
.badge-ejecutivo {
  background: var(--info-light);
  color: var(--info);
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--brand-dark);
  color: #fff;
  border-color: var(--brand-dark);
  box-shadow: 0 2px 8px rgba(21,41,26,0.18);
}
.btn-primary:hover {
  background: #1f3526;
  border-color: #1f3526;
  box-shadow: 0 4px 12px rgba(21,41,26,0.25);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); border-color: #cbd5e1; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-dark); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

.btn-sm  { padding: 5px 12px; font-size: 12px; }
.btn-lg  { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

/* ── Compact action buttons for table rows ───────── */
.btn-xs {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 8px; font-size: 11px; font-weight: 500;
  border-radius: 6px; border: 1px solid var(--border);
  cursor: pointer; white-space: nowrap; line-height: 1.4;
  transition: background .15s, border-color .15s;
}
.btn-xs.btn-outline { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-xs.btn-outline:hover { background: var(--bg-secondary); }
.btn-xs.btn-secondary-xs { background: var(--bg-secondary); color: var(--text-primary); border-color: var(--border); }
.btn-xs.btn-secondary-xs:hover { background: var(--border); }
.btn-xs.btn-danger-xs { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.btn-xs.btn-danger-xs:hover { background: #fee2e2; }
.btn-xs.btn-ai-xs { background: var(--primary-xlight); color: var(--primary-dark); border-color: var(--accent-dim); }
.btn-xs.btn-ai-xs:hover { background: var(--accent-dim); }
.btn-xs.btn-ai-xs--green { background: #f0fdf4; color: #335943; border-color: #bbf7d0; }
.btn-xs.btn-ai-xs--green:hover { background: #e2f6e4; }
.btn-xs.btn-ai-xs--blue { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.btn-xs.btn-ai-xs--blue:hover { background: #dbeafe; }

/* ── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47,174,66,0.12);
}

.form-input::placeholder { color: var(--text-hint); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

.form-hint {
  font-size: 12px;
  color: var(--text-hint);
  margin-top: 4px;
}

.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 14px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Calculated preview field */
.calc-field {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 700;
}

/* Input with icon */
.input-with-icon { position: relative; }
.input-with-icon .form-input { padding-right: 44px; }
.input-icon-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color var(--transition);
}
.input-icon-btn:hover { color: var(--text-primary); }

/* Search input */
.search-input {
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

/* ── Modals ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  backdrop-filter: blur(2px);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(8px);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-lg   { max-width: 720px; }
.modal-xl   { max-width: 880px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 1;
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.modal-close {
  background: transparent;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
  box-shadow: none;
  outline: none;
}
.modal-close:hover {
  background: var(--border-light);
  color: var(--text-primary);
  box-shadow: none;
}

.modal-body { padding: 20px 24px; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
  border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
  position: sticky;
  bottom: 0;
}

/* ── Alerts ──────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid;
  margin-bottom: 14px;
  display: none;
  align-items: center;
  gap: 8px;
}
.alert.show { display: flex; }

.alert-success { background: var(--success-light); border-color: var(--success-border); color: #335943; }
.alert-error   { background: var(--danger-light);  border-color: var(--danger-border);  color: var(--danger); }
.alert-warning { background: var(--warning-light); border-color: var(--warning-border); color: #92400e; }
.alert-info    { background: var(--info-light);    border-color: var(--info-border);    color: #1d4ed8; }

/* ── Toast Notifications ─────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-primary);
  color: #fff;
  padding: 13px 18px;
  border-radius: var(--radius-xl);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  transition: opacity 0.28s, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast-success { background: var(--brand-dark); }
.toast-error   { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info    { background: var(--info); }

.toast-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Pagination ──────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
  background: var(--bg);
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.page-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.page-info {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Loading States ──────────────────────────────── */
.spinner {
  width: 30px;
  height: 30px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px;
  gap: 14px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13.5px;
  text-align: center;
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-hint);
  opacity: 0.7;
}

/* ── Login Page — estilo marketplace camejo.mx ───── */
.login-page {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background: #f0f3ef;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
/* Franja superior verde oscuro, como la barra de navegación del sitio */
.login-page::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 8px;
  background: #335943;
}

/* Shell de dos paneles — card blanca limpia estilo retail */
.login-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 960px;
  min-height: 560px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: #ffffff;
  border: 1px solid #e4eae2;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(21,41,26,0.14);
}

/* Panel promocional — verde vivo como las tarjetas de promo del sitio */
.login-brand {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(520px 380px at 88% -10%, rgba(255,255,255,0.20) 0%, transparent 60%),
    radial-gradient(420px 360px at -10% 108%, rgba(0,0,0,0.16) 0%, transparent 55%),
    linear-gradient(135deg, #17953c 0%, #2fae42 55%, #4ec44b 100%);
  color: #fff;
  padding: 46px 42px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-deco {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.14);
}
.login-deco.d1 { width: 300px; height: 300px; top: -110px; right: -90px; }
.login-deco.d2 { width: 200px; height: 200px; bottom: -70px; left: -60px; border-width: 14px; border-color: rgba(255,255,255,0.08); }

.login-brand-inner { position: relative; z-index: 1; }

/* "AQUÍ SÍ PUEDES" — tipografía del hero del marketplace */
.login-hero {
  font-size: 44px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: -0.02em;
  line-height: 1.06;
  text-transform: uppercase;
  text-shadow: 0 3px 14px rgba(0,0,0,0.18);
  margin-bottom: 12px;
}
.login-hero-si {
  position: relative;
  color: #ffd23f;
  padding-right: 4px;
}
.login-hero-si svg {
  position: absolute;
  top: -16px; right: -14px;
  width: 26px; height: 26px;
  color: #ffd23f;
  transform: rotate(-6deg);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.22));
}
.login-brand-tag {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.92);
  margin-bottom: 30px;
}
.login-brand-feats { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.login-brand-feats li {
  display: flex; align-items: center; gap: 12px;
  font-size: 13.5px; font-weight: 600; color: #fff;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-full);
  padding: 9px 18px 9px 10px;
  width: fit-content;
  backdrop-filter: blur(4px);
}
.login-brand-feats svg {
  width: 18px; height: 18px; flex-shrink: 0;
  color: #1c7a34; background: #fff;
  border-radius: 50%; padding: 6px; box-sizing: content-box;
}
.login-brand-foot { position: relative; z-index: 1; }

/* Pill blanca "Ven a Camejo y hazlo posible", como la del hero del sitio */
.login-promo-pill {
  display: inline-block;
  background: #fff;
  color: #24402f;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: var(--radius-full);
  padding: 11px 22px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.18);
}
.login-promo-pill strong { font-weight: 800; color: #17953c; }
.login-promo-pill em { font-style: normal; font-weight: 800; color: #2fae42; }

/* Panel del formulario — blanco limpio, logo arriba como el header del sitio */
.login-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 44px 40px;
  background: #ffffff;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 340px;
}

.login-logo-sm { display: block; text-align: center; margin-bottom: 22px; }
.login-logo-sm img { width: 185px; height: auto; margin: 0 auto; }

.login-heading {
  font-size: 23px; font-weight: 800; color: #24402f;
  letter-spacing: -0.02em; text-align: center;
}
.login-sub { font-size: 13.5px; color: var(--text-muted); margin: 6px 0 26px; text-align: center; }

/* Campo con icono a la izquierda */
.login-field { position: relative; }
.login-field-ic {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-hint); display: flex; pointer-events: none;
}
.login-field .form-input {
  padding-left: 40px;
  background: #f4f7f3;
  border-color: #e2e9e0;
  border-radius: var(--radius-full);
}
.login-field .form-input:focus {
  background: #fff;
  border-color: #2fae42;
  box-shadow: 0 0 0 3px rgba(47,174,66,0.15);
}
/* Ocultar el ícono nativo de "revelar contraseña" del navegador (Edge/Chrome) */
.login-field input[type="password"]::-ms-reveal,
.login-field input[type="password"]::-ms-clear { display: none; }

/* Botón pill verde vivo, como los "Conoce más" del marketplace */
.login-card .btn-primary {
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #17953c 0%, #3dbb47 100%);
  border: none;
  font-weight: 700;
  letter-spacing: .01em;
  box-shadow: 0 10px 24px rgba(23,149,60,0.35);
}
.login-card .btn-primary:hover {
  background: linear-gradient(135deg, #128333 0%, #2fae42 100%);
  box-shadow: 0 12px 28px rgba(23,149,60,0.45);
}

.login-form { display: flex; flex-direction: column; gap: 4px; }

.login-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-hint);
}

/* Login en móvil: una sola columna, sin panel visual */
@media (max-width: 820px) {
  .login-page { padding: 16px; }
  .login-shell {
    grid-template-columns: 1fr;
    max-width: 400px;
    min-height: 0;
    border-radius: 20px;
  }
  .login-brand { display: none; }
  .login-form-wrap { padding: 34px 26px; }
  .login-card { max-width: 100%; }
}

/* ── Smart select (searchbar inteligente para ejecutivos) ── */
.smart-select-origin { display: none !important; }
.smart-select {
  position: relative;
  width: 185px;
  display: inline-block;
  vertical-align: middle;
}
.form-group .smart-select { width: 100%; display: block; }
.smart-select-ic {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-hint); display: flex; pointer-events: none; z-index: 1;
}
.smart-select-input {
  width: 100%;
  height: 36px;
  font-size: 13px;
  padding-left: 32px;
  padding-right: 28px;
}
.smart-select-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-hint);
  width: 18px; height: 18px; border-radius: 50%;
  display: none; align-items: center; justify-content: center; cursor: pointer;
}
.smart-select.has-value .smart-select-clear { display: flex; }
.smart-select-clear:hover { color: var(--danger); background: var(--danger-light); }
.smart-select-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 230px;
  overflow-y: auto;
  z-index: 300;
}
.smart-select-list.open { display: block; }
/* Sin espacio debajo (p.ej. cerca del footer de un modal) → se abre hacia arriba */
.smart-select.smart-select-up .smart-select-list {
  top: auto;
  bottom: calc(100% + 4px);
}
.smart-select-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
}
.smart-select-item:last-child { border-bottom: none; }
.smart-select-item:hover { background: var(--primary-xlight); }
.smart-select-item.selected { background: var(--primary-light); font-weight: 600; color: var(--primary-darker); }
.smart-select-empty { padding: 10px 12px; font-size: 12.5px; color: var(--text-hint); }

/* ── FAB de acciones rápidas (abajo a la derecha) ── */
.qa-fab-wrap {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 160;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.qa-fab {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(23,149,60,0.4);
  transition: transform var(--transition), box-shadow var(--transition);
}
.qa-fab:hover { transform: scale(1.06); box-shadow: 0 12px 30px rgba(23,149,60,0.5); }
.qa-fab svg { transition: transform 0.22s ease; }
.qa-fab-wrap.open .qa-fab svg { transform: rotate(45deg); }

/* Mini-círculos en arco alrededor del botón principal (solo icono) */
.qa-actions { pointer-events: none; }
.qa-action {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 38px;
  height: 38px;
  text-decoration: none;
  opacity: 0;
  transform: translate(0, 0) scale(0.4);
  transition: opacity 0.16s ease, transform 0.24s cubic-bezier(0.34, 1.4, 0.64, 1);
}
/* El círculo con hover (y su tooltip) siempre por encima de los demás y del FAB */
.qa-action:hover { z-index: 10; }
/* Arco de 90° del FAB: arriba → izquierda (radio 86px) */
.qa-action:nth-child(1) { --tx:   0px; --ty: -86px; }
.qa-action:nth-child(2) { --tx: -43px; --ty: -74px; }
.qa-action:nth-child(3) { --tx: -74px; --ty: -43px; }
.qa-action:nth-child(4) { --tx: -86px; --ty:   0px; }
.qa-fab-wrap.open .qa-actions { pointer-events: auto; }
.qa-fab-wrap.open .qa-action { opacity: 1; transform: translate(var(--tx), var(--ty)) scale(1); }
.qa-fab-wrap.open .qa-action:nth-child(1) { transition-delay: 0s; }
.qa-fab-wrap.open .qa-action:nth-child(2) { transition-delay: 0.04s; }
.qa-fab-wrap.open .qa-action:nth-child(3) { transition-delay: 0.08s; }
.qa-fab-wrap.open .qa-action:nth-child(4) { transition-delay: 0.12s; }

.qa-action-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  color: var(--primary-darker);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: all var(--transition);
}
.qa-action-circle svg { width: 16px; height: 16px; }
.qa-action:hover .qa-action-circle {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: scale(1.12);
}

/* Tooltip: aparece solo al pasar el cursor, a la izquierda del círculo */
.qa-action-label {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(4px);
  background: var(--brand-dark);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 20;
}
.qa-action:hover .qa-action-label {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* En móvil el FAB sube para no encimarse con la barra de navegación inferior */
@media (max-width: 820px) {
  .qa-fab-wrap { right: 14px; bottom: 76px; }
  .qa-fab { width: 50px; height: 50px; }
}

/* ── Utility Classes ─────────────────────────────── */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.text-sm      { font-size: 12px; }
.text-bold    { font-weight: 700; }
.fw-600       { font-weight: 600; }

.d-flex        { display: flex; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1  { margin-top: 4px; }
.mt-2  { margin-top: 8px; }
.mt-3  { margin-top: 16px; }
.mb-3  { margin-bottom: 16px; }
.mb-4  { margin-bottom: 24px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}

/* RA Result Box */
.ra-result {
  background: var(--primary-xlight);
  border: 1.5px solid var(--accent-dim);
  border-radius: var(--radius-xl);
  padding: 16px;
  display: none;
  margin-top: 12px;
}
.ra-result.show { display: block; }
.ra-result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.ra-item { text-align: center; padding: 8px; border-radius: var(--radius); background: rgba(255,255,255,0.6); }
.ra-item-value { font-size: 18px; font-weight: 800; color: var(--primary-dark); line-height: 1.2; }
.ra-item-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* Pagos progress bar */
.pagos-progress { margin-top: 6px; }
.progress-bar-bg {
  height: 5px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* Actions column */
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.actions > * { flex-shrink: 0; }
/* La columna de acciones nunca se parte ni se encoge: la tabla hace scroll si hace falta */
.data-table td .actions { white-space: nowrap; }
.data-table th:last-child, .data-table td:last-child { white-space: nowrap; }
/* Botones de acción anclados a la derecha de su columna */
.data-table .actions { justify-content: flex-end; }
.data-table th:last-child { text-align: right; }

/* ── Page-specific header ────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-left h1 {
  font-size: 21px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-header-left p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Comparativo Panel ───────────────────────────── */
.comparativo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.comparativo-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  text-align: center;
}

.comparativo-card .c-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 6px;
}

.comparativo-card .c-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.comparativo-card.success .c-value { color: var(--primary); }
.comparativo-card.warning .c-value { color: var(--warning); }
.comparativo-card.info    .c-value { color: var(--info); }

/* ── Doc upload areas ────────────────────────────── */
.doc-upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}

.doc-upload-slot {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
}

.doc-upload-slot:hover {
  border-color: var(--primary);
  background: var(--primary-xlight);
}

.doc-upload-slot .doc-icon {
  color: var(--text-hint);
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-upload-slot:hover .doc-icon { color: var(--primary); }

.doc-upload-slot .doc-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.doc-upload-slot .doc-hint {
  font-size: 10.5px;
  color: var(--text-hint);
  margin-top: 3px;
}

.doc-upload-slot input[type="file"] { display: none; }

/* ── Mora Detail Analysis ────────────────────────── */
.mora-analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.mora-analysis-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 16px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.mora-analysis-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.mora-analysis-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.mora-analysis-row:last-child { border-bottom: none; }

.mora-analysis-row .label { color: var(--text-secondary); }
.mora-analysis-row .value { font-weight: 700; color: var(--text-primary); }
.mora-analysis-row .value.danger { color: var(--danger); }
.mora-analysis-row .value.success { color: var(--primary); }

/* Resumen de mora por antigüedad — vista tipo tabla/lista con acento verde,
   inspirada en el control de pagos original del cliente (fila con triángulo
   verde a la izquierda + monto en negrita a la derecha, filas alternadas). */
.mat-table { display: flex; flex-direction: column; }
.mat-row {
  display: flex;
  align-items: center;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-light);
  background: var(--card-bg);
}
.mat-row:last-child { border-bottom: none; }
.mat-row:nth-child(even) { background: var(--primary-xlight); }
.mat-row::before {
  content: '';
  width: 0; height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 7px solid var(--primary);
  margin-right: 14px;
  flex-shrink: 0;
}
.mat-label { flex: 1; font-weight: 600; font-size: 13px; color: var(--text-primary); }
.mat-label small { font-weight: 500; color: var(--text-muted); font-size: 11px; }
.mat-value { font-weight: 800; font-size: 15.5px; color: var(--text-primary); font-variant-numeric: tabular-nums; }
/* La fila nueva "8 días en adelante" (acumulado) se destaca del resto */
.mat-row.mat-highlight { background: var(--warning-light); }
.mat-row.mat-highlight::before { border-left-color: var(--warning); }
.mat-row.mat-highlight .mat-value { color: var(--warning); }

/* Vista compacta de la página de Mora — menos padding/tamaños, menos "aire"
   entre tarjetas. Escopeado a .mora-page para no afectar al Dashboard, que
   comparte las mismas clases .aging-grid/.aging-card. */
.mora-page .aging-grid { gap: 7px; margin-bottom: 10px; }
.mora-page .aging-card { padding: 7px 9px; border-radius: 9px; }
.mora-page .aging-label { font-size: 8px; margin-bottom: 3px; gap: 3px; }
.mora-page .aging-label::before { width: 5px; height: 5px; }
.mora-page .aging-count { font-size: 15px; margin-bottom: 1px; }
.mora-page .aging-monto { font-size: 9.5px; }

.mora-page .card.mb-4 { margin-bottom: 10px; }
.mora-page .card-header { padding: 8px 12px; }
.mora-page .card-title { font-size: 12px; }

.mora-page .mat-row { padding: 6px 12px; }
.mora-page .mat-row::before { border-top-width: 5px; border-bottom-width: 5px; border-left-width: 6px; margin-right: 9px; }
.mora-page .mat-label { font-size: 11.5px; }
.mora-page .mat-label small { font-size: 9.5px; }
.mora-page .mat-value { font-size: 12.5px; }

.mora-page .mora-analysis-grid { gap: 8px; margin-top: 10px; }
.mora-page .mora-analysis-card { padding: 9px 12px; }
.mora-page .mora-analysis-title { font-size: 10px; margin-bottom: 6px; }
.mora-page .mora-analysis-row { padding: 4px 0; font-size: 11.5px; }

/* ── Bottom nav tipo app (solo móvil): slider horizontal ── */
.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  height: 58px;
  background: var(--brand-dark);
  z-index: 400;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 22px rgba(0,0,0,0.20);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  align-items: stretch;
}
.bottom-nav::-webkit-scrollbar { display: none; height: 0; }
.bnav-item {
  flex: 0 0 auto;
  min-width: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: rgba(255,255,255,0.56); font-size: 9.5px; font-weight: 600;
  background: none; border: none; cursor: pointer; text-decoration: none; padding: 8px 6px;
  transition: color .15s; white-space: nowrap;
}
.bnav-ic { display: flex; }
.bnav-ic svg { width: 16px; height: 16px; }
.bnav-item.active { color: #4ec44b; }
.bnav-item.active .bnav-ic svg { stroke-width: 2.4; }
.bnav-lbl { line-height: 1; }
.bnav-logout { color: rgba(255,120,110,0.85); }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1200px) {
  .aging-grid     { grid-template-columns: repeat(3, 1fr); }
  .charts-grid    { grid-template-columns: 1fr; }
  .kpi-grid       { grid-template-columns: repeat(3, 1fr); }
  .stats-row      { grid-template-columns: repeat(2, 1fr); }
  .comparativo-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .bottom-grid    { grid-template-columns: 1fr; }
  .kpi-grid       { grid-template-columns: repeat(2, 1fr); }
  .aging-grid     { grid-template-columns: repeat(3, 1fr); }
  .stats-row      { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Sin sidebar ni hamburguesa en móvil: se usa el bottom-nav tipo app */
  .sidebar { display: none; }
  .sidebar-toggle { display: none; }
  .main-content { margin-left: 0; padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  body.sidebar-collapsed .main-content { margin-left: 0; }
  .bottom-nav { display: flex; }

  /* Header compacto: todo a la derecha, pequeño, sin botón de importar */
  .topbar {
    height: auto; min-height: 52px;
    padding: 0 10px; gap: 8px;
    justify-content: flex-end; align-items: center; flex-wrap: nowrap;
  }
  #topbar-import { display: none !important; }
  .topbar-date {
    display: inline-block; margin-left: auto;
    font-size: 10px; padding: 3px 8px; white-space: nowrap; align-self: center;
    min-width: 0; flex-shrink: 1; overflow: hidden; text-overflow: ellipsis;
  }
  .topbar-notif { align-self: center; }
  .topbar-notif-btn { width: 30px; height: 30px; }
  .topbar-notif-btn svg { width: 15px; height: 15px; }
  /* INTELLI: círculo compacto solo con el logo, centrado y a la derecha */
  .intelli-fab {
    width: 32px !important; height: 32px !important;
    padding: 0 !important; gap: 0 !important; font-size: 0 !important;
    border-radius: 50% !important; align-self: center; flex-shrink: 0;
  }
  .intelli-fab-icon { width: 32px !important; height: 32px !important; }
  .intelli-fab-icon img { width: 18px !important; height: 18px !important; }

  /* Body más compacto en móvil */
  .page-content { padding: 12px; }
  /* 8 KPIs arriba y 4 stat-cards abajo → 4 columnas en móvil */
  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
  .kpi-card { padding: 7px 5px; min-height: 42px; text-align: center; align-items: center; }
  .kpi-card .kpi-icon { display: none !important; }   /* sin iconos en móvil */
  .kpi-header {
    gap: 0; width: 100%;
    flex-direction: column; align-items: center; justify-content: center;
  }
  .kpi-header > div { width: 100%; text-align: center; }
  .kpi-value { font-size: 10.5px; text-align: center; width: 100%; }
  /* Etiquetas cortas (data-short) en móvil */
  .kpi-label, .stat-card-label { font-size: 0; letter-spacing: 0; text-align: center; }
  .kpi-label[data-short]::after, .stat-card-label[data-short]::after {
    content: attr(data-short);
    font-size: 8px; font-weight: 600;
  }
  .stats-row { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .stat-card { padding: 8px 6px; text-align: center; align-items: center; }
  .stat-card-value { font-size: 10.5px; text-align: center; width: 100%; }
  .stat-card-label { text-align: center; width: 100%; }
  .card { padding: 12px; }
  .card-header { padding: 12px; }
  .card-title { font-size: 13px; }
  .card-body { padding: 12px; }
  .section-title { font-size: 15px; }
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .doc-upload-grid { grid-template-columns: 1fr; }

  /* Botones más pequeños en móvil (para que grupos de 3 quepan en línea) */
  .btn { padding: 7px 11px; font-size: 12px; gap: 5px; }
  .btn-sm { padding: 5px 9px; font-size: 11px; }
  .btn-lg { padding: 10px 16px; font-size: 13px; }

  /* Tarjetas comparativas (liquidados, etc.): 3 en línea y compactas */
  .comparativo-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
  .comparativo-card { padding: 10px 6px; }
  .comparativo-card .c-value { font-size: 13px; margin-bottom: 3px; }
  .comparativo-card .c-label { font-size: 7.5px; letter-spacing: 0.02em; }

  /* Mora: tarjetas de análisis apiladas y compactas */
  .mora-analysis-grid { grid-template-columns: 1fr; gap: 10px; }
  .mora-analysis-card { padding: 12px 14px; }
  .mora-analysis-title { font-size: 12px; }
  .mora-analysis-row { font-size: 11.5px; }

  /* Barras de vista/toolbar (préstamos, pagos, matriz) compactas */
  .matriz-toolbar { gap: 6px; margin-bottom: 10px; }
  .view-toggle button { padding: 4px 8px; font-size: 10.5px; }
  /* Selects/inputs con anchos fijos inline en toolbars → a ancho completo */
  .matriz-toolbar .form-input,
  .matriz-toolbar .form-select { width: 100% !important; min-width: 0 !important; flex: 1 1 100%; }

  /* Botones de filtro/tabs aún más compactos para que quepan en línea */
  .btn { padding: 6px 9px; font-size: 11px; }
  .btn-secondary, .btn-primary { min-width: 0; }

  /* Mora: los 2 charts (% Mora / $ en Mora) uno debajo del otro */
  .mora-charts-row { grid-template-columns: 1fr !important; gap: 10px !important; }
  .mora-charts-row canvas { max-height: 200px; }

  /* Ganancia Mensual: card más chaparro */
  .chart-container { height: 150px; }

  /* Envejecimiento de Cartera: card chaparro + 5 cards inline en 5 columnas */
  .aging-grid { grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 0; }
  .aging-card { padding: 7px 4px; border-radius: 9px; }
  .aging-label { font-size: 6px; margin-bottom: 3px; gap: 3px; letter-spacing: 0; }
  .aging-label::before { width: 5px; height: 5px; }
  .aging-count { font-size: 15px; margin-bottom: 1px; }
  .aging-monto { font-size: 7px; }

  /* Alertas de Impago / Proyección / Anomalías: en línea (3 columnas), centradas */
  .dash-2col .dash-side .intelli-stack { flex-direction: row; gap: 8px; align-items: stretch; }
  .dash-2col .dash-side .intelli-stack > .intelli-card {
    flex: 1; min-width: 0; padding: 12px 8px;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
  }
  .dash-2col .dash-side .intelli-stack .card-header {
    flex-direction: column; align-items: center; justify-content: center;
    gap: 9px; padding: 0; border: none; text-align: center; width: 100%;
  }
  .dash-2col .dash-side .intelli-stack .card-title {
    font-size: 10px; gap: 0; line-height: 1.25;
    justify-content: center; text-align: center; flex-wrap: wrap; width: 100%;
  }
  .dash-2col .dash-side .intelli-stack .card-title svg { display: none; }  /* sin iconos */
  .dash-2col .dash-side .intelli-stack .btn-sm { font-size: 9px; padding: 5px 12px; width: auto; align-self: center; }

  /* Actividad Reciente: fuente pequeña, sin scroll horizontal (como ejecutivos) */
  .dash-bottom .data-table { min-width: 0; font-size: 10px; }
  .dash-bottom .data-table th,
  .dash-bottom .data-table td { padding: 6px 7px; white-space: nowrap; }

  /* Ejecutivos: fuente más pequeña para que no se encime */
  .ejecutivo-card { padding: 8px 10px; gap: 8px; }
  .ejecutivo-avatar { width: 30px; height: 30px; font-size: 12px; }
  .ejecutivo-info h4 { font-size: 11px; }
  .ejecutivo-info p { font-size: 9.5px; }
  .ejecutivo-stats { gap: 10px; }
  .stat-value { font-size: 11px; }
  .stat-label { font-size: 8px; }

  /* Tablas (todas las páginas): compactas, legibles y que quepan */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { font-size: 11px; }                 /* sin min-width fijo: nowrap deja
                                                      que las angostas quepan y las
                                                      anchas hagan scroll natural */
  .data-table th, .data-table td { padding: 8px 9px; white-space: nowrap; }

  /* Encabezado de tabla + filtros: apilados y a ancho completo */
  .table-header { padding: 12px; gap: 10px; }
  .table-title { font-size: 13px; }
  .table-filters { width: 100%; }
  .table-filters .form-input,
  .table-filters .form-select,
  .table-filters .search-input,
  .table-filters input,
  .table-filters select { flex: 1 1 100%; min-width: 0; width: 100%; max-width: none !important; }
  /* Botones de acción del encabezado: crecen y se acomodan en móvil */
  .table-header > .btn { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .aging-grid { grid-template-columns: repeat(5, 1fr); }
  .modal { margin: 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .modal-overlay { align-items: flex-end; }
  .stats-row { grid-template-columns: repeat(4, 1fr); }
}

/* ── Ajustes page ──────────────────────────────────── */
.ajustes-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.ajustes-tab {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: color .15s, border-color .15s, background .15s;
}
.ajustes-tab:hover { color: var(--primary); background: var(--primary-xlight); }
.ajustes-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.ajustes-panel { display: none; }
.ajustes-panel.active { display: block; }

.ajustes-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}
.ajustes-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 14px; color: var(--text); }
.toggle-desc  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

.ai-mode-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.ai-mode-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all .15s;
}
.ai-mode-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-xlight);
}

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--border);
}
.status-dot.ok     { background: var(--success); }
.status-dot.error  { background: var(--danger); }
.status-dot.warn   { background: var(--warning); }

.template-textarea {
  width: 100%;
  min-height: 72px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: border-color .15s;
}
.template-textarea:focus { outline: none; border-color: var(--primary); }

.template-var {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--primary-dark);
  font-size: 11px;
  font-family: monospace;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  margin: 2px 3px 2px 0;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.feature-card {
  background: var(--primary-xlight);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.feature-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.feature-card p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}
.badge-soon {
  background: var(--warning);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: auto;
  text-transform: uppercase;
}
.badge-idea {
  background: var(--accent-dim);
  color: var(--primary-dark);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: auto;
  text-transform: uppercase;
}

/* ── AI Widget ─────────────────────────────────────── */
.ai-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-top: 16px;
}
.ai-widget-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.ai-widget-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  flex: 1;
}
.ai-widget-icon {
  width: 28px; height: 28px;
  background: var(--primary-xlight);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}
.ai-widget-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  min-height: 40px;
}
.ai-widget-body.loading { color: var(--text-muted); font-style: italic; }
.ai-widget-body.error   { color: var(--danger); }

/* Markdown renderizado en resultados de IA (mora, dashboard, reportes, etc.) */
.md-render { white-space: normal; }
.md-render p { margin: 4px 0; }
.md-render strong { font-weight: 700; color: var(--text-primary); }
.md-render em { font-style: italic; }
.md-render h3, .md-render h4, .md-render h5 { font-weight: 700; margin: 12px 0 5px; color: var(--text-primary); line-height: 1.3; }
.md-render h3 { font-size: 14.5px; }
.md-render h4 { font-size: 13px; }
.md-render h5 { font-size: 12px; }
.md-render ul, .md-render ol { margin: 6px 0; padding-left: 20px; }
.md-render li { margin: 3px 0; }
.md-render table { border-collapse: collapse; margin: 8px 0; font-size: 12px; min-width: max-content; }
.md-render th, .md-render td { border: 1px solid var(--border); padding: 5px 9px; white-space: nowrap; text-align: right; }
.md-render th:first-child, .md-render td:first-child { text-align: left; }
.md-render th { background: var(--border-light); font-weight: 600; text-align: left; }
.md-render > div { overflow-x: auto; }
.ai-widget-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-ai {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1.5px solid var(--primary);
  background: var(--primary-xlight);
  color: var(--primary-dark);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn-ai:hover {
  background: var(--primary);
  color: #fff;
}
.btn-ai:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── WA quick-send row in mora/clientes ────────────── */
.wa-send-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.btn-wa {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1.5px solid #25d366;
  background: #f0fdf4;
  color: #166534;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn-wa:hover { background: #25d366; color: #fff; }

/* ── AI suggestion chips ───────────────────────────── */
.ai-suggestion-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.ai-suggestion-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-xlight);
}

/* ── Intelli Floating Chatbot ───────────────────────── */
/* Botón INTELLI en el header (ya no flotante) */
.intelli-fab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--brand-dark);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 5px 13px 5px 6px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
  letter-spacing: .03em;
}
.intelli-fab:hover { background: #1f3526; transform: translateY(-1px); }
.intelli-fab-icon {
  width: 22px; height: 22px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.intelli-fab-badge {
  position: absolute;
  top: -3px; right: -3px;
  width: 9px; height: 9px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg);
  display: none;
}
.intelli-fab.has-unread .intelli-fab-badge { display: block; }

/* Botón pulsante mientras INTELLI está pensando */
@keyframes intelli-thinking-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(78,196,75,0.5); }
  50%       { box-shadow: 0 0 0 7px rgba(78,196,75,0); }
}
.intelli-fab.intelli-fab-thinking { animation: intelli-thinking-pulse 1.4s ease-in-out infinite; }

/* Drawer lateral derecho (de piso a techo) */
.intelli-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 92vw;
  height: 100vh;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(21,41,26,0.14);
  display: flex;
  flex-direction: column;
  z-index: 8999;
  overflow: hidden;
  transform: translateX(100%);
  opacity: 1;
  pointer-events: none;
  transition: transform .26s cubic-bezier(.4,0,.2,1);
}
.intelli-panel.open {
  transform: translateX(0);
  pointer-events: all;
}
/* Overlay tenue detrás del drawer */
.intelli-overlay {
  position: fixed; inset: 0;
  background: rgba(21,41,26,0.18);
  z-index: 8998;
  opacity: 0; pointer-events: none;
  transition: opacity .26s ease;
}
.intelli-overlay.open { opacity: 1; pointer-events: all; }
/* Header claro compacto */
.intelli-panel-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  flex-shrink: 0;
}
.intelli-panel-header-icon {
  width: 32px; height: 32px;
  background: var(--primary-light);
  color: var(--primary-darker);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.intelli-panel-header-info { flex: 1; min-width: 0; }
.intelli-panel-header-info h3 { font-size: 14px; font-weight: 700; line-height: 1.1; margin-bottom: 1px; color: var(--text-primary); }
.intelli-panel-header-info p { font-size: 11px; color: var(--text-muted); margin: 0; }

/* Toggle segmentado texto/voz */
.intelli-seg {
  display: inline-flex;
  background: var(--border-light);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}
.intelli-seg-btn {
  width: 30px; height: 26px;
  border: none; background: transparent;
  color: var(--text-muted);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s;
}
.intelli-seg-btn.active { background: var(--card-bg); color: var(--primary-darker); box-shadow: var(--shadow-xs); }

.intelli-panel-close,
.intelli-panel-clear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.intelli-panel-close:hover,
.intelli-panel-clear:hover { background: var(--border-light); color: var(--text-primary); }

/* Vistas: texto vs voz */
.intelli-view-text { display: flex; flex-direction: column; flex: 1; min-height: 0; position: relative; }
.intelli-view-voice { display: none; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: var(--bg); }
.intelli-panel.voice-mode .intelli-view-text { display: none; }
.intelli-panel.voice-mode .intelli-view-voice { display: flex; }

/* Orbe de voz */
.intelli-orb {
  width: 150px; height: 150px;
  border-radius: 50%;
  border: none; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, var(--primary) 0%, var(--sidebar-active) 55%, var(--brand-dark) 100%);
  box-shadow: 0 16px 40px rgba(22,38,26,0.25);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s;
}
.intelli-orb:hover { transform: scale(1.03); }
.intelli-orb-wave { display: flex; align-items: center; gap: 4px; height: 38px; }
.intelli-orb-wave i {
  width: 4px; height: 12px; border-radius: 99px;
  background: rgba(255,255,255,0.9);
  transition: height .15s;
}
.intelli-orb.listening { animation: orbPulse 1.6s ease-in-out infinite; }
.intelli-orb.listening .intelli-orb-wave i { animation: orbBar .9s ease-in-out infinite; }
.intelli-orb.listening .intelli-orb-wave i:nth-child(1){animation-delay:0s}
.intelli-orb.listening .intelli-orb-wave i:nth-child(2){animation-delay:.1s}
.intelli-orb.listening .intelli-orb-wave i:nth-child(3){animation-delay:.2s}
.intelli-orb.listening .intelli-orb-wave i:nth-child(4){animation-delay:.3s}
.intelli-orb.listening .intelli-orb-wave i:nth-child(5){animation-delay:.25s}
.intelli-orb.listening .intelli-orb-wave i:nth-child(6){animation-delay:.15s}
.intelli-orb.listening .intelli-orb-wave i:nth-child(7){animation-delay:.05s}
.intelli-orb.listening .intelli-orb-wave i:nth-child(8){animation-delay:.2s}
.intelli-orb.thinking { animation: orbPulse 1s ease-in-out infinite; }
.intelli-orb.speaking { animation: orbPulse 1.3s ease-in-out infinite; }
@keyframes orbPulse {
  0%,100% { box-shadow: 0 16px 40px rgba(22,38,26,0.25), 0 0 0 0 rgba(47,174,66,0.4); }
  50%     { box-shadow: 0 16px 40px rgba(22,38,26,0.25), 0 0 0 18px rgba(47,174,66,0); }
}
@keyframes orbBar { 0%,100% { height: 10px; } 50% { height: 30px; } }
.intelli-orb-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }

.intelli-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 180px;
  scroll-behavior: smooth;
  background: var(--bg);
}
.intelli-msgs::-webkit-scrollbar { width: 4px; }
.intelli-msgs::-webkit-scrollbar-track { background: transparent; }
.intelli-msgs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.intelli-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.intelli-msg.user { flex-direction: row-reverse; }

/* Pasos del agente en vivo (qué hizo INTELLI) */
.intelli-trace {
  margin: 2px 0 0 34px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: intelliTraceIn .25s ease;
}
@keyframes intelliTraceIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.intelli-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-soft, #6b7280);
  line-height: 1.3;
}
.intelli-step-ic {
  width: 16px; height: 16px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.intelli-step.ok .intelli-step-ic   { background: var(--primary-light); color: var(--primary-darker); }
.intelli-step.pend .intelli-step-ic { background: #fef3c7; color: #b45309; }
.intelli-step.fail .intelli-step-ic { background: #fee2e2; color: #b91c1c; }
.intelli-step.fail span:last-child  { text-decoration: line-through; opacity: .7; }
.intelli-msg-av {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  color: var(--primary-darker);
}
.intelli-msg.user .intelli-msg-av {
  background: var(--brand-dark);
  color: #fff;
}
.intelli-msg-bub {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary);
  max-width: calc(100% - 38px);
  word-break: break-word;
  overflow-x: auto;
  box-shadow: var(--shadow-xs);
}
.intelli-msg.user .intelli-msg-bub {
  background: var(--brand-dark);
  color: #fff;
  border-color: var(--brand-dark);
  border-radius: 14px 14px 4px 14px;
}
.intelli-msg-bub strong { font-weight: 700; }
.intelli-msg-bub em { font-style: italic; }
.intelli-msg-bub h4, .intelli-msg-bub h5 { font-size: 12px; font-weight: 700; margin: 5px 0 2px; }
.intelli-msg-bub ul, .intelli-msg-bub ol { margin: 4px 0; padding-left: 16px; }
.intelli-msg-bub li { margin-bottom: 2px; }
.intelli-msg-bub code { background: var(--border-light); border-radius: 4px; padding: 1px 4px; font-size: 11px; font-family: monospace; }
.intelli-msg-bub pre { background: var(--border-light); border-radius: 6px; padding: 7px 10px; font-size: 11px; overflow-x: auto; margin: 5px 0; }
.intelli-msg-bub div[style*="overflow-x"] { overflow-x: auto; max-width: 100%; }
.intelli-msg-bub table { border-collapse: collapse; margin: 5px 0; font-size: 11px; min-width: max-content; }
.intelli-msg-bub th, .intelli-msg-bub td { border: 1px solid var(--border); padding: 3px 8px; white-space: nowrap; text-align: right; }
.intelli-msg-bub th:first-child, .intelli-msg-bub td:first-child { text-align: left; }
.intelli-msg-bub th { background: var(--border-light); font-weight: 600; text-align: left; }
.intelli-msg-bub p { margin: 2px 0; }
.intelli-msg-bub p:first-child { margin-top: 0; }
.intelli-msg-bub p:last-child { margin-bottom: 0; }
.intelli-msg-bub a { color: var(--primary); }

.intelli-typing-bub { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.intelli-dot { width: 6px; height: 6px; background: var(--text-hint); border-radius: 50%; animation: idot .9s ease infinite; }
.intelli-dot:nth-child(2) { animation-delay: .15s; }
.intelli-dot:nth-child(3) { animation-delay: .3s; }
@keyframes idot { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

.intelli-chips-row {
  padding: 8px 12px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  border-top: 1px solid var(--border-light);
}
.intelli-chip {
  background: var(--primary-xlight);
  border: 1px solid var(--accent-dim);
  color: var(--primary-darker);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s;
  white-space: nowrap;
}
.intelli-chip:hover { background: var(--primary-light); }

.intelli-input-row {
  padding: 10px 12px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: var(--card-bg);
}
.intelli-inp {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color .15s;
}
.intelli-inp:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(122,212,115,.18); }
.intelli-send-btn {
  width: 36px; height: 36px;
  background: var(--brand-dark);
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.intelli-send-btn:hover:not(:disabled) { background: var(--sidebar-active); transform: scale(1.06); }
.intelli-send-btn:disabled { opacity: .45; cursor: not-allowed; }

/* Botón de micrófono (dictado por voz) */
.intelli-mic-btn {
  width: 36px; height: 36px;
  background: var(--card-bg);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: all .15s;
}
.intelli-mic-btn:hover { border-color: var(--primary); color: var(--primary-darker); }
.intelli-mic-btn.recording {
  background: var(--danger); color: #fff; border-color: var(--danger);
  animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(214,69,61,.45); }
  50%     { box-shadow: 0 0 0 7px rgba(214,69,61,0); }
}

/* Botón de herramientas */
.intelli-tools-btn {
  width: 36px; height: 36px;
  background: var(--card-bg);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: all .15s;
}
.intelli-tools-btn:hover { border-color: var(--primary); color: var(--primary-darker); background: var(--primary-xlight); }

/* Hoja desplegable con todas las herramientas */
.intelli-tools-sheet {
  position: absolute;
  left: 8px; right: 8px; bottom: 60px;
  max-height: 68%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 -8px 30px rgba(0,0,0,.16);
  display: flex; flex-direction: column;
  opacity: 0; transform: translateY(12px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 6;
}
.intelli-tools-sheet.open { opacity: 1; transform: none; pointer-events: auto; }
.intelli-tools-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 6px;
  font-size: 13px; font-weight: 700; color: var(--text-primary);
}
.intelli-tools-x {
  width: 26px; height: 26px; border: none; background: transparent;
  color: var(--text-secondary); cursor: pointer; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.intelli-tools-x:hover { background: var(--bg); color: var(--text-primary); }
.intelli-tools-hint { padding: 0 14px 8px; font-size: 11px; color: var(--text-soft, #6b7280); }
.intelli-tools-hint b { color: var(--primary-darker); }
.intelli-tools-list { overflow-y: auto; padding: 4px 8px 10px; }
.intelli-tools-cat {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--primary-darker); padding: 10px 8px 4px;
}
.intelli-tool-item, .intelli-slash-item {
  width: 100%; display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 8px; border: none; background: transparent;
  border-radius: 9px; cursor: pointer; text-align: left;
}
.intelli-tool-item:hover, .intelli-slash-item:hover, .intelli-slash-item.active { background: var(--primary-light); }
.intelli-tool-cmd {
  flex-shrink: 0; font-size: 11px; font-weight: 700; color: var(--primary-darker);
  background: var(--primary-xlight); border: 1px solid var(--primary-light);
  border-radius: 6px; padding: 2px 6px; margin-top: 1px; font-family: ui-monospace, monospace;
}
.intelli-tool-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.intelli-tool-txt b { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.intelli-tool-txt i {
  font-size: 11px; font-style: normal; color: var(--text-soft, #6b7280);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Dropdown del autocompletado con "/" */
.intelli-slash {
  position: absolute;
  left: 8px; right: 8px; bottom: 60px;
  max-height: 50%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 -8px 24px rgba(0,0,0,.14);
  overflow-y: auto; padding: 6px;
  display: none; z-index: 7;
}
.intelli-slash.open { display: block; }

/* Barra de modo (voz / texto) en el header */
.intelli-modebar {
  display: flex; gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
  flex-shrink: 0;
}
.intelli-mode-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; transition: all .15s;
}
.intelli-mode-btn svg { width: 14px; height: 14px; }
.intelli-mode-btn.active {
  background: var(--brand-dark); color: #fff; border-color: var(--brand-dark);
}
.intelli-mode-btn.active svg { color: var(--accent); }
/* Indicador "hablando" (TTS activo) */
.intelli-speaking { color: var(--primary-darker); }

@media (max-width: 600px) {
  .intelli-panel { width: 100vw; max-width: 100vw; right: 0; bottom: 0; }
  /* El fab vive en el header (position:relative). NO usar offsets bottom/right
     porque empujarían el botón fuera de línea ("volando"). */
  .intelli-fab { right: auto; bottom: auto; top: auto; left: auto; }
}

/* ===========================================================
   Seguimiento de Pagos — Matriz / Cronograma / Timeline
   (compartido entre matriz-pagos.html y prestamos.html)
   =========================================================== */
.matriz-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.view-toggle { display: inline-flex; background: var(--border-light); border-radius: 10px; padding: 3px; gap: 2px; }
.view-toggle button {
  border: none; background: transparent; padding: 6px 14px; border-radius: 8px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 6px; transition: all var(--transition);
}
.view-toggle button.active { background: #fff; color: var(--text-primary); box-shadow: var(--shadow-xs); }
.view-toggle button svg { width: 14px; height: 14px; }

.matriz-legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; font-size: 11px; }
.matriz-legend .lg { display: inline-flex; align-items: center; gap: 5px; color: var(--text-secondary); font-weight: 500; }
.matriz-legend .sw { width: 13px; height: 13px; border-radius: 4px; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.06); }

/* Paleta sólida estilo Excel (como en el control de pagos original del
   cliente) — colores más saturados que un pastel, con el font-color de
   cada clase ajustado para que el texto nunca se pierda sobre el fondo. */
.st-pagado  { background: #92d050; color: #1a3d05; }   /* verde: a tiempo */
.st-hoy     { background: #ffc000; color: #4a3400; }   /* amarillo/dorado: pagó tarde */
.st-futuro  { background: #00b0f0; color: #00263d; }   /* azul: por delante */
.st-m1      { background: #ff8c00; color: #3d1f00; }   /* naranja: mora 1-7d (incluye parciales) */
.st-m2      { background: #ff0000; color: #fff; }      /* rojo: mora 8-90d (incluye parciales) */
.st-perdida { background: #7f1d1d; color: #fff; }      /* rojo oscuro: +90d pérdida (incluye parciales) */
.st-empty   { background: #fff; }

#view-container { width: 100%; }
.matriz-wrapper {
  width: 100%; overflow: auto; max-height: calc(100vh - 280px);
  border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--card-bg);
}
table.matriz { border-collapse: separate; border-spacing: 0; font-size: 11px; white-space: nowrap; width: 100%; min-width: 100%; }
table.matriz th, table.matriz td {
  border-right: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light);
  padding: 4px 7px; text-align: center; height: 34px;
}
table.matriz thead th { position: sticky; top: 0; z-index: 3; background: #1e293b; color: #fff; font-weight: 700; font-size: 10.5px; height: 30px; }
table.matriz .col-cliente {
  position: sticky; left: 0; z-index: 2; background: var(--card-bg);
  text-align: left; font-weight: 600; min-width: 180px; max-width: 180px;
  overflow: hidden; text-overflow: ellipsis; box-shadow: 1px 0 0 var(--border);
}
table.matriz thead .col-cliente { z-index: 4; background: #0f172a; }
table.matriz .col-ejec {
  position: sticky; left: 180px; z-index: 2; background: var(--card-bg);
  min-width: 56px; max-width: 56px; font-weight: 600; box-shadow: 1px 0 0 var(--border);
}
table.matriz thead .col-ejec { z-index: 4; background: #0f172a; }
table.matriz .col-debe {
  position: sticky; left: 236px; z-index: 2; background: var(--card-bg);
  min-width: 92px; max-width: 92px; font-weight: 700; box-shadow: 1px 0 0 var(--border);
  text-align: right; padding-right: 10px;
}
table.matriz thead .col-debe { z-index: 4; background: #0f172a; }
.cell-monto { font-weight: 700; line-height: 1.1; }
.cell-fecha { font-size: 9px; opacity: .75; line-height: 1.1; }
.cell-pago { position: relative; cursor: pointer; }
.cell-pago:hover { outline: 2px solid rgba(22,38,26,0.35); outline-offset: -2px; }
.cell-nota-dot { position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: #24402f; box-shadow: 0 0 0 1.5px #fff; }
/* Puntito de "pago parcial" — la celda ya toma el color de mora normal
   (naranja/rojo/rojo oscuro) según los días; este punto blanco con anillo
   oscuro es lo único que distingue "no pagó nada" de "pagó una parte". */
.cell-parcial-dot { position: absolute; top: 3px; left: 3px; width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1.5px #1e293b; }
.matriz-cliente-name { display: block; overflow: hidden; text-overflow: ellipsis; }
.matriz-cliente-sub  { font-size: 9px; color: var(--text-muted); font-weight: 500; }
.cli-top { display: flex; align-items: center; gap: 4px; }
.cli-top .matriz-cliente-name { flex: 1; }
.btn-irr-matriz { border: none; background: transparent; color: var(--text-hint); font-size: 13px; line-height: 1; padding: 2px 3px; border-radius: 5px; flex-shrink: 0; transition: all var(--transition); }
.btn-irr-matriz:hover { background: var(--danger-light); color: var(--danger); }

.crono-grid { display: flex; flex-direction: column; gap: 12px; }
.crono-week { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-xs); }
.crono-week.is-current { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(47,174,66,0.25); }
.crono-head { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border-light); cursor: pointer; user-select: none; }
.crono-head:hover { background: var(--border-light); }
.crono-date { font-weight: 700; font-size: 13px; }
.crono-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--primary-light); color: var(--primary-darker); }
.crono-badge.cur { background: var(--primary); color: #06340f; }
.crono-stats { margin-left: auto; display: flex; gap: 16px; font-size: 12px; }
.crono-stat b { font-weight: 700; }
.crono-body { padding: 6px 10px 10px; display: none; }
.crono-week.open .crono-body { display: block; }
.crono-chev { transition: transform var(--transition); }
.crono-week.open .crono-chev { transform: rotate(90deg); }
.crono-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; font-size: 12px; }
.crono-row:hover { background: var(--border-light); }
.crono-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.crono-row .nm { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crono-row .ej { color: var(--text-muted); font-size: 11px; min-width: 44px; }
.crono-row .mt { font-weight: 700; min-width: 80px; text-align: right; }
.crono-row .pg { font-size: 10px; color: var(--text-muted); min-width: 54px; text-align: right; }

.tl-head-note { display: flex; align-items: center; gap: 6px; margin: 0 0 8px 226px; font-size: 11px; font-weight: 700; color: var(--text-secondary); }
.tl-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--border-light); color: var(--text-secondary);
  font-size: 10px; font-weight: 800; cursor: help; flex-shrink: 0;
}
.tl-help:hover { background: var(--primary-light); color: var(--primary-darker); }
.tl-list { display: flex; flex-direction: column; gap: 8px; }
.tl-row { display: flex; align-items: center; gap: 12px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px; box-shadow: var(--shadow-xs); }
.tl-info { min-width: 200px; max-width: 200px; }
.tl-name { font-weight: 600; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-sub { font-size: 10px; color: var(--text-muted); }
.tl-track { display: flex; gap: 3px; flex: 1; align-items: center; }
.tl-seg { flex: 1; height: 22px; border-radius: 4px; min-width: 6px; display: flex; align-items: center; justify-content: center; font-size: 8.5px; font-weight: 700; }
.tl-prog { min-width: 86px; text-align: right; font-size: 11px; }
.tl-prog b { font-size: 14px; font-weight: 800; }
.empty-msg { padding: 40px; text-align: center; color: var(--text-muted); }
