:root {
  --blue-bright: #5bc2e7;
  --blue: #005bbb;
  --blue-deep: #003f7d;
  --blue-ink: #052f58;
  --blue-pale: #eaf5fb;
  --green: #16835d;
  --green-pale: #e9f7f1;
  --amber: #a66000;
  --amber-pale: #fff4db;
  --red: #b53434;
  --red-pale: #fff0ef;
  --ink: #17212b;
  --muted: #647383;
  --line: #dce3e9;
  --line-strong: #c8d2dc;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --shadow: 0 12px 34px rgba(0, 43, 82, 0.08);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: #eef4f8;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 0%, rgba(91, 194, 231, 0.17), transparent 27rem),
    linear-gradient(180deg, #f8fbfd 0, #eef4f8 42rem);
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(0, 91, 187, 0.25);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  z-index: 50;
  top: 0;
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 10px 24px;
  border-bottom: 1px solid #d6e0e8;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 5px 18px rgba(0, 52, 94, 0.06);
  backdrop-filter: blur(14px);
}

.brand {
  flex: 0 0 auto;
  color: inherit;
  text-decoration: none;
  line-height: 1;
}

.brand-word {
  display: block;
  color: var(--blue-deep);
  font-size: 25px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.brand-subtitle {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.015em;
  white-space: nowrap;
}

.main-nav {
  display: flex;
  align-self: stretch;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
}

.nav-item {
  position: relative;
  border: 0;
  padding: 0 12px;
  color: #536372;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.nav-item::after {
  position: absolute;
  right: 10px;
  bottom: -10px;
  left: 10px;
  height: 3px;
  border-radius: 4px 4px 0 0;
  background: transparent;
  content: "";
}

.nav-item:hover {
  color: var(--blue);
}

.nav-item.is-active {
  color: var(--blue-deep);
}

.nav-item.is-active::after {
  background: var(--blue);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}

.demo-badge,
.term-badge {
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 800;
}

.demo-badge {
  color: #41556a;
  background: #edf1f5;
}

.term-badge {
  color: var(--blue-deep);
  background: #dfeefa;
}

.sample-link {
  border-radius: 9px;
  padding: 8px 11px;
  color: #fff;
  background: var(--green);
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
}

.sample-link:hover {
  background: #116d4d;
}

.engine-banner {
  min-height: 37px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 8px 20px;
  color: #365a78;
  background: #e7f3fa;
  border-bottom: 1px solid #d2e7f3;
  font-size: 12px;
  font-weight: 650;
  transition: 180ms ease;
}

.engine-banner.is-ready {
  color: #34614d;
  background: var(--green-pale);
  border-color: #cce9dc;
}

.engine-banner.is-error {
  color: var(--red);
  background: var(--red-pale);
}

.engine-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 5px rgba(54, 90, 120, 0.09);
}

.engine-banner:not(.is-ready):not(.is-error) .engine-dot {
  animation: pulse 1.2s ease-in-out infinite;
}

.app-content {
  width: min(1600px, calc(100% - 40px));
  margin: 28px auto 80px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  color: var(--blue-ink);
  font-size: clamp(25px, 3vw, 36px);
  letter-spacing: -0.035em;
}

h2 {
  color: var(--blue-ink);
  font-size: 18px;
}

.heading-copy {
  max-width: 750px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.summary-line {
  color: #556878;
  font-size: 13px;
  font-weight: 650;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.file-toolbar,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-toolbar {
  margin-bottom: 14px;
  padding: 11px 13px;
  border: 1px solid #d8e3ec;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.88);
}

.loaded-file {
  color: #334c62;
  font-size: 12px;
  font-weight: 750;
}

.privacy-copy {
  color: #71808d;
  font-size: 11px;
}

.privacy-copy::before {
  content: "•";
  margin-right: 9px;
  color: var(--green);
}

.button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 13px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition:
    color 140ms ease,
    background 140ms ease,
    border 140ms ease,
    transform 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-primary {
  color: #fff;
  background: var(--blue);
}

.button-primary:hover:not(:disabled) {
  background: var(--blue-deep);
}

.button-secondary {
  border-color: var(--line-strong);
  color: #354a5e;
  background: #fff;
}

.button-secondary:hover:not(:disabled) {
  border-color: #9eb4c6;
  background: #f7fafc;
}

.button-danger {
  border-color: #efc7c4;
  color: var(--red);
  background: var(--red-pale);
}

.entity-layout {
  display: grid;
  grid-template-columns: minmax(390px, 1fr) minmax(330px, 0.72fr);
  min-height: 630px;
  overflow: hidden;
}

.entity-browser {
  border-right: 1px solid var(--line);
}

.browser-toolbar {
  padding: 15px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 39px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 11px;
  background: #fff;
}

.search:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 91, 187, 0.08);
}

.search span {
  color: #7d8b97;
  font-size: 19px;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
}

.filter-row {
  display: flex;
  gap: 7px;
  margin-top: 11px;
  overflow-x: auto;
}

.filter-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: #536575;
  background: #fff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.filter-chip.is-active {
  border-color: var(--blue);
  color: var(--blue-deep);
  background: var(--blue-pale);
}

