:root {
  --page: #f2f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --ink: #111827;
  --muted: #667085;
  --line: #d8e2ee;
  --line-strong: #b7c8dc;
  --blue: #1f5fbf;
  --blue-deep: #123a74;
  --blue-soft: #eaf2ff;
  --teal: #0f766e;
  --teal-soft: #e6f6f3;
  --green: #16834a;
  --green-soft: #e9f7ef;
  --amber: #a15c07;
  --amber-soft: #fff5df;
  --red: #b42318;
  --red-soft: #fff0ef;
  --violet: #6841bf;
  --violet-soft: #f3efff;
  --shadow: 0 18px 42px rgba(15, 23, 42, .08);
  --shadow-soft: 0 8px 22px rgba(15, 23, 42, .06);
}

html {
  background: var(--page);
}

body {
  color: var(--ink);
  background:
    linear-gradient(180deg, #eaf3fb 0, #f8fafc 230px, #f2f6fb 100%);
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, #1f5fbf 0%, #0f766e 38%, #16834a 70%, #d18b11 100%);
  z-index: 10;
}

#apiStatus {
  display: none !important;
}

.page {
  width: min(1280px, calc(100% - 36px));
  margin: 22px auto 46px;
}

.gate {
  min-height: calc(100vh - 44px);
}

.gate-card,
.panel,
.modal-panel {
  border: 1px solid rgba(183, 200, 220, .78);
  border-radius: 8px;
  background: rgba(255, 255, 255, .97);
  box-shadow: var(--shadow);
}

.gate-card {
  width: min(96vw, 700px);
  padding: 32px;
}

.brand-row,
.app-header {
  gap: 22px;
}

.app-header {
  position: relative;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  padding: 24px 26px;
  margin-top: 14px;
  overflow: hidden;
}

.app-header::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, #1f5fbf, #0f766e, #16834a, #d18b11);
}

.logo-box {
  position: relative;
  width: 112px !important;
  height: 112px !important;
  padding: 6px !important;
  flex: 0 0 auto;
  overflow: visible !important;
  border: 1px solid #c4d7ee !important;
  border-radius: 8px !important;
  background: #fff !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .9), 0 10px 22px rgba(31, 95, 191, .11);
}

.logo-box img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  padding: 0 !important;
  object-fit: contain !important;
  object-position: center !important;
  border-radius: 0 !important;
  clip-path: none !important;
}

.logo-box .logo-fallback {
  position: absolute;
  inset: 9px;
  display: none;
  place-items: center;
  border: 1px solid #c4d7ee;
  border-radius: 8px;
  background: #eaf2ff;
  color: var(--blue-deep);
  font-size: 25px;
  font-weight: 900;
}

.logo-box.logo-failed img {
  display: none !important;
}

.logo-box.logo-failed .logo-fallback {
  display: grid;
}

.app-logo {
  width: 104px !important;
  height: 104px !important;
}

.gate-title,
.app-title {
  color: #101828;
  letter-spacing: 0;
}

.gate-title {
  font-size: clamp(32px, 5vw, 43px);
  line-height: 1.1;
}

.app-title {
  max-width: 980px;
  font-size: clamp(29px, 3vw, 40px);
  line-height: 1.12;
}

.subline,
.mode-text,
.env-note,
.muted {
  color: var(--muted);
}

.mode-text {
  margin-top: 8px;
}

.toolbar,
.actions,
.select-row {
  gap: 10px;
}

.toolbar {
  margin-top: 18px;
}

.btn,
.mode-btn {
  min-height: 46px;
  border-radius: 8px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}

