/* ============================================
   DESIGN SYSTEM · Tegel-aligned (Scania Ibérica)
   ============================================ */
:root {
  /* Tegel-aligned tokens */
  --tds-blue-50:  #E5F2FF;
  --tds-blue-100: #C6E0FF;
  --tds-blue-200: #87BCFF;
  --tds-blue-300: #3D85DD;   /* Scania Blue · core brand */
  --tds-blue-400: #2762A5;
  --tds-blue-500: #1B4D8C;
  --tds-blue-600: #0F3263;
  --tds-blue-700: #0B1F3D;
  --tds-grey-50:  #F9FAFB;
  --tds-grey-100: #F1F3F5;
  --tds-grey-200: #DDE2E8;
  --tds-grey-300: #C0C8D2;
  --tds-grey-400: #8B95A3;
  --tds-grey-500: #5C6675;
  --tds-grey-600: #41464D;
  --tds-grey-700: #2A2E33;
  --tds-grey-800: #1A1D21;
  --tds-grey-900: #0D0F10;
  --tds-white:    #FFFFFF;
  --tds-red-500:  #C72D1F;
  --tds-red-100:  #FBE3E0;
  --tds-green-500:#1D8C4D;
  --tds-green-100:#DFF1E5;
  --tds-yellow-500:#D6892B;
  --tds-yellow-100:#FBEED4;
  --scania-brand-red:#D6001C;
  --scania-brand-blue:#041E42;

  --tds-background-body:    var(--tds-grey-50);
  --tds-background-surface: var(--tds-white);
  --tds-text-primary:   var(--tds-grey-900);
  --tds-text-secondary: var(--tds-grey-500);
  --tds-border-subtle:  var(--tds-grey-200);
  --tds-border-strong:  var(--tds-grey-300);
  --tds-accent: var(--tds-blue-300);

  --tds-radius-xs: 2px;
  --tds-radius-sm: 4px;
  --tds-radius-md: 8px;
  --tds-radius-lg: 12px;

  --neutral-50:#F8FAFC; --neutral-100:#F1F5F9; --neutral-200:#E2E8F0;
  --neutral-300:#CBD5E1; --neutral-400:#94A3B8; --neutral-500:#64748B;
  --neutral-600:#475569; --neutral-700:#334155; --neutral-800:#1E293B;
  --neutral-900:#0F172A;

  --shadow-xs:0 1px 2px rgba(15,23,42,.04);
  --shadow-sm:0 1px 3px rgba(15,23,42,.06),0 1px 2px rgba(15,23,42,.04);
  --shadow:0 4px 12px rgba(15,23,42,.06),0 2px 4px rgba(15,23,42,.04);
  --shadow-lg:0 12px 24px rgba(15,23,42,.08),0 4px 8px rgba(15,23,42,.04);
  --shadow-ai:0 8px 24px rgba(139,92,246,.25);   /* usado por la vista Forecast (banner IA) */
  --accent-purple:#8B5CF6; --accent-cyan:#06B6D4; --scania-red:#DC2626;

  --tx-fast:150ms cubic-bezier(.4,0,.2,1);
  --tx:220ms cubic-bezier(.4,0,.2,1);

  --topnav-h:78px;
  --bottomnav-h:58px;
  --radius-lg:16px;

  --font-sans:'Scania Sans','Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  --font-mono:'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--neutral-800);
  background: var(--neutral-50);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
svg { display: block; }

/* ===== TOP NAV ===== */
.topnav {
  min-height: var(--topnav-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;   /* pestañas centradas, independientes del ancho de los lados */
  align-items: stretch;
  gap: 24px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}
/* Franja del color del CONTENIDO al pie del topnav: el "panel" en el que se funde
   exactamente la pestaña activa (misma superficie), estilo "tabs conectadas". */
.topnav::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 8px; background: var(--neutral-50); }
.topnav > .brand { justify-self: start; align-self: center; }
.topnav > .topnav-tabs { justify-self: center; align-self: end; }
.topnav > .topnav-spacer { justify-self: end; align-self: center; }
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.logo-mark {
  width: 38px; height: 38px;
  background: var(--tds-blue-300);
  border-radius: var(--tds-radius-sm);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.logo-mark::before {
  content: ""; position: absolute; inset: -30%;
  background: conic-gradient(from 0deg, transparent, rgba(255,255,255,.25), transparent);
  animation: rotate 4s linear infinite;
}
@keyframes rotate { to { transform: rotate(360deg); } }
.logo-mark svg { position: relative; z-index: 1; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-logo { width: 50px; height: 50px; object-fit: contain; flex-shrink: 0; }
.brand-text .name {
  font-weight: 800; font-size: 15px;
  color: var(--neutral-900);
  display: inline-flex; flex-direction: column; align-items: stretch;
  line-height: 1.08;
}
.brand-text .name span { display: block; letter-spacing: -.01em; text-align: justify; text-align-last: justify; text-justify: inter-character; }
.brand-text .name .name-accent { color: var(--tds-blue-300); }
.brand-text .name .mvp-tag {
  font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: var(--tds-radius-xs);
  background: var(--tds-blue-300); color: white; letter-spacing: .05em;
}
.brand-text .tag { font-size: 10.5px; color: var(--neutral-500); font-weight: 500; margin-top: 2px; }

/* ===== TOPNAV TABS (folder-tab metaphor) =====
   Pestaña activa: tarjeta blanca elevada con icono saturado.
   Pestañas secundarias: solo icono+texto desaturado, fondo transparente. */
.topnav-tabs {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  position: relative;
  z-index: 1;              /* por encima de la franja azul (.topnav::after) */
}
.topnav-tabs button {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px;
  padding: 8px 16px 10px;
  min-width: 92px;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  font: 600 11.5px/1.2 var(--font-sans);
  color: var(--neutral-500);
  letter-spacing: -.005em;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  margin-bottom: 0;
  transition: color var(--tx-fast), background var(--tx-fast), box-shadow var(--tx-fast), border-color var(--tx-fast);
}
.topnav-tabs button .tab-ico {
  width: 34px; height: 34px; display: block;
  opacity: .42;
  filter: saturate(.15) brightness(.95);
  transition: opacity var(--tx-fast), filter var(--tx-fast);
}
.topnav-tabs button:not(.active):hover {
  color: var(--neutral-800);
  background: rgba(15,23,42,.03);
}
.topnav-tabs button:not(.active):hover .tab-ico {
  opacity: .85;
  filter: saturate(.85);
}
.topnav-tabs button:focus-visible { outline: 2px solid var(--tds-blue-300); outline-offset: -2px; }
.topnav-tabs button.active {
  color: var(--tds-blue-700);
  font-weight: 700;
  background: var(--neutral-50);      /* MISMO color que el fondo del contenido: la pestaña "abre" ese espacio */
}
/* Alas cóncavas (radio invertido) que funden la pestaña activa con la franja
   azul del pie del topnav — sello del codepen "tabs conectadas". */
.topnav-tabs button.active::before,
.topnav-tabs button.active::after {
  content: ''; position: absolute; bottom: 0; width: 12px; height: 12px; pointer-events: none;
}
.topnav-tabs button.active::before {
  left: -12px;
  background: radial-gradient(circle at top left, transparent 12px, var(--neutral-50) 0);
}
.topnav-tabs button.active::after {
  right: -12px;
  background: radial-gradient(circle at top right, transparent 12px, var(--neutral-50) 0);
}
.topnav-tabs button.active .tab-ico {
  opacity: 1;
  filter: none;
}
.tab-divider {
  width: 1px; height: 36px;
  background: var(--neutral-200);
  margin: 0 18px 14px;          /* más aire a izq/der: separa Paneles vs Herramientas */
  flex-shrink: 0;
}
/* ===== VALUER VO · Valuer VO Predictor embebido (iframe a pantalla completa) ===== */
#view-valuer .valuer-frame-wrap { height: calc(100vh - var(--topnav-h)); }
#valuerFrame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }

/* Etiqueta "AI Tools" entre el divider y los botones de herramientas.
   Dos palabras horizontales lado a lado (AI a la izquierda, Tools a la derecha),
   centradas verticalmente dentro del menú para no exceder su alto. */
.ai-tools-label {
  flex-shrink: 0;
  align-self: center;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  margin: 0 2px 14px;             /* mismo margin-bottom que los botones para alinearse al baseline */
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .02em;
  color: var(--neutral-400);
  text-transform: uppercase;
  line-height: 1;
  user-select: none;
}
.ai-tools-label > span { display: inline; }

.topnav-spacer { flex: 1; display: flex; justify-content: flex-end; align-items: center; }
.topnav-admin {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px;
  border-radius: var(--tds-radius-sm);
  background: var(--tds-white);
  border: 1px solid var(--tds-border-subtle);
  color: var(--tds-text-secondary);
  font-size: 12.5px; font-weight: 600;
  text-decoration: none;
  transition: all var(--tx-fast);
}
.topnav-admin svg { display: block; color: var(--tds-text-secondary); transition: color var(--tx-fast), transform var(--tx-fast); }
.topnav-admin:hover { background: var(--tds-blue-50); border-color: var(--tds-blue-300); color: var(--tds-blue-500); }
.topnav-admin:hover svg { color: var(--tds-blue-500); transform: rotate(30deg); }
.topnav-admin:focus-visible { outline: 2px solid var(--tds-blue-300); outline-offset: 2px; }
.topnav-period {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-radius: var(--tds-radius-sm);
  background: var(--tds-grey-50);
  border: 1px solid var(--tds-border-subtle);
  font-size: 12px; color: var(--tds-text-secondary);
  font-weight: 500; font-family: var(--font-mono);
}
.topnav-period .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tds-green-500);
  box-shadow: 0 0 0 3px rgba(29,140,77,.18);
}
.topnav-period b { color: var(--tds-text-primary); font-weight: 600; }

