:root {
  color-scheme: light;
  --bg: #e9eef6;
  --bg-2: #f8f4f5;
  --panel: #fbfdff;
  --panel-strong: #f4f8ff;
  --panel-raised: #fffdf8;
  --line: #cbd7e6;
  --line-strong: #7690b4;
  --text: #10201f;
  --muted: #657580;
  --primary: #38517f;
  --primary-strong: #2b416b;
  --accent: #c92f3a;
  --accent-2: #5d75a5;
  --accent-3: #a92731;
  --accent-4: #7587b2;
  --danger: #a93641;
  --success: #2f6f69;
  --navy-deep: #1f3458;
  --navy: #2d4774;
  --navy-soft: #3e5c8b;
  --navy-ink: #182947;
  --surface-wash: #fbfdff;
  --surface-quiet: #f4f7fb;
  --surface-tint: #edf4ff;
  --card-wash: #f3f7ff;
  --card-blue: #edf3ff;
  --card-blue-soft: #f7faff;
  --card-blue-strong: #e4ecfb;
  --card-danger: #fff5f6;
  --card-red: #fff3f4;
  --card-red-soft: #fff9fa;
  --card-red-strong: #ffe9eb;
  --shadow: 0 1px 2px rgba(16, 32, 31, 0.08);
  --shadow-soft: 0 1px 2px rgba(16, 32, 31, 0.06);
  --sans: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: var(--sans);
  --number: var(--sans);
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;
  --dashboard-breakdown-table-height-offset: 10px;
  --leading-tight: 1.22;
  --leading-normal: 1.45;
  --leading-relaxed: 1.68;
}

:is(.summary-card strong,
  .category-card-head strong,
  .report-card strong,
  .mix-row strong,
  .credit-value strong,
  .stem-shortcut strong,
  .mini-metric strong,
  .rank-no,
  .course-no-pill,
  input[type="number"],
  .allocation-input,
  .detail-chip,
  .teacher-load-main small,
  .distribution-main small,
  .breakdown-table td:not(:first-child),
  .mini-table td:not(:first-child),
  .allocation-table td:nth-child(4),
  .allocation-table td:nth-child(5)) {
  font-family: var(--number);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(135deg, #e9eef6 0%, #f7f9fd 46%, #fff3f4 100%);
  font-family: var(--sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
}

body::before {
  content: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(48, 69, 127, 0.45);
  border-radius: 6px;
  color: #ffffff;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  box-shadow: none;
  cursor: pointer;
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

button:hover {
  background: linear-gradient(180deg, #3d5595, var(--primary-strong));
}

button:active {
  background: var(--primary-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button.ghost,
.text-button,
.tab-button {
  color: var(--text);
  background: linear-gradient(180deg, #ffffff, #f1f5fb);
  border-color: #c3cedd;
  box-shadow: none;
}

button.ghost:hover,
.tab-button:hover {
  color: var(--primary-strong);
  border-color: rgba(48, 69, 127, 0.42);
  background: linear-gradient(180deg, #ffffff, #e8eef8);
}

button.ghost:active,
.tab-button:active {
  background: #dfe8f5;
}

.text-button {
  min-height: auto;
  padding: 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  box-shadow: none;
}

.text-button:hover {
  color: var(--primary-strong);
  background: transparent;
}

.auth-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  color: var(--muted);
  font-size: var(--text-sm);
}

.app-footer {
  display: flex;
  justify-content: center;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(180deg, #334a72, #263b60);
}

.app-footer .auth-line {
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  color: #eef4ff;
  text-align: center;
}

.app-footer .auth-line .compact-button {
  min-height: 30px;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(233, 238, 246, 0.88);
  backdrop-filter: blur(8px);
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel h2 {
  margin: 0;
  font-size: var(--text-2xl);
  line-height: var(--leading-tight);
}

.auth-panel .eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

.auth-panel small {
  min-height: 20px;
  color: var(--danger);
}

.tab-button.active {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.tab-button.active:hover {
  color: #ffffff;
  background: var(--primary-strong);
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #ffffff;
  padding: 8px 10px;
  box-shadow: none;
  font-family: var(--sans);
  font-weight: var(--weight-regular);
}

select {
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
  padding-right: 38px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

select option {
  font-family: var(--sans);
  font-weight: var(--weight-regular);
}

input::placeholder,
textarea::placeholder {
  color: #8a9d9a;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(48, 69, 127, 0.12);
}

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

.page-shell {
  width: min(1580px, calc(100vw - 24px));
  margin: 12px auto 24px;
}

.hero,
.dashboard-panel,
.sidebar-panel,
.content-panel,
.budget-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(237, 243, 249, 0.74)),
    var(--panel);
  box-shadow: var(--shadow);
}

.hero::before,
.dashboard-panel::before,
.sidebar-panel::before,
.content-panel::before,
.budget-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-top: 1px solid rgba(215, 25, 32, 0.28);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.48), transparent 48%);
}

.sidebar-panel::before,
.content-panel::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), transparent 48%);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(680px, auto);
  align-items: center;
  gap: 18px;
  padding: 20px clamp(18px, 2.6vw, 30px);
  border-color: rgba(48, 69, 127, 0.24);
  background:
    linear-gradient(90deg, rgba(232, 239, 251, 0.98), rgba(248, 250, 252, 0.96) 58%, rgba(255, 242, 243, 0.92)),
    var(--panel);
  animation: boot 360ms ease;
}

.hero-copy,
.hero-view-nav,
.summary-card,
.dashboard-panel>*,
.sidebar-panel>*,
.content-panel>*,
.budget-panel>* {
  position: relative;
  z-index: 1;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  color: var(--primary);
  font-family: var(--sans);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
  text-transform: none;
}

.eyebrow::before {
  content: "●";
  color: var(--accent);
  font-size: var(--text-xs);
}

.hero h1,
.detail-title {
  font-family: var(--sans);
  letter-spacing: 0;
}

.hero h1 {
  max-width: 20ch;
  color: #10211f;
  font-size: clamp(28px, 3.2vw, 44px);
  line-height: 1.08;
  font-weight: var(--weight-bold);
}

.hero-text {
  max-width: 76ch;
  margin-top: 10px;
  color: #526966;
  line-height: var(--leading-relaxed);
}

.view-nav {
  display: flex;
  gap: 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.hero-view-nav {
  justify-self: end;
  align-self: end;
  margin: 0 0 18px;
  width: min(100%, 720px);
  background: transparent;
}

.view-tab {
  flex: 1 1 0;
  min-width: 0;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(239, 244, 252, 0.9));
  border-color: #c3cedd;
  box-shadow: none;
  white-space: nowrap;
}

.view-tab.active {
  color: #ffffff;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  border-color: var(--primary);
}

.import-tab {
  color: var(--accent);
  border-color: rgba(201, 47, 58, 0.36);
  background: linear-gradient(180deg, #fffafa, #fff1f3);
}

.import-tab:hover {
  border-color: rgba(201, 47, 58, 0.48);
  background: linear-gradient(180deg, #ffffff, #ffe9ec);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.summary-card {
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(234, 242, 255, 0.9));
  box-shadow: var(--shadow-soft);
}

.summary-card:nth-child(n) {
  border-color: rgba(48, 69, 127, 0.24);
  background: linear-gradient(180deg, var(--card-blue-soft), var(--card-blue));
}

.summary-card span,
.summary-card small,
.field span,
.meta-block label,
.detail-note,
.section-caption {
  color: var(--muted);
}

.summary-card span,
.field span,
.meta-block label,
.section-caption,
.mini-table th,
.allocation-table th {
  font-family: var(--sans);
  font-size: var(--text-xs);
  letter-spacing: 0;
  text-transform: none;
}

.summary-card span {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.summary-card strong {
  display: block;
  margin-top: 10px;
  color: var(--primary);
  font-family: var(--number);
  font-size: var(--text-3xl);
  line-height: 1;
}

.summary-card small {
  display: block;
  margin-top: 7px;
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  line-height: 1.35;
}

.summary-card.budget {
  border-color: rgba(48, 69, 127, 0.24);
  background: linear-gradient(180deg, var(--card-blue-soft), var(--card-blue));
}

.summary-card.allocation-status {
  border-color: rgba(48, 69, 127, 0.28);
  background: linear-gradient(180deg, var(--card-blue-soft), var(--card-blue-strong));
}

.app-layout {
  margin-top: 12px;
}

.view-panel {
  margin-top: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
  align-items: stretch;
}

.dashboard-stack {
  display: grid;
  grid-template-rows: auto auto;
  gap: 12px;
  align-content: start;
}

.dashboard-grid .breakdown-panel {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  margin-top: 0;
}

.dashboard-secondary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 12px;
  margin-top: 12px;
}

.dashboard-insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 0;
  align-items: start;
}

.dashboard-insight-grid>.dashboard-panel {
  display: flex;
  height: var(--insight-panel-height, auto);
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.dashboard-insight-grid .dashboard-panel {
  margin-top: 0;
}

.dashboard-panel {
  padding: 14px;
}

.category-dashboard,
.category-budget-panel,
.report-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.primary-dashboard .category-dashboard {
  grid-template-columns: 1fr;
}

.category-card,
.report-card,
.mix-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(234, 242, 255, 0.9));
  box-shadow: var(--shadow-soft);
}

.category-card:nth-child(n),
.report-card:nth-child(n),
.mix-row:nth-child(n) {
  border-color: rgba(80, 106, 167, 0.24);
  background: linear-gradient(180deg, var(--card-blue-soft), var(--card-blue));
}

.category-card,
.report-card {
  padding: 14px;
}

.allocation-breakdown-panel .category-card {
  padding: 8px 12px;
}

.category-card.over {
  border-color: rgba(215, 25, 32, 0.34);
  background:
    linear-gradient(180deg, rgba(255, 250, 250, 0.96), var(--card-danger));
}

.category-card-head,
.category-card-foot,
.mix-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.category-card-head span,
.report-card span,
.mix-row span {
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  text-transform: none;
}

.category-card-head strong,
.report-card strong,
.mix-row strong {
  color: var(--primary-strong);
  font-family: var(--number);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}

.progress-track {
  height: 9px;
  margin: 14px 0 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(48, 69, 127, 0.12);
}

.allocation-breakdown-panel .progress-track {
  margin: 7px 0 6px;
}

.progress-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-2), var(--primary-strong));
}

.category-card-foot small,
.report-card small,
.mix-row small {
  color: var(--muted);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.allocation-breakdown-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
}

.allocation-breakdown-actions button {
  min-height: 42px;
  padding-inline: 10px;
}

.course-mix {
  display: grid;
  gap: 8px;
}