.btn:hover,
.mode-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.btn {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn.secondary {
  background: #fff;
  border-color: #b8cdf2;
  color: #143f89;
}

.btn.ghost {
  background: transparent;
  color: #475467;
}

.mode-row {
  gap: 12px;
}

.mode-btn {
  padding: 15px 16px;
  border-color: #c8d7e9;
  background: #fff;
}

.mode-btn.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.auth-box,
.strip-cell,
.metric,
.issue-box,
.semester-credit,
.semester-card,
.mini-block {
  border-radius: 8px;
  border-color: #dce5ef;
}

.auth-box {
  background: var(--surface-soft);
}

.panel {
  padding: 18px;
  margin-top: 14px;
}

.tools-grid {
  align-items: end;
}

.result {
  gap: 16px;
}

.student-strip {
  grid-template-columns: minmax(280px, 1.15fr) repeat(3, minmax(140px, .48fr));
  gap: 12px;
}

.student-strip.source-trimmed {
  grid-template-columns: minmax(280px, 1.15fr) minmax(140px, .45fr) minmax(180px, .55fr);
}

.strip-cell.source-cell {
  display: none !important;
}

.strip-cell {
  background: #fff;
  padding: 15px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .03);
}

.strip-label {
  color: #66758c;
  font-size: 12px;
  font-weight: 900;
}

.strip-value {
  color: #101828;
  font-size: clamp(17px, 1.55vw, 21px);
  line-height: 1.22;
}

.metric-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  position: relative;
  min-height: 116px;
  padding: 16px;
  overflow: hidden;
  background: #fff;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--blue);
}

