/* ============================================================
   Delivery v2 — Command Center + vista individual (.d2-*)
   Scoped a .rai-delivery: reusa los tokens warm-dark del shell
   (delivery.css) — superficies, fg, borders, success/danger.
   Paleta de charts en dlv2Charts.js (familia cálida slots fijos).
   Verde/rojo SOLO en chips de delta y estados — jamás como serie.
   ============================================================ */

.rai-delivery .d2-page {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
  padding-bottom: 40px;
}

/* ── Barra de página (fusión 2026-08-20: crumb + Export/Resty del v1) ── */
.rai-delivery .d2-pagebar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.rai-delivery .d2-pagebar-actions { display: flex; gap: 8px; }
.rai-delivery .d2-pagebar .d2-btn { display: inline-flex; align-items: center; gap: 6px; }
.rai-delivery .d2-pagebar .d2-btn svg { display: block; }

/* ── Cards / secciones ── */
.rai-delivery .d2-card,
.rai-delivery .d2-hero {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg, 14px);
  padding: 20px 22px;
}
.rai-delivery .d2-section-head {
  display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px;
}
.rai-delivery .d2-section-num {
  font: 700 26px/1 var(--font-display); color: var(--brand); opacity: 0.55;
  letter-spacing: -0.02em;
}
.rai-delivery .d2-section-title { font: 600 15px/1.2 var(--font-ui); color: var(--fg-1); }
.rai-delivery .d2-section-sub { font: 400 11.5px/1.5 var(--font-ui); color: var(--fg-3); margin-top: 3px; max-width: 720px; }

/* ── Hero ── */
.rai-delivery .d2-eyebrow {
  font: 600 11px/1 var(--font-ui); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--fg-3); margin-bottom: 12px;
}
.rai-delivery .d2-hero-row { display: flex; align-items: flex-end; gap: 22px; flex-wrap: wrap; }
.rai-delivery .d2-hero-num {
  font: 700 54px/1 var(--font-display); color: var(--fg-1);
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.rai-delivery .d2-hero-lbl { font: 400 12.5px/1.4 var(--font-ui); color: var(--fg-3); margin-top: 8px; }
.rai-delivery .d2-hero-chips { display: flex; gap: 8px; padding-bottom: 26px; }
.rai-delivery .d2-hero-sub { font: 400 13px/1.5 var(--font-ui); color: var(--fg-2); margin-top: 14px; }
.rai-delivery .d2-hero-sub .d2-ok { color: var(--success); }
.rai-delivery .d2-hero-sub .d2-warn { color: var(--warning); }
.rai-delivery .d2-hero-state { display: flex; align-items: center; gap: 8px; padding-bottom: 30px; }
.rai-delivery .d2-hero-state-lbl { font: 600 14px var(--font-ui); color: var(--fg-1); }
.rai-delivery .d2-hero-frase { font: 400 12.5px/1.5 var(--font-ui); color: var(--fg-2); margin-top: 10px; }
.rai-delivery .d2-hero-kpirow {
  display: flex; gap: 22px; flex-wrap: wrap; margin-top: 16px;
  padding-top: 14px; border-top: 1px solid var(--divider);
  font: 400 12.5px var(--font-ui); color: var(--fg-3);
  align-items: center;
}
.rai-delivery .d2-hero-kpirow strong { color: var(--fg-1); font-variant-numeric: tabular-nums; }

/* ── Chips de delta (único punto de entrada del verde/rojo) ── */
.rai-delivery .d2-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font: 600 10.5px/1 var(--font-ui); font-variant-numeric: tabular-nums;
  padding: 3px 7px; border-radius: 999px; white-space: nowrap;
}
.rai-delivery .d2-chip.up   { color: var(--success); background: var(--success-bg); }
.rai-delivery .d2-chip.down { color: var(--danger);  background: var(--danger-bg); }
.rai-delivery .d2-chip.flat { color: var(--fg-3);    background: var(--surface-2); }
.rai-delivery .d2-chip.na   { color: var(--fg-muted); background: var(--surface-2); font-weight: 400; }

/* ── KPI row 4-up (hairlines por gap 1px) ── */
.rai-delivery .d2-kpis {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--border-subtle); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg, 14px); overflow: hidden;
}
.rai-delivery .d2-kpi { background: var(--surface-1); padding: 16px 18px; display: grid; gap: 8px; align-content: start; }
.rai-delivery .d2-kpi-label { font: 600 11px/1 var(--font-ui); text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-3); }
.rai-delivery .d2-kpi-val { font: 700 24px/1 var(--font-display); color: var(--fg-1); font-variant-numeric: tabular-nums; }
.rai-delivery .d2-kpi-deltas { display: flex; gap: 6px; flex-wrap: wrap; }
.rai-delivery .d2-spark { display: block; opacity: 0.9; }

