/* =====================================================
   Panel Corporativo - Estilos generales
   ===================================================== */
:root {
  --brand-900: #0b2545;
  --brand-800: #10315c;
  --brand-700: #14406e;
  --brand-600: #1a5089;
  --brand-500: #2166a8;
  --accent: #f2a900;
  --accent-dark: #d99400;
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --text-dark: #1c2b3a;
  --text-muted: #64748b;
  --border: #e3e8ee;
  --success: #1f9d55;
  --danger: #d64545;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(16, 49, 92, 0.06);
  --shadow-lg: 0 8px 30px rgba(16, 49, 92, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }

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

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--brand-900), var(--brand-800));
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: transform 0.25s ease, width 0.2s ease, opacity 0.15s ease;
  overflow: hidden;
}

/* Sidebar colapsado en escritorio: se oculta la columna del menú por
   completo (ancho 0) para dejar más espacio al contenido; se vuelve a
   mostrar con el mismo botón de "3 líneas" de la topbar. Preferencia
   persistida en localStorage (ver js/layout.js) para que se mantenga
   colapsado al navegar entre páginas. Solo aplica en escritorio: en
   móvil el mismo botón sigue abriendo/cerrando el menú como overlay
   (ver .sidebar.open más abajo, dentro del media query de 760px). */