.health-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px;
  border-radius: var(--tds-radius-sm);
  background: var(--tds-white);
  border: 1px solid var(--tds-border-subtle);
  font-size: 12px; color: var(--tds-text-primary);
  font-weight: 500; cursor: pointer; transition: all var(--tx-fast);
}
.health-chip:hover { background: var(--tds-grey-50); border-color: var(--tds-blue-300); }
.health-chip .h-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--tds-green-500);
  box-shadow: 0 0 0 3px rgba(29,140,77,.15);
}
.health-chip .h-lbl { font-family: var(--font-mono); font-size: 11.5px; color: var(--tds-text-secondary); }
.health-chip .h-val { font-weight: 700; color: var(--tds-text-primary); }

.profile-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 12px 5px 5px;
  border-radius: 24px;
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  transition: all var(--tx-fast); cursor: pointer;
}
.profile-chip:hover { background: white; border-color: var(--neutral-300); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--tds-blue-300);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 11.5px; flex-shrink: 0;
}
.profile-chip .meta { line-height: 1.15; display: flex; flex-direction: column; }
.profile-chip .meta .n { font-size: 12.5px; font-weight: 600; color: var(--neutral-900); }
.profile-chip .meta .r { font-size: 10.5px; color: var(--neutral-500); }

/* ===== CONTENT ===== */
.content {
  padding: 28px 32px 56px;
  max-width: 1760px;
  margin: 0 auto;
  width: 100%;
}
.view { display: none; }
.view.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; margin-bottom: 16px; flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-sans);
  font-size: 32px; font-weight: 700;
  color: var(--neutral-900);
  letter-spacing: -.02em;
  line-height: 1.1;
}
.page-title em { font-style: normal; color: var(--tds-blue-300); font-weight: 700; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 16px; height: 40px;
  border-radius: var(--tds-radius-sm);
  font-size: 14px; font-weight: 600;
  transition: all var(--tx-fast); white-space: nowrap;
}
.btn-primary {
  background: var(--tds-blue-300);
  color: var(--tds-white);
  border: 1px solid var(--tds-blue-300);
}
.btn-primary:hover { background: var(--tds-blue-400); border-color: var(--tds-blue-400); }
.btn-secondary {
  background: var(--tds-white);
  color: var(--tds-blue-300);
  border: 1px solid var(--tds-blue-300);
}
.btn-secondary:hover { background: var(--tds-blue-50); }
.btn-ghost {
  color: var(--tds-blue-300);
  padding: 0 12px; height: 36px;
  background: transparent; border: 0;
  font-weight: 600; font-size: 13px;
}
.btn-ghost:hover { background: var(--tds-blue-50); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }

/* ===== GRID ===== */
.grid { display: grid; gap: 18px; }
.grid-kpi-6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-half { grid-template-columns: 1fr 1fr; }
.grid-main { grid-template-columns: 1.7fr 1fr; }
.grid-main-2 { grid-template-columns: 1.4fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-corr { grid-template-columns: 4fr 2fr; }
/* Value Insights IA (card lateral 1/5) */
.vi-card { display:flex; flex-direction:column; min-width:0; }
.vi-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:10px; }
.vi-body { flex:1 1 auto; overflow:auto; font-size:12px; line-height:1.5; color:var(--neutral-800); min-height:130px; }
.vi-body ul { margin:4px 0 4px 15px; padding:0; }
.vi-body li { margin:5px 0; }
.vi-body p { margin:5px 0; }
.vi-body b { color:var(--neutral-900); }
.vi-foot { margin-top:10px; padding-top:8px; border-top:1px solid var(--tds-border-subtle); font-size:10.5px; color:var(--tds-text-secondary); line-height:1.4; }
.vi-card.loading .vi-body { opacity:.55; }
.info-btn[disabled] { opacity:.5; cursor:default; }
.info-btn.spin svg { animation: vi-spin .8s linear infinite; }
@keyframes vi-spin { to { transform: rotate(360deg); } }
/* Boton unico "Cambios pendientes": gris/disabled sin cambios, ambar clicable con cambios */
.vi-changes-btn { display:inline-flex; align-items:center; gap:6px; font-size:11px; font-weight:600; padding:5px 10px; border-radius:7px; border:1px solid var(--tds-border-subtle); background:var(--tds-grey-50); color:var(--tds-text-secondary); cursor:default; white-space:nowrap; }
.vi-changes-btn .vi-dot { width:7px; height:7px; border-radius:50%; background:currentColor; flex-shrink:0; }
.vi-changes-btn.pending { background:#FFF6E6; border-color:var(--tds-yellow-500); color:#8a5a00; cursor:pointer; }
.vi-changes-btn.pending .vi-dot { animation: vi-pulse 1.4s ease-in-out infinite; }
.vi-changes-btn.pending:hover { background:#FFEFCC; }
.vi-changes-btn.busy { cursor:default; }
.vi-changes-btn.busy .vi-dot { width:11px; height:11px; background:none; border:2px solid currentColor; border-top-color:transparent; animation: vi-spin .7s linear infinite; }
.vi-changes-btn:not(.pending):not(.busy) { cursor:pointer; }   /* clicable -> modal "sin datos nuevos" */
@keyframes vi-pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

/* ===== Market Insight IA: insights + DAFO 2x2 ===== */
.mi-grid { display:grid; grid-template-columns: 0.85fr 1.15fr; gap:22px; align-items:start; }
.mi-sub { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--tds-text-secondary); margin-bottom:8px; }
.mi-insights ul { margin:0 0 0 16px; padding:0; font-size:12.5px; line-height:1.5; color:var(--neutral-800); }
.mi-insights li { margin:6px 0; }
.dafo-grid { display:grid; grid-template-columns:1fr 1fr; grid-template-rows:auto auto; gap:10px; }
.dafo-cell { border-radius:10px; padding:10px 12px; border:1px solid var(--tds-border-subtle); min-width:0; }
.dafo-h { font-size:11.5px; font-weight:700; margin-bottom:5px; display:flex; align-items:center; gap:6px; }
.dafo-h::before { content:""; width:8px; height:8px; border-radius:2px; background:currentColor; flex-shrink:0; }
.dafo-cell ul { margin:0 0 0 14px; padding:0; font-size:11.5px; line-height:1.45; color:var(--neutral-800); }
.dafo-cell li { margin:3px 0; }
.daf-f { background:#EAF7EE; border-color:#BFE6CB; } .daf-f .dafo-h { color:#1B7A3D; }
.daf-d { background:#FDEDEC; border-color:#F5C9C4; } .daf-d .dafo-h { color:#B23A2E; }
.daf-o { background:#EAF1FB; border-color:#C5D8F2; } .daf-o .dafo-h { color:#1E5BB8; }
.daf-a { background:#FBF4E6; border-color:#EBDAB0; } .daf-a .dafo-h { color:#8a5a00; }
@media (max-width:1280px){ .mi-grid { grid-template-columns:1fr; gap:16px; } }
@media (max-width:560px){ .dafo-grid { grid-template-columns:1fr; } }
.insights-modal-icon { width:40px;height:40px;border-radius:50%;background:var(--tds-grey-50);display:flex;align-items:center;justify-content:center;flex-shrink:0; }

/* ===== CARDS ===== */
.card {
  background: var(--tds-white);
  border-radius: var(--tds-radius-md);
  box-shadow: var(--shadow-sm);
  transition: all var(--tx);
  overflow: hidden;
}
.card-pad { padding: 20px 22px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.card-title {
  font-size: 14px; font-weight: 600;
  color: var(--neutral-900); letter-spacing: -.01em;
}
.card-sub { font-size: 12px; color: var(--neutral-500); margin-top: 3px; font-weight: 400; }

/* ===== SECTION HEADING ===== */
.section-h {
  display: flex; align-items: center; justify-content: space-between;
  margin: 32px 0 16px; gap: 12px;
}
.section-h:first-child { margin-top: 0; }
.section-h h2 {
  font-family: var(--font-sans);
  font-size: 20px; font-weight: 700;
  color: var(--neutral-900);
  letter-spacing: -.01em; line-height: 1.2;
}
.section-h .hint { font-size: 12px; color: var(--neutral-500); font-weight: 500; margin-left: 8px; }

/* ===== KPI ===== */
.kpi {
  background: var(--tds-white);
  border-radius: var(--tds-radius-md);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all var(--tx);
  box-shadow: var(--shadow-sm);
}
.kpi:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-label {
  font-size: 11px; color: var(--tds-text-secondary);
  font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 12px;
}
.kpi-value {
  font-size: 32px; font-weight: 800;
  color: var(--tds-text-primary);
  letter-spacing: -.03em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.kpi-value small {
  font-size: 14px; color: var(--tds-text-secondary);
  font-weight: 500; margin-left: 4px;
}
.kpi-footer { margin-top: 10px; display: flex; align-items: center; gap: 8px; font-size: 11.5px; }
.kpi-delta {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: var(--tds-radius-sm);
  font-weight: 600;
}
.kpi-delta.up { color: var(--tds-green-500); background: var(--tds-green-100); }
.kpi-delta.down { color: var(--tds-red-500); background: var(--tds-red-100); }
.kpi-delta.flat { color: var(--tds-text-secondary); background: var(--tds-grey-100); }
.kpi-hint { color: var(--tds-text-secondary); }
.kpi-b-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.kpi-ico { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; flex-shrink: 0; }
.kpi-ico svg { width: 15px; height: 15px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kpi-cells .kpi-b .kpi-label { margin-bottom: 0; }
.kpi-spark { width: 100%; height: 26px; margin-top: 8px; display: block; opacity: .85; }

/* ===== CABECERA · KPIs (3 columnas) + métricas de dispersión ===== */
.cabecera {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr 1.05fr;   /* KPIs (2 col) | perfil+sistema | insights IA */
  gap: 1px;                       /* líneas divisorias entre columnas */
  background: var(--tds-border-subtle);
}
.kpi-cells {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 1fr;
  gap: 1px;                       /* líneas entre KPIs */
  background: var(--tds-border-subtle);
}
/* Columna central: "Perfil del periodo" + "Sistema y datos" apilados */
.cabecera-center { background: var(--tds-white); display: flex; flex-direction: column; min-width: 0; }
.cabecera-center .cabecera-estado { border-top: 1px solid var(--tds-border-subtle); margin-top: auto; }
/* Columna derecha: caja de insights IA del Snapshot */
.cabecera-insights { background: var(--tds-white); padding: 14px 16px; display: flex; flex-direction: column; min-width: 0; }
.cabecera-insights .vi-head { margin-bottom: 8px; }
.cabecera-insights .vi-body { min-height: 0; max-height: 260px; font-size: 11.5px; }
.cabecera-insights .vi-foot { font-size: 10px; }
.kpi-cells .kpi {
  background: var(--tds-white);
  box-shadow: none;
  border-radius: 0;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.kpi-cells .kpi:hover { transform: none; box-shadow: none; background: var(--tds-grey-50); }
/* Compactación de la cabecera (menos scroll hasta las gráficas) */
.kpi-cells .kpi-label  { margin-bottom: 4px; }
.kpi-cells .kpi-value  { font-size: 22px; }
.kpi-cells .kpi-footer { margin-top: 4px; }
.cabecera-metrics { background: var(--tds-white); padding: 14px 20px; }
.cabecera-metrics .metrics-list {           /* métricas en 2 columnas: la mitad de alto */
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 24px;
}
.cabecera-metrics .metric-row { padding: 7px 0; }
.cabecera-metrics .metric-name .hint { display: none; }   /* subtítulo redundante */
.cabecera-metrics .metric-val .sub  { display: none; }    /* segunda línea -> filas a 1 línea */
/* Columna de estado del sistema (3ª columna de la cabecera) */
.cabecera-estado { background: var(--tds-white); padding: 14px 18px; }
.estado-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; font-size: 13px; color: var(--neutral-800);
  border-bottom: 1px dashed var(--tds-border-subtle);
}
.estado-row:last-child { border-bottom: none; }
.estado-row b { font-family: var(--font-mono); font-weight: 700; color: var(--neutral-900); }
.estado-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--tds-green-500); box-shadow: 0 0 0 3px rgba(29,140,77,.15);
  margin-right: 7px; vertical-align: middle;
}
/* Altura mínima de la cabecera: sin subtítulos en columnas métricas/estado y filas más juntas */
.cabecera-metrics .card-sub, .cabecera-estado .card-sub { display: none; }
.cabecera-estado .estado-row { padding: 4px 0; }

/* ===== Análisis ML (like-for-like, estacionalidad, arquetipos) ===== */
.lfl-attribution {
  margin-top: 14px; font-size: 13px; color: var(--neutral-700);
  background: var(--tds-grey-50); border: 1px solid var(--tds-border-subtle);
  border-radius: var(--tds-radius-sm); padding: 10px 14px;
}
.lfl-tag { font-weight: 700; color: var(--tds-blue-500); margin-right: 6px; }
.lfl-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 8px; }
.lfl-legend .li { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--tds-text-secondary); }
.lfl-legend .sw { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.lfl-legend .sw-dash { height: 2px; background: repeating-linear-gradient(90deg, var(--neutral-900) 0 5px, transparent 5px 8px); }

/* ===== Recompras por marca (leyenda interactiva) ===== */
.recompra-legend { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 12px; align-items: center; }
.rc-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--neutral-800); background: var(--tds-grey-50); border: 1px solid var(--tds-border-subtle); border-radius: 999px; padding: 4px 11px; cursor: pointer; transition: all var(--tx-fast); }
.rc-chip .sw { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.rc-chip:hover { border-color: var(--tds-blue-300); }
.rc-chip:focus-visible { outline: 2px solid var(--tds-blue-300); outline-offset: 1px; }
.rc-chip.off { opacity: .4; }
.rc-all { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--neutral-400); }
.rc-all button { font-size: 11px; font-weight: 700; color: var(--tds-blue-500); background: none; border: none; cursor: pointer; padding: 2px 5px; border-radius: 4px; }
.rc-all button:hover { background: var(--tds-blue-50); }
.recompra-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.conquista-foot { display: flex; flex-wrap: wrap; gap: 5px 12px; margin-top: 6px; }
.cq-item { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--neutral-700); font-weight: 500; }
.cq-item .sw { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.cq-item b { color: var(--neutral-900); font-weight: 700; margin-left: 1px; }
.fid-split { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--neutral-200); }
.fid-split-title { font-size: 11px; color: var(--neutral-600); font-weight: 600; margin-bottom: 6px; }
.fid-bar { display: flex; height: 22px; border-radius: 5px; overflow: hidden; }
.fid-bar > span { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 700; white-space: nowrap; min-width: 0; }
.fid-conq { background: var(--scania-brand-red, #d6001c); }
.fid-split-legend { display: flex; justify-content: space-between; margin-top: 5px; font-size: 10.5px; color: var(--neutral-600); }
.fid-split-legend .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
@media (max-width: 1100px) { .recompra-row { grid-template-columns: 1fr; } }
.mw-effective-row { display: flex; flex-direction: column; gap: 4px; }
.mw-effective-row .mw-eff-item { display: grid; grid-template-columns: 70px 1fr auto; align-items: center; gap: 8px; font-size: 11.5px; padding: 3px 0; }
.mw-effective-row .mw-eff-item .mw-eff-name { color: var(--neutral-800); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.mw-effective-row .mw-eff-item .mw-eff-name .sw { width: 9px; height: 9px; border-radius: 2px; }
.mw-effective-row .mw-eff-item .mw-eff-bar { background: var(--neutral-100); border-radius: 4px; height: 8px; position: relative; overflow: hidden; }
.mw-effective-row .mw-eff-item .mw-eff-bar > span { position: absolute; left: 0; top: 0; bottom: 0; }
.mw-effective-row .mw-eff-item .mw-eff-val { color: var(--neutral-900); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 11px; }
.mw-eff-note { font-size: 11px; color: var(--neutral-500); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--neutral-100); }
.archetype-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.arch-card {
  border: 1px solid var(--tds-border-subtle); border-radius: var(--tds-radius-md);
  padding: 12px 14px; background: var(--tds-grey-50);
}
.arch-name { font-weight: 700; font-size: 13.5px; color: var(--neutral-900); margin-bottom: 4px; }
.arch-share { font-size: 23px; font-weight: 800; color: var(--tds-blue-500); letter-spacing: -.02em; }
.arch-share small { font-size: 11px; font-weight: 500; color: var(--tds-text-secondary); margin-left: 5px; }
.arch-stats { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; font-size: 11.5px; color: var(--tds-text-secondary); }
.arch-stats b { color: var(--neutral-900); font-weight: 600; }
.arch-vehicles {
  margin-top: 10px; width: 100%; padding: 6px 10px; font-size: 11.5px; font-weight: 600;
  color: var(--tds-blue-500); background: var(--tds-white); border: 1px solid var(--tds-blue-300);
  border-radius: var(--tds-radius-sm); cursor: pointer; transition: all var(--tx-fast);
}
.arch-vehicles:hover { background: var(--tds-blue-50); }
@media (max-width: 900px) { .archetype-grid { grid-template-columns: 1fr; } }

/* ===== Modal (listado de vehículos por segmento) ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,32,.55); z-index: 1000; display: none; align-items: center; justify-content: center; padding: 24px; }
.modal-overlay.open { display: flex; }
.modal-dialog { background: var(--tds-white); border-radius: var(--tds-radius-md); box-shadow: 0 20px 60px rgba(0,0,0,.3); width: min(980px, 100%); max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--tds-border-subtle); }
.modal-title { font-size: 16px; font-weight: 700; color: var(--neutral-900); }
.modal-sub { font-size: 12.5px; color: var(--tds-text-secondary); margin-top: 3px; }
.modal-close { flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--tds-border-subtle); background: var(--tds-white); color: var(--tds-text-secondary); font-size: 18px; line-height: 1; cursor: pointer; }
.modal-close:hover { background: var(--tds-grey-50); color: var(--neutral-900); }
.modal-body { padding: 16px 22px 22px; overflow: auto; }
/* Botón de ayuda (i) inline junto a títulos */
.info-btn { display:inline-flex; align-items:center; justify-content:center; width:22px; height:22px; padding:0; border-radius:50%; border:1px solid var(--tds-border-subtle); background:var(--tds-white); color:var(--tds-text-secondary); cursor:pointer; flex-shrink:0; transition: background .15s, color .15s, border-color .15s; }
.info-btn:hover { background: var(--tds-grey-50); color: var(--tds-blue-500); border-color: var(--tds-blue-300); }

/* ===== Margen potencial (escenarios 5/10/15/20/máx) ===== */
.margin-scn-totals { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--tds-text-secondary); }
.margin-scn-totals .pill { padding: 5px 9px; border-radius: var(--tds-radius-sm); background: var(--tds-grey-50); border: 1px solid var(--tds-border-subtle); display: inline-flex; align-items: baseline; gap: 6px; }
.margin-scn-totals .pill .lbl { font-weight: 600; color: var(--tds-text-secondary); }
.margin-scn-totals .pill .val { font-family: var(--font-mono); font-weight: 700; color: var(--neutral-900); font-size: 12.5px; }
.margin-scn-totals .pill.max { background: var(--tds-blue-50); border-color: var(--tds-blue-300); }
.margin-scn-totals .pill.max .val { color: var(--tds-blue-500); }
.margin-scn-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 10px 0 6px; font-size: 11.5px; font-weight: 600; color: var(--tds-text-secondary); }
.margin-scn-legend .li { display: inline-flex; align-items: center; gap: 6px; }
.margin-scn-legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.margin-scn-foot { margin-top: 8px; font-size: 11.5px; color: var(--tds-text-secondary); line-height: 1.45; }

/* Aviso bajo gráficas (e.g. gap 0-2 años en reventa de mercado vs tasación) */
.mkt-depr-note { margin-top: 10px; padding: 9px 12px; border-radius: var(--tds-radius-sm); background: #FFF7E6; border: 1px solid #F2D58A; color: #6B4F00; font-size: 12px; line-height: 1.5; display: flex; gap: 9px; align-items: flex-start; }
.mkt-depr-note .nicon { flex-shrink: 0; width: 16px; height: 16px; color: #B8860B; margin-top: 1px; }
.mkt-depr-note b { color: #5A4100; font-weight: 700; }
.mkt-depr-note .nkv { display: inline-block; font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 3px; background: rgba(255,255,255,.55); margin: 0 2px; }

/* ===== Depreciación por marca ===== */
.depr-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
.depr-legend .li { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--tds-text-secondary); }
.depr-legend .sw { width: 14px; height: 3px; border-radius: 2px; }
.depr-grid .ops-row { grid-template-columns: 1.3fr 1fr 1fr 1.1fr 1fr 1fr .6fr; }

/* KPIs comparativos en la cabecera de "Indicadores de depreciación por marca" */
.depr-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 10px 0 14px; }
.depr-kpis .dk { padding: 9px 11px; border-radius: var(--tds-radius-sm); background: var(--tds-grey-50); border: 1px solid var(--tds-border-subtle); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.depr-kpis .dk-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--tds-text-secondary); }
.depr-kpis .dk-val { font-size: 13px; font-weight: 700; color: var(--neutral-900); display: inline-flex; align-items: center; gap: 6px; }
.depr-kpis .dk-val .swatch { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.depr-kpis .dk-sub { font-size: 10.5px; color: var(--tds-text-secondary); font-family: var(--font-mono); }
.depr-kpis .dk.best { background: linear-gradient(180deg, #E8F5EE 0%, #F5FBF7 100%); border-color: #C9E4D2; }
.depr-kpis .dk.worst { background: linear-gradient(180deg, #FBEAEA 0%, #FDF6F6 100%); border-color: #EFC5C5; }
@media (max-width: 700px) { .depr-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ===== Layout Panel General: rail de filtros (izda) + contenido ===== */
.panel-layout { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 18px; align-items: start; }
.panel-main { min-width: 0; }
.filter-rail {
  position: sticky; top: calc(var(--topnav-h) + 16px);
  background: var(--tds-white); border: 1px solid var(--tds-border-subtle);
  border-radius: var(--tds-radius-md); box-shadow: var(--shadow-sm);
  padding: 14px 12px; display: flex; flex-direction: column; gap: 12px;
}
.filter-rail label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--tds-text-secondary); display: block; margin-bottom: 5px; }
.filter-rail .input, .filter-rail .select { width: 100%; min-width: 0; }
.filter-rail .rail-check { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 500; color: var(--neutral-700); text-transform: none; letter-spacing: 0; margin: 0; cursor: pointer; }
.filter-rail .rail-check input { width: 14px; height: 14px; accent-color: var(--scania-brand-red); cursor: pointer; flex-shrink: 0; }
.chips-vert { display: flex; flex-direction: column; gap: 5px; }
.chips-vert .chip { width: 100%; text-align: center; }
.rail-actions { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--tds-border-subtle); padding-top: 12px; }
.rail-actions .btn { width: 100%; justify-content: center; }
.rail-admin { display: flex; align-items: center; gap: 6px; justify-content: center; padding: 8px; border-radius: var(--tds-radius-sm); background: var(--tds-grey-50); border: 1px solid var(--tds-border-subtle); color: var(--tds-text-primary); font-weight: 600; font-size: 12.5px; text-decoration: none; }
.rail-admin:hover { background: var(--tds-blue-50); border-color: var(--tds-blue-300); }

/* Checkboxes de fuente en "Estado del sistema" */
.src-row { cursor: pointer; user-select: none; }
.src-check { display: inline-block; width: 13px; height: 13px; border: 1.5px solid var(--tds-grey-300); border-radius: 3px; margin-right: 7px; vertical-align: -2px; position: relative; transition: all var(--tx-fast); }
.src-row.on .src-check { background: var(--tds-blue-300); border-color: var(--tds-blue-300); }
.src-row.on .src-check::after { content: ''; position: absolute; left: 3.5px; top: 0.5px; width: 3px; height: 7px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.estado-ambas span, .estado-ambas b { color: var(--tds-green-500); }
.estado-ambas .estado-dot { background: var(--tds-green-500); }

/* "Perfil del periodo" + toggle de detalle estadístico */
.perfil-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stats-toggle { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--tds-border-subtle); background: var(--tds-white); color: var(--tds-text-secondary); font-size: 11px; line-height: 1; cursor: pointer; padding: 0; }
.stats-toggle:hover, .stats-toggle.on { background: var(--tds-blue-50); color: var(--tds-blue-400); border-color: var(--tds-blue-300); }
#statsDetail { border-top: 1px dashed var(--tds-border-subtle); margin-top: 8px; padding-top: 8px; }

/* Toggle "Solo Scania" (switch + etiqueta) */
.scania-sw { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--tds-text-secondary); cursor: pointer; user-select: none; }
.scania-sw .switch { flex-shrink: 0; }

@media (max-width: 1000px) {
  .panel-layout { grid-template-columns: 1fr; }
  .filter-rail { position: static; flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
  .filter-rail .rail-group { flex: 1 1 140px; }
  .filter-rail .rail-actions { flex: 1 1 100%; flex-direction: row; border-top: none; padding-top: 0; }
  .chips-vert { flex-direction: row; }
}
@media (max-width: 1100px) {
  .cabecera { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .kpi-cells { grid-template-columns: repeat(2, 1fr); }
  .cabecera-metrics .metrics-list { grid-template-columns: 1fr; }
}

/* ===== FILTER BAR ===== */
.filter-bar {
  background: var(--tds-white);
  border-radius: var(--tds-radius-md);
  box-shadow: var(--shadow-sm);
  padding: 12px 18px;
  margin-bottom: 16px;
}
.filter-row { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-group label {
  font-size: 10.5px;
  font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--tds-text-secondary);
}

.input, .select {
  appearance: none;
  background: var(--tds-white);
  border: 1px solid var(--tds-border-subtle);
  border-radius: var(--tds-radius-sm);
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 13px; color: var(--neutral-900);
  min-width: 130px;
  transition: border-color var(--tx-fast), box-shadow var(--tx-fast);
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--tds-blue-300);
  box-shadow: 0 0 0 3px rgba(61,133,221,.15);
}
.select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3e%3cpath fill='none' stroke='%235C6675' stroke-width='1.5' d='M1 1l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.chips { display: flex; gap: 6px; }
.chip {
  border: 1px solid var(--tds-border-subtle);
  background: var(--tds-white);
  color: var(--tds-text-secondary);
  padding: 6px 12px;
  border-radius: var(--tds-radius-sm);
  font-size: 12px; font-weight: 600;
  transition: all var(--tx-fast);
}
.chip:hover { border-color: var(--tds-blue-300); color: var(--tds-blue-300); }
.chip.active {
  background: var(--tds-blue-300);
  color: var(--tds-white);
  border-color: var(--tds-blue-300);
}

.toggle-group {
  display: flex;
  background: var(--tds-grey-100);
  border: 1px solid var(--tds-border-subtle);
  border-radius: var(--tds-radius-sm);
  padding: 3px;
}
.toggle-group button {
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  color: var(--tds-text-secondary);
  border-radius: 3px;
  transition: all var(--tx-fast);
}
.toggle-group button.active {
  background: var(--tds-white);
  color: var(--neutral-900);
  box-shadow: var(--shadow-sm);
}

/* ===== CHART ===== */
.chart-container { position: relative; width: 100%; }
svg.chart { width: 100%; height: auto; display: block; }
.axis-label { font-family: var(--font-mono); font-size: 11px; fill: var(--neutral-600); }
/* Quick wins UI/UX: foco visible global + micro-transiciones + respeto a reduced-motion */
button, .toggle-group button, .chip, .rc-chip, .switch, select, input, a.rail-admin, .kpi-hint { transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease; }
.card { transition: box-shadow .18s ease; }
button:focus-visible, .toggle-group button:focus-visible, .chip:focus-visible, .switch:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--tds-blue-300); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; } }
.grid-line { stroke: var(--tds-border-subtle); stroke-width: 1; stroke-dasharray: 2 4; }
.axis-line { stroke: var(--tds-border-strong); stroke-width: 1; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; }
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--neutral-600); font-weight: 500;
}
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-line { width: 14px; height: 2px; border-radius: 1px; }
.legend-band { width: 14px; height: 10px; border-radius: 2px; opacity: .35; }