/* ── Semáforo: dots ── */
.rai-delivery .d2-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none;
}
.rai-delivery .d2-dot.green { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.rai-delivery .d2-dot.amber { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-bg); }
.rai-delivery .d2-dot.red   { background: var(--danger);  box-shadow: 0 0 0 3px var(--danger-bg); }
.rai-delivery .d2-dot.gray  { background: var(--fg-muted); box-shadow: 0 0 0 3px var(--surface-2); }

/* ── Tabla-semáforo ── */
.rai-delivery .d2-table-scroll { overflow-x: auto; }
.rai-delivery .d2-table { width: 100%; border-collapse: collapse; font: 400 12.5px var(--font-ui); }
.rai-delivery .d2-table th {
  text-align: left; font: 600 10.5px/1 var(--font-ui); text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--fg-muted); padding: 8px 10px;
  border-bottom: 1px solid var(--border-default);
}
.rai-delivery .d2-table td { padding: 10px; border-bottom: 1px solid var(--divider); color: var(--fg-2); vertical-align: middle; }
.rai-delivery .d2-row { cursor: pointer; }
.rai-delivery .d2-row:hover td { background: var(--surface-2); }
.rai-delivery .d2-td-state { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.rai-delivery .d2-state-lbl { font: 600 11.5px var(--font-ui); color: var(--fg-2); }
.rai-delivery .d2-td-name strong { color: var(--fg-1); font-weight: 600; display: block; }
.rai-delivery .d2-td-loc { font-size: 11px; color: var(--fg-3); }
.rai-delivery .d2-td-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rai-delivery .d2-mini-deltas { display: block; margin-top: 3px; }
.rai-delivery .d2-mini-deltas .d2-chip { padding: 2px 5px; font-size: 9.5px; }
.rai-delivery .d2-na { color: var(--fg-muted); }
.rai-delivery .d2-promo-count {
  font: 600 11px var(--font-ui); color: var(--brand);
  background: var(--brand-soft); padding: 3px 8px; border-radius: 999px; cursor: help;
}

/* Mini-banda de payout inline */
.rai-delivery .d2-bandcell { display: inline-grid; gap: 4px; min-width: 84px; }
.rai-delivery .d2-bandcell-val { font: 600 12px var(--font-ui); color: var(--fg-2); font-variant-numeric: tabular-nums; }
.rai-delivery .d2-bandcell-val.ok { color: var(--success); }
.rai-delivery .d2-bandcell.low .d2-bandcell-val { color: var(--warning); }
.rai-delivery .d2-bandcell.crit .d2-bandcell-val { color: var(--danger); }
.rai-delivery .d2-bandcell-bar {
  position: relative; height: 5px; border-radius: 3px; background: var(--surface-3);
  display: block; overflow: visible;
}
.rai-delivery .d2-bandcell-band {
  position: absolute; top: 0; bottom: 0; background: var(--success-bg);
  border-left: 1px solid var(--success); border-right: 1px solid var(--success);
  opacity: 0.9;
}
.rai-delivery .d2-bandcell-dot {
  position: absolute; top: -2.5px; width: 4px; height: 10px; margin-left: -2px;
  border-radius: 2px; background: var(--fg-1);
}

/* ── Needs attention ── */
.rai-delivery .d2-att-list { display: grid; gap: 8px; }
.rai-delivery .d2-att {
  display: flex; align-items: flex-start; gap: 10px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 10px); padding: 10px 12px; cursor: pointer;
  color: inherit; font: inherit; width: 100%;
}
.rai-delivery .d2-att:hover { border-color: var(--border-default); }
.rai-delivery .d2-att-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; flex: none; }
.rai-delivery .d2-att-dot.red   { background: var(--danger); }
.rai-delivery .d2-att-dot.amber { background: var(--warning); }
.rai-delivery .d2-att-dot.info  { background: var(--info); }
.rai-delivery .d2-att-t { display: block; font: 600 12.5px var(--font-ui); color: var(--fg-1); }
.rai-delivery .d2-att-d { display: block; font: 400 11.5px/1.45 var(--font-ui); color: var(--fg-3); margin-top: 2px; }
.rai-delivery .d2-allgood { display: flex; align-items: center; gap: 12px; }
.rai-delivery .d2-allgood-pill {
  font: 600 11px var(--font-ui); color: var(--success); background: var(--success-bg);
  padding: 4px 10px; border-radius: 999px;
}
.rai-delivery .d2-allgood-txt { font: 400 12px var(--font-ui); color: var(--fg-3); }

/* ── Charts wrap + leyenda ── */
.rai-delivery .d2-chart-wrap { overflow-x: auto; }
.rai-delivery .d2-legend {
  display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px;
  font: 400 11px var(--font-ui); color: var(--fg-3);
}
.rai-delivery .d2-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rai-delivery .d2-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.rai-delivery .d2-legend i.d2-legend-line { height: 3px; border-radius: 2px; width: 14px; }

