/* ================================================================
   Bahía Motors — Dashboards v4.2 (modular + tabs)
   ================================================================ */

[hidden] { display: none !important; }

:root {
  /* Brand greens */
  --green-primary: #009E83;
  --green-deep:    #033932;

  --green-950: #022722;
  --green-900: #033932;
  --green-800: #015a4d;
  --green-700: #007a66;
  --green-600: #009E83;
  --green-500: #1cb19a;

  /* Complementaria */
  --teal-light:  #95D7D1;
  --green-mint:  #C4EFD8;
  --gray-deep:   #2F3138;
  --gray-soft:   #BEBEBE;

  /* Superficies */
  --surface-page: #F7F7F4;
  --surface-card: #FFFFFF;

  /* Texto */
  --text-strong: #033932;
  --text-base:   #2F3138;
  --text-muted:  #6b7280;

  /* Bordes */
  --border-soft:   #E8E6DF;
  --border-strong: #BEBEBE;

  /* Radios */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text-base);
  background: var(--surface-page);
  /* Evitar scroll horizontal accidental por algún elemento que se exceda */
  overflow-x: hidden;
  max-width: 100vw;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Tabs principales (módulos) ─────────────────────────────── */

.primary-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 1.5rem;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.primary-tab {
  position: relative;
  padding: 0.95rem 1.4rem;
  border: 0;
  background: transparent;
  font-family: "Instrument Serif", serif;
  font-size: 19px;
  letter-spacing: -0.005em;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease;
}

.primary-tab:hover {
  color: var(--text-strong);
}

.primary-tab.is-active {
  color: var(--text-strong);
  font-weight: 500;
}

.primary-tab.is-active::after {
  content: "";
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: -1px;
  height: 3px;
  background: var(--green-primary);
  border-radius: 3px 3px 0 0;
}

/* ─── Sub-tabs (vistas dentro del módulo) ────────────────────── */

.sub-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 0;
  margin-bottom: 0.5rem;
}

.sub-tab {
  padding: 0.6rem 1rem;
  border: 0;
  background: transparent;
  font-family: "Manrope", sans-serif;
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  margin-bottom: -1px;
}

.sub-tab:hover {
  color: var(--text-strong);
}

.sub-tab.is-active {
  color: var(--green-deep);
  border-bottom-color: var(--green-primary);
}

/* ─── Layout dashboard ──────────────────────────────────────── */

