:root {
  --brand: #1d4f7a;
  --brand-dark: #153c5f;
  --surface: #ffffff;
  --canvas: #f4f7fb;
  --border: #d8e0ea;
  --text: #1d2939;
  --muted: #667085;
  --success: #167a4a;
  --warning: #a66300;
  --danger: #b42318;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--text); font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--brand); text-decoration: none; font-weight: 600; }
a:hover { color: var(--brand-dark); text-decoration: underline; }

.topbar { background: #123b5a; color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.16); }
.topbar-inner { width: min(1440px, calc(100% - 2rem)); min-height: 4rem; margin: auto; display: flex; align-items: center; gap: 1rem; padding: .6rem 0; }
.brand { flex: 0 0 auto; color: #fff; font-size: 1.15rem; font-weight: 750; white-space: nowrap; }
.brand:hover { color: #fff; }
.topbar a { color: #eaf3fa; font-size: .875rem; }
.topbar a:hover { color: #fff; }
.active-school, .user-name, .nav-label { font-size: .82rem; color: #d3e4f1; }
.active-school { padding: .2rem .5rem; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; }
.user-menu { display: flex; align-items: center; gap: .7rem; margin-left: auto; white-space: nowrap; }
.inline-action-form, .sidebar-switch-form { display: inline; margin: 0; }
.button-link { min-height: auto; padding: 0; border: 0; background: transparent; color: var(--brand); font-size: inherit; font-weight: 600; }
.button-link:hover { background: transparent; color: var(--brand-dark); text-decoration: underline; }
.topbar .button-link { color: #eaf3fa; font-size: .875rem; }
.topbar .button-link:hover { color: #fff; }

.page-content, .flash-messages { width: min(1200px, calc(100% - 2rem)); margin-inline: auto; }
.page-content { padding-block: 2rem 3rem; }
.app-shell { display: grid; grid-template-columns: 16rem minmax(0, 1fr); width: min(1440px, 100%); margin-inline: auto; min-height: calc(100vh - 4rem); }
.app-sidebar { padding: 1.25rem 1rem; border-right: 1px solid var(--border); background: #fff; }
.sidebar-nav { display: grid; gap: 1rem; }
.sidebar-section { margin: 0; }
.sidebar-section h2 { margin: 0 0 .35rem; color: var(--muted); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.sidebar-link { display: block; padding: .42rem .55rem; border-radius: 5px; color: #344054; font-size: .9rem; font-weight: 600; }
.sidebar-link:hover { background: #edf3f8; color: var(--brand-dark); text-decoration: none; }
.sidebar-switch-form .sidebar-link { width: 100%; min-height: auto; border: 0; background: transparent; text-align: left; }
.sidebar-switch-form .sidebar-link:hover { background: #edf3f8; color: var(--brand-dark); }
.sidebar-link-subtle { margin-left: .45rem; padding-left: .7rem; border-left: 2px solid #d8e6f1; color: var(--muted); font-size: .84rem; }
.app-main.page-content { width: auto; margin: 0; padding: 2rem; }
.flash-messages { padding-top: 1rem; }
.flash { margin: 0 0 .5rem; padding: .75rem 1rem; background: #eef4ff; border-left: 4px solid var(--brand); border-radius: 4px; color: #17446a; }
.flash-success { background: #ecfdf3; border-color: var(--success); color: #05603a; }
.flash-warning { background: #fffaeb; border-color: var(--warning); color: #7a4900; }
.flash-error, .flash-danger { background: #fef3f2; border-color: var(--danger); color: #912018; }

h1, h2, h3 { color: #172b3a; line-height: 1.2; margin: 0 0 .75rem; }
h1 { font-size: clamp(1.65rem, 3vw, 2rem); }
h2 { font-size: 1.25rem; margin-top: 1.5rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.25rem; }
li + li { margin-top: .35rem; }
section { margin-bottom: 1.25rem; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; }
.page-intro { max-width: 52rem; margin: .35rem 0 0; color: var(--muted); }
.card, .page-content > section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.card > :last-child, .page-content > section > :last-child { margin-bottom: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card { padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stat-card dt, .stat-card .stat-label { color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat-card dd, .stat-card .stat-value { margin: .25rem 0 0; font-size: 1.55rem; font-weight: 700; color: #172b3a; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-block: 1rem; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.section-heading h2 { margin: 0; }
.section-heading p { margin: .25rem 0 0; color: var(--muted); font-size: .9rem; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.dashboard-grid > section { margin: 0; }
.action-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: .65rem; list-style: none; margin: 0; padding: 0; }
.action-tiles li { margin: 0; }
.action-tiles a { display: block; min-height: 100%; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 6px; background: #f8fafc; }
.action-tiles a:hover { background: #edf3f8; text-decoration: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.form-grid > div { margin: 0; }
.form-grid-heading, .follow-up-guidance { grid-column: 1 / -1; }
.form-grid-heading h2 { margin: 0; font-size: 1rem; }
.form-grid-heading p, .field-help { margin: .25rem 0 0; color: var(--muted); font-size: .88rem; }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; align-self: end; }
.follow-up-summary { border-left: 4px solid #8db7d5; }
.eyebrow { margin: 0 0 .35rem; color: var(--brand); font-size: .74rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.follow-up-guidance { padding: .85rem 1rem; border: 1px solid #d5e4f0; border-radius: 6px; background: #f5f9fc; color: #40556a; font-size: .9rem; }
.follow-up-guidance p { margin: 0; }
.follow-up-guidance p + p { margin-top: .35rem; }

button, input[type="submit"], input[type="button"], .button { appearance: none; display: inline-flex; align-items: center; justify-content: center; min-height: 2.4rem; padding: .45rem .85rem; border: 1px solid var(--brand); border-radius: 6px; background: var(--brand); color: #fff; cursor: pointer; font: inherit; font-weight: 650; text-decoration: none; }
button:hover, input[type="submit"]:hover, input[type="button"]:hover, .button:hover { background: var(--brand-dark); color: #fff; text-decoration: none; }
.button-secondary { border-color: #b8c5d4; background: #fff; color: var(--brand); }
.button-secondary:hover { background: #edf3f8; color: var(--brand-dark); }
.button-danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.button-danger:hover { background: #8f1b13; color: #fff; }
form { margin: 1rem 0; }
form > div { margin-bottom: 1rem; }
label { display: block; margin-bottom: .35rem; color: #344054; font-size: .9rem; font-weight: 650; }
label input[type="checkbox"], label input[type="radio"] { width: auto; margin-right: .35rem; }
input, select, textarea { width: 100%; max-width: 38rem; padding: .55rem .7rem; border: 1px solid #b8c5d4; border-radius: 6px; background: #fff; color: var(--text); font: inherit; }
textarea { min-height: 7rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(29,79,122,.18); border-color: var(--brand); }
form p label { display: inline-block; margin: 0 .75rem .5rem 0; vertical-align: top; }

.table-responsive { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; margin: 1rem 0; background: var(--surface); }
.table-responsive table { margin: 0; }
th, td { padding: .7rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #edf3f8; color: #344054; font-size: .8rem; letter-spacing: .02em; text-transform: uppercase; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
td form { display: inline; margin: 0 .25rem 0 0; }
td form button { min-height: 1.9rem; padding: .25rem .5rem; font-size: .8rem; }

dl { display: grid; grid-template-columns: minmax(9rem, .4fr) 1fr; gap: .5rem 1rem; margin: 0; }
dt { color: var(--muted); font-weight: 650; }
dd { margin: 0; }
.badge { display: inline-flex; align-items: center; padding: .15rem .5rem; border-radius: 999px; background: #e8edf3; color: #465364; font-size: .78rem; font-weight: 700; line-height: 1.4; }
.badge-success { background: #dff7e9; color: #086536; }
.badge-warning { background: #fff0cc; color: #875100; }
.badge-danger { background: #ffe4e1; color: #a22018; }
.badge-muted { background: #e8edf3; color: #526170; }
.empty-state { padding: 1.5rem; text-align: center; border: 1px dashed #b8c5d4; border-radius: var(--radius); background: #fafcff; color: var(--muted); }
.source-reference { color: var(--muted); font-size: .9rem; font-weight: 650; }
.empty-state > :last-child { margin-bottom: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 720px) {
  .topbar-inner { width: min(100% - 1.25rem, 1440px); align-items: flex-start; flex-wrap: wrap; padding-block: .75rem; }
  .user-menu { margin-left: auto; }
  .page-content, .flash-messages { width: min(100% - 1.25rem, 1200px); }
  .page-content { padding-top: 1.25rem; }
  .app-shell { display: block; width: 100%; min-height: 0; }
  .app-sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: 1rem .625rem; }
  .sidebar-nav { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: .75rem; }
  .sidebar-section h2 { margin-bottom: .2rem; }
  .app-main.page-content { width: min(100% - 1.25rem, 1200px); margin-inline: auto; padding: 1.25rem 0 2rem; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .card, .page-content > section { padding: 1rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
  dl { grid-template-columns: 1fr; gap: .15rem; }
  dd { margin-bottom: .55rem; }
  input, select, textarea { max-width: none; }
}
