/* dashboard.css — Panel de Control v2 (single-screen layout) */

/* ── Root container ────────────────────────────────────────────────────────── */
.dash-root {
  display: flex;
  flex-direction: column;
  gap: 8px;           /* ↓ 12→8 ahorra 16px en 4 gaps */
  max-width: 1400px;
}

/* ── Shared card ────────────────────────────────────────────────────────────── */
.dash-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.dash-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;  /* ↓ 10→7 ahorra 6px por card (×5 = 30px) */
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.dash-card-icon { font-size: 13px; }

.dash-card-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-primary);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.dash-card-body {
  padding: 8px 12px;  /* ↓ 12→8 ahorra 8px por card (×5 = 40px) */
}

.dash-header-sub {
  margin-left: auto;
  font-size: 11px;
  color: var(--color-text-muted);
}

.dash-header-hint {
  font-size: 10px;
  color: var(--color-text-hint);
  font-style: italic;
  margin-left: 4px;
}

.dash-header-action {
  margin-left: auto;
  font-size: 11px;
  color: var(--color-primary);
  cursor: pointer;
  white-space: nowrap;
}
.dash-header-action:hover { text-decoration: underline; }

.dash-refresh-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-hint);
  padding: 1px 3px;
  border-radius: 4px;
  font-size: 12px;
  margin-left: auto;
}
.dash-refresh-btn:hover { background: var(--color-bg-tertiary); color: var(--color-primary); }

.dash-loading {
  color: var(--color-text-hint);
  font-size: 12px;
  text-align: center;
  padding: 8px 0;
}

.dash-empty {
  color: var(--color-text-hint);
  font-size: 12px;
  text-align: center;
  padding: 10px 0;
  line-height: 1.5;
}

/* ── Two-column layout ──────────────────────────────────────────────────────── */
.dash-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (max-width: 900px) {
  .dash-two-col { grid-template-columns: 1fr; }
}

/* ── FILA 1: Hero KPIs — target ~62px ──────────────────────────────────────── */
.dash-hero-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
@media (max-width: 1100px) {
  .dash-hero-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .dash-hero-grid { grid-template-columns: 1fr 1fr; }
}

.dash-hero-card {
  border-radius: 8px;
  padding: 9px 12px 8px;  /* ↓ 14→9 ahorra 10px por card */
  display: flex;
  gap: 9px;
  align-items: flex-start;
  border: 1px solid transparent;
  transition: box-shadow .15s;
}
.dash-hero-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.07); }