.metric.good::before { background: var(--green); }
.metric.warn::before { background: #d18b11; }
.metric.bad::before { background: var(--red); }
.metric.neutral::before { background: var(--teal); }

.metric strong {
  margin-top: 9px;
  font-size: clamp(22px, 2vw, 27px);
}

.metric.neutral {
  background: linear-gradient(180deg, #f3f9ff, #fff);
  border-color: #c9daf7;
}

.metric.good {
  background: linear-gradient(180deg, #effaf4, #fff);
  border-color: #b8dec8;
}

.metric.warn {
  background: linear-gradient(180deg, #fff8e8, #fff);
  border-color: #edd39d;
}

.metric.bad {
  background: linear-gradient(180deg, #fff2f1, #fff);
  border-color: #efc7c2;
}

.dashboard-grid {
  grid-template-columns: minmax(420px, .92fr) minmax(440px, 1.08fr);
  gap: 16px;
}

.section-title {
  align-items: center;
  margin-bottom: 14px;
}

.section-title h3 {
  color: #172033;
  font-size: 18px;
}

.badge {
  min-height: 25px;
  border-radius: 999px;
  font-weight: 900;
}

.group-compact-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.group-credit-card {
  display: grid;
  gap: 8px;
  min-height: 84px;
  padding: 11px 12px;
  border: 1px solid #dce7f2;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.group-credit-card.warn {
  border-color: #f0d39b;
  background: linear-gradient(180deg, #fffaf0, #ffffff);
}

.group-credit-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.group-credit-name {
  min-width: 0;
  color: #152238;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.25;
  word-break: keep-all;
}

.group-credit-value {
  color: #475467;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.group-credit-value strong {
  color: #111827;
  font-size: 17px;
}

.group-credit-track {
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: #e7eef7;
}

.group-credit-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e, #19a596);
}

.group-credit-card.warn .group-credit-fill {
  background: linear-gradient(90deg, #d18b11, #efb146);
}

.group-credit-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #667085;
  font-size: 12px;
  font-weight: 800;
}

.table-wrap {
  border: 1px solid #e3ebf4;
  border-radius: 8px;
  background: #fff;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f7fb;
  color: #344054;
}

th,
td {
  padding: 10px 9px;
}

tr:hover td {
  background: rgba(234, 242, 255, .42);
}

.progress-track {
  height: 10px;
  background: #e5edf6;
}

.progress-bar {
  background: var(--teal);
}

.issue-grid {
  gap: 12px;
}

.issue-box {
  min-height: 110px;
}

.issue-head {
  color: #18243a;
}

.semester-credit-grid {
  gap: 10px;
}

.semester-credit {
  background: linear-gradient(180deg, #fff, #f8fbff);
}

.semester-card header {
  background: #f6f9fd;
}

.course-table td:last-child {
  max-width: 280px;
}

.raw,
details.raw {
  display: none !important;
}

.modal {
  background: rgba(15, 23, 42, .48);
}

.modal-head {
  background: #12325f;
}

.site-footer {
  width: min(1280px, calc(100% - 36px));
  margin: -22px auto 28px;
  color: #667085;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.plan-matrix-wrap {
  margin-top: 14px;
  overflow: auto;
  border: 1px solid #dce7f2;
  border-radius: 8px;
  background: #fff;
}

.plan-matrix-table {
  min-width: 1120px;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.plan-matrix-table th,
.plan-matrix-table td {
  border-right: 1px solid #e5edf6;
  border-bottom: 1px solid #e5edf6;
  vertical-align: top;
}

.plan-matrix-table th:first-child,
.plan-matrix-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 110px;
  background: #f4f7fb;
  color: #172033;
  font-weight: 900;
}

.plan-matrix-table thead th {
  min-width: 162px;
  text-align: center;
}

.plan-semester-head {
  display: grid;
  gap: 5px;
}

.plan-semester-head strong {
  color: #111827;
  font-size: 15px;
}

.plan-semester-head span {
  color: #5f6f85;
  font-size: 12px;
  font-weight: 800;
}

.plan-cell-list {
  display: grid;
  gap: 8px;
}

.plan-block {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid #e3ebf4;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.plan-block.selection {
  background: linear-gradient(180deg, #f6f2ff, #ffffff);
}

.plan-block-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #172033;
  font-size: 13px;
  font-weight: 900;
}

.plan-course-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.plan-course-list li {
  color: #344054;
  font-size: 12px;
  line-height: 1.35;
}

.plan-credit-cell {
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
}

.plan-credit-cell strong {
  color: #111827;
  font-size: 20px;
}

.plan-credit-cell span {
  color: #667085;
  font-size: 12px;
  font-weight: 800;
}

body.ui-polished .gate-card,
body.ui-polished .app-header,
body.ui-polished #teacherTools,
body.ui-polished #status,
body.ui-polished #result > *,
body.ui-polished .site-footer {
  animation: uiRise .42s ease both;
}

body.ui-polished .logo-box {
  animation: logoBreathe 4.8s ease-in-out infinite;
}

body.ui-polished .mode-btn,
body.ui-polished .btn,
body.ui-polished .metric,
body.ui-polished .group-credit-card,
body.ui-polished .issue-box {
  will-change: transform;
}

.status.loading {
  position: relative;
  overflow: hidden;
}

.status.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  animation: statusSweep 1.25s ease-in-out infinite;
}

@keyframes uiRise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes logoBreathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes statusSweep {
  to { transform: translateX(100%); }
}

@media (max-width: 1120px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .student-strip,
  .student-strip.source-trimmed,
  .dashboard-grid,
  .tools-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .group-compact-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .page {
    width: min(100% - 20px, 1280px);
    margin-top: 12px;
  }

  .gate-card,
  .panel {
    padding: 14px;
  }

  .brand-row,
  .app-header {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    text-align: left;
  }

  .logo-box,
  .app-logo {
    width: 82px !important;
    height: 82px !important;
    padding: 5px !important;
  }

  .gate-title,
  .app-title {
    font-size: 25px;
  }

  .toolbar,
  .actions,
  .select-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn,
  .mode-btn {
    width: 100%;
  }

  .mode-row,
  .two,
  .metric-grid,
  .issue-grid,
  .semester-credit-grid,
  .summary-grid,
  .block-grid {
    grid-template-columns: 1fr;
  }

  .site-footer {
    width: min(100% - 20px, 1280px);
    margin-top: -18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
