:root {
  --paper: #fbfaf7;
  --sidebar: #f0ede6;
  --surface: #ffffff;
  --ink: #1b2430;
  --muted: #6d7681;
  --faint: #9aa1a9;
  --line: #e3ded5;
  --line-soft: #efece5;
  --blue: #3d7fc1;
  --blue-dark: #2f66a0;
  --red: #b4432f;
  --amber: #b98b2a;
  --radius: 4px;
  --control-height: 42px;
  --control-radius: 6px;
  --control-border: #d7dce2;
  --control-border-hover: #b8c0ca;
  --control-focus-ring: rgba(61,127,193,.14);
  --control-error-ring: rgba(180,67,47,.12);
  --control-disabled: #f2f1ed;
  --control-readonly: #f7f6f2;
  font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); -webkit-font-smoothing: antialiased; }
.error-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.error-card { width: min(100%, 520px); padding: 42px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 18px 55px rgba(27,36,48,.08); text-align: center; }
.error-code { margin: 0; color: var(--primary); font-size: 13px; font-weight: 800; letter-spacing: .16em; }
.error-card h1 { margin: 10px 0; color: var(--navy); font-family: var(--serif); }
.error-card > p:not(.error-code) { margin: 0 0 24px; color: var(--muted); }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { outline-offset: 3px; }
:focus-visible { outline: 2px solid var(--blue); }

