/* Design tokens: all application surfaces share this scale. */
:root {
  --brand: #b0003f;
  --brand-hover: #96003a;
  --brand-soft: #fbe7ee;
  --brand-border: #ecc0d1;
  --background: #faf7f3;
  --surface: #fff;
  --surface-muted: #f5f3f1;
  --surface-hover: #f0ece8;
  --text: #2b2523;
  --muted: #6d635c;
  --border: #dcd3cb;
  --border-strong: #c3b7ae;
  --divider: #ece6e1;
  --success: #227a55;
  --success-soft: #e6f4ed;
  --success-border: #b2d7c5;
  --warning: #9d5f00;
  --warning-soft: #fff3dc;
  --warning-border: #ebd09e;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --danger-border: #efc3bd;
  --on-brand: #fff;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --font-small: 12px;
  --font-control: 13px;
  --font-body: 14px;
  --font-section: 16px;
  --font-title: 20px;
  --line-body: 1.5;
  --radius-control: 4px;
  --radius: 6px;
  --control-height: 32px;
  --touch-height: 44px;
  --row-height: 36px;
  --row-double: 56px;
  --row-rich: 64px;
  --label-width: 104px;
  --header-height: 64px;
  --shadow: none;
  --shadow-menu: 0 8px 24px rgb(43 37 35 / 12%);
  --backdrop: rgb(43 37 35 / 35%);
  --focus-halo: 0 0 0 3px var(--brand-soft);
  --z-sticky: 2;
  --z-header: 3;
  --z-corner: 4;
  --z-menu: 20;
  --z-skip: 100;
  --transition: 150ms ease;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: var(--font-body);
  line-height: var(--line-body);
  color: var(--text);
  background: var(--background);
}

