:root {
  --g-primary: #CA3C42;
  --g-primary-soft: #fee2e2;
  --g-bg: #f1f5f9;
  --g-border: #e2e8f0;
  --g-text: #0f172a;
  --g-muted: #64748b;
}

.gerencia {
  padding: 1.5rem 2rem;
  max-width: 1600px;
  margin: 0 auto;
}

.gerencia-loading {
  text-align: center;
  padding: 3rem;
  color: var(--g-muted);
}

/* Dashboard tabs (Operación / Finanzas / Talento) */
.gerencia-dash-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--g-border);
  margin-bottom: 0;
}
.gerencia-dash-tabs button {
  background: none; border: none; padding: 12px 20px;
  font-size: 1rem; font-weight: 600; color: var(--g-muted); cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.gerencia-dash-tabs button:hover { color: var(--g-text); }
.gerencia-dash-tabs button.active { color: var(--g-primary); border-bottom-color: var(--g-primary); }
.gerencia-dash-tabs button i { margin-right: 8px; }

/* Subtabs */
.gerencia-subtabs {
  display: flex; gap: 2px; overflow-x: auto;
  padding: 1rem 0; border-bottom: 1px solid var(--g-border);
}
.gerencia-subtabs button {
  background: none; border: none; padding: 8px 16px;
  font-size: 0.85rem; font-weight: 600; color: var(--g-muted); cursor: pointer;
  border-radius: 6px; white-space: nowrap;
}
.gerencia-subtabs button:hover { background: var(--g-bg); }
.gerencia-subtabs button.active { background: var(--g-primary); color: #fff; }

/* Filter bar */
.gerencia-filters {
  display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
  padding: 1rem 0; position: sticky; top: 60px;
  background: #fff; z-index: 10;
}
.filter-chip-group { display: flex; gap: 3px; background: #fff; padding: 3px; border-radius: 10px; border: 1px solid #cbd5e1; }
.filter-chip-group button { background: transparent; border: none; padding: 6px 12px; font-size: 0.8rem; font-weight: 600; color: var(--g-muted); cursor: pointer; border-radius: 7px; }
.filter-chip-group button.active { background: var(--g-primary); color: #fff; }
.filter-dropdown { padding: 6px 12px; border-radius: 999px; border: 1px solid #cbd5e1; background: #fff; font-size: 0.8rem; font-weight: 600; color: #475569; }
.filter-export { background: var(--g-text); color: #fff; border: none; padding: 6px 14px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; cursor: pointer; }

/* Grid de widgets */
.gerencia-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
  padding: 1rem 0;
}
.gerencia-grid .widget {
  background: #fff; border: 1px solid var(--g-border); border-radius: 10px;
  padding: 1rem; min-height: 120px;
}
.gerencia-grid .widget.span-2 { grid-column: span 2; }
.gerencia-grid .widget.span-3 { grid-column: span 3; }
.gerencia-grid .widget.span-4 { grid-column: span 4; }
.gerencia-grid .widget.row-2 { grid-row: span 2; min-height: 260px; }
.widget-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.widget-header h4 { margin: 0; font-size: 0.9rem; color: var(--g-text); }
.widget-drilldown { color: var(--g-primary); font-weight: 700; text-decoration: none; font-size: 1rem; }
.widget-error { color: #991b1b; font-size: 0.8rem; background: #fee2e2; padding: 6px 10px; border-radius: 5px; }

/* KPI specific */
.kpi-label { font-size: 0.68rem; color: var(--g-muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.3px; }
.kpi-value { font-size: 2rem; font-weight: 700; color: var(--g-text); margin-top: 4px; line-height: 1; }
.kpi-delta { font-size: 0.75rem; margin-top: 8px; font-weight: 600; }
.kpi-delta.up { color: #10b981; }
.kpi-delta.down { color: #ef4444; }
.kpi-delta.flat { color: var(--g-muted); }

@media (max-width: 900px) {
  .gerencia { padding: 1rem; }
  .gerencia-grid { grid-template-columns: repeat(2, 1fr); }
  .gerencia-grid .widget.span-3, .gerencia-grid .widget.span-4 { grid-column: span 2; }
}

/* Tables */
.widget-table { width: 100%; font-size: 0.8rem; border-collapse: collapse; }
.widget-table th { text-align: left; font-weight: 600; color: var(--g-muted); font-size: 0.68rem; text-transform: uppercase; padding: 5px 0; border-bottom: 1px solid var(--g-border); }
.widget-table td { padding: 7px 0; border-bottom: 1px solid #f1f5f9; color: #334155; }
.badge { padding: 2px 8px; border-radius: 6px; font-size: 0.65rem; font-weight: 600; display: inline-block; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }

/* Funnel */
.funnel { display: flex; gap: 2px; align-items: stretch; height: 70px; }
.funnel-step { display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; border-radius: 4px; padding: 6px; }

/* Progress */
.progress-bar { height: 18px; background: var(--g-bg); border-radius: 4px; position: relative; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--g-primary), #f59e0b); }
.progress-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.68rem; font-weight: 700; color: #fff; }

/* Canvas containers (para que Chart.js respete altura) */
.gerencia-grid .widget canvas { max-height: 220px; }

@media (max-width: 640px) {
  .gerencia { padding: 0.8rem; }
  .gerencia-grid { grid-template-columns: 1fr; }
  .gerencia-grid .widget.span-2, .gerencia-grid .widget.span-3, .gerencia-grid .widget.span-4 { grid-column: span 1; }
  .gerencia-dash-tabs { overflow-x: auto; }
  .gerencia-dash-tabs button { padding: 10px 14px; font-size: 0.9rem; white-space: nowrap; }
  .gerencia-filters { padding: 0.6rem 0; overflow-x: auto; flex-wrap: nowrap; }
  .filter-chip-group { flex-shrink: 0; }
  .kpi-value { font-size: 1.5rem; }
  .filter-export { flex-shrink: 0; }
}

/* Scroll nicely on horizontal overflow */
.gerencia-dash-tabs::-webkit-scrollbar,
.gerencia-subtabs::-webkit-scrollbar,
.gerencia-filters::-webkit-scrollbar {
  height: 4px;
}
.gerencia-dash-tabs::-webkit-scrollbar-thumb,
.gerencia-subtabs::-webkit-scrollbar-thumb,
.gerencia-filters::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}
