/* Civadelia shared components.
   Loaded right after tokens.css. Built only from tokens, so every component
   follows the institution colour and dark mode automatically.

   Every class is prefixed ui- so nothing here collides with the legacy
   .btn / .card / .table / .co-* / .gs-* rules. Look: neutral and flat, with the
   brand colour reserved for primary actions, focus, links and highlights
   (decision 4). The stats row and quick-link cards follow the student and
   lecturer dashboard patterns (decision 10).

   Partials: templates/includes/ui/page_header.html, stat.html, empty_state.html. */

/* Text for screen readers only. */
.ui-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Demo banner: every page of a demo school and its login page (docs/demo_environments.md).
   Warning colours, never the institution's, so it reads the same in every school. */
.ui-demo-banner {
  margin: 0;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-align: center;
}

/* Page header: unboxed, title and description on the left, actions on the right. */
.ui-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  margin: var(--space-6) 0;
}
.ui-page-header-copy {
  min-width: 0;
  max-width: 72ch;
}
.ui-page-header h1 {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: -.02em;
}
.ui-page-header p {
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
}
.ui-page-header-actions {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  gap: var(--space-2);
}

/* Breadcrumb row: the first thing on the page, directly above the title. The trail sits on the
   left and the active institution badge on the right. */
.ui-page-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-6) 0 var(--space-3);
}
.ui-page-context + .ui-page-header {
  margin-top: 0;
}
/* No taller than the trail, so the title keeps its position. */
.ui-badge.ui-institution-badge {
  flex-shrink: 0;
  min-height: 0;
  margin-left: auto;
  padding-block: 0;
}
.ui-breadcrumb {
  min-width: 0;
  font-size: var(--fs-sm);
}
.ui-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.ui-breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
}
.ui-breadcrumb li + li::before {
  content: "›";
  color: var(--text-faint);
}
.ui-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}
.ui-breadcrumb a:hover {
  color: var(--brand-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ui-breadcrumb a:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.ui-breadcrumb [aria-current="page"] {
  color: var(--text);
  font-weight: var(--fw-medium);
}

/* Buttons: 36px tall, secondary by default. */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.ui-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}
.ui-btn:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}
.ui-btn:disabled,
.ui-btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
}
.ui-btn-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-brand);
}
.ui-btn-primary:hover {
  border-color: var(--brand-hover);
  background: var(--brand-hover);
  color: var(--on-brand);
}
.ui-btn-ghost {
  border-color: transparent;
  background: transparent;
}
.ui-btn-ghost:hover {
  border-color: transparent;
  background: var(--surface-hover);
}
.ui-btn-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--on-danger);
}
.ui-btn-danger:hover {
  border-color: var(--danger-hover);
  background: var(--danger-hover);
  color: var(--on-danger);
}
.ui-btn-sm {
  min-height: 30px;
  padding: 0 var(--space-3);
}

/* Cards. .ui-card-link is the student and lecturer dashboard's quick-link card: the icon on the
   left of its title and one-line text (decision 10). */
.ui-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
}
.ui-card-body {
  padding: var(--space-5);
}
.ui-card-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: center;
  align-items: center;
  gap: 2px var(--space-3);
  padding: var(--space-4);
  text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease;
}
.ui-card-link > .ui-card-icon {
  grid-row: 1 / span 2;
}
.ui-card-link > :not(.ui-card-icon) {
  grid-column: 2;
}
.ui-card-link:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}
.ui-card-link:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}
.ui-card-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--brand-soft);
  color: var(--brand-text);
}
.ui-card-title {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
}
.ui-card-text {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
}
.ui-card-footer {
  margin-top: auto;
  padding-top: var(--space-2);
}
.ui-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}
/* A row of quick links shares the width evenly, four across on a desktop dashboard. */
.ui-card-grid:has(> .ui-card-link) {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.ui-card-grid + .ui-stats {
  margin-top: var(--space-4);
}
/* Split: two cards side by side, e.g. a record's summary next to its form; stacks on narrow screens. */
.ui-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  align-items: start;
}
@media (max-width: 960px) {
  .ui-split {
    grid-template-columns: 1fr;
  }
}

/* Overview cards: the pre-Phase-2 operations-overview card (2 per row, title,
   description, bold status badge at the bottom), built from tokens so the
   badge and hover follow the institution colour. Reuse on any area overview. */