/* Base elements and small layout helpers. */
* { box-sizing: border-box; }
body, h1, h2, h3, p { margin: 0; }
html { scroll-padding-block: var(--space-4) 100px; }
img { max-width: 100%; object-fit: contain; }
[hidden] { display: none !important; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, summary, select { cursor: pointer; }
summary { min-height: var(--control-height); align-content: center; }
a, button, summary { touch-action: manipulation; }
button:disabled { cursor: default; opacity: .65; }
h1 { font-size: var(--font-title); line-height: 1.4; font-weight: 650; overflow-wrap: anywhere; }
h2, h3 { font-size: var(--font-section); font-weight: 600; }
small, .help { font-size: var(--font-small); }
.muted, .help { color: var(--muted); }
.required { color: var(--brand); }
.nowrap { white-space: nowrap; }
.full { width: 100%; }
.full-text { white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.spread { justify-content: space-between; }
.space-top { margin-top: var(--space-3); }
.narrow { max-width: 620px; margin-inline: auto; }
:is(a, button, summary, input, select, textarea):focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
:is(a, button, summary, input, select, textarea):focus:not(:focus-visible) { outline: none; }
input, select, textarea, .error-summary { scroll-margin-block: var(--space-4) 100px; }
.skip-link { position: absolute; top: -100px; left: var(--space-3); z-index: var(--z-skip); background: var(--surface); padding: var(--space-3); }
.skip-link:focus { top: var(--space-3); }

/* Application frame and navigation. */
.workspace { min-height: 100dvh; }
.workspace-main, .main { min-width: 0; }
.main { padding: var(--space-3); }
.main > p { margin-bottom: var(--space-3); overflow-wrap: anywhere; }
.app-header { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3) var(--space-6); min-height: var(--header-height); padding: var(--space-2) var(--space-3); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: var(--space-2); color: var(--text); flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand img { flex-shrink: 0; }
.brand strong { font-size: var(--font-section); font-weight: 600; }
.brand small { display: block; color: var(--muted); }
.app-header .brand img { width: 38px; height: 38px; }
.app-header .brand strong { font-size: var(--font-body); }
.header-nav { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-1); min-width: 0; }
.nav-item { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--control-height); padding: var(--space-1) var(--space-3); color: var(--muted); border-radius: var(--radius-control); white-space: nowrap; font-size: var(--font-control); }
.nav-item:hover { background: var(--surface-muted); text-decoration: none; }
.nav-item.active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.header-tools { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); margin-left: auto; min-width: 0; }
.scope { display: flex; align-items: center; gap: var(--space-2); font-size: var(--font-small); }
.user-menu { position: relative; }
.user-menu summary { display: flex; align-items: center; gap: var(--space-2); list-style: none; min-height: var(--control-height); padding: var(--space-1) var(--space-2); border-radius: var(--radius-control); font-size: var(--font-control); }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu[open] summary, .user-menu summary:hover { background: var(--surface-muted); }
.user-menu-panel { position: absolute; right: 0; top: calc(100% + var(--space-1)); z-index: var(--z-menu); width: 240px; max-width: calc(100vw - 24px); padding: var(--space-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-menu); }
.user-menu-panel a, .user-menu-panel button { display: flex; align-items: center; width: 100%; min-height: var(--control-height); padding: var(--space-1) var(--space-2); text-align: left; color: var(--text); background: transparent; border: 0; border-radius: var(--radius-control); }
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--surface-muted); text-decoration: none; }
.user-menu-panel p { border-bottom: 1px solid var(--divider); padding: var(--space-2); overflow-wrap: anywhere; }
.page-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-3); }
.page-heading > div:first-child { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-1) var(--space-3); min-width: 0; }
.page-heading p { max-width: 680px; font-size: var(--font-small); }
.back-link { display: inline-flex; align-items: center; min-height: var(--control-height); margin-bottom: var(--space-1); font-size: var(--font-control); color: var(--muted); }
.tabs { display: flex; align-items: stretch; flex-wrap: wrap; gap: 0 var(--space-4); border-bottom: 1px solid var(--border); margin-bottom: var(--space-3); min-width: 0; }
.tabs a { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: var(--space-2) 0; color: var(--muted); border-bottom: 2px solid transparent; font-size: var(--font-control); white-space: nowrap; }
.tabs a:hover { color: var(--brand); border-bottom-color: var(--brand-border); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* Controls, status, feedback and panels. */
.button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--control-height); padding: var(--space-1) var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-control); background: var(--surface); color: var(--text); font-size: var(--font-control); font-weight: 500; line-height: var(--line-body); text-align: center; transition: background-color var(--transition), border-color var(--transition); }
.button:hover { background: var(--surface-muted); text-decoration: none; }
.button:active { background: var(--divider); }
.button.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.button.primary:hover, .button.primary:active { background: var(--brand-hover); border-color: var(--brand-hover); }
.button.small { padding-inline: var(--space-2); }
.button.danger-outline { color: var(--danger); }
.button.danger-outline:hover { background: var(--danger-soft); border-color: var(--danger); }
.text-link, .text-button { display: inline-flex; align-items: center; justify-content: center; min-height: var(--control-height); color: var(--brand); font-size: var(--font-control); white-space: nowrap; }
.text-button { border: 0; padding: 0 var(--space-1); background: transparent; }
.text-button:hover, .secondary-action:hover { text-decoration: underline; }
.secondary-action { color: var(--muted); }
.main-action { font-weight: 600; }
.control, :where(input:not([type=hidden]):not([type=checkbox]):not([type=radio])), select, textarea { display: block; width: 100%; min-width: 0; min-height: var(--control-height); border: 1px solid var(--border-strong); border-radius: var(--radius-control); padding: var(--space-1) var(--space-2); background-color: var(--surface); color: var(--text); font-size: var(--font-control); line-height: var(--line-body); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[readonly], .control:disabled { background-color: var(--surface-muted); }
.control:focus-visible { border-color: var(--brand); box-shadow: var(--focus-halo); }
textarea.control, textarea { resize: vertical; min-height: 80px; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; flex: 0 0 16px; margin: 0; accent-color: var(--brand); }
select.control { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%236d635c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 12px; }
.badge, .status { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2); border-radius: var(--radius-control); font-size: var(--font-small); white-space: nowrap; }
.badge { color: var(--brand); background: var(--brand-soft); }
.status, .business-area-badge { color: var(--muted); background: var(--surface-muted); }
.status.archived, .status.filled, .status.success { color: var(--success); background: var(--success-soft); }
.status.pending, .status.invited, .status.warning { color: var(--warning); background: var(--warning-soft); }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-padding { padding: var(--space-3); }
.panel-padding > .field + .field { margin-top: var(--space-3); }
.notice { padding: var(--space-2) var(--space-3); border: 1px solid var(--brand-border); border-radius: var(--radius); background: var(--brand-soft); color: var(--brand); margin-block: var(--space-2) var(--space-3); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); overflow-wrap: anywhere; }
.notice p { flex-basis: 100%; }
.notice.success { border-color: var(--success-border); color: var(--success); background: var(--success-soft); }
.notice.warning { border-color: var(--warning-border); color: var(--warning); background: var(--warning-soft); }
.notice.error, .error-summary { border: 1px solid var(--danger-border); color: var(--danger); background: var(--danger-soft); }
.error-summary { padding: var(--space-3); border-radius: var(--radius); margin-block: var(--space-3); overflow-wrap: anywhere; }
.error-summary a { display: block; color: inherit; text-decoration: underline; margin-top: var(--space-1); }
.error-summary ul { margin: var(--space-2) 0; padding-left: var(--space-6); }
.field-error, .save-error, .copy-feedback.copy-error { font-size: var(--font-small); color: var(--danger); }
.has-error :is(input, select, textarea) { border-color: var(--danger); }
.saved-state, .copy-feedback { color: var(--success); }
.copy-feedback { display: block; flex-basis: 100%; font-size: var(--font-small); white-space: normal; overflow-wrap: anywhere; }
.copy-feedback:empty { display: none; }
.danger-text { color: var(--danger) !important; }
.empty-state { padding: var(--space-6) var(--space-4); text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); }
td.empty-state { display: table-cell; }
.empty-state p { max-width: 480px; margin-inline: auto; }

