:root[data-theme="light"] {
  --bg: #f3f5f8;
  --ink: #263449;
  --muted: #718096;
  --green: #466cba;
  --link-ink: #3b63a8;
  --line: #e3e8ef;
  --surface-subtle: #f7f9fc;
  --surface-hover: #f0f4fa;
  --accent-bg: #edf2fb;
  --accent-border: #bdcce8;
  --focus: #6e8fc7;
}
:root[data-theme="dark"] {
  --bg: #1b2330;
  --surface: #242e3c;
  --surface-subtle: #293545;
  --surface-hover: #2c3a4c;
  --green: #557bbb;
  --line: #394656;
}
.layout { grid-template-columns: 180px minmax(0, 1fr); }
.sidebar { background: #243348; border-color: #243348; padding: 22px 10px 14px; }
.sidebar .brand { margin-bottom: 32px; }
.sidebar .brand strong { color: #f0f4fc; }
.sidebar .brand-mark { background: #466cba; border-radius: 6px; }
.sidebar .brand small, .sidebar .nav-caption, .sidebar .account small { color: #93a4bd; }
.sidebar .nav-item { color: #becbdd; min-height: 38px; border-radius: 4px; }
.sidebar .nav-item:hover { background: #2d405a; }
.sidebar .nav-item.active { background: #395577; color: #fff; box-shadow: inset 3px 0 #7ba3dc; }
.sidebar .account { border-color: #3a4b63; color: #dce5f4; }
.sidebar .avatar { background: #3b5271; color: #e4edff; }
.sidebar .text-btn, .sidebar .operator-link { color: #afc5e6; }
.nav-group + .nav-group { margin-top: 24px; }
.topbar { height: 44px; background: var(--surface); padding: 0 22px; }
.workspace-tabs { display: flex; align-items: center; gap: 6px; min-height: 38px; padding: 5px 22px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.workspace-tab { flex-shrink: 0; border: 1px solid var(--line); background: var(--surface); color: var(--muted); height: 26px; padding: 0 11px; font-size: 11px; border-radius: 3px; }
.workspace-tab.active { color: var(--link-ink); border-color: var(--accent-border); background: var(--accent-bg); }
.workspace-tab.active::before { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.content { max-width: none; padding: 20px 22px; }
.page-heading { margin-bottom: 16px; }
.page-heading h1 { font-size: 19px; font-weight: 600; }
.page-heading p { margin-top: 5px; font-size: 12px; }
.btn { min-height: 32px; border-radius: 4px; padding: 6px 13px; }
.btn.small { min-height: 28px; padding: 4px 10px; }
.panel { border-radius: 5px; padding: 16px; }
.panel-head h2, .grant-layout h3, .workspace-help h2, .settings-defaults h2 { font-size: 13px; font-weight: 600; }
.stats { gap: 14px; }
.stat { border-radius: 5px; padding: 17px 20px; }
.stat strong { font-size: 28px; color: var(--ink); }
.stat::after { display: none; }
.filter-bar { gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.filter-bar input, .filter-bar select, .compact-search { height: 32px; min-height: 32px; border-radius: 4px; padding: 6px 10px; font-size: 12px; }
.filter-bar select { min-width: 112px; }
.student-list-panel .filter-bar input { max-width: 340px; }
.table-wrap { border: 1px solid var(--line); border-radius: 3px; }
th { font-weight: 500; background: var(--surface-subtle); color: var(--muted); padding: 10px 12px; }
td { padding: 10px 12px; color: var(--ink); border-bottom: 1px solid var(--line); }
td small { margin-top: 3px; line-height: 1.5; }
tbody tr:hover td { background: var(--surface-hover); }
.student-table { min-width: 1000px; }
.student-table th:last-child, .student-table td:last-child, .course-table th:last-child, .course-table td:last-child { position: sticky; right: 0; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -5px 0 6px -7px #1b2d49aa; z-index: 1; }
.student-table th:last-child, .course-table th:last-child { background: var(--surface-subtle); }
.student-table tbody tr:hover td:last-child, .course-table tbody tr:hover td:last-child { background: var(--surface-hover); }
.student-name-cell { max-width: 190px; }
.student-name-cell .student-link, .student-name-cell small { display: block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.student-link { font-size: 12px; font-weight: 500; }
.student-table .row-actions { flex-wrap: nowrap; gap: 13px; }
.student-pagination { margin-top: 16px; flex-wrap: wrap; gap: 10px; }
.student-pagination .toolbar { gap: 5px; }
.page-number { display: inline-grid; place-items: center; height: 28px; min-width: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: 3px; color: var(--secondary-ink); background: var(--surface); font-size: 12px; }
.page-number.active { background: var(--green); border-color: var(--green); color: #fff; opacity: 1; }
.student-pagination form, .student-pagination label { display: flex; align-items: center; gap: 7px; }
.student-pagination form { margin-left: 8px; }
.student-pagination input { width: 48px; height: 28px; border: 1px solid var(--line); border-radius: 3px; padding: 3px 5px; background: var(--field-bg); color: var(--ink); }
dialog { border-radius: 6px; padding: 22px; }
dialog.wide { width: min(1080px, 94vw); }
.student-dialog-header h2 { font-size: 18px; }
.student-summary { display: grid; grid-template-columns: 1fr 1fr 1fr 1.2fr; gap: 16px; padding: 16px; margin: 16px 0 4px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 4px; }
.student-summary span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.student-summary strong { display: block; font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.student-detail-tabs { margin-top: 12px; }
.student-dialog [data-form="student-settings"] { background: var(--surface-subtle); padding: 4px 16px 16px; border-radius: 4px; }
.grant-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 15px; }
.grant-header h2 { font-size: 18px; margin: 0 0 5px; }
.grant-header p { margin: 0; }
.grant-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.grant-layout h3 { margin: 0; }
.grant-picker { min-width: 0; padding: 18px 20px 16px 0; }
.grant-section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.grant-section-title span { font-size: 12px; color: var(--link-ink); }
.grant-picker .compact-search { width: 100%; max-width: none; }
.grant-select-tools { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0; }
.grant-course-list { max-height: 380px; overflow: auto; border: 1px solid var(--line); border-radius: 4px; }
.grant-course { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.grant-course:last-child { border-bottom: 0; }
.grant-course:hover { background: var(--surface-hover); }
.grant-course.selected { background: var(--accent-bg); }
.grant-course input { flex-shrink: 0; accent-color: var(--green); margin: 3px 0 0; width: 15px; height: 15px; }
.grant-course span { min-width: 0; }
.grant-course strong { display: block; font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.grant-course small { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.grant-course[hidden], .grant-policy[hidden], .grant-no-match[hidden] { display: none; }
.grant-options { border-left: 1px solid var(--line); padding: 18px 0 12px 20px; min-width: 0; }
.grant-options .field { margin: 12px 0; }
.grant-options .field input, .grant-options .field select { min-height: 32px; padding: 7px 9px; margin-top: 6px; }
.grant-options .field small { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.grant-options textarea { min-height: 64px; padding: 9px; margin-top: 6px; }
.grant-terms { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grant-terms .field:has([name="note"]), .grant-terms .privacy-note { grid-column: 1 / -1; }
.grant-terms .field:has([name="note"]) { grid-row: 2; }
.grant-terms .privacy-note { margin: 0; font-size: 11px; line-height: 1.65; }
.grant-policy .policy-fields { border-radius: 4px; padding: 12px; margin: 12px 0 0; }
.grant-policy .policy-fields .field { margin-top: 2px; }
.grant-policy .privacy-note, .grant-policy .casting-policy-note { font-size: 11px; }
.grant-footnote { padding: 10px 12px; margin: 14px 0 0; background: var(--surface-subtle); border-radius: 4px; font-size: 11px; }
.grant-footer { position: sticky; bottom: -22px; background: var(--surface); display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 15px 0 0; border-top: 1px solid var(--line); }
.grant-footer > span { color: var(--muted); font-size: 12px; }
.settings-defaults { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.settings-defaults h2 { margin: 0 0 6px; }
.settings-defaults p { color: var(--muted); margin: 0; font-size: 12px; }
.workspace-help details { border-top: 1px solid var(--line); padding: 12px 0; font-size: 12px; }
.workspace-help summary { cursor: pointer; }
.workspace-help p { color: var(--muted); line-height: 1.8; margin-bottom: 0; }
@media (max-width: 1100px) {
  .student-list-panel .filter-bar { flex-wrap: wrap; }
  .student-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .layout { display: block; }
  .sidebar { padding: 14px 12px 8px; }
  .sidebar .brand { margin-bottom: 12px; }
  .sidebar nav { display: flex; }
  .nav-group + .nav-group { margin: 0; }
  .workspace-tabs { padding: 5px 12px; }
  .content { padding: 16px 12px; }
  .page-heading { align-items: flex-start; }
  .page-heading .toolbar { width: 100%; }
  .student-list-panel .filter-bar input { max-width: none; min-width: 0; }
  .student-list-panel .filter-bar select { min-width: 0; flex: 1 1 100px; }
  .grant-layout { display: block; }
  .grant-picker { padding: 16px 0; }
  .grant-options { border: 0; border-top: 1px solid var(--line); padding: 16px 0; }
  .grant-course-list { max-height: 230px; }
  .grant-footer { bottom: -18px; padding-top: 12px; }
  .grant-footer > span { max-width: 45%; }
  dialog { padding: 18px; }
  .settings-defaults { align-items: flex-start; flex-direction: column; }
}