.dashboard {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Grids reutilizables */

.grid-kpis-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.grid-kpis-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.grid-kpis-five {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

.grid-charts-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.grid-charts-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

/* Vista Clientes: mapa a la izquierda (más ancho) + 2 donuts a la derecha */
.grid-clientes {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}

.grid-donuts {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 1280px) {
  .grid-kpis-five { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1100px) {
  .grid-kpis-row,
  .grid-charts-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-charts-2,
  .grid-clientes { grid-template-columns: 1fr; }
  .grid-donuts   { grid-template-rows: auto auto; grid-template-columns: 1fr 1fr; }
  .grid-kpis-five { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .grid-kpis-row,
  .grid-charts-3,
  .grid-kpis-hero,
  .grid-kpis-five { grid-template-columns: 1fr; }
  .grid-donuts    { grid-template-columns: 1fr; }
}

/* Loaders / errores */

.dashboard-loading {
  flex: 1;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

.dashboard-loading.error {
  color: #b91c1c;
}

/* ─── Sub-tab Mercado: header con título + subtítulo (v6.3.0/v6.12.5) ─ */
.mercado-header {
  margin: 0 0 1rem 0;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e5e7eb;
}
/* Título del sub-tab — TOP de la jerarquía. Instrument Serif weight 500.
   "Estudio de Mercado", "Resumen", "Clientes", "Reservas", etc. usan
   esta clase para mantener la familia tipográfica consistente. */
.mercado-title {
  font-family: "Instrument Serif", serif;
  font-size: 2.2rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin: 0 0 0.25rem 0;
  color: #033932;
}
.mercado-subtitle {
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 0.78rem;
  color: #6b7280;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}
.mercado-placeholder {
  margin-top: 1.5rem;
  padding: 2rem 1rem;
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  border-radius: 8px;
  text-align: center;
  color: #6b7280;
  font-size: 0.9rem;
  font-style: italic;
}

/* ─── Chart Top Marcas (Mercado v6.4.0) ─────────────────────── */
bm-chart-mercado-top-marcas .chart-body {
  /* Más altura porque son 10 barras horizontales agrupadas */
  height: 380px;
}
.mercado-marcas-legend {
  margin-top: 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.mercado-marca-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1fr 0.8fr 0.7fr;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.78rem;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
}
.mercado-marca-row:nth-child(odd) {
  background: #f9fafb;
}
.mm-marca { font-weight: 600; color: #033932; }
.mm-actual { font-variant-numeric: tabular-nums; font-weight: 600; }
.mm-ly { color: #6b7280; font-variant-numeric: tabular-nums; }
.mm-growth { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.mm-growth.positive { color: #047857; }
.mm-growth.negative { color: #b91c1c; }
.mm-growth.neutral { color: #6b7280; }
.mm-share { color: #6b7280; font-variant-numeric: tabular-nums; text-align: right; }

@media (max-width: 720px) {
  .mercado-marca-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
    font-size: 0.75rem;
  }
  .mm-ly, .mm-share { display: none; }
}

/* ─── Top 20 Modelos table (Mercado v6.5.0) ─────────────────── */
.modelos-table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
}
.modelos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.modelos-table thead th {
  text-align: left;
  font-weight: 600;
  color: #033932;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid #033932;
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 1;
}
.modelos-table thead th.col-num,
.modelos-table thead th.col-pct {
  text-align: right;
}
.modelos-table tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #f3f4f6;
}
.modelos-table tbody tr:nth-child(even) td {
  background: #fafafa;
}
.modelos-table tbody tr:hover td {
  background: #ecfdf5;
}
.modelos-table .col-modelo {
  font-weight: 600;
  color: #033932;
}
.modelos-table .col-marca {
  color: #6b7280;
  font-size: 0.78rem;
}
.modelos-table .col-num {
  text-align: right;
  font-weight: 500;
}
.modelos-table .col-pct {
  text-align: right;
  white-space: nowrap;
}
.modelos-table .col-pct.positive { color: #047857; }
.modelos-table .col-pct.negative { color: #b91c1c; }
.modelos-table .col-pct.neutral  { color: #6b7280; }
.growth-arrow { display: inline-block; margin-right: 2px; font-size: 0.7rem; }
.growth-arrow.up    { color: #047857; }
.growth-arrow.down  { color: #b91c1c; }
.growth-arrow.neutral { color: #9ca3af; }
.growth-num { font-weight: 600; }

.modelos-table tfoot .total-row td {
  padding: 0.7rem 0.75rem;
  border-top: 2px solid #033932;
  background: #f3f4f6;
  font-weight: 700;
  font-size: 0.85rem;
}
.modelos-table tfoot .total-row .col-modelo {
  color: #033932;
}

.modelos-table tbody .empty-row td {
  text-align: center;
  color: #6b7280;
  font-style: italic;
  padding: 1.5rem;
  background: #fafafa;
}

@media (max-width: 720px) {
  .modelos-table { font-size: 0.75rem; }
  .modelos-table thead th,
  .modelos-table tbody td { padding: 0.4rem 0.5rem; }
  .modelos-table .col-marca { display: none; }
  .modelos-table thead th.col-marca { display: none; }
}

/* ─── Top 20 Marcas Detalle (Mercado v6.6.0) ────────────────── */
.marcas-detalle-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
  /* Borde sutil para que se vea que hay scroll horizontal */
  border-radius: 4px;
}
.marcas-detalle-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  min-width: 1100px;     /* fuerza horizontal scroll en pantallas más chicas */
}
.marcas-detalle-table thead th {
  text-align: right;
  font-weight: 600;
  color: #033932;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.55rem 0.55rem;
  border-bottom: 2px solid #033932;
  background: #f9fafb;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.marcas-detalle-table thead th .hdr-sub {
  display: block;
  font-size: 0.6rem;
  color: #6b7280;
  font-weight: 500;
  margin-top: 2px;
  text-transform: none;
  letter-spacing: 0;
}
.marcas-detalle-table thead th.col-rank,
.marcas-detalle-table thead th.col-marca { text-align: left; }

/* v6.16.4 — sort interactivo en columnas numéricas. El cursor cambia a
   pointer; hover sutil; indicador ↑/↓ visible cuando la columna está
   ordenada. Las columnas sin sort (Rank y Marca) no tienen .sortable. */
.marcas-detalle-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease;
}
.marcas-detalle-table thead th.sortable:hover {
  background: #eef2f5;
}
.marcas-detalle-table thead th .sort-ind {
  display: inline-block;
  width: 0.85em;
  margin-left: 0.2em;
  font-size: 0.85em;
  color: #9ca3af;
  transition: color 0.12s ease;
}
.marcas-detalle-table thead th .sort-ind.active {
  color: #033932;
  font-weight: 700;
}
.marcas-detalle-table tbody td {
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid #f3f4f6;
}
.marcas-detalle-table tbody tr:nth-child(even) td {
  background: #fafafa;
}
.marcas-detalle-table tbody tr:hover td {
  background: #ecfdf5;
}
.marcas-detalle-table .col-rank {
  text-align: center;
  color: #6b7280;
  font-weight: 500;
  width: 36px;
}
.marcas-detalle-table .col-marca {
  font-weight: 600;
  color: #033932;
  text-align: left;
  white-space: nowrap;
  min-width: 130px;
}
.marcas-detalle-table .col-num {
  text-align: right;
  font-weight: 500;
  white-space: nowrap;
}
.marcas-detalle-table .col-pct {
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
}
.marcas-detalle-table .col-pct.positive { color: #047857; }
.marcas-detalle-table .col-pct.negative { color: #b91c1c; }
.marcas-detalle-table .col-pct.neutral  { color: #9ca3af; font-weight: 500; }

/* Highlight de las marcas foco de Bahía (GEELY en el PBIX) */
.marcas-detalle-table tbody tr.row-focus td {
  background: #033932 !important;
  color: #ecfdf5;
}
.marcas-detalle-table tbody tr.row-focus .col-marca { color: #fff; }
.marcas-detalle-table tbody tr.row-focus .col-pct.positive { color: #6ee7b7; }
.marcas-detalle-table tbody tr.row-focus .col-pct.negative { color: #fca5a5; }
.marcas-detalle-table tbody tr.row-focus .col-rank { color: #d1fae5; }

.marcas-detalle-table tfoot .total-row td {
  padding: 0.6rem 0.55rem;
  border-top: 2px solid #033932;
  background: #f3f4f6;
  font-weight: 700;
  font-size: 0.82rem;
}
.marcas-detalle-table tfoot .total-row .col-marca {
  color: #033932;
}

.marcas-detalle-table tbody .empty-row td {
  text-align: center;
  color: #6b7280;
  font-style: italic;
  padding: 1.5rem;
  background: #fafafa;
}

/* ─── Mercado Overview (v6.7.0) ─────────────────────────────── */
.mercado-overview {
  margin-bottom: 1.5rem;
}
.overview-row {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}
.overview-row-headline { grid-template-columns: repeat(4, 1fr); }
.overview-row-segments { grid-template-columns: repeat(4, 1fr); }

.ov-card {
  background: #fff;
  border: 1.5px solid #033932;
  border-radius: 8px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 110px;
  justify-content: space-between;
}
.ov-card-primary {
  background: linear-gradient(135deg, #033932 0%, #0a4d44 100%);
  color: #ecfdf5;
  border-color: #033932;
}
.ov-card-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  text-align: center;
}
.ov-card-primary .ov-card-label {
  color: #a7f3d0;
}
.ov-card-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: #033932;
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.ov-card-primary .ov-card-value {
  color: #fff;
}
.ov-card-meta {
  font-size: 0.78rem;
  color: #6b7280;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.ov-card-primary .ov-card-meta {
  color: #d1fae5;
}
.ov-card-meta .meta-pct {
  font-weight: 700;
}
.ov-card-meta .meta-pct.positive { color: #047857; }
.ov-card-meta .meta-pct.negative { color: #b91c1c; }
.ov-card-primary .ov-card-meta .meta-pct.positive { color: #6ee7b7; }
.ov-card-primary .ov-card-meta .meta-pct.negative { color: #fca5a5; }

/* Cards de segmento (SUV / SEDAN / PICKUP / LUJO) */
.ov-card-segment .ov-card-value {
  font-size: 2rem;
}
.ov-segment-stats {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-align: center;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.ov-stat-ms { color: #6b7280; }
.ov-stat-growth.positive { color: #047857; }
.ov-stat-growth.negative { color: #b91c1c; }
.ov-stat-growth.neutral  { color: #9ca3af; }
.ov-card-primary .ov-stat-ms { color: #a7f3d0; }
.ov-card-primary .ov-stat-growth.positive { color: #6ee7b7; }
.ov-card-primary .ov-stat-growth.negative { color: #fca5a5; }

/* Mini-cards de SUV sub-segments */
.overview-row-suv {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1rem;
  display: block;
}
.ov-mini-header {
  font-size: 0.78rem;
  font-weight: 600;
  color: #033932;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}
.ov-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}
.ov-mini-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.65rem 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.ov-mini-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ov-mini-value.positive { color: #047857; }
.ov-mini-value.negative { color: #b91c1c; }
.ov-mini-value.neutral  { color: #9ca3af; }
.ov-mini-label {
  font-size: 0.7rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}

/* Top Marcas: drill-down header / back button */
.chart-title-block {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.chart-header .btn-back {
  background: #fff;
  border: 1px solid #033932;
  color: #033932;
  border-radius: 5px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.chart-header .btn-back:hover {
  background: #033932;
  color: #ecfdf5;
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Responsive */
@media (max-width: 1100px) {
  .overview-row-headline,
  .overview-row-segments,
  .ov-mini-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .overview-row-headline,
  .overview-row-segments,
  .ov-mini-grid { grid-template-columns: 1fr; }
  .ov-card-value { font-size: 1.4rem; }
  .ov-card-segment .ov-card-value { font-size: 1.6rem; }
}

/* ─── Mercado Mapa (v6.9.0) ─────────────────────────────────── */
/* Reusamos las clases .map-card/.map-leaflet/.map-legend del mapa
   de Clientes (ya existen). Solo agregamos un override para el
   tooltip estilizado de Mercado. */
.leaflet-tooltip-bm {
  background: rgba(255, 255, 255, 0.96) !important;
  border: 1px solid #033932 !important;
  border-radius: 6px !important;
  padding: 0.5rem 0.7rem !important;
  color: #033932 !important;
  font-size: 0.82rem !important;
  line-height: 1.4 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12) !important;
}

/* ─── Mercado Precios SUV (v6.9.0) ──────────────────────────── */
.precios-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1.5rem 0;
}
.precios-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.precios-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #033932;
  margin: 0 0 0.25rem 0;
}
.precios-sub {
  font-size: 0.78rem;
  color: #6b7280;
}
.precios-search {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  width: 220px;
  background: #f9fafb;
}
.precios-search:focus {
  outline: none;
  border-color: #033932;
  background: #fff;
}
.precios-body {
  overflow-x: auto;
}
.precios-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.precios-table th {
  background: #f3f4f6;
  color: #033932;
  text-align: left;
  font-weight: 600;
  padding: 0.55rem 0.6rem;
  border-bottom: 2px solid #e5e7eb;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.precios-table th:hover { background: #e5e7eb; }
.precios-table th.num,
.precios-table td.num { text-align: right; }
.precios-table th.sort-asc::after  { content: " ↑"; opacity: 0.7; }
.precios-table th.sort-desc::after { content: " ↓"; opacity: 0.7; }
.precios-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #f3f4f6;
}
.precios-row:hover { background: #f9fafb; }
.precios-row.row-focus { background: rgba(3, 57, 50, 0.08); }
.precios-row.row-focus:hover { background: rgba(3, 57, 50, 0.14); }
.precios-row.row-focus .precios-marca { font-weight: 700; color: #033932; }
.precios-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.9rem;
}

/* ─── Mercado Género Card (v6.9.0) ──────────────────────────── */
.genero-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 0 0 1.5rem 0;
  max-width: 580px;
}
.genero-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
}
.genero-card-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #033932;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.genero-card-source {
  font-size: 0.7rem;
  color: #9ca3af;
  font-style: italic;
}
.genero-card-body {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.genero-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.55rem;
  background: #f9fafb;
  border-radius: 6px;
}
.genero-pill {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  color: #fff;
  flex-shrink: 0;
}
.genero-pill-f       { background: #be185d; }
.genero-pill-m       { background: #1d4ed8; }
.genero-pill-empresa { background: #6b7280; }
.genero-pill-notiene { background: #a16207; }
.genero-pill-otro    { background: #94a3b8; }
.genero-empty {
  color: #9ca3af;
  font-size: 0.85rem;
  text-align: center;
  padding: 0.5rem 0;
  grid-column: 1 / -1;
}
.genero-count {
  font-weight: 700;
  color: #033932;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
.genero-pct {
  color: #6b7280;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

/* ─── Precios SUV redesign (feed de cards) — v6.10.0 ─────────── */
.precios-feed-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1.5rem 0;
  max-height: 480px;
  display: flex;
  flex-direction: column;
}
.precios-feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
  gap: 1rem;
}
.precios-feed-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #033932;
  margin: 0;
}
.precios-feed-search {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  width: 180px;
  background: #f9fafb;
}
.precios-feed-search:focus { outline: none; border-color: #033932; background: #fff; }
.precios-feed-sub {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 1rem;
}
.precios-feed-list {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.precios-feed-item {
  background: #f9fafb;
  border-left: 3px solid #e5e7eb;
  padding: 0.7rem 0.9rem;
  border-radius: 0 6px 6px 0;
}
.precios-feed-item-focus {
  background: rgba(3, 57, 50, 0.06);
  border-left-color: #033932;
}
.precios-feed-marca {
  font-size: 0.68rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.precios-feed-modelo {
  font-size: 0.95rem;
  font-weight: 700;
  color: #033932;
  margin: 0.1rem 0 0.25rem 0;
}
.precios-feed-item-focus .precios-feed-modelo {
  color: #033932;
}
.precios-feed-precio {
  font-size: 1.4rem;
  font-weight: 700;
  color: #111827;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.precios-feed-label {
  font-size: 0.72rem;
  color: #6b7280;
  margin-top: 0.15rem;
}
.precios-feed-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.85rem;
}

/* ─── ML section title — v6.10.0 / v6.12.5 ─────────────────── */
/* Tier intermedio de la jerarquía: más chico que .mercado-title y
   más grande/peso que los chart-title. Misma familia tipográfica. */
.mercado-section-title {
  font-family: "Instrument Serif", serif;
  font-size: 2.2rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.2;
  color: #033932;
  margin: 2.25rem 0 1rem 0;
  padding-top: 1rem;
  border-top: 2px solid #e5e7eb;
}

/* ─── Forecast (Prophet) — v6.10.0 ────────────────────────── */
.forecast-card,
.competencia-card,
.insights-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.25rem;
  margin: 0 0 1.5rem 0;
}
.forecast-header,
.competencia-header,
.insights-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.forecast-title,
.competencia-title,
.insights-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #033932;
  margin: 0 0 0.25rem 0;
}
.forecast-sub,
.competencia-sub,
.insights-sub {
  font-size: 0.78rem;
  color: #6b7280;
}
.forecast-controls,
.competencia-controls,
.insights-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}
.forecast-controls select,
.competencia-controls select,
.insights-controls select {
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  background: #fff;
  color: #033932;
  font-weight: 600;
}
.forecast-body {
  position: relative;
  height: 320px;
  margin: 0.5rem 0 1rem 0;
}
.forecast-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f3f4f6;
  font-size: 0.82rem;
}
.forecast-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.forecast-stat-label {
  font-size: 0.68rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.forecast-stat-value {
  font-weight: 700;
  color: #033932;
}
.forecast-stat-value .positive { color: #047857; }
.forecast-stat-value .negative { color: #b91c1c; }

/* ─── Competencia (regresión) — v6.10.0 ────────────────────── */
.competencia-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.competencia-warning {
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: #fef3c7;
  color: #92400e;
  border-radius: 6px;
  font-size: 0.8rem;
  border-left: 3px solid #f59e0b;
}
.comp-row {
  display: grid;
  grid-template-columns: 180px 1fr 110px;
  gap: 0.75rem;
  align-items: center;
}
.comp-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}
.comp-sig { color: #d97706; font-size: 0.9rem; }
.comp-nosig { color: #d1d5db; font-size: 0.9rem; }
.comp-marca {
  font-weight: 600;
  color: #033932;
}
.comp-bar-track {
  height: 22px;
  background: #f3f4f6;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.comp-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.comp-bar-pos {
  background: linear-gradient(90deg, #6ee7b7, #047857);
}
.comp-bar-neg {
  background: linear-gradient(90deg, #fca5a5, #b91c1c);
}
.comp-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}
.comp-coef {
  font-weight: 700;
  display: block;
}
.comp-coef.positive { color: #047857; }
.comp-coef.negative { color: #b91c1c; }
.comp-pval {
  font-size: 0.7rem;
  color: #9ca3af;
}

/* ─── Insights SWOT — v6.10.0 ─────────────────────────────── */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 0.75rem;
}
.insights-col {
  background: #f9fafb;
  border-radius: 6px;
  padding: 1rem;
  border-top: 4px solid;
}
.insights-col-ventajas       { border-top-color: #047857; }
.insights-col-amenazas       { border-top-color: #b91c1c; }
.insights-col-oportunidades  { border-top-color: #1d4ed8; }
.insights-col-title {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0 0 0.75rem 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.insights-col-ventajas .insights-col-title       { color: #047857; }
.insights-col-amenazas .insights-col-title       { color: #b91c1c; }
.insights-col-oportunidades .insights-col-title  { color: #1d4ed8; }
.insights-col-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.insights-item {
  background: #fff;
  border-radius: 5px;
  padding: 0.75rem;
  border-left: 3px solid #e5e7eb;
}
.insights-item.insights-nivel-alto  { border-left-width: 4px; }
.insights-col-ventajas .insights-item.insights-nivel-alto       { border-left-color: #047857; }
.insights-col-amenazas .insights-item.insights-nivel-alto       { border-left-color: #b91c1c; }
.insights-col-oportunidades .insights-item.insights-nivel-alto  { border-left-color: #1d4ed8; }
.insights-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}
.insights-item-titulo {
  font-weight: 700;
  color: #033932;
  font-size: 0.85rem;
  flex: 1;
}
.insights-item-metrica {
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: #f3f4f6;
  color: #033932;
  white-space: nowrap;
}
.insights-col-ventajas .insights-item-metrica       { background: #d1fae5; color: #047857; }
.insights-col-amenazas .insights-item-metrica       { background: #fee2e2; color: #b91c1c; }
.insights-col-oportunidades .insights-item-metrica  { background: #dbeafe; color: #1d4ed8; }
.insights-item-detalle {
  font-size: 0.78rem;
  color: #4b5563;
  line-height: 1.45;
}
.insights-empty,
.insights-loading {
  padding: 0.75rem;
  color: #9ca3af;
  font-style: italic;
  font-size: 0.82rem;
  text-align: center;
}

/* Responsive */
@media (max-width: 1100px) {
  .insights-grid { grid-template-columns: 1fr; }
  .comp-row { grid-template-columns: 130px 1fr 90px; gap: 0.5rem; }
}

/* ─── Top 10 + Precios layout 3:1 — v6.12.3 ──────────────────── */
.mercado-top10-precios-grid {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
  align-items: stretch;
  /* v6.12.3: altura definida del grid para que la GRÁFICA del Top 10
     tenga un tamaño razonable (con 10 marcas + leyenda, ~480px es cómodo).
     Antes la altura era libre y stretch hacía que se estirara feo. */
  height: 500px;
}
.mercado-top10-precios-grid > * {
  min-height: 0;       /* evita overflow del grid item */
  overflow: hidden;
}
/* El chart card del Top 10 ocupa los 500px y su .chart-body adentro
   también, para que Chart.js no se estire ni encoja indebidamente. */
.mercado-top10-precios-grid .chart-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.mercado-top10-precios-grid .chart-card .chart-body {
  flex: 1;
  min-height: 0;
}
/* El precios card también ocupa los 500px, lista interna scrollea */
.mercado-top10-precios-grid > bm-mercado-precios {
  display: block;
  min-width: 0;
}
.mercado-top10-precios-grid .precios-feed-card {
  margin: 0;
  height: 100%;
  max-height: none;
  display: flex;
  flex-direction: column;
}
.mercado-top10-precios-grid .precios-feed-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  max-height: none;
}
/* Buscar más chico en columna estrecha */
.mercado-top10-precios-grid .precios-feed-search {
  width: 100%;
  max-width: 140px;
}
/* Items de precios compactos en columna estrecha */
.mercado-top10-precios-grid .precios-feed-item    { padding: 0.5rem 0.65rem; }
.mercado-top10-precios-grid .precios-feed-modelo  { font-size: 0.85rem; }
.mercado-top10-precios-grid .precios-feed-precio  { font-size: 1.15rem; }
.mercado-top10-precios-grid .precios-feed-marca   { font-size: 0.62rem; }
.mercado-top10-precios-grid .precios-feed-label   { font-size: 0.66rem; }

/* Responsive: pantallas chicas → apilamos */
@media (max-width: 1100px) {
  .mercado-top10-precios-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  .mercado-top10-precios-grid .precios-feed-card {
    height: auto;
    max-height: 480px;
  }
}

/* ─── Jerarquía tipográfica del dashboard (v6.12.5) ──────────
   Una sola fuente (Instrument Serif) para TODOS los títulos.
   La jerarquía se define solo por TAMAÑO y PESO:

     Sub-tab title (h2 grande, ej "Estudio de Mercado")  1.65rem  w500
     Section title (h3, ej "Análisis predictivo")        1.30rem  w500
     Card title    (h2 dentro de card, ej "Top 10")      1.10rem  w400

   Subtítulos en Manrope uppercase chico (contraste visual). */
.chart-title,
.precios-feed-title,
.precios-title,
.forecast-title,
.competencia-title,
.insights-title,
.map-title,
.tx-title {
  font-family: "Instrument Serif", serif !important;
  font-size: 1.7rem !important;
  font-weight: 400 !important;
  color: #033932 !important;
  margin: 0 0 0.25rem 0 !important;
  letter-spacing: 0 !important;
  line-height: 1.25 !important;
  text-transform: none !important;
  font-style: normal !important;
}
/* Subtítulos: Manrope uppercase, contraste con los serif de los títulos */
.chart-sub,
.precios-feed-sub,
.precios-sub,
.forecast-sub,
.competencia-sub,
.insights-sub,
.map-sub,
.tx-sub {
  font-family: "Manrope", system-ui, sans-serif !important;
  font-size: 0.72rem !important;
  color: #6b7280 !important;
  font-weight: 500 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  font-style: normal !important;
}

/* ════════════════════════════════════════════════════════════════
   Reservas (v6.15.0) — Dashboard de pipeline RETAIL + FLOTA
   ════════════════════════════════════════════════════════════════ */

/* Header */
.reservas-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin: 0.5rem 0 1.25rem;
  flex-wrap: wrap;
}
.reservas-header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.reservas-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  text-align: right;
  font-size: 0.85rem;
  color: #4b5563;
  font-variant-numeric: tabular-nums;
}
.reservas-marca-pill {
  background: #2563eb;
  color: #fff;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}
.reservas-titulo {
  font-size: 1.4rem;
  font-weight: 600;
  color: #111827;
  margin: 0;
}
.reservas-fecha { font-weight: 500; color: #1f2937; }
.reservas-dia-habil strong { color: #111827; }
.reservas-actualizado { font-size: 0.78rem; color: #6b7280; }

/* Bloque RETAIL / FLOTA */
.reservas-bloque {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.reservas-bloque-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.reservas-segmento-label {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: #111827;
}
.reservas-segmento-pill {
  background: #dbeafe;
  color: #1e3a8a;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.reservas-segmento-pill strong { font-weight: 700; }
.reservas-bloque[data-tone="orange"] .reservas-segmento-pill {
  background: #ffedd5;
  color: #9a3412;
}

/* KPI grid */
.reservas-kpi-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.reservas-kpi-card {
  background: #f9fafb;
  border-radius: 8px;
  padding: 0.85rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 95px;
}
.reservas-kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b7280;
  letter-spacing: 0.02em;
}
.reservas-kpi-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: #111827;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.reservas-kpi-meta {
  font-size: 0.72rem;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
  margin-top: auto;
}
.reservas-kpi-negativo { color: #b91c1c; }
.reservas-kpi-destacado {
  background: #2563eb;
}
.reservas-kpi-destacado .reservas-kpi-label,
.reservas-kpi-destacado .reservas-kpi-meta {
  color: #c7d2fe;
}
.reservas-kpi-destacado .reservas-kpi-value { color: #fff; }
.reservas-bloque[data-tone="orange"] .reservas-kpi-destacado {
  background: #ea580c;
}
.reservas-bloque[data-tone="orange"] .reservas-kpi-destacado .reservas-kpi-label,
.reservas-bloque[data-tone="orange"] .reservas-kpi-destacado .reservas-kpi-meta {
  color: #fed7aa;
}

/* Tabla detalle */
.reservas-detalle-header {
  font-size: 0.78rem;
  font-weight: 700;
  color: #374151;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}
.reservas-tabla-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
}
.reservas-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.reservas-tabla thead th {
  text-align: right;
  padding: 0.55rem 0.6rem;
  font-weight: 500;
  font-size: 0.78rem;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
}
.reservas-tabla thead th.col-modelo { text-align: left; }
.reservas-tabla tbody td {
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid #f3f4f6;
}
.reservas-tabla tbody tr:last-child td { border-bottom: 0; }
.reservas-tabla .col-modelo { text-align: left; font-weight: 500; }
.reservas-tabla .col-num    { text-align: right; }
.reservas-tabla .col-num-strong { font-weight: 700; }
.reservas-tabla .reservas-cell-negativo { color: #b91c1c; }
.reservas-tabla .reservas-cell-em { color: #d1d5db; }
.reservas-tabla tfoot .reservas-tfoot-row td {
  background: #f9fafb;
  padding: 0.7rem 0.6rem;
  font-size: 0.92rem;
  border-top: 1.5px solid #e5e7eb;
}
.reservas-tabla .empty-row td {
  text-align: center;
  color: #9ca3af;
  padding: 1.5rem 0.5rem;
}

/* Barra de avance temporal */
.reservas-progress-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: #f9fafb;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
}
.reservas-progress-label {
  font-weight: 600;
  color: #374151;
  flex-shrink: 0;
}
.reservas-progress-bar {
  flex: 1;
  background: #e5e7eb;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  min-width: 100px;
}
.reservas-progress-fill {
  background: #2563eb;
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease-out;
}
.reservas-bloque[data-tone="orange"] .reservas-progress-fill {
  background: #ea580c;
}
.reservas-progress-pct {
  font-weight: 700;
  color: #2563eb;
  font-variant-numeric: tabular-nums;
}
.reservas-bloque[data-tone="orange"] .reservas-progress-pct { color: #ea580c; }
.reservas-progress-meta {
  font-size: 0.78rem;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

/* Responsivo: si la pantalla es chica, las 7 cards pasan a 2 filas */
@media (max-width: 1200px) {
  .reservas-kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
  .reservas-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .reservas-header-right { align-items: flex-start; text-align: left; }
}

/* ════════════════════════════════════════════════════════════════
   Reservas — Metas modal + % Avance + Botón header (v6.16.0)
   ════════════════════════════════════════════════════════════════ */

/* ── Botón "Actualizar Metas y Tubería" en el header ── */
.reservas-header-right {
  flex-direction: row;
  align-items: center;
  gap: 1rem;
}
.reservas-header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  text-align: right;
  font-size: 0.85rem;
  color: #4b5563;
  font-variant-numeric: tabular-nums;
}
.btn-metas {
  background: #033932;
  color: #ecfdf5;
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn-metas:hover  { background: #015a4d; }
.btn-metas:active { transform: translateY(1px); }

/* v6.18.0 — Botón Devoluciones (variante del btn-metas, color rojizo) */
.btn-devoluciones {
  background: #7c2d12;
  margin-right: 0.5rem;
}
.btn-devoluciones:hover { background: #9a3412; }

/* v6.18.0 — Modal de Devoluciones (reusa .metas-modal-* del estilo base) */
.dev-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0 1.25rem 0;
}
.dev-upload-card {
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 1rem;
  background: #f8fafc;
}
.dev-upload-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #0f172a;
  margin-bottom: 0.15rem;
}
.dev-upload-card-sub {
  font-size: 0.78rem;
  color: #64748b;
  margin-bottom: 0.6rem;
}
.dev-upload-card input[type="file"] {
  display: block;
  width: 100%;
  padding: 0.4rem 0;
  font-size: 0.85rem;
}
.dev-upload-status {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-family: "JetBrains Mono", monospace;
  color: #475569;
}
.dev-upload-status[data-state="ok"]      { color: #047857; }
.dev-upload-status[data-state="warn"]    { color: #b45309; }
.dev-upload-status[data-state="loading"] { color: #2563eb; }

.dev-preview { margin-top: 0.5rem; }
.dev-preview-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.5rem 0;
}
.dev-preview-tables {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.dev-preview-marca h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #033932;
  margin: 0 0 0.3rem 0;
}
.dev-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.dev-preview-table th, .dev-preview-table td {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}
.dev-preview-table th.num, .dev-preview-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Columna % Avance en la tabla de detalle ── */
.reservas-tabla .col-avance { min-width: 130px; }
.cell-avance-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-end;
}
.cell-avance-bar {
  width: 60px;
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  display: inline-block;
}
.cell-avance-fill {
  display: block;
  height: 100%;
  background: #2563eb;
  border-radius: 999px;
  transition: width 0.5s ease-out;
}
.reservas-bloque[data-tone="orange"] .cell-avance-fill { background: #ea580c; }
.cell-avance-pct {
  font-weight: 700;
  color: #2563eb;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  min-width: 48px;
  text-align: right;
}
.reservas-bloque[data-tone="orange"] .cell-avance-pct { color: #ea580c; }

/* Tip de TI manual (badge "M" al lado del número) */
.ti-manual {
  display: inline-block;
  margin-left: 0.3rem;
  background: #ddd6fe;
  color: #5b21b6;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  vertical-align: middle;
}

/* ── Modal de metas ── */
.metas-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem 1rem;
}
.metas-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 920px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35);
}
.metas-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.1rem 1.3rem;
  border-bottom: 1px solid #e5e7eb;
}
.metas-modal-title {
  margin: 0;
  font-size: 1.15rem;
  color: #111827;
}
.metas-modal-subtitle {
  margin: 0.2rem 0 0 0;
  font-size: 0.82rem;
  color: #6b7280;
}
.metas-modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}
.metas-modal-close:hover { background: #f3f4f6; color: #111827; }

.metas-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.3rem;
}
.metas-loading, .metas-error, .metas-help {
  font-size: 0.88rem;
  color: #4b5563;
  padding: 0.5rem 0;
}
.metas-error { color: #b91c1c; }
.metas-help  { margin-bottom: 0.85rem; color: #6b7280; }

.metas-table-wrap { overflow-x: auto; }
.metas-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.metas-table thead th {
  background: #f9fafb;
  padding: 0.6rem 0.6rem;
  font-weight: 600;
  font-size: 0.78rem;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
  text-align: right;
}
.metas-table thead th.col-marca,
.metas-table thead th.col-modelo {
  text-align: left;
}
.metas-table thead th.col-group {
  text-align: center;
  border-bottom: 1px solid #e5e7eb;
}
.metas-table thead th.col-group-retail { color: #1e3a8a; background: #eff6ff; }
.metas-table thead th.col-group-flota  { color: #9a3412; background: #fff7ed; }

.metas-table tbody tr {
  border-bottom: 1px solid #f3f4f6;
}
.metas-table tbody tr.row-first-of-marca {
  border-top: 1.5px solid #e5e7eb;
}
.metas-table tbody td {
  padding: 0.45rem 0.55rem;
}
.metas-table .col-marca  { font-weight: 500; min-width: 100px; }
.metas-table .col-modelo { color: #374151; min-width: 110px; }
.metas-table .col-num    { text-align: right; }
.metas-table input[type="number"] {
  width: 70px;
  padding: 0.32rem 0.45rem;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 0.88rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  background: #fff;
}
.metas-table input[type="number"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.metas-table tbody tr.empty td {
  text-align: center;
  color: #9ca3af;
  padding: 1.5rem 0.5rem;
}

.metas-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.3rem;
  border-top: 1px solid #e5e7eb;
  background: #fafafa;
}
.metas-status {
  font-size: 0.82rem;
  color: #6b7280;
}
.metas-actions {
  display: flex;
  gap: 0.6rem;
}
.metas-actions .btn-secondary,
.metas-actions .btn-primary {
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.metas-actions .btn-secondary {
  background: #f3f4f6;
  color: #374151;
}
.metas-actions .btn-secondary:hover { background: #e5e7eb; }
.metas-actions .btn-primary {
  background: #033932;
  color: #ecfdf5;
}
.metas-actions .btn-primary:hover           { background: #015a4d; }
.metas-actions .btn-primary:disabled        { background: #9ca3af; cursor: not-allowed; }

@media (max-width: 768px) {
  .reservas-header-right { flex-direction: column; align-items: flex-start; }
  .reservas-header-meta  { align-items: flex-start; text-align: left; }
  .metas-modal { max-height: 95vh; }
}

/* Modal de metas v6.16.1 — fila de marca (TI) destacada */
.metas-table tbody tr.row-marca {
  background: #f9fafb;
  border-top: 1.5px solid #e5e7eb;
}
.metas-table tbody tr.row-marca td { padding-top: 0.65rem; padding-bottom: 0.65rem; }
.metas-table tbody tr.row-marca .row-marca-label {
  font-style: italic;
  color: #6b7280;
  font-size: 0.78rem;
}

/* v6.16.2 — Inputs disabled del modal (marcas que no tienen ese segmento) */
.metas-table input[type="number"]:disabled {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
  border-color: #e5e7eb;
}
.metas-table input[type="number"]:disabled::placeholder {
  color: #d1d5db;
}

/* ── Tabla forecast por modelo (v6.19.9, <bm-mercado-forecast-tabla>) ── */
.ftabla-wrap { overflow-x: auto; }
.ftabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.ftabla th, .ftabla td {
  padding: 0.45rem 0.6rem;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid #f3f4f6;
}
.ftabla thead th {
  font-weight: 700;
  color: #033932;
  border-bottom: 2px solid #e5e7eb;
}
.ftabla-modelo { text-align: left; font-weight: 600; color: #1f2937; }
.ftabla-num { text-align: right; font-variant-numeric: tabular-nums; }
.ftabla-base { color: #6b7280; }
.ftabla-na { color: #d1d5db; }
.ftabla-marca td {
  text-align: left;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  color: #009E83;
  background: #f0faf6;
  padding-top: 0.6rem;
}
.ftabla-units { display: block; font-weight: 600; color: #033932; }
.ftabla-share { display: block; font-size: 0.68rem; color: #6b7280; margin-top: 0.05rem; }
.ftabla-up { background: rgba(0, 158, 131, 0.12); }
.ftabla-down { background: rgba(220, 38, 38, 0.09); }
.ftabla-tag {
  font-size: 0.62rem; font-weight: 700; color: #9ca3af;
  border: 1px solid #e5e7eb; border-radius: 4px; padding: 0 0.25rem; margin-left: 0.3rem;
}
.ftabla-empty { color: #6b7280; font-size: 0.85rem; padding: 1rem 0; text-align: center; }

/* ── Enrutador bancario / sub-tab Referencia (v6.20.0) ── */
.ref-wrap { display: flex; flex-direction: column; gap: 1.25rem; }
.ref-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.9rem 1.1rem; margin-top: 0.6rem; }
.ref-field { display: flex; flex-direction: column; gap: 0.3rem; }
.ref-field > span { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: #6b7280; }
.ref-field select, .ref-field input {
  padding: 0.5rem 0.6rem; border: 1px solid #E8E6DF; border-radius: 8px;
  font-size: 0.9rem; color: #1f2937; background: #fff;
}
.ref-field select:focus, .ref-field input:focus { outline: none; border-color: #009E83; box-shadow: 0 0 0 3px rgba(0,158,131,0.12); }

.ref-summary { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.ref-pill { font-size: 0.78rem; font-weight: 700; padding: 0.25rem 0.7rem; border-radius: 999px; }
.ref-pill--verde    { background: rgba(0,158,131,0.14);  color: #027a66; }
.ref-pill--amarillo { background: rgba(224,161,0,0.16);  color: #9a6b00; }
.ref-pill--rojo     { background: rgba(220,38,38,0.12);  color: #b91c1c; }

.ref-results { display: flex; flex-direction: column; gap: 0.8rem; }
.ref-bank { background: #fff; border: 1px solid #E8E6DF; border-left-width: 5px; border-radius: 12px; padding: 0.85rem 1rem; }
.ref-bank--verde    { border-left-color: #009E83; }
.ref-bank--amarillo { border-left-color: #E0A100; }
.ref-bank--rojo     { border-left-color: #DC2626; opacity: 0.82; }
.ref-bank-head { display: flex; align-items: center; gap: 0.55rem; }
.ref-bank-name { font-size: 1rem; font-weight: 700; color: #033932; margin: 0; flex: 0 0 auto; }
.ref-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.ref-dot--verde    { background: #009E83; }
.ref-dot--amarillo { background: #E0A100; }
.ref-dot--rojo     { background: #DC2626; }
.ref-plazo { margin-left: auto; font-size: 0.74rem; color: #6b7280; }

.ref-crit-list { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.25rem; }
.ref-crit { display: grid; grid-template-columns: 1.1rem 8.5rem 1fr; align-items: baseline; gap: 0.4rem; font-size: 0.82rem; }
.ref-crit-icon { font-weight: 800; text-align: center; }
.ref-crit-label { font-weight: 600; color: #374151; }
.ref-crit-detalle { color: #6b7280; }
.ref-crit--ok   .ref-crit-icon { color: #009E83; }
.ref-crit--warn .ref-crit-icon { color: #E0A100; }
.ref-crit--fail .ref-crit-icon { color: #DC2626; }
.ref-crit--fail .ref-crit-detalle { color: #b91c1c; }

.ref-foot { font-size: 0.74rem; color: #9ca3af; margin: 0.5rem 0 0; }
@media (max-width: 640px) { .ref-crit { grid-template-columns: 1.1rem 1fr; } .ref-crit-detalle { grid-column: 2; } }

.ref-crit--info .ref-crit-icon { color: #9ca3af; }
.ref-crit--info .ref-crit-label { color: #6b7280; font-weight: 500; }