/* ── Details (secundario colapsado por default) ── */
.rai-delivery .d2-details summary {
  cursor: pointer; font: 600 12.5px var(--font-ui); color: var(--fg-2);
  padding: 6px 0; list-style: none; display: flex; align-items: center; gap: 10px;
}
.rai-delivery .d2-details summary::-webkit-details-marker { display: none; }
.rai-delivery .d2-details summary::after { content: '▾'; color: var(--fg-muted); font-size: 10px; }
.rai-delivery .d2-details[open] summary::after { content: '▴'; }
.rai-delivery .d2-details > *:not(summary) { margin-top: 10px; }
.rai-delivery .d2-wf-table td { padding: 6px 10px; }
.rai-delivery .d2-wf-total td { color: var(--fg-1); font-weight: 600; border-top: 1px solid var(--border-default); }

/* ── Promos ── */
.rai-delivery .d2-promo-block { margin-bottom: 16px; }
.rai-delivery .d2-promo-head { font: 600 12px var(--font-ui); color: var(--fg-2); margin-bottom: 8px; }
.rai-delivery .d2-promo-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.rai-delivery .d2-promo-kind {
  font: 600 10px var(--font-ui); text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--fg-muted); margin-right: 6px;
}
.rai-delivery .d2-promo-item {
  display: inline-block; font: 500 12px var(--font-ui); color: var(--fg-1);
  background: var(--surface-2); border: 1px solid var(--border-subtle);
  padding: 3px 9px; border-radius: 999px; margin: 2px 2px 2px 0;
}
.rai-delivery .d2-promo-math {
  display: grid; gap: 6px; font: 400 12px/1.5 var(--font-ui); color: var(--fg-3);
  border-left: 2px solid var(--brand-soft-hi); padding-left: 12px;
}
.rai-delivery .d2-promo-math strong { color: var(--fg-1); font-variant-numeric: tabular-nums; }
.rai-delivery .d2-promo-math em { font-style: normal; color: var(--fg-muted); font-size: 11px; }
.rai-delivery .d2-oppnote {
  margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-md, 10px);
  background: var(--brand-soft); color: var(--fg-1);
  font: 400 12px/1.5 var(--font-ui); border: 1px solid var(--border-default);
}

/* ── Operación ── */
.rai-delivery .d2-ops-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 14px; }
.rai-delivery .d2-ops-cell { background: var(--surface-2); border-radius: var(--radius-md, 10px); padding: 10px 12px; }
.rai-delivery .d2-ops-lbl { font: 600 10px var(--font-ui); text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted); }
.rai-delivery .d2-ops-val { font: 600 15px var(--font-display); color: var(--fg-1); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ── Estados vacíos / carga / error (honestos, 1 línea) ── */
.rai-delivery .d2-slimstrip {
  font: 400 12px var(--font-ui); color: var(--fg-3);
  background: var(--surface-2); border: 1px dashed var(--border-default);
  border-radius: var(--radius-md, 10px); padding: 10px 14px; margin-bottom: 8px;
}
.rai-delivery .d2-loading { font: 400 13px var(--font-ui); color: var(--fg-3); padding: 30px 0; text-align: center; }
.rai-delivery .d2-error {
  background: var(--danger-bg); border: 1px solid var(--danger);
  border-radius: var(--radius-lg, 14px); padding: 18px 20px;
}
.rai-delivery .d2-error-t { font: 600 14px var(--font-ui); color: var(--fg-1); }
.rai-delivery .d2-error-s { font: 400 12px/1.5 var(--font-ui); color: var(--fg-2); margin: 6px 0 12px; }

/* ── Botones / navegación ── */
.rai-delivery .d2-btn {
  font: 600 12px var(--font-ui); color: var(--fg-2);
  background: var(--surface-2); border: 1px solid var(--border-default);
  border-radius: var(--radius-md, 10px); padding: 7px 14px; cursor: pointer;
}
.rai-delivery .d2-btn:hover { border-color: var(--border-strong); color: var(--fg-1); }
.rai-delivery .d2-cv-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.rai-delivery .d2-cv-title { font: 600 16px var(--font-ui); color: var(--fg-1); }
.rai-delivery .d2-scope-chips { display: flex; gap: 6px; margin-left: auto; }
.rai-delivery .d2-scope {
  font: 600 11px var(--font-ui); color: var(--fg-3); background: transparent;
  border: 1px solid var(--border-default); border-radius: 999px; padding: 5px 12px; cursor: pointer;
}
.rai-delivery .d2-scope.on { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.rai-delivery .d2-resty-strip {
  display: flex; align-items: center; gap: 14px; justify-content: center;
  font: 400 12.5px var(--font-ui); color: var(--fg-3); padding: 6px 0 20px;
}
.rai-delivery .d2-foot {
  font: 400 11px var(--font-ui); color: var(--fg-muted); text-align: center; padding: 4px 0 10px;
}

/* ── Responsive ── */
@media (max-width: 980px) {
  .rai-delivery .d2-kpis { grid-template-columns: repeat(2, 1fr); }
  .rai-delivery .d2-ops-grid { grid-template-columns: repeat(3, 1fr); }
  .rai-delivery .d2-hero-num { font-size: 40px; }
}
