/* =====================================================================
   Dashboard redesign — Variante A · "Refresh minimalista"
   Spec: docs/design/2026-05-19-dashboard-redesign.md
   Handoff: bi-dashboard-v2 (Claude design 2026-05-19/20)

   Scope:
   - KPI cards (white with color accent stripe)
   - Insights "Resumen del periodo" (Beta) collapsible block
   - Top-N widget chrome (donut vs bars toggle)
   - Money widget chrome (table vs bars toggle, alternating rows)
   - Foot-note at the bottom
   ===================================================================== */

.dash-redesign { font-family: 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif; color: #2d353c; }

/* ---------- Page head ---------- */
.dash-redesign .page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 18px; gap: 16px; flex-wrap: wrap;
  padding-bottom: 12px; border-bottom: 1px solid #eee;
}
.dash-redesign .page-head__title {
  font-size: 26px; font-weight: 300; color: #2d353c; margin: 0; line-height: 1.1;
}
.dash-redesign .page-head__title small { color: #6c757d; font-size: 14px; font-weight: 300; margin-left: 8px; }
.dash-redesign .page-head__actions { display: flex; align-items: center; gap: 12px; }
.dash-redesign .page-head__hint {
  color: #6c757d; font-size: 13px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color .15s ease;
}
.dash-redesign .page-head__hint:hover,
.dash-redesign .page-head__hint:focus { color: #00acac; text-decoration: none; outline: none; }

/* ---------- KPI cards (Variant A) ---------- */
.dash-redesign .kpi-row {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 18px;
}
.dash-redesign .kpi-card {
  background: #fff; border-radius: 6px; padding: 16px 16px 14px;
  position: relative; overflow: hidden;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
  transition: transform .15s ease, box-shadow .15s ease;
  min-height: 110px;
}
.dash-redesign .kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(45,53,60,.08); }
.dash-redesign .kpi-card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: var(--accent, #00acac);
}
.dash-redesign .kpi-card__row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.dash-redesign .kpi-card__label {
  font-size: 11.5px; color: #6c757d; line-height: 1.3;
  text-transform: uppercase; letter-spacing: .04em;
}
.dash-redesign .kpi-card__icon {
  width: 28px; height: 28px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--accent, #00acac);
  background: var(--accent-soft, rgba(0,172,172,.08));
  flex-shrink: 0;
}
.dash-redesign .kpi-card__value {
  font-size: 30px; font-weight: 300; color: #2d353c; line-height: 1.1; margin-top: 10px;
}
.dash-redesign .kpi-card__value.is-zero { color: #b6c2c9; }
.dash-redesign .kpi-card__value .spinner { font-size: 16px; color: #b6c2c9; }
.dash-redesign .kpi-card__foot { font-size: 11px; color: #9ca3af; margin-top: 4px; }

.dash-redesign .kpi-card[data-tone="red"]    { --accent: #ff5b57; --accent-soft: rgba(255,91,87,.10); }
.dash-redesign .kpi-card[data-tone="blue"]   { --accent: #348fe2; --accent-soft: rgba(52,143,226,.10); }
.dash-redesign .kpi-card[data-tone="grey"]   { --accent: #8b97a1; --accent-soft: rgba(139,151,161,.12); }
.dash-redesign .kpi-card[data-tone="teal"]   { --accent: #00acac; --accent-soft: rgba(0,172,172,.10); }
.dash-redesign .kpi-card[data-tone="purple"] { --accent: #727cb6; --accent-soft: rgba(114,124,182,.12); }
.dash-redesign .kpi-card[data-tone="aqua"]   { --accent: #49b6d6; --accent-soft: rgba(73,182,214,.12); }

/* ---------- Insights · "Resumen del periodo" (Beta) ---------- */
.dash-redesign .insights {
  background: #fff; border-radius: 6px;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
  margin-bottom: 18px;
  border-left: 3px solid #8a6dd1;
  overflow: hidden;
}
.dash-redesign .insights[open] > summary .insights__caret { transform: rotate(180deg); }
.dash-redesign .insights > summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: 14px 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.dash-redesign .insights > summary::-webkit-details-marker { display: none; }
.dash-redesign .insights > summary:hover { background: #fbfafd; }
.dash-redesign .insights > summary:focus-visible { outline: 2px solid #8a6dd1; outline-offset: -2px; }
.dash-redesign .insights__body { padding: 4px 22px 18px; }
.dash-redesign .insights__head {
  display: flex; align-items: center; gap: 10px; flex: 1 1 auto; flex-wrap: wrap; min-width: 0;
}
.dash-redesign .insights__title {
  font-size: 13px; font-weight: 600; color: #2d353c; margin: 0;
  display: inline-flex; align-items: center; gap: 8px;
}
.dash-redesign .insights__title i { color: #8a6dd1; }
.dash-redesign .insights__hint {
  font-size: 11.5px; color: #6c757d;
  background: #f4f9fb; border-left: 3px solid #49b6d6;
  padding: 6px 10px; border-radius: 3px;
  display: inline-flex; align-items: center; gap: 6px;
}
.dash-redesign .insights__hint i { color: #49b6d6; }
.dash-redesign .insights__caret {
  margin-left: auto; color: #9ca3af; font-size: 11px;
  transition: transform .18s ease; flex: 0 0 auto;
}

.dash-redesign .beta-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: #6b4fc4;
  background:
    repeating-linear-gradient(135deg, rgba(138,109,209,.10) 0 4px, rgba(138,109,209,.04) 4px 8px),
    #f3effb;
  border: 1px solid rgba(138,109,209,.35);
  padding: 2px 7px 2px 6px; border-radius: 999px; line-height: 1.4;
  position: relative;
}
.dash-redesign .beta-badge i { font-size: 9.5px; }
.dash-redesign .beta-badge[data-tooltip] { cursor: help; }
.dash-redesign .beta-badge[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; top: calc(100% + 6px); left: 0;
  background: #2d353c; color: #fff; font-size: 11px; font-weight: 400;
  letter-spacing: 0; text-transform: none;
  padding: 6px 9px; border-radius: 4px; white-space: normal;
  width: max-content; max-width: 280px; z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.dash-redesign .insights__disclaimer {
  font-size: 11px; color: #8a6dd1;
  background: #f6f3fc; border-radius: 4px;
  padding: 7px 10px; margin-top: 12px;
  display: flex; align-items: flex-start; gap: 7px; line-height: 1.45;
}
.dash-redesign .insights__disclaimer i { color: #8a6dd1; margin-top: 1px; }

.dash-redesign .ins-head { padding: 4px 0 14px; border-bottom: 1px solid #f3f5f7; margin-bottom: 12px; }
.dash-redesign .ins-head__line { font-size: 20px; font-weight: 300; color: #2d353c; line-height: 1.3; }
.dash-redesign .ins-head__pct {
  display: inline-block; padding: 1px 10px; border-radius: 4px;
  font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums;
}
.dash-redesign .ins-head__pct--neg { color: #ff5b57; outline: 2px solid #348fe2; outline-offset: 2px; }
.dash-redesign .ins-head__pct--pos { color: #00acac; outline: 2px solid #00acac; outline-offset: 2px; }
.dash-redesign .ins-head__sub { font-size: 12px; color: #6c757d; margin-top: 10px; }
.dash-redesign .ins-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.dash-redesign .ins-item {
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 13px; color: #2d353c; line-height: 1.5;
}
.dash-redesign .ins-item b { font-weight: 600; }
.dash-redesign .ins-item__icon {
  flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px;
}
.dash-redesign .ins-item--neg .ins-item__icon  { background: rgba(255,91,87,.12); color: #ff5b57; }
.dash-redesign .ins-item--warn .ins-item__icon { background: rgba(245,156,26,.14); color: #f59c1a; }
.dash-redesign .ins-item--pos .ins-item__icon  { background: rgba(0,172,172,.12); color: #00acac; }
.dash-redesign .ins-item__text { padding-top: 1px; }

/* ---------- Shared cards ---------- */
.dash-redesign .dash-card {
  background: #fff; border-radius: 6px; padding: 16px 20px;
  box-shadow: 0 1px 0 rgba(0,0,0,.04); margin-bottom: 16px;
}
.dash-redesign .dash-card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.dash-redesign .dash-card__title {
  font-size: 13px; font-weight: 600; color: #2d353c; margin: 0;
  display: flex; align-items: center; gap: 8px;
}
.dash-redesign .dash-card__title i { color: #00acac; }
.dash-redesign .dash-card__sub { font-size: 11px; color: #9ca3af; }
.dash-redesign .dash-card__tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Sales/Buys legend row (in header) */
.dash-redesign .legend-row { display: flex; gap: 18px; align-items: center; font-size: 12px; flex-wrap: wrap; }
.dash-redesign .legend-row .legend-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  vertical-align: -1px; margin-right: 6px;
}
.dash-redesign .legend-row b { font-weight: 700; }
.dash-redesign .legend-row .legend-muted { color: #6c757d; }

/* ---------- Viz toggle (donut/bars or bars/table) ---------- */
.dash-redesign .viz-toggle {
  display: inline-flex; border: 1px solid #e1e5e9; border-radius: 4px; overflow: hidden;
  background: #fff;
}
.dash-redesign .viz-toggle button {
  background: #fff; color: #6c757d; border: 0;
  font: inherit; font-size: 11px; padding: 5px 9px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; line-height: 1;
}
.dash-redesign .viz-toggle button + button { border-left: 1px solid #e1e5e9; }
.dash-redesign .viz-toggle button.is-active { background: #00acac; color: #fff; }
.dash-redesign .viz-toggle button:hover:not(.is-active) { background: #f4f6f7; color: #2d353c; }

/* ---------- Top widgets grid (donut/bars) ----------
   IMPORTANT: usamos minmax(0, 1fr) en lugar de 1fr porque el default `1fr`
   se resuelve como `minmax(auto, 1fr)`, lo que deja a la celda crecer más
   allá de su tercio cuando el contenido lo empuja (p.ej. una <table> en modo
   tabla con nombres de servicio largos como "Transfer Punto a Punto..."
   forzaba la celda a expandirse y cambiar el ancho al togglear bars↔table).
   minmax(0, 1fr) clampa la celda a exactamente 1fr. */
.dash-redesign .tops-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

/* Stable card height across mode toggles — prevents the layout from jumping
   when the user flips donut↔bars or bars↔table. Each card is at least as tall
   as its tallest mode. The widget that shows utility sub-lines per row
   (topCustomersSales) needs more room than the rest. CSS grid stretches all
   cards in a row to match the tallest, so visual symmetry is preserved. */
.dash-redesign .tops-grid > .dash-card { min-height: 340px; }
.dash-redesign #TopCustomersSales30d { min-height: 430px; }

/* Donut container — overlay on existing Flot donut */
.dash-redesign .donut-block { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: center; }
.dash-redesign .donut-host { position: relative; height: 200px; }
.dash-redesign .donut-center {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
.dash-redesign .donut-center .donut-label {
  font-size: 10px; color: #6c757d; letter-spacing: .04em; text-transform: uppercase;
}
.dash-redesign .donut-center .donut-total { font-size: 24px; font-weight: 700; color: #2d353c; }

.dash-redesign .donut-legend { font-size: 12px; min-width: 0; }
.dash-redesign .donut-legend .lg-row {
  display: grid; grid-template-columns: 14px 1fr auto auto; gap: 8px;
  padding: 4px 0; align-items: center;
}
.dash-redesign .donut-legend .lg-row + .lg-row { border-top: 1px solid #f3f5f7; }
.dash-redesign .donut-legend .lg-dot { width: 10px; height: 10px; border-radius: 2px; }
.dash-redesign .donut-legend .lg-name {
  color: #2d353c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.dash-redesign .donut-legend .lg-n {
  color: #2d353c; font-weight: 600; text-align: right; min-width: 32px;
}
.dash-redesign .donut-legend .lg-pct {
  color: #6c757d; min-width: 38px; text-align: right;
}

/* Bars view of count-based Top-N */
.dash-redesign .bars-head {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px;
  padding-bottom: 10px; border-bottom: 1px solid #f3f5f7;
}
.dash-redesign .bars-head__total {
  font-size: 26px; font-weight: 300; color: #2d353c; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.dash-redesign .bars-head__label {
  font-size: 10.5px; color: #9ca3af; letter-spacing: .08em; text-transform: uppercase;
}

.dash-redesign .top-bars, .dash-redesign .money-bars {
  display: flex; flex-direction: column; gap: 14px;
}
.dash-redesign .mb-row { display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.dash-redesign .mb-row:hover .mb-name { color: #00acac; }
.dash-redesign .mb-row__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 12.5px;
}
.dash-redesign .mb-name {
  color: #2d353c; font-weight: 500;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .02em; font-size: 11.5px;
}
.dash-redesign .mb-vals {
  display: inline-flex; align-items: baseline; gap: 8px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.dash-redesign .mb-vals b { color: #2d353c; font-weight: 700; font-size: 12.5px; }
.dash-redesign .mb-pct { color: #9ca3af; font-size: 11px; min-width: 28px; text-align: right; }
.dash-redesign .mb-sub { font-size: 11px; color: #9ca3af; display: flex; align-items: center; gap: 8px; }
.dash-redesign .mb-badge {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700;
}
.dash-redesign .mb-badge--pos { background: rgba(0,172,172,.10); color: #00acac; }
.dash-redesign .mb-badge--neu { background: #f0f2f4; color: #6c757d; }
.dash-redesign .mb-badge--neg { background: rgba(255,91,87,.10); color: #ff5b57; }
.dash-redesign .mb-track { height: 4px; background: #f0f2f4; border-radius: 2px; overflow: hidden; }
.dash-redesign .mb-fill { display: block; height: 100%; border-radius: 2px; transition: width .4s ease; }

/* ---------- Money tables (table mode) ----------
   `table-layout: fixed` evita que columnas con contenido largo (nombres de
   servicios o de clientes) deformen el ancho — combinado con el clamp del
   grid arriba, garantiza que el card NO cambie de ancho al togglear modes.
   `word-break: break-word` deja que los nombres muy largos rompan a varias
   líneas en vez de salirse o forzar overflow horizontal. */
.dash-redesign .table-clean { width: 100%; font-size: 12.5px; margin: 0; table-layout: fixed; }
.dash-redesign .table-clean th {
  font-weight: 600; color: #6c757d; font-size: 11px; letter-spacing: .04em;
  text-transform: uppercase; padding: 10px 12px; border-bottom: 1px solid #eef0f2;
  text-align: left;
}
.dash-redesign .table-clean th.is-num,
.dash-redesign .table-clean td.is-num {
  text-align: right; font-variant-numeric: tabular-nums; width: 130px;
}
.dash-redesign .table-clean td {
  padding: 10px 12px; border-bottom: 1px solid #f3f5f7; color: #2d353c;
  word-break: break-word;
}
.dash-redesign .table-clean tbody tr:nth-child(even) td { background: #fafbfc; }
.dash-redesign .table-clean tbody tr:hover td { background: #eef7f7; }
.dash-redesign .table-clean .num-pos { color: #00acac; font-weight: 600; }

/* Empty state */
.dash-redesign .empty { text-align: center; padding: 32px 16px; color: #9ca3af; font-size: 12.5px; }
.dash-redesign .empty i { font-size: 28px; display: block; margin-bottom: 8px; opacity: .5; }

/* ---------- Foot-note ---------- */
.dash-redesign .foot-note {
  margin-top: 22px; padding: 12px 16px; border-radius: 6px;
  background: #fff; border-left: 3px solid #00acac;
  font-size: 12px; color: #6c757d; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.dash-redesign .foot-note i { color: #00acac; }
.dash-redesign .foot-note a {
  margin-left: auto; color: #00acac; text-decoration: underline; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}

/* ---------- Loading spinner inside KPI ---------- */
.dash-redesign .kpi-card__value .fa-spinner { color: var(--accent, #00acac); font-size: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .dash-redesign .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .dash-redesign .tops-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-redesign .donut-block { grid-template-columns: 180px minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .dash-redesign .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .dash-redesign .donut-block { grid-template-columns: 1fr; }
}