/* Tooltip */
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--neutral-900);
  color: white;
  padding: 10px 12px;
  border-radius: var(--tds-radius-sm);
  font-size: 11.5px;
  font-family: var(--font-mono);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .12s;
  z-index: 5;
  min-width: 180px;
  transform: translate(-50%, -100%);
  margin-top: -8px;
}
.tooltip.visible { opacity: 1; }
.tooltip-row { display: flex; justify-content: space-between; gap: 14px; }
.tooltip-row + .tooltip-row { margin-top: 4px; }
.tooltip-label { color: var(--neutral-400); }
.tooltip-value { color: white; font-weight: 600; }
.tooltip-title {
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--neutral-400);
  margin-bottom: 6px; padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

/* Bars */
.bar { fill: var(--neutral-900); transition: fill .15s; cursor: pointer; }
.bar:hover { fill: var(--tds-blue-300); }
.bar.high { fill: var(--scania-brand-red); }

/* ===== METRICS LIST ===== */
.metrics-list { display: flex; flex-direction: column; }
.metric-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed var(--tds-border-subtle);
  gap: 16px;
}
.metric-row:last-child { border-bottom: none; }
.metric-name { font-size: 13px; color: var(--neutral-800); }
.metric-name .hint {
  font-size: 11px; color: var(--tds-text-secondary);
  display: block; margin-top: 2px;
}
.metric-val {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--neutral-900);
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.metric-val .sub {
  display: block;
  font-size: 10.5px;
  color: var(--tds-text-secondary);
  margin-top: 2px;
  font-weight: 400;
}