.dash-hero-card--primary { background: linear-gradient(135deg, #1e40af10, #3b82f615); border-color: #3b82f630; }
.dash-hero-card--success  { background: linear-gradient(135deg, #06652510, #22c55e15); border-color: #22c55e30; }
.dash-hero-card--info     { background: linear-gradient(135deg, #0891b210, #06b6d415); border-color: #06b6d430; }
.dash-hero-card--ok       { background: linear-gradient(135deg, #16653410, #10b98115); border-color: #10b98130; }
.dash-hero-card--danger   { background: linear-gradient(135deg, #7f1d1d10, #ef444415); border-color: #ef444430; }

.dash-hero-icon {
  font-size: 18px;    /* ↓ 22→18 */
  opacity: .70;
  flex-shrink: 0;
  margin-top: 1px;
}
.dash-hero-card--primary .dash-hero-icon { color: #3b82f6; }
.dash-hero-card--success .dash-hero-icon { color: #22c55e; }
.dash-hero-card--info    .dash-hero-icon { color: #06b6d4; }
.dash-hero-card--ok      .dash-hero-icon { color: #10b981; }
.dash-hero-card--danger  .dash-hero-icon { color: #ef4444; }

.dash-hero-body { flex: 1; min-width: 0; }

.dash-hero-label {
  font-size: 9px;       /* ↓ 10→9 */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-hint);
  margin-bottom: 2px;   /* ↓ 4→2 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-hero-value {
  font-size: 17px;      /* ↓ 20→17 ahorra ~3px línea */
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;   /* ↓ 3→2 */
}

.dash-hero-sub {
  font-size: 10px;      /* ↓ 11→10 */
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-hero-badge {
  font-size: 9px;
  font-weight: 600;
  border-radius: 3px;
  padding: 1px 4px;
  vertical-align: middle;
  margin-left: 3px;
}
.badge-ok     { background: #dcfce7; color: #166534; }
.badge-warn   { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* ── FILA 2: Embudo — target ~165px (era ~290px, ahorra ~125px) ─────────────── */
.dash-funnel-wrap {
  padding: 4px 12px 5px;  /* ↓ 10+12→4+5 ahorra 13px */
}

.dash-funnel {
  display: flex;
  flex-direction: column;
  gap: 2px;               /* ↓ 6→2 ahorra 5×4=20px */
}

.dash-funnel-row {
  display: grid;
  grid-template-columns: 110px 1fr 34px 108px;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 4px;       /* ↓ 4→1 ahorra 3×2×6=36px */
  transition: background .12s;
}
.dash-funnel-row:hover { background: var(--color-bg-secondary); }

.dash-funnel-paid { opacity: .75; }

.dash-funnel-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;        /* ↓ 12→11 */
  color: var(--color-text-primary);
  white-space: nowrap;
}

.dash-funnel-bar-wrap {
  flex: 1;
  height: 18px;           /* ↓ 26→18 ahorra 8×6=48px */
  display: flex;
  align-items: center;
}

.dash-funnel-bar {
  height: 14px;           /* ↓ 22→14 */
  border-radius: 0 3px 3px 0;
  display: flex;
  align-items: center;
  padding-left: 5px;
  min-width: 3px;
  transition: width .4s;
}

.dash-funnel-bar-count {
  font-size: 10px;        /* ↓ 11→10 */
  font-weight: 700;
  white-space: nowrap;
  padding-right: 3px;
}

.dash-funnel-pct {
  font-size: 10px;
  color: var(--color-text-muted);
  text-align: right;
  min-width: 34px;
}

.dash-funnel-monto {
  font-size: 10px;        /* ↓ 11→10 */
  color: var(--color-text-muted);
  text-align: right;
  white-space: nowrap;
}

.dash-monto-success { color: var(--color-success) !important; font-weight: 500; }

/* ── FILA 3a: Aging — target ~155px ─────────────────────────────────────────── */
.dash-aging-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;     /* ↓ 10→6 */
  padding-bottom: 5px;    /* ↓ 8→5 */
  border-bottom: 1px solid var(--color-border);
}
.dash-aging-total-label { font-size: 10px; color: var(--color-text-hint); }
.dash-aging-total-value { font-size: 12px; font-weight: 700; color: var(--color-text-primary); }

.dash-aging-row {
  display: grid;
  grid-template-columns: 82px 1fr 38px 30px 96px;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;     /* ↓ 7→4 ahorra 3×5=15px */
}

.dash-aging-bucket { display: flex; align-items: center; gap: 5px; }
.dash-aging-dot    { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.dash-aging-label {
  font-size: 10px;        /* ↓ 11→10 */
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
}

.dash-aging-bar-wrap { height: 14px; display: flex; align-items: center; } /* ↓ 18→14 */
.dash-aging-bar      { height: 10px; border-radius: 0 3px 3px 0; min-width: 3px; transition: width .4s; }

.dash-aging-count  { font-size: 10px; font-weight: 600; color: var(--color-text-primary); text-align: right; }
.dash-aging-pct    { font-size: 9px; font-weight: 700; text-align: right; }
.dash-aging-monto  { font-size: 10px; color: var(--color-text-muted); text-align: right; white-space: nowrap; }

/* ── FILA 3b: Canal — target ~145px ─────────────────────────────────────────── */
.dash-canal-row {
  display: grid;
  grid-template-columns: 120px 1fr 40px 32px;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;     /* ↓ 8→5 ahorra 3×N */
}

.dash-canal-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--color-text-primary);
}

.dash-canal-bar-wrap { height: 16px; display: flex; align-items: center; } /* ↓ 22→16 */
.dash-canal-bar      { height: 12px; border-radius: 0 3px 3px 0; min-width: 3px; transition: width .4s; }

.dash-canal-count { font-size: 10px; font-weight: 600; color: var(--color-text-primary); text-align: right; }
.dash-canal-pct   { font-size: 10px; font-weight: 700; text-align: right; }

.dash-attr-note {
  margin-top: 6px;        /* ↓ 12→6 */
  padding-top: 5px;
  border-top: .5px solid var(--color-border);
  font-size: 10px;
  color: var(--color-text-hint);
  line-height: 1.4;
}

/* ── FILA 4a: Campo — target ~125px ─────────────────────────────────────────── */
.dash-campo-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-bottom: 5px;     /* ↓ 8→5 */
}

.dash-campo-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;               /* ↓ 4→2 */
  padding: 5px 3px;       /* ↓ 8→5 */
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
  border: 1px solid var(--color-border);
  text-align: center;
}
.dash-campo-item:hover { background: var(--color-bg-secondary); }

.dash-campo-icon  { font-size: 15px; }        /* ↓ 18→15 */
.dash-campo-n     { font-size: 14px; font-weight: 700; line-height: 1; } /* ↓ 16→14 */
.dash-campo-label { font-size: 8px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.dash-campo-pct   { font-size: 8px; color: var(--color-text-hint); }

.dash-campo-total {
  font-size: 10px;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 3px;
}

/* ── FILA 4b: Notify — target ~115px ────────────────────────────────────────── */
.dash-notify-summary {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--color-text-muted);
  padding-bottom: 5px;    /* ↓ 8→5 */
  margin-bottom: 5px;     /* ↓ 8→5 */
  border-bottom: .5px solid var(--color-border);
}

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

.dash-notify-table thead th {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-hint);
  padding: 3px 0;         /* ↓ 4→3 */
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.dash-notify-th-num, .dash-notify-td-num { text-align: right; }

.dash-notify-table tbody td {
  padding: 4px 0;         /* ↓ 6→4 ahorra 2×4 canales×2=16px */
  color: var(--color-text-primary);
  border-bottom: .5px solid var(--color-border);
  vertical-align: middle;
}
.dash-notify-table tbody tr:last-child td { border-bottom: none; }

/* ── FILA 5b: Compactos ─────────────────────────────────────────────────────── */
.dash-compact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;       /* ↓ 8→6 */
  border-radius: 6px;
  border: 1px solid var(--color-border);
  transition: background .12s;
}
.dash-compact-row:hover { background: var(--color-bg-secondary); cursor: pointer; }

.dash-compact-ok   { border-color: #22c55e30; background: #22c55e08; }
.dash-compact-warn { border-color: #f59e0b30; background: #f59e0b08; }

/* ── Botón ? (tip button) ───────────────────────────────────────────────────── */
.dash-tip-btn {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-hint);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
  padding: 0;
}
.dash-tip-btn:hover,
.dash-tip-btn:focus {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  outline: none;
}

/* Versión hero: posición absoluta en la esquina superior derecha */
.dash-tip-btn--hero {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 14px;
  height: 14px;
  font-size: 8px;
  opacity: .55;
}
.dash-hero-card:hover .dash-tip-btn--hero { opacity: 1; }

/* ── Popover de ayuda ───────────────────────────────────────────────────────── */
.dash-tip-pop {
  position: fixed;
  z-index: 9999;
  width: 290px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14), 0 1px 6px rgba(0,0,0,.08);
  overflow: hidden;
  pointer-events: auto;
  animation: dash-tip-in .12s ease;
}
.dash-tip-pop--hidden { display: none; }

@keyframes dash-tip-in {
  from { opacity: 0; transform: translateY(-4px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.dash-tip-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px 8px;
  background: var(--color-primary);
  border-bottom: 1px solid var(--color-border);
}

.dash-tip-title {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.dash-tip-close {
  background: rgba(255,255,255,.2);
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background .12s;
}
.dash-tip-close:hover { background: rgba(255,255,255,.35); }

.dash-tip-body {
  padding: 10px 12px 8px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--color-text-primary);
  white-space: pre-line;
}

.dash-tip-meta {
  padding: 6px 12px 8px;
  font-size: 10px;
  color: var(--color-text-hint);
  font-style: italic;
  border-top: .5px solid var(--color-border);
}

/* ── Legacy dist-bar ────────────────────────────────────────────────────────── */
.dist-bar { display: flex; height: 22px; border-radius: 4px; overflow: hidden; margin: 4px 0 10px; }
.dist-seg { display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; transition: flex .4s ease; }

/* ── BayForce KPI grid (fila 6) ── */
.dash-bf-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.dash-bf-section {
  flex: 1;
  min-width: 180px;
}
.dash-bf-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.dash-mini-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dash-mini-kpi {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 6px 10px;
  min-width: 72px;
  text-align: center;
}
.dash-mini-val {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}
.dash-mini-lbl {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── SGC/Pagos stat rows (fila 7) ── */
.dash-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: .5px solid var(--color-border);
  font-size: 12px;
}
.dash-stat-row:last-child { border-bottom: none; }
.dash-stat-label { color: var(--color-text-muted); }
.dash-stat-val   { font-weight: 600; }
