/* ============================================================
   Indicadores Comerciales C.I. J Y J - Estilos (v1.5)
   ============================================================ */

/* ===== Variables de tema ===== */
:root {
  --bg-page: #f4f5f7;
  --bg-surface: #ffffff;
  --bg-soft: #f1f2f4;
  --bg-info: #e6f1fb;
  --color-text: #1f2329;
  --color-text-secondary: #5f6266;
  --color-text-tertiary: #8a8d92;
  --color-text-info: #185fa5;
  --color-border: rgba(15, 17, 19, 0.12);
  --color-border-strong: rgba(15, 17, 19, 0.2);
  --color-primary: #1f2329;
  --color-primary-fg: #ffffff;
  --color-error: #a32d2d;
  --color-error-bg: #fceaea;
  --color-success: #0f6e56;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 17, 19, 0.04);
}

[data-theme="dark"] {
  --bg-page: #0f1419;
  --bg-surface: #1a1f26;
  --bg-soft: #232932;
  --bg-info: #1e3a5f;
  --color-text: #e8eaed;
  --color-text-secondary: #b1b5ba;
  --color-text-tertiary: #7e848b;
  --color-text-info: #8fc1f5;
  --color-border: rgba(255, 255, 255, 0.10);
  --color-border-strong: rgba(255, 255, 255, 0.20);
  --color-primary: #4a90e2;
  --color-primary-fg: #ffffff;
  --color-error: #ff6b6b;
  --color-error-bg: #3a1d1d;
  --color-success: #5dcaa5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ===== Reset basico ===== */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-page);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
input, select, button, textarea { font-family: inherit; font-size: 14px; }

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

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

.content {
  padding: 24px 32px;
  flex: 1;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
}

.sidebar-brand {
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.sidebar-brand img {
  max-width: 64px;
  max-height: 64px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.logo-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
  font-size: 11px;
  color: var(--color-text-tertiary);
  font-weight: 500;
}

.brand-title {
  font-size: 12px;
  font-weight: 500;
  margin: 0;
  color: var(--color-text);
  line-height: 1.3;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar-footer {
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}

.user-info {
  font-size: 12px;
  color: var(--color-text);
  margin: 0 0 4px;
  padding: 0 12px;
}

.logout-link {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.logout-link:hover { color: var(--color-text); }

/* Items de navegacion */
.nav-item {
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--color-text-secondary);
  transition: background 120ms ease, color 120ms ease;
}

.nav-item:hover {
  background: var(--bg-soft);
  color: var(--color-text);
}

.nav-item.active {
  background: var(--bg-info);
  color: var(--color-text-info);
  font-weight: 500;
}

.nav-section-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-tertiary);
  padding: 14px 12px 6px;
  margin-top: 8px;
  border-top: 1px solid var(--color-border);
  font-weight: 500;
}

.nav-subitem {
  padding-left: 22px;
  font-size: 13px;
}

/* Grupo desplegable (Dashboards) */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.nav-toggle .nav-chevron {
  display: inline-block;
  font-size: 10px;
  margin-left: 8px;
  transition: transform 150ms ease;
  color: var(--color-text-tertiary);
}

.nav-toggle.open .nav-chevron {
  transform: rotate(90deg);
}

.nav-submenu {
  display: none;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
}

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--color-border);
}

.topbar-title {
  font-size: 14px;
  font-weight: 500;
  margin: 0;
  color: var(--color-text);
}

.topbar-date {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin: 0;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 120ms ease, color 120ms ease;
}

.theme-toggle:hover {
  background: var(--bg-soft);
  color: var(--color-text);
}

.theme-toggle-icon {
  font-size: 16px;
  line-height: 1;
}

/* ===== Titulos de pagina ===== */
.page-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--color-text);
}

.page-subtitle {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin: 0 0 16px;
}

/* ===== Botones ===== */
.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-fg);
  border: none;
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 120ms ease, transform 120ms ease;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.99); }

.link-action {
  font-size: 13px;
  color: var(--color-text-info);
  text-decoration: underline;
  cursor: pointer;
  padding: 0 4px;
}

.link-action:hover {
  opacity: 0.85;
}