/* ===== LOADED OFFER BANNER ===== */
.offer-banner {
  background: linear-gradient(135deg, var(--scania-brand-blue) 0%, #0a3a6e 100%);
  color: white;
  border-radius: var(--tds-radius-md);
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.offer-banner::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--scania-brand-red);
}
.offer-banner-grid {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 28px;
  align-items: center;
}
.offer-banner-block { line-height: 1.25; }
.offer-banner-block .lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.55);
  font-weight: 600;
  margin-bottom: 4px;
  font-family: var(--font-mono);
}
.offer-banner-block .val {
  font-size: 15px;
  font-weight: 700;
  color: white;
  letter-spacing: -.01em;
}
.offer-banner-block .val .mono {
  font-family: var(--font-mono);
  font-weight: 600;
}
.offer-banner-block .sub {
  font-size: 11px;
  color: rgba(255,255,255,.7);
  margin-top: 2px;
}
.offer-banner-ref {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px;
  background: rgba(255,255,255,.1);
  border-radius: var(--tds-radius-sm);
  border: 1px solid rgba(255,255,255,.15);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: white;
}
.offer-banner-ref .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #86EFAC;
  box-shadow: 0 0 8px #86EFAC;
}
.offer-load-input {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: white;
  padding: 8px 12px;
  border-radius: var(--tds-radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  width: 160px;
}
.offer-load-input::placeholder { color: rgba(255,255,255,.5); }
.offer-load-input:focus {
  outline: none;
  border-color: var(--tds-blue-200);
  background: rgba(255,255,255,.15);
}
.offer-load-btn {
  background: white;
  color: var(--scania-brand-blue);
  padding: 8px 14px;
  border-radius: var(--tds-radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  transition: all var(--tx-fast);
}
.offer-load-btn:hover { background: var(--tds-blue-50); }

/* ===== VERDICT CARD ===== */
.verdict-card {
  position: relative;
  background: var(--tds-white);
  border-radius: var(--tds-radius-md);
  padding: 28px 32px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: all var(--tx);
}
.verdict-band {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  transition: background var(--tx);
}
.verdict-card.positive .verdict-band { background: var(--tds-green-500); }
.verdict-card.neutral  .verdict-band { background: var(--tds-yellow-500); }
.verdict-card.negative .verdict-band { background: var(--scania-brand-red); }

.verdict-grid {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 28px;
  align-items: center;
}

.verdict-light {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  flex-shrink: 0;
  transition: all var(--tx);
}
.verdict-light::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  opacity: .15;
  transition: background var(--tx);
}
.verdict-card.positive .verdict-light { background: var(--tds-green-500); box-shadow: 0 0 28px rgba(29,140,77,.4); }
.verdict-card.positive .verdict-light::before { background: var(--tds-green-500); }
.verdict-card.neutral  .verdict-light { background: var(--tds-yellow-500); box-shadow: 0 0 28px rgba(214,137,43,.4); }
.verdict-card.neutral  .verdict-light::before { background: var(--tds-yellow-500); }
.verdict-card.negative .verdict-light { background: var(--scania-brand-red); box-shadow: 0 0 28px rgba(214,0,28,.4); }
.verdict-card.negative .verdict-light::before { background: var(--scania-brand-red); }
.verdict-light svg { color: white; }

.verdict-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--tds-text-secondary);
  font-weight: 700;
  margin-bottom: 6px;
}
.verdict-title {
  font-family: var(--font-sans);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -.025em;
  line-height: 1.05;
  color: var(--neutral-900);
  transition: color var(--tx);
}
.verdict-card.positive .verdict-title em { color: var(--tds-green-500); }
.verdict-card.neutral  .verdict-title em { color: var(--tds-yellow-500); }
.verdict-card.negative .verdict-title em { color: var(--scania-brand-red); }
.verdict-title em { font-style: normal; font-weight: 800; }