.browser-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.browser-actions small {
  color: var(--muted);
}

.text-button {
  border: 0;
  padding: 3px 5px;
  color: var(--blue);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.entity-list {
  max-height: 590px;
  overflow: auto;
}

.year-heading {
  position: sticky;
  z-index: 1;
  top: 0;
  margin: 0;
  padding: 9px 15px;
  color: #4d6071;
  background: #f0f4f7;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.entity-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid #edf1f4;
  padding: 12px 15px;
  text-align: left;
  color: inherit;
  background: #fff;
  cursor: pointer;
}

.entity-row:hover {
  background: #f8fbfd;
}

.entity-row.is-selected {
  background: #eef7fc;
  box-shadow: inset 3px 0 var(--blue);
}

.entity-row strong,
.entity-row small {
  display: block;
}

.entity-row strong {
  overflow: hidden;
  margin-bottom: 4px;
  color: #203749;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-row small {
  color: #71808d;
  font-size: 11px;
}

.row-tags {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 5px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.tag.include,
.tag.assigned {
  color: #176048;
  background: var(--green-pale);
}

.tag.exclude {
  color: #6e7780;
  background: #eef1f3;
}

.tag.unallocated {
  color: var(--amber);
  background: var(--amber-pale);
}

.tag.required {
  color: var(--blue-deep);
  background: #e3f0fa;
}

.detail-pane {
  padding: 22px;
  background: linear-gradient(180deg, #fff, #fbfcfd);
}

.detail-overline {
  margin-bottom: 7px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.detail-pane h2 {
  margin-bottom: 6px;
  font-size: 23px;
}

.detail-subtitle {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 13px;
}

.detail-tabs {
  display: flex;
  gap: 5px;
  border-bottom: 1px solid var(--line);
}

.detail-tabs span {
  padding: 9px 11px;
  color: #71808d;
  font-size: 11px;
  font-weight: 800;
}

.detail-tabs .is-active {
  color: var(--blue-deep);
  border-bottom: 2px solid var(--blue);
}

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

.data-card {
  min-height: 76px;
  border: 1px solid #e2e8ed;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.data-card.is-wide {
  grid-column: 1 / -1;
}

.data-label {
  display: block;
  margin-bottom: 7px;
  color: #71808d;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.data-value {
  display: block;
  overflow-wrap: anywhere;
  color: #263d50;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.empty {
  display: grid;
  min-height: 300px;
  place-items: center;
  padding: 40px;
  color: var(--muted);
  text-align: center;
}

.timetable-panel {
  overflow: hidden;
}

.timetable-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.timetable-toolbar .search {
  width: min(340px, 100%);
  margin-left: auto;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: #edf2f6;
  overflow-x: auto;
}

.segment {
  border: 0;
  border-radius: 7px;
  padding: 7px 9px;
  color: #5b6c7b;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.segment.is-active {
  color: var(--blue-deep);
  background: #fff;
  box-shadow: 0 1px 5px rgba(24, 58, 84, 0.12);
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 14px;
  color: #496173;
  background: #f4f8fb;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
}

.progress-details {
  min-width: 0;
  flex: 1 1 auto;
}

.progress-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 7px;
}

.progress-heading strong {
  color: var(--blue-deep);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.progress-heading span {
  color: #53697a;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  position: relative;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #d9e4eb;
  box-shadow: inset 0 1px 2px rgba(0, 43, 82, 0.08);
}

.progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--blue-bright));
  box-shadow: 0 0 8px rgba(0, 91, 187, 0.24);
  transition: width 120ms linear;
}

.progress-copy {
  display: block;
  overflow: hidden;
  margin-top: 7px;
  color: #607383;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-scroll {
  overflow: auto;
  max-height: calc(100vh - 245px);
  min-height: 520px;
}

.schedule {
  --row-height: 26px;
  --time-width: 78px;
  min-width: 920px;
  position: relative;
  display: grid;
  grid-template-columns: var(--time-width) 1fr;
  background: #fff;
}

.schedule-head {
  position: sticky;
  z-index: 12;
  top: 0;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: var(--time-width) repeat(var(--day-count), minmax(160px, 1fr));
  min-height: 43px;
  border-bottom: 1px solid var(--line-strong);
  background: #f7f9fb;
}

.schedule-head div {
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  color: #44596a;
  font-size: 11px;
  font-weight: 850;
}

.time-axis {
  position: relative;
  height: calc(52 * var(--row-height));
  border-right: 1px solid var(--line-strong);
  background: #fafcfd;
}

.time-label {
  position: absolute;
  right: 10px;
  transform: translateY(-7px);
  color: #71808d;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.grid-canvas {
  position: relative;
  height: calc(52 * var(--row-height));
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, #edf1f4 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 91, 187, 0.07) 1px, transparent 1px);
  background-size:
    calc(100% / var(--day-count)) 100%,
    100% var(--row-height),
    100% calc(var(--row-height) * 4);
}

.course-block {
  position: absolute;
  z-index: 2;
  overflow: hidden;
  border: 1px solid rgba(0, 63, 125, 0.18);
  border-left: 3px solid rgba(0, 63, 125, 0.6);
  border-radius: 6px;
  padding: 5px 6px;
  color: #0c3557;
  box-shadow: 0 2px 6px rgba(0, 44, 82, 0.09);
  cursor: pointer;
  font-size: 9px;
  line-height: 1.25;
}

.course-block:hover {
  z-index: 5;
  filter: saturate(1.1) brightness(0.98);
}

.course-block strong,
.course-block span {
  display: block;
}

.course-block strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.course-block span {
  margin-top: 2px;
  opacity: 0.82;
}

.course-block.is-dimmed {
  opacity: 0.12;
}

.empty-grid {
  position: absolute;
  z-index: 4;
  top: 56px;
  left: 50%;
  width: min(440px, 80%);
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  color: #607383;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  text-align: center;
  font-size: 12px;
}

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

.settings-card,
.help-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 18px;
  background: #fff;
  box-shadow: 0 7px 22px rgba(0, 43, 82, 0.05);
}