/* ===== Barra de filtros / acciones ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 0;
  margin-bottom: 8px;
}

.filter-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.filter-bar input[type="text"],
.filter-bar select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--color-text);
  font-size: 13px;
}

.filter-bar input[type="text"]:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--color-text-info);
}

.save-btn {
  margin-left: auto;
}

.save-status {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-left: 8px;
  font-style: italic;
}

.save-status.ok { color: var(--color-success); font-style: normal; }
.save-status.err { color: var(--color-error); font-style: normal; }

/* ===== Alertas ===== */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin: 10px 0;
  border: 1px solid transparent;
}

.alert-info {
  background: var(--bg-info);
  color: var(--color-text-info);
  border-color: rgba(24, 95, 165, 0.2);
}

.alert-error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: rgba(163, 45, 45, 0.2);
}

/* ===== Hints y placeholders ===== */
.hint {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin: 8px 0 0;
}

.placeholder-card {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  background: var(--bg-soft);
  margin-top: 16px;
}

.placeholder-title { font-weight: 600; margin: 0 0 8px; }
.placeholder-text { color: var(--color-text-secondary); margin: 0 0 8px; }
.placeholder-list { margin: 0; padding-left: 20px; color: var(--color-text-secondary); }

.version-tag {
  font-size: 11px;
  color: var(--color-text-tertiary);
  margin-top: 24px;
}

.tag-huerfana {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #FFEBEE;
  color: #B71C1C;
  font-size: 11px;
  margin-left: 6px;
}

.tag-inactivo {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  background: #ECEFF1;
  color: #607D8B;
  font-size: 11px;
  font-weight: 500;
}

[data-theme="dark"] .tag-inactivo {
  background: #2a3038;
  color: #8a9ba8;
}

/* ===== Contenedor de tabla con scroll horizontal ===== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  margin-top: 10px;
}

/* ===== Cards de metricas (Home y secciones) ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 16px 0 24px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.metric-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0 0 6px;
  font-weight: 500;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.metric-hint {
  font-size: 11px;
  color: var(--color-text-tertiary);
  margin: 4px 0 0;
}

/* ===== Login ===== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-page);
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 12px rgba(15, 17, 19, 0.08);
}

[data-theme="dark"] .login-card {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  max-width: 80px;
  max-height: 80px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.login-logo-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 12px;
  color: var(--color-text-tertiary);
  font-weight: 500;
}

.login-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.login-subtitle {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin: 4px 0 0;
}

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

.login-form input {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: var(--bg-surface);
  color: var(--color-text);
}

.login-form input:focus {
  outline: none;
  border-color: var(--color-text-info);
}

.login-form button {
  background: var(--color-primary);
  color: var(--color-primary-fg);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 4px;
}

.login-foot {
  font-size: 12px;
  color: var(--color-text-tertiary);
  text-align: center;
  margin-top: 16px;
}

/* ===== Tabla generica de Presupuestos ===== */
.budget-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.budget-table th,
.budget-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
}

.budget-table thead th {
  background: var(--bg-soft);
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-align: center;
}

.budget-table .col-linea {
  width: 220px;
  text-align: left;
  font-weight: 500;
  background: var(--bg-soft);
}

.budget-table .col-mes {
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 90px;
}

.budget-table th.col-mes-actual {
  background: var(--bg-info);
  color: var(--color-text-info);
}

.budget-table td.col-mes-actual {
  background: rgba(24, 95, 165, 0.06);
}

.budget-table .col-total {
  text-align: right;
  font-weight: 600;
  background: var(--bg-soft);
  font-variant-numeric: tabular-nums;
}

