/* ─── Variables ──────────────────────────────────────────────── */
:root {
  --blue:    #0071e3;
  --green:   #34c759;
  --red:     #ff3b30;
  --orange:  #ff9500;
  --bg:      #f5f5f7;
  --card:    #ffffff;
  --border:  #d2d2d7;
  --text:    #1d1d1f;
  --muted:   #6e6e73;
  --shadow:  0 2px 20px rgba(0,0,0,0.08);
  --r:       14px;
  --r-sm:    10px;
}

html { scroll-behavior: smooth; }
html.no-scroll, html.no-scroll body {
  overflow: hidden !important;
  height: 100vh !important;
  scrollbar-width: none !important;          /* Firefox */
  -ms-overflow-style: none !important;       /* IE/Edge legacy */
}
html.no-scroll::-webkit-scrollbar,
html.no-scroll body::-webkit-scrollbar { display: none !important; }
body {
  -webkit-font-smoothing: antialiased;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
input[type="text"]              { text-transform: uppercase; }
input[type="text"]::placeholder { text-transform: none; }

/* ─── Cards ──────────────────────────────────────────────────── */
.feature-card {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  background: var(--card);
  box-shadow: var(--shadow);
}
.feature-card:hover { transform: translateY(-4px); box-shadow: 0 8px 32px rgba(0,0,0,0.12); }
.step-card { transition: transform 0.25s ease; }
.step-card:hover { transform: translateY(-4px); }

/* ─── Utilidades ─────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Modal overlay ──────────────────────────────────────────── */
.modal-active         { opacity: 1 !important; pointer-events: auto !important; }
.modal-content-active { transform: scale(1) !important; opacity: 1 !important; }

/* ─── Progress list (2 columnas, sin scroll) ─────────────────── */
/* ─── Grupos de progreso ─────────────────────────────────────── */
.k-prog-group {
  margin-bottom: 8px;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s;
  background: rgba(255,255,255,0.5);
}
.k-prog-group:last-child { margin-bottom: 0; }
.k-prog-group-active { border-color: rgba(0,113,227,0.25); box-shadow: 0 0 0 1px rgba(0,113,227,0.08); background: rgba(255,255,255,0.7); }
.k-prog-group-done   { border-color: rgba(52,199,89,0.25); background: rgba(255,255,255,0.6); }

.k-prog-group-hd {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px;
  font-size: 11.5px; font-weight: 700; color: #7a8ba8;
  text-transform: uppercase; letter-spacing: 0.06em;
  background: rgba(0,0,0,0.02);
}
.k-prog-group-active .k-prog-group-hd { color: var(--blue); background: rgba(0,113,227,0.05); }
.k-prog-group-done   .k-prog-group-hd { color: var(--green); background: rgba(52,199,89,0.05); }

.k-prog-group-icon {
  font-size: 10px; width: 12px; text-align: center; flex-shrink: 0;
}
.k-prog-group-count {
  margin-left: auto;
  font-size: 9px; font-weight: 600; color: var(--caption);
  background: rgba(0,0,0,0.04); padding: 1px 6px; border-radius: 99px;
}
.k-prog-group-active .k-prog-group-count { color: var(--blue); background: rgba(0,113,227,0.1); }
.k-prog-group-done   .k-prog-group-count { color: var(--green); background: rgba(52,199,89,0.1); }

.k-prog-group-list {
  list-style: none; margin: 0; padding: 2px 4px 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
}

.k-progress-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  transition: background 0.2s;
}
.k-prog-icon   { font-size: 13px; flex-shrink: 0; width: 15px; text-align: center; }
.k-prog-label  { flex: 1; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-prog-status {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px; white-space: nowrap;
}

/* estados */
.k-prog-pendiente  .k-prog-icon   { color: var(--caption); }
.k-prog-pendiente  .k-prog-label  { color: var(--muted); }
.k-prog-pendiente  .k-prog-status { color: var(--caption); background: rgba(0,0,0,0.03); }
.k-prog-procesando                { background: rgba(0,113,227,0.05); }
.k-prog-procesando .k-prog-icon   { color: var(--blue); }
.k-prog-procesando .k-prog-label  { color: var(--blue); font-weight: 500; }
.k-prog-procesando .k-prog-status { color: var(--blue); background: rgba(0,113,227,0.1); }
.k-prog-ok         .k-prog-icon   { color: var(--green); }
.k-prog-ok         .k-prog-status { color: var(--green); background: rgba(52,199,89,0.1); }
.k-prog-error      .k-prog-icon   { color: var(--red); }
.k-prog-error      .k-prog-status { color: var(--red); background: rgba(255,59,48,0.1); }
.k-prog-timeout    .k-prog-icon   { color: var(--orange); }
.k-prog-timeout    .k-prog-status { color: var(--orange); background: rgba(255,149,0,0.1); }

/* ─── Barra de progreso ──────────────────────────────────────── */
.k-progressbar-wrap {
  height: 6px; background: rgba(0,0,0,0.06); border-radius: 99px; overflow: hidden; margin-top: 12px;
  position: relative;
}
.k-progressbar-fill {
  height: 6px; border-radius: 99px; transition: width 0.6s ease;
  background: linear-gradient(90deg, #0071e3, #4facfe, #0071e3);
  background-size: 200% 100%;
  animation: k-bar-shimmer 2s linear infinite;
  position: relative;
}
.k-progressbar-glow {
  position: absolute; top: -3px; right: 0; bottom: -3px; width: 60px;
  background: radial-gradient(ellipse at right, rgba(0,113,227,0.4), transparent 70%);
  pointer-events: none;
  animation: k-glow-pulse 1.5s ease-in-out infinite;
}
@keyframes k-bar-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes k-glow-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ─── Spinner ────────────────────────────────────────────────── */
@keyframes k-spin { to { transform: rotate(360deg); } }
.k-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(0,113,227,0.2); border-top-color: var(--blue);
  border-radius: 50%; animation: k-spin 0.75s linear infinite; flex-shrink: 0;
}
.k-spinner-lg { width: 24px; height: 24px; border-width: 3px; }

@keyframes k-fadein { from { opacity:0; transform:translateY(3px); } to { opacity:1; transform:none; } }
.k-prog-group { animation: k-fadein 0.2s ease both; }
.k-progress-item { animation: k-fadein 0.15s ease both; }

/* Transición de completado */
.k-progress-collapsing .k-prog-group {
  transition: opacity 0.4s ease, transform 0.4s ease, max-height 0.5s ease;
  opacity: 0; transform: translateY(-8px); max-height: 0; overflow: hidden;
  margin-bottom: 0; border: none; padding: 0;
}
.k-progressbar-complete .k-progressbar-fill {
  background: linear-gradient(90deg, #22c55e, #4ade80, #22c55e);
  background-size: 200% 100%;
  animation: k-bar-shimmer 2s linear infinite;
}
.k-progressbar-complete .k-progressbar-glow {
  background: radial-gradient(ellipse at right, rgba(34,197,94,0.4), transparent 70%);
}
@keyframes k-result-in {
  from { opacity:0; transform:translateY(12px); }
  to { opacity:1; transform:none; }
}
.k-result-visible {
  animation: k-result-in 0.4s ease both;
}

/* ─── Visor de reporte (pantalla completa) ───────────────────── */
#report-viewer {
  display: none;
  position: fixed; inset: 0; z-index: 9000;
  background: #f5f5f7;
  flex-direction: column;
  overflow: hidden;
}
#report-viewer.open { display: flex; }

/* Navbar del visor */
.viewer-nav {
  flex-shrink: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #e5e5ea;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.viewer-nav-left  { display: flex; align-items: center; gap: 12px; }
.viewer-nav-right { display: flex; align-items: center; gap: 8px; }
.viewer-back-btn  {
  display: flex; align-items: center; gap: 5px;
  color: var(--blue); font-size: 13px; font-weight: 500;
  cursor: pointer; background: none; border: none; padding: 4px 8px; border-radius: 6px;
  transition: background 0.15s;
}
.viewer-back-btn:hover { background: rgba(0,113,227,0.07); }
.viewer-plate-badge {
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em;
  background: #1d1d1f; color: #fff;
  padding: 4px 12px; border-radius: 6px;
}
/* Cuerpo scrollable del visor */
.viewer-body {
  flex: 1; overflow-y: auto; padding: 24px 32px;
}
.viewer-body::-webkit-scrollbar { width: 6px; }
.viewer-body::-webkit-scrollbar-track { background: transparent; }
.viewer-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.viewer-doc {
  max-width: 1600px; margin: 0 auto; width: 100%;
  padding: 0 12px;
  display: flex; flex-direction: column; gap: 14px;
}

/* ── Dashboard: Hero card ──────────────────────────────────── */
.dash-hero {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 0 0 24px;
  color: #111827;
  display: flex; flex-direction: column; gap: 20px;
  overflow: visible;
}
.dash-hero-header {
  display: flex; align-items: center; gap: 20px;
}
/* Placa peruana */
.peru-plate {
  display: inline-flex; flex-direction: column; align-items: center;
  background: #fff; border: 3px solid #222; border-radius: 8px;
  padding: 3px 18px 7px; box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  flex-shrink: 0;
}
.peru-plate-top {
  display: flex; align-items: center; gap: 6px; width: 100%;
  justify-content: center; margin-bottom: 1px; position: relative;
}
.peru-plate-flag {
  display: flex; width: 16px; height: 11px; border: 1px solid #bbb;
  overflow: hidden; border-radius: 1px; position: absolute; left: 0; top: 1px;
}
.pf-r { flex: 1; background: #d91023; }
.pf-w { flex: 1; background: #fff; }
.peru-plate-country {
  font-size: 10px; font-weight: 800; color: #222; letter-spacing: 0.18em;
  font-family: 'Arial Black', Arial, sans-serif;
}
.peru-plate-number {
  font-size: 30px; font-weight: 900; color: #111; letter-spacing: 0.06em;
  font-family: 'Arial Black', Arial, sans-serif; line-height: 1;
}
.dash-hero-vehicle {
  display: flex; flex-direction: column; gap: 2px;
}
.dash-hero-vname {
  font-size: 22px; font-weight: 800; color: #111827; letter-spacing: -0.01em;
}
.dash-hero-vmeta {
  font-size: 13px; color: #6b7280; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.dash-hero-color-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.1); display: inline-block; flex-shrink: 0;
}
.dash-hero-vowner {
  font-size: 13px; color: #374151; font-weight: 600; margin-top: 4px;
}
.dash-hero-vowner-lbl {
  display: block; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.04em; color: #9ca3af; font-weight: 600; margin-bottom: 1px;
}
/* Cada copropietario en su propia línea: en una sola corrida se leen como uno */
.dash-hero-vowner-name { display: block; line-height: 1.35; }
.dash-hero-vowner-name + .dash-hero-vowner-name { margin-top: 1px; }
.dash-hero-tagline {
  text-align: center; padding: 24px 32px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  border-radius: 16px 16px 0 0;
}
.dash-hero-tagline strong {
  display: block; font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.12em; color: #ffffff; font-weight: 800; margin-bottom: 4px;
}
.dash-hero-tagline span {
  font-size: 13px; color: rgba(255,255,255,0.6); font-weight: 400;
}
.dash-hero-main {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 32px 10px;
}
.dash-hero-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px 0; border-top: 1px solid #f3f4f6;
}
.dash-hero-badges {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.dash-hero-prop {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f0f4ff; border: 1px solid #c7d2fe; border-radius: 8px;
  padding: 6px 14px;
}
.dash-hero-prop-val {
  font-size: 15px; font-weight: 800; color: #3730a3;
}
.dash-hero-prop-lbl {
  font-size: 11px; font-weight: 500; color: #6b7280;
}
.dash-hero-debt {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff1f2; border: 1px solid #fecaca; border-radius: 8px;
  padding: 6px 14px;
}
.dash-hero-debt-amount {
  font-size: 15px; font-weight: 800; color: #b91c1c;
}
.dash-hero-debt-label {
  font-size: 11px; font-weight: 500; color: #6b7280;
}
.dash-hero-date {
  font-size: 11px; color: #9ca3af; font-weight: 500;
}

/* ── Hero: Badge pills interactivos ───────────────────────── */
.hero-badge {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 18px; border-radius: 10px; font-size: 13px; cursor: pointer;
  transition: filter .15s; user-select: none;
}
.hero-badge:hover { filter: brightness(0.96); }
.hero-badge--red    { background: #fff1f2; border: 1.5px solid #fecaca; }
.hero-badge--yellow { background: #fffbeb; border: 1.5px solid #fde68a; }
.hero-badge--green  { background: #f0fdf4; border: 1.5px solid #bbf7d0; }
.hero-badge--blue   { background: #f0f4ff; border: 1.5px solid #c7d2fe; }
/* Naranja: "no se pudo comprobar". Deliberadamente distinto del amarillo de
   las alertas — no es un hallazgo malo, es la ausencia de respuesta. */
.hero-badge--amber  { background: #fff7ed; border: 1.5px solid #fed7aa; }
.hb-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.hb-dot--red    { background: #ef4444; }
.hb-dot--yellow { background: #f59e0b; }
.hb-dot--green  { background: #22c55e; }
.hb-dot--blue   { background: #6366f1; }
.hb-dot--amber  { background: #f97316; }
.hb-amount { font-weight: 800; }
.hero-badge--red .hb-amount    { color: #b91c1c; }
.hero-badge--blue .hb-amount   { color: #3730a3; }
.hero-badge--amber .hb-amount  { color: #9a3412; }
.hb-label { font-weight: 600; color: #374151; font-size: 12.5px; }

.hero-badge-popup {
  display: none; position: absolute;
  bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #f9fafb; border-radius: 10px;
  padding: 10px 14px; min-width: 220px; max-width: 320px;
  z-index: 200; font-size: 12.5px; font-weight: 500;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35); border: 1px solid #374151;
  white-space: nowrap;
}
.hero-badge-popup::before {
  content: ''; position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  border-left: 7px solid transparent; border-right: 7px solid transparent;
  border-top: 7px solid #374151;
}
.hero-badge-popup::after {
  content: ''; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-top: 6px solid #1f2937;
}
.hero-badge:hover .hero-badge-popup,
.hero-badge.active .hero-badge-popup { display: block; }
.hb-popup-row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 5px 0; border-bottom: 1px solid #374151;
  font-size: 12.5px; line-height: 1.4;
}
.hb-popup-row:last-child { border-bottom: none; }
.hb-popup-row span:first-child { color: #d1d5db; }
.hb-popup-row span:last-child { font-weight: 700; color: #ffffff; }

/* ── Dashboard: Resumen ejecutivo ──────────────────────────── */
.dash-summary {
  background: #fff; border: 1px solid #e5e7eb;
  border-radius: 14px; padding: 22px 28px; margin-top: 4px;
}
.dash-summary-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: #6b7280; margin-bottom: 12px;
}
.dash-summary-list { display: flex; flex-direction: column; gap: 6px; }
.dash-summary-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 600;
}
.dash-summary-item.red    { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.dash-summary-item.yellow { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.dash-summary-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.dash-summary-dot.red    { background: #ef4444; }
.dash-summary-dot.yellow { background: #f59e0b; }
.dash-summary-ok {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 22px; border-radius: 12px;
  background: #f0fdf4; border: 1px solid #bbf7d0;
}
.dash-summary-ok-icon {
  width: 40px; height: 40px; border-radius: 50%;
  background: #dcfce7; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: #16a34a; font-size: 20px; font-weight: 700;
}
.dash-summary-ok-text { font-size: 14px; font-weight: 700; color: #166534; }
.dash-summary-ok-sub  { font-size: 12.5px; color: #4ade80; font-weight: 500; margin-top: 2px; }

/* ── Dashboard: Group wrappers ─────────────────────────────── */
.dash-group {
  border-radius: 14px; overflow: hidden;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
.dash-group-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: var(--dg-color, #6366f1);
  color: #fff; font-size: 14px; font-weight: 700;
  letter-spacing: 0.02em;
}
.dash-group-header i, .dash-group-header svg {
  color: rgba(255,255,255,0.85); stroke: rgba(255,255,255,0.85);
}
.dash-group-body {
  background: #f8fafc;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.dash-group-body > .vsec.vsec-wide {
  grid-column: 1 / -1;
}
@media (max-width: 900px) {
  .dash-group-body { grid-template-columns: 1fr; }
}

/* ── Dashboard: Section group ─────────────────────────────── */
.dash-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
.dash-section-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  color: #334155;
}
.dash-section-toggle {
  cursor: pointer; user-select: none;
  transition: background 0.15s;
}
.dash-section-toggle:hover { background: #eef2f7; }
.dash-section-right {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto;
}
.dash-section-chevron {
  transition: transform 0.3s ease;
  color: #94a3b8; flex-shrink: 0;
}
.dash-section--collapsed .dash-section-chevron {
  transform: rotate(-90deg);
}
.dash-section--collapsed .dash-section-header {
  border-bottom-color: transparent;
}

/* ── Sección de Análisis inteligente ────────────────────────────
   Violeta, el color que el ojo ya asocia con IA: la distingue de las
   secciones de datos duros, que van todas en gris neutro. */
.dash-section--ia {
  border-color: #ddd6fe;
  box-shadow: 0 1px 10px rgba(124,58,237,0.10);
}
.dash-section--ia .dash-section-header {
  background: linear-gradient(120deg, #f5f3ff 0%, #ede9fe 55%, #e0e7ff 100%);
  border-bottom-color: #ddd6fe;
  color: #4c1d95;
}
.dash-section--ia .dash-section-toggle:hover {
  background: linear-gradient(120deg, #ede9fe 0%, #ddd6fe 55%, #c7d2fe 100%);
}
.dash-section--ia .dash-section-title { color: #5b21b6; }
.dash-section--ia .dash-section-icon { color: #7c3aed; }
.dash-section--ia .dash-section-chevron { color: #8b5cf6; }
/* Chapita "IA": dice de un vistazo por qué esta sección es distinta */
.dash-ia-tag {
  font-size: 9.5px; font-weight: 800; letter-spacing: 0.06em;
  color: #fff; background: linear-gradient(135deg, #8b5cf6, #6366f1);
  padding: 2px 8px; border-radius: 99px;
  box-shadow: 0 1px 4px rgba(124,58,237,0.35);
}

/* Collapsible body */
.dash-section-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  padding: 16px;
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}
.dash-section--collapsed .dash-section-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

/* Badge de resumen en header */
.dash-section-badge {
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 99px;
  white-space: nowrap;
}
.dash-section-badge--ok {
  color: #15803d; background: #dcfce7;
}
.dash-section-badge--warn {
  color: #b91c1c; background: #fee2e2;
}
.dash-section-badge--caution {
  color: #92400e; background: #fef3c7;
}
/* Fuentes que no respondieron. En gris a proposito: no es un hallazgo ni un
   visto bueno, y mezclarlo con las alertas hacia que un grupo entero pareciera
   problematico solo porque a tres municipalidades se les cayo el portal. */
.dash-section-badge--mudo {
  color: #6e6e73; background: #f2f2f7; font-weight: 600;
}

.dash-section-icon {
  width: 28px; height: 28px; border-radius: 6px;
  background: #e2e8f0;
  display: flex; align-items: center; justify-content: center;
}
.dash-section-icon i, .dash-section-icon svg {
  width: 14px; height: 14px; stroke: #475569;
}
.dash-section-title {
  font-size: 16px; font-weight: 700; letter-spacing: 0.01em; color: #1e293b;
}
.dash-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  padding: 16px;
}

/* ── Dashboard: Card ─────────────────────────────────────── */
.dash-card {
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 16px;
  padding: 16px 18px 12px;
  display: flex; flex-direction: column; gap: 5px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  position: relative;
  min-height: 130px;
}
.dash-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.10);
  border-color: #94a3b8;
}
.dash-card-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.dash-card-icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.dash-card-icon i, .dash-card-icon svg { width: 22px; height: 22px; }
.dash-card-icon img { width: 44px; height: 44px; object-fit: contain; border-radius: 6px; }
.dash-card-title {
  font-size: 14.5px; font-weight: 700; color: #1d1d1f;
  line-height: 1.3;
}
.dash-card-summary {
  font-size: 13px; color: #6b7280; line-height: 1.4;
  flex: 1;
}
.dash-card-action {
  display: flex; align-items: center; gap: 4px;
  font-size: 12.5px; font-weight: 600; color: #0071e3;
  margin-top: 6px;
}
.dash-card:hover .dash-card-action { text-decoration: underline; }

/* Card status colors */
.dash-card--ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.dash-card--ok:hover { border-color: #86efac; }
.dash-card--ok .dash-card-summary { color: #15803d; }

.dash-card--warn {
  background: #fef2f2;
  border-color: #fecaca;
}
.dash-card--warn:hover { border-color: #fca5a5; }
.dash-card--warn .dash-card-summary { color: #b91c1c; font-weight: 600; }

.dash-card--caution {
  background: #fffbeb;
  border-color: #fde68a;
}
.dash-card--caution:hover { border-color: #fcd34d; }
.dash-card--caution .dash-card-summary { color: #92400e; }

.dash-card--neutral {
  background: #f9fafb;
  border-color: #e5e7eb;
}
.dash-card--neutral .dash-card-summary { color: #9ca3af; font-style: italic; }

/* Chain card */
.dash-card-chain {
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border-color: #a5b4fc;
  border-style: dashed;
}
.dash-card-chain:hover { border-color: #818cf8; border-style: solid; }

/* IA analysis cards */
.dash-card-ia {
  background: linear-gradient(135deg, #fefce8 0%, #f0f9ff 100%);
  border-color: #e0e7ff;
}

/* ── Detail modal overlay (centered) ─────────────────────── */
.detail-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 9500;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  justify-content: center;
  align-items: center;
}
.detail-overlay.active { display: flex; }

.detail-panel {
  width: auto;
  min-width: 360px;
  /* Las tablas de 7-9 columnas (revisión técnica, ATU, papeletas) no entraban
     en 720px y quedaban recortadas por la derecha. */
  max-width: min(980px, 94vw);
  max-height: 88vh;
  background: #fff;
  border-radius: 18px;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,0,0,0.05);
  animation: detail-pop-in 0.22s ease;
  overflow: hidden;
}
@keyframes detail-pop-in {
  from { transform: scale(0.92) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.detail-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  flex-shrink: 0;
}
.detail-panel-header h3 {
  font-size: 17px; font-weight: 700; color: #fff;
  margin: 0;
}
.detail-panel-close {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.1); border: none; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.detail-panel-close:hover { background: rgba(255,255,255,0.2); color: #fff; }
.detail-panel-body {
  flex: 1; overflow-y: auto; padding: 22px;
}
.detail-panel-body::-webkit-scrollbar { width: 5px; }
.detail-panel-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 99px; }

/* Hide duplicate title inside detail modal */
.detail-panel-body .vsec-head { display: none; }
/* Dentro del modal la sección va sin relleno, así que el texto queda pegado al
   borde. Con el border-radius y el overflow:hidden que trae .vsec, la curva de
   la esquina recortaba en diagonal la primera letra ("Registros" perdía la R).
   Aquí no hace falta ni el redondeo ni el recorte. */
.detail-panel-body .vsec {
  box-shadow: none; border: none;
  border-radius: 0; overflow: visible;
}
.detail-panel-body .vsec-body { padding: 0; }

@media (max-width: 600px) {
  .detail-panel { width: 96vw; min-width: unset; max-height: 94vh; border-radius: 12px; }
  .dash-cards-grid { grid-template-columns: 1fr; }
}

/* Sección del visor */
.vsec {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.vsec-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #f2f2f7;
}
.vsec-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.vsec-title { flex: 1; font-size: 13px; font-weight: 600; color: #1d1d1f; }
.vsec-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 3px 9px; border-radius: 99px;
}
.vsec-badge-ok      { color: var(--green); background: rgba(52,199,89,0.1); }
.vsec-badge-warn    { color: var(--red);   background: rgba(255,59,48,0.1); }
.vsec-badge-neutral { color: var(--muted); background: rgba(0,0,0,0.05); }
.vsec-badge-caution { color: var(--orange);background: rgba(255,149,0,0.1); }

.vsec-body { padding: 14px 16px; }

/* KV table del visor */
.v-kv { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; border-radius: 10px; overflow: hidden; border: 1px solid #e5e7eb; }
.v-kv tr { transition: background 0.15s; }
.v-kv tr:hover { background: #f8fafc; }
.v-kv tr:nth-child(even) { background: #f9fafb; }
.v-kv tr:nth-child(even):hover { background: #f1f5f9; }
.v-kv tr:last-child td { border-bottom: none; }
.v-kv td:first-child { color: #6b7280; width: 38%; padding: 10px 14px; vertical-align: top; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; border-bottom: 1px solid #f0f0f5; }
.v-kv td:last-child  { color: var(--text); padding: 10px 14px; font-weight: 600; border-bottom: 1px solid #f0f0f5; }

/* Data table del visor */
.v-tbl {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px;
  /* 'auto' reparte según el contenido: con 'fixed' todas las columnas medían
     lo mismo y las de texto largo se partían ("PENDIENT/E", "IMPOSICIÓ/N")
     mientras las cortas ("T.1") desperdiciaban espacio.
     'word-break: normal' evita cortes a media palabra. */
  table-layout: auto; word-break: normal; overflow-wrap: break-word;
  border-radius: 10px; overflow: hidden; border: 1px solid #e5e7eb;
}
/* Datos que no deben partirse nunca: importes, fechas y estados */
.v-tbl td, .v-tbl th { white-space: nowrap; }
/* Los textos largos (empresa, falta, infractor) sí pueden ajustarse, con tope
   de ancho para que no acaparen la tabla y desplacen al resto de columnas */
.v-tbl td.v-td-largo { white-space: normal; min-width: 150px; max-width: 280px; }
.v-tbl th {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: #fff; padding: 8px 10px; text-align: left;
  background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
  border-bottom: none;
}
.v-tbl td {
  padding: 8px 10px; color: var(--text); border-bottom: 1px solid #f0f0f5;
  overflow: hidden; text-overflow: ellipsis;
}
.v-tbl tr:last-child td { border-bottom: none; }
.v-tbl tr:nth-child(even) td { background: #f9fafb; }
.v-tbl tr:hover td { background: #f1f5f9; }

/* ── Tablas en celular: cada fila pasa a ser una ficha ──────────────
   Con 7-9 columnas en 390px cada una recibe ~35px y el navegador parte
   las palabras letra por letra ("PEN DIE NTE"). Aquí cada celda ocupa su
   propia línea, con el nombre de la columna (data-lbl) a la izquierda. */
@media (max-width: 640px) {
  .v-tbl { border: none; border-radius: 0; table-layout: auto; font-size: 13px; }
  .v-tbl thead { position: absolute; width: 1px; height: 1px;
                 overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .v-tbl tbody, .v-tbl tr, .v-tbl td { display: block; width: 100%; }
  .v-tbl tr {
    border: 1px solid #e5e7eb; border-radius: 12px;
    margin-bottom: 10px; overflow: hidden; background: #fff;
  }
  .v-tbl tr:last-child { margin-bottom: 0; }
  .v-tbl td {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 8px 12px; border-bottom: 1px solid #f4f4f7;
    text-overflow: clip; overflow: visible;
  }
  .v-tbl td::before {
    content: attr(data-lbl);
    flex: 0 0 38%; max-width: 38%;
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; color: #8a93a5; padding-top: 2px;
  }
  .v-tbl td:last-child { border-bottom: none; }
  /* Sin filas cebra ni hover: cada ficha ya se distingue por su borde */
  .v-tbl tr:nth-child(even) td, .v-tbl tr:hover td { background: transparent; }
  /* Celdas vacías (—) no aportan nada en una ficha */
  .v-tbl td.v-td-vacia { display: none; }

  /* En columnas el color de fondo bastaba para separar la póliza vigente del
     historial; apilado se pierde, así que cada ficha lleva su franja y su
     rótulo. */
  .v-tbl tr.fila-vigente {
    border: 1.5px solid #86efac; border-left: 5px solid #22c55e;
    box-shadow: none !important;
  }
  .v-tbl tr.fila-vigente::before {
    content: 'VIGENTE';
    display: block; background: #dcfce7; color: #15803d;
    font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
    padding: 5px 12px;
  }
  .v-tbl tr.fila-historica {
    border: 1px solid #e5e7eb; border-left: 5px solid #cbd5e1;
    opacity: 0.92;
  }
  .v-tbl tr.fila-historica::before {
    content: 'HISTÓRICO';
    display: block; background: #f1f5f9; color: #64748b;
    font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
    padding: 5px 12px;
  }
  /* Con la franja arriba, el verde de cada celda ya no hace falta */
  .v-tbl tr.fila-vigente td { background: #fff !important; }
}

/* Mensajes dentro de sección */
.vsec-ok   { color: var(--green); font-size: 13px; font-weight: 500; }
.vsec-warn { color: var(--red);   font-size: 13px; font-weight: 500; }
.vsec-note { color: var(--muted); font-size: 12.5px; font-style: italic; }
.vsec-amount { font-size: 16px; font-weight: 700; color: var(--red); margin-bottom: 10px; }

/* Bloque verificación Farenet */
.citv-verif { font-size: 13px; }
.citv-verif td { padding: 4px 8px 4px 0; }

/* Panel de análisis IA */
.ia-panel {
  margin-top: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.ia-panel::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #0f172a, #1e3a5f, #3b82f6);
}
.ia-panel-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.ia-panel-icon { font-size: 12px; }
.ia-panel-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: #0f172a;
}
.ia-panel-body {
  font-size: 12.5px; line-height: 1.7; color: #334155;
}
.ia-panel-body strong { font-weight: 700; color: #0f172a; }

/* IA callouts */
.ia-alerta {
  background: #fef2f2;
  border-left: 5px solid #dc2626;
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  margin: 8px 0;
  color: #7f1d1d;
  font-size: 12.5px;
  line-height: 1.65;
}
.ia-alerta strong { color: #991b1b; }
.ia-advertencia {
  background: #fffbeb;
  border-left: 5px solid #f59e0b;
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  margin: 8px 0;
  color: #78350f;
  font-size: 12.5px;
  line-height: 1.65;
}
.ia-advertencia strong { color: #92400e; }
.ia-linea {
  padding: 3px 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: #334155;
}

/* Panel final: Perfil de Uso / Riesgo */
.ia-final-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.ia-final-panel::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #0f172a, #1e3a5f, #3b82f6);
}
.ia-final-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.ia-final-icon { font-size: 14px; }
.ia-final-title {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.08em; color: #0f172a;
}
.ia-final-body {
  font-size: 13px; line-height: 1.7; color: #334155;
}
.ia-final-body strong { font-weight: 700; color: #0f172a; }

/* Resumen ejecutivo del visor */
.viewer-summary-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px;
  margin-bottom: 10px;
}
.vsummary-card {
  background: #fff; border-radius: 10px; padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  font-size: 11.5px; font-weight: 500;
}
.vsummary-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Cadena de Propiedad ─────────────────────────────────── */
.chain-btn-wrap { margin-top: 14px; text-align: center; }
.chain-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, #0071e3 0%, #5856d6 100%);
  color: #fff; border: none; border-radius: 12px;
  padding: 12px 24px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 4px 16px rgba(0,113,227,0.25);
}
.chain-btn:hover { opacity: 0.92; transform: translateY(-1px); }
.chain-btn-count {
  font-size: 11px; font-weight: 500; opacity: 0.75;
  padding-left: 8px; border-left: 1px solid rgba(255,255,255,0.3);
}

/* La VENTANA: lo único que hace scroll. Separarla del contenido es lo que
   permite que arrastrar recorra la cadena en vez de mover el bloque entero. */
.cadena-viewport {
  overflow-x: auto; overflow-y: hidden;
  cursor: grab; user-select: none;
  scrollbar-width: none;            /* Firefox */
  overscroll-behavior-x: contain;   /* que no dispare el "atrás" del navegador */
}
.cadena-viewport::-webkit-scrollbar { display: none; }
.cadena-viewport.grabbing { cursor: grabbing; }

/* El CONTENIDO: crece lo que necesite y se centra solo cuando cabe entero. */
.cadena-graph {
  display: flex; align-items: flex-start; gap: 0;
  width: max-content; min-width: 100%;
  /* "safe center": centra la cadena cuando entra completa, y cuando no entra
     se comporta como flex-start. Con un "center" normal, el sobrante se
     recorta por los DOS lados y los primeros dueños quedan inalcanzables
     (el scroll no llega a valores negativos). */
  justify-content: safe center;
  /* Padding simétrico: antes eran 60px a la izquierda y 24px a la derecha,
     así que la cadena se veía corrida aunque estuviera completa. */
  padding: 20px 32px; min-height: 180px;
  box-sizing: border-box;
}
/* Reserva el ancho de la barra a ambos lados: sin esto, en navegadores con
   scrollbar clásica el contenido queda descentrado respecto al modal. */
#cadena-modal-body { scrollbar-gutter: stable both-edges; }
/* Ancla del botón "Centrar" (el modal trae sus estilos en línea, sin position) */
#cadena-modal-content { position: relative; }
/* Botón para volver a la vista original tras ampliar o desplazar el timeline */
.cadena-centrar {
  position: absolute; right: 14px; bottom: 14px; z-index: 5;
  display: none; align-items: center; gap: 6px;
  background: rgba(29,29,31,0.9); color: #fff; border: none;
  border-radius: 999px; padding: 8px 14px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; font-family: inherit;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.cadena-centrar svg { width: 14px; height: 14px; }
/* Acercar / alejar a la vista. El zoom vivía solo en Ctrl+rueda y en el
   pellizco; sin un botón visible, para el cliente era como si no existiera. */
.cadena-lupas {
  position: absolute; right: 14px; top: 76px; z-index: 5;
  display: flex; flex-direction: column; gap: 1px;
  border-radius: 9px; overflow: hidden;
  box-shadow: 0 3px 12px rgba(0,0,0,0.18);
}
.cadena-lupas button {
  width: 30px; height: 30px; border: none; cursor: pointer;
  background: rgba(29,29,31,0.9); color: #fff;
  font-size: 16px; font-weight: 700; line-height: 1;
  font-family: inherit; padding: 0;
}
.cadena-lupas button:hover { background: #1d1d1f; }

/* ── Ejercicios del impuesto vehicular ──────────────────────────
   Un acordeón por año. Antes era una barra gris con una comilla como flecha;
   se veía tosco y no dejaba claro qué año estaba en problemas. Ahora cada
   ejercicio es una ficha con su punto de estado, su número de cuotas y su
   total, y el rojo aparece solo donde de verdad hay algo vencido. */
.imp-anio {
  border: 1px solid #e5e5ea; border-radius: 12px;
  background: #fff; overflow: hidden; margin-top: 10px;
}
.imp-anio:first-of-type { margin-top: 6px; }
.imp-anio-cab {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 14px; background: #fff;
  transition: background .15s ease;
}
.imp-anio-punto {
  width: 7px; height: 7px; border-radius: 50%;
  background: #34c759; flex-shrink: 0;
}
.imp-anio-punto.vencido { background: #ff3b30; }
.imp-anio-nom {
  font-size: 14px; font-weight: 800; color: #1d1d1f;
  letter-spacing: -0.01em;
}
.imp-anio-meta {
  font-size: 11px; color: #aeaeb2; font-weight: 500;
  white-space: nowrap;
}
.imp-anio-total {
  margin-left: auto; font-size: 14px; font-weight: 800;
  color: #1d1d1f; font-variant-numeric: tabular-nums;
}
.imp-anio-total.vencido { color: #dc2626; }
.imp-anio-flecha {
  width: 16px; height: 16px; color: #c7c7cc; flex-shrink: 0;
  transition: transform .25s cubic-bezier(0.4,0,0.2,1);
}

/* Solo se pliega cuando hay más de un ejercicio */
.imp-anio--plegable > .imp-anio-cab { cursor: pointer; }
.imp-anio--plegable > .imp-anio-cab:hover { background: #fafafa; }
.imp-anio--plegable.abierto > .imp-anio-cab { border-bottom: 1px solid #f0f0f5; }
.imp-anio--plegable.abierto .imp-anio-flecha { transform: rotate(180deg); }

/* Despliegue suave: grid de 0fr a 1fr anima la altura sin fijarla a mano,
   que es lo que obliga a inventar un max-height y deja saltos. */
.imp-anio-cuerpo {
  display: grid; grid-template-rows: 1fr;
  transition: grid-template-rows .28s cubic-bezier(0.4,0,0.2,1);
}
.imp-anio-cuerpo > div { overflow: hidden; min-height: 0; }
.imp-anio--plegable:not(.abierto) > .imp-anio-cuerpo { grid-template-rows: 0fr; }
.imp-anio-cuerpo table { margin: 0; }
@media (prefers-reduced-motion: reduce) {
  .imp-anio-cuerpo, .imp-anio-flecha { transition: none; }
}

/* ── Los tres estados de la ATU ─────────────────────────────────
   Se listan los tres con su significado y se resalta el que aplica, en vez de
   soltar una sola frase. Asi el cliente ve que otras posibilidades habia y
   entiende donde cae su vehiculo. Mismo molde que la tarjeta de siniestros. */
.atu-estados { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.atu-estado {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 9px;
  background: #f9fafb; opacity: 0.55;
}
.atu-estado b {
  display: block; font-size: 12.5px; font-weight: 700; color: #6e6e73;
}
.atu-estado i {
  display: block; font-style: normal; font-size: 11px; line-height: 1.45;
  color: #aeaeb2; margin-top: 2px;
}
.atu-marca {
  min-width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid #d2d2d7; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff; line-height: 1;
}
/* El estado que aplica: a todo color y sin atenuar */
.atu-estado.activo { opacity: 1; }
.atu-estado.activo b { color: #1d1d1f; font-weight: 800; }
.atu-estado.activo i { color: #6e6e73; }
.atu-estado.activo .atu-marca { border: none; }

.atu-estado.activo--hab   { background: #fff7ed; border-color: #fdba74; }
.atu-estado.activo--hab   .atu-marca { background: #f97316; }
.atu-estado.activo--nohab { background: #fff7ed; border-color: #fdba74; }
.atu-estado.activo--nohab .atu-marca { background: #f97316; }
.atu-estado.activo--noreg { background: #f0fdf4; border-color: #bbf7d0; }
.atu-estado.activo--noreg .atu-marca { background: #22c55e; }

/* Insignia de orden de captura: rojo pleno, no el ambar de las advertencias.
   Es la unica alerta del reporte que significa que pueden llevarse el auto. */
.vsec-badge-danger {
  background: #dc2626 !important; color: #fff !important;
  border: 1px solid #b91c1c !important; font-weight: 800 !important;
  letter-spacing: 0.02em;
}

/* Orden de captura: es la alerta más grave del reporte y salía en gris */
.captura-alerta {
  background: #fef2f2; border: 1.5px solid #f87171; border-radius: 10px;
  padding: 11px 13px; margin-bottom: 10px;
}
.captura-alerta b {
  display: block; color: #991b1b; font-size: 13px; font-weight: 800;
  margin-bottom: 3px;
}
/* El emoji va en el HTML. Como escape CSS (F6A8) el navegador lo mostraba
   partido: un cuadrito y el texto "F6A8" suelto al lado del titulo. */
.captura-alerta span { display: block; color: #7c2d12; font-size: 11.5px; line-height: 1.45; }
.captura-detalle {
  margin: 0; padding: 10px 12px; background: #fafafa;
  border: 1px solid #e5e5ea; border-radius: 8px;
  font-size: 10.5px; line-height: 1.6; color: #1d1d1f;
  overflow-x: auto; white-space: pre; font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* Fila de TOTAL en la tabla de impuesto vehicular: el documento anual, cuyo
   importe es la suma de las cuotas. Se separa para que no se lea como una
   deuda más —que era justo lo que descuadraba la cuenta a simple vista—. */
.v-fila-total td {
  border-top: 2px solid #d2d2d7 !important;
  background: #fafafa !important;
  font-weight: 700;
}
/* Las lupas también van en celular: el pellizco existe, pero nadie tiene por
   qué adivinarlo, igual que pasaba con Ctrl+rueda en escritorio. */
.cadena-centrar:hover { background: #1d1d1f; }
.cadena-node {
  display: flex; flex-direction: column; align-items: center;
  min-width: 160px; max-width: 210px; flex-shrink: 0;
}
.cadena-leyenda {
  display: flex; align-items: center; gap: 8px;
  justify-content: flex-end; padding: 8px 16px 0;
  font-size: 10px; color: #6e6e73;
}
.cadena-leyenda-color {
  display: inline-block; width: 14px; height: 14px;
  background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 3px;
}
.cadena-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; border: 2px solid #a5b4fc; margin-bottom: 8px;
}
.cadena-avatar--juridico {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #fbbf24;
}
.cadena-avatar--coprop {
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  border-color: #818cf8;
}
.cadena-name {
  font-size: 11.5px; font-weight: 700; color: #1d1d1f;
  text-align: center; line-height: 1.3; max-width: 160px;
  word-break: break-word;
}
.cadena-dates { font-size: 10px; color: #6e6e73; margin-top: 4px; text-align: center; }
.cadena-current {
  display: inline-block; font-size: 9px; font-weight: 700;
  color: #16a34a; background: rgba(22,163,74,0.1);
  padding: 1px 6px; border-radius: 99px; margin-top: 2px;
}
.cadena-first {
  display: inline-block; font-size: 9px; font-weight: 700;
  color: #2563eb; background: rgba(37,99,235,0.1);
  padding: 1px 6px; border-radius: 99px; margin-top: 2px;
}
/* Aseguradora como dueña: siniestro con pérdida total. El nodo entero avisa
   —avatar rojo, nombre rojo y etiqueta— porque es la peor noticia que puede
   dar la cadena y no debe pasar como una empresa más. */
.cadena-avatar--aseg {
  background: linear-gradient(135deg, #fecaca, #fca5a5) !important;
  box-shadow: 0 0 0 3px rgba(220,38,38,0.25);
}
.cadena-name--aseg { color: #b91c1c; }
.cadena-aseg-tag {
  display: inline-block; font-size: 9px; font-weight: 700;
  color: #b91c1c; background: #fee2e2; border: 1px solid #fecaca;
  padding: 2px 8px; border-radius: 99px; margin-top: 3px;
  max-width: 190px; line-height: 1.35;
}
.cadena-events { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.cadena-event {
  /* En columna, no en fila: los chips resueltos llevan el hecho arriba y las
     fechas debajo, y en línea el segundo renglón quedaba pegado al primero. */
  display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 10px; padding: 5px 9px; border-radius: 7px;
  cursor: pointer; transition: background 0.15s; white-space: normal;
  text-align: center; max-width: 220px;
}
.cadena-event:hover { filter: brightness(0.95); }
.cadena-event--garantia { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.cadena-event--cancelacion { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.cadena-event--cambio { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.cadena-event--otro { background: #f5f5f7; color: #6e6e73; border: 1px solid #e5e5ea; }

/* ── Chips con desenlace ────────────────────────────────────────
   Una sola regla de color, para que el cliente no tenga que aprenderse nada:
     rojo  = sigue vigente y te afecta si compras
     verde = ya se resolvió, es historia
     ámbar = no es deuda, pero cambia el valor del vehículo           */
.cadena-event--vigente   { background: #fef2f2; color: #991b1b; border: 1.5px solid #f87171; }
.cadena-event--saldado   { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.cadena-event--uso       { background: #fff7ed; color: #9a3412; border: 1.5px solid #fdba74; }
/* Los chips resueltos llevan dos renglones: el hecho y sus fechas */
.cadena-event b { display: block; font-weight: 700; }
.cadena-event i {
  display: block; font-style: normal; font-weight: 500;
  font-size: 9.5px; opacity: 0.85; margin-top: 2px; line-height: 1.35;
}

/* ── Veredicto: la conclusión antes que el detalle ───────────────
   Va fuera de la ventana desplazable a propósito. Muchos clientes no leen
   chip por chip; necesitan una frase que les diga si hoy hay algo pendiente. */
.cadena-veredicto {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 0 0 12px; padding: 12px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.45;
}
.cadena-veredicto + .cadena-veredicto { margin-top: -4px; }
.cadena-veredicto span { font-size: 15px; line-height: 1.2; flex-shrink: 0; }
.cadena-veredicto b { display: block; font-weight: 800; }
.cadena-veredicto i {
  display: block; font-style: normal; font-size: 12px;
  opacity: 0.9; margin-top: 2px;
}
.cadena-veredicto--ok     { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.cadena-veredicto--alerta { background: #fef2f2; border: 1.5px solid #f87171; color: #991b1b; }
.cadena-veredicto--uso    { background: #fff7ed; border: 1.5px solid #fdba74; color: #9a3412; }

/* Ancho fijo: si se deja crecer con el texto, la flecha de un acto largo
   ("TRANSFERENCIA POR SINIESTRO (PÉRDIDA TOTAL)") mide el triple que la de
   "COMPRA - VENTA" y el timeline se ve desparejo. */
.cadena-arrow {
  display: flex; flex-direction: column; align-items: center;
  /* flex-start: la línea arranca siempre a la misma altura aunque el acto
     ocupe una o dos líneas; si no, cada flecha se centra a distinta altura. */
  justify-content: flex-start;
  min-width: 128px; max-width: 128px; flex-shrink: 0;
  padding-top: 14px; cursor: pointer; position: relative;
}
.cadena-arrow-line {
  display: flex; align-items: center; width: 100%; height: 2px;
}
.cadena-arrow-line::before {
  content: ''; flex: 1; height: 2px;
  background: linear-gradient(90deg, #c7d2fe, #818cf8);
}
.cadena-arrow-line::after {
  content: ''; width: 0; height: 0;
  border-top: 5px solid transparent; border-bottom: 5px solid transparent;
  border-left: 8px solid #818cf8;
}
.cadena-arrow-price {
  font-size: 11px; font-weight: 700; color: #4f46e5;
  margin-top: 4px; padding: 2px 8px; background: #eef2ff;
  border-radius: 99px; white-space: nowrap;
}
.cadena-arrow:hover .cadena-arrow-price { background: #e0e7ff; }
.cadena-arrow-acto {
  font-size: 9px; color: #6e6e73; margin-top: 2px;
  /* Se ajusta en varias líneas en vez de estirar la flecha; el alto mínimo
     de dos renglones mantiene todas las flechas del mismo tamaño. */
  white-space: normal; text-align: center;
  line-height: 1.3; max-width: 100%; min-height: 24px;
}

.cadena-detail {
  position: absolute; top: calc(100% + 8px);
  left: 50%; transform: translateX(-50%);
  background: #fff; border: 1px solid #e5e5ea; border-radius: 10px;
  padding: 10px 14px; box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  font-size: 11px; min-width: 200px; max-width: 300px; width: max-content;
  z-index: 10; word-wrap: break-word; overflow-wrap: anywhere;
}
.cadena-detail::before {
  content: ''; position: absolute;
  top: -6px; left: calc(50% + var(--arrow-shift, 0px));
  transform: translateX(-50%) rotate(45deg);
  width: 10px; height: 10px; background: #fff;
  border-left: 1px solid #e5e5ea; border-top: 1px solid #e5e5ea;
}
.cadena-detail--above {
  top: auto; bottom: calc(100% + 8px);
}
.cadena-detail--above::before {
  top: auto; bottom: -6px;
  left: calc(50% + var(--arrow-shift, 0px));
  border-left: none; border-top: none;
  border-right: 1px solid #e5e5ea; border-bottom: 1px solid #e5e5ea;
}
.cadena-detail-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 3px 0; border-bottom: 1px solid #f5f5f7;
}
.cadena-detail-row:last-child { border-bottom: none; }
.cadena-detail-label { color: #6e6e73; white-space: nowrap; }
.cadena-detail-value { font-weight: 600; color: #1d1d1f; text-align: right; }

/* ── Tarjeta de transición (detalle de un hecho de la cadena) ────
   Sustituye a la tabla de etiqueta/valor. La tabla obligaba al cliente a
   armar la frase leyendo "Tipo: otro" + "Detalle: ..." + "Fecha: ...", y
   además partía palabras a la mitad ("Detall/e") porque la columna de la
   izquierda se quedaba sin ancho. */
.cadena-detail { padding: 0; min-width: 250px; max-width: 320px; }

.cd-cabecera {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 13px; border-radius: 10px 10px 0 0;
  background: #f5f5f7;
}
.cd-cabecera--ok     { background: #f0fdf4; }
.cd-cabecera--alerta { background: #fef2f2; }
.cd-cabecera--uso    { background: #fff7ed; }
.cd-icono { font-size: 15px; line-height: 1.2; flex-shrink: 0; }
.cd-cabecera b { display: block; font-size: 12.5px; font-weight: 800; color: #1d1d1f; }
.cd-cabecera i {
  display: block; font-style: normal; font-size: 11px;
  color: #6e6e73; margin-top: 1px;
}

.cd-transicion {
  display: flex; align-items: center; gap: 6px;
  padding: 14px 12px 12px;
}
.cd-lado { flex: 1; text-align: center; min-width: 0; }
.cd-lado b {
  display: block; font-size: 11.5px; font-weight: 800; color: #6e6e73;
  line-height: 1.25; word-break: break-word;
}
.cd-lado i {
  display: block; font-style: normal; font-size: 9.5px;
  color: #aeaeb2; margin-top: 2px;
}
/* El destino se resalta; el origen queda apagado, como corresponde a algo
   que ya no rige. */
.cd-lado--ahora b { color: #1d1d1f; }
.cd-lado--ahora.cd-lado--ok b     { color: #166534; }
.cd-lado--ahora.cd-lado--alerta b { color: #991b1b; }
.cd-lado--ahora.cd-lado--uso b    { color: #9a3412; }

.cd-flecha {
  flex: 0 0 68px; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.cd-medio {
  font-size: 10px; font-weight: 700; color: #4f46e5;
  background: #eef2ff; border-radius: 99px; padding: 1px 7px;
  white-space: nowrap;
}
/* La línea se dibuja sola al abrir: el ojo sigue el trazo y entiende la
   dirección del cambio antes de leer una sola palabra. */
.cd-linea {
  display: block; width: 100%; height: 2px; position: relative;
  background: linear-gradient(90deg, #c7d2fe, #6366f1);
  transform-origin: left center;
  animation: cdTrazo 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.cd-linea::after {
  content: ''; position: absolute; right: -1px; top: -4px;
  border-left: 7px solid #6366f1;
  border-top: 5px solid transparent; border-bottom: 5px solid transparent;
  animation: cdPunta 0.25s ease-out 0.45s both;
}
@keyframes cdTrazo { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes cdPunta { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .cd-linea, .cd-linea::after { animation: none; }
}

.cd-explica {
  margin: 0; padding: 0 13px 11px;
  font-size: 11px; line-height: 1.45; color: #6e6e73;
}
.cd-pie {
  border-top: 1px solid #f0f0f5; padding: 8px 13px 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.cd-pie div { display: flex; justify-content: space-between; gap: 12px; }
.cd-pie span:first-child { color: #aeaeb2; font-size: 10px; white-space: nowrap; }
.cd-pie span:last-child {
  color: #6e6e73; font-size: 10px; font-weight: 600;
  text-align: right; word-break: break-word;
}

@media (max-width: 600px) {
  /* En columna, justify-content pasa a mandar sobre el eje vertical: se vuelve
     a flex-start para que la cadena arranque arriba y no quede flotando. */
  .cadena-viewport { overflow-x: hidden; cursor: default; }
  .cadena-graph { flex-direction: column; align-items: center;
                  width: 100%; justify-content: flex-start; padding: 20px 16px; }
  /* En columna la flecha tampoco debe estirarse con el texto del acto */
  .cadena-arrow { min-width: 190px; max-width: 190px; min-height: 50px; padding-top: 0; }
  .cadena-arrow-line { flex-direction: column; width: 2px; height: 100%; min-height: 30px; }
  .cadena-arrow-line::before { width: 2px; height: 100%; flex: 1; background: linear-gradient(180deg, #c7d2fe, #818cf8); }
  .cadena-arrow-line::after { border-top: 8px solid #818cf8; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: none; }
  .cadena-node { min-width: unset; max-width: 280px; }

  /* ── Viewer mobile ───────────────────────────────────────── */
  .viewer-body { padding: 12px 10px; }
  .viewer-nav { padding: 0 12px; height: 46px; }
  .viewer-nav-right span { display: none; }
  .viewer-plate-badge { font-size: 12px; padding: 3px 8px; }

  /* ── Hero card mobile ────────────────────────────────────── */
  .dash-hero-tagline { padding: 16px 16px; }
  .dash-hero-tagline strong { font-size: 11px; }
  .dash-hero-tagline span { font-size: 11px; }
  .dash-hero-main {
    flex-direction: column; align-items: center; text-align: center;
    padding: 16px 16px 8px; gap: 14px;
  }
  .dash-hero-header {
    flex-direction: column; align-items: center; gap: 10px;
  }
  .dash-hero-vehicle { align-items: center; }
  .dash-hero-vname { font-size: 18px; text-align: center; }
  .dash-hero-vmeta { flex-wrap: wrap; justify-content: center; font-size: 12px; }
  .dash-hero-vowner { text-align: center; font-size: 12px; }
  .peru-plate-number { font-size: 24px; }
  .peru-plate { padding: 3px 14px 6px; }
  .dash-hero-footer {
    flex-direction: column; align-items: center; gap: 10px;
    padding: 12px 16px 0;
  }
  .dash-hero-badges { justify-content: center; }
  .dash-hero-date { text-align: center; }

  /* ── Section headers mobile ──────────────────────────────── */
  .dash-section-title { font-size: 14px; }
  .dash-section-header { padding: 10px 14px; }
  .dash-cards-grid { padding: 10px; gap: 10px; }
  .dash-card { min-height: 110px; padding: 14px 14px 10px; }
}


/* ── Aviso de fuente caída ─────────────────────────────────────
   Naranja y no rojo: no es un hallazgo malo del vehículo, es que la entidad
   no respondió. El enlace deja que el cliente lo confirme por su cuenta. */
.fuente-caida {
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 12px;
  padding: 14px 16px; margin: 4px 0;
}
.fuente-caida-tit {
  font-size: 13px; font-weight: 800; color: #9a3412; margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.fuente-caida-tit::before { content: '\26A0\FE0F'; font-size: 14px; }
.fuente-caida-msg { font-size: 12.5px; color: #7c2d12; margin: 0 0 10px; line-height: 1.5; }
.fuente-caida-link {
  display: inline-flex; align-items: center; gap: 7px;
  background: #9a3412; color: #fff !important; text-decoration: none !important;
  border-radius: 9px; padding: 9px 14px; font-size: 12.5px; font-weight: 700;
}
.fuente-caida-link:hover { background: #7c2d12; }
.fuente-caida-link svg { width: 14px; height: 14px; flex-shrink: 0; }
@media (max-width: 600px) {
  .fuente-caida { padding: 12px 13px; }
  .fuente-caida-link { width: 100%; justify-content: center; }
}

/* Señal de que la cadena sigue fuera de vista.
   Los degradados a ambos lados hacen que el recorte se lea como una ventana
   sobre algo más largo, y no como contenido cortado por error. */
#cadena-modal-content.cadena-hay-mas::after,
#cadena-modal-content.cadena-hay-antes::before {
  content: ''; position: absolute; top: 68px; bottom: 16px;
  width: 72px; pointer-events: none; z-index: 3;
}
#cadena-modal-content.cadena-hay-mas::after {
  right: 0; border-radius: 0 18px 18px 0;
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, #fff 78%);
}
#cadena-modal-content.cadena-hay-antes::before {
  left: 0; border-radius: 18px 0 0 18px;
  background: linear-gradient(270deg, rgba(255,255,255,0) 0%, #fff 78%);
}
#cadena-modal-content.cadena-hay-mas .cadena-mas-flecha { display: flex; }
.cadena-mas-flecha {
  display: none; position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%); z-index: 4; cursor: pointer;
  height: 30px; min-width: 30px; border-radius: 999px; padding: 0 3px;
  background: #1e3a5f; color: #fff;
  align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; font-family: inherit;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  animation: cadenaHint 1.6s ease-in-out infinite;
}
/* El número solo aparece si hay dueños fuera; si no, queda el círculo limpio */
.cadena-mas-num { padding-right: 4px; }
.cadena-mas-num:empty { display: none; }
.cadena-mas-flecha svg { width: 15px; height: 15px; flex-shrink: 0; }
@keyframes cadenaHint {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  50%      { transform: translateY(-50%) translateX(5px); }
}
@media (prefers-reduced-motion: reduce) { .cadena-mas-flecha { animation: none; } }

/* En celular la cadena corre en VERTICAL, así que todos los indicadores de
   "sigue más allá" giran 90°: el degradado tapa el borde de abajo, la flecha
   apunta hacia abajo y rebota en vertical. Sin esto, medían y señalaban un
   corte horizontal que en columna no existe, y no aparecían nunca. */
@media (max-width: 600px) {
  #cadena-modal-content.cadena-hay-mas::after {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 62px;
    border-radius: 0 0 18px 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #fff 80%);
  }
  #cadena-modal-content.cadena-hay-antes::before {
    top: 58px; left: 0; right: 0; bottom: auto; width: auto; height: 44px;
    border-radius: 0;
    background: linear-gradient(0deg, rgba(255,255,255,0) 0%, #fff 80%);
  }
  .cadena-mas-flecha {
    top: auto; right: auto; bottom: 14px; left: 50%;
    animation: cadenaHintV 1.6s ease-in-out infinite;
  }
  .cadena-mas-flecha svg { transform: rotate(90deg); }
  /* El botón Centrar comparte esquina con la flecha: se corre a la izquierda */
  .cadena-centrar { right: auto; left: 14px; }
}
@keyframes cadenaHintV {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(5px); }
}