.dashboard-grid .course-mix {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mix-row {
  min-height: 72px;
  padding: 12px 14px;
}

.dashboard-grid .mix-row {
  display: grid;
  grid-template-columns: 1fr;
  align-content: center;
  justify-items: center;
  min-height: 94px;
  gap: 6px;
  text-align: center;
}

.teacher-load-board {
  display: grid;
  gap: 10px;
}

.attribute-distribution,
.sdg-distribution {
  display: grid;
  gap: 8px;
}

.dashboard-insight-grid .teacher-load-board,
.dashboard-insight-grid .attribute-distribution,
.dashboard-insight-grid .sdg-distribution {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.teacher-load-list {
  display: grid;
  gap: 8px;
}

.teacher-load-row,
.stem-shortcut,
.attribute-row,
.sdg-row {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 56px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  overflow: hidden;
  padding: 13px 16px 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: linear-gradient(180deg, var(--card-red-soft), var(--card-red));
  box-shadow: var(--shadow-soft);
  text-align: left;
}

.teacher-load-row:hover,
.stem-shortcut:hover,
.attribute-row:hover,
.sdg-row:hover {
  border-color: rgba(215, 25, 32, 0.34);
  background: linear-gradient(180deg, #fffafa, var(--card-red-strong));
  filter: none;
}

.rank-no {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  background: var(--primary);
  font-family: var(--number);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

.teacher-load-main,
.distribution-main,
.stem-shortcut span {
  min-width: 0;
}

.teacher-load-main strong,
.distribution-main strong,
.stem-shortcut span {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teacher-load-main small,
.distribution-main small,
.stem-shortcut small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
}

.credit-value {
  display: inline-flex;
  min-width: 86px;
  align-items: baseline;
  justify-content: flex-end;
  gap: 7px;
  color: var(--accent);
  white-space: nowrap;
}

.credit-value strong {
  font-family: var(--number);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: 1;
}

.credit-value small {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  line-height: 1;
}

.stem-shortcut strong {
  color: var(--primary-strong);
  font-family: var(--number);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}

.teacher-load-row> :not(.teacher-load-bar),
.attribute-row> :not(.attribute-bar),
.sdg-row> :not(.sdg-bar) {
  position: relative;
  z-index: 1;
}

.teacher-load-bar,
.attribute-bar,
.sdg-bar {
  position: absolute;
  inset: auto auto 0 0;
  z-index: 0;
  width: var(--load, var(--amount));
  height: 4px;
  border-right: 0;
  background: rgba(215, 25, 32, 0.24);
}

.attribute-row,
.sdg-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.attribute-row,
.sdg-row {
  min-height: 72px;
}

.stem-shortcut {
  grid-template-columns: minmax(0, 1fr) auto;
  border-color: rgba(215, 25, 32, 0.24);
  background:
    linear-gradient(180deg, var(--card-red-soft), var(--card-red));
}

.stem-shortcut strong {
  color: var(--accent);
  font-size: var(--text-2xl);
}

.teacher-load-panel,
.report-preview,
.report-panel,
.breakdown-panel,
.allocation-breakdown-panel {
  margin-top: 12px;
}

.dashboard-secondary-grid .teacher-load-panel,
.dashboard-secondary-grid .report-preview,
.dashboard-secondary-grid .breakdown-panel {
  margin-top: 0;
}

.allocation-breakdown-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(247, 250, 253, 0.96), rgba(232, 239, 248, 0.9));
}

.budget-entry-grid .allocation-breakdown-panel {
  margin-top: 0;
}

.budget-entry-grid .allocation-breakdown-panel,
.budget-entry-grid .allocation-list-panel {
  align-self: stretch;
}

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

#allocationBreakdown.breakdown-grid {
  grid-template-columns: 1fr;
}

#dashboardBreakdown.breakdown-grid {
  grid-template-columns: 1fr;
  padding-inline: 0;
}

.dashboard-grid .breakdown-panel #dashboardBreakdown {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
}

.dashboard-grid .breakdown-panel .breakdown-table-wrap {
  height: calc(100% - var(--dashboard-breakdown-table-height-offset));
  border: 0;
  border-radius: 0;
}

.dashboard-grid .breakdown-panel .breakdown-table {
  height: 100%;
  table-layout: fixed;
}

.dashboard-grid .breakdown-panel .breakdown-table th,
.dashboard-grid .breakdown-panel .breakdown-table td {
  padding: 6px 12px;
  text-align: center;
  vertical-align: middle;
  font-size: var(--text-md);
  line-height: 1.2;
}

.dashboard-grid .breakdown-panel .breakdown-table th {
  padding: 13px 12px 7px;
}

.dashboard-grid .breakdown-panel .breakdown-table td strong {
  font-size: var(--text-lg);
}

.dashboard-grid .breakdown-panel .breakdown-table th:first-child,
.dashboard-grid .breakdown-panel .breakdown-table td:first-child {
  width: auto;
}

.breakdown-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-wash);
}

.dashboard-grid .breakdown-panel .breakdown-table-wrap {
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.allocation-breakdown-panel .breakdown-table-wrap {
  max-height: 360px;
}

.allocation-breakdown-panel .budget-metrics {
  margin-top: 0;
  order: 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.allocation-breakdown-panel .category-budget-panel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.budget-entry-grid .allocation-breakdown-panel .category-budget-panel {
  grid-template-columns: 1fr;
  align-content: stretch;
}

#categoryBudgetPanel {
  grid-template-columns: 1fr;
}

.budget-entry-grid #categoryBudgetPanel {
  height: 100%;
  grid-auto-rows: minmax(118px, 1fr);
}

.budget-entry-grid .allocation-breakdown-panel .category-card {
  display: grid;
  align-content: center;
  padding: 14px 16px;
}

.budget-entry-grid .allocation-breakdown-panel .progress-track {
  margin: 12px 0 10px;
}

.allocation-breakdown-panel .mini-metric {
  min-height: 76px;
  padding: 12px;
}

.allocation-breakdown-panel .mini-metric strong {
  margin-top: 8px;
  font-size: var(--text-2xl);
}

.allocation-check-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.compact-metric {
  min-height: 92px;
}

.compact-metric strong {
  overflow: hidden;
  margin-top: 10px;
  font-size: var(--text-2xl);
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-metric small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}

.allocation-check-table {
  max-height: 280px;
  border: 0;
  background: transparent;
}

.allocation-check-table .mini-table {
  margin-top: 0;
}

.breakdown-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.breakdown-controls select {
  width: auto;
  min-width: 180px;
}

.breakdown-table {
  min-width: 600px;
  margin-top: 0;
  border: 0;
}

.breakdown-table td,
.breakdown-table th {
  padding: 13px 14px;
  font-size: var(--text-md);
  text-align: center;
  white-space: nowrap;
}

.breakdown-table th {
  background: #e6ebf4;
}

.breakdown-table td strong {
  font-size: var(--text-lg);
}

.report-group {
  margin-top: 16px;
}

.report-group h3 {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: var(--text-md);
}

.empty-state.compact {
  padding: 16px;
}

.danger-badge {
  color: var(--danger);
  border-color: rgba(169, 54, 65, 0.24);
  background: rgba(255, 245, 246, 0.82);
}

.muted-badge {
  color: var(--primary);
  border-color: rgba(48, 69, 127, 0.18);
  background: rgba(244, 248, 255, 0.82);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.58fr) minmax(0, 1.42fr);
  align-items: start;
  gap: 12px;
}

.import-panel {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.import-workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.78fr) minmax(0, 1.22fr);
  gap: 12px;
  align-items: stretch;
}

.import-source-panel,
.import-preview-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(247, 250, 253, 0.96), rgba(232, 239, 248, 0.9));
}

.import-dropzone {
  display: grid;
  min-height: 150px;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 18px;
  border: 1px dashed rgba(48, 69, 127, 0.34);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.62);
  text-align: center;
}

.import-dropzone strong {
  color: var(--primary-strong);
  font-size: var(--text-xl);
  line-height: var(--leading-tight);
}

.import-dropzone p {
  max-width: 38ch;
  color: var(--muted);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
}

.import-dropzone small {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.import-source-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.import-file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.import-file-button span {
  display: inline-grid;
  min-height: 38px;
  place-items: center;
  padding: 0 16px;
  border: 1px solid rgba(48, 69, 127, 0.45);
  border-radius: 6px;
  color: #ffffff;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  font-weight: var(--weight-semibold);
  cursor: pointer;
}

.import-file-button span:hover {
  background: linear-gradient(180deg, #3d5595, var(--primary-strong));
}

.import-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.import-empty-state {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.import-empty-state h3 {
  color: var(--text);
  font-size: var(--text-xl);
}

.import-empty-state p {
  max-width: 62ch;
  margin-top: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.45;
}

.import-preview-list {
  margin-top: 10px;
}

.import-preview-table-wrap {
  max-height: 440px;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.import-preview-table {
  min-width: 760px;
  margin-top: 0;
  border: 0;
  border-radius: 0;
  table-layout: fixed;
}

.import-preview-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.import-preview-table th,
.import-preview-table td {
  padding: 6px 12px;
  text-align: center;
  vertical-align: middle;
  font-size: var(--text-md);
  line-height: 1.2;
}

.import-preview-table th {
  padding: 13px 12px 7px;
}

.import-preview-table td {
  font-weight: var(--weight-medium);
}

.import-preview-table td:nth-child(3) {
  text-align: left;
}

.import-preview-table td strong,
.import-preview-table td small {
  display: block;
}

.import-preview-table td small {
  margin-top: 3px;
  color: var(--danger);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.import-empty-row td {
  height: 96px;
  color: var(--muted);
  text-align: center;
  font-weight: var(--weight-semibold);
}

.import-row-error {
  background: rgba(255, 245, 246, 0.72);
}

#coursesView {
  align-items: start;
}

#coursesView .sidebar-panel {
  display: flex;
  height: var(--course-content-height, auto);
  max-height: var(--course-content-height, none);
  min-height: 0;
  flex-direction: column;
}

.sidebar-panel,
.content-panel,
.budget-panel,
.import-panel {
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head.compact {
  margin-top: 16px;
}

.detail-panel-head {
  justify-content: space-between;
}

.panel-head h2 {
  color: var(--text);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}

.panel-head h2::before {
  content: none;
}

.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(169, 54, 65, 0.24);
  border-radius: 6px;
  color: var(--accent);
  background: rgba(255, 245, 246, 0.82);
  font-family: var(--sans);
  font-weight: var(--weight-semibold);
}

.filter-stack {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-quiet);
}

.filter-stack input,
.filter-stack select {
  min-height: 42px;
  padding: 7px 28px 7px 10px;
  font-size: 14px;
  font-family: var(--sans);
  font-weight: var(--weight-regular);
  line-height: 1.25;
}

.filter-stack input::placeholder {
  font-size: 14px;
}

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

.class-axis-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 8px;
}

.class-axis-grid select {
  padding-right: 26px;
  padding-left: 8px;
  font-size: 13px;
  font-weight: var(--weight-regular);
}

.tag-filter-grid select {
  min-width: 0;
  padding-right: 26px;
  font-size: 13px;
}

.field span {
  display: block;
  margin-bottom: 6px;
}

.course-list {
  display: grid;
  flex: 1;
  gap: 8px;
  align-content: start;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding-right: 4px;
}

.course-card {
  align-self: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(243, 248, 252, 0.96), rgba(224, 233, 245, 0.92));
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 130ms ease, border-color 130ms ease, background 130ms ease;
}

