:root {
  --red: #b5121b;
  --red-dark: #8c0e15;
  --blue: #205479;
  --blue-dark: #17394f;
  --ink: #161616;
  --muted: #525252;
  --line: #cbd0d2;
  --line-light: #e5e6e7;
  --surface: #ffffff;
  --background: #f4f4f4;
  --success: #38614a;
  --warning: #8a4b00;
  --danger: #b5121b;
  font-family: Inter, Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--background); }
button, input, select, textarea { font: inherit; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .25rem; font-size: clamp(1.5rem, 4vw, 2rem); line-height: 1.1; }
h2 { margin-bottom: .5rem; font-size: clamp(1.4rem, 3vw, 1.8rem); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: .45rem; color: var(--red); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

/* Authentication pages: Lancaster identity with GOV.UK-style form clarity. */
.auth-page { display: grid; place-items: center; padding: 1.5rem; background: #ededed; }
.auth-card { width: min(100%, 440px); padding: 2.5rem; border: 1px solid var(--line); border-top: 6px solid var(--red); background: var(--surface); }
.auth-logo { display: block; width: min(100%, 255px); height: auto; margin-bottom: 2rem; }
label { display: grid; gap: .45rem; margin-bottom: 1rem; font-size: .88rem; font-weight: 700; }
input, select, textarea { width: 100%; padding: .78rem .82rem; border: 2px solid #8d8d8d; border-radius: 0; background: white; color: var(--ink); }
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #fd9029; outline-offset: 0; border-color: var(--ink); }

.button { min-height: 42px; padding: .65rem 1rem; border: 1px solid transparent; border-radius: 0; font-weight: 750; cursor: pointer; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button.primary { width: 100%; background: var(--red); color: white; }
.button.primary:hover { background: var(--red-dark); }
.button.secondary { border-color: #8d8d8d; background: white; color: var(--ink); }
.button.secondary:hover { background: #e5e5e5; }
.button.danger { border-color: var(--danger); background: white; color: var(--danger); }
.button.danger:hover { background: #fff0f0; }
.text-button { display: block; margin: 1rem auto 0; border: 0; background: transparent; color: var(--red); text-decoration: underline; cursor: pointer; }
.message { min-height: 1.5rem; margin: 1rem 0; padding: .65rem 0; overflow-wrap: anywhere; }
.message.error { color: var(--danger); }
.message.success { color: var(--success); }

/* IBM Carbon-inspired application shell. */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; min-height: 92px; padding: 1rem 2rem; border-bottom: 5px solid var(--red); background: var(--blue-dark); color: white; }
.portal-brand { display: flex; align-items: center; gap: 1.25rem; }
.portal-brand h1 { color: white; }
.logo-panel { display: flex; align-items: center; width: 245px; min-height: 56px; padding: .55rem .75rem; background: white; }
.brand-logo { display: block; width: 100%; height: auto; }
.account-block { display: flex; align-items: center; gap: .8rem; font-size: .85rem; }
.account-block .button.secondary { border-color: white; background: transparent; color: white; }
.account-block .button.secondary:hover { background: white; color: var(--blue-dark); }
.role-pill { padding: .35rem .55rem; border: 1px solid #f3b2b6; border-radius: 0; background: white; color: var(--red-dark); font-weight: 800; }
.layout { display: grid; grid-template-columns: 245px minmax(0, 1fr); min-height: calc(100vh - 92px); }
.layout.student-layout { display: flex; width: 100%; justify-content: center; }
.student-layout .content { flex: 1 1 auto; width: 100%; max-width: 1120px; margin: 0 auto; padding-top: clamp(2rem, 6vw, 4.5rem); }
.student-layout #studentPortalSection { display: block; width: 100%; min-width: 0; }
.student-layout #studentPortalStatuses { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.student-layout .metric { min-width: 0; }
.student-layout .status { margin-top: .65rem; }
.sidebar { padding: 1.5rem 0; border-right: 1px solid #3d3d3d; background: #262626; }
.nav-button { width: 100%; min-height: 48px; margin: 0; padding: .8rem 1.35rem; border: 0; border-left: 4px solid transparent; background: transparent; color: #f4f4f4; text-align: left; cursor: pointer; }
.nav-button:hover { background: #393939; }
.nav-button.active { border-left-color: var(--red); background: #161616; color: white; font-weight: 800; }
.content { min-width: 0; padding: clamp(1.25rem, 4vw, 3rem); }
.panel-section { padding: clamp(1.25rem, 3vw, 2rem); border: 1px solid var(--line); background: white; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-top: 2rem; border: 1px solid var(--line); }
.metric { min-height: 120px; padding: 1.25rem; border-right: 1px solid var(--line); background: white; }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: .84rem; }
.metric strong { display: block; margin-top: .45rem; font-size: 2rem; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 1.5rem 0 2rem; padding: 1.25rem; border: 1px solid var(--line); background: #f4f4f4; }
.form-action { display: flex; align-items: end; padding-bottom: 1rem; }
.card-list { display: grid; gap: 0; border: 1px solid var(--line); }
.list-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; border-bottom: 1px solid var(--line-light); background: white; }
.list-card:last-child { border-bottom: 0; }
.list-card p { margin: .25rem 0 0; color: var(--muted); font-size: .83rem; }
.button-row { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0; }
.button-row .button { width: auto; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: white; font-size: .88rem; }
th, td { padding: .85rem; border-bottom: 1px solid var(--line-light); text-align: left; vertical-align: top; }
th { background: #262626; color: white; font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; }
tbody tr:hover { background: #f4f4f4; }
tbody tr:last-child td { border-bottom: 0; }
td small { display: block; margin-top: .2rem; color: var(--muted); }
.status { display: inline-block; padding: .3rem .5rem; border: 1px solid currentColor; border-radius: 0; background: white; font-size: .74rem; font-weight: 800; }
.status.cleared { color: var(--success); }
.status.pending { color: var(--warning); }
.status.rejected { color: var(--danger); }
.status.not_required { color: var(--muted); }
.search-label { max-width: 380px; margin: 1.5rem 0; }
.toolbar { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.student-filters { display: grid; grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(150px, 1fr)) auto; gap: 1rem; align-items: end; margin: 1.5rem 0 1rem; padding: 1rem; border: 1px solid var(--line); background: #f4f4f4; }
.student-filters label, .student-filters .search-label { max-width: none; margin: 0; }
.student-filters .button { margin: 0; white-space: nowrap; }
.edit-dialog { width: min(92vw, 540px); padding: 2rem; border: 1px solid var(--line); border-top: 6px solid var(--red); border-radius: 0; }
.edit-dialog::backdrop { background: rgba(0, 0, 0, .62); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; }
.dialog-actions .button { width: auto; }
.privacy-note { margin-top: 1.5rem; padding: 1rem; border-left: 4px solid var(--blue); background: #ededed; color: var(--muted); font-size: .85rem; }
.table-actions { display: flex; flex-wrap: wrap; gap: .4rem; min-width: 190px; }
.table-actions .button { min-height: 36px; padding: .45rem .65rem; font-size: .78rem; }

@media (max-width: 820px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 1rem; }
  .portal-brand { width: 100%; align-items: flex-start; flex-direction: column; gap: .75rem; }
  .logo-panel { width: min(100%, 245px); }
  .account-block { width: 100%; align-items: flex-start; flex-wrap: wrap; }
  .layout { grid-template-columns: 1fr; }
  .student-layout .content { padding-top: 1.5rem; }
  .student-layout #studentPortalStatuses { grid-template-columns: 1fr; }
  .sidebar { display: flex; gap: 0; overflow-x: auto; padding: 0; border-right: 0; border-bottom: 1px solid #3d3d3d; }
  .nav-button { min-width: max-content; border-left: 0; border-bottom: 4px solid transparent; }
  .nav-button.active { border-left-color: transparent; border-bottom-color: var(--red); }
  .form-grid, .metric-grid { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .student-filters { grid-template-columns: 1fr 1fr; }
  .student-filters .button { width: 100%; }
}

@media (max-width: 520px) {
  .auth-page { padding: 0; place-items: start stretch; }
  .auth-card { width: 100%; min-height: 100vh; padding: 1.5rem; border-right: 0; border-bottom: 0; border-left: 0; }
  .content { padding: 1rem; }
  .panel-section { padding: 1rem; }
  .student-filters { grid-template-columns: 1fr; }
}