.settings-card h2,
.help-card h2 {
  margin-bottom: 8px;
  font-size: 15px;
}

.settings-card p,
.help-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.algorithm-note {
  grid-column: span 2;
  border-color: #bdd7e8;
  background: linear-gradient(135deg, #f8fcff, #edf7fc);
}

.algorithm-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 14px;
}

.algorithm-step {
  border-radius: 9px;
  padding: 11px;
  color: #244862;
  background: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
}

.noscript {
  margin: 30px;
  color: var(--red);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

@media (max-width: 1180px) {
  .app-header {
    flex-wrap: wrap;
    gap: 8px 16px;
  }

  .main-nav {
    order: 3;
    width: 100%;
    min-height: 39px;
  }

  .nav-item::after {
    bottom: 0;
  }

  .header-actions {
    margin-left: auto;
  }
}

@media (max-width: 820px) {
  .app-content {
    width: min(100% - 22px, 1600px);
    margin-top: 17px;
  }

  .brand-subtitle,
  .demo-badge,
  .sample-link {
    display: none;
  }

  .entity-layout {
    grid-template-columns: 1fr;
  }

  .entity-browser {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .entity-list {
    max-height: 430px;
  }

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

  .algorithm-note {
    grid-column: auto;
  }

  .timetable-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .timetable-toolbar .search {
    width: 100%;
    margin-left: 0;
  }

  .progress-wrap {
    align-items: stretch;
  }
}

@media (max-width: 520px) {
  .app-header {
    padding: 9px 12px;
  }

  .header-actions {
    gap: 5px;
  }

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

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

  .data-card.is-wide {
    grid-column: auto;
  }
}