/* Shared forms and editing surfaces. */
.form-section { padding: var(--space-3); border-bottom: 1px solid var(--divider); min-width: 0; }
.form-section:last-child { border-bottom: 0; }
.form-section h2, .archive-group > summary { font-size: var(--font-body); font-weight: 600; }
.archive-group { padding-block: var(--space-1); }
.archive-group[open] { padding-block: var(--space-2) var(--space-3); }
.archive-group > summary { min-height: var(--control-height); align-content: center; }
.archive-group > summary + .help { margin-top: var(--space-2); }
.section-heading { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); min-height: var(--control-height); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: var(--space-3) var(--space-4); margin-block: var(--space-2) var(--space-3); }
.field { display: grid; align-content: start; gap: var(--space-1); min-width: 0; }
.field label { font-size: var(--font-control); font-weight: 500; }
.field:has(textarea) { grid-column: 1 / -1; }
.check-label, label:has(> input[type=checkbox]) { display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-height); cursor: pointer; }
.check-field { align-self: start; }
.form-grid > .check-field { padding-top: calc(var(--font-control) * var(--line-body) + var(--space-1)); }
.check-label span { font-weight: 400; }
.archive-summary { padding: var(--space-3); color: var(--muted); background: var(--surface-muted); }
.material-editor-row, .certificate-row { padding-block: var(--space-3); border-bottom: 1px solid var(--divider); }
.material-editor-row small { display: block; }
.action-bar { position: sticky; bottom: 0; z-index: var(--z-header); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3); padding: var(--space-2) var(--space-3); margin-top: var(--space-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

/* Tables and filter toolbars. */
.table-scroll { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: var(--font-control); line-height: 1.5; }
th, td { height: var(--row-height); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--divider); vertical-align: middle; text-align: left; }
th { color: var(--muted); font-weight: 500; background: var(--surface-muted); white-space: nowrap; }
td { overflow-wrap: anywhere; padding-block: 2px; }
td:has(small) { padding-block: var(--space-2); }
td small { display: block; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-hover); }
.table-scroll:not(.staff-table-scroll) > table { min-width: 640px; }
.table-scroll td:last-child > a { display: inline-flex; align-items: center; min-height: var(--control-height); white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3); padding: var(--space-2) var(--space-3); color: var(--muted); font-size: var(--font-small); }
.pagination nav { display: flex; align-items: center; gap: var(--space-3); }
.filter-form { padding: var(--space-3); border-bottom: 1px solid var(--divider); background: var(--surface); }
.filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
.filter-row label { display: flex; align-items: center; gap: var(--space-2); min-width: 0; font-size: var(--font-control); white-space: nowrap; }
.filter-row label .control { width: auto; min-width: 112px; flex: 1; }
.filter-search { flex: 0 1 300px; }
.filter-actions { display: flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.roster-panel { container: roster / inline-size; }
.view-toolbar { display: flex; align-items: center; gap: var(--space-4); padding-inline: var(--space-3); border-bottom: 1px solid var(--border); }
.view-label { font-size: var(--font-control); font-weight: 600; white-space: nowrap; }
.view-tabs { flex: 1; flex-wrap: nowrap; overflow-x: auto; margin: 0; border: 0; }
.roster-filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: var(--space-2) var(--space-3); }
.roster-filter-grid > label, .business-area-filter { display: flex; align-items: center; gap: var(--space-2); min-width: 0; white-space: nowrap; font-size: var(--font-control); }
.roster-filter-grid .control { flex: 1; width: 100%; min-width: 0; }
.roster-filter-primary { grid-template-columns: minmax(220px, 1.5fr) repeat(5, minmax(0, 1fr)) auto; align-items: center; }
.roster-filter-bottom { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2) var(--space-3); margin-top: var(--space-2); align-items: start; }
.active-filters { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); min-height: var(--control-height); min-width: 0; }
.filter-chip { display: inline-flex; align-items: center; gap: var(--space-2); max-width: 100%; padding: var(--space-1) var(--space-2); border: 1px solid var(--brand-border); border-radius: var(--radius-control); background: var(--surface); font-size: var(--font-small); overflow-wrap: anywhere; }
.filter-chip:hover { background: var(--brand-soft); text-decoration: none; }
.filter-chip > span { font-size: var(--font-section); flex-shrink: 0; }
.more-filters { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; }
.more-filters > summary { grid-column: 2; justify-self: end; min-height: var(--control-height); align-content: center; color: var(--brand); font-size: var(--font-control); }
.more-filters .roster-filter-grid { margin-top: var(--space-2); }
.more-filters .roster-filter-grid > label { display: grid; grid-template-columns: 104px minmax(0, 1fr); }
/* The conditions stay beside the disclosure; its expanded body occupies a new row. */
.roster-filter-bottom .active-filters { grid-column: 1; grid-row: 1; position: relative; z-index: 1; }
.more-filters { grid-row: 1; }
.more-filters[open] { grid-row: 1 / span 2; }
.more-filters::details-content { grid-column: 1 / -1; }
.business-area-select { position: relative; flex: 1; min-width: 0; }
.business-area-select > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); list-style: none; }
.business-area-select > summary::-webkit-details-marker { display: none; }
.business-area-select > summary::after { content: ''; width: 6px; height: 6px; flex-shrink: 0; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: translateY(-2px) rotate(45deg); margin-right: var(--space-1); }
.business-area-select > summary > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.business-area-options { position: absolute; top: calc(100% + var(--space-1)); right: 0; z-index: var(--z-menu); min-width: 200px; max-width: calc(100vw - 24px); padding: var(--space-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-menu); }
.business-area-options label { display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-height); padding-inline: var(--space-1); cursor: pointer; }
.business-area-options .help { display: block; margin-top: var(--space-1); }

