/* Freedom Institute SIS -- shared styles.
   Navy #101D49 and red #B9291D are the institute's marks. The interface stays
   quiet so the data reads first: this is a tool people use for six hours a day,
   not a marketing page. */

:root {
  --navy: #101D49;
  --navy-700: #1b2c66;
  --navy-300: #6675a8;
  --red: #B9291D;
  --red-dark: #972016;

  --ink: #16181d;
  --ink-soft: #4a4f5c;
  --ink-faint: #7a8090;
  --line: #dfe3ec;
  --line-soft: #edeff5;
  --bg: #f5f6fa;
  --panel: #ffffff;

  --ok: #1c7a4a;
  --ok-bg: #e6f4ec;
  --warn: #9a6207;
  --warn-bg: #fdf3e0;
  --err: #b3261e;
  --err-bg: #fceceb;

  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 29, 73, .06), 0 4px 14px rgba(16, 29, 73, .05);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- app shell ---------- */

.app { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.sidebar .brand strong { display: block; font-size: 15px; letter-spacing: .2px; }
.sidebar .brand span { display: block; font-size: 11px; color: #9aa6cd; margin-top: 2px; }

.sidebar nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: block;
  padding: 8px 10px;
  margin-bottom: 1px;
  border-radius: var(--radius);
  color: #c6cde4;
  font-size: 13.5px;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--red); color: #fff; font-weight: 600; }
.sidebar nav .group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px;
  color: #7d89b4; padding: 14px 10px 5px;
}
.sidebar .foot {
  padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .12); font-size: 12px;
}
.sidebar .foot .who { color: #fff; font-weight: 600; }
.sidebar .foot .role { color: #9aa6cd; text-transform: capitalize; }
.sidebar .foot button {
  margin-top: 8px; background: none; border: 1px solid rgba(255, 255, 255, .25);
  color: #c6cde4; padding: 4px 10px; border-radius: var(--radius); cursor: pointer; font-size: 12px;
}
.sidebar .foot button:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.main { min-width: 0; }
.topbar {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 14px 24px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: -.2px; }
.topbar .sub { color: var(--ink-faint); font-size: 12.5px; }
.topbar .spacer { flex: 1; }

.content { padding: 22px 24px 60px; max-width: 1240px; }

/* School year picker, top right. When you are looking at a year that is not the
   school's current one, it turns amber. That state is easy to forget you are in
   and expensive to forget: grades and enrollments would land in the wrong year. */
.year-select {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fafbfd;
}
.year-select label {
  margin: 0; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--ink-faint); white-space: nowrap;
}
.year-select select {
  width: auto; min-width: 108px; border: none; background: transparent;
  font-weight: 700; font-size: 14px; color: var(--navy); padding: 3px 2px; cursor: pointer;
}
.year-select select:focus { box-shadow: none; }
/* The campus slot is present on every page but only filled where a page is
   campus-scoped; empty, it would still take a gap in the flex row. */
#campus-picker:empty { display: none; }

/* ---------- brand ---------- */
/* The crest sits with the wordmark; the red rule under the topbar is the same
   red the institute prints. Decoration stays out of the data's way. */
.brand { display: flex; align-items: center; gap: 10px; }
/* The crest is a navy eagle; on the navy sidebar it needs its own ground. A
   white chip reads as a badge rather than a patch, and the logo keeps its own
   colors instead of being recolored. */
.brand-crest { height: 46px; width: 46px; flex: none; object-fit: contain;
               background: #fff; border-radius: 8px; padding: 4px;
               box-shadow: 0 1px 3px rgba(0,0,0,.35); }

.topbar { border-top: 3px solid var(--red); }
body.off-year .topbar { border-top-color: var(--navy); }

.sidebar nav a.active {
  box-shadow: inset 3px 0 0 #fff;
}

/* Section headers pick up the brand rule. */
.panel h2 { border-left: 3px solid var(--red); padding-left: 11px; }

/* Stat tiles get the navy/red identity: navy number, red underscore. */
.stat .n { position: relative; padding-bottom: 6px; }
.stat .n::after { content: ''; position: absolute; left: 0; bottom: 0;
                  width: 26px; height: 3px; border-radius: 2px; background: var(--red); }
.stat.alert .n::after { background: var(--warn); }

/* The eagle keeps watch over the sidebar footer, faintly. */
.sidebar { position: relative; }
.sidebar::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 180px;
  background: url('/assets/freedom-eagle.png') no-repeat center bottom 8px / 150px auto;
  /* Navy art on a navy wall is invisible; inverted to a white ghost it reads. */
  filter: brightness(0) invert(1);
  opacity: .10; pointer-events: none;
}
.sidebar .foot { position: relative; z-index: 1; }

/* Empty states carry a whisper of the crest instead of dead air. */
.empty { position: relative; }
.empty::before {
  content: ''; display: block; margin: 0 auto 8px; width: 44px; height: 44px;
  background: url('/assets/freedom-eagle.png') no-repeat center / contain;
  opacity: .18;
}

/* "View as" banner. Amber rather than red: nothing is wrong, but you are not
   where you think you are, and every page has to say so. */