.verdict-summary {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--neutral-600);
  max-width: 560px;
  line-height: 1.55;
}

.confidence-meter { width: 130px; text-align: center; }
.confidence-meter .label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--tds-text-secondary);
  font-weight: 700;
  margin-bottom: 8px;
}
.confidence-circle { position: relative; width: 110px; height: 110px; margin: 0 auto; }
.confidence-circle svg { transform: rotate(-90deg); }
.confidence-circle .value {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 28px;
  color: var(--neutral-900);
  letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
}
.confidence-circle .value .pct {
  font-size: 14px;
  color: var(--tds-text-secondary);
  font-weight: 500;
  margin-left: 1px;
}

/* ===== MARGIN CARD (sliders) ===== */
.margin-card {
  background: var(--tds-white);
  border-radius: var(--tds-radius-md);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  height: 100%;
}
.margin-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--neutral-900);
  letter-spacing: -.01em;
  margin-bottom: 4px;
}
.margin-card-sub {
  font-size: 11.5px;
  color: var(--tds-text-secondary);
  margin-bottom: 18px;
}

.slider-block { margin-bottom: 16px; }
.slider-block:last-of-type { margin-bottom: 12px; }
.slider-block .slider-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.slider-block .slider-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--neutral-800);
}
.slider-block .slider-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--neutral-900);
  font-variant-numeric: tabular-nums;
}
.slider-block .slider-amount {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tds-text-secondary);
  margin-top: 4px;
  display: block;
}
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--tds-grey-200);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: var(--tds-blue-300);
  border-radius: 50%; cursor: pointer;
  border: 2px solid var(--tds-white);
  box-shadow: 0 2px 4px rgba(15,23,42,.15);
  transition: all var(--tx-fast);
}
input[type=range]::-webkit-slider-thumb:hover {
  background: var(--tds-blue-400);
  transform: scale(1.15);
}
input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px;
  background: var(--tds-blue-300);
  border-radius: 50%; cursor: pointer;
  border: 2px solid var(--tds-white);
  box-shadow: 0 2px 4px rgba(15,23,42,.15);
}
.margin-total {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--tds-border-subtle);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: baseline;
}
.margin-total .total-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--tds-text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.margin-total .total-val {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 800;
  color: var(--neutral-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.margin-total .total-amount {
  grid-column: 1 / -1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--tds-blue-300);
  font-weight: 600;
}

.scania-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: var(--tds-grey-50);
  border-radius: var(--tds-radius-sm);
  border: 1px solid var(--tds-border-subtle);
  margin-bottom: 18px;
}
.scania-toggle .label-text {
  font-size: 13px; font-weight: 600;
  color: var(--neutral-900);
  display: flex; align-items: center; gap: 8px;
}
.scania-toggle .label-text .scania-pill {
  font-size: 9.5px;
  background: var(--scania-brand-red);
  color: white;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: .05em;
}
.switch {
  position: relative;
  width: 38px; height: 22px;
  background: var(--tds-grey-300);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--tx-fast);
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--tds-white);
  border-radius: 50%;
  transition: transform var(--tx-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch.on { background: var(--tds-blue-300); }
.switch.on::after { transform: translateX(16px); }

/* ===== POSITION BAR ===== */
.position-bar {
  position: relative;
  height: 64px;
  background: var(--tds-grey-50);
  border-radius: var(--tds-radius-sm);
  margin-top: 12px;
  border: 1px solid var(--tds-border-subtle);
}
.position-band {
  position: absolute;
  top: 8px; bottom: 8px;
  background: linear-gradient(90deg, rgba(29,140,77,.15), rgba(199,45,31,.15));
  border-radius: 3px;
}
.position-mean {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--neutral-900);
  opacity: .5;
}
.position-mean::before {
  content: 'μ';
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tds-text-secondary);
}
.position-marker {
  position: absolute;
  top: -4px; bottom: -4px;
  width: 3px;
  background: var(--tds-blue-300);
  border-radius: 2px;
  box-shadow: 0 0 0 4px rgba(61,133,221,.18);
  transition: left var(--tx);
}
.position-marker::after {
  content: 'OFERTA';
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--tds-blue-300);
  font-weight: 700;
  letter-spacing: .06em;
  white-space: nowrap;
}
.position-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 30px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--tds-text-secondary);
}

