:root {
  --bg: #f4f2fb;
  --panel: #ffffff;
  --ink: #1c2526;
  --muted: #695f78;
  --line: #ded8ea;
  --brand: #3d1a78;
  --brand-2: #5b2ab1;
  --brand-3: #8a4fd6;
  --ciencia-basica: #00a6ff;
  --ciencias-ingenieria: #ff4d00;
  --ingenieria-aplicada: #18b400;
  --diseno-ingenieria: #c026d3;
  --economico-administrativas: #f2b705;
  --sociales-humanidades: #ef2f6d;
  --cursos-complementarios: #6d5dfc;
  --sin-eje: #64748b;
  --i: #0ea5e9;
  --m: #f59e0b;
  --a: #dc2626;
  --shadow: 0 12px 28px rgba(61, 26, 120, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.home-page {
  background: #100f16;
  color: #fff;
}

.home-hero {
  position: relative;
  min-height: 78vh;
  display: grid;
  align-content: space-between;
  overflow: hidden;
  background: #111018;
}

.home-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0.78;
}

.home-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(16, 15, 22, 0.44);
}

.home-nav,
.home-content {
  position: relative;
  z-index: 1;
}

.home-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(18px, 5vw, 64px);
}

.home-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}

.logo-pair {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.home-brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 4px;
}

.home-content {
  width: min(920px, calc(100% - 36px));
  margin: 0 auto;
  padding: 48px 0 56px;
}

.home-content h1 {
  max-width: 760px;
  margin: 8px 0 14px;
  font-size: clamp(42px, 7vw, 86px);
  line-height: 0.95;
}

.home-content > p {
  max-width: 690px;
  margin: 0 0 28px;
  color: #eee8f8;
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.45;
}

.program-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  width: min(760px, 100%);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-left: 6px solid var(--brand-3);
  border-radius: 8px;
  background: rgba(16, 15, 22, 0.78);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.program-entry h2 {
  margin: 4px 0 6px;
  font-size: clamp(22px, 3vw, 34px);
}

.program-entry p {
  margin: 0;
  color: #d8d1e6;
}

.primary-link,
.card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 900;
}

.primary-link {
  padding: 0 18px;
  background: var(--brand-3);
  color: #fff;
  white-space: nowrap;
}

.primary-link:hover {
  background: #9d67e4;
}

.home-main {
  padding: 30px clamp(18px, 5vw, 64px) 56px;
  background: var(--bg);
  color: var(--ink);
}

.programs-section {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 4px 0 0;
  color: var(--brand);
  font-size: 28px;
}

.program-card {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 104px;
  padding: 18px;
  border: 1px solid rgba(91, 42, 177, 0.18);
  border-left: 6px solid var(--brand-2);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, border-color 160ms ease;
}

.program-card + .program-card {
  margin-top: 14px;
}

.program-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-2);
}

.program-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}

.program-card h3 {
  margin: 0 0 4px;
  font-size: 20px;
}

.program-card p {
  margin: 0;
  color: var(--muted);
}

.card-action {
  padding: 0 14px;
  background: #efe9fb;
  color: var(--brand);
}