.budget-table .col-mes-total {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.budget-table .cell-row-total { font-weight: 600; }
.budget-table .cell-grand-total { font-weight: 700; }

.budget-table .row-totals td {
  background: var(--bg-soft);
  border-top: 2px solid var(--color-border-strong);
  font-weight: 600;
}

.cell-input {
  width: 100%;
  min-width: 80px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

.cell-input:hover {
  border-color: var(--color-border);
  background: var(--bg-surface);
}

.cell-input:focus {
  outline: none;
  border-color: var(--color-text-info);
  background: var(--bg-surface);
}

.cell-input.dirty {
  background: #FFF8E1;
  border-color: #FF9800;
}

[data-theme="dark"] .cell-input.dirty {
  background: #3d3520;
  border-color: #786230;
}

/* ===== Tabla de Conversiones ===== */
.conv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.conv-table th,
.conv-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.conv-table thead th {
  background: var(--bg-soft);
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 12px;
}

.conv-table tbody tr:hover { background: var(--bg-soft); }

.col-ref { width: 60%; }
.col-uom { width: 20%; color: var(--color-text-secondary); }
.col-conv { width: 20%; }

.conv-input {
  width: 130px;
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--color-text);
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.conv-input:focus {
  outline: none;
  border-color: var(--color-text-info);
}

.conv-input.dirty {
  background: #FFF8E1;
  border-color: #FF9800;
}

[data-theme="dark"] .conv-input.dirty {
  background: #3d3520;
  border-color: #786230;
}

/* ===== Tabla de Lineas de Producto ===== */
.lineas-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

.lineas-table thead th {
  background: var(--bg-soft);
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 12px;
}

.lineas-table tbody tr:hover { background: var(--bg-soft); }

.col-linea-nombre { width: 60%; }
.col-comis { width: 40%; }

.linea-check {
  margin: 0;
}

/* ===== Switch (toggle on/off) ===== */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
  background: #cfd2d6;
  border-radius: 22px;
  transition: background 150ms ease;
  flex-shrink: 0;
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 150ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .switch-slider {
  background: #4CAF50;
}

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

[data-theme="dark"] .switch-slider {
  background: #4a5057;
}

.switch-label {
  font-size: 13px;
  color: var(--color-text-secondary);
}

/* ===== Tabla de Roles ===== */
.roles-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

.roles-table thead th {
  background: var(--bg-soft);
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 12px;
}

.roles-table tbody tr:hover { background: var(--bg-soft); }

.col-vendedor { width: 55%; }
.col-rol { width: 45%; }

.rol-select {
  width: 260px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--color-text);
  font-size: 13px;
}

.rol-select:hover { border-color: var(--color-border-strong); }

.rol-select:focus {
  outline: none;
  border-color: var(--color-text-info);
}

.rol-select.dirty {
  background: #FFF8E1;
  border-color: #FF9800;
}

[data-theme="dark"] .rol-select.dirty {
  background: #3d3520;
  border-color: #786230;
}

/* ===== Home: tabla de vendedores ===== */
.seller-table-section { margin-top: 24px; }

.seller-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 12px;
  flex-wrap: wrap;
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.period-selector label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.period-selector select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--color-text);
}

.seller-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.seller-table th,
.seller-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.seller-table thead th {
  background: var(--bg-soft);
  font-weight: 600;
  color: var(--color-text-secondary);
}

.seller-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.seller-table .row-totals td {
  font-weight: 600;
  background: var(--bg-soft);
  border-top: 2px solid var(--color-border-strong);
}

/* ===== Dashboards ===== */
.dashboard-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.dashboard-filter label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.dashboard-filter input[type="date"] {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--color-text);
  background: var(--bg-surface);
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.dash-table th,
.dash-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--color-border);
}

.dash-table thead th {
  background: var(--bg-soft);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-align: left;
}

.dash-table th.num,
.dash-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dash-table tr.row-totals td {
  font-weight: 600;
  border-top: 2px solid var(--color-border-strong);
  background: var(--bg-soft);
}