.course-card.course-required {
  border-color: rgba(215, 25, 32, 0.22);
  background: linear-gradient(180deg, #fffafa, #fff1f2);
}

.course-card.course-elective {
  border-color: rgba(48, 69, 127, 0.22);
  background: linear-gradient(180deg, #f8fbff, #edf3ff);
}

.course-card.course-required:hover,
.course-card.course-required.active {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #ffffff, #ffe8ea);
}

.course-card.course-elective:hover,
.course-card.course-elective.active {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #ffffff, #e6eefc);
}

.course-card.course-required:hover {
  border-color: rgba(215, 25, 32, 0.42);
}

.course-card.course-elective:hover {
  border-color: rgba(48, 69, 127, 0.48);
}

.course-card.active {
  box-shadow: inset 3px 0 0 var(--primary), var(--shadow-soft);
}

.course-card.course-required.active {
  border-color: rgba(215, 25, 32, 0.38);
  box-shadow: inset 3px 0 0 var(--accent), var(--shadow-soft);
}

.course-card-top,
.course-card-bottom,
.detail-topline,
.detail-chip-row,
.budget-actions,
.detail-tabs,
.budget-metrics,
.allocation-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.course-card-top {
  justify-content: flex-start;
  gap: 6px;
}

.course-no-pill,
.course-class-pill,
.course-type-marker,
.detail-chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--primary);
  background: rgba(48, 69, 127, 0.08);
  font-family: var(--sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
}

.course-type-marker {
  min-width: 26px;
  justify-content: center;
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
  font-family: var(--sans);
  font-weight: var(--weight-bold);
}

.course-card.course-elective .course-type-marker {
  border-color: var(--primary);
  background: var(--primary);
}

.course-class-pill {
  color: #53676a;
  background: rgba(248, 250, 252, 0.96);
  font-family: var(--sans);
  font-weight: var(--weight-semibold);
}

.course-class-pill.course-group-pill {
  color: #2f5f74;
  border-color: rgba(47, 95, 116, 0.28);
  background: rgba(234, 247, 250, 0.94);
}

.course-attribute-pill {
  font-family: var(--sans);
  font-weight: var(--weight-bold);
}

.detail-chip.course-group-chip {
  color: #2f5f74;
  background: rgba(234, 247, 250, 0.94);
  border-color: rgba(47, 95, 116, 0.28);
}

.detail-chip.attribute-tag {
  color: var(--accent);
  background: rgba(255, 248, 249, 0.86);
  border-color: rgba(215, 25, 32, 0.24);
}

.course-card h3 {
  margin-top: 10px;
  font-size: var(--text-lg);
  line-height: 1.35;
}

.course-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: var(--text-sm);
}

.course-card-bottom {
  margin-top: 10px;
  justify-content: space-between;
  color: #465d5a;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-normal);
}

.detail-panel {
  min-height: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(rgba(48, 69, 127, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(48, 69, 127, 0.06) 1px, transparent 1px),
    var(--panel-strong);
  background-size: 18px 18px, 18px 18px, auto;
  box-shadow: var(--shadow-soft);
}

.detail-panel.course-required {
  border-color: rgba(215, 25, 32, 0.22);
  background:
    linear-gradient(rgba(215, 25, 32, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(215, 25, 32, 0.032) 1px, transparent 1px),
    #fffafa;
}

.detail-panel.course-elective {
  border-color: rgba(48, 69, 127, 0.22);
  background:
    linear-gradient(rgba(48, 69, 127, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(48, 69, 127, 0.035) 1px, transparent 1px),
    #f7faff;
}

.detail-panel.course-required .course-no-pill,
.detail-panel.course-required .detail-chip {
  color: var(--accent);
  border-color: rgba(215, 25, 32, 0.24);
  background: rgba(215, 25, 32, 0.06);
}

.detail-panel.course-elective .course-no-pill,
.detail-panel.course-elective .detail-chip {
  color: var(--primary);
  border-color: rgba(48, 69, 127, 0.24);
  background: rgba(48, 69, 127, 0.075);
}

.detail-panel.course-required .detail-section h3 {
  color: var(--accent);
}

.course-type-chip {
  font-family: var(--sans);
  font-weight: var(--weight-bold);
}

.detail-panel.empty {
  display: grid;
  place-items: center;
  min-height: 420px;
  color: var(--muted);
}

.empty-state {
  max-width: 28rem;
  text-align: center;
}

.empty-state h3 {
  color: var(--primary-strong);
  font-size: var(--text-2xl);
}

.empty-state p {
  margin-top: 10px;
  line-height: 1.7;
}

.detail-title {
  margin-top: 12px;
  color: #13211f;
  font-size: clamp(28px, 2.4vw, 36px);
  line-height: 1.2;
  font-weight: var(--weight-bold);
}

.detail-topline {
  justify-content: space-between;
}

.detail-subtitle {
  margin-top: 12px;
  color: #617571;
  font-size: var(--text-lg);
  line-height: 1.55;
}

.detail-chip-row {
  gap: 10px;
  margin-top: 18px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.meta-block {
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(248, 250, 252, 0.72);
}

.teacher-meta {
  position: relative;
  padding-right: 50px;
}

.meta-block label {
  display: block;
  font-size: var(--text-sm);
}

.meta-block strong {
  display: block;
  margin-top: 6px;
  font-size: var(--text-lg);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.meta-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.email-toggle {
  position: absolute;
  top: 10px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 5px;
  color: var(--primary-strong);
  background: rgba(48, 69, 127, 0.08);
  border-color: rgba(48, 69, 127, 0.3);
  font-family: var(--sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  box-shadow: none;
}

.email-toggle.active {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.teacher-email {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  color: var(--primary-strong);
  font-family: var(--sans);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

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

.detail-section h3 {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: var(--text-lg);
}

.detail-body {
  color: #2f403d;
  white-space: pre-wrap;
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.65fr);
  gap: 24px;
}

.note-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(248, 250, 252, 0.82);
}

.mini-table {
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

.mini-table th,
.mini-table td,
.allocation-table th,
.allocation-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.mini-table td,
.allocation-table td {
  color: #263835;
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
}

.mini-table th,
.allocation-table th {
  color: var(--primary-strong);
  background: #e6ebf4;
}

.allocation-table-wrap {
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-wash);
}

.allocation-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

.allocation-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: center;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.allocation-list-panel .allocation-table td,
.allocation-workspace-panel .allocation-table td {
  text-align: center;
  vertical-align: middle;
}

.allocation-list-panel .allocation-table td:nth-child(2),
.allocation-workspace-panel .allocation-table td:nth-child(2) {
  text-align: left;
}

.allocation-list-panel .allocation-input,
.allocation-list-panel .allocation-select,
.allocation-list-panel .allocation-note,
.allocation-workspace-panel .allocation-input,
.allocation-workspace-panel .allocation-select,
.allocation-workspace-panel .allocation-note {
  text-align: center;
}

.allocation-table tbody tr:hover {
  background: rgba(48, 69, 127, 0.055);
}

.allocation-table tbody tr.teaching-active {
  background: rgba(48, 69, 127, 0.09);
  box-shadow: inset 3px 0 0 var(--primary);
}

.allocation-input,
.allocation-select,
.allocation-note {
  width: 100%;
  min-height: 34px;
}

.allocation-input {
  max-width: 110px;
  font-family: var(--number);
}

.allocation-note {
  min-width: 180px;
}

.allocation-workspace-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(247, 250, 253, 0.96), rgba(232, 239, 248, 0.9));
}

.allocation-workspace-panel .panel-head {
  align-items: center;
  margin-bottom: 0;
}

.allocation-workspace-panel .panel-head h2 {
  font-size: var(--text-xl);
}

.allocation-summary {
  max-width: min(100%, 440px);
}

.allocation-workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.48fr) minmax(0, 1.52fr);
  gap: 14px;
  align-items: stretch;
}

.allocation-status-panel {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
  gap: 8px;
  align-content: stretch;
  min-width: 0;
}

.allocation-table-panel {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
}

.allocation-workspace-panel .category-budget-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.allocation-workspace-panel #categoryBudgetPanel {
  height: 100%;
  grid-auto-rows: minmax(0, 1fr);
}

.allocation-workspace-panel .category-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: space-between;
  min-height: 116px;
  overflow: hidden;
  padding: 16px 18px 14px 20px;
  border-color: rgba(74, 99, 151, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(244, 248, 253, 0.9));
  box-shadow: 0 1px 2px rgba(31, 52, 88, 0.08);
}

.allocation-workspace-panel .category-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.allocation-workspace-panel .category-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--primary);
}

.allocation-workspace-panel .category-card-total::before {
  background: var(--primary-strong);
}

.allocation-workspace-panel .category-card-required::before {
  background: var(--accent);
}

.allocation-workspace-panel .category-card-elective::before {
  background: #2f7f95;
}

.allocation-workspace-panel .category-card-head span {
  min-width: 0;
  color: #5e7078;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
}

.allocation-workspace-panel .category-card-head strong {
  color: var(--primary-strong);
  font-size: var(--text-3xl);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-bold);
  letter-spacing: 0;
  line-height: 0.95;
  text-align: right;
  white-space: nowrap;
}

.allocation-workspace-panel .category-card-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.allocation-workspace-panel .category-card-foot small {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  min-width: 0;
  width: fit-content;
  max-width: 100%;
  padding: 2px 8px;
  border: 1px solid rgba(74, 99, 151, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: #5f7379;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  white-space: nowrap;
}

.allocation-workspace-panel .category-card-foot small:last-child {
  justify-self: end;
}

.allocation-workspace-panel .category-card.unset .category-card-head strong,
.allocation-workspace-panel .category-card.unset .category-card-foot small:last-child {
  color: #6c7f87;
}

.allocation-workspace-panel .progress-track {
  height: 8px;
  margin: 14px 0 12px;
  border-color: rgba(48, 69, 127, 0.14);
  background: rgba(48, 69, 127, 0.1);
}

.allocation-workspace-panel .category-card-required .progress-track span {
  background: linear-gradient(90deg, var(--accent), #e06b75);
}

.allocation-workspace-panel .category-card-elective .progress-track span {
  background: linear-gradient(90deg, #2f7f95, #6bb3c4);
}

.allocation-workspace-panel .allocation-breakdown-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 0;
}

.allocation-workspace-panel .allocation-breakdown-actions button {
  min-height: 42px;
  padding-block: 0;
}

.allocation-workspace-panel .allocation-table-wrap {
  height: 400px;
  margin-top: 0;
}

.teaching-hours-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(247, 250, 253, 0.96), rgba(232, 239, 248, 0.9));
}