.ui-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.ui-overview-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 142px;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: background-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.ui-overview-card:hover {
  background: var(--brand-faint);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 15%, transparent), 0 6px 19px color-mix(in srgb, var(--brand) 15%, transparent);
  color: var(--text);
  transform: translateY(-1px);
}
.ui-overview-card:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 3px;
}
.ui-overview-card-title {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: -.02em;
}
.ui-overview-card-text {
  max-width: 92%;
  margin: var(--space-2) 0 var(--space-3);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.ui-overview-card .ui-badge {
  margin-top: auto;
}
.ui-overview-grid > .ui-empty-state {
  grid-column: 1 / -1;
}
@media (prefers-reduced-motion: reduce) {
  .ui-overview-card {
    transition: none;
  }
  .ui-overview-card:hover {
    transform: none;
  }
}

/* Badges: neutral by default; brand uses the institution colour. */
.ui-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 100%;
  min-height: 22px;
  padding: 2px var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.3;
}
.ui-badge-brand {
  border-color: transparent;
  background: var(--brand-soft);
  color: var(--brand-text);
}
.ui-badge-warning {
  border-color: var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning-text);
}
/* Bold badge: the status pill of the overview cards; warnings get a "!" mark. */
.ui-badge-strong {
  min-height: 25px;
  padding: var(--space-1) var(--space-2);
  border-color: var(--border);
  font-weight: var(--fw-bold);
  line-height: 1.25;
}
.ui-badge-strong.ui-badge-brand {
  border-color: color-mix(in srgb, var(--brand) 30%, var(--surface));
}
.ui-badge-strong.ui-badge-warning {
  border-color: var(--warning-border);
}
.ui-badge-strong.ui-badge-warning::before {
  content: "!";
  display: inline-grid;
  place-items: center;
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  margin-right: 1px;
  border-radius: var(--radius-full);
  background: var(--warning-accent);
  color: var(--on-warning-accent);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  line-height: 1;
}
.ui-badge-danger {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger-text);
}

/* Stats: one row split by dividers, like the dashboard overview. */
.ui-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin: 0 0 var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.ui-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: var(--space-4) var(--space-5);
  border-left: 1px solid var(--border-subtle);
  margin-left: -1px;
  color: var(--text);
  text-decoration: none;
}
a.ui-stat:hover {
  background: var(--brand-faint);
  color: var(--text);
}
.ui-stat-label {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.ui-stat-value {
  color: var(--text);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  font-variant-numeric: tabular-nums;
}
.ui-stat-note {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* Toolbar: filter bar above a table; the search field takes the spare width. */
.ui-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
}
.ui-toolbar-search {
  flex: 1 1 240px;
}
.ui-toolbar-end {
  margin-left: auto;
}

/* Tables: dense rows, small muted header, right-aligned numbers. */
.ui-table-wrap {
  position: relative; /* keeps absolutely placed content (.ui-sr-only labels) inside the scroll area */
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow-x: auto;
}
.ui-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.ui-table th {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-align: left;
  white-space: nowrap;
}
.ui-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.ui-table tbody tr:last-child td {
  border-bottom: 0;
}
.ui-table tbody tr:hover td {
  background: var(--surface-hover);
}
.ui-table .ui-num {
  text-align: right;
}

/* Form fields. .ui-field-grid lays fields out in two columns; .ui-form-body stacks a form's parts. */
.ui-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.ui-field-grid > .ui-field-full {
  grid-column: 1 / -1;
}
.ui-form-body {
  display: grid;
  gap: var(--space-4);
}
.ui-checkbox {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: var(--lh-normal);
  cursor: pointer;
}
.ui-checkbox input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--brand);
}
.ui-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}
.ui-field-label {
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}
.ui-field-help {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
}
.ui-field-error {
  color: var(--danger-text);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}
.ui-input,
.ui-select {
  width: 100%;
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-base);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea.ui-input {
  min-height: 88px;
  padding: var(--space-2) var(--space-3);
  line-height: var(--lh-normal);
  resize: vertical;
}
.ui-input::placeholder {
  color: var(--text-faint);
}
.ui-input:hover,
.ui-select:hover {
  border-color: var(--border-strong);
}
.ui-input:focus,
.ui-select:focus {
  border-color: var(--brand-text);
  outline: 0;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.ui-field-invalid .ui-input,
.ui-field-invalid .ui-select {
  border-color: var(--danger);
}
/* File chooser: the browser's native control, visible and keyboard accessible. */
.ui-file {
  display: block;
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.ui-file::file-selector-button {
  margin-right: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: var(--fw-medium);
  cursor: pointer;
}
.ui-file:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}
.ui-field-invalid .ui-file {
  border-color: var(--danger);
}
/* Repeatable row: one entry of a list the user can add to before saving (e.g. extra references). */
.ui-repeat-row {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-subtle);
}
.ui-repeat-row .ui-section-head {
  align-items: center;
}

/* Card sections: a heading and short explanation at the top of a card. */
.ui-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin: 0 0 var(--space-4);
}
.ui-section-head .ui-card-title {
  font-size: var(--fs-md);
}
.ui-section-head .ui-card-text {
  margin-top: var(--space-1);
}

/* Stack: vertical rhythm between the cards of a page. */
.ui-stack {
  display: grid;
  gap: var(--space-4);
}
/* Grid items default to their content's width; a wide table must scroll inside its
   .ui-table-wrap instead of widening the card and the page. */
.ui-stack > *,
.ui-split > * {
  min-width: 0;
}

/* Checklist: one row per check with its status, title, detail and next action. */
.ui-checklist {
  margin: 0;
  padding: 0;
  list-style: none;
}
.ui-check-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border-subtle);
}
.ui-check-item:first-child {
  border-top: 0;
  padding-top: 0;
}
.ui-check-item:last-child {
  padding-bottom: 0;
}
.ui-check-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-full);
  background: var(--warning-soft);
  color: var(--warning-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}