@media (min-width: 761px) {
  .sidebar.collapsed {
    width: 0;
    min-width: 0;
    opacity: 0;
    pointer-events: none;
    border: none;
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand .logo-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-900);
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-brand .brand-text { line-height: 1.2; }
.sidebar-brand .brand-text strong { display: block; font-size: 15px; letter-spacing: .3px; }
.sidebar-brand .brand-text span { font-size: 12px; color: rgba(255,255,255,0.65); }

/* ---------- Logo "Pro-cura": la "o" de "Pro" es un anillo tipo gráfico
   circular (dona) con 3 colores. El logo del sidebar/encabezados es
   siempre ESTÁTICO (no gira). El indicador de carga real es el overlay
   centrado (#globalLoadingOverlay, ver más abajo y Api._setLoading en
   js/api.js), cuyo propio logo sí gira mientras hay peticiones en curso. ---------- */
.brand-text-wrap { display: flex; flex-direction: column; gap: 2px; }
.procura-tagline { font-size: 12px; color: rgba(255,255,255,0.65); }
.public-header .procura-wordmark { color: #fff; }
.public-header .procura-tagline { color: rgba(255,255,255,0.8); }

.procura-wordmark {
  display: flex;
  align-items: baseline;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: .2px;
  color: #fff;
  line-height: 1;
}
.procura-wordmark.lg { font-size: 26px; }
.procura-wordmark.xl { font-size: 40px; color: var(--brand-900); }
.pro-o-ring {
  display: inline-block;
  width: 0.62em;
  height: 0.62em;
  margin: 0 0.04em;
  border-radius: 50%;
  flex-shrink: 0;
  transform: translateY(0.09em);
  background: conic-gradient(#132f4c 0deg 245deg, #2aa7c4 245deg 322deg, #f2a900 322deg 360deg);
  -webkit-mask: radial-gradient(circle, transparent 0 56%, #000 58% 100%);
          mask: radial-gradient(circle, transparent 0 56%, #000 58% 100%);
}
@keyframes pro-o-spin { to { transform: translateY(0.09em) rotate(360deg); } }

/* ---------- Overlay de carga centrado en pantalla: solo el círculo de
   3 colores (mismo diseño del logo), sin texto "Pr-cura". ---------- */
.global-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(244, 246, 249, 0.85);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.15s ease;
}
.global-loading-overlay.hidden { display: none; }
.global-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.global-loading-ring {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: conic-gradient(#132f4c 0deg 245deg, #2aa7c4 245deg 322deg, #f2a900 322deg 360deg);
  -webkit-mask: radial-gradient(circle, transparent 0 56%, #000 58% 100%);
          mask: radial-gradient(circle, transparent 0 56%, #000 58% 100%);
}
.global-loading-ring.spinning { animation: pro-o-spin 0.9s linear infinite; }
.global-loading-text { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }

.sidebar-nav .nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,0.4);
  padding: 14px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin: 2px 0;
  border-radius: 10px;
  color: rgba(255,255,255,0.82);
  font-size: 14.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.nav-link i { width: 18px; text-align: center; font-size: 15px; }
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link.active { background: var(--accent); color: var(--brand-900); font-weight: 700; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; color: var(--brand-900); }
.topbar .topbar-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.menu-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  font-size: 16px; color: var(--brand-900); cursor: pointer;
  transition: background .15s ease;
}
.menu-toggle:hover { background: rgba(33,102,168,0.08); }

.content { padding: 26px 28px 60px; flex: 1; }

/* ---------- Cards / KPI ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
}

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.kpi-card .kpi-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 12px;
}

.kpi-card .kpi-label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi-card .kpi-value { font-size: 26px; font-weight: 800; color: var(--brand-900); margin-top: 4px; }
.kpi-card .kpi-delta { font-size: 12.5px; margin-top: 6px; font-weight: 600; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

.icon-blue { background: rgba(33,102,168,0.12); color: var(--brand-600); }
.icon-gold { background: rgba(242,169,0,0.15); color: var(--accent-dark); }
.icon-green { background: rgba(31,157,85,0.12); color: var(--success); }
.icon-red { background: rgba(214,69,69,0.12); color: var(--danger); }

/* ---------- Tarjetas de saldo por banco (Dashboard Panel de
   Transferencias): borde superior con el color de marca de cada banco
   girador, para diferenciarlas a simple vista de los demás KPIs. ---------- */
.saldo-card { border-top: 4px solid transparent; }
.saldo-amerant { border-top-color: #E35205; }
.saldo-banesco { border-top-color: #556B2F; }
.saldo-total { border-top-color: var(--brand-700); }

.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; margin-bottom: 22px; }
.charts-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.charts-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; }

.card h2, .card h3 { margin: 0 0 4px; font-size: 16px; color: var(--brand-900); font-weight: 700; }
.card .card-sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
.chart-box { position: relative; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 9px; border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--brand-700); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-accent { background: var(--accent); color: var(--brand-900); }
.btn-accent:hover { background: var(--accent-dark); }
.btn-outline { background: #fff; color: var(--brand-700); border: 1px solid var(--border); }
.btn-outline:hover { background: #f0f3f7; }
.btn-danger { background: rgba(214,69,69,0.1); color: var(--danger); }
.btn-danger:hover { background: rgba(214,69,69,0.18); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.field input, .field select, .field textarea { width: 100%; min-width: 0; }

input[type="text"], input[type="number"], input[type="date"], input[type="search"], input[type="email"],
select, textarea {
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text-dark);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(33,102,168,0.12);
}

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }
table.data-table td:last-child, table.data-table th:last-child { white-space: nowrap; }
table.data-table th {
  background: #f0f3f8; text-align: left; padding: 11px 12px;
  font-weight: 700; color: var(--brand-800); white-space: nowrap; position: sticky; top: 0;
}
table.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr:hover { background: #f7f9fc; }
table.data-table tfoot td { position: sticky; bottom: 0; background: #f0f3f8; border-top: 2px solid var(--border); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge-amerant { background: rgba(227,82,5,0.14); color: #E35205; }
.badge-banesco { background: rgba(85,107,47,0.16); color: #556B2F; }
.badge-ok { background: rgba(31,157,85,0.12); color: var(--success); }
.badge-warn { background: rgba(214,69,69,0.12); color: var(--danger); }

/* ---------- Upload área ---------- */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 34px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s; background: #fafcfe;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--brand-500); background: #eef4fb; }
.upload-zone i { font-size: 34px; color: var(--brand-500); margin-bottom: 10px; }
.upload-zone p { margin: 4px 0; color: var(--text-muted); font-size: 13.5px; }

.bank-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.bank-option {
  border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer;
  display: flex; align-items: center; gap: 12px; transition: border-color .15s, background .15s; background: #fff;
}
.bank-option.selected { border-color: var(--brand-600); background: #eef4fb; }
.bank-option .bank-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; color: #fff;
}
.bank-amerant-icon { background: #E35205; }
.bank-banesco-icon { background: #556B2F; }
.bank-option strong { display: block; font-size: 14.5px; color: var(--brand-900); }
.bank-option span { font-size: 12px; color: var(--text-muted); }

/* ---------- Utilidades ---------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8{margin-top:8px;} .mt-12{margin-top:12px;} .mt-16{margin-top:16px;} .mt-20{margin-top:20px;} .mt-24{margin-top:24px;}
.mb-8{margin-bottom:8px;} .mb-12{margin-bottom:12px;} .mb-16{margin-bottom:16px;} .mb-20{margin-bottom:20px;}
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.hidden { display: none !important; }

.pill-tabs { display: flex; gap: 8px; background: #eef1f6; border-radius: 10px; padding: 4px; width: fit-content; }
.pill-tab { padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.pill-tab.active { background: #fff; color: var(--brand-800); box-shadow: var(--shadow); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; color: var(--border); }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--brand-900); color: #fff; padding: 14px 20px; border-radius: 10px;
  box-shadow: var(--shadow-lg); font-size: 14px; z-index: 999;
  display: flex; align-items: center; gap: 10px;
  transform: translateY(20px); opacity: 0; transition: all .25s ease; max-width: 360px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 14px; }
.pagination button {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--brand-800);
}
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination span { font-size: 13px; color: var(--text-muted); padding: 0 6px; }

.progress-bar { height: 8px; background: var(--border); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.progress-bar > div { height: 100%; background: var(--brand-600); width: 0%; transition: width .2s; }

.checkbox-cell { width: 34px; text-align: center; }

.access-lock {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-900), var(--brand-700));
  color: #fff; text-align: center; padding: 30px;
}

.overlay-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 35; display: none; }
.overlay-bg.show { display: block; }

/* ---------- Documento de Cotización (formato imprimible/PDF) ----------
   Reproduce la ESTRUCTURA del PDF de referencia del usuario (empresa
   emisora, bloque de datos del cliente, tabla de ítems, totales) con
   los colores/tipografía propios de la marca Pro-cura. Se usa tanto en
   la vista previa del editor (cotizacion_editor.html) como en la vista
   pública que ve el cliente para aprobar (ver_cotizacion.html). */
.quote-doc {
  background: #fff; padding: 30px; max-width: 900px; margin: 0 auto;
  font-size: 13px; color: var(--text-dark); border-radius: var(--radius);
}
.quote-doc-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 3px solid var(--brand-700); padding-bottom: 16px; margin-bottom: 18px; gap: 16px;
}
.quote-doc-header .empresa strong { font-size: 15.5px; color: var(--brand-900); display: block; margin-bottom: 3px; }
.quote-doc-header .empresa div { font-size: 12px; color: var(--text-muted); }
.quote-doc-header .cot-no { text-align: right; flex-shrink: 0; }
.quote-doc-header .cot-no .label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.quote-doc-header .cot-no .num { font-size: 30px; font-weight: 800; color: var(--brand-700); line-height: 1.15; }

.quote-doc-client {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px 20px;
  background: #f7f9fc; border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 20px; margin-bottom: 18px;
}
.quote-doc-client .qf label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; margin-bottom: 2px; }
.quote-doc-client .qf div.qv { font-size: 13.5px; font-weight: 600; color: var(--text-dark); word-break: break-word; }

table.quote-items { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 16px; min-width: 720px; }
table.quote-items th {
  background: var(--brand-800); color: #fff; padding: 9px 10px; text-align: left;
  font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
}
table.quote-items td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.quote-items tbody tr:nth-child(even) { background: #f7f9fc; }

.quote-doc-totals { display: flex; justify-content: flex-end; }
.quote-doc-totals table { min-width: 280px; border-collapse: collapse; }
.quote-doc-totals td { padding: 6px 10px; font-size: 13.5px; }
.quote-doc-totals td:first-child { color: var(--text-muted); text-align: right; }
.quote-doc-totals td:last-child { text-align: right; font-weight: 700; min-width: 110px; }
.quote-doc-totals tr.total-row td { font-size: 17px; font-weight: 800; color: var(--brand-900); border-top: 2px solid var(--brand-700); padding-top: 12px; }

.quote-doc-footer { margin-top: 26px; font-size: 11.5px; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 14px; }

/* Instrucciones de giro a Colombia + Términos de la venta: mismo formato
   del documento de referencia del cliente (recuadros con borde), fijos
   al pie de toda cotización. */
.quote-doc-bank-info, .quote-doc-terms {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 16px; margin-top: 16px; font-size: 12px; color: var(--text-dark);
}
.quote-doc-bank-info strong, .quote-doc-terms strong {
  display: block; margin-bottom: 8px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em;
}
.quote-doc-bank-info div { line-height: 1.7; }
.quote-doc-terms ol { margin: 0; padding-left: 20px; }
.quote-doc-terms li { line-height: 1.7; }

/* Fila editable de ítems dentro del editor (inputs compactos dentro de la tabla) */
table.items-edit-table input, table.items-edit-table select { padding: 6px 8px; font-size: 12.5px; }
table.items-edit-table td { padding: 6px; }
table.items-edit-table th { white-space: nowrap; }
.item-total-cell { font-weight: 700; white-space: nowrap; }

/* ---------- Panel Administrativo: tabla resumen de aliados ----------
   Réplica del tablero de referencia del usuario (columnas Aliados, Cupo
   Crédito, Cuentas por Cobrar con ícono de estado, Días Calle, Equivalencia
   x Cobrar/Ventas con barra y Ventas en 2026), con encabezados ordenables
   al hacer clic (igual que las flechas de filtro/orden de la imagen). */
table.data-table th.sortable { cursor: pointer; user-select: none; }
table.data-table th.sortable:hover { background: #e6ebf3; }
table.data-table th.sortable .sort-arrow { margin-left: 5px; font-size: 10px; opacity: .55; }
table.data-table th.sortable.sort-active .sort-arrow { opacity: 1; color: var(--accent-dark); }

/* ---------- Listado de aliados: filas más delgadas ----------
   El usuario reportó que la tabla se veía "gruesa" (demasiado alta por
   fila). Se reduce el padding vertical y se aligera la línea separadora
   SOLO en #aliadosTable, sin tocar table.data-table en general (eso
   afectaría todas las demás tablas del sitio: cotizaciones, informes,
   panel administrativo, cobranza semanal, etc.). */
#aliadosTable td { padding: 6px 12px; border-bottom: 1px solid #edf1f6; }
#aliadosTable th { padding: 8px 12px; }

.status-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; color: #fff; font-size: 10px; margin-right: 6px; flex-shrink: 0;
}
.status-dot.ok { background: var(--success); }
.status-dot.warn { background: var(--danger); }

.eq-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.eq-pct { font-weight: 700; font-size: 12.5px; min-width: 34px; text-align: right; }
.eq-bar-track { width: 70px; height: 8px; border-radius: 6px; background: #eef1f6; overflow: hidden; flex-shrink: 0; }
.eq-bar-fill { height: 100%; border-radius: 6px; }
.eq-bar-fill.cobrar { background: linear-gradient(90deg, #c7ccd6, #8a92a3); }
.eq-bar-fill.ventas { background: linear-gradient(90deg, #6ea8d8, #1a5089); }

/* ---------- Switch (interruptor) reutilizable ----------
   Usado en Aliados para activar/desactivar la opción de Financiamiento
   Personal por aliado, sin necesitar botones extra en la tabla. */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background-color: #cbd3df; transition: .2s; border-radius: 999px;
}
.switch .slider::before {
  position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background-color: #fff; transition: .2s; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch input:checked + .slider { background-color: var(--success); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:disabled + .slider { opacity: .6; cursor: not-allowed; }

/* Variante pequeña del switch (ej. columna "Fin. personal" en Aliados) */
.switch.switch-sm { width: 32px; height: 18px; }
.switch.switch-sm .slider::before { height: 12px; width: 12px; left: 3px; bottom: 3px; }
.switch.switch-sm input:checked + .slider::before { transform: translateX(14px); }

/* ---------- Selector Cava / Bolsa (Solicitudes de Pedido) ----------
   Botones tipo "toggle" para elegir el método de envío de la semana
   antes de generar/enviar el enlace del portal a un aliado. */
.btn-modo { opacity: .6; }
.btn-modo.active { opacity: 1; background: var(--brand-600); color: #fff; border-color: var(--brand-600); }

/* ---------- Sugerencia de Ofertas y Combos (detalle de Solicitud) ----------
   Aviso que aparece cuando el aliado pidió cantidades desbalanceadas
   de un combo activo (ej. pidió 60 Prevenar y solo 20 Rotateq, y el
   combo es fijo 60+60): sugiere completar la cantidad que falta. */
.combo-suggestion {
  display: flex; align-items: flex-start; gap: 10px;
  background: rgba(242,169,0,0.12); border: 1px solid rgba(242,169,0,0.35);
  border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 8px;
}
.combo-suggestion i { color: var(--accent-dark); margin-top: 2px; }
.combo-suggestion strong { color: var(--brand-900); }

/* ---------- Cobranza Semanal: tabla estilo reporte semanal (mismo
   patrón de colores de la hoja de referencia que compartió el usuario:
   encabezados en azul marino en cursiva, PENDIENTE en color acento/durazno
   para destacarlo, igual que la hoja de Excel original). La columna
   "Cuota de Financiamiento" del Excel se omitió a petición explícita del
   usuario. ---------- */
.cobranza-table thead th {
  background: var(--brand-900); color: #fff; font-style: italic;
}
.cobranza-table thead th.col-pendiente { background: var(--accent); color: var(--brand-900); }
.cobranza-table tfoot td { background: #f0f3f8; font-weight: 700; }
.cobranza-proyectado-input {
  width: 120px; padding: 6px 8px; font-size: 13px; text-align: right;
  border: 1px solid var(--border); border-radius: 6px; font-family: inherit;
}
.cobranza-proyectado-input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(33,102,168,0.12); }
/* Breve destello verde al guardar el Proyectado de una fila (feedback visual sin modal/toast intrusivo). */
.cobranza-saved-flash { animation: cobranzaSavedFlash 0.65s ease; }
@keyframes cobranzaSavedFlash { 0% { background: rgba(31,157,85,0.28); } 100% { background: transparent; } }

/* ---------- Barra de progreso GLOBAL de la semana (Pagado vs. Proyectado) ----------
   Se muestra debajo de las tarjetas KPI, como resumen ejecutivo del avance
   de cobranza de toda la semana actual. */
.cobranza-progress-card { padding: 18px 20px; }
.cobranza-progress-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 10px; flex-wrap: wrap; gap: 6px;
}
.cobranza-progress-head strong { font-size: 14px; color: var(--brand-900); }
.cobranza-progress-head span { font-size: 13px; color: var(--text-muted); }
.cobranza-progress-track {
  position: relative; width: 100%; height: 16px; border-radius: 999px;
  background: #eef1f6; overflow: hidden;
}
.cobranza-progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-600), var(--success));
  transition: width .4s ease;
}
.cobranza-progress-marker {
  position: absolute; top: -4px; width: 2px; height: 24px;
  background: var(--accent-dark); opacity: .85;
}
.cobranza-progress-foot {
  display: flex; justify-content: space-between; margin-top: 6px;
  font-size: 11.5px; color: var(--text-muted);
}

/* ---------- Semáforo de avance por aliado ----------
   Compara el % ya cobrado contra el % de la semana ya transcurrida (ritmo
   esperado), NO contra un plazo fijo — así el primer día de la semana
   (miércoles) nunca se marca en rojo, sin importar cuánto se haya cobrado
   todavía, porque recién empieza el plazo para cobrar. */
.cobranza-estado-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  white-space: nowrap;
}
.cobranza-estado-badge i { font-size: 8px; }
.cobranza-estado-badge.estado-azul { background: rgba(33,102,168,0.12); color: var(--brand-600); }
.cobranza-estado-badge.estado-verde { background: rgba(31,157,85,0.14); color: var(--success); }
.cobranza-estado-badge.estado-amarillo { background: rgba(242,169,0,0.16); color: var(--accent-dark); }
.cobranza-estado-badge.estado-rojo { background: rgba(214,69,69,0.14); color: var(--danger); }
.cobranza-estado-badge.estado-gris { background: #eef1f6; color: var(--text-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid, .charts-grid-2, .charts-grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .bank-pick { grid-template-columns: 1fr; }
  .quote-doc-client { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .quote-doc-header { flex-direction: column; }
  .quote-doc-header .cot-no { text-align: left; }
  .quote-doc-client { grid-template-columns: 1fr; }
  .quote-doc { padding: 18px; }
}

@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); height: 100vh; width: 260px; opacity: 1; pointer-events: auto; }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 18px 16px 60px; }
  .topbar { padding: 14px 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .kpi-grid, .form-grid { grid-template-columns: 1fr; }
}

/* =====================================================
   Luci — Asistente flotante (basado en reglas, sin IA externa)
   ===================================================== */
.luci-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 200;
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #1a1200; border: none; border-radius: 999px;
  padding: 13px 18px; font-family: 'Inter', sans-serif; font-weight: 700; font-size: 14px;
  box-shadow: 0 8px 24px rgba(217,148,0,0.4);
  cursor: pointer; transition: transform .15s ease, box-shadow .15s ease;
}
.luci-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(217,148,0,0.5); }
.luci-fab i { font-size: 18px; }
.luci-fab .luci-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px rgba(255,255,255,0.6); flex-shrink: 0; }
.luci-fab.luci-fab-active { background: linear-gradient(135deg, var(--brand-700), var(--brand-900)); color: #fff; }
.luci-fab-label { line-height: 1; }
@media (max-width: 560px) {
  .luci-fab { right: 14px; bottom: 14px; padding: 12px 14px; }
  .luci-fab-label { display: none; }
}

.luci-panel {
  position: fixed; right: 22px; bottom: 90px; z-index: 201;
  width: min(380px, calc(100vw - 28px)); height: min(560px, calc(100vh - 130px));
  background: var(--card-bg); border-radius: 16px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--border);
}
.luci-panel.hidden { display: none; }
@media (max-width: 560px) {
  .luci-panel { right: 10px; left: 10px; width: auto; bottom: 78px; height: min(70vh, 520px); }
}

.luci-header {
  background: linear-gradient(135deg, var(--brand-900), var(--brand-700));
  color: #fff; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.luci-header-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.luci-header-title i { color: var(--accent); }
.luci-avatar-header { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.luci-sub { font-weight: 400; font-size: 11px; opacity: .75; margin-left: 4px; }
.luci-close { background: transparent; border: none; color: #fff; opacity: .8; cursor: pointer; font-size: 15px; padding: 4px; }
.luci-close:hover { opacity: 1; }

.luci-messages {
  flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px;
  background: var(--bg);
}
.luci-msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.luci-msg-row-bot { align-self: flex-start; }
.luci-msg-row-user { align-self: flex-end; }
.luci-avatar-msg { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; margin-bottom: 2px; }
.luci-msg { max-width: 88%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; }
.luci-msg-bot { align-self: flex-start; background: #fff; border: 1px solid var(--border); color: var(--text-dark); border-bottom-left-radius: 4px; }
.luci-msg-user { align-self: flex-end; background: var(--brand-600); color: #fff; border-bottom-right-radius: 4px; }
.luci-msg strong { color: var(--brand-800); }
.luci-msg-user strong { color: #fff; }
.luci-note { color: var(--text-muted); font-size: 12px; }

/* Etiqueta que marca una respuesta generada por IA (Gemini vía Worker),
   para diferenciarla claramente de las respuestas calculadas con datos
   reales de Pro-cura — ver intentIA() en js/luci.js. */
.luci-ia-badge {
  display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--accent-dark);
}
.luci-ia-badge i { font-size: 12px; }

/* Contenido de respuestas de IA renderizado desde Markdown (ver
   renderMarkdownLite() en js/luci.js) — tablas, títulos y listas dentro
   del panel angosto de Luci, con tipografía compacta para que quepan. */
.luci-ia-content { font-size: 13px; }
.luci-ia-content .luci-ia-p { margin: 0 0 8px; }
.luci-ia-content .luci-ia-heading { margin: 10px 0 6px; font-size: 14px; color: var(--brand-800); }
.luci-ia-content .luci-ia-list { margin: 0 0 8px; padding-left: 18px; }
.luci-ia-content .luci-ia-list li { margin-bottom: 4px; }
.luci-ia-content .table-wrap { margin: 8px 0; max-width: 100%; }
.luci-ia-table { font-size: 11.5px; min-width: 0; width: 100%; }
.luci-ia-table th, .luci-ia-table td { padding: 6px 8px; white-space: normal; }
.luci-ia-table th { position: static; }

.luci-typing { display: flex; gap: 4px; padding: 12px 14px; }
.luci-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: luciBlink 1.2s infinite ease-in-out; }
.luci-typing span:nth-child(2) { animation-delay: .2s; }
.luci-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes luciBlink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.luci-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; flex-shrink: 0; }
.luci-chip {
  background: rgba(20,64,110,0.08); border: 1px solid var(--border); color: var(--brand-700);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer; font-family: 'Inter', sans-serif;
}
.luci-chip:hover { background: rgba(20,64,110,0.15); }

.luci-input-row {
  display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); flex-shrink: 0; background: #fff;
}
.luci-input-row input {
  flex: 1; border: 1px solid var(--border); border-radius: 999px; padding: 10px 16px;
  font-family: 'Inter', sans-serif; font-size: 13.5px; outline: none;
}
.luci-input-row input:focus { border-color: var(--brand-600); }
.luci-input-row button {
  width: 40px; height: 40px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--brand-700); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.luci-input-row button:hover { background: var(--brand-800); }