.cump-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.cump-bajo  { background: #FEE4E4; color: #9D2C2C; }
.cump-medio { background: #FFF3D6; color: #8A5A00; }
.cump-alto  { background: #DCF4E0; color: #1F6B2A; }

[data-theme="dark"] .cump-bajo  { background: #4A2424; color: #FFB6B6; }
[data-theme="dark"] .cump-medio { background: #4D3A14; color: #FFD68A; }
[data-theme="dark"] .cump-alto  { background: #1E3D26; color: #B3F0C0; }

/* Cards de seleccion en pantalla de Dashboards */
.dash-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.dash-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg-surface);
  text-decoration: none;
  color: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.dash-card:hover {
  border-color: var(--color-text-info);
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.dash-card-title { font-weight: 600; font-size: 15px; margin: 0 0 6px; }
.dash-card-desc { font-size: 13px; color: var(--color-text-secondary); margin: 0; }

/* ===== Comisiones (Director / Coordinador / Asesor) ===== */

/* Fila aplicable de la escala de comision */
.com-row-active td {
  background: #DCF4E0;
  color: #1F6B2A;
  font-weight: 600;
}
[data-theme="dark"] .com-row-active td {
  background: #1E3D26;
  color: #B3F0C0;
}

/* Tarjetas resumen (cumplimiento, salario, variable, total) */
.com-kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.com-kpi-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin: 0 0 4px;
  font-weight: 500;
}

.com-kpi-value {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.com-kpi-value.lg {
  font-size: 28px;
  font-weight: 700;
}

.com-kpi-card.total {
  background: #E6F1FB;
  border-color: #1F6FEB;
}
.com-kpi-card.total .com-kpi-label,
.com-kpi-card.total .com-kpi-value {
  color: #185FA5;
  font-weight: 700;
}
[data-theme="dark"] .com-kpi-card.total {
  background: #1E3A5F;
  border-color: #4F8EE0;
}
[data-theme="dark"] .com-kpi-card.total .com-kpi-label,
[data-theme="dark"] .com-kpi-card.total .com-kpi-value {
  color: #C8E0F8;
}

/* Colores de cumplimiento porcentual (KPI) */
.com-pct-bajo  { color: #9D2C2C; }
.com-pct-medio { color: #8A5A00; }
.com-pct-alto  { color: #1F6B2A; }
[data-theme="dark"] .com-pct-bajo  { color: #FFB6B6; }
[data-theme="dark"] .com-pct-medio { color: #FFD68A; }
[data-theme="dark"] .com-pct-alto  { color: #B3F0C0; }

/* Grid de KPI cards */
.com-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

/* ===== Dashboard Ventas por Region (grid 2x2 + cross-filtering) ===== */

.vr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

@media (max-width: 1100px) {
  .vr-grid { grid-template-columns: 1fr; }
}

.vr-cell {
  background: var(--bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  min-width: 0;       /* permite que el contenido NO expanda la columna del grid */
  overflow: hidden;   /* contiene los scroll horizontales dentro del card */
}

.vr-cell-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 6px;
}

.vr-cell-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.vr-cell-info {
  font-size: 12px;
  color: var(--color-text-tertiary);
  font-variant-numeric: tabular-nums;
}

.vr-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-soft);
  color: var(--color-text-tertiary);
  font-style: italic;
  border-radius: 6px;
  border: 1px dashed var(--color-border);
  padding: 24px;
  text-align: center;
}

/* Filas de tabla con cross-filtering */
.vr-table tbody tr.vr-row {
  cursor: pointer;
  transition: background 120ms ease, opacity 120ms ease;
}
.vr-table tbody tr.vr-row:hover {
  background: var(--bg-soft);
}
.vr-table tbody tr.vr-row-active {
  background: #DCF4E0;
  font-weight: 600;
}
[data-theme="dark"] .vr-table tbody tr.vr-row-active {
  background: #1E3D26;
}
.vr-table tbody tr.vr-row-dim {
  opacity: 0.35;
}

/* Banner de filtro activo */
.vr-active-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-info);
  color: var(--color-text-info);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
}

.btn-clear-filter {
  background: transparent;
  border: 1px solid var(--color-text-info);
  color: var(--color-text-info);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-clear-filter:hover {
  background: var(--color-text-info);
  color: var(--bg-info);
}

/* Filas país (parent) y ciudad (child) */
.vr-table tbody tr.vr-row-pais {
  background: var(--bg-soft);
}
.vr-table tbody tr.vr-row-pais:hover {
  background: var(--bg-info);
}
.vr-table tbody tr.vr-row-ciudad td:nth-child(2) {
  padding-left: 28px;
  color: var(--color-text-secondary);
}
.vr-table tbody tr.vr-row-ciudad:hover {
  background: var(--bg-soft);
}
.vr-table td.vr-expand-cell {
  width: 36px;
  text-align: center;
}
.vr-table .vr-expand-icon {
  display: inline-block;
  color: var(--color-text-tertiary);
  font-size: 11px;
  transition: transform 120ms ease;
}
.vr-table tbody tr.vr-row-pais.vr-row-active .vr-expand-icon {
  color: var(--color-text);
}


/* ===== Contenedor de graficos del dashboard de regiones ===== */
.vr-chart-wrap {
  flex: 1;
  position: relative;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vr-chart-wrap canvas {
  max-width: 100%;
  max-height: 100%;
}

/* ===== Dashboard Utilidad por Producto ===== */

.up-pct-ok { color: var(--color-text); }
.up-pct-bad { color: #b91c1c; font-weight: 600; }
[data-theme="dark"] .up-pct-bad { color: #ff8f8f; }

.up-row-alerta td {
  background: #fff1f2;
}
[data-theme="dark"] .up-row-alerta td {
  background: #3a1616;
}
.up-alerta-icon {
  color: #b91c1c;
  font-size: 14px;
  margin-right: 4px;
}
[data-theme="dark"] .up-alerta-icon {
  color: #ff8f8f;
}