.viewas-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 8px 16px; font-size: 13px;
  background: #8a5a00; color: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
}
.viewas-bar strong { font-weight: 700; }
.viewas-bar .btn {
  background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .5); color: #fff;
}
.viewas-bar .btn:hover { background: rgba(255, 255, 255, .28); }
body.viewing-as .app { padding-top: 37px; }
body.viewing-as .topbar { top: 37px; }
/* Off the current school year, the whole header goes red. Working in the wrong
   year is the single easiest mistake to make in a system like this and the
   most annoying to unpick, so the warning is the header itself, not a badge
   somebody has to notice. */
body.off-year .topbar {
  background: var(--red);
  border-bottom-color: var(--red-dark);
}
body.off-year .topbar h1 { color: #fff; }
body.off-year .topbar .sub { color: rgba(255, 255, 255, .88); }
body.off-year .topbar .btn {
  background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .45); color: #fff;
}
body.off-year .topbar .btn:hover { background: rgba(255, 255, 255, .26); }
body.off-year .topbar .btn.primary {
  background: #fff; border-color: #fff; color: var(--red-dark);
}
body.off-year .year-select {
  background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .5);
}
body.off-year .year-select label { color: rgba(255, 255, 255, .9); }
body.off-year .year-select select { color: #fff; }
body.off-year .year-select select option { color: var(--ink); }

/* ---------- panels ---------- */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
}
.panel > h2 {
  margin: 0; padding: 12px 16px; font-size: 13px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .6px; color: var(--ink-soft);
  border-bottom: 1px solid var(--line-soft);
}
.panel .body { padding: 16px; }
.panel .body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---------- stat tiles ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .n { font-size: 26px; font-weight: 660; color: var(--navy); line-height: 1.1; }
.stat .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-faint); margin-top: 4px; }
.stat.alert .n { color: var(--red); }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 9px 14px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--ink-faint); border-bottom: 1px solid var(--line);
  background: #fafbfd; font-weight: 650; white-space: nowrap;
}
tbody td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f7f9fd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- forms ---------- */

label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=tel], input[type=number], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  font-family: inherit; font-size: 13.5px; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--navy-300); box-shadow: 0 0 0 3px rgba(16, 29, 73, .08);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
.field { margin-bottom: 13px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; }
.check { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.check input { width: auto; margin: 0; }
.check label { margin: 0; font-weight: 500; color: var(--ink); font-size: 13px; }
.hint { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 13.5px; font-weight: 600;
  font-family: inherit; cursor: pointer;
}
.btn:hover { background: #f4f6fa; text-decoration: none; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-700); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: var(--red-dark); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--navy-700); }
.btn.ghost:hover { background: #eef1f7; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- pills and badges ---------- */

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px;
  font-weight: 600; background: var(--line-soft); color: var(--ink-soft); white-space: nowrap;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--err-bg); color: var(--err); }
.pill.navy { background: #e8ebf5; color: var(--navy); }

/* ---------- notices ---------- */

.notice { padding: 11px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; border: 1px solid; }
.notice.info { background: #eef2fb; border-color: #cfd8ee; color: var(--navy); }
.notice.warn { background: var(--warn-bg); border-color: #f0dcb4; color: var(--warn); }
.notice.err  { background: var(--err-bg); border-color: #f2cbc8; color: var(--err); }
.notice.ok   { background: var(--ok-bg); border-color: #c2e2d0; color: var(--ok); }
.notice strong { font-weight: 700; }

.empty { padding: 34px 20px; text-align: center; color: var(--ink-faint); font-size: 13.5px; }

/* ---------- toast ---------- */

#toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
#toast div {
  background: var(--navy); color: #fff; padding: 10px 15px; border-radius: var(--radius);
  font-size: 13.5px; box-shadow: 0 6px 22px rgba(16, 29, 73, .25); max-width: 340px;
  animation: rise .18s ease-out;
}
#toast div.err { background: var(--red); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------- modal ---------- */

.modal-bg {
  position: fixed; inset: 0; background: rgba(16, 29, 73, .45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 50px 20px;
  overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 8px; width: 100%; max-width: 620px;
  box-shadow: 0 20px 60px rgba(16, 29, 73, .3);
}
.modal header {
  padding: 15px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal header h3 { margin: 0; font-size: 16px; }
.modal .body { padding: 20px; }
.modal footer {
  padding: 13px 20px; border-top: 1px solid var(--line); background: #fafbfd;
  display: flex; justify-content: flex-end; gap: 8px; border-radius: 0 0 8px 8px;
}
.x { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-faint); }

/* ---------- tabs ---------- */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 9px 15px; font-size: 13.5px; font-weight: 600; color: var(--ink-faint);
  cursor: pointer; font-family: inherit;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--navy); border-bottom-color: var(--red); }

/* ---------- login ---------- */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--navy) 0%, #0a1230 100%); padding: 20px;
}
.login-card {
  background: #fff; border-radius: 10px; width: 100%; max-width: 380px;
  padding: 32px 30px; box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
}
.login-card h1 { margin: 0 0 3px; font-size: 21px; color: var(--navy); }
.login-card .sub { color: var(--ink-faint); font-size: 13px; margin-bottom: 22px; }
.login-card .btn { width: 100%; justify-content: center; padding: 9px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 3px; }
  .sidebar nav .group { display: none; }
  .content { padding: 16px; }
  /* Stacked layout has no sidebar bottom for the eagle to sit in. */
  .sidebar::after { display: none; }
}