.ui-check-item.ui-check-ready .ui-check-icon {
  border-color: transparent;
  background: var(--brand-soft);
  color: var(--brand-text);
}
.ui-check-title {
  display: block;
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
}
.ui-check-detail {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
}
.ui-check-meta {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* Form actions: sit after the last section in normal flow, never over the fields. */
.ui-form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

/* Text links inside cards and lists. */
.ui-link {
  color: var(--brand-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-decoration: none;
}
.ui-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ui-link-danger {
  color: var(--danger-text);
}
.ui-text-muted {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* Alerts: a short notice in the page flow. Neutral by default; warning and danger use the
   status tokens and are never institution-coloured. A leading <strong> reads as its title. */
.ui-alert {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
}
.ui-alert-warning {
  border-color: var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning-text);
}
.ui-alert-danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--surface));
  background: var(--danger-soft);
  color: var(--danger-text);
}

/* Summary: label/value pairs, e.g. what a confirmation step is about to change. */
.ui-summary {
  display: grid;
  grid-template-columns: minmax(140px, max-content) minmax(0, 1fr);
  gap: var(--space-2) var(--space-6);
  margin: 0;
  font-size: var(--fs-sm);
}
.ui-summary > div {
  display: contents;
}
.ui-summary dt {
  color: var(--text-muted);
}
.ui-summary dd {
  margin: 0;
  color: var(--text);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}

/* Details: extra information a row or card can expand, e.g. before/after values. */
.ui-details {
  margin-top: var(--space-2);
}
.ui-details > summary {
  color: var(--brand-text);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  cursor: pointer;
}
.ui-details > summary:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}
.ui-details[open] > summary {
  margin-bottom: var(--space-2);
}

/* Editable tables (e.g. the grade table): a select in a cell keeps room for its value and
   arrow. Stated strongly enough to beat the legacy sheets' min-width: 0 on selects. */
.ui-table-wrap table.ui-table select.ui-select {
  min-width: 5.5rem;
}

/* Meter list: a label and count over a bar, one per category (report distributions).
   The bar width comes from the data: <span style="width: 40%">. */
.ui-meter-list {
  display: grid;
  gap: var(--space-3);
}
.ui-meter-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--fs-sm);
}
.ui-meter-head b {
  font-weight: var(--fw-semibold);
}
.ui-meter-track {
  height: 6px;
  margin-top: var(--space-1);
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}
.ui-meter-track > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
}

/* Table cells: a primary line and a muted detail line. */
.ui-table .ui-cell-detail {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
.ui-table .ui-badge {
  white-space: nowrap;
}
.ui-table .ui-cell-actions {
  text-align: right;
  white-space: nowrap;
}
.ui-table .ui-cell-actions form {
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
}
/* Several actions in one cell, e.g. Grade, Edit and Delete. */
.ui-table .ui-cell-actions > * + * {
  margin-left: var(--space-3);
}

/* Empty state: says what is missing and offers the next action. */
.ui-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-10) var(--space-6);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}
.ui-empty-state-title {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
}
.ui-empty-state-text {
  max-width: 48ch;
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
}
.ui-empty-state-sm {
  padding: var(--space-5) var(--space-4);
}
.ui-empty-state-actions {
  margin-top: var(--space-2);
}
.ui-card-grid > .ui-empty-state {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .ui-overview-grid,
  .ui-field-grid {
    grid-template-columns: 1fr;
  }
  .ui-page-header {
    flex-direction: column;
    gap: var(--space-3);
  }
  .ui-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ui-stat {
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: -1px;
  }
}

/* A document shown beside a form, e.g. an uploaded proof of payment. */
.ui-doc-frame { width: 100%; min-height: 520px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.ui-doc-image { max-width: 100%; height: auto; border-radius: var(--radius-md); }

/* Shared list (templates/includes/ui/data_table.html): filter chips with counts, sortable headers, pager. */
.ui-chip-groups {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.ui-chip-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.ui-chip-group-label {
  min-width: 7rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold, 600);
}
.ui-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  text-decoration: none;
}
.ui-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.ui-chip:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}
.ui-chip-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: var(--fw-semibold, 600);
}
.ui-chip-count {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}
.ui-chip-active .ui-chip-count {
  color: var(--brand-text);
}
.ui-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}
.ui-sort:hover {
  color: var(--brand-text);
}
.ui-sort-mark {
  font-size: var(--fs-xs);
  color: var(--brand-text);
}
.ui-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-top: var(--space-3);
}
.ui-pager-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}
.ui-pager-link,
.ui-pager-current {
  min-width: 30px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  text-align: center;
  text-decoration: none;
}
.ui-pager-link {
  color: var(--brand-text);
}
.ui-pager-link:hover {
  background: var(--surface-hover);
}
.ui-pager-current {
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: var(--fw-semibold, 600);
}

/* A2: class lecturer picker (static/portal/lecturer_picker.js). */
.ui-lecturer-picker {
  display: grid;
  gap: var(--space-2);
}
.ui-lecturer-picker-options {
  display: grid;
  gap: var(--space-1);
