:root {
  --michigan-blue: #00274c;
  --michigan-blue-light: #173f64;
  --michigan-maize: #ffcb05;
  --ink: #1f2933;
  --muted: #5c6670;
  --line: #d9dde2;
  /* Control borders (inputs): 3:1+ against white and the #eaf1f7 row
     tint, as WCAG 1.4.11 asks of a control's boundary. */
  --line-strong: #767f88;
  --bg: #f4f5f6;
  --surface: #ffffff;
  --surface-subtle: #f8f9fa;
  --accent: #005ea8;
  --accent-hover: #004b87;
  --ok: #137752;
  --warn: #a54c00;
  --bad: #b32d2e;
  --shadow: 0 1px 2px rgb(0 39 76 / 8%);
  --content-width: 1400px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  display: flex;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  flex-direction: column;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

.skip-link {
  position: fixed;
  z-index: 100;
  top: .5rem;
  left: .5rem;
  padding: .55rem .8rem;
  color: var(--michigan-blue);
  background: var(--michigan-maize);
  font-weight: 700;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.site-header { background: var(--michigan-blue); }
.masthead { border-bottom: 4px solid var(--michigan-maize); }
.masthead-inner,
.nav-inner {
  width: min(100%, var(--content-width));
  margin: 0 auto;
  padding-inline: 1.5rem;
}
.masthead-inner {
  display: flex;
  min-height: 94px;
  align-items: center;
  gap: 1.35rem;
}
.unit-brand {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  color: white;
}
.unit-brand img {
  display: block;
  width: 76px;
  height: 65px;
  object-fit: contain;
}
.app-identity {
  display: flex;
  min-width: 0;
  padding-left: 1.35rem;
  border-left: 1px solid rgb(255 255 255 / 35%);
  color: white;
  flex-direction: column;
}
.app-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.15;
}
.app-description {
  margin-top: .2rem;
  color: #dbe5ee;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.primary-nav {
  color: white;
  background: var(--michigan-blue-light);
  box-shadow: 0 2px 5px rgb(0 0 0 / 14%);
}
.nav-inner {
  display: flex;
  min-height: 48px;
  align-items: stretch;
  justify-content: space-between;
  gap: 1rem;
}
.nav-links,
.nav-tools {
  display: flex;
  align-items: center;
}
.nav-links { min-width: 0; }
.nav-links a {
  display: flex;
  min-height: 48px;
  padding: 0 .8rem;
  align-items: center;
  border-bottom: 4px solid transparent;
  color: white;
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.nav-links a:hover {
  color: white;
  background: rgb(255 255 255 / 8%);
}
.nav-links a.active {
  border-bottom-color: var(--michigan-maize);
  color: var(--michigan-maize);
}
.nav-more {
  position: relative;
  display: flex;
  align-items: stretch;
}
.nav-more summary {
  display: flex;
  min-height: 48px;
  padding: 0 .8rem;
  align-items: center;
  border-bottom: 4px solid transparent;
  color: white;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 700;
  list-style: none;
  user-select: none;
  white-space: nowrap;
}
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more summary::after { margin-left: .35rem; content: "▾"; }
.nav-more summary:hover,
.nav-more[open] summary { background: rgb(255 255 255 / 8%); }
.nav-more summary.active {
  border-bottom-color: var(--michigan-maize);
  color: var(--michigan-maize);
}
.nav-more .nav-menu {
  position: absolute;
  z-index: 60;
  top: 100%;
  left: 0;
  min-width: 12rem;
  padding: .25rem 0;
  border-radius: 0 0 6px 6px;
  background: var(--michigan-blue-light);
  box-shadow: 0 8px 18px rgb(0 0 0 / 30%);
}
.nav-more .nav-menu a {
  min-height: 42px;
  border-bottom: none;
  border-left: 4px solid transparent;
}
.nav-more .nav-menu a.active {
  border-left-color: var(--michigan-maize);
}

.nav-tools {
  flex: 0 0 auto;
  gap: .55rem;
  font-size: .78rem;
}
.nav-tools label,
.user-name { color: #dbe5ee; }
.nav-tools select {
  min-height: 32px;
  border-color: #8ea1b2;
  font-size: .8rem;
}
.nav-tools form { display: flex; margin: 0; }
.nav-tools .nav-logout {
  min-height: 32px;
  border-color: #8ea1b2;
  color: white;
  background: transparent;
  font-size: .8rem;
}
.nav-tools .nav-logout:hover { background: rgb(255 255 255 / 10%); }
.nav-tools .nav-search input {
  min-height: 32px;
  width: 9.5rem;
  border-color: #8ea1b2;
  background: transparent;
  color: white;
  font-size: .8rem;
}
.nav-tools .nav-search input::placeholder { color: #dbe5ee; }

main {
  width: min(100%, var(--content-width));
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1 1 auto;
}

h1, h2, h3 { color: var(--michigan-blue); }
h1 {
  margin: 0 0 1.15rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.75rem;
  line-height: 1.2;
}
h2 {
  margin: 1.8rem 0 .7rem;
  font-size: 1.12rem;
  line-height: 1.3;
}
h3 {
  margin: 1.35rem 0 .55rem;
  font-size: .95rem;
  line-height: 1.35;
}
h1 .muted,
h2 .muted,
h3.muted,
h3 .muted {
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
  font-size: .78em;
  font-weight: 400;
}

table {
  width: 100%;
  border: 1px solid var(--line);
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}
th,
td {
  padding: .58rem .7rem;
  border-bottom: 1px solid var(--line);
  font-size: .875rem;
  text-align: left;
  vertical-align: top;
}
th {
  position: sticky;
  z-index: 1;
  top: 0;
  color: var(--michigan-blue);
  background: #e8edf2;
  font-weight: 700;
}
tr:last-child > td,
tbody:last-child tr:last-child > th { border-bottom: 0; }
tbody tr:hover > td,
tbody tr:hover > th { background: #f5f8fa; }

.filters {
  display: flex;
  margin-bottom: 1rem;
  padding: .8rem;
  align-items: end;
  border: 1px solid var(--line);
  border-left: 4px solid var(--michigan-maize);
  background: var(--surface);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  gap: .7rem;
}
.filters label,
.filters legend,
.edit-form label,
.edit-form legend {
  display: block;
  margin-bottom: .2rem;
  color: #4b5661;
  font-size: .75rem;
  font-weight: 700;
}
/* Django renders a radio group as fieldset + legend, so the legend IS the
   field label and needs the same treatment; the browser's default fieldset
   box would otherwise indent and outline the question. */
.filters fieldset,
.edit-form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}
/* A radio or checkbox label is a choice, not a field label: normal weight,
   on one line with its control. */
.filters label:has(input[type="checkbox"]),
.filters label:has(input[type="radio"]),
.edit-form label:has(input[type="checkbox"]),
.edit-form label:has(input[type="radio"]) {
  display: flex;
  margin: .18rem 0;
  align-items: center;
  gap: .35rem;
  font-weight: 400;
}

select,
input[type="text"],
input[type="number"],
input[type="password"],
textarea {
  min-height: 36px;
  padding: .4rem .55rem;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: .875rem;
}
textarea { resize: vertical; }
input[type="checkbox"] { accent-color: var(--michigan-blue); }
select:hover,
input:hover,
textarea:hover { border-color: #4b5661; }
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  /* Navy on the light page (15:1); maize alone was 1.5:1 on white,
     under WCAG 1.4.11's 3:1. The navy header and footer keep maize. */
  outline: 3px solid var(--michigan-blue);
  outline-offset: 2px;
}
.site-header :focus-visible,
.site-footer :focus-visible { outline-color: var(--michigan-maize); }

button {
  min-height: 36px;
  padding: .42rem .8rem;
  border: 2px solid var(--michigan-blue);
  border-radius: 3px;
  color: white;
  background: var(--michigan-blue);
  cursor: pointer;
  font: inherit;
  font-size: .875rem;
  font-weight: 700;
}
button:hover { border-color: var(--michigan-blue-light); background: var(--michigan-blue-light); }
button:active { transform: translateY(1px); }
button.quiet {
  color: var(--michigan-blue);
  background: var(--surface);
}
button.quiet:hover { background: #e8edf2; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--bad); font-weight: 700; }
.pos { color: var(--warn); }
.zero { color: var(--ok); }
.muted { color: var(--muted); }
.error { color: var(--bad); }
ul.errorlist {
  margin: .2rem 0 .4rem;
  padding: 0;
  list-style: none;
  color: var(--bad);
  font-size: .85rem;
}
ul.errorlist.nonfield { margin-bottom: .75rem; }
.notes { white-space: pre-wrap; }

.pill {
  display: inline-block;
  padding: .12rem .45rem;
  border: 1px solid #b5c8da;
  border-radius: 999px;
  color: var(--michigan-blue);
  background: #eaf1f7;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.35;
}
.pill.ph {
  border-color: #e0b45c;
  color: #704400;
  background: #fff4d3;
}

.login-box {
  max-width: 24rem;
  margin: 3.5rem auto;
  padding: 1.75rem;
  border: 1px solid var(--line);
  border-top: 5px solid var(--michigan-maize);
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(0 39 76 / 10%);
}
.login-box h1 { margin-bottom: .4rem; }
.login-box h1 + p:not(.error) { margin-top: 0; }
.login-box label { display: block; margin-bottom: .25rem; color: #4b5661; font-size: .8rem; font-weight: 700; }
.login-box input { width: 100%; }
.login-box button { width: 100%; margin-top: .5rem; }

.board {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.1rem;
}
.board section { min-width: 0; }
.board h2 {
  margin-top: .35rem;
  padding-bottom: .45rem;
  border-bottom: 2px solid var(--michigan-blue);
  font-size: 1rem;
}
.cards { display: flex; flex-direction: column; gap: .5rem; }
.card {
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card.person { border-left: 4px solid #5b7f95; }
.card.person.dropzone-active { outline: 3px dashed var(--michigan-maize); outline-offset: 1px; }
.card .head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
}
.meter { color: var(--michigan-blue); font-variant-numeric: tabular-nums; font-weight: 700; }
.meter.ok { color: var(--ok); }
.meter.room { color: var(--warn); }
/* Over-assigned deliberately has no .meter modifier (never red). */
.chip {
  display: inline-flex;
  margin: .18rem .2rem 0 0;
  padding: .12rem .45rem;
  align-items: center;
  border: 1px solid #c6d0d9;
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface-subtle);
  font-size: .76rem;
  gap: .3rem;
  text-decoration: none;
}
a.chip:hover { border-color: var(--accent); color: var(--accent-hover); background: #edf5fb; }
.chip form { display: inline; }
.chip button {
  min-height: 0;
  padding: 0;
  border: 0;
  color: var(--bad);
  background: transparent;
  font-size: .95rem;
  line-height: 1;
}
.chip button:hover { color: #7f1d1d; background: transparent; }
.course-card { border-left: 4px solid var(--michigan-maize); cursor: grab; }
.course-card:hover { border-color: #9da9b4; border-left-color: var(--michigan-maize); box-shadow: 0 2px 7px rgb(0 39 76 / 13%); }
.course-card.assigned { opacity: .72; }
.course-card.armed { outline: 3px solid var(--michigan-maize); outline-offset: 1px; opacity: 1; }
.warning-banner {
  margin-top: .35rem;
  padding: .5rem .65rem;
  border-left: 4px solid var(--bad);
  border-radius: 2px;
  color: #7f1d1d;
  background: #fdf0f0;
  font-size: .8rem;
}
.board-courses { max-height: 75vh; padding: 1px; overflow-y: auto; }

/* Scenario (what-if plan) cues: a banner on planning pages and a tinted
   plan switcher in the nav, so nobody edits a scenario thinking it is
   the real plan. */
.scenario-banner {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .6rem;
  margin: 0 0 1rem;
  padding: .55rem .7rem;
  border: 1px solid #e5c76b;
  border-left-width: 4px;
  border-radius: 2px;
  background: #fff8e1;
  font-size: .85rem;
}
.scenario-banner-label {
  text-transform: uppercase; letter-spacing: .04em; font-size: .7rem;
  font-weight: 600; color: #7a5a00;
}
.scenario-banner-links { margin-left: auto; display: flex; gap: .75rem; }
.nav-tools select.in-scenario { background: #ffcb05; color: #00274c; font-weight: 600; }
.nav-plan-note { font-size: .7rem; color: #dbe5ee; white-space: nowrap; cursor: help; }
tr.current-plan td { background: #fff8e1; }
.scenario-actions { white-space: nowrap; }
.scenario-actions > * + * { margin-left: .5rem; }
.inline-details { display: inline-block; }
.inline-details summary { cursor: pointer; color: var(--michigan-blue); text-decoration: underline; }
.inline-form { display: inline-flex; gap: .3rem; margin: .3rem 0 0; }
.inline-form input { width: 14rem; }

/* Flash messages (django.contrib.messages) — one style per level. */
.flash-messages { margin-bottom: 1rem; }
.flash {
  margin-bottom: .5rem;
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 2px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: .84rem;
}
.flash:last-child { margin-bottom: 0; }
.flash-success {
  border-color: #b7dfc9;
  border-left-color: var(--ok);
  color: #0d5c3f;
  background: #f0fdf4;
}
.flash-info,
.flash-debug {
  border-color: #b5c8da;
  border-left-color: var(--accent);
  color: #084b7a;
  background: #eef5fb;
}
.flash-warning {
  border-color: #ecd3b4;
  border-left-color: var(--warn);
  color: #7a3c00;
  background: #fdf6ec;
}
.flash-error {
  border-color: #eec7c7;
  border-left-color: var(--bad);
  color: #7f1d1d;
  background: #fdf0f0;
}

.summary-strip {
  display: flex;
  margin-bottom: 1rem;
  padding: .65rem .8rem;
  align-items: center;
  border: 1px solid var(--line);
  border-top: 3px solid var(--michigan-maize);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: .84rem;
  flex-wrap: wrap;
  gap: .65rem 1.5rem;
}
.summary-strip strong { color: var(--michigan-blue); font-variant-numeric: tabular-nums; }
.summary-strip strong.neg { color: var(--bad); }
.summary-strip form { margin: 0; }
.stat-cards {
  display: grid;
  margin-bottom: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: .75rem;
}
.stat-cards .card {
  min-height: 92px;
  padding: .8rem 1rem;
  border-top: 4px solid var(--michigan-maize);
}
.stat-cards .card .big {
  margin-top: .15rem;
  color: var(--michigan-blue);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  font-weight: 700;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.inline-edit { display: inline-flex; align-items: center; gap: .3rem; }
.inline-edit input { width: 5rem; }
.edit-form {
  max-width: 38rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--line);
  border-top: 4px solid var(--michigan-maize);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.edit-form div { margin-bottom: .85rem; }
.edit-form input:not([type="checkbox"]),
.edit-form select,
.edit-form textarea { width: 100%; }
.edit-form .helptext { display: block; margin-top: .2rem; color: var(--muted); font-size: .75rem; }
.note-card {
  max-width: 44rem;
  margin-bottom: .5rem;
  padding: .65rem .8rem;
  border: 1px solid var(--line);
  border-left: 4px solid #8ba3b7;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.note-card .meta {
  display: flex;
  margin-bottom: .4rem;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: .75rem;
  gap: 1rem;
}
.note-card .meta button { min-height: 30px; padding: .25rem .5rem; }

dialog#role-modal {
  width: min(22rem, calc(100% - 2rem));
  padding: 1.25rem;
  border: 0;
  border-top: 5px solid var(--michigan-maize);
  border-radius: 4px;
  box-shadow: 0 16px 48px rgb(0 0 0 / 28%);
}
dialog#role-modal::backdrop { background: rgb(0 39 76 / 56%); }
dialog#role-modal .choices { display: flex; margin-top: .8rem; flex-wrap: wrap; gap: .5rem; }

.site-footer {
  margin-top: 2rem;
  border-top: 4px solid var(--michigan-maize);
  color: #dbe5ee;
  background: var(--michigan-blue);
}
.footer-inner {
  display: flex;
  width: min(100%, var(--content-width));
  margin: 0 auto;
  padding: .8rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  font-size: .78rem;
  flex-wrap: wrap;
  gap: .35rem 1.5rem;
}

@media (max-width: 1100px) {
  .nav-inner { padding-inline: 1rem; flex-direction: column; gap: 0; }
  .nav-links { overflow-x: auto; }
  .nav-tools { min-height: 43px; padding-bottom: .35rem; }

  /* Inside the horizontally scrolling strip an absolute menu would be
     clipped — open inline instead. */
  .nav-more { position: static; }
  .nav-more .nav-menu {
    position: static;
    display: flex;
    min-width: 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .nav-more .nav-menu a {
    min-height: 48px;
    border-bottom: 4px solid transparent;
    border-left: none;
  }
  .nav-more .nav-menu a.active { border-bottom-color: var(--michigan-maize); }
}

@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
  .board-courses { max-height: 50vh; }
  table { display: block; overflow-x: auto; }
}

@media (max-width: 640px) {
  .masthead-inner { min-height: 82px; padding-inline: 1rem; gap: .9rem; }
  .unit-brand img { width: 63px; height: 54px; }
  .app-identity { padding-left: .9rem; }
  .app-name { font-size: 1.28rem; }
  .app-description { font-size: .68rem; }
  .nav-links { margin-inline: -1rem; padding-inline: .4rem; }
  .nav-links a { padding-inline: .65rem; font-size: .82rem; }
  .nav-tools { flex-wrap: wrap; }
  .user-name { display: none; }
  main { padding: 1rem; }
  h1 { font-size: 1.45rem; }
  .filters { align-items: stretch; }
  .filters > div { flex: 1 1 10rem; }
  .filters select,
  .filters input[type="text"] { width: 100%; }
  .summary-strip { align-items: flex-start; flex-direction: column; }
  .summary-strip > a[style*="margin-left:auto"] { margin-left: 0 !important; }
  .login-box { margin: 1.5rem auto; padding: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Sortable table headers (script in base.html): every thead th is
   clickable; the arrow marks the active column and direction. */
thead th {
  cursor: pointer;
  user-select: none;
}
thead th[aria-sort]::after {
  font-size: .7em;
  opacity: .7;
}
thead th[aria-sort="ascending"]::after { content: " ▲"; }
thead th[aria-sort="descending"]::after { content: " ▼"; }
