/* ============================================================
   Dashboard Financiero CRM — Versión 2026
   Estilos Consolidados (Extraídos de DASHBOARD INTERNO/index.html)
   ============================================================ */

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

/* ── VARIABLES DE TEMA (OSCURO POR DEFECTO) ── */
:root {
  --bg: #0d0f14;
  --surface: #161920;
  --surface2: #1e2230;
  --border: #2a2f42;
  --accent: #4f8ef7;
  --accent2: #22d3a5;
  --warn: #f59e3f;
  --danger: #f06060;
  --text: #e8eaf0;
  --text2: #8b91a8;
  --text3: #545c74;
  --green: #22d3a5;
  --red: #f06060;
  --gold: #f59e3f;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* ── VARIABLES TEMA CLARO ── */
body.theme-light {
  --bg: #f0f2f8;
  --surface: #ffffff;
  --surface2: #e8ecf4;
  --border: #c8d0e4;
  --accent: #2563eb;
  --accent2: #059669;
  --text: #1a1f36;
  --text2: #4b5675;
  --text3: #94a3b8;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
}

/* ── RESET GLOBAL ── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ── TOP BAR ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text2);
  font-family: 'DM Mono', monospace;
}

.topbar-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  padding: 3px;
  border-radius: 8px;
}

.tab {
  padding: 6px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text2);
  border: none;
  background: none;
  transition: all .2s;
}

.tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 142, 247, 0.4);
}

.tab:hover:not(.active) {
  color: var(--text);
  background: var(--surface);
}

/* ── CONTROLS ── */
select,
.icon-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: all .2s;
}

/* Estilo Minimalista para Selectores */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg stroke='%238b91a8' fill='none' viewBox='0 0 24 24' height='16' width='16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.icon-btn:hover,
select:hover {
  border-color: var(--accent);
}

.sel-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

label.sel-label {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}

/* ── MAIN ── */
.main {
  padding: 24px 28px;
}

.section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── KPIs ── */
.kpi-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-card {
  flex: 1 1 220px;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-color, var(--accent));
  transition: height 0.2s;
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.kpi-card:hover::before {
  height: 4px;
}

.kpi-label {
  font-size: 11px;
  color: var(--text2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
  overflow: visible;
}

/* ── CHARTS ── */
.chart-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 24px;
  width: 100%;
  min-width: 0;
}

.chart-grid-2 {
  grid-template-columns: 1fr 1fr;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform 0.2s;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.chart-card:hover {
  box-shadow: var(--shadow);
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.chart-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

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

.chart-wrap {
  position: relative;
  height: 300px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

/* ── TABLES ── */
.matrix-table {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
}

.matrix-table th,
.matrix-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.matrix-table th {
  background: var(--surface2);
  color: var(--text2);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
}

.matrix-table td.label {
  text-align: left;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
}

.matrix-table td {
  font-family: 'DM Mono', monospace;
}

.pos {
  color: var(--green);
}

.neg {
  color: var(--red);
}

/* ── FILAS DE MATRICES JERÁRQUICAS ── */
.row-l1 {
  font-weight: 700;
  background: var(--surface2);
  cursor: pointer;
  transition: background 0.2s;
}

.row-l1:hover {
  filter: brightness(1.1);
}

.row-l2 {
  font-weight: 600;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.02);
}

.row-l3 {
  color: var(--text2);
  font-family: 'DM Mono', monospace;
}

/* ── LOADER ── */
#loader {
  position: fixed;
  inset: 0;
  background: rgba(13, 15, 20, 0.8);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--accent);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

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

/* ── DROPDOWN GRÁFICOS ── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  background-color: var(--surface);
  border: 1px solid var(--border);
  min-width: 250px;
  box-shadow: var(--shadow);
  z-index: 200;
  border-radius: 8px;
  padding: 10px;
  margin-top: 5px;
}

.dropdown-group-title {
  font-size: 11px;
  color: var(--text2);
  font-weight: 700;
  text-transform: uppercase;
  margin: 12px 4px 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.dropdown-group-title:first-child {
  margin-top: 4px;
}

.dropdown-content label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}

.dropdown-content label:hover {
  background-color: var(--surface2);
  border-radius: 4px;
}

.dropdown-content input {
  cursor: pointer;
}

.dropdown.open .dropdown-content {
  display: block;
}

/* ── MODALS Y OVERLAY ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 15, 20, 0.85);
  z-index: 500;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 800px;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  position: relative;
}

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

/* ── QUICK VIEW LANE (PINNED AREA) ── */
.quick-view-lane {
  display: flex;
  gap: 16px;
  padding: 0 28px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  min-height: 0;
  transition: min-height 0.3s, padding 0.3s;
}

.quick-view-lane.has-pins {
  min-height: 220px;
  padding: 16px 28px;
}

.pinned-chart-card {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 8px;
  width: 350px;
  min-width: 350px;
  padding: 12px;
  position: relative;
  box-shadow: var(--shadow);
}

.pinned-chart-card canvas {
  height: 150px !important;
}

.unpin-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── SWITCH UI (toggle general) ── */
.switch-ui {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
}

.switch-ui input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-ui {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  transition: .4s;
  border-radius: 34px;
}

.slider-ui:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider-ui {
  background-color: var(--accent);
}

input:checked + .slider-ui:before {
  transform: translateX(16px);
}

/* ── SWITCH DE MODO PyG (Mes/Acumulado) ── */
#swMatrizPygModo:checked + #sliderPyg {
  background-color: var(--accent);
}

