/* ═══════════════════════════════════════════════════════════
   Dashboard General — Celumania  (Siigo Style)
   ═══════════════════════════════════════════════════════════ */

#dgRoot {
  font-family: inherit;
  background: #0d1117;
  min-height: 100vh;
  color: #e6edf3;
  padding: 20px 24px 40px;
  box-sizing: border-box;
}

/* ── Header ── */
.dg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.dg-title    { font-size: 22px; font-weight: 700; color: #e6edf3; margin: 0; }
.dg-subtitle { font-size: 12px; color: #8b949e; margin-top: 2px; }
.dg-periodo-badge {
  background: rgba(59,130,246,0.15);
  color: #60a5fa;
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 600;
}

/* ── Filtros de fecha ── */
.dg-filtros {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.dg-filtros label { color: #8b949e; font-size: 13px; white-space: nowrap; }
.dg-filtros input[type="date"] {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
}
.dg-filtros input[type="date"]:focus { outline: none; border-color: #3b82f6; }
.dg-sep { color: #30363d; font-size: 18px; margin: 0 2px; }
.dg-preset {
  background: transparent;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.dg-preset:hover  { border-color: #3b82f6; color: #60a5fa; }
.dg-preset.active { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.dg-btn-aplicar {
  background: #3b82f6;
  border: none;
  border-radius: 6px;
  color: #fff;
  padding: 6px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-left: auto;
  transition: background .15s;
}
.dg-btn-aplicar:hover { background: #2563eb; }

/* ── Títulos de sección ── */
.dg-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #c9d1d9;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #21262d;
}

/* ── Grid de KPI cards (4 columnas) ── */
.dg-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.dg-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.dg-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.dg-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, #3b82f6);
  border-radius: 12px 12px 0 0;
}
.dg-card-ventas    { --card-color: #3b82f6; }
.dg-card-utilidad  { --card-color: #10b981; }
.dg-card-cartera   { --card-color: #f59e0b; }
.dg-card-pagar     { --card-color: #ef4444; }

.dg-card-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #8b949e;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dg-card-icon  { font-size: 16px; opacity: .7; }
.dg-card-value {
  font-size: 26px;
  font-weight: 700;
  color: #e6edf3;
  line-height: 1.1;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dg-card-meta {
  font-size: 12px;
  color: #8b949e;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.dg-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.dg-badge-up   { background: rgba(16,185,129,.15); color: #10b981; }
.dg-badge-down { background: rgba(239,68,68,.15);  color: #ef4444; }
.dg-badge-neu  { background: rgba(139,92,246,.15); color: #a78bfa; }

/* Mini sparkline */
.dg-spark             { margin-top: 14px; height: 36px; position: relative; }
.dg-spark canvas      { width: 100% !important; }
.dg-spark-placeholder { margin-top: 14px; height: 36px; }

/* ── Ventas Detalle — 4 mini-stats ── */
.dg-ventas-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.dg-vstat {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 14px 16px;
}
.dg-vstat-label {
  font-size: 10px;
  font-weight: 700;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.dg-vstat-val        { font-size: 20px; font-weight: 700; color: #e6edf3; }
.dg-vstat-accent     { color: #60a5fa; }

/* ── Aging ── */
.dg-aging-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.dg-aging-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-top: 3px solid var(--aging-color, #30363d);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
}
.dg-aging-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  color: #8b949e;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.dg-aging-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--aging-color, #e6edf3);
}

/* Aging CxC */
.dg-aging-corriente { --aging-color: #10b981; }
.dg-aging-d1-30     { --aging-color: #f59e0b; }
.dg-aging-d31-60    { --aging-color: #f97316; }
.dg-aging-d61-90    { --aging-color: #ef4444; }
.dg-aging-d90-mas   { --aging-color: #dc2626; }

/* Aging CxP (misma lógica visual: corriente=verde, vencida=rojo) */
.dg-aging-pagar-corriente { --aging-color: #10b981; }
.dg-aging-pagar-d1-30     { --aging-color: #f59e0b; }
.dg-aging-pagar-d31-60    { --aging-color: #f97316; }
.dg-aging-pagar-d61-90    { --aging-color: #ef4444; }
.dg-aging-pagar-d90-mas   { --aging-color: #dc2626; }

/* ── Tabla detalle cartera ── */
.dg-cartera-table-wrap {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 28px;
}
.dg-cartera-table-head {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #c9d1d9;
  border-bottom: 1px solid #21262d;
  background: #0d1117;
}
.dg-cartera-table-body {
  max-height: 360px;
  overflow-y: auto;
}
.dg-cartera-table-body::-webkit-scrollbar       { width: 6px; }
.dg-cartera-table-body::-webkit-scrollbar-track  { background: #161b22; }
.dg-cartera-table-body::-webkit-scrollbar-thumb  { background: #30363d; border-radius: 3px; }

/* ── Tags semáforo ── */
.dg-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.dg-tag-verde    { background: rgba(16,185,129,.15); color: #10b981; }
.dg-tag-amarillo { background: rgba(245,158,11,.15); color: #f59e0b; }
.dg-tag-naranja  { background: rgba(249,115,22,.15); color: #f97316; }
.dg-tag-rojo     { background: rgba(239,68,68,.15);  color: #ef4444; }

/* ── Top tables ── */
.dg-tops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.dg-tops-grid-single {
  grid-template-columns: minmax(300px, 560px);
}
.dg-table-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  overflow: hidden;
}
.dg-table-head {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #c9d1d9;
  border-bottom: 1px solid #21262d;
  background: #0d1117;
}
.dg-table { width: 100%; border-collapse: collapse; }
.dg-table th {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  color: #8b949e;
  text-transform: uppercase;
  padding: 8px 16px;
  text-align: left;
  background: #0d1117;
}
.dg-table th:last-child { text-align: right; }
.dg-table td {
  padding: 10px 16px;
  font-size: 13px;
  color: #c9d1d9;
  border-top: 1px solid #21262d;
}
.dg-table td:last-child { text-align: right; color: #e6edf3; font-weight: 600; }
.dg-table tr:hover td  { background: rgba(255,255,255,.03); }
.dg-table .dg-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(59,130,246,.15);
  color: #60a5fa;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
  flex-shrink: 0;
}
.dg-table .dg-rank-1 { background: rgba(251,191,36,.15); color: #fbbf24; }
.dg-table .dg-rank-2 { background: rgba(156,163,175,.15); color: #9ca3af; }
.dg-table .dg-rank-3 { background: rgba(180,83,9,.15);   color: #b45309; }

/* ── Loading ── */
.dg-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 0;
  color: #8b949e;
  font-size: 14px;
}
.dg-spinner {
  width: 36px; height: 36px;
  border: 3px solid #21262d;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: dg-spin .7s linear infinite;
}
@keyframes dg-spin { to { transform: rotate(360deg); } }

/* ─── EXTRAS — Siigo-style modules ───────────────────────── */

/* Flujo de caja del día */
.dg-flujo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.dg-flujo-grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.dg-flujo-card {
  background: linear-gradient(135deg, #161b22 0%, #1a2230 100%);
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.dg-flujo-card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 3px; height: 100%;
  background: #3b82f6;
}
.dg-flujo-in::before    { background: #10b981; }
.dg-flujo-total::before { background: #f59e0b; }
.dg-flujo-info::before  { background: #8b5cf6; }
.dg-flujo-icon  { font-size: 18px; margin-bottom: 6px; }
.dg-flujo-label { font-size: 10px; color: #8b949e; text-transform: uppercase; font-weight: 700; letter-spacing: .06em; }
.dg-flujo-val   { font-size: 20px; font-weight: 700; color: #e6edf3; margin-top: 6px; }
.dg-flujo-val-big { font-size: 24px; color: #fbbf24; }
.dg-flujo-sub   { font-size: 11px; color: #6e7681; margin-top: 4px; }

/* Meta vs Real */
.dg-meta-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 24px;
}
.dg-meta-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 14px;
}
.dg-meta-lbl { font-size: 10px; color: #8b949e; text-transform: uppercase; font-weight: 700; letter-spacing: .06em; }
.dg-meta-val { font-size: 18px; font-weight: 700; color: #e6edf3; margin-top: 4px; }
.dg-meta-pct { color: #fbbf24; }
.dg-bar {
  width: 100%; height: 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
  overflow: hidden;
}
.dg-bar-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.dg-bar-done { background: linear-gradient(90deg, #10b981, #34d399); }
.dg-bar-ok   { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.dg-bar-warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.dg-bar-low  { background: linear-gradient(90deg, #ef4444, #f87171); }
.dg-meta-empty {
  display: flex; flex-direction: column; gap: 6px;
  background: #161b22; border: 1px dashed #30363d;
  border-radius: 10px; padding: 18px 20px;
  color: #8b949e; margin-bottom: 24px;
}
.dg-meta-empty-sub { font-size: 12px; }

/* Inventario crítico */
.dg-inv-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

/* ─── DRILL-DOWN — clickable cursor + hover ──────────────── */
.dg-clickable { cursor: pointer; transition: background .15s; }
.dg-clickable:hover { background: rgba(59,130,246,0.08) !important; }
.dg-aging-card.dg-clickable:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.dg-link { color: #60a5fa; text-decoration: none; border-bottom: 1px dashed rgba(96,165,250,0.4); }
.dg-link:hover { border-bottom-style: solid; }

/* ─── MODAL ──────────────────────────────────────────────── */
.dg-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
  animation: dg-fadein .2s ease;
}
@keyframes dg-fadein { from { opacity: 0; } to { opacity: 1; } }
.dg-modal {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 14px;
  max-width: 900px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  overflow: hidden;
  animation: dg-slideup .25s ease;
}
@keyframes dg-slideup { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.dg-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: #161b22;
  border-bottom: 1px solid #21262d;
}
.dg-modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; color: #e6edf3; }
.dg-modal-close {
  background: transparent; border: none; color: #8b949e;
  font-size: 26px; line-height: 1; cursor: pointer;
  padding: 0 6px; border-radius: 6px; transition: all .15s;
}
.dg-modal-close:hover { background: rgba(239,68,68,0.15); color: #ef4444; }
.dg-modal-body { padding: 20px; }
.dg-modal-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.dg-modal-stats .dg-vstat { padding: 10px 12px; }
.dg-modal-table-title {
  font-size: 12px; font-weight: 700; color: #8b949e;
  text-transform: uppercase; letter-spacing: .06em;
  margin: 16px 0 8px;
}
.dg-suggest-box {
  background: #161b22; border: 1px solid #30363d;
  border-radius: 10px; padding: 14px 16px;
  margin-bottom: 16px;
}
.dg-modal-loading {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 40px 20px; color: #8b949e;
}
.dg-modal-error {
  padding: 20px; text-align: center; color: #ef4444;
  background: rgba(239,68,68,0.08); border-radius: 10px;
}

/* ─── ANALÍTICAS TABS ────────────────────────────────────── */
.dg-analytics-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
}
.dg-tabs {
  display: flex;
  background: #0d1117;
  border-bottom: 1px solid #21262d;
  padding: 0 12px;
}
.dg-tab {
  background: transparent; border: none; color: #8b949e;
  padding: 14px 18px; font-size: 13px; font-weight: 600;
  cursor: pointer; position: relative;
  transition: color .15s;
}
.dg-tab:hover { color: #e6edf3; }
.dg-tab.active { color: #60a5fa; }
.dg-tab.active::after {
  content: ''; position: absolute; bottom: -1px; left: 12px; right: 12px;
  height: 2px; background: #60a5fa; border-radius: 2px;
}
.dg-tab-content { padding: 18px; }
.dg-analytics-grid {
  display: grid;
  /* 2 columnas máximo en desktop — 3 columnas espachurraban las tablas */
  grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
  gap: 14px;
}
/* Tablas dentro de analytics: scroll horizontal interno cuando no caben */
.dg-analytics-grid .dg-table-card { min-width: 0; }
.dg-analytics-grid .dg-table-card table { min-width: 100%; }
/* Permitir que el contenido de las cards respire — quitar wrap brusco */
.dg-analytics-grid .dg-table th,
.dg-analytics-grid .dg-table td { white-space: nowrap; }

/* Charts (analytics) */
.dg-chart-card {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 14px 16px;
}
.dg-chart-title {
  font-size: 12px; font-weight: 700; color: #8b949e;
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 10px;
}
.dg-chart-wrap { height: 200px; position: relative; }

/* ─── FOCUS MODE — back bar ─────────────────────────────── */
.dg-back-bar {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(90deg, rgba(59,130,246,0.12), rgba(16,185,129,0.06));
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  animation: dg-fadein .25s ease;
}
.dg-back-btn {
  background: rgba(59,130,246,0.18);
  border: 1px solid rgba(59,130,246,0.4);
  color: #60a5fa;
  padding: 6px 14px; border-radius: 8px;
  font-weight: 600; font-size: 13px;
  cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.dg-back-btn:hover { background: rgba(59,130,246,0.3); border-color: #60a5fa; color: #93c5fd; }
.dg-back-title { font-size: 14px; font-weight: 700; color: #e6edf3; }
.dg-block { animation: dg-fadein .2s ease; }

/* ─── QUICK-NAV — Barra de navegación rápida por secciones ── */
.dg-quick-nav {
  margin-bottom: 20px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 10px 12px;
}
.dg-quick-nav-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  scrollbar-width: thin;
  scrollbar-color: #30363d transparent;
}
.dg-quick-nav-scroll::-webkit-scrollbar       { height: 4px; }
.dg-quick-nav-scroll::-webkit-scrollbar-track  { background: transparent; }
.dg-quick-nav-scroll::-webkit-scrollbar-thumb  { background: #30363d; border-radius: 2px; }
.dg-pill {
  background: rgba(59,130,246,0.08);
  border: 1px solid #30363d;
  border-radius: 8px;
  color: #8b949e;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  flex-shrink: 0;
}
.dg-pill:hover {
  border-color: #3b82f6;
  color: #60a5fa;
  background: rgba(59,130,246,0.15);
}
.dg-pill:active {
  transform: scale(0.96);
}

/* ─── RESPONSIVE — Tabla scroll horizontal en todas las tablas ── */
.dg-table-card,
.dg-cartera-table-wrap,
.dg-chart-card {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.dg-table { min-width: 100%; }

/* Tablet — 1024px y abajo */
@media (max-width: 1024px) {
  .dg-kpi-grid,
  .dg-analytics-grid    { grid-template-columns: 1fr; }
  .dg-flujo-grid        { grid-template-columns: repeat(2, 1fr); }
  .dg-tops-grid         { grid-template-columns: 1fr; }
}

/* Móvil — 700px y abajo */
@media (max-width: 700px) {
  #dgRoot { padding: 10px 8px 40px; }

  /* Grids: aging y flujo 2 cols, resto 1 col */
  .dg-kpi-grid        { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .dg-aging-grid      { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .dg-flujo-grid,
  .dg-flujo-grid-3    { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .dg-ventas-stats    { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .dg-inv-stats       { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .dg-meta-row        { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .dg-analytics-grid,
  .dg-modal-stats,
  .dg-tops-grid       { grid-template-columns: 1fr !important; gap: 10px; }

  /* Header compacto */
  .dg-header          { margin-bottom: 12px; }
  .dg-title           { font-size: 17px; }
  .dg-subtitle        { font-size: 11px; }
  .dg-periodo-badge   { font-size: 11px; padding: 3px 10px; }

  /* Filtros — wrap en grid */
  .dg-filtros {
    padding: 10px;
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 6px;
    align-items: center;
  }
  .dg-filtros label { font-size: 11px; }
  .dg-filtros input[type="date"] { font-size: 12px; padding: 4px 6px; width: 100%; }
  .dg-sep { display: none; }
  .dg-preset { padding: 6px 10px; font-size: 11px; }
  .dg-btn-aplicar { padding: 6px 12px; font-size: 12px; grid-column: span 4; }

  /* Quick-nav pills */
  .dg-quick-nav     { padding: 8px 10px; margin-bottom: 14px; }
  .dg-pill          { padding: 6px 10px; font-size: 11px; }

  /* KPI cards */
  .dg-card          { padding: 12px; }
  .dg-card-value    { font-size: 18px; white-space: normal; word-break: break-word; }
  .dg-card-label    { font-size: 10px; }
  .dg-card-meta     { font-size: 10px; flex-wrap: wrap; }
  .dg-spark         { margin-top: 10px; height: 28px; }

  /* Aging cards — compactas */
  .dg-aging-card    { padding: 10px 8px; }
  .dg-aging-val     { font-size: 14px; word-break: break-word; }
  .dg-aging-label   { font-size: 9px; }

  /* Flujo */
  .dg-flujo-card    { padding: 10px; }
  .dg-flujo-val     { font-size: 15px; word-break: break-word; }
  .dg-flujo-val-big { font-size: 17px; }
  .dg-flujo-label   { font-size: 9px; }
  .dg-flujo-sub     { font-size: 10px; }

  /* Stats genéricos */
  .dg-vstat         { padding: 10px; }
  .dg-vstat-val     { font-size: 15px; word-break: break-word; }
  .dg-vstat-label   { font-size: 9px; }

  /* Meta */
  .dg-meta-card     { padding: 12px; }
  .dg-meta-val      { font-size: 14px; }

  /* Tablas — scroll horizontal con indicador visual */
  .dg-table-card,
  .dg-cartera-table-wrap {
    position: relative;
  }
  .dg-table-card::after,
  .dg-cartera-table-wrap::after {
    content: '→ deslizar';
    position: absolute;
    bottom: 8px; right: 10px;
    font-size: 10px;
    color: #3b82f6;
    opacity: 0.6;
    pointer-events: none;
  }
  .dg-table         { min-width: 420px; font-size: 11px; }
  .dg-table th      { padding: 6px 5px; font-size: 9px; }
  .dg-table td      { padding: 7px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
  .dg-table td:first-child { position: sticky; left: 0; background: #161b22; z-index: 1; max-width: none; }
  .dg-table-head    { font-size: 12px; padding: 10px 12px; }

  /* Modales — fullscreen en móvil */
  .dg-modal-overlay { padding: 0; align-items: stretch; }
  .dg-modal         { border-radius: 0; max-width: 100%; min-height: 100vh; }
  .dg-modal-header  { padding: 12px 14px; position: sticky; top: 0; z-index: 1; }
  .dg-modal-header h3 { font-size: 14px; }
  .dg-modal-body    { padding: 12px; }
  .dg-modal-stats   { grid-template-columns: 1fr 1fr !important; gap: 8px; }

  /* Tabs analíticas */
  .dg-tabs          { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dg-tab           { padding: 10px 8px; font-size: 11px; flex-shrink: 0; text-align: center; }
  .dg-tab.active::after { left: 6px; right: 6px; }
  .dg-tab-content   { padding: 12px; }
  .dg-chart-wrap    { height: 170px; }

  /* Back bar */
  .dg-back-bar      { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px; }
  .dg-back-title    { font-size: 13px; }
  .dg-back-btn      { font-size: 12px; padding: 5px 10px; }

  /* Section titles */
  .dg-section-title { font-size: 13px; margin: 14px 0 8px; }

  /* Ranking badges más pequeños */
  .dg-table .dg-rank { width: 16px; height: 16px; font-size: 9px; margin-right: 4px; }
}

/* Móvil pequeño — 400px y abajo */
@media (max-width: 400px) {
  #dgRoot           { padding: 6px 4px 30px; }
  .dg-kpi-grid      { grid-template-columns: 1fr !important; }
  .dg-card-value    { font-size: 17px; }
  .dg-vstat-val     { font-size: 13px; }
  .dg-flujo-val     { font-size: 14px; }
  .dg-aging-grid    { grid-template-columns: 1fr !important; }
  .dg-modal-stats   { grid-template-columns: 1fr !important; }
  .dg-pill          { padding: 5px 8px; font-size: 10px; }
}