.teaching-hours-panel .panel-head {
  align-items: center;
  margin-bottom: 0;
}

.teaching-hours-panel .panel-head h2 {
  font-size: var(--text-xl);
}

.teaching-hours-workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.48fr) minmax(0, 1.52fr);
  gap: 14px;
  align-items: stretch;
}

.teaching-status-panel {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto repeat(3, minmax(0, 1fr));
  gap: 8px;
  height: 100%;
}

.teaching-status-panel .mini-metric {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-content: center;
  align-items: center;
  min-height: 70px;
  overflow: hidden;
  padding: 13px 16px 13px 18px;
  border-color: rgba(74, 99, 151, 0.24);
  gap: 6px 12px;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(245, 248, 253, 0.9));
  box-shadow: 0 1px 2px rgba(31, 52, 88, 0.06);
}

.teaching-status-panel .mini-metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: #6b86b8;
}

.teaching-status-panel .mini-metric span {
  display: block;
  min-width: 0;
  color: #5e7078;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
}

.teaching-status-panel .mini-metric strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--primary-strong);
  font-size: var(--text-xl);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-bold);
  letter-spacing: 0;
  line-height: 1.15;
  justify-self: end;
  margin-top: 0;
  text-align: right;
}

.teaching-status-panel .mini-metric small {
  display: inline-flex;
  align-items: center;
  grid-column: 1 / -1;
  min-height: 24px;
  width: fit-content;
  max-width: 100%;
  padding: 2px 8px;
  border: 1px solid rgba(74, 99, 151, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  margin-top: 0;
  color: #60777a;
}

.teaching-status-panel .teaching-value-card {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-content: center;
  min-height: 84px;
  padding: 14px 16px 14px 18px;
  gap: 8px 14px;
}

.teaching-status-panel .teaching-value-card span {
  grid-column: 1;
  grid-row: 1;
  align-self: end;
}

.teaching-status-panel .teaching-value-card strong {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  justify-self: end;
  font-size: var(--text-3xl);
  line-height: 0.95;
  white-space: nowrap;
}

.teaching-status-panel .teaching-value-card small {
  grid-column: 1;
  grid-row: 2;
  align-self: start;
  font-size: var(--text-sm);
}

.teaching-status-panel .teaching-progress-track {
  grid-column: 1 / -1;
  width: 100%;
  height: 8px;
  margin: 2px 0 0;
  border-color: rgba(48, 69, 127, 0.14);
  background: rgba(48, 69, 127, 0.1);
}

.teaching-status-panel .warning-metric {
  border-color: rgba(215, 25, 32, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 247, 248, 0.9));
}

.teaching-status-panel .warning-metric::before {
  background: var(--accent);
}

.teaching-status-panel .warning-metric strong,
.teaching-status-panel .warning-metric small {
  color: var(--accent);
}

.teaching-table-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.teaching-table-wrap {
  flex: 0 0 386px;
  height: 386px;
  max-height: 386px;
  margin-top: 0;
  background: var(--surface-wash);
}

.teaching-hours-table {
  min-width: 1040px;
  table-layout: fixed;
}

.teaching-hours-table th,
.teaching-hours-table td {
  padding: 10px 12px;
  text-align: center;
  vertical-align: middle;
}

.teaching-hours-table thead tr {
  height: 44px;
}

.teaching-hours-table tbody tr {
  height: 66px;
}

.teaching-hours-table th:nth-child(1) {
  width: 7%;
}

.teaching-hours-table th:nth-child(2) {
  width: 21%;
}

.teaching-hours-table th:nth-child(3) {
  width: 18%;
}

.teaching-hours-table th:nth-child(4) {
  width: 13%;
}

.teaching-hours-table th:nth-child(5) {
  width: 31%;
}

.teaching-hours-table th:nth-child(6) {
  width: 10%;
}

.teaching-hours-table select,
.teaching-hours-table input {
  width: 100%;
  min-height: 34px;
  text-align: center;
}

.teaching-hours-input {
  max-width: 120px;
  font-family: var(--number);
  text-align: center;
}

.teaching-row-number {
  color: var(--primary-strong);
  font-family: var(--number);
  font-weight: var(--weight-bold);
}

.teaching-credit-cell {
  font-family: var(--number);
  text-align: center;
  color: var(--primary-strong);
  font-weight: var(--weight-bold);
}

.teaching-note-input {
  min-width: 180px;
  text-align: center;
}

.teaching-hours-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 0;
}

.status-pill.clean {
  color: var(--success);
  background: rgba(105, 229, 143, 0.08);
  border-color: rgba(105, 229, 143, 0.28);
}

.status-pill.dirty {
  color: var(--accent);
  background: var(--surface-wash);
  border-color: rgba(169, 54, 65, 0.24);
}

.status-pill.category {
  color: var(--accent);
  background: var(--surface-wash);
  border-color: rgba(169, 54, 65, 0.18);
}

.status-pill.category-required {
  color: var(--accent);
  background: rgba(201, 47, 58, 0.07);
  border-color: rgba(169, 54, 65, 0.22);
}

.status-pill.category-elective {
  color: var(--primary);
  background: rgba(56, 81, 127, 0.08);
  border-color: rgba(56, 81, 127, 0.2);
}

.budget-panel {
  margin-top: 12px;
}

.budget-panel-head {
  align-items: center;
  margin-bottom: 12px;
}

.budget-entry-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.48fr) minmax(0, 1.52fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
}

.budget-start-card,
.budget-records-panel {
  align-self: stretch;
}

.budget-records-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(246, 249, 252, 0.96), rgba(232, 239, 248, 0.9));
}

.budget-records-panel .budget-record-field {
  width: min(420px, 100%);
  margin-left: auto;
}

.budget-record-head {
  align-items: center;
}

.budget-record-summary {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  align-self: end;
  width: fit-content;
  max-width: min(100%, 520px);
  min-height: 32px;
  margin: 6px 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(169, 54, 65, 0.2);
  border-radius: 999px;
  padding: 5px 13px;
  color: var(--accent);
  background: rgba(255, 245, 246, 0.8);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.budget-record-table-wrap {
  align-self: start;
  width: 100%;
  height: 331px;
  max-height: 331px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(246, 249, 252, 0.92)),
    var(--surface-wash);
}

.budget-record-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  table-layout: fixed;
}

.budget-record-table th,
.budget-record-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
  font-size: var(--text-md);
}

.budget-record-table td {
  font-weight: var(--weight-medium);
}

.budget-record-table th:first-child,
.budget-record-table td:first-child {
  width: 25%;
  text-align: center;
  white-space: nowrap;
}

.budget-record-table th:nth-child(2),
.budget-record-table td:nth-child(2) {
  width: 9%;
}

.budget-record-table th:nth-child(3),
.budget-record-table td:nth-child(3),
.budget-record-table th:nth-child(4),
.budget-record-table td:nth-child(4),
.budget-record-table th:nth-child(5),
.budget-record-table td:nth-child(5) {
  width: 8.5%;
}

.budget-record-table th:nth-child(6),
.budget-record-table td:nth-child(6) {
  width: 8%;
}

.budget-record-table th:nth-child(7),
.budget-record-table td:nth-child(7) {
  width: 14%;
}

.budget-record-table th:last-child,
.budget-record-table td:last-child {
  width: 16%;
}

.budget-record-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--primary-strong);
  background: #e6ebf4;
  box-shadow: 0 1px 0 var(--line);
  font-weight: var(--weight-semibold);
}

.budget-record-summary.complete {
  color: #25613d;
  border-color: rgba(54, 138, 89, 0.26);
  background: rgba(236, 250, 241, 0.9);
}

.budget-record-table tr.active td {
  background: rgba(48, 69, 127, 0.08);
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.budget-record-table .empty-cell {
  height: 48px;
  vertical-align: middle;
}

.danger-text {
  color: var(--danger);
}

.record-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  white-space: nowrap;
}

.compact-button {
  min-height: 32px;
  min-width: 42px;
  padding: 5px 8px;
  font-size: var(--text-sm);
}

.danger-button {
  border: 1px solid rgba(215, 25, 32, 0.34);
  color: var(--danger);
  background: #fffafa;
}

.danger-button:hover {
  color: var(--danger);
  border-color: rgba(215, 25, 32, 0.52);
  background: #fff3f4;
}

.danger-button:active {
  color: #ffffff;
  border-color: var(--danger);
  background: var(--danger);
}

.budget-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.7fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 18px;
}

.budget-main-column {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.workflow-card {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(247, 250, 253, 0.96), rgba(232, 239, 248, 0.9));
}

.workflow-step {
  color: var(--text);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}

.budget-start-card {
  grid-template-rows: auto minmax(0, 1fr);
}

.budget-form {
  display: grid;
  grid-template-columns:
    minmax(108px, 0.8fr) minmax(108px, 0.8fr) minmax(132px, 1fr) minmax(100px, 0.75fr) minmax(220px, 1.65fr);
  grid-auto-rows: auto;
  align-content: start;
  gap: 12px 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(248, 250, 252, 0.86);
}

.budget-form .budget-class-field {
  grid-column: auto;
}

.budget-form button {
  grid-column: span 2;
}

.budget-start-card .budget-form {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  height: 100%;
  grid-template-rows: repeat(4, auto) minmax(0, 1fr) auto;
  align-content: stretch;
  gap: 9px 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

.budget-start-card .budget-form .field {
  grid-column: span 3;
}

.budget-start-card .budget-form .budget-class-field,
.budget-start-card .budget-form button {
  grid-column: 1 / -1;
}

.budget-start-card .budget-form button {
  min-height: 48px;
  grid-row: 6;
  align-self: end;
}

.budget-start-card .budget-form .field:nth-of-type(6),
.budget-start-card .budget-form .field:nth-of-type(7),
.budget-start-card .budget-form .field:nth-of-type(8) {
  grid-column: span 3;
}

.budget-start-card .budget-form .field:nth-of-type(8) {
  grid-column: 1 / -1;
}

.budget-main-column .category-budget-panel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.category-budget-panel>.empty-state {
  grid-column: 1 / -1;
}

.budget-side-panel {
  display: grid;
  grid-template-rows: auto auto;
  gap: 10px;
}

.budget-pool-card {
  display: grid;
  order: 2;
  gap: 10px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(238, 244, 255, 0.92));
}