button,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 94px;
  padding: 14px clamp(16px, 4vw, 34px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 16px 34px rgba(61, 26, 120, 0.22);
  backdrop-filter: blur(12px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.header-logos {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.uach-logo {
  width: 76px;
  height: 76px;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 4px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
}

.fing-logo {
  width: 76px;
  height: 76px;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 4px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
}

.institution {
  display: block;
  margin-bottom: 4px;
  color: #efe6ff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(21px, 2.4vw, 31px);
  line-height: 1.05;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-top: 8px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.filter-block span,
.filter-block label {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.topbar p {
  margin: 0;
  color: #efe6ff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}

.back-link:hover {
  background: rgba(255, 255, 255, 0.2);
}

.plan-link {
  background: rgba(255, 255, 255, 0.92);
  color: var(--brand);
}

.plan-link:hover {
  background: #fff;
}

.shell {
  padding: 18px clamp(16px, 4vw, 34px) 40px;
}

.filters {
  position: sticky;
  top: 94px;
  z-index: 9;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(260px, 1.5fr) minmax(190px, 0.8fr);
  align-items: end;
  gap: 14px;
  padding: 12px clamp(16px, 4vw, 34px);
  border-bottom: 1px solid rgba(91, 42, 177, 0.18);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 24px rgba(61, 26, 120, 0.08);
  backdrop-filter: blur(12px);
}

.filter-block {
  display: grid;
  gap: 8px;
}

.filter-block label,
.filter-block span {
  font-weight: 800;
}

select,
.wide-button,
.icon-button {
  border: 1px solid rgba(91, 42, 177, 0.2);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

select,
.wide-button {
  min-height: 42px;
  padding: 9px 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.wide-button {
  cursor: pointer;
  text-align: left;
  color: var(--brand);
  font-weight: 800;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  cursor: pointer;
  font-size: 22px;
}

.topbar .icon-button {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.level-toggles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.level-toggles label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.level {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.level-i { background: var(--i); }
.level-m { background: var(--m); }
.level-a { background: var(--a); }

.board-wrap {
  position: relative;
  min-width: 0;
}

#connections {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.board {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 18px;
}

.cycle {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 16px;
  align-items: start;
  min-height: 120px;
}

.cycle-label {
  position: sticky;
  top: 186px;
  padding: 10px 12px;
  border-left: 4px solid var(--brand);
  color: var(--brand);
  font-weight: 800;
  background: rgba(255, 255, 255, 0.68);
  border-radius: 0 8px 8px 0;
  backdrop-filter: blur(8px);
}

.subjects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.subject {
  --eje-color: var(--sin-eje);
  --eje-soft: rgba(100, 116, 139, 0.14);
  min-height: 132px;
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--eje-color) 58%, #ffffff);
  border-left: 8px solid var(--eje-color);
  border-radius: 8px;
  background: var(--panel);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 8px 22px color-mix(in srgb, var(--eje-color) 18%, rgba(61, 26, 120, 0.08));
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.subject:hover,
.subject.active {
  transform: translateY(-2px);
  border-color: var(--eje-color);
  box-shadow: 0 14px 28px color-mix(in srgb, var(--eje-color) 28%, rgba(28, 37, 38, 0.08));
}

.subject.dimmed {
  opacity: 0.24;
}

.subject h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.24;
}

.subject-meta,
.subject small {
  color: var(--muted);
  font-size: 12px;
}

.subject-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--eje-color);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.eje-ciencia-basica {
  --eje-color: var(--ciencia-basica);
  --eje-soft: rgba(0, 166, 255, 0.15);
}

.eje-ciencias-de-la-ingenieria {
  --eje-color: var(--ciencias-ingenieria);
  --eje-soft: rgba(255, 77, 0, 0.14);
}

.eje-ingenieria-aplicada {
  --eje-color: var(--ingenieria-aplicada);
  --eje-soft: rgba(24, 180, 0, 0.14);
}

.eje-diseno-de-ingenieria {
  --eje-color: var(--diseno-ingenieria);
  --eje-soft: rgba(192, 38, 211, 0.14);
}

.eje-ciencias-economico-administrativas {
  --eje-color: var(--economico-administrativas);
  --eje-soft: rgba(242, 183, 5, 0.18);
}

.eje-ciencias-sociales-y-humanidades {
  --eje-color: var(--sociales-humanidades);
  --eje-soft: rgba(239, 47, 109, 0.14);
}

.eje-cursos-complementarios {
  --eje-color: var(--cursos-complementarios);
  --eje-soft: rgba(109, 93, 252, 0.14);
}

.special-panel {
  position: relative;
  z-index: 1;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.special-panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.special-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.credits-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(240px, 320px) minmax(260px, 1fr);
  align-items: center;
  gap: 22px;
  margin-top: 28px;
  padding: 22px;
  border: 1px solid rgba(91, 42, 177, 0.18);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.credits-copy h2 {
  margin: 4px 0 8px;
  color: var(--brand);
  font-size: 24px;
}

.credits-copy p {
  margin: 0;
  color: var(--muted);
}

.section-kicker {
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.donut-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 270px;
}

.donut {
  width: min(270px, 100%);
  aspect-ratio: 1;
  overflow: visible;
}

.donut-slice {
  cursor: pointer;
  stroke: #fff;
  stroke-width: 2;
  transition: opacity 140ms ease, transform 140ms ease;
  transform-origin: 120px 120px;
}

.donut-slice:hover,
.donut-slice:focus {
  opacity: 0.86;
  transform: scale(1.025);
  outline: none;
}

.donut-center {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  transform: translate(-50%, -50%);
  text-align: center;
}

.donut-center strong {
  font-size: 28px;
  line-height: 1;
}

.donut-center span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.donut-legend {
  display: grid;
  gap: 8px;
}

.legend-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.legend-item:hover,
.legend-item.selected {
  border-color: var(--brand-2);
  box-shadow: 0 8px 18px rgba(61, 26, 120, 0.1);
}

.legend-item span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-item strong {
  color: var(--brand);
  font-size: 12px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
}

dialog {
  width: min(720px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(28, 37, 38, 0.34);
}

.close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.detail-cell {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.detail-cell strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.detail-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.detail-section strong {
  display: block;
  margin-bottom: 6px;
  color: var(--brand);
}

.detail-section p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}

@media (max-width: 860px) {
  .home-hero {
    min-height: auto;
  }

  .home-bg {
    object-position: 44% center;
  }

  .home-content {
    padding: 36px 0 42px;
  }

  .program-entry,
  .program-card {
    grid-template-columns: 1fr;
  }

  .program-card {
    align-items: start;
  }

  .primary-link,
  .card-action {
    width: 100%;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .uach-logo {
    width: 58px;
    height: 58px;
  }

  .fing-logo {
    width: 58px;
    height: 58px;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .topbar p {
    white-space: normal;
  }

  .cycle-label {
    position: static;
  }

  .filters {
    position: static;
    grid-template-columns: 1fr;
  }

  .cycle {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .credits-panel {
    grid-template-columns: 1fr;
  }
}