/* ===== COMPARABLES TABLE (Tegel ops-grid style) ===== */
.ops-grid {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--tds-border-subtle);
  border-radius: var(--tds-radius-sm);
  overflow: hidden;
}
.ops-row {
  display: grid;
  grid-template-columns: 90px 100px 1fr 60px 90px 110px 100px;
  align-items: center;
  border-bottom: 1px solid var(--tds-border-subtle);
  transition: background var(--tx-fast);
}
.ops-row:last-child { border-bottom: none; }
.ops-row:not(.ops-head):hover { background: var(--tds-grey-50); }
.ops-row.ops-head {
  background: var(--tds-grey-100);
  font-size: 10px;
  color: var(--tds-text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--tds-border-strong);
}
.ops-cell {
  padding: 11px 12px;
  font-size: 12.5px;
  color: var(--neutral-900);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.ops-cell.ops-num { text-align: right; font-family: var(--font-mono); }
.ops-row.ops-head .ops-cell { padding: 9px 12px; font-weight: 700; }
.ops-row.ops-head .ops-cell.ops-num { text-align: right; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--tds-radius-sm);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-anomaly { background: var(--tds-red-100); color: var(--tds-red-500); }
.badge-normal  { background: var(--tds-green-100); color: var(--tds-green-500); }

/* ===== RECOMMENDATIONS ===== */
.rec-list { list-style: none; padding: 0; margin: 0; }
.rec-list li {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--tds-border-subtle);
  font-size: 13px;
  color: var(--neutral-800);
  line-height: 1.5;
}
.rec-list li:last-child { border-bottom: none; }
.rec-list .marker {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: var(--tds-radius-sm);
  background: var(--tds-blue-50);
  color: var(--tds-blue-300);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

/* ===== HELPERS ===== */
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 22px; }
.mb-4 { margin-bottom: 28px; }

.live-pulse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--tds-green-500);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.live-pulse .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tds-green-500);
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ===== TAB 2 LAYOUT ===== */
.strategic-main-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
  align-items: stretch;
}
.kpi-stack {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  align-content: start;
}
.kpi-stack .kpi { padding: 18px 20px; }
.kpi-stack .kpi-value { font-size: 26px; }
.kpi-stack .kpi-total {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--tds-grey-50) 0%, var(--tds-blue-50) 100%);
  border: 1px solid var(--tds-blue-100);
}
.kpi-stack .kpi-total .kpi-value { font-size: 36px; }

/* ===== TAB 2 · ESCENARIO (Agente Oferta) ===== */
.scenario-form { display: flex; flex-direction: column; gap: 12px; }
.scenario-form .field { display: flex; flex-direction: column; gap: 5px; }
.scenario-form label { font-size: 11.5px; font-weight: 600; color: var(--tds-text-secondary); }
.scenario-form .field-hint { font-weight: 500; color: var(--neutral-500); }
.btn-soft {
  margin-top: 14px; width: 100%; padding: 9px 12px; font-size: 12.5px; font-weight: 600;
  color: var(--tds-blue-500); background: var(--tds-blue-50); border: 1px solid var(--tds-blue-100);
  border-radius: 8px; cursor: pointer; transition: background .15s;
}
.btn-soft:hover { background: var(--tds-blue-100); }
.lever { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--tds-grey-200); }
.lever-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.lever-name { font-size: 12.5px; font-weight: 600; color: var(--neutral-800); }
.lever-value { font-size: 22px; font-weight: 800; color: var(--tds-blue-500); font-variant-numeric: tabular-nums; }
.lever-foot { margin-top: 7px; font-size: 11.5px; color: var(--tds-text-secondary); min-height: 16px; }
.position-techo { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--scania-brand-red); transform: translateX(-1px); z-index: 3; }
.position-techo::after { content: 'techo'; position: absolute; top: -15px; left: 50%; transform: translateX(-50%); font-size: 9px; font-weight: 700; color: var(--scania-brand-red); white-space: nowrap; }

/* ===== Riesgo de reventa (compuesto) ===== */
.risk-pill { font-size: 13px; font-weight: 800; padding: 6px 14px; border-radius: 999px; letter-spacing: .02em; white-space: nowrap; }
.risk-pill.bajo { background: var(--tds-green-100); color: var(--tds-green-500); }
.risk-pill.medio { background: #fbf0d9; color: var(--tds-yellow-500); }
.risk-pill.alto { background: var(--tds-red-100); color: var(--scania-brand-red); }
.risk-factors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.risk-factor { border: 1px solid var(--tds-border-subtle); border-radius: var(--tds-radius-md); padding: 12px 14px; }
.risk-factor-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.risk-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.risk-dot.bajo { background: var(--tds-green-500); }
.risk-dot.medio { background: var(--tds-yellow-500); }
.risk-dot.alto { background: var(--scania-brand-red); }
.risk-factor-name { font-size: 12.5px; font-weight: 700; color: var(--neutral-900); }
.risk-factor-detail { font-size: 11.5px; color: var(--tds-text-secondary); margin-bottom: 9px; }
.risk-weight { display: flex; align-items: center; gap: 8px; font-size: 10.5px; font-weight: 600; color: var(--tds-text-secondary); }
.risk-weight-bar { flex: 1; height: 5px; border-radius: 3px; background: var(--tds-grey-200); overflow: hidden; }
.risk-weight-bar > i { display: block; height: 100%; background: var(--tds-blue-300); border-radius: 3px; }
@media (max-width: 900px) { .risk-factors { grid-template-columns: 1fr; } }

/* ===== Agente Oferta · card superior (3 zonas) + fila de 3 columnas ===== */
.offer-top-grid { display: grid; grid-template-columns: 1.1fr 1.15fr 0.82fr; gap: 24px; align-items: center; }
/* Repartos por pestaña (antes vivían inline en el HTML, lo que impedía que las
   media queries los colapsaran en móvil). Aquí los reglas responsive sí ganan. */
.offer-top-grid--ops { grid-template-columns: 1.25fr 1fr 1.1fr; }
.offer-top-grid--tco { grid-template-columns: 1.5fr 0.85fr 1.25fr; }
.offer-verdict { display: flex; gap: 18px; align-items: flex-start; }
.offer-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 22px; border-left: 1px solid var(--tds-border-subtle); border-right: 1px solid var(--tds-border-subtle); }
.offer-kpis .kpi:hover { transform: none; box-shadow: none; }
.offer-margen { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.offer-margen .kpi-total { width: 100%; background: linear-gradient(135deg, var(--tds-grey-50) 0%, var(--tds-blue-50) 100%); border: 1px solid var(--tds-blue-100); }
.offer-margen .btn-soft { margin-top: 0; width: auto; padding: 7px 18px; }
.offer-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; align-items: start; }
.offer-verdict-col { display: flex; flex-direction: column; }
.risk-col-wrap { display: flex; flex-direction: column; }
.risk-col-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.risk-col { grid-template-columns: 1fr; gap: 8px; }
.risk-col .risk-factor { padding: 9px 12px; }
.ops-insights { margin-top: 10px; padding: 10px 12px; background: var(--tds-grey-50); border: 1px solid var(--tds-border-subtle); border-radius: var(--tds-radius-md); font-size: 12px; }
@media (max-width: 1100px) {
  .offer-top-grid { grid-template-columns: 1fr; gap: 18px; }
  .offer-kpis { border: none; padding: 0; }
  .offer-3col { grid-template-columns: 1fr; }
}

