/* BuenTrato V2 — sistema visual institucional reversible. */
.theme-v2 {
  --bt-ink: #123047;
  --bt-ink-deep: #0a2233;
  --bt-green: #167566;
  --bt-green-dark: #0f5c50;
  --bt-mint: #e5f3ef;
  --bt-mint-strong: #c9e5dc;
  --bt-paper: #f4f7f8;
  --bt-panel: #ffffff;
  --bt-line: #d4e0e3;
  --bt-line-strong: #b7c9ce;
  --bt-muted: #5d707b;
  --bt-amber: #a66b15;
  --bt-amber-soft: #fff3dc;
  --bt-danger: #a93632;
  --bt-danger-soft: #fdecea;
  --bt-shadow-sm: 0 1px 2px rgba(18, 48, 71, 0.05), 0 8px 24px rgba(18, 48, 71, 0.05);
  --bt-shadow-md: 0 18px 50px rgba(18, 48, 71, 0.1);
  --bt-focus: 0 0 0 3px rgba(22, 117, 102, 0.2);
  --bg: var(--bt-paper);
  --surface: var(--bt-panel);
  --surface-soft: #f7faf9;
  --text: var(--bt-ink);
  --muted: var(--bt-muted);
  --line: var(--bt-line);
  --line-soft: #e8eff1;
  --primary: var(--bt-green);
  --primary-dark: var(--bt-green-dark);
  --primary-soft: var(--bt-mint);
  --accent: var(--bt-amber);
  --accent-dark: #7c4f0e;
  --danger-soft: var(--bt-danger-soft);
  --shadow: var(--bt-shadow-sm);
  background: var(--bt-paper);
  color: var(--bt-ink);
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

.theme-v2::before {
  background:
    radial-gradient(circle at 8% 0%, rgba(22, 117, 102, 0.1), transparent 28rem),
    linear-gradient(90deg, rgba(18, 48, 71, 0.025) 1px, transparent 1px);
  background-size: auto, 64px 64px;
  content: "";
  inset: 0 0 auto;
  height: 460px;
  pointer-events: none;
  position: fixed;
  z-index: -1;
}

.theme-v2 h1,
.theme-v2 h2,
.theme-v2 h3,
.theme-v2 h4,
.theme-v2 strong {
  color: var(--bt-ink);
}

.theme-v2 h1,
.theme-v2 h2,
.theme-v2 h3 {
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.theme-v2 a {
  color: var(--bt-green-dark);
  text-underline-offset: 3px;
}

.theme-v2 :focus-visible {
  box-shadow: var(--bt-focus);
  outline: 2px solid transparent;
}

.theme-v2 .topbar {
  backdrop-filter: blur(18px);
  background: rgba(249, 252, 251, 0.94);
  border-bottom: 1px solid rgba(183, 201, 206, 0.76);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
  min-height: 68px !important;
}

.theme-v2 .topbar-inner {
  grid-template-rows: 68px !important;
  max-width: 1500px;
  padding-inline: clamp(16px, 2.5vw, 38px) !important;
  width: 100%;
}

.theme-v2 .brand {
  gap: 11px;
}

.theme-v2 .brand-logo {
  border-radius: 10px !important;
  height: 38px !important;
  width: 38px !important;
}

.theme-v2 .brand strong {
  font-size: 16px !important;
  letter-spacing: -0.015em;
}

.theme-v2 .brand small {
  color: var(--bt-muted);
  font-size: 11px !important;
  font-weight: 650;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.theme-v2 .main-nav > a,
.theme-v2 .nav-menu > summary,
.theme-v2 .nav-more > summary {
  border: 1px solid transparent;
  border-radius: 9px !important;
  color: #3f5764 !important;
  font-size: 13px !important;
  font-weight: 700;
  min-height: 38px !important;
  padding: 8px 10px !important;
}

.theme-v2 .main-nav > a:hover,
.theme-v2 .nav-menu > summary:hover,
.theme-v2 .main-nav > a.active,
.theme-v2 .nav-menu.active > summary {
  background: var(--bt-mint);
  border-color: var(--bt-mint-strong);
  color: var(--bt-green-dark) !important;
}

.theme-v2 .nav-menu > div {
  border: 1px solid var(--bt-line);
  border-radius: 12px;
  box-shadow: var(--bt-shadow-md);
  overflow: hidden;
  padding: 7px;
}

.theme-v2 .nav-menu > div a {
  border-radius: 8px;
  color: var(--bt-ink);
  min-height: 40px;
  padding: 9px 11px;
}

.theme-v2 .notification-trigger,
.theme-v2 .topbar-logout-form button {
  border-color: var(--bt-line);
  border-radius: 9px;
  min-height: 38px !important;
}

.theme-v2 .notification-symbol {
  background: var(--bt-green);
  color: white;
}

.theme-v2 .data-mode-banner {
  border-bottom-width: 1px;
  font-weight: 600;
  letter-spacing: 0.005em;
}

.theme-v2 .data-mode-banner strong {
  color: currentColor;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.theme-v2 .page {
  max-width: 1380px;
  padding: clamp(24px, 3vw, 44px) clamp(16px, 3vw, 40px) 72px;
}

.theme-v2 .heading,
.theme-v2 .dashboard-heading {
  align-items: end;
  border-bottom: 1px solid var(--bt-line);
  margin-bottom: 24px;
  padding-bottom: 24px;
}

.theme-v2 .heading h1 {
  color: var(--bt-ink-deep);
  font-size: clamp(2rem, 3vw, 3.25rem);
  font-weight: 720;
  line-height: 1.03;
}

.theme-v2 .heading p {
  color: var(--bt-muted);
  font-size: 1rem;
  line-height: 1.65;
  max-width: 720px;
}

.theme-v2 .eyebrow {
  color: var(--bt-green-dark);
  display: inline-flex;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.theme-v2 .button,
.theme-v2 button:not(.nav-toggle-button, .notification-trigger) {
  border-radius: 9px;
  font-weight: 750;
  min-height: 44px;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.theme-v2 .button:not(.secondary),
.theme-v2 button[type="submit"]:not(.notification-trigger, .topbar-logout-form button) {
  background: var(--bt-green);
  border-color: var(--bt-green);
  color: #fff;
  box-shadow: 0 8px 20px rgba(22, 117, 102, 0.16);
}

.theme-v2 .button:hover,
.theme-v2 button[type="submit"]:hover {
  transform: translateY(-1px);
}

.theme-v2 .button.secondary {
  background: var(--bt-panel);
  border-color: var(--bt-line-strong);
  color: var(--bt-ink);
  box-shadow: none;
}

.theme-v2 .panel,
.theme-v2 .form-panel,
.theme-v2 article[class^="metric-"],
.theme-v2 .metric {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--bt-line);
  border-radius: 14px;
  box-shadow: var(--bt-shadow-sm);
}

.theme-v2 .panel {
  padding: clamp(18px, 2vw, 26px);
}

.theme-v2 .section-title {
  border-bottom: 1px solid #e6edef;
  margin-bottom: 14px;
  padding-bottom: 13px;
}

.theme-v2 .section-title h2 {
  font-size: 1.1rem;
  font-weight: 760;
}

.theme-v2 .metrics,
.theme-v2 .dashboard-metrics {
  gap: 12px;
}

.theme-v2 article[class^="metric-"] {
  border-top: 1px solid var(--bt-line);
  min-height: 138px;
  overflow: hidden;
  padding: 21px;
  position: relative;
}

.theme-v2 article[class^="metric-"]::after {
  background: var(--bt-mint-strong);
  content: "";
  height: 4px;
  inset: 0 0 auto;
  position: absolute;
}

.theme-v2 article[class*="warning"]::after,
.theme-v2 article[class*="urgent"]::after {
  background: #d59636;
}

.theme-v2 article[class*="danger"]::after {
  background: var(--bt-danger);
}

.theme-v2 article[class^="metric-"] strong {
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  font-variant-numeric: tabular-nums;
}

.theme-v2 article[class^="metric-"] span,
.theme-v2 article[class^="metric-"] small {
  color: var(--bt-muted);
}

.theme-v2 .quick-actions {
  background: transparent;
  border: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 18px 0 26px;
  padding: 0;
}

.theme-v2 .quick-actions a {
  background: var(--bt-panel);
  border: 1px solid var(--bt-line);
  border-radius: 9px;
  box-shadow: 0 3px 10px rgba(18, 48, 71, 0.035);
  color: var(--bt-ink);
  font-size: 0.88rem;
  font-weight: 720;
  min-height: 42px;
  padding: 9px 14px;
}

.theme-v2 .quick-actions a:hover {
  background: var(--bt-mint);
  border-color: var(--bt-mint-strong);
  color: var(--bt-green-dark);
}

.theme-v2 .dashboard-grid {
  gap: 18px;
}

.theme-v2 .dashboard-item {
  border: 1px solid transparent;
  border-bottom-color: #e6edef;
  border-radius: 9px;
  min-height: 68px;
  padding: 12px 10px;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.theme-v2 a.dashboard-item:hover {
  background: #f4faf8;
  border-color: var(--bt-mint-strong);
}

.theme-v2 .dashboard-item strong {
  font-weight: 730;
}

.theme-v2 .dashboard-item small,
.theme-v2 .dashboard-item em {
  color: var(--bt-muted);
  font-style: normal;
}

.theme-v2 input:not([type="checkbox"], [type="radio"]),
.theme-v2 select,
.theme-v2 textarea {
  background: #fbfdfd;
  border: 1px solid var(--bt-line-strong);
  border-radius: 9px;
  color: var(--bt-ink);
  min-height: 46px;
  padding: 10px 12px;
}

.theme-v2 textarea {
  line-height: 1.55;
  min-height: 112px;
}

.theme-v2 input:focus,
.theme-v2 select:focus,
.theme-v2 textarea:focus {
  background: #fff;
  border-color: var(--bt-green);
  box-shadow: var(--bt-focus);
  outline: 0;
}

.theme-v2 label {
  color: #314c5b;
  font-weight: 680;
}

.theme-v2 table {
  border: 1px solid var(--bt-line);
  border-collapse: separate;
  border-radius: 12px;
  border-spacing: 0;
  overflow: hidden;
}

.theme-v2 th {
  background: #edf5f3;
  border-bottom: 1px solid var(--bt-line-strong);
  color: #36505d;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

/* Los encabezados permanecen en su fila: evita que cubran datos al desplazar. */
.theme-v2 thead th {
  position: static;
  top: auto;
  z-index: auto;
}

.theme-v2 td {
  border-bottom-color: #e5edef;
}

.theme-v2 tbody tr:hover td {
  background: #f8fbfa;
}

.theme-v2 .status,
.theme-v2 .badge,
.theme-v2 .tag {
  border-radius: 999px;
  font-weight: 750;
}

.theme-v2 .message {
  border: 1px solid var(--bt-line);
  border-left: 4px solid var(--bt-green);
  border-radius: 10px;
  box-shadow: var(--bt-shadow-sm);
}

/* Firma V2: el seguimiento aparece como un hilo, no como tarjetas aisladas. */
.theme-v2 .timeline,
.theme-v2 .case-timeline {
  position: relative;
}

.theme-v2 .timeline::before,
.theme-v2 .case-timeline::before {
  background: linear-gradient(var(--bt-green), var(--bt-mint-strong));
  border-radius: 999px;
  bottom: 24px;
  content: "";
  left: 20px;
  position: absolute;
  top: 24px;
  width: 2px;
}

.theme-v2 .timeline-item {
  background: #fff;
  border: 1px solid var(--bt-line);
  border-radius: 11px;
  box-shadow: 0 5px 16px rgba(18, 48, 71, 0.045);
  margin-left: 20px;
  padding: 15px 17px 15px 26px;
  position: relative;
}

.theme-v2 .timeline-item::before {
  background: var(--bt-green);
  border: 4px solid var(--bt-paper);
  border-radius: 50%;
  content: "";
  height: 14px;
  left: -8px;
  position: absolute;
  top: 20px;
  width: 14px;
}

.theme-v2 .sticky-form-actions {
  backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.94);
  border-color: var(--bt-line);
  box-shadow: 0 -12px 30px rgba(18, 48, 71, 0.07);
}

@media (max-width: 980px) {
  .theme-v2 .topbar-inner {
    min-height: 64px;
  }

  .theme-v2 .main-nav {
    background: #fff;
    border: 1px solid var(--bt-line);
    border-radius: 14px;
    box-shadow: var(--bt-shadow-md);
    padding: 10px !important;
  }

  .theme-v2 .main-nav > a,
  .theme-v2 .nav-menu > summary {
    min-height: 46px !important;
  }
}

@media (max-width: 720px) {
  .theme-v2::before {
    background-size: auto, 48px 48px;
  }

  .theme-v2 .page {
    padding: 22px 14px 64px;
  }

  .theme-v2 .heading,
  .theme-v2 .dashboard-heading {
    align-items: stretch;
    gap: 18px;
  }

  .theme-v2 .heading h1 {
    font-size: clamp(1.9rem, 10vw, 2.65rem);
  }

  .theme-v2 .heading .button-row,
  .theme-v2 .heading .button {
    width: 100%;
  }

  .theme-v2 .metrics,
  .theme-v2 .dashboard-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .theme-v2 article[class^="metric-"] {
    min-height: 126px;
    padding: 17px;
  }

  .theme-v2 .panel {
    border-radius: 12px;
    padding: 17px;
  }

  .theme-v2 table {
    min-width: 720px;
  }
}

@media (max-width: 430px) {
  .theme-v2 .metrics,
  .theme-v2 .dashboard-metrics {
    grid-template-columns: 1fr;
  }

  .theme-v2 article[class^="metric-"] {
    min-height: 112px;
  }
}

/* Integración V2 completa sobre las pantallas operativas reales. */
.theme-v2 {
  background:
    radial-gradient(circle at 88% 4%, rgba(201, 229, 220, 0.58), transparent 24rem),
    linear-gradient(90deg, rgba(18, 48, 71, 0.025) 1px, transparent 1px),
    var(--bt-paper);
  background-size: auto, 64px 64px, auto;
  color: var(--bt-ink);
  font-family: "Segoe UI Variable", "Segoe UI", Inter, system-ui, sans-serif;
}

.theme-v2 .topbar {
  backdrop-filter: blur(18px);
  background: rgba(248, 251, 251, 0.92);
  border-bottom: 1px solid rgba(185, 205, 207, 0.82);
  box-shadow: 0 8px 30px rgba(18, 48, 71, 0.055);
}

.theme-v2 .topbar-inner {
  max-width: 1440px;
  min-height: 72px;
  padding-inline: clamp(18px, 3vw, 42px);
}

.theme-v2 .brand {
  flex: 0 0 auto;
  gap: 11px;
}

.theme-v2 .brand-logo {
  background: #fff;
  border: 1px solid var(--bt-line);
  border-radius: 12px;
  box-shadow: var(--bt-shadow-sm);
  height: 42px;
  padding: 6px;
  width: 42px;
}

.theme-v2 .brand strong {
  color: var(--bt-ink);
  font-size: 0.96rem;
  font-weight: 850;
  letter-spacing: -0.025em;
}

.theme-v2 .brand small {
  color: #4e6975;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.theme-v2 .main-nav {
  align-items: center;
  gap: 2px;
}

.theme-v2 .main-nav > a,
.theme-v2 .nav-menu > summary {
  border: 0;
  border-radius: 9px;
  color: #405b68;
  font-size: 0.82rem;
  font-weight: 750;
  min-height: 42px;
  padding: 0 11px;
}

.theme-v2 .main-nav > a:hover,
.theme-v2 .nav-menu > summary:hover,
.theme-v2 .main-nav > a.active,
.theme-v2 .nav-menu.active > summary {
  background: var(--bt-mint);
  color: var(--bt-green-deep);
}

.theme-v2 .nav-menu > div {
  background: #fff;
  border: 1px solid var(--bt-line);
  border-radius: 12px;
  box-shadow: var(--bt-shadow-md);
  padding: 8px;
}

.theme-v2 .nav-menu > div a {
  border-radius: 8px;
  color: #314c5b;
  font-weight: 700;
  min-height: 42px;
}

.theme-v2 .notification-trigger,
.theme-v2 .topbar-logout-form button {
  background: #fff;
  border: 1px solid var(--bt-line);
  border-radius: 10px;
  color: var(--bt-ink);
  min-height: 44px;
}

.theme-v2 .notification-trigger:hover,
.theme-v2 .topbar-logout-form button:hover {
  background: var(--bt-mint);
  border-color: var(--bt-mint-strong);
  color: var(--bt-green-deep);
}

.theme-v2 .data-mode-banner {
  border: 0;
  box-shadow: inset 0 -1px rgba(18, 48, 71, 0.08);
  min-height: 36px;
}

.theme-v2 .data-mode-banner.demo {
  background: #fff5dd;
  color: #71480d;
}

.theme-v2 .page {
  max-width: 1320px;
  padding: clamp(28px, 4vw, 54px) clamp(18px, 3vw, 40px) 80px;
}

.theme-v2 .heading,
.theme-v2 .dashboard-heading {
  align-items: flex-end;
  border-bottom: 1px solid var(--bt-line);
  margin-bottom: 24px;
  padding-bottom: 22px;
}

.theme-v2 .heading h1,
.theme-v2 .heading h2,
.theme-v2 .dashboard-heading h1,
.theme-v2 .dashboard-heading h2 {
  color: var(--bt-ink);
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 780;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.theme-v2 .heading p,
.theme-v2 .dashboard-heading p {
  color: #56707c;
  font-size: 1rem;
  line-height: 1.6;
  margin-top: 8px;
}

.theme-v2 .panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--bt-line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(18, 48, 71, 0.055);
  padding: clamp(18px, 2.4vw, 26px);
}

.theme-v2 .panel:hover {
  border-color: #bed2d1;
}

.theme-v2 .section-title {
  align-items: center;
  border-bottom: 1px solid #e4ecee;
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.theme-v2 .section-title h2 {
  color: var(--bt-ink);
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.theme-v2 .section-title > a:not(.button) {
  background: var(--bt-mint);
  border-radius: 8px;
  color: var(--bt-green-deep);
  min-height: 40px;
  padding: 9px 12px;
}

.theme-v2 .metrics,
.theme-v2 .dashboard-metrics {
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 26px;
}

.theme-v2 .metrics article,
.theme-v2 .dashboard-metrics article {
  background: linear-gradient(145deg, #fff, #f7fbfa);
  border: 1px solid var(--bt-line);
  border-radius: 14px;
  box-shadow: var(--bt-shadow-sm);
  min-height: 132px;
  padding: 20px;
}

.theme-v2 .metrics article strong,
.theme-v2 .dashboard-metrics article strong {
  color: var(--bt-ink);
  font-size: clamp(1.8rem, 4vw, 2.45rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em;
}

.theme-v2 .metrics article span,
.theme-v2 .dashboard-metrics article span {
  color: #385563;
  font-size: 0.83rem;
  font-weight: 760;
  line-height: 1.35;
}

.theme-v2 .dashboard-grid,
.theme-v2 .grid.two,
.theme-v2 .grid.three {
  gap: 18px;
  margin-bottom: 18px;
}

.theme-v2 .dashboard-item {
  align-items: center;
  background: #fbfdfd;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--bt-ink);
  min-height: 64px;
  padding: 12px 14px;
}

.theme-v2 .dashboard-item:hover {
  background: var(--bt-mint);
  border-color: var(--bt-mint-strong);
  transform: translateX(2px);
}

.theme-v2 .dashboard-item small {
  color: #607884;
  line-height: 1.45;
}

.theme-v2 .dashboard-item em {
  color: var(--bt-green-deep);
  font-size: 0.74rem;
  font-style: normal;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.theme-v2 table {
  background: #fff;
  border-radius: 11px;
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  width: 100%;
}

.theme-v2 thead,
.theme-v2 tbody {
  width: 100%;
}

.theme-v2 th,
.theme-v2 td {
  line-height: 1.42;
  padding: 13px 14px;
}

.theme-v2 thead th {
  background: #edf5f3;
  box-shadow: inset 0 -1px var(--bt-line-strong);
  color: #314d5a;
  white-space: normal;
}

.theme-v2 tbody tr:last-child td {
  border-bottom: 0;
}

.theme-v2 tbody tr:nth-child(even) td {
  background: #fbfdfd;
}

.theme-v2 input,
.theme-v2 select,
.theme-v2 textarea {
  background: #fbfdfd;
  border: 1px solid #c8d8db;
  border-radius: 9px;
  color: var(--bt-ink);
  min-height: 46px;
  padding: 11px 13px;
}

.theme-v2 textarea {
  min-height: 120px;
}

.theme-v2 .button,
.theme-v2 button:not(.nav-toggle-button) {
  border-radius: 9px;
  font-weight: 780;
  min-height: 44px;
}

.theme-v2 .button:not(.secondary),
.theme-v2 .form button[type="submit"] {
  background: var(--bt-ink);
  border-color: var(--bt-ink);
}

.theme-v2 .button:not(.secondary):hover,
.theme-v2 .form button[type="submit"]:hover {
  background: var(--bt-green);
  border-color: var(--bt-green);
}

.theme-v2 .empty-state,
.theme-v2 .dashboard-list > .muted:only-child {
  background: #f8fbfa;
  border: 1px dashed #bfd2d2;
  border-radius: 10px;
  color: #58717c;
  padding: 22px;
}

@media (max-width: 1120px) {
  .theme-v2 .brand small,
  .theme-v2 .main-nav > a:nth-of-type(2),
  .theme-v2 .main-nav > a:nth-of-type(3) {
    display: none;
  }
}

@media (max-width: 980px) {
  .theme-v2 .brand small {
    display: block;
  }

  .theme-v2 .main-nav {
    max-height: calc(100dvh - 92px);
    overflow-y: auto;
  }

  .theme-v2 .main-nav > a:nth-of-type(2),
  .theme-v2 .main-nav > a:nth-of-type(3) {
    display: flex;
  }
}

@media (max-width: 720px) {
  .theme-v2 {
    background-size: auto, 48px 48px, auto;
  }

  .theme-v2 .page {
    padding: 24px 14px 64px;
  }

  .theme-v2 .metrics,
  .theme-v2 .dashboard-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .theme-v2 .metrics article,
  .theme-v2 .dashboard-metrics article {
    min-height: 116px;
    padding: 16px;
  }

  .theme-v2 .panel {
    border-radius: 13px;
    padding: 17px;
  }

  .theme-v2 table {
    font-size: 0.82rem;
  }

  .theme-v2 th,
  .theme-v2 td {
    min-width: 118px;
    padding: 11px 12px;
  }

  .theme-v2 th:first-child,
  .theme-v2 td:first-child {
    min-width: 138px;
  }
}

@media (max-width: 430px) {
  .theme-v2 .metrics,
  .theme-v2 .dashboard-metrics {
    grid-template-columns: 1fr;
  }

  .theme-v2 .brand small {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-v2 *,
  .theme-v2 *::before,
  .theme-v2 *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Acceso: una portada institucional contenida, no una tarjeta genérica. */
.theme-v2.route-login .page {
  align-items: center;
  display: flex;
  min-height: calc(100dvh - 68px);
}

.theme-v2 .login-shell {
  align-items: stretch;
  background: var(--bt-ink-deep);
  border: 1px solid rgba(18, 48, 71, 0.16);
  border-radius: 24px;
  box-shadow: 0 32px 90px rgba(10, 34, 51, 0.2);
  gap: 0;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  margin: 0 auto;
  max-width: 1120px;
  overflow: hidden;
  width: 100%;
}

.theme-v2 .login-intro {
  background:
    radial-gradient(circle at 15% 5%, rgba(142, 212, 196, 0.18), transparent 18rem),
    linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: auto, 52px 52px;
  color: #dce7eb;
  padding: clamp(34px, 6vw, 72px);
}

.theme-v2 .login-intro .eyebrow,
.theme-v2 .login-intro h1,
.theme-v2 .login-intro p {
  color: inherit;
}

.theme-v2 .login-intro h1 {
  color: #fff;
  font-size: clamp(2.5rem, 5vw, 4.8rem);
  line-height: 0.98;
  margin-top: 28px;
  max-width: 650px;
}

.theme-v2 .login-intro p {
  font-size: 1.05rem;
  line-height: 1.7;
  max-width: 620px;
}

.theme-v2 .login-proof {
  border-top: 1px solid rgba(255,255,255,0.14);
  gap: 10px;
  margin-top: 34px;
  padding-top: 24px;
}

.theme-v2 .login-proof span {
  background: rgba(255,255,255,0.075);
  border: 1px solid rgba(255,255,255,0.12);
  color: #eef6f4;
}

.theme-v2 .login-card {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 58px);
}

.theme-v2 .login-card .section-title h2 {
  font-size: 1.65rem;
}

.theme-v2 .login-form {
  gap: 18px;
}

.theme-v2 .login-form button {
  margin-top: 5px;
  width: 100%;
}

/* Pendientes: densidad operativa con jerarquía antes que decoración. */
.theme-v2.route-pendientes .pending-visual-hero {
  background:
    linear-gradient(115deg, rgba(10,34,51,0.98), rgba(18,48,71,0.94)),
    var(--bt-ink);
  border: 0;
  border-radius: 18px;
  box-shadow: var(--bt-shadow-md);
  color: #dbe7eb;
  margin-bottom: 22px;
  min-height: 220px;
  padding: clamp(24px, 4vw, 42px);
}

.theme-v2.route-pendientes .pending-visual-hero h1,
.theme-v2.route-pendientes .pending-visual-hero p,
.theme-v2.route-pendientes .visual-kicker {
  color: inherit;
}

.theme-v2.route-pendientes .pending-visual-hero h1 {
  color: #fff;
  font-size: clamp(2.8rem, 6vw, 5.4rem);
  line-height: 0.95;
}

.theme-v2.route-pendientes .visual-kicker {
  color: #8ed4c4;
  letter-spacing: 0.12em;
}

.theme-v2.route-pendientes .visual-hero-card {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px;
  min-width: 180px;
}

.theme-v2.route-pendientes .visual-hero-card strong,
.theme-v2.route-pendientes .visual-hero-card span {
  color: #fff;
}

.theme-v2.route-pendientes .metrics article {
  border-radius: 12px;
  min-height: 116px;
  padding: 17px;
}

.theme-v2 .dashboard-list > .muted:only-child,
.theme-v2 .timeline > .muted:only-child {
  align-items: center;
  background: #f7faf9;
  border: 1px dashed var(--bt-line-strong);
  border-radius: 10px;
  color: var(--bt-muted);
  display: flex;
  font-size: 0.9rem;
  justify-content: center;
  margin: 4px 0 0;
  min-height: 78px;
  padding: 16px;
  text-align: center;
}

/* Centro de caso: acciones y pestañas permanecen legibles en alta densidad. */
.theme-v2 .case-actions-wide {
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.theme-v2 .case-actions a {
  background: #f8fbfa;
  border: 1px solid var(--bt-line);
  border-radius: 11px;
  min-height: 76px;
  padding: 14px;
}

.theme-v2 .case-actions a:hover {
  background: var(--bt-mint);
  border-color: var(--bt-mint-strong);
}

.theme-v2 .case-tabs {
  background: #eaf2f1;
  border: 1px solid var(--bt-line);
  border-radius: 12px;
  gap: 5px;
  padding: 5px;
  position: sticky;
  top: 76px;
  z-index: 8;
}

.theme-v2 .case-tabs button {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  color: var(--bt-muted) !important;
  min-width: 110px;
}

.theme-v2 .case-tabs button.active {
  background: #fff !important;
  color: var(--bt-ink) !important;
  box-shadow: var(--bt-shadow-sm) !important;
}

@media (max-width: 820px) {
  .theme-v2 .login-shell {
    grid-template-columns: 1fr;
  }

  .theme-v2 .login-intro {
    padding: 34px 28px;
  }

  .theme-v2 .login-intro h1 {
    font-size: clamp(2.35rem, 10vw, 3.6rem);
  }

  .theme-v2 .login-proof {
    display: none;
  }

  .theme-v2 .case-actions-wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Identidad editorial: bitácora de acompañamiento escolar. */
.theme-v2.route-login .topbar {
  display: none;
}

.theme-v2.route-login .page {
  min-height: calc(100dvh - 36px);
  padding-block: clamp(18px, 4vw, 48px);
}

.theme-v2.route-login .login-shell {
  grid-template-columns: minmax(0, 1.18fr) minmax(340px, 0.82fr);
  max-width: 1240px;
  position: relative;
}

.theme-v2.route-login .login-shell::before {
  background: #d99b45;
  border-radius: 8px 8px 0 0;
  color: #3f2b0e;
  content: "BITÁCORA DE ACOMPAÑAMIENTO";
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  padding: 9px 16px 8px;
  position: absolute;
  right: 36px;
  top: -31px;
  z-index: -1;
}

.theme-v2.route-login .login-intro {
  overflow: hidden;
  padding: clamp(38px, 5vw, 66px);
  position: relative;
}

.theme-v2.route-login .login-intro::before {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 31px,
    rgba(28, 96, 86, 0.075) 32px
  );
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.theme-v2.route-login .login-intro::after {
  background: #d49a5b;
  bottom: 0;
  content: "";
  left: 25px;
  opacity: 0.52;
  position: absolute;
  top: 0;
  width: 2px;
}

.theme-v2.route-login .login-intro > * {
  position: relative;
  z-index: 1;
}

.theme-v2.route-login .login-masthead {
  align-items: flex-end;
  border-bottom: 1px solid rgba(18, 48, 71, 0.17);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: clamp(34px, 6vw, 64px);
  padding-bottom: 20px;
}

.theme-v2.route-login .login-logo {
  margin: 0;
  max-width: 285px;
  width: min(56%, 285px);
}

.theme-v2.route-login .login-edition {
  color: #536c76;
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  max-width: 160px;
  text-align: right;
  text-transform: uppercase;
}

.theme-v2.route-login .login-intro .eyebrow {
  align-items: center;
  display: inline-flex;
  gap: 10px;
  letter-spacing: 0.14em;
}

.theme-v2.route-login .login-intro .eyebrow::before {
  background: var(--bt-green);
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(22, 117, 102, 0.12);
  content: "";
  height: 8px;
  width: 8px;
}

.theme-v2.route-login .login-intro h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.7rem, 5.2vw, 5.25rem);
  font-weight: 700;
  letter-spacing: -0.052em;
  line-height: 0.98;
  margin: 24px 0;
}

.theme-v2.route-login .login-lead {
  border-left: 3px solid #d99b45;
  font-size: 1.05rem;
  margin: 0;
  max-width: 590px;
  padding-left: 16px;
}

.theme-v2.route-login .login-care-thread {
  display: grid;
  gap: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: clamp(34px, 5vw, 54px);
  position: relative;
}

.theme-v2.route-login .login-care-thread::before {
  background: linear-gradient(90deg, var(--bt-green), #89bfb5);
  content: "";
  height: 2px;
  left: 18px;
  position: absolute;
  right: 18px;
  top: 18px;
}

.theme-v2.route-login .login-care-step {
  display: grid;
  gap: 12px;
  grid-template-columns: 36px 1fr;
  position: relative;
}

.theme-v2.route-login .login-care-step > span {
  align-items: center;
  background: #fff;
  border: 2px solid #9fc9c0;
  border-radius: 50%;
  color: var(--bt-green-deep);
  display: flex;
  font-size: 0.62rem;
  font-weight: 900;
  height: 36px;
  justify-content: center;
  position: relative;
  width: 36px;
  z-index: 1;
}

.theme-v2.route-login .login-care-step:first-child > span {
  background: var(--bt-green);
  border-color: var(--bt-green);
  color: #fff;
}

.theme-v2.route-login .login-care-step div {
  display: grid;
  gap: 3px;
  padding: 2px 8px 0 0;
}

.theme-v2.route-login .login-care-step strong {
  color: var(--bt-ink);
  font-size: 0.82rem;
  font-weight: 850;
}

.theme-v2.route-login .login-care-step small {
  color: #58717b;
  font-size: 0.7rem;
  line-height: 1.35;
}

.theme-v2.route-login .login-card {
  border-left: 1px solid #d1e0e0;
  padding: clamp(34px, 5vw, 64px);
  position: relative;
}

.theme-v2.route-login .login-card::after {
  border: 1px solid #bfd3d0;
  border-radius: 50%;
  bottom: 34px;
  color: #4f746d;
  content: "BT";
  display: grid;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.78rem;
  font-weight: 700;
  height: 42px;
  opacity: 0.72;
  place-items: center;
  position: absolute;
  right: 34px;
  transform: rotate(-8deg);
  width: 42px;
}

.theme-v2.route-login .login-card-kicker {
  color: var(--bt-green-deep);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.theme-v2.route-login .login-card .section-title {
  margin-top: 10px;
}

.theme-v2.route-login .login-card .section-title h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  letter-spacing: -0.035em;
}

.theme-v2.route-login .login-form {
  margin-top: 10px;
}

.theme-v2.route-login .login-form button[type="submit"] {
  box-shadow: 0 10px 24px rgba(18, 48, 71, 0.16);
  margin-top: 6px;
}

@media (max-width: 820px) {
  .theme-v2.route-login .login-shell {
    grid-template-columns: 1fr;
  }

  .theme-v2.route-login .login-shell::before {
    right: 24px;
  }

  .theme-v2.route-login .login-masthead {
    margin-bottom: 34px;
  }

  .theme-v2.route-login .login-intro h1 {
    font-size: clamp(2.45rem, 11vw, 4rem);
  }

  .theme-v2.route-login .login-card {
    border-left: 0;
    border-top: 1px solid #d1e0e0;
  }
}

@media (max-width: 540px) {
  .theme-v2.route-login .login-intro,
  .theme-v2.route-login .login-card {
    padding: 28px 24px 34px;
  }

  .theme-v2.route-login .login-intro::after {
    left: 13px;
  }

  .theme-v2.route-login .login-edition {
    display: none;
  }

  .theme-v2.route-login .login-logo {
    width: min(78%, 270px);
  }

  .theme-v2.route-login .login-care-thread {
    gap: 16px;
    grid-template-columns: 1fr;
  }

  .theme-v2.route-login .login-care-thread::before {
    bottom: 18px;
    height: auto;
    left: 17px;
    right: auto;
    top: 18px;
    width: 2px;
  }

  .theme-v2.route-login .login-care-step div {
    padding-top: 1px;
  }
}

@media (max-width: 520px) {
  .theme-v2.route-login .page {
    padding: 12px;
  }

  .theme-v2 .login-shell {
    border-radius: 16px;
  }

  .theme-v2 .login-intro {
    padding: 28px 22px;
  }

  .theme-v2 .login-intro p {
    font-size: 0.95rem;
  }

  .theme-v2 .login-card {
    padding: 28px 22px;
  }

  .theme-v2.route-pendientes .pending-visual-hero {
    align-items: stretch;
    min-height: 0;
  }

  .theme-v2.route-pendientes .visual-hero-card {
    min-width: 0;
    width: 100%;
  }

  .theme-v2 .case-actions-wide {
    grid-template-columns: 1fr;
  }

  .theme-v2 .case-tabs {
    overflow-x: auto;
    top: 68px;
  }
}

/* Acceso V2 claro: contraste alto para lectura cómoda en cualquier pantalla. */
.theme-v2.route-login {
  background:
    radial-gradient(circle at 12% 12%, rgba(201, 229, 220, 0.92), transparent 25rem),
    linear-gradient(135deg, #fbfdfd 0%, #eef6f3 55%, #f7fafb 100%);
}

.theme-v2.route-login .page {
  min-height: calc(100dvh - 108px);
}

.theme-v2.route-login .login-shell {
  background: #fff;
  border-color: #c8dada;
  box-shadow: 0 26px 70px rgba(18, 48, 71, 0.13);
}

.theme-v2.route-login .login-intro {
  background:
    radial-gradient(circle at 15% 8%, rgba(255, 255, 255, 0.95), transparent 17rem),
    linear-gradient(135deg, #e3f3ee 0%, #f3f8f6 62%, #eaf3f2 100%);
  color: var(--bt-ink);
}

.theme-v2.route-login .login-intro .eyebrow {
  color: var(--bt-green-deep);
}

.theme-v2.route-login .login-intro h1 {
  color: #0a2a3d;
  max-width: 620px;
  text-shadow: none;
}

.theme-v2.route-login .login-intro p {
  color: #405d69;
  font-weight: 500;
}

.theme-v2.route-login .login-proof {
  border-top-color: rgba(18, 48, 71, 0.13);
}

.theme-v2.route-login .login-proof span {
  background: rgba(255, 255, 255, 0.8);
  border-color: #bfd5d1;
  color: #0f5c50;
}

.theme-v2.route-login .login-card {
  background: #fff;
  color: var(--bt-ink);
}

.theme-v2.route-login .login-card .section-title {
  border-bottom-color: #e1e9eb;
}

.theme-v2.route-login .login-card .section-title h2 {
  color: var(--bt-ink);
}

.theme-v2.route-login .login-card .muted {
  color: #526d79;
}

.theme-v2.route-login .login-form label {
  color: #263f4d;
}

.theme-v2.route-login .login-form input {
  background: #f9fbfb;
  border-color: #b8cbcf;
  color: #102f42;
}

.theme-v2.route-login .login-form input::placeholder {
  color: #6b7f88;
}

.theme-v2.route-login .login-form input:focus {
  background: #fff;
  border-color: var(--bt-green);
}

.theme-v2.route-login .login-form button[type="submit"] {
  background: #123047;
  border-color: #123047;
  color: #fff;
}

.theme-v2.route-login .login-form button[type="submit"]:hover {
  background: #167566;
  border-color: #167566;
}

@media (max-width: 820px) {
  .theme-v2.route-login .login-intro {
    border-bottom: 1px solid #d5e4e2;
  }

  .theme-v2.route-login .login-intro h1 {
    font-size: clamp(2.1rem, 9vw, 3.35rem);
    line-height: 1.02;
  }
}

/* Identidad definitiva: Continuidad institucional. */
.theme-v2.route-login {
  background:
    radial-gradient(circle at 8% 15%, rgba(226, 241, 237, 0.92), transparent 28rem),
    #f4f7f7;
}

.theme-v2.route-login .page {
  min-height: calc(100dvh - 36px);
  padding: clamp(20px, 4vw, 48px) clamp(16px, 3vw, 36px);
}

.theme-v2.route-login .login-shell {
  background: #fff;
  border: 1px solid #cddbdc;
  border-radius: 18px;
  box-shadow: 0 22px 54px rgba(22, 56, 74, 0.1);
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.75fr);
  max-width: 1120px;
  min-height: min(680px, calc(100dvh - 90px));
  overflow: hidden;
}

.theme-v2 {
  background:
    radial-gradient(circle at 88% 4%, rgba(201, 229, 220, 0.44), transparent 24rem),
    #f4f7f7;
  background-size: auto;
}

.theme-v2::before {
  content: none;
}

.theme-v2.route-login .login-shell::before,
.theme-v2.route-login .login-intro::before,
.theme-v2.route-login .login-intro::after,
.theme-v2.route-login .login-card::after {
  content: none;
}

.theme-v2.route-login .login-intro {
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 255, 255, 0.9), transparent 17rem),
    linear-gradient(145deg, #e8f2ef 0%, #f4f8f7 72%);
  border-right: 1px solid #d5e1e1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(38px, 5vw, 60px);
}

.theme-v2.route-login .login-masthead {
  align-items: center;
  border-bottom: 1px solid rgba(22, 56, 74, 0.16);
  margin-bottom: clamp(34px, 5vw, 52px);
  padding-bottom: 18px;
}

.theme-v2.route-login .login-logo {
  max-width: 252px;
  width: min(58%, 252px);
}

.theme-v2.route-login .login-edition {
  color: #526a75;
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  max-width: 130px;
}

.theme-v2.route-login .login-intro .eyebrow {
  color: #187466;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
}

.theme-v2.route-login .login-intro .eyebrow::before {
  box-shadow: 0 0 0 4px rgba(24, 116, 102, 0.11);
  height: 7px;
  width: 7px;
}

.theme-v2.route-login .login-intro h1 {
  color: #16384a;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  font-size: clamp(2.35rem, 4.5vw, 4.15rem);
  font-weight: 760;
  letter-spacing: -0.052em;
  line-height: 1.01;
  margin: 20px 0;
  max-width: 570px;
}

.theme-v2.route-login .login-lead {
  border-left: 0;
  color: #405d69;
  font-size: 1rem;
  line-height: 1.65;
  max-width: 570px;
  padding-left: 0;
}

.theme-v2.route-login .login-care-thread {
  margin-top: clamp(34px, 5vw, 48px);
}

.theme-v2.route-login .login-care-thread::before {
  background: #8dbeb5;
}

.theme-v2.route-login .login-care-step > span {
  border-color: #9ec6bf;
  color: #125e53;
}

.theme-v2.route-login .login-care-step:first-child > span {
  background: #fff;
  border-color: #9ec6bf;
  color: #125e53;
}

.theme-v2.route-login .login-care-step strong {
  color: #16384a;
  font-size: 0.8rem;
}

.theme-v2.route-login .login-care-step small {
  color: #5b717a;
}

.theme-v2.route-login .login-card {
  align-self: stretch;
  background: #fff;
  border: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(38px, 5vw, 58px);
}

.theme-v2.route-login .login-card-kicker {
  color: #187466;
}

.theme-v2.route-login .login-card .section-title h2 {
  color: #16384a;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  font-size: clamp(1.75rem, 2.7vw, 2.2rem);
  font-weight: 750;
  letter-spacing: -0.035em;
}

.theme-v2.route-login .login-form button[type="submit"] {
  background: #16384a;
  border-color: #16384a;
  box-shadow: none;
}

.theme-v2.route-login .login-form button[type="submit"]:hover {
  background: #187466;
  border-color: #187466;
}

/* La línea de continuidad es la única firma gráfica compartida. */
.theme-v2:not(.route-login) .heading,
.theme-v2:not(.route-login) .dashboard-heading {
  position: relative;
}

.theme-v2:not(.route-login) .heading::after,
.theme-v2:not(.route-login) .dashboard-heading::after {
  background: linear-gradient(90deg, #187466 0 72px, #c4dad6 72px 100%);
  bottom: -1px;
  content: "";
  height: 2px;
  left: 0;
  position: absolute;
  right: 0;
}

@media (max-width: 820px) {
  .theme-v2.route-login .login-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .theme-v2.route-login .login-intro {
    border-bottom: 1px solid #d5e1e1;
    border-right: 0;
  }

  .theme-v2.route-login .login-intro h1 {
    font-size: clamp(2.25rem, 9vw, 3.45rem);
  }
}

@media (max-width: 540px) {
  .theme-v2.route-login .page {
    padding: 12px;
  }

  .theme-v2.route-login .login-intro,
  .theme-v2.route-login .login-card {
    padding: 28px 24px 34px;
  }

  .theme-v2.route-login .login-masthead {
    margin-bottom: 30px;
  }

  .theme-v2.route-login .login-care-thread {
    gap: 14px;
    grid-template-columns: 1fr;
  }

  .theme-v2.route-login .login-care-thread::before {
    bottom: 18px;
    height: auto;
    left: 17px;
    right: auto;
    top: 18px;
    width: 2px;
  }
}