/* Fixed personnel work views. */
.staff-table-scroll { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
.staff-floating-header { position: fixed; top: 0; overflow: hidden; z-index: var(--z-header); pointer-events: none; background: var(--surface-muted); box-shadow: 0 1px 0 var(--border); }
.staff-floating-header[hidden] { display: none; }
.staff-table a, .staff-table summary { scroll-margin-top: 64px; }
.staff-table { table-layout: fixed; min-width: 1120px; border-collapse: separate; border-spacing: 0; }
.staff-table th { position: sticky; top: 0; z-index: var(--z-header); height: var(--row-height); font-size: var(--font-small); white-space: normal; }
.staff-table td { height: var(--row-double); padding-block: var(--space-2); background: var(--surface); }
.staff-table tbody tr:nth-child(even) td { background: var(--surface-muted); }
.staff-table tbody tr:hover td { background: var(--surface-hover); }
.staff-table th:first-child, .staff-table td:first-child { position: sticky; left: 0; z-index: var(--z-sticky); border-right: 1px solid var(--divider); }
.staff-table th:first-child { z-index: var(--z-corner); }
.staff-table .col-person { width: 120px; }
.staff-table .col-campus { width: 170px; }
.staff-table .col-actions { width: 128px; }
.staff-table .col-employment_status, .staff-table .col-credential_issue_count { width: 86px; }
.staff-table .col-professional_title { width: 160px; }
.staff-table .col-position, .staff-table .col-todo, .staff-table .col-other_certificates { width: 180px; }
.staff-table .col-joined_on, .staff-table-license .col-education_display { width: 154px; }
.staff-table .col-contract_start { width: 140px; }
.staff-table .col-contract_type { width: 110px; }
.staff-table .col-social_insurance, .staff-table .col-provident_fund { width: 125px; }
.staff-table .col-contract_due, .staff-table .col-materials_missing_count, .staff-table .col-materials_unreviewed_count, .staff-table .col-materials_unregistered_count { width: 150px; }
.staff-table .col-entry_approval, .staff-table .col-regular_application, .staff-table .col-contract_seal, .staff-table .col-enterprise_wechat { width: 130px; }
.staff-table-license { min-width: 1190px; }
.staff-table-license td { height: var(--row-rich); }
.staff-table-license .col-practice_names { width: 170px; }
.staff-table-material { min-width: 1020px; }
.roster-field, .field-content, .field-content > * { min-width: 0; max-width: 100%; }
.roster-field { font-size: var(--font-control); line-height: 20px; }
.roster-field + .roster-field { font-size: var(--font-small); color: var(--muted); }
.field-content > span, .field-content > a, .field-content > small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.field-content small { display: block; font-size: var(--font-small); color: var(--muted); line-height: 18px; }
.person-name { font-size: var(--font-control); font-weight: 600; color: var(--text); }
.person-name:hover { color: var(--brand); }
.tone-normal > .field-content > a:not(.person-name) { color: inherit; }
.tone-muted, .tone-muted a { color: var(--muted); }
.tone-warning, .tone-warning a, .roster-notices a.tone-warning { color: var(--warning); }
.tone-danger, .tone-danger a, .roster-notices a.tone-danger { color: var(--danger); }
.roster-notices { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: var(--font-small); line-height: 20px; }
.roster-notices a { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.roster-actions, .staff-actions, .create-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.staff-table .roster-actions { flex-wrap: nowrap; gap: var(--space-1); }
.roster-action-menu { position: relative; }
.roster-action-menu > summary { display: flex; align-items: center; justify-content: center; list-style: none; width: var(--control-height); min-height: var(--control-height); padding: 0; border-radius: var(--radius-control); color: var(--muted); font-size: var(--font-title); }
.roster-action-menu > summary::-webkit-details-marker { display: none; }
.roster-action-menu > summary:hover, .roster-action-menu[open] > summary { background: var(--surface-muted); color: var(--text); }
.roster-action-panel { position: absolute; right: 0; top: calc(100% + var(--space-1)); z-index: var(--z-menu); width: 200px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow: auto; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-menu); }
.roster-action-menu[data-upward] .roster-action-panel { top: auto; bottom: calc(100% + var(--space-1)); }
.table-scroll .roster-action-panel { position: fixed; right: auto; bottom: auto; }
.roster-action-panel .staff-actions { flex-direction: column; align-items: stretch; gap: 0; }
.roster-action-panel .staff-actions > a, .roster-action-panel .staff-actions > button { justify-content: flex-start; min-height: var(--control-height); padding: var(--space-1) var(--space-2); text-align: left; white-space: normal; border-radius: var(--radius-control); }
.roster-action-panel .staff-actions > a:hover, .roster-action-panel .staff-actions > button:hover { background: var(--surface-muted); text-decoration: none; }
.roster-action-panel .copy-feedback:not(:empty) { padding: var(--space-2); }

/* Read-only records, history and review. */
.archive-profile { padding: var(--space-3); margin-bottom: var(--space-3); }
.archive-profile .roster-action-menu > summary { width: auto; padding-inline: var(--space-2); font-size: var(--font-control); }
.archive-profile .roster-action-panel { display: grid; gap: var(--space-2); padding: var(--space-3); }
.archive-notices { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.archive-notices a { display: inline-flex; align-items: center; min-height: var(--control-height); padding: var(--space-1) var(--space-2); border: 1px solid var(--warning-border); border-radius: var(--radius-control); color: var(--warning); background: var(--warning-soft); font-size: var(--font-control); }
.archive-read-layout { display: grid; grid-template-columns: 142px minmax(0, 1fr); gap: var(--space-3); align-items: start; }
.archive-directory { position: sticky; top: var(--space-3); display: grid; border-left: 2px solid var(--border); }
.archive-directory a { display: flex; align-items: center; min-height: var(--control-height); padding: var(--space-1) var(--space-3); color: var(--muted); font-size: var(--font-control); }
.archive-directory a:hover { color: var(--brand); background: var(--brand-soft); text-decoration: none; }
.archive-read-content { display: grid; gap: var(--space-3); min-width: 0; }
.archive-read-section { padding: var(--space-3); scroll-margin-top: var(--space-3); min-width: 0; }
.archive-read-section h2 { margin-bottom: var(--space-3); }
.archive-read-section h3 { font-size: var(--font-body); margin: var(--space-3) 0 var(--space-2); }
.archive-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); margin: 0; }
.archive-fields > div { display: grid; grid-template-columns: var(--label-width) minmax(0, 1fr); gap: var(--space-2); align-items: baseline; min-width: 0; }
.archive-fields > div.wide { grid-column: 1 / -1; }
.archive-fields dt { color: var(--muted); font-size: var(--font-control); overflow-wrap: anywhere; }
.archive-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.archive-read-table { table-layout: fixed; }
.archive-read-table th { white-space: normal; }
.archive-read-table td { vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
.archive-history-block { border-top: 1px solid var(--divider); padding-block: var(--space-3); }
.archive-history-block summary { min-height: var(--control-height); align-content: center; color: var(--muted); font-size: var(--font-control); }
.archive-history-block table { margin-top: var(--space-2); }
.cell-disclosure > summary { overflow-wrap: anywhere; }
.cell-preview { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.detail-entries { display: grid; gap: var(--space-2); min-width: 0; max-height: 55dvh; overflow-y: auto; }
.detail-entry { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2) var(--space-4); padding: var(--space-3); margin: 0; background: var(--surface-muted); border-radius: var(--radius-control); }
.detail-entry > div { min-width: 0; }
.detail-entry dt { color: var(--muted); font-size: var(--font-small); }
.detail-entry dd { margin: var(--space-1) 0 0; }
.cell-detail-body { padding-top: var(--space-2); }
.cell-detail-body .text-button { margin-top: var(--space-1); }
.detail-list { margin: var(--space-3) 0 0; }
.detail-list > div { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: var(--space-3); padding-block: var(--space-2); border-bottom: 1px solid var(--divider); }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.comparison { margin-bottom: var(--space-3); }
.comparison summary { padding: var(--space-2) var(--space-3); color: var(--warning); background: var(--warning-soft); }
.comparison td, .history table td { width: 35%; white-space: pre-wrap; }
.comparison td:last-child { background: var(--success-soft); }
.comparison th, .comparison td, .history table th { white-space: normal; overflow-wrap: anywhere; }
.history article { padding: var(--space-3); border-bottom: 1px solid var(--divider); }
.history article:last-of-type { border-bottom: 0; }
.history article > .help { margin-block: var(--space-1) var(--space-2); }
.review-table { table-layout: fixed; }
.review-table th:first-child { width: 15%; }
.review-table pre, .detail-list pre, .review-values pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 0; }
.review-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); width: 100%; }
.return-field-row { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr; gap: var(--space-3); align-items: center; margin-block: var(--space-2); }
[data-returned] { outline: 2px solid var(--warning); outline-offset: 2px; }
.return-summary li, .result-timeline li { margin-block: var(--space-3); }