/* ===== Configurador de renovación (Valoración potencial) ===== */
.rnv-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--tds-blue-500); margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--tds-border-subtle); }
.rnv-group.first { margin-top: 0; padding-top: 0; border-top: none; }
.rnv-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.scenario-form.rnv-grid4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 6px 10px; }
.rnv-grid4 .rnv-group { grid-column: 1 / -1; margin-top: 8px; }
.rnv-grid4 .rnv-group.first { margin-top: 0; }
.rnv-grid4 .field label { font-size: 10px; }
.rnv-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.rnv-legend .li { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--tds-text-secondary); }
.rnv-legend .sw { width: 14px; height: 3px; border-radius: 2px; }
.rnv-sav { width: 100%; text-align: left; background: var(--tds-grey-50); border: 1px solid var(--tds-border-subtle); border-radius: var(--tds-radius-md); padding: 11px 14px; }
.rnv-sav-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--tds-text-secondary); margin-bottom: 7px; }
.rnv-sav-title span { text-transform: none; font-weight: 500; letter-spacing: 0; }
.rnv-sav-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; padding: 2.5px 0; }
.rnv-sav-row span { color: var(--neutral-700); }
.rnv-sav-row b { font-variant-numeric: tabular-nums; font-weight: 800; }
.rnv-sav-note { font-size: 10.5px; color: var(--neutral-500); margin-top: 6px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1280px) {
  .grid-kpi-6 { grid-template-columns: repeat(3, 1fr); }
  .grid-3, .grid-half, .grid-main, .grid-main-2, .grid-corr { grid-template-columns: 1fr; }
  .strategic-main-grid { grid-template-columns: 1fr; }
  .offer-banner-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
}
@media (max-width: 1120px) {
  /* El menú (4 paneles + 2 herramientas) no cabe en una fila: pasa a su propia fila con scroll */
  .topnav { grid-template-columns: 1fr auto; min-height: 0; gap: 4px 14px; padding: 8px 16px 0; }
  .topnav > .brand { justify-self: start; }
  .topnav > .topnav-tabs { grid-column: 1 / -1; justify-self: stretch; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .topnav > .topnav-tabs::-webkit-scrollbar { display: none; }
  .topnav-tabs button { flex-shrink: 0; min-width: 78px; padding: 6px 11px 10px; }
  .topnav-tabs button .tab-ico { width: 28px; height: 28px; }
  .topnav > .topnav-spacer { justify-self: end; align-self: center; }
  .topnav-admin span { display: none; }
}
@media (max-width: 900px) {
  .topnav { grid-template-columns: 1fr auto; height: auto; gap: 8px; padding: 10px 14px; }
  .topnav > .brand, .topnav > .topnav-tabs { justify-self: stretch; }
  .topnav > .topnav-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; grid-column: 1 / -1; }
  .topnav > .topnav-tabs::-webkit-scrollbar { display: none; }
  .topnav-tabs button { white-space: nowrap; flex-shrink: 0; }
  .topnav > .topnav-spacer { justify-self: end; align-self: center; }
  .topnav-admin span { display: none; }
  .topnav-admin { padding: 7px 9px; }
  .grid-kpi-6 { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 18px; }
  .page-title { font-size: 24px; }
  .verdict-grid { grid-template-columns: 1fr; gap: 18px; }
  .verdict-title { font-size: 26px; }
  .kpi-stack { grid-template-columns: 1fr; }
  .offer-banner-grid { grid-template-columns: 1fr; }
}

/* ===========================================================
   MÓVIL · experiencia tipo app (M0 + gráficas táctiles)
   =========================================================== */
/* Táctil base (todas las resoluciones): sin delay de 300ms */
button, a, .chip, .rc-chip, .toggle-group button, select, .switch, .scania-sw, .info-btn, .bottomnav-item, .vi-changes-btn { touch-action: manipulation; }
.chart-container { touch-action: pan-y; }   /* scroll vertical normal; arrastre horizontal = inspeccionar */
@media (hover: none) {
  button:active, .chip:active, .rc-chip:active, .toggle-group button:active, .btn-soft:active, .bottomnav-item:active, .vi-changes-btn:active { transform: scale(.97); }
}
.bottomnav { display: none; }   /* solo móvil */

@media (max-width: 768px) {
  body { overscroll-behavior-y: contain; }
  /* Top app bar compacto: la barra inferior sustituye a las pestañas */
  .topnav { grid-template-columns: 1fr auto; min-height: 52px; padding: 0 14px; padding-top: env(safe-area-inset-top); gap: 8px; }
  .topnav-tabs { display: none; }
  .topnav > .topnav-spacer { display: flex; justify-self: end; align-self: center; }
  .topnav > .brand { justify-self: start; }
  .topnav-admin span { display: none; }
  .topnav-admin { padding: 6px 8px; }
  .brand-logo { width: 32px; height: 32px; }
  .brand-text .name { font-size: 13px; line-height: 1.05; }

  /* Hueco inferior para la barra fija */
  .content { padding: 16px 14px calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 20px); }

  /* Barra de navegación inferior tipo app */
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255,255,255,.97); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--neutral-200); box-shadow: 0 -2px 12px rgba(15,23,32,.06);
  }
  .bottomnav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: none; background: none; color: var(--tds-text-secondary);
    font-size: 10px; font-weight: 600; letter-spacing: -.01em; line-height: 1;
    min-height: 44px; padding: 7px 2px; cursor: pointer;
  }
  .bottomnav-item svg { width: 23px; height: 23px; display: block; }
  .bottomnav-item.active { color: var(--tds-blue-300); }
  /* Separa el área de Herramientas (VO Ops · TCO) de los paneles BI/IA */
  .bottomnav-item[data-tab="strategic"] { border-left: 1px solid var(--neutral-200); }

  /* Touch targets ≥44px + inputs a 16px (evita auto-zoom iOS) */
  .toggle-group button { min-height: 42px; padding: 0 14px; }
  .chip { min-height: 40px; display: inline-flex; align-items: center; }
  .btn-soft { min-height: 44px; }
  .scania-sw { min-height: 44px; }
  .info-btn { width: 32px; height: 32px; }
  select, .select, input, .input { min-height: 44px; font-size: 16px; }
  .vi-changes-btn { min-height: 40px; }

  /* La tarjeta IA (1/5) a ancho completo bajo la gráfica */
  .grid-corr { grid-template-columns: 1fr; }

  /* VO Ops AI / TCO AI · formularios usables en móvil */
  .scenario-form .input, .scenario-form .select { width: 100%; }   /* el input llena su celda (no se desborda) */
  .scenario-form.rnv-grid4 { grid-template-columns: 1fr 1fr; gap: 12px 12px; }
  .rnv-grid4 .field label { font-size: 11.5px; }
  /* Riesgo de reventa y KPIs de resultado a ancho completo al apilarse */
  .offer-kpis { grid-template-columns: 1fr 1fr; padding: 0; border: none; }
  .confidence-meter { width: 100%; }
}

@media (max-width: 460px) {
  /* Configurador TCO en una sola columna: formulario apilado tipo app */
  .scenario-form.rnv-grid4 { grid-template-columns: 1fr; }
  /* Gauge + ahorro (columna derecha de TCO) se apilan en pantallas muy estrechas */
  #renovVerdict .offer-margen > div[style*="display:flex"] { flex-direction: column; gap: 14px; }
}

/* ===== TCO AI · exportar (botones + estilos de captura) ===== */
.tco-export-bar { display:flex; align-items:center; justify-content:flex-end; gap:8px; flex-wrap:wrap; margin-bottom:12px; }
.tco-export-bar .btn-export { display:inline-flex; align-items:center; gap:7px; padding:9px 14px; border:1px solid var(--tds-border-subtle); background:var(--tds-white); color:var(--neutral-800); font-size:12.5px; font-weight:600; border-radius:var(--tds-radius-md); cursor:pointer; }
.tco-export-bar .btn-export:hover { background:var(--tds-grey-50); border-color:var(--tds-grey-300); }
.tco-export-bar .btn-export:disabled { opacity:.55; cursor:wait; }
.tco-export-bar .btn-export svg { flex-shrink:0; }
/* Marca temporal aplicada al contenedor a capturar para forzar fondo blanco / sin sombras */
.tco-capturing { background:#fff; padding:18px; border-radius:0; box-shadow:none !important; }
.tco-capturing .card { box-shadow:0 0 0 1px var(--tds-border-subtle) !important; }