.budget-pool-card h3 {
  color: var(--text);
  font-size: var(--text-lg);
  line-height: var(--leading-tight);
}

.budget-pool-card p {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.budget-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.budget-metrics {
  display: grid;
  order: 1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mini-metric {
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(237, 243, 255, 0.9));
}

.mini-metric:nth-child(n) {
  border-color: rgba(48, 69, 127, 0.24);
  background: linear-gradient(180deg, var(--card-blue-soft), var(--card-blue));
}

.mini-metric span {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.mini-metric strong {
  display: block;
  margin-top: 14px;
  color: var(--primary-strong);
  font-family: var(--number);
  font-size: var(--text-3xl);
}

.category-card.unset .progress-track span {
  background: var(--line-strong);
}

.inline-field {
  width: min(360px, 100%);
}

.allocation-list-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  margin-top: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(247, 250, 253, 0.96), rgba(232, 239, 248, 0.9));
}

.allocation-list-panel .panel-head {
  align-items: center;
  margin-bottom: 0;
}

.subtle-action {
  color: var(--muted);
}

.allocation-list-panel #printReportBtn {
  min-height: 42px;
  padding-block: 0;
}

.allocation-list-panel #saveAllBtn {
  min-height: 42px;
  padding-block: 0;
}

.allocation-list-panel .allocation-table-wrap {
  height: 400px;
  margin-top: 0;
}

.tab-button {
  min-height: 34px;
  padding: 0 12px;
}

.filter-clear-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--text);
  background: #ffffff;
  border-color: var(--line);
  box-shadow: none;
}

.filter-clear-button:hover {
  color: var(--primary-strong);
  background: linear-gradient(180deg, #ffffff, #e8eef8);
  border-color: rgba(48, 69, 127, 0.42);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(48, 69, 127, 0.32);
  border-radius: 6px;
  color: var(--text);
  background: rgba(248, 250, 252, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.danger {
  color: var(--danger) !important;
}

.hidden {
  display: none !important;
}

@keyframes boot {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1240px) {

  .workspace-grid,
  .budget-workspace,
  .import-workspace,
  .dashboard-grid,
  .dashboard-insight-grid,
  .dashboard-secondary-grid {
    grid-template-columns: 1fr;
  }

  .category-dashboard,
  .category-budget-panel,
  .report-cards,
  .breakdown-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .budget-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .allocation-workspace,
  .teaching-hours-workspace {
    grid-template-columns: 1fr;
  }

  .allocation-status-panel,
  .teaching-status-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: auto;
    height: auto;
  }

  .allocation-workspace-panel #categoryBudgetPanel {
    height: auto;
    grid-auto-rows: auto;
  }
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100vw - 16px, 1580px);
    margin: 8px auto 18px;
  }

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

  .hero-view-nav {
    justify-self: stretch;
    width: 100%;
    overflow-x: auto;
  }

  .panel-head,
  .budget-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .budget-record-summary {
    max-width: 100%;
    margin-left: 0;
    white-space: normal;
  }

  .allocation-status-panel,
  .teaching-status-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .budget-actions {
    grid-template-columns: 1fr;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .view-tab {
    flex: 1 0 132px;
  }

  .filter-grid,
  .budget-entry-grid,
  .import-summary-grid,
  .detail-grid,
  .budget-form,
  .budget-start-card .budget-form,
  .budget-metrics,
  .category-dashboard,
  .category-budget-panel,
  .report-cards,
  .allocation-check-grid,
  .breakdown-grid,
  .dashboard-secondary-grid {
    grid-template-columns: 1fr;
  }

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

  .budget-form .budget-class-field,
  .budget-start-card .budget-form .field,
  .budget-start-card .budget-form .budget-class-field,
  .budget-start-card .budget-form button,
  .budget-start-card .budget-form .field:nth-of-type(6),
  .budget-start-card .budget-form .field:nth-of-type(7),
  .budget-start-card .budget-form .field:nth-of-type(8),
  .budget-form button {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 30px;
  }

  .detail-title {
    font-size: 28px;
  }

  .sidebar-panel,
  .content-panel,
  .budget-panel,
  .import-panel,
  .dashboard-panel {
    padding: 12px;
  }
}