#swMatrizPygModo:checked + #sliderPyg:before {
  transform: translateX(14px);
}

#sliderPyg:before {
  position: absolute;
  content: "";
  height: 10px;
  width: 10px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

/* ── SWITCH VENTAS (toggle Pareto — conservado por compatibilidad) ── */
.switch-ventas {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 18px;
}

.switch-ventas input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-ventas {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  transition: .4s;
  border-radius: 20px;
}

.slider-ventas:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider-ventas {
  background-color: var(--accent2);
}

input:checked + .slider-ventas:before {
  transform: translateX(18px);
}

/* ── FULLSCREEN CHARTS ── */
.chart-card:fullscreen {
  background: var(--bg);
  padding: 40px;
  overflow-y: auto;
}

.chart-card:-webkit-full-screen {
  background: var(--bg);
  padding: 40px;
  overflow-y: auto;
}

.chart-card:fullscreen .chart-wrap {
  height: calc(100vh - 120px) !important;
}

.chart-card:-webkit-full-screen .chart-wrap {
  height: calc(100vh - 120px) !important;
}

/* ── TOOLTIP FLOTANTE CXC/CXP ── */
#ai-tooltip-cartera {
  position: absolute;
  display: none;
  background: #ffffff;
  border: 1px solid #8b5cf6;
  padding: 12px;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 10000;
  pointer-events: none;
  color: #1e293b;
  min-width: 250px;
  font-family: 'DM Sans', sans-serif;
}

/* ── INDICADORES — CATEGORÍAS Y CARDS PREMIUM ── */
.ind-category-section {
  background: rgba(0, 0, 0, 0.02);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.ind-category-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
  letter-spacing: 0.5px;
}

.ind-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.premium-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s;
}

.premium-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
  border-color: var(--text3);
}

.premium-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.premium-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.premium-context {
  font-size: 10px;
  color: var(--text2);
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  font-weight: 600;
}

.premium-main-val {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.premium-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.premium-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.premium-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.premium-year-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
  flex: 1;
}

.premium-year-lbl {
  color: var(--text2);
  font-size: 10px;
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

/* ── MENÚ DE FILTROS DE INDICADORES ── */
#catFilterMenu.active {
  display: block !important;
}

.filter-cb-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: color 0.2s;
}

.filter-cb-label:hover {
  color: var(--accent);
}

/* ── SCROLL PERSONALIZADO ── */
.custom-scroll::-webkit-scrollbar {
  width: 6px;
}

.custom-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.custom-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text3);
}

/* ============================================================
   ESTILOS PARA PARETO E INTERACTIVIDAD DE VENTAS
   ============================================================ */

.pareto-row {
  background: rgba(34, 211, 165, 0.05);
}

.pareto-label {
  color: var(--accent2);
  font-weight: bold;
}

.item-segmentador {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s;
  font-size: 0.8rem;
  color: var(--text2);
  border: 1px solid transparent;
  margin-bottom: 4px;
}

.item-segmentador:hover {
  background: var(--border);
  color: var(--text);
}

.item-segmentador.active {
  background: rgba(79, 142, 247, 0.15);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: bold;
}

/* ESTILOS PARA PANTALLA COMPLETA */
#contenedor-ventas-maestro.fullscreen-ventas,
#wrap_matriz_pareto.fullscreen-ventas {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 99999 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  background: var(--bg) !important;
  padding: 20px !important;
  box-sizing: border-box !important;
}

/* Cuando está en pantalla completa, la altura de las tablas ocupa todo el espacio sobrante */
#contenedor-ventas-maestro.fullscreen-ventas .matriz-scroll-area,
#wrap_matriz_pareto.fullscreen-ventas .matriz-scroll-area {
  max-height: calc(100vh - 130px) !important;
}

#btn-fullscreen-ventas:hover {
  filter: brightness(1.2);
}