/* Credentials and invitations. */
.credential-card { border: 1px solid var(--border); border-radius: var(--radius); margin-block: var(--space-3); background: var(--surface); min-width: 0; }
.credential-card > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); min-height: var(--control-height); overflow-wrap: anywhere; }
.credential-card .form-grid, .credential-remove { padding: var(--space-3); margin: 0; }
.credential-card.is-removed { background: var(--surface-muted); color: var(--muted); }
.credential-card.is-removed [data-card-label] { text-decoration: line-through; }
.credentials-editor h3 { font-size: var(--font-body); margin: var(--space-4) 0 var(--space-2); }
.credential-issue, .credential-detail { border-top: 1px solid var(--divider); padding-block: var(--space-3); overflow-wrap: anywhere; }
.credential-tags, .credential-mini-tags { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block: var(--space-3); }
.credential-tags a, .credential-tag { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-control); padding: var(--space-1) var(--space-2); max-width: 100%; overflow-wrap: anywhere; color: inherit; background: var(--surface-muted); font-size: var(--font-small); }
.credential-tags a { min-height: var(--control-height); }
.credential-detail summary { min-height: var(--control-height); padding-block: var(--space-1); align-content: center; }
.credential-detail:target { outline: 2px solid var(--brand); outline-offset: var(--space-1); }
.credential-mini-tags { gap: var(--space-1); margin: 0; }
.invite-dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-menu); }
dialog::backdrop { background: var(--backdrop); }
.dialog-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--divider); }
.create-methods { border: 0; padding: 0; margin: var(--space-4) 0; display: grid; gap: var(--space-2); }
.create-methods legend { padding: 0; margin-bottom: var(--space-2); font-weight: 600; }
.create-method { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.create-method:hover { background: var(--surface-hover); }
.create-method:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.create-method span { display: grid; gap: var(--space-1); }
.create-method small { color: var(--muted); }
.invitation-panel { display: grid; gap: var(--space-3); }
.invitation-panel .detail-list, .invitation-panel .space-top { margin: 0; }
.invitation-panel > .field { grid-template-columns: 1fr; }
.invitation-management { border-top: 1px solid var(--divider); padding-top: var(--space-3); }
.invitation-danger { margin-left: auto; padding-left: var(--space-3); border-left: 1px solid var(--divider); }
.invitation-copy { gap: var(--space-2); }
.delete-panel { max-width: 640px; }

/* Public pages: compact content with comfortable touch controls. */
.public-main { padding: var(--space-6) var(--space-3); min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.public-main > .messages { max-width: 530px; width: 100%; }
.login-card, .fill-card { width: 100%; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.login-card { max-width: 390px; padding: var(--space-6); }
.login-card .brand { padding-bottom: var(--space-4); border-bottom: 1px solid var(--divider); }
.login-card h1 { margin: var(--space-4) 0 var(--space-1); }
.login-card form { margin-top: var(--space-4); }
.login-card .field { margin-bottom: var(--space-3); }
.login-card .button { margin-top: var(--space-2); }
.login-help { margin-top: var(--space-4); text-align: center; }
.fill-card { max-width: 530px; overflow: hidden; }
.fill-header { padding: var(--space-4); background: var(--brand-soft); border-bottom: 1px solid var(--brand-border); }
.fill-header h1 { margin-block: var(--space-3) var(--space-2); }
.fill-header h1:first-child { margin-top: 0; }
.fill-header p + p { margin-top: var(--space-2); }
.fill-header progress { appearance: none; display: block; width: 100%; height: var(--space-1); border: 0; margin-top: var(--space-2); background: var(--brand-border); }
.fill-header progress::-webkit-progress-bar { background: var(--brand-border); }
.fill-header progress::-webkit-progress-value { background: var(--brand); }
.fill-header progress::-moz-progress-bar { background: var(--brand); }
.step-caption { font-size: var(--font-small); font-weight: 600; color: var(--brand); margin-top: var(--space-3); }
.fill-form { padding: var(--space-4); }
.fill-form fieldset { padding: 0; margin: 0 0 var(--space-4); border: 0; min-width: 0; }
.fill-form legend { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-2); width: 100%; font-size: var(--font-section); font-weight: 600; margin-bottom: var(--space-3); }
.fill-form legend small { color: var(--muted); font-weight: 400; }
.fill-form .form-grid { grid-template-columns: 1fr; }
.fill-form .field { margin-bottom: var(--space-3); }
.fill-form .form-grid .field { margin-bottom: 0; }
.fill-form .credentials-editor { padding-inline: 0; }
.fill-form .control { font-size: var(--font-section); min-height: var(--touch-height); }
.fill-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.fill-actions > .button { flex: 1 1 100px; min-height: var(--touch-height); }
.autosave-status { padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--divider); }
.result-card, .access-card { padding: var(--space-4); }
.result-card { border-top: 3px solid var(--brand); text-align: center; }
.result-card img { margin-bottom: var(--space-3); }
.result-card h1, .access-card h1 { margin-block: var(--space-3); }
.access-card p { margin-bottom: var(--space-3); }
.result-timeline { text-align: left; padding-left: var(--space-6); margin-bottom: 0; }

/* Native desktop select menu; mobile keeps the platform picker. */
@supports (appearance: base-select) {
  @media (min-width: 761px) and (pointer: fine) {
    .filter-form select.control, .filter-form select.control::picker(select) { appearance: base-select; }
    .filter-form select.control { display: flex; align-items: center; }
    .roster-filters select.control > button { display: block; flex: 1; width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: start; }
    .roster-filters selectedcontent { display: block; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .filter-form select.control::picker-icon { display: none; }
    .filter-form select.control::picker(select) { margin-block: var(--space-1); padding: var(--space-1); min-width: anchor-size(width); max-width: calc(100vw - 24px); max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-menu); font: inherit; }
    .filter-form select.control option { display: flex; align-items: center; gap: var(--space-3); min-height: var(--control-height); padding: var(--space-1) var(--space-2); border-radius: var(--radius-control); white-space: normal; overflow-wrap: anywhere; cursor: pointer; }
    .filter-form select.control option:hover { background: var(--surface-muted); }
    .filter-form select.control option:checked { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
    .filter-form select.control option::checkmark { order: 1; margin-left: auto; }
  }
}

/* Responsive layout. Container thresholds follow available filter space. */
@container roster (max-width: 1199px) {
  .roster-filter-primary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .roster-filter-primary .filter-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
@container roster (max-width: 600px) {
  .roster-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .roster-filter-grid > label, .business-area-filter { display: grid; gap: var(--space-1); white-space: normal; }
  .roster-filter-primary .filter-search { grid-column: 1 / -1; }
  .more-filters .roster-filter-grid > label { grid-template-columns: 1fr; }
}
@media (min-width: 761px) {
  .panel-padding > div.field:not(.check-field) { grid-template-columns: var(--label-width) minmax(0, 1fr); gap: var(--space-1) var(--space-2); }
  .panel-padding > div.field > label { padding-top: var(--space-1); }
  .panel-padding > div.field:not(.check-field) > .help, .panel-padding > div.field:not(.check-field) > .field-error { grid-column: 2; }
  .panel-padding > .check-field { margin-left: calc(var(--label-width) + var(--space-2)); }
  .invitation-panel > div.field:not(.check-field) { grid-template-columns: 1fr; }
}
@media (min-width: 1100px) {
  .editor-panel .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .editor-panel .field:not(.check-field) { grid-template-columns: var(--label-width) minmax(0, 1fr); gap: var(--space-1) var(--space-2); }
  .editor-panel .field > label { padding-top: var(--space-1); }
  .editor-panel .form-grid > .check-field { padding-top: 0; }
  .editor-panel .field > .help, .editor-panel .field > .field-error { grid-column: 2; }
}
@media (min-width: 761px) and (max-width: 1099px) {
  .archive-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .header-nav { order: 3; width: 100%; }
}
@media (max-width: 760px), (pointer: coarse) {
  :root { --control-height: var(--touch-height); }
  .control, :where(input:not([type=hidden]):not([type=checkbox]):not([type=radio])), select, textarea { font-size: var(--font-section); }
  summary, .filter-chip, .tabs a, .credential-tags a { min-height: var(--touch-height); align-content: center; }
  .staff-table .col-actions { width: 164px; }
  .staff-table .roster-actions { gap: var(--space-2); }
  .staff-table .roster-actions > .text-link { min-width: var(--touch-height); }
}
@media (max-width: 760px) {
  .app-header { gap: var(--space-2); }
  .header-tools { width: 100%; justify-content: space-between; margin-left: 0; }
  .header-nav { order: 3; width: 100%; gap: var(--space-1); flex-wrap: nowrap; overflow-x: auto; }
  .header-nav .nav-item { padding-inline: var(--space-2); }
  .page-heading > div:first-child { flex-basis: 100%; }
  .form-grid, .detail-entry { grid-template-columns: 1fr; }
  .form-grid > .check-field { padding-top: 0; }
  .filter-row label { display: grid; flex: 1 1 140px; gap: var(--space-1); }
  .filter-row label:has(> input[type=checkbox]) { display: flex; }
  .filter-row label .control { width: 100%; min-width: 0; }
  .filter-search { flex-basis: 100% !important; }
  .filter-actions .button, .filter-row > .button { flex: 1; }
  .view-label { display: none; }
  .staff-table .col-person { width: 108px; }
  .action-bar { position: static; padding-bottom: max(var(--space-3), env(safe-area-inset-bottom)); }
  .action-bar > .row { width: 100%; }
  .action-bar .button { flex: 1 1 45%; }
  .create-actions { width: 100%; }
  .create-actions .button { flex: 1; }
  .archive-read-layout { grid-template-columns: minmax(0, 1fr); }
  .archive-directory { position: static; display: flex; flex-wrap: wrap; border-left: 0; border-bottom: 1px solid var(--border); }
  .archive-directory a { padding-inline: var(--space-2); }
  .archive-fields { grid-template-columns: minmax(0, 1fr); }
  .archive-read-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .archive-read-table, .archive-read-table tbody { display: block; }
  .archive-read-table tr { display: block; padding-block: var(--space-2); border-bottom: 1px solid var(--divider); }
  .archive-read-table td { display: grid; grid-template-columns: var(--label-width) minmax(0, 1fr); gap: var(--space-2); border: 0; padding: var(--space-1) 0; height: auto; }
  .archive-read-table td::before { content: attr(data-label); color: var(--muted); }
  .archive-read-table td[colspan] { display: block; }
  .archive-read-table td[colspan]::before { display: none; }
  .credential-card > summary { flex-wrap: wrap; }
  .review-values, .return-field-row { grid-template-columns: minmax(0, 1fr); }
  .invitation-danger { padding-left: 0; margin-left: 0; border-left: 0; flex-basis: 100%; border-top: 1px solid var(--divider); padding-top: var(--space-3); }
  .invitation-copy .button { flex: 1 1 auto; }
  .public-main { padding: var(--space-3); padding-bottom: max(var(--space-4), env(safe-area-inset-bottom)); justify-content: flex-start; }
  .login-card { padding: var(--space-4); }
}
@supports not selector(::details-content) {
  .more-filters { display: block; grid-column: 1 / -1; grid-row: 2; }
  .more-filters > summary { width: fit-content; margin-left: auto; }
}
@media (forced-colors: active) {
  select.control { appearance: auto; background-image: none; }
  .button, .status, .badge { border: 1px solid ButtonText; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

/* Account permissions use the same compact form and interaction tokens. */
.account-form > h2:not(:first-of-type) { margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--divider); }
.account-campuses { margin: 0 0 var(--space-3); padding: 0; border: 0; min-width: 0; }
.account-campuses legend { font-weight: 600; margin-bottom: var(--space-1); }
.account-campuses #id_campuses { display: flex; flex-wrap: wrap; gap: var(--space-3); padding: 0; border: 0; }

/* Account management. Keep row menus outside scroll-container clipping. */
.account-filters { align-items: flex-end; }
.account-filters label { flex-direction: column; align-items: stretch; gap: var(--space-1); }
.account-filters .filter-search { flex: 1 1 280px; max-width: 400px; }
.account-filters label .control { width: 100%; min-width: 128px; }
.table-scroll > table.account-table { min-width: 900px; }
.account-table td { height: var(--row-double); }
.account-table .roster-actions { flex-wrap: nowrap; gap: var(--space-1); }
.account-table .roster-actions > a, .account-table .roster-action-menu > summary { min-height: var(--control-height); padding: var(--space-1) var(--space-2); border-radius: var(--radius-control); white-space: nowrap; }
.account-table .roster-action-menu > summary { width: auto; gap: var(--space-1); font-size: var(--font-control); border: 1px solid var(--border); }
.account-table .roster-actions > a:hover { background: var(--surface-muted); text-decoration: none; }
.account-table .roster-actions > a:active, .account-table .roster-action-menu > summary:active { background: var(--surface-hover); }
.account-created { border-color: var(--success-border); }
.account-created h2 { color: var(--success); }
@media (max-width: 760px), (pointer: coarse) {
  .account-table .roster-actions > a, .account-table .roster-action-menu > summary, .account-table .staff-actions > a { min-height: var(--touch-height); }
  .account-table .roster-actions { gap: var(--space-2); }
  .account-filters .filter-search { max-width: none; }
}

.session-warning { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; max-width: calc(100vw - 32px); width: max-content; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; box-shadow: var(--shadow-menu); }