:where(
  input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
  select,
  textarea
) {
  width: 100%;
  min-height: var(--control-height);
  padding: 9px 12px;
  border: 1px solid var(--control-border);
  border-radius: var(--control-radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(27,36,48,.035);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

:where(
  input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
  select,
  textarea
):hover:not(:disabled):not([readonly]) {
  border-color: var(--control-border-hover);
}

:where(
  input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
  select,
  textarea
):focus-visible {
  border-color: var(--blue);
  outline: 0;
  box-shadow: 0 0 0 3px var(--control-focus-ring);
}

:where(input, select, textarea):disabled {
  border-color: var(--line);
  background: var(--control-disabled);
  color: var(--faint);
  box-shadow: none;
  cursor: not-allowed;
}

:where(input:read-only[readonly], textarea:read-only[readonly]) {
  background: var(--control-readonly);
  box-shadow: none;
}

:where(input, select, textarea)[aria-invalid="true"] { border-color: var(--red); }
:where(input, select, textarea)[aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 3px var(--control-error-ring); }
::placeholder { color: var(--faint); opacity: 1; }
textarea { min-height: 96px; line-height: 1.65; resize: vertical; }
select {
  appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

input[type="checkbox"], input[type="radio"] {
  appearance: none;
  display: inline-grid;
  width: 18px;
  height: 18px;
  min-height: 18px;
  flex: 0 0 18px;
  margin: 0;
  padding: 0;
  place-content: center;
  border: 1px solid var(--control-border-hover);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
input[type="checkbox"] { border-radius: 4px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::before {
  width: 8px;
  height: 4px;
  border-bottom: 2px solid #fff;
  border-left: 2px solid #fff;
  content: "";
  opacity: 0;
  transform: translateY(-1px) rotate(-45deg) scale(.7);
  transition: opacity .12s ease, transform .12s ease;
}
input[type="radio"]::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  content: "";
  opacity: 0;
  transform: scale(.5);
  transition: opacity .12s ease, transform .12s ease;
}
input[type="checkbox"]:checked,
input[type="checkbox"]:indeterminate,
input[type="radio"]:checked { border-color: var(--blue); background: var(--blue); }
input[type="checkbox"]:checked::before,
input[type="checkbox"]:indeterminate::before,
input[type="radio"]:checked::before { opacity: 1; transform: translateY(-1px) rotate(-45deg) scale(1); }
input[type="radio"]:checked::before { transform: scale(1); }
input[type="checkbox"]:indeterminate::before {
  width: 8px;
  height: 0;
  border-left: 0;
  transform: none;
}
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--control-focus-ring); }
input[type="checkbox"]:disabled,
input[type="radio"]:disabled { border-color: var(--line); background: var(--control-disabled); cursor: not-allowed; }
input[type="checkbox"]:checked:disabled,
input[type="checkbox"]:indeterminate:disabled,
input[type="radio"]:checked:disabled { border-color: #a9c1d8; background: #a9c1d8; }

input[type="file"] { padding: 5px 6px; }
input[type="file"]::file-selector-button {
  min-height: 30px;
  margin-right: 10px;
  padding: 5px 11px;
  border: 0;
  border-radius: 4px;
  background: rgba(61,127,193,.10);
  color: var(--blue-dark);
  cursor: pointer;
}
input[type="file"]:disabled::file-selector-button { color: var(--faint); cursor: not-allowed; }

.skip-link { position: fixed; left: 16px; top: -60px; z-index: 100; padding: 10px 14px; background: var(--ink); color: #fff; }
.skip-link:focus { top: 12px; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: 252px; flex-direction: column; overflow: hidden; border-right: 1px solid #ded8cd; background: var(--sidebar); }
.brand { padding: 22px 22px 18px; border-bottom: 1px solid #eeeae2; }
.brand__title { font-family: "Noto Serif SC", "SimSun", serif; font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.brand__meta { margin-top: 5px; color: #7d8590; font-size: 11.5px; letter-spacing: .3px; }
.navigation { display: flex; flex: 1; flex-direction: column; gap: 18px; overflow-y: auto; padding: 20px 16px; }
.navigation__group { display: grid; gap: 3px; }
.navigation__label { margin: 0 6px 9px; color: var(--faint); font-size: 10.5px; letter-spacing: 1.4px; }
.navigation__empty { padding: 9px 12px; color: var(--faint); font-size: 12px; }
.nav-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 12px; border-radius: 3px; color: var(--muted); font-size: 13px; }
.nav-item:hover { background: rgba(61,127,193,.06); text-decoration: none; }
.nav-item--active { background: rgba(61,127,193,.10); color: var(--blue); font-weight: 500; }
.nav-item__dot { width: 5px; height: 5px; flex: 0 0 5px; opacity: .35; }
.nav-item--active .nav-item__dot { opacity: 1; }
.sidebar-user { display: flex; flex-direction: column; gap: 4px; padding: 16px 22px 20px; border-top: 1px solid #eeeae2; color: var(--muted); font-size: 11.5px; }
.sidebar-user strong { color: var(--ink); font-size: 13px; font-weight: 500; }
.sidebar-user__actions { display: flex; align-items: center; gap: 12px; margin-top: 5px; }
.sidebar-user__actions a, .sidebar-user__actions button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 11px; padding: 0; }
.main { min-width: 0; flex: 1; margin-left: 252px; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 84px; padding: 18px 36px; border-bottom: 1px solid var(--line); background: rgba(251,250,247,.94); backdrop-filter: blur(8px); }
.topbar h1 { margin: 3px 0 0; font-family: "Noto Serif SC", "SimSun", serif; font-size: 22px; letter-spacing: .4px; }
.breadcrumb { color: var(--muted); font-size: 11.5px; letter-spacing: .6px; }
.topbar__status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.page-content { width: min(100%, 1240px); padding: 28px 36px 64px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 24px 26px; }
.card h2 { margin: 0 0 6px; font-family: "Noto Serif SC", "SimSun", serif; font-size: 15px; }
.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.message { padding: 10px 12px; border-left: 3px solid var(--blue); background: rgba(61,127,193,.08); color: var(--ink); font-size: 12px; }
.message--error { border-left-color: var(--red); background: rgba(180,67,47,.08); color: var(--red); }
.empty-state { max-width: 620px; }
.empty-state p { color: var(--muted); font-size: 13px; }
.eyebrow { margin: 0 0 5px !important; color: var(--blue) !important; font-size: 11px !important; letter-spacing: 1.2px; }
.chip { display: inline-block; padding: 3px 9px; border-radius: 2px; font-size: 11px; white-space: nowrap; }
.chip--blue { background: rgba(61,127,193,.1); color: var(--blue); }
.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; padding: 8px 16px; border: 1px solid var(--line); border-radius: 3px; background: #fff; color: var(--ink); cursor: pointer; }
.button--primary { border-color: var(--ink); background: var(--ink); color: #f5f3ef; }
.button--primary:hover { background: #2b3947; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.field--check { flex-direction: row; align-items: center; gap: 9px; }
.field--check input { width: 18px; padding: 0; }
.field__help { color: var(--faint); font-size: 11px; line-height: 1.6; }
.field__help ul { margin: 4px 0; padding-left: 18px; }
.field__error { color: var(--red); font-size: 11.5px; }
.form-card { max-width: 620px; }
.split-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-heading p, .muted { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.button--outline { border-color: var(--blue); color: var(--blue); }
.import-guide ol { margin: 16px 0 0; padding-left: 20px; color: var(--muted); font-size: 12.5px; line-height: 2; }
.section-spaced { margin-top: 20px; }
.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; }
.data-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 12.5px; }
.data-table th { padding: 9px 10px; border-bottom: 1px solid var(--ink); color: var(--muted); font-size: 11.5px; font-weight: 500; text-align: left; white-space: nowrap; }
.data-table td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); }
.data-table td small { display: block; margin-top: 3px; color: var(--muted); font-size: 10.5px; }
.table-empty { color: var(--faint); text-align: center; }
.eyebrow--error { color: var(--red) !important; }
.issue-list { display: grid; gap: 8px; margin: 16px 0; }
.issue-item { padding: 10px 12px; border-left: 2px solid var(--red); background: rgba(180,67,47,.05); }
.issue-item strong, .issue-item span { display: block; font-size: 12px; }
.issue-item span { margin-top: 3px; color: var(--muted); }
.issue-item p { margin: 5px 0 0; color: var(--red); font-size: 11.5px; }
.stats-grid { display: grid; gap: 14px; }
.stats-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-grid--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card { min-width: 0; padding: 19px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.stat-card > span { display: block; color: var(--muted); font-size: 11.5px; }
.stat-card strong { display: block; margin: 12px 0 8px; font-family: "Noto Serif SC", "SimSun", serif; font-size: 30px; line-height: 1; font-weight: 500; }
.stat-card strong.stat-card__text { overflow: hidden; font-family: inherit; font-size: 17px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.stat-card small { color: var(--muted); font-size: 11.5px; }
.compact-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.compact-row small { color: var(--muted); }
.organization-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
.organization-layout > *, .split-layout > * { min-width: 0; }
.tree-list { display: grid; gap: 18px; margin-top: 18px; }
.tree-group__heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tree-group__heading strong { font-size: 13px; font-weight: 500; }
.tree-group__heading span { color: var(--faint); font-size: 10.5px; }
.tree-children { display: grid; gap: 3px; margin-top: 7px; padding-left: 10px; border-left: 1px solid var(--line); }
.tree-link { padding: 7px 9px; border-radius: 3px; color: var(--muted); font-size: 12px; }
.tree-link:hover, .tree-link--active { background: rgba(61,127,193,.08); color: var(--blue); text-decoration: none; }
.tree-card-heading, .tree-row, .tree-row__actions { display: flex; align-items: center; gap: 8px; }
.tree-card-heading, .tree-row { justify-content: space-between; }
.tree-card-heading { flex-wrap: wrap; }
.tree-card-heading h2 { margin-bottom: 0; }
.tree-card-heading__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tree-filter { margin-top: 12px; color: var(--muted); font-size: 12px; }
.tree-filter label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.tree-group__identity { display: grid; min-width: 0; gap: 3px; }
.tree-child-row { min-width: 0; }
.tree-child-row .tree-link { min-width: 0; flex: 1; }
.tree-row__actions { flex: 0 0 auto; opacity: 0; transition: opacity .15s ease; }
.tree-row__actions form { display: inline-flex; margin: 0; }
.tree-row:hover > .tree-row__actions, .tree-row:focus-within > .tree-row__actions { opacity: 1; }
.tree-row--inactive { opacity: .58; }
.tree-empty { padding: 7px 9px; color: var(--faint); font-size: 11.5px; }
.tree-action { min-height: 28px; padding: 4px 6px; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 10.5px; white-space: nowrap; }
.tree-action:hover { color: var(--blue-dark); text-decoration: underline; }
.tree-action--danger { color: var(--red); }
.button--small { min-height: 30px; padding: 5px 9px; font-size: 11px; }
.button--text { border: 0; background: transparent; color: var(--blue); }
.foundation-tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.foundation-tabs a { padding: 10px 15px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 12.5px; }
.foundation-tabs a:hover, .foundation-tabs a.active { border-bottom-color: var(--blue); color: var(--blue); text-decoration: none; }
.foundation-panel { min-width: 0; }
.foundation-list, .grade-list { display: grid; gap: 7px; }
.foundation-item { display: flex; min-width: 0; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 3px; background: #fbfaf7; }
.foundation-item__content { display: grid; min-width: 0; flex: 1; gap: 3px; }
.foundation-item__content strong { overflow: hidden; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.foundation-item__content small, .stage-card__heading small { color: var(--muted); font-size: 10.5px; }
.foundation-item__actions { display: flex; flex: 0 0 auto; align-items: center; gap: 3px; }
.foundation-item__actions form { display: inline-flex; margin: 0; }
.foundation-item--inactive { opacity: .55; }
.order-handle { width: 30px; min-height: 30px; flex: 0 0 30px; border: 0; background: transparent; color: var(--faint); cursor: grab; font-size: 19px; }
.order-handle:active { cursor: grabbing; }
.foundation-item--chosen, .stage-card.foundation-item--chosen { border-color: var(--blue); box-shadow: 0 4px 12px rgba(35, 112, 184, .12); }
.foundation-item--dragging, .stage-card.foundation-item--dragging { border-color: var(--blue); opacity: .45; }
.foundation-list--saving { pointer-events: none; }
.stage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stage-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 3px; background: #fbfaf7; }
.stage-card__heading { display: flex; min-width: 0; align-items: center; gap: 9px; margin-bottom: 13px; }
.stage-card__heading > div:nth-child(2) { display: grid; min-width: 0; flex: 1; gap: 3px; }
.stage-card__heading strong { font-size: 13px; font-weight: 500; }
.rotation-preview { margin: 12px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.staffing-term-filter, .staffing-generate-form { display: flex; align-items: end; gap: 12px; }
.staffing-term-filter .field, .staffing-generate-form .field { min-width: min(100%, 360px); margin: 0; }
.staffing-term-filter select, .staffing-generate-form select { width: 100%; }
.staffing-force { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.staffing-issue-filter { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.staffing-teacher-list { display: grid; gap: 8px; }
.staffing-teacher-card { display: grid; grid-template-columns: minmax(150px, .7fr) minmax(280px, 2fr) auto; align-items: center; gap: 16px; padding: 13px 14px; border: 1px solid var(--line-soft); border-radius: 3px; background: #fbfaf7; }
.staffing-teacher-card__identity { display: grid; min-width: 0; gap: 3px; }
.staffing-teacher-card__identity strong { font-size: 13px; font-weight: 500; }
.staffing-teacher-card__identity span { color: var(--muted); font-size: 11px; }
.staffing-tags { display: flex; min-width: 0; flex-wrap: wrap; gap: 6px; }
.staffing-tag { display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 11.5px; }
.staffing-tag small { color: var(--muted); font-size: 10px; }
.staffing-tag--primary { border-color: rgba(61,127,193,.45); background: rgba(61,127,193,.08); color: var(--blue-dark); }
.staffing-add-teacher { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.staffing-add-teacher summary { color: var(--blue); cursor: pointer; font-size: 12px; }
.staffing-unassigned-list { display: grid; gap: 4px; margin-top: 10px; }
.staffing-unassigned-list > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
.staffing-assignment-options { display: grid; gap: 4px; max-height: min(52vh, 480px); overflow-y: auto; }
.staffing-assignment-option { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px; border-bottom: 1px solid var(--line-soft); }
.staffing-assignment-option > label:first-child { display: flex; min-width: 0; align-items: center; gap: 8px; }
.staffing-assignment-option label span { display: grid; min-width: 0; gap: 2px; }
.staffing-assignment-option strong { font-size: 12px; font-weight: 500; }
.staffing-assignment-option small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.staffing-primary-choice { display: inline-flex; align-items: center; gap: 5px; color: var(--blue); font-size: 11px; white-space: nowrap; }
.selection-fieldset ul { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.selection-fieldset label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.group-drawer { position: fixed; inset: 0; z-index: 40; display: grid; grid-template-columns: 1fr minmax(360px, 460px); }
.group-drawer__backdrop { grid-column: 1; grid-row: 1; border: 0; background: rgba(27,36,48,.24); cursor: default; }
.group-drawer__panel { grid-column: 2; grid-row: 1; min-width: 0; overflow-y: auto; padding: 28px; background: var(--paper); box-shadow: -10px 0 28px rgba(27,36,48,.12); }
.group-drawer__heading, .group-drawer__actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.group-drawer__heading { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.group-drawer__heading h2 { margin: 0; font-family: "Noto Serif SC", "SimSun", serif; font-size: 20px; }
.group-drawer__form { margin-top: 24px; }
.group-drawer__actions { justify-content: flex-end; margin-top: 8px; }
.subject-list-toolbar { display: grid; gap: 12px; margin: 20px 0 14px; }
.subject-list-toolbar .button { justify-self: start; }
.subject-list { display: grid; border-top: 1px solid var(--line-soft); }
.subject-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.subject-row > div:first-child { display: grid; gap: 3px; }
.subject-row strong { font-size: 13px; font-weight: 500; }
.subject-row small { color: var(--muted); font-size: 11px; }
.subject-row--inactive { opacity: .55; }
.subject-row__actions { display: flex; align-items: center; gap: 4px; }
.subject-row__actions form { display: inline-flex; margin: 0; }
.selection-fieldset { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 3px; }
.selection-fieldset legend { padding: 0 6px; color: var(--ink); font-size: 12px; font-weight: 500; }
.selection-grid > div { display: grid; gap: 8px 12px; }
.selection-grid--subjects > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.selection-grid--grades > div { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.selection-grid label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; cursor: pointer; }
.generation-preview, .generation-result { margin-top: 4px; padding: 14px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); }
.generation-preview h3, .generation-result h3 { margin: 0 0 10px; font-size: 13px; }
.generation-targets { display: grid; gap: 7px; max-height: 260px; overflow-y: auto; }
.generation-targets p { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0; font-size: 11.5px; }
.generation-targets code { color: var(--blue); white-space: nowrap; }
.generation-result p { margin: 5px 0 0; font-size: 12px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 16px; color: var(--muted); font-size: 12px; }
.filter-bar { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 10px; margin: 18px 0; }
.score-negative { color: var(--red); }
.score-positive { color: var(--blue); }
.form-card--wide { max-width: 880px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid__full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }
.task-list { display: grid; gap: 10px; }
.task-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: 3px; background: #faf9f6; }
.task-row strong, .task-row span { display: block; }
.task-row strong { font-size: 13px; font-weight: 500; }
.task-row span { margin-top: 4px; color: var(--muted); font-size: 11.5px; }
.form-error { padding: 10px 12px; border-left: 3px solid var(--red); background: rgba(180,67,47,.08); color: var(--red); font-size: 12px; }
.score-preview { display: grid; gap: 5px; padding: 16px; border: 1px solid #c8dcff; border-radius: 8px; background: #f2f7ff; }
.score-preview > span { color: var(--primary); font-size: 13px; font-weight: 700; }
.score-preview > strong { color: var(--navy); font-size: 24px; }
.score-preview > small { color: var(--muted); line-height: 1.6; }
.score-value { color: var(--primary); font-weight: 800; white-space: nowrap; }
.compact-row > div { display: grid; gap: 4px; }
.ranking-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 18px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--line); }
.ranking-meta > div { display: grid; gap: 5px; padding: 12px 14px; background: #fff; }
.ranking-meta span { color: var(--muted); font-size: 11px; }
.ranking-meta strong { color: var(--navy); font-size: 13px; }
.snapshot-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; }
.snapshot-tabs a { padding: 7px 11px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 12px; text-decoration: none; white-space: nowrap; }
.snapshot-tabs a.active { border-color: var(--primary); background: #eef5ff; color: var(--primary); }
.rank-badge { display: inline-grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; background: #edf0f3; font-weight: 800; }
.rank-badge--first { background: #fff0c7; color: #8a5b00; }
.rank-badge--third { background: #f2e5dd; color: #895139; }
.ranking-table { min-width: 940px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.button--danger { border-color: var(--red); background: var(--red); color: #fff; }
.button--danger:hover { filter: brightness(.96); }
.definition-list { display: grid; gap: 1px; overflow: hidden; margin: 18px 0 0; border: 1px solid var(--line); border-radius: 8px; background: var(--line); }
.definition-list > div { display: grid; grid-template-columns: 130px 1fr; gap: 14px; padding: 11px 13px; background: #fff; }
.definition-list dt { color: var(--muted); font-size: 12px; }
.definition-list dd { margin: 0; color: var(--navy); font-size: 13px; font-weight: 700; }
.score-cell { color: var(--primary); font-weight: 800; }
.guidance-card ol { margin: 18px 0; padding-left: 20px; color: var(--muted); line-height: 1.9; }
.guidance-card > p:last-child { color: var(--muted); font-size: 12px; line-height: 1.7; }
.declaration-list { display: grid; margin-top: 12px; }
.declaration-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 4px; border-bottom: 1px solid var(--line-soft); color: inherit; text-decoration: none; }
.declaration-row:hover { background: #fbfaf7; }
.declaration-row > div:first-child, .declaration-row__score { display: grid; gap: 4px; }
.declaration-row span, .declaration-row__score span { color: var(--muted); font-size: 11.5px; }
.declaration-row__score { text-align: right; }
.declaration-row__score strong { color: var(--primary); font-size: 21px; }
.attachment-list { display: grid; gap: 8px; }
.attachment-list a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); font-size: 12px; text-decoration: none; }
.attachment-list small { color: var(--muted); }
.publication-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.publication-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 6px; color: inherit; text-decoration: none; }
.publication-card:hover { border-color: #b9c8d8; background: #fbfcfd; }
.publication-card > div { display: grid; gap: 5px; }
.publication-card span, .publication-card small { color: var(--muted); font-size: 11px; }
.publication-card > div:last-child { text-align: right; }
.publication-card > div:last-child strong, .publication-score { color: var(--primary); font-size: 24px; }
.publication-detail { max-width: 820px; }
.privacy-note { margin: 18px 0 0; padding: 12px 14px; border-left: 3px solid var(--primary); background: #f2f7ff; color: var(--muted); font-size: 12px; }
.publication-admin-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 3px; border-bottom: 1px solid var(--line-soft); }
.publication-admin-row > div { display: grid; gap: 4px; }
.publication-admin-row span { color: var(--muted); font-size: 11.5px; }
.publication-admin-row form { display: flex; gap: 8px; }
.publication-admin-row input { min-width: 220px; }
.review-radio { display: flex; flex-wrap: wrap; gap: 16px; }
.review-radio > div label { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); }
.review-radio input { width: 18px; padding: 0; }
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-card { width: min(100%, 420px); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 20px 60px rgba(27,36,48,.08); }
.brand--login { margin-bottom: 4px; padding: 28px 30px 22px; text-align: center; }
.login-card form { padding: 22px 30px 30px; }
.captcha-field { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 10px; align-items: center; }
.captcha-field input { min-width: 0; height: 42px; font-size: 18px; letter-spacing: .24em; text-align: center; }
.captcha-image-button { overflow: hidden; width: 120px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 3px; background: #f3f1eb; cursor: pointer; }
.captcha-image-button img { display: block; width: 120px; height: 42px; }
.captcha-refresh { align-self: flex-start; padding: 0; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 11.5px; }
.captcha-refresh:hover { color: var(--blue-dark); text-decoration: underline; }
.select-native--enhanced {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}
.select-enhanced { position: relative; width: 100%; min-width: 0; }
.select-enhanced__trigger {
  position: relative;
  display: flex;
  width: 100%;
  min-height: var(--control-height);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden;
  padding: 9px 36px 9px 12px;
  border: 1px solid var(--control-border);
  border-radius: var(--control-radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(27,36,48,.035);
  cursor: pointer;
  font-size: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.select-enhanced__trigger::after {
  position: absolute;
  right: 14px;
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  content: "";
  transform: translateY(-2px) rotate(45deg);
}
.select-enhanced__trigger:hover:not(.is-disabled) { border-color: var(--control-border-hover); }
.select-enhanced__trigger:focus-visible,
.select-enhanced.is-open .select-enhanced__trigger {
  border-color: var(--blue);
  outline: 0;
  box-shadow: 0 0 0 3px var(--control-focus-ring);
}
.select-enhanced__trigger.is-disabled { background: var(--control-disabled); color: var(--faint); cursor: not-allowed; }
.select-enhanced__menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 7px);
  left: 0;
  width: 100%;
  min-width: 100%;
  max-width: min(420px, calc(100vw - 36px));
  max-height: min(320px, 45vh);
  overflow-y: auto;
  padding: 5px;
  border: 1px solid #d9dee4;
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(27,36,48,.12);
}
.select-enhanced--up .select-enhanced__menu { top: auto; bottom: calc(100% + 7px); }
.select-enhanced__option {
  position: relative;
  display: flex;
  min-height: 40px;
  align-items: center;
  overflow: hidden;
  padding: 8px 34px 8px 10px;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.select-enhanced__option:hover,
.select-enhanced__option.is-active { background: #f6f8fa; color: var(--ink); }
.select-enhanced__option.is-selected { background: rgba(61,127,193,.10); color: var(--blue-dark); font-weight: 500; }
.select-enhanced__option.is-selected::after {
  position: absolute;
  right: 12px;
  color: var(--blue);
  content: "✓";
  font-weight: 700;
}
.select-enhanced__option.is-disabled { color: var(--faint); cursor: not-allowed; opacity: .65; }
.select-enhanced__option.is-disabled:hover { background: transparent; }
select[aria-invalid="true"] + .select-enhanced .select-enhanced__trigger { border-color: var(--red); }
select[aria-invalid="true"] + .select-enhanced .select-enhanced__trigger:focus-visible { box-shadow: 0 0 0 3px var(--control-error-ring); }
.sidebar-toggle, .sidebar__close { display: none; }
.sidebar-backdrop { display: none; }

.role-workflow { overflow: hidden; }
.role-workflow__heading { margin-bottom: 20px; }
.role-workflow__heading .eyebrow { margin-bottom: 6px; }
.role-workflow__timeline { width: min(100%, 900px); }
.workflow-step { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; min-width: 0; }
.workflow-step__rail { position: relative; display: flex; flex-direction: column; align-items: center; }
.workflow-step__node { position: relative; z-index: 1; width: 38px; height: 38px; flex: 0 0 38px; overflow: visible; }
.workflow-step__node circle { fill: #fff; stroke: var(--line); stroke-width: 2; }
.workflow-step__node path { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.4; }
.workflow-step__node text { fill: currentColor; font-size: 10px; font-weight: 700; }
.workflow-step__connector { width: 4px; min-height: 58px; flex: 1; }
.workflow-step__connector path { fill: none; stroke: var(--line); stroke-width: 2; stroke-dasharray: 4 4; }
.workflow-step__body { min-width: 0; margin-bottom: 14px; padding: 15px 16px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: #fbfaf7; }
.workflow-step__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.workflow-step__header h3 { margin: 0; font-size: 14px; line-height: 1.45; }
.workflow-step__header h3 span { margin-right: 8px; color: var(--faint); font-size: 10px; font-weight: 600; }
.workflow-step__status { flex: 0 0 auto; padding: 3px 8px; border-radius: 999px; background: #efede8; color: var(--muted); font-size: 10px; line-height: 1.4; }
.workflow-step__body > p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.workflow-step__body .workflow-step__reason { color: var(--red); }
.workflow-step__actions { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; }
.workflow-step__action { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; color: var(--blue); font-size: 11.5px; font-weight: 600; }
.workflow-step__actions .workflow-step__action { margin-top: 0; }
.workflow-step__action--disabled { color: var(--faint); cursor: not-allowed; }
.workflow-step--completed .workflow-step__node { color: #2e7d62; }
.workflow-step--completed .workflow-step__node circle { fill: #e4f1ec; stroke: #2e7d62; }
.workflow-step--completed .workflow-step__status { background: #e4f1ec; color: #22604d; }
.workflow-step--active .workflow-step__node { color: var(--blue); }
.workflow-step--active .workflow-step__node circle { fill: #e8f1fa; stroke: var(--blue); }
.workflow-step--active .workflow-step__status { background: #e8f1fa; color: var(--blue-dark); }
.workflow-step--pending .workflow-step__node { color: #8a6a2f; }
.workflow-step--pending .workflow-step__node circle { fill: #f4ecd9; stroke: #a98643; }
.workflow-step--pending .workflow-step__status { background: #f4ecd9; color: #765c27; }
.workflow-step--blocked .workflow-step__node { color: var(--red); }
.workflow-step--blocked .workflow-step__node circle { fill: #f8e6e3; stroke: var(--red); }
.workflow-step--blocked .workflow-step__status { background: #f8e6e3; color: var(--red); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { border-radius: 6px; background: #d8d2c7; }

@media (max-width: 820px) {
  .split-layout { grid-template-columns: 1fr; }
  .organization-layout { grid-template-columns: 1fr; }
  .stats-grid--three, .stats-grid--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar, .form-grid { grid-template-columns: 1fr; }
  .ranking-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .publication-grid { grid-template-columns: 1fr; }
  .publication-admin-row, .publication-admin-row form { align-items: stretch; flex-direction: column; }
  .form-grid__full { grid-column: auto; }
  .sidebar { transform: translateX(-100%); transition: transform .18s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar-toggle, .sidebar__close { display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
  .sidebar-toggle { width: 38px; height: 38px; flex: 0 0 38px; font-size: 20px; }
  .sidebar__close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; font-size: 22px; }
  .sidebar-toggle img { width: 22px; height: 22px; }
  .sidebar__close img { width: 16px; height: 16px; }
  body.sidebar-open .sidebar-backdrop { position: fixed; inset: 0; z-index: 15; display: block; background: rgba(27,36,48,.28); }
  .topbar { align-items: flex-start; padding: 16px 18px; }
  .topbar__status { display: none; }
  .page-content { padding: 20px 18px 48px; }
  .tree-row__actions { opacity: 1; }
  .stage-grid { grid-template-columns: 1fr; }
  .staffing-teacher-card { grid-template-columns: 1fr; align-items: start; }
  .staffing-term-filter, .staffing-generate-form { align-items: stretch; flex-direction: column; }
}

@media (max-width: 520px) {
  .captcha-field { grid-template-columns: minmax(0, 1fr) 108px; }
  .captcha-field input { height: 40px; }
  .captcha-image-button, .captcha-image-button img { width: 108px; height: 40px; }
  .stats-grid--three, .stats-grid--four { grid-template-columns: 1fr; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .group-drawer { grid-template-columns: 1fr; }
  .group-drawer__backdrop { display: none; }
  .group-drawer__panel { grid-column: 1; padding: 22px 18px; }
  .tree-card-heading { align-items: flex-start; flex-direction: column; }
  .tree-card-heading__actions { width: 100%; }
  .tree-card-heading__actions .button { flex: 1 1 auto; }
  .tree-group__heading { align-items: flex-start; flex-direction: column; }
  .tree-group__heading > .tree-row__actions { flex-wrap: wrap; }
  .subject-row { align-items: flex-start; }
  .subject-row__actions { flex-wrap: wrap; justify-content: flex-end; }
  .foundation-item { align-items: flex-start; flex-wrap: wrap; }
  .foundation-item__content { width: calc(100% - 42px); flex: 1 1 calc(100% - 42px); }
  .foundation-item__actions { width: 100%; flex-wrap: wrap; justify-content: flex-end; }
  .stage-card__heading { align-items: flex-start; flex-wrap: wrap; }
  .stage-card__heading > .foundation-item__actions { margin-left: 39px; width: calc(100% - 39px); }
  .selection-grid--subjects > div { grid-template-columns: 1fr; }
  .workflow-step { grid-template-columns: 34px minmax(0, 1fr); gap: 9px; }
  .workflow-step__node { width: 32px; height: 32px; flex-basis: 32px; }
  .workflow-step__body { padding: 13px; }
  .workflow-step__header { display: grid; gap: 7px; }
  .workflow-step__status { justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