@media screen {
  .page-shell {
    width: min(1580px, calc(100vw - 28px));
    margin-top: 14px;
  }

  .hero,
  .dashboard-panel,
  .sidebar-panel,
  .content-panel,
  .budget-panel,
  .detail-panel,
  .allocation-breakdown-panel,
  .filter-stack,
  .budget-form,
  .budget-pool-card,
  .mini-metric,
  .category-card,
  .report-card,
  .mix-row,
  .teacher-load-row,
  .stem-shortcut,
  .attribute-row,
  .sdg-row,
  .course-card,
  .meta-block,
  .note-card {
    border-radius: 6px;
    background:
      linear-gradient(180deg, rgba(239, 245, 252, 0.96), rgba(220, 231, 244, 0.9)),
      var(--card-wash);
    box-shadow: none;
  }

  .allocation-table-wrap,
  .breakdown-table-wrap,
  .toast {
    border-radius: 6px;
    background: var(--surface-wash);
    box-shadow: none;
  }

  .hero,
  .dashboard-panel,
  .sidebar-panel,
  .content-panel,
  .budget-panel {
    border: 1px solid var(--line);
  }

  .hero::before,
  .dashboard-panel::before,
  .sidebar-panel::before,
  .content-panel::before,
  .budget-panel::before {
    content: none;
  }

  .hero {
    min-height: 132px;
    padding: 20px 24px;
    border-color: rgba(48, 69, 127, 0.24);
    background:
      linear-gradient(90deg, #eaf1fc 0%, #f8fafc 62%, #fff2f3 100%);
  }

  .hero h1 {
    color: var(--text);
    font-size: clamp(30px, 3.2vw, 44px);
    max-width: 18ch;
  }

  .eyebrow {
    color: var(--primary);
    font-family: var(--sans);
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
  }

  .hero-view-nav {
    align-self: center;
    margin-bottom: 0;
  }

  .view-tab {
    min-height: 44px;
    border-color: var(--line);
    color: #111827;
    background: linear-gradient(180deg, #ffffff, #f1f5fb);
    font-size: var(--text-md);
  }

  .view-tab.active,
  .tab-button.active,
  .budget-actions button:not(.ghost) {
    color: #ffffff;
    border-color: var(--primary);
    background: var(--primary);
  }

  .view-tab.active:hover,
  .tab-button.active:hover,
  .budget-actions button:not(.ghost):hover {
    background: var(--primary-strong);
  }

  .summary-strip {
    padding: 0;
    border: 0;
    background: transparent;
  }

  .summary-card {
    min-height: 108px;
  }

  .summary-card strong,
  .category-card-head strong,
  .report-card strong,
  .mix-row strong,
  .teacher-load-value,
  .distribution-value,
  .stem-shortcut strong,
  .mini-metric strong {
    color: var(--primary);
  }

  .dashboard-insight-grid .teacher-load-value,
  .dashboard-insight-grid .distribution-value,
  .dashboard-insight-grid .teacher-load-value strong,
  .dashboard-insight-grid .distribution-value strong {
    color: var(--accent);
  }

  .category-card.over,
  .stem-shortcut,
  .danger-badge {
    border-color: #efb2b5;
    background: #fffafa;
  }

  .stem-shortcut strong,
  .danger,
  .badge {
    color: var(--accent);
  }

  .dashboard-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
  }

  .dashboard-insight-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-panel,
  .sidebar-panel,
  .content-panel,
  .budget-panel {
    padding: 16px;
  }

  .panel-head {
    margin-bottom: 14px;
  }

  .panel-head h2 {
    color: var(--text);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
  }

  .panel-head p {
    color: var(--muted);
    font-size: var(--text-sm);
  }

  .category-dashboard,
  .category-budget-panel,
  .report-cards,
  .course-mix,
  .teacher-load-board,
  .teacher-load-list,
  .attribute-distribution,
  .sdg-distribution {
    gap: 10px;
  }

  .primary-dashboard .category-dashboard {
    grid-template-columns: 1fr;
  }

  .dashboard-stack {
    gap: 12px;
    grid-template-rows: auto auto;
  }

  .dashboard-grid>.dashboard-panel,
  .dashboard-grid .breakdown-panel {
    min-height: 0;
  }

  .primary-dashboard .category-dashboard,
  .dashboard-grid .course-mix {
    height: auto;
    align-content: start;
  }

  .primary-dashboard .category-dashboard {
    grid-auto-rows: 1fr;
  }

  .primary-dashboard .category-card {
    min-height: 78px;
  }

  .dashboard-grid .mix-row {
    min-height: 94px;
  }

  .primary-dashboard .progress-track {
    margin: 10px 0 8px;
  }

  .dashboard-grid .breakdown-table-wrap {
    max-height: none;
    border: 0;
    border-radius: 0;
    overflow: visible;
  }

  .dashboard-grid .breakdown-table {
    min-width: 620px;
  }

  .course-mix .mix-row {
    min-height: 78px;
  }

  .teacher-load-list,
  .attribute-distribution,
  .sdg-distribution {
    align-content: start;
  }

  .dashboard-insight-grid .teacher-load-row {
    min-height: 76px;
  }

  .dashboard-insight-grid .attribute-row {
    min-height: 76px;
  }

  .dashboard-insight-grid .sdg-row {
    min-height: 76px;
  }

  .category-card,
  .report-card,
  .mix-row,
  .stem-shortcut,
  .course-card,
  .meta-block,
  .note-card,
  .mini-metric {
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #ffffff, #f4f7fc);
  }

  .category-card:nth-child(n),
  .report-card:nth-child(n),
  .mix-row:nth-child(n),
  .mini-metric:nth-child(n) {
    border-color: rgba(48, 69, 127, 0.24);
    background: linear-gradient(180deg, var(--card-blue-soft), var(--card-blue));
  }

  .teacher-load-row:nth-child(n),
  .attribute-row:nth-child(n),
  .sdg-row:nth-child(n) {
    border-color: rgba(215, 25, 32, 0.24);
    background: linear-gradient(180deg, var(--card-red-soft), var(--card-red));
  }

  .attribute-row,
  .sdg-row,
  .teacher-load-row {
    min-height: 76px;
  }

  .teacher-load-bar,
  .attribute-bar,
  .sdg-bar {
    background: rgba(215, 25, 32, 0.24);
  }

  .progress-track {
    height: 7px;
    border-color: var(--line);
    background: #e8edf2;
  }

  .progress-track span {
    background: var(--primary);
  }

  .badge {
    border-color: #efb2b5;
    background: #fffafa;
  }

  .filter-stack,
  .detail-panel,
  .budget-form,
  .allocation-breakdown-panel {
    background: linear-gradient(180deg, #f8fbff, #fff7f8);
  }

  .budget-workspace {
    gap: 20px;
  }

  .budget-form {
    border-top: 3px solid var(--primary);
  }

  .mini-metric {
    min-height: 126px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .course-card {
    transition: border-color 120ms ease, box-shadow 120ms ease;
  }

  .course-card:hover,
  .course-card.active {
    transform: none;
  }

  .course-card.active {
    box-shadow: inset 4px 0 0 var(--primary);
  }

  .course-card.course-required.active {
    box-shadow: inset 4px 0 0 var(--accent);
  }

  .detail-panel {
    background: linear-gradient(180deg, #ffffff, #f8fbff);
  }

  .detail-panel.course-required {
    border-color: rgba(215, 25, 32, 0.22);
    background: linear-gradient(180deg, #fffafa, #fff1f2);
  }

  .detail-panel.course-elective {
    border-color: rgba(48, 69, 127, 0.22);
    background: linear-gradient(180deg, #f8fbff, #edf3ff);
  }

  .detail-title {
    color: var(--text);
  }

  .detail-section {
    border-top-color: var(--line);
  }

  .detail-section h3 {
    color: var(--primary);
  }

  .mini-table,
  .allocation-table-wrap,
  .breakdown-table-wrap {
    border-color: var(--line);
    background: #ffffff;
  }

  .mini-table th,
  .allocation-table th,
  .breakdown-table th {
    color: var(--primary);
    background: linear-gradient(180deg, #edf3ff, #e6ecf7);
    font-weight: var(--weight-semibold);
  }

  .mini-table td,
  .allocation-table td {
    color: #21312f;
  }

  .allocation-table tbody tr:hover {
    background: #f8f3f5;
  }

  .status-pill.clean,
  .status-pill.dirty,
  .status-pill.category,
  .course-no-pill,
  .course-class-pill,
  .detail-chip {
    background: #f1f5fb;
    border-color: var(--line);
  }

  .detail-chip.attribute-tag {
    color: var(--accent);
    background: #fffafa;
    border-color: #efb2b5;
  }

  .toast {
    background: #ffffff;
    border-color: var(--line-strong);
  }
}

@media screen and (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .dashboard-grid .breakdown-panel {
    grid-column: auto;
    align-self: auto;
  }
}

.hero {
  border-color: rgba(64, 86, 128, 0.54);
  background:
    radial-gradient(circle at 18% 0%, rgba(125, 151, 195, 0.22), transparent 36%),
    linear-gradient(135deg, var(--navy-deep) 0%, var(--navy) 58%, #263d66 100%);
  box-shadow: 0 2px 6px rgba(31, 52, 88, 0.12);
}

.hero::before {
  content: "";
  border-top-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), transparent 55%);
}

.hero .eyebrow {
  color: #d7e2f6;
}

.hero .eyebrow::before {
  color: #e95f68;
}

.hero h1 {
  color: #f9fbff;
  text-shadow: none;
}

.hero .view-tab {
  color: #eef4ff;
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.075);
}

.hero .view-tab:hover {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.13);
}

.hero .view-tab.active {
  color: var(--primary-strong);
  border-color: rgba(255, 255, 255, 0.84);
  background: #f8fbff;
}

.hero .import-tab {
  color: #ffecef;
  border-color: rgba(233, 95, 104, 0.5);
  background: rgba(201, 47, 58, 0.16);
}

.hero .import-tab:hover {
  border-color: rgba(255, 210, 216, 0.7);
  background: rgba(201, 47, 58, 0.24);
}

.mini-table th,
.allocation-table th,
.breakdown-table th,
.budget-record-table th {
  color: #f8fbff;
  background: linear-gradient(180deg, var(--navy-soft), var(--navy));
  border-bottom-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 1px 0 rgba(31, 52, 88, 0.18);
  font-weight: var(--weight-semibold);
}

.mini-table th+th,
.allocation-table th+th,
.breakdown-table th+th,
.budget-record-table th+th {
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.mini-table,
.allocation-table,
.breakdown-table,
.budget-record-table,
.import-preview-table {
  border-collapse: collapse;
  color: var(--text);
}

.mini-table th,
.mini-table td,
.allocation-table th,
.allocation-table td,
.breakdown-table th,
.breakdown-table td,
.budget-record-table th,
.budget-record-table td,
.import-preview-table th,
.import-preview-table td {
  height: 48px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: var(--text-md);
  line-height: 1.3;
}

.mini-table th,
.allocation-table th,
.breakdown-table th,
.budget-record-table th,
.import-preview-table th {
  height: 42px;
  padding-block: 9px;
  text-align: center;
  white-space: nowrap;
}

.mini-table td,
.allocation-table td,
.breakdown-table td,
.budget-record-table td,
.import-preview-table td {
  color: #263835;
  font-weight: var(--weight-medium);
}

.mini-table tbody tr:nth-child(even),
.allocation-table tbody tr:nth-child(even),
.breakdown-table tbody tr:nth-child(even),
.budget-record-table tbody tr:nth-child(even),
.import-preview-table tbody tr:nth-child(even) {
  background: rgba(248, 250, 252, 0.62);
}

.mini-table tbody tr:hover,
.allocation-table tbody tr:hover,
.breakdown-table tbody tr:hover,
.budget-record-table tbody tr:hover,
.import-preview-table tbody tr:hover {
  background: rgba(48, 69, 127, 0.055);
}

.allocation-table tbody tr.teaching-active,
.budget-record-table tr.active td {
  background: rgba(48, 69, 127, 0.09);
}

.mini-table tbody tr:last-child td,
.allocation-table tbody tr:last-child td,
.breakdown-table tbody tr:last-child td,
.budget-record-table tbody tr:last-child td,
.import-preview-table tbody tr:last-child td {
  border-bottom: 0;
}

.breakdown-table-wrap,
.allocation-table-wrap,
.budget-record-table-wrap,
.import-preview-table-wrap {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-wash);
}

.mini-table .empty-cell,
.allocation-table .empty-cell,
.breakdown-table .empty-cell,
.budget-record-table .empty-cell,
.import-preview-table .empty-cell,
.mini-table td[colspan],
.allocation-table td[colspan],
.breakdown-table td[colspan],
.budget-record-table td[colspan],
.import-preview-table td[colspan] {
  height: 56px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.dashboard-grid .breakdown-panel .breakdown-table th,
.dashboard-grid .breakdown-panel .breakdown-table td {
  height: auto;
  padding: 6px 12px;
  font-size: var(--text-md);
  line-height: 1.2;
}

.dashboard-grid .breakdown-panel .breakdown-table th {
  padding: 13px 12px 7px;
}

.dashboard-panel,
.sidebar-panel,
.content-panel,
.budget-panel,
.budget-records-panel,
.workflow-card,
.allocation-breakdown-panel,
.allocation-list-panel {
  padding: 16px;
}

.panel-head,
.budget-panel-head,
.budget-record-head,
.allocation-list-panel .panel-head {
  min-height: 34px;
  align-items: flex-start;
  margin: 0 0 14px;
}

.panel-head>div:not(.detail-tabs) {
  display: grid;
  align-content: start;
  gap: 4px;
}

.detail-panel-head .detail-tabs {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.detail-panel-head .tab-button {
  flex: 0 0 auto;
  min-width: 74px;
}

.panel-head h2 {
  margin: 0;
  line-height: 1.2;
}

.panel-head p {
  margin-top: 0;
}

.badge,
.budget-record-summary {
  align-self: start;
}

.budget-record-summary {
  margin: 0 0 0 auto;
}

.dashboard-grid .breakdown-panel .panel-head {
  margin-bottom: 6px;
}

@media print {
  body {
    background: white;
  }

  .hero,
  .view-nav,
  .summary-strip,
  .budget-workspace,
  .allocation-list-panel,
  .toast {
    display: none !important;
  }

  .page-shell {
    width: 100%;
    margin: 0;
  }

  .budget-panel,
  .report-panel,
  .dashboard-panel {
    border: 0;
    box-shadow: none;
  }

  .report-panel {
    margin-top: 0;
  }
}

@media screen and (max-width: 760px) {
  :root {
    --text-md: 15px;
    --text-lg: 17px;
    --text-xl: 19px;
    --text-2xl: 22px;
    --text-3xl: 28px;
  }

  body {
    background: #f4f7fb;
  }

  .auth-gate {
    place-items: start center;
    padding: 72px 12px 24px;
    background: #eef3f9;
    backdrop-filter: none;
  }

  .auth-panel {
    width: 100%;
    max-width: 360px;
    gap: 14px;
    padding: 20px;
    border-color: rgba(48, 69, 127, 0.18);
    box-shadow: 0 10px 34px rgba(31, 52, 88, 0.12);
  }

  .auth-panel h2 {
    font-size: 24px;
    line-height: 1.18;
  }

  .auth-panel button {
    min-height: 46px;
  }

  .page-shell {
    width: 100%;
    margin: 0;
  }

  .hero {
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
    border-width: 0 0 1px;
    border-radius: 0;
    box-shadow: none;
    background: linear-gradient(135deg, #1f3458 0%, #2d4774 100%) !important;
  }

  .hero h1 {
    max-width: none;
    color: #ffffff !important;
    font-size: 24px;
    line-height: 1.12;
  }

  .hero .eyebrow {
    margin-bottom: 6px;
    color: #dbe7fb !important;
    font-size: 13px;
  }

  .hero .eyebrow::before {
    color: #ff7a84 !important;
  }

  .app-footer {
    margin: 10px 0 0;
    border-radius: 0;
  }

  .app-footer .auth-line {
    min-height: 0;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    color: #eef4ff;
    font-size: 12px;
  }

  .app-footer .auth-line .compact-button {
    min-height: 30px;
    padding: 0 10px;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
  }

  .hero-view-nav {
    width: 100%;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    overflow: visible;
  }

  .view-tab {
    flex: none;
    width: 100%;
    min-height: 42px;
    min-width: 0;
    padding: 0 8px;
    font-size: 14px;
    color: #eef4ff !important;
    border-color: rgba(255, 255, 255, 0.22) !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border-radius: 6px;
  }

  .view-tab.active {
    color: var(--primary-strong) !important;
    border-color: rgba(255, 255, 255, 0.9) !important;
    background: #ffffff !important;
  }

  .app-layout,
  .view-panel {
    margin-top: 10px;
  }

  .app-layout {
    padding: 0 8px 18px;
  }

  .summary-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
    padding: 0 8px;
    overflow: visible;
  }

  .summary-card {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 72px;
    min-width: 0;
    padding: 9px 10px;
    background: #ffffff;
  }

  .summary-card.allocation-status {
    grid-column: 1 / -1;
    min-height: 56px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
  }

  .summary-card span,
  .summary-card small {
    overflow: hidden;
    font-size: 11px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .summary-card strong {
    margin-top: 3px;
    font-size: 25px;
    line-height: 1;
  }

  .summary-card.allocation-status strong {
    grid-column: 2;
    grid-row: 1 / 3;
    margin: 0 0 0 10px;
    font-size: 28px;
  }

  .summary-card.allocation-status small {
    align-self: start;
  }

  .dashboard-grid,
  .dashboard-insight-grid,
  .dashboard-secondary-grid,
  .workspace-grid,
  .budget-workspace,
  .budget-entry-grid,
  .import-workspace,
  .allocation-workspace,
  .teaching-hours-workspace,
  .detail-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .dashboard-grid .breakdown-panel,
  .teaching-hours-panel {
    grid-column: auto;
  }

  .dashboard-insight-grid>.dashboard-panel {
    height: auto;
    overflow: visible;
  }

  .dashboard-panel,
  .sidebar-panel,
  .content-panel,
  .budget-panel,
  .budget-records-panel,
  .workflow-card,
  .allocation-breakdown-panel,
  .allocation-list-panel,
  .teaching-hours-panel,
  .import-source-panel,
  .import-preview-panel,
  .detail-panel {
    padding: 12px;
    border-radius: 6px;
    background: #ffffff;
    box-shadow: none;
  }

  .dashboard-panel::before,
  .sidebar-panel::before,
  .content-panel::before,
  .budget-panel::before {
    content: none;
  }

  .panel-head,
  .budget-panel-head,
  .budget-record-head,
  .allocation-workspace-panel .panel-head,
  .teaching-hours-panel .panel-head {
    min-height: 0;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
  }

  .panel-head h2 {
    font-size: 18px;
  }

  .badge,
  .budget-record-summary,
  .allocation-summary {
    width: 100%;
    max-width: 100%;
    margin: 0;
    justify-content: flex-start;
    border-radius: 6px;
    white-space: normal;
  }

  .filter-stack,
  .budget-form,
  .workflow-card,
  .budget-records-panel,
  .import-source-panel,
  .import-preview-panel,
  .teaching-hours-panel,
  .allocation-breakdown-panel,
  .allocation-list-panel {
    background: #ffffff;
    box-shadow: none;
  }

  #coursesView .sidebar-panel {
    height: auto;
    max-height: none;
  }

  .filter-stack,
  .budget-form,
  .budget-start-card .budget-form {
    grid-template-columns: 1fr !important;
    height: auto;
    gap: 10px;
  }

  .filter-grid,
  .class-axis-grid,
  .tag-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .class-axis-grid .field:first-child {
    grid-column: 1 / -1 !important;
  }

  .filter-stack .field,
  .tag-filter-grid .field,
  .filter-grid .field:last-child:nth-child(odd),
  .budget-form .field,
  .budget-start-card .budget-form .field,
  .budget-form .budget-class-field,
  .budget-start-card .budget-form .budget-class-field,
  .budget-form button,
  .budget-start-card .budget-form button,
  .budget-start-card .budget-form .field:nth-of-type(n) {
    grid-column: auto !important;
  }

  .filter-stack > .field,
  .filter-grid .field:last-child:nth-child(odd),
  .tag-filter-grid .field {
    grid-column: 1 / -1 !important;
  }

  .filter-stack {
    gap: 8px;
    padding: 8px;
  }

  #coursesView .filter-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #coursesView .filter-stack > .field {
    grid-column: 1 / -1 !important;
  }

  #coursesView .filter-stack > .filter-grid {
    display: contents;
  }

  #coursesView .filter-stack .filter-grid .field,
  #coursesView .filter-stack .tag-filter-grid .field,
  #coursesView .class-axis-grid .field:first-child,
  #coursesView .filter-grid .field:last-child:nth-child(odd) {
    grid-column: auto !important;
  }

  .field span {
    margin-bottom: 4px;
    font-size: 13px;
  }

  input,
  select,
  textarea,
  .filter-stack input,
  .filter-stack select {
    min-height: 42px;
    padding-block: 6px;
    font-size: 15px;
  }

  .course-list {
    max-height: 252px;
    overflow: auto;
    padding-right: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px;
    background: #ffffff;
  }

  #coursesView .sidebar-panel>.panel-head.compact {
    position: sticky;
    top: 0;
    z-index: 3;
    margin: 12px -12px 8px;
    padding: 10px 12px;
    border-block: 1px solid var(--line);
    background: #f4f7fb;
  }

  #coursesView .sidebar-panel>.panel-head.compact h2 {
    font-size: 18px;
  }

  .course-card {
    padding: 11px;
    background: #ffffff;
  }

  .course-card h3 {
    margin-top: 8px;
    font-size: 16px;
  }

  .course-card-bottom {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
  }

  .detail-title {
    margin-top: 10px;
    font-size: 24px;
    line-height: 1.18;
  }

  .detail-subtitle {
    font-size: 15px;
  }

  .detail-tabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .detail-panel-head .tab-button {
    min-width: 82px;
  }

  .detail-chip-row,
  .detail-topline {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .meta-grid,
  .category-dashboard,
  .category-budget-panel,
  .report-cards,
  .import-summary-grid,
  .allocation-check-grid,
  .breakdown-grid,
  .budget-metrics,
  .course-mix,
  .dashboard-grid .course-mix,
  .budget-main-column .category-budget-panel,
  .allocation-status-panel,
  .teaching-status-panel {
    grid-template-columns: 1fr !important;
  }

  .detail-panel .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .detail-panel .meta-grid .meta-block:first-child {
    grid-column: auto;
  }

  .detail-panel .meta-block {
    min-height: 92px;
    padding: 10px;
  }

  .detail-panel .meta-block label {
    font-size: 12px;
  }

  .detail-panel .meta-block strong {
    font-size: 17px;
    line-height: 1.25;
  }

  .primary-dashboard .category-dashboard,
  .course-mix-panel .course-mix {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .primary-dashboard .category-card,
  .course-mix-panel .mix-row {
    min-height: 96px;
    align-content: center;
    justify-items: center;
    text-align: center;
  }

  .primary-dashboard .category-card-head,
  .primary-dashboard .category-card-foot,
  .course-mix-panel .mix-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .primary-dashboard .category-card-head strong,
  .course-mix-panel .mix-row strong {
    font-size: 24px;
  }

  .primary-dashboard .category-card-foot small,
  .course-mix-panel .mix-row small {
    justify-self: center;
    font-size: 12px;
    line-height: 1.25;
    white-space: normal;
  }

  .primary-dashboard .progress-track {
    width: 100%;
    margin: 6px 0;
  }

  .meta-block {
    min-height: 64px;
  }

  .category-card,
  .report-card,
  .mix-row,
  .mini-metric,
  .teacher-load-row,
  .attribute-row,
  .sdg-row,
  .allocation-workspace-panel .category-card,
  .teaching-status-panel .mini-metric {
    min-height: 0;
    padding: 12px;
    background: #ffffff;
  }

  .allocation-workspace-panel #categoryBudgetPanel {
    height: auto;
    grid-auto-rows: auto;
  }

  .allocation-workspace-panel .category-card-head strong,
  .teaching-status-panel .teaching-value-card strong {
    font-size: 26px;
  }

  .allocation-workspace-panel .category-card-foot {
    grid-template-columns: 1fr;
  }

  .allocation-workspace-panel .category-card-foot small,
  .allocation-workspace-panel .category-card-foot small:last-child {
    justify-self: start;
    white-space: normal;
  }

  .budget-record-table-wrap,
  .allocation-workspace-panel .allocation-table-wrap,
  .teaching-table-wrap,
  .import-preview-table-wrap {
    height: auto;
    max-height: none;
  }

  .breakdown-table-wrap,
  .allocation-table-wrap,
  .budget-record-table-wrap,
  .import-preview-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #dashboardBreakdown .breakdown-table-wrap {
    overflow: hidden;
  }

  #dashboardBreakdown .breakdown-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  #dashboardBreakdown .breakdown-table th,
  #dashboardBreakdown .breakdown-table td,
  .dashboard-grid .breakdown-panel .breakdown-table th,
  .dashboard-grid .breakdown-panel .breakdown-table td {
    height: auto;
    padding: 8px 5px;
    font-size: 13px;
    line-height: 1.15;
    white-space: normal;
    word-break: keep-all;
  }

  #dashboardBreakdown .breakdown-table td strong {
    font-size: 15px;
  }

  #dashboardBreakdown .breakdown-table th:first-child,
  #dashboardBreakdown .breakdown-table td:first-child {
    width: 22%;
  }

  #dashboardBreakdown .breakdown-table th:nth-child(2),
  #dashboardBreakdown .breakdown-table td:nth-child(2),
  #dashboardBreakdown .breakdown-table th:nth-child(3),
  #dashboardBreakdown .breakdown-table td:nth-child(3) {
    width: 15%;
  }

  #dashboardBreakdown .breakdown-table th:nth-child(4),
  #dashboardBreakdown .breakdown-table td:nth-child(4),
  #dashboardBreakdown .breakdown-table th:nth-child(5),
  #dashboardBreakdown .breakdown-table td:nth-child(5),
  #dashboardBreakdown .breakdown-table th:nth-child(6),
  #dashboardBreakdown .breakdown-table td:nth-child(6) {
    width: 16%;
  }

  .breakdown-table {
    min-width: 560px;
  }

  .mini-table {
    min-width: 520px;
  }

  .detail-section:has(.mini-table) {
    overflow-x: auto;
  }

  .allocation-table,
  .budget-record-table {
    min-width: 0;
    width: 100%;
  }

  .allocation-table thead,
  .budget-record-table thead {
    display: none;
  }

  .allocation-table,
  .allocation-table tbody,
  .allocation-table tr,
  .allocation-table td,
  .budget-record-table,
  .budget-record-table tbody,
  .budget-record-table tr,
  .budget-record-table td {
    display: block;
  }

  .allocation-table tbody,
  .budget-record-table tbody {
    display: grid;
    gap: 10px;
  }

  .allocation-table tr,
  .budget-record-table tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    box-shadow: none;
  }

  .allocation-table td,
  .budget-record-table td {
    display: grid;
    grid-template-columns: minmax(96px, 0.42fr) minmax(0, 1fr);
    gap: 8px;
    min-height: 0;
    height: auto;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left !important;
    white-space: normal;
    align-items: start;
  }

  .allocation-table td::before,
  .budget-record-table td::before {
    color: var(--muted);
    font-size: 12px;
    font-weight: var(--weight-semibold);
  }

  .allocation-table td:nth-child(1)::before { content: "選課號"; }
  .allocation-table td:nth-child(2)::before { content: "課程 / 範圍"; }
  .allocation-table td:nth-child(3)::before { content: "屬性"; }
  .allocation-table td:nth-child(4)::before { content: "原學分"; }
  .allocation-table td:nth-child(5)::before { content: "分配"; }
  .allocation-table td:nth-child(6)::before { content: "備註"; }
  .allocation-table td:nth-child(7)::before { content: "狀態"; }

  .budget-record-table td:nth-child(1)::before { content: "範圍"; }
  .budget-record-table td:nth-child(2)::before { content: "學期"; }
  .budget-record-table td:nth-child(3)::before { content: "課程數"; }
  .budget-record-table td:nth-child(4)::before { content: "總學分"; }
  .budget-record-table td:nth-child(5)::before { content: "已分配"; }
  .budget-record-table td:nth-child(6)::before { content: "剩餘"; }
  .budget-record-table td:nth-child(7)::before { content: "最後分配"; }
  .budget-record-table td:nth-child(8)::before { content: "操作"; }

  .record-actions,
  .allocation-workspace-panel .allocation-breakdown-actions,
  .teaching-hours-actions,
  .import-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .record-actions button,
  .allocation-workspace-panel .allocation-breakdown-actions button,
  .teaching-hours-actions button,
  .import-actions button {
    width: 100%;
  }

  .allocation-input,
  .allocation-select,
  .allocation-note {
    width: 100%;
  }

  body[data-active-view="budget"] .summary-strip {
    display: none;
  }

  body[data-active-view="budget"] .app-layout {
    margin-top: 0;
    padding: 0 8px 14px;
  }

  #budgetView {
    padding: 10px;
    border-color: rgba(48, 69, 127, 0.16);
    background: #ffffff;
  }

  #budgetView .budget-panel-head {
    display: block;
    margin: 0 0 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }

  #budgetView .budget-panel-head h2 {
    font-size: 20px;
    line-height: 1.2;
  }

  #budgetView .budget-panel-head p {
    margin-top: 4px;
    color: #526477;
    font-size: 13px;
    line-height: 1.35;
  }

  #budgetView .budget-entry-grid {
    gap: 10px;
    margin-bottom: 0;
  }

  #budgetView .workflow-card,
  #budgetView .budget-records-panel,
  #budgetView .allocation-workspace-panel,
  #budgetView .teaching-hours-panel {
    padding: 10px;
    border-color: rgba(48, 69, 127, 0.18);
    background: #ffffff;
  }

  #budgetView .budget-start-card {
    gap: 8px;
  }

  #budgetView .workflow-step {
    font-size: 19px;
  }

  #budgetView .budget-start-card .budget-form {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
    height: auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
  }

  #budgetView .budget-start-card .budget-form .field {
    grid-column: auto !important;
    min-width: 0;
  }

  #budgetView .budget-start-card .budget-form .budget-class-field,
  #budgetView .budget-start-card .budget-form button {
    grid-column: 1 / -1 !important;
  }

  #budgetView .budget-start-card .budget-form .field span {
    font-size: 12px;
  }

  #budgetView .budget-start-card .budget-form input,
  #budgetView .budget-start-card .budget-form select {
    min-height: 40px;
    padding-inline: 10px;
    font-size: 15px;
  }

  #budgetView .budget-start-card .budget-form button {
    min-height: 42px;
    margin-top: 2px;
    font-size: 15px;
  }

  #budgetView .budget-record-head,
  #budgetView .allocation-workspace-panel .panel-head,
  #budgetView .teaching-hours-panel .panel-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    margin-bottom: 8px;
  }

  #budgetView .budget-record-summary,
  #budgetView .allocation-summary {
    min-height: 30px;
    padding: 5px 9px;
    border-radius: 6px;
    font-size: 12px;
  }

  #budgetView .budget-record-table-wrap,
  #budgetView .allocation-workspace-panel .allocation-table-wrap,
  #budgetView .teaching-table-wrap {
    max-height: min(46vh, 420px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  #budgetView .budget-record-table,
  #budgetView .allocation-table {
    table-layout: auto;
  }

  #budgetView .budget-record-table tr,
  #budgetView .allocation-table tr {
    width: 100%;
  }

  #budgetView .budget-record-table th,
  #budgetView .budget-record-table td,
  #budgetView .allocation-table th,
  #budgetView .allocation-table td {
    width: auto !important;
    white-space: normal;
  }

  #budgetView .budget-record-table td,
  #budgetView .allocation-table td {
    grid-template-columns: 58px minmax(0, 1fr);
    align-items: center;
  }

  #budgetView .allocation-table td:nth-child(2) .detail-note {
    white-space: nowrap;
  }

  #budgetView .allocation-status-panel {
    padding: 0;
    border: 0;
    background: transparent;
  }

  #budgetView .allocation-workspace-panel #categoryBudgetPanel {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 6px;
    height: auto;
  }

  #budgetView .allocation-workspace-panel .category-card {
    min-height: 58px;
    grid-template-rows: auto auto auto;
    gap: 5px;
    padding: 8px 10px 8px 13px;
  }

  #budgetView .allocation-workspace-panel .category-card::before {
    width: 4px;
  }

  #budgetView .allocation-workspace-panel .category-card-head {
    align-items: center;
    gap: 8px;
  }

  #budgetView .allocation-workspace-panel .category-card-head span {
    font-size: 14px;
    line-height: 1.15;
  }

  #budgetView .allocation-workspace-panel .category-card-head strong {
    font-size: 22px;
    line-height: 1;
  }

  #budgetView .allocation-workspace-panel .progress-track {
    height: 5px;
    margin: 0;
  }

  #budgetView .allocation-workspace-panel .category-card-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }

  #budgetView .allocation-workspace-panel .category-card-foot small,
  #budgetView .allocation-workspace-panel .category-card-foot small:last-child {
    min-height: 19px;
    padding: 1px 6px;
    font-size: 11px;
    line-height: 1.15;
  }

  #budgetView .teaching-hours-workspace {
    gap: 10px;
  }

  #budgetView .teaching-status-panel {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }

  #budgetView .teaching-table-wrap {
    max-height: min(46vh, 420px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
  }

  #budgetView .teaching-hours-table {
    display: block;
    width: 100%;
    min-width: 0;
    table-layout: auto;
  }

  #budgetView .teaching-hours-table thead {
    display: none;
  }

  #budgetView .teaching-hours-table tbody {
    display: grid;
    gap: 8px;
    padding: 8px;
  }

  #budgetView .teaching-hours-table tr {
    display: grid;
    grid-template-columns: minmax(110px, 0.74fr) minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    height: auto;
    padding: 9px;
    border: 1px solid rgba(48, 69, 127, 0.18);
    border-radius: 6px;
    background: #f8fafc;
  }

  #budgetView .teaching-hours-table td {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    min-height: 0;
    height: auto;
    padding: 0;
    border: 0;
    text-align: left !important;
    white-space: normal;
    width: auto !important;
  }

  #budgetView .teaching-hours-table td:nth-child(1) {
    display: none;
  }

  #budgetView .teaching-hours-table td:nth-child(2),
  #budgetView .teaching-hours-table td:nth-child(5),
  #budgetView .teaching-hours-table td:nth-child(6) {
    grid-column: 1 / -1;
  }

  #budgetView .teaching-hours-table td::before {
    color: var(--muted);
    font-size: 11px;
    font-weight: var(--weight-semibold);
    line-height: 1.1;
  }

  #budgetView .teaching-hours-table td:nth-child(2)::before { content: "授課教師"; }
  #budgetView .teaching-hours-table td:nth-child(3)::before { content: "授課時數"; }
  #budgetView .teaching-hours-table td:nth-child(4)::before { content: "回推學分"; }
  #budgetView .teaching-hours-table td:nth-child(5)::before { content: "備註"; }
  #budgetView .teaching-hours-table td:nth-child(6)::before { content: "操作"; }

  #budgetView .teaching-hours-table select,
  #budgetView .teaching-hours-table input {
    width: 100%;
    min-height: 36px;
    font-size: 14px;
    text-align: left;
  }

  #budgetView .teaching-hours-input {
    max-width: none;
    min-width: 0;
    text-align: left;
  }

  #budgetView .teaching-credit-cell {
    min-height: 36px;
    align-content: center;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    font-family: var(--number);
    font-weight: var(--weight-bold);
  }

  .teaching-hours-table,
  .import-preview-table {
    min-width: 760px;
  }

  .toast {
    right: 10px;
    bottom: 10px;
    left: 10px;
    max-width: none;
  }

  .dashboard-insight-grid .mobile-collapsible {
    padding: 0;
    overflow: hidden;
    border-color: rgba(48, 69, 127, 0.18);
    background: #ffffff;
  }

  .dashboard-insight-grid .mobile-collapsible .panel-head {
    position: relative;
    min-height: 54px;
    margin: 0;
    padding: 0 12px 0 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    cursor: pointer;
    background: linear-gradient(180deg, #ffffff, #f6f9fd);
  }

  .dashboard-insight-grid .mobile-collapsible .panel-head::before {
    content: "";
    position: absolute;
    inset: 10px auto 10px 0;
    width: 4px;
    border-radius: 0 999px 999px 0;
    background: var(--primary);
  }

  .dashboard-insight-grid .mobile-collapsible:nth-child(2) .panel-head::before {
    background: #2f7f95;
  }

  .dashboard-insight-grid .mobile-collapsible:nth-child(3) .panel-head::before {
    background: var(--accent);
  }

  .dashboard-insight-grid .mobile-collapsible .panel-head h2 {
    color: var(--text);
    font-size: 18px;
    line-height: 1.2;
  }

  .dashboard-insight-grid .mobile-collapsible .panel-head::after {
    content: "展開";
    align-self: center;
    justify-self: end;
    min-width: 48px;
    padding: 4px 10px;
    border: 1px solid rgba(48, 69, 127, 0.18);
    border-radius: 999px;
    color: var(--primary-strong);
    background: #edf3ff;
    font-size: 12px;
    font-weight: var(--weight-semibold);
    line-height: 1;
    text-align: center;
  }

  .dashboard-insight-grid .mobile-collapsible.mobile-open .panel-head::after {
    content: "收合";
  }

  .dashboard-insight-grid .mobile-collapsible > :not(.panel-head) {
    display: none;
  }

  .dashboard-insight-grid .mobile-collapsible.mobile-open > :not(.panel-head) {
    display: grid;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--line);
  }
}

@media screen and (max-width: 420px) {
  .hero-view-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-layout {
    padding-inline: 6px;
  }

  .allocation-table td,
  .budget-record-table td {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  #budgetView .allocation-table td,
  #budgetView .budget-record-table td {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 8px;
  }
}
