/* FHP Field Training Division dashboard
   Theme: fixed palette tokens never change. Semantic tokens switch with [data-theme]. */
:root {
  color-scheme: light;

  /* Fixed palette (same in both themes) */
  --navy: #13205C;
  --navy-2: #1C2E78;
  --navy-3: #2B4399;
  --gold: #FEC01D;
  --gold-ink: #7A5C0B;
  --cream: #F4F6FB;
  --steel: #B9C5E4;

  /* Semantic tokens: light */
  --bg: #F1F4FA;
  --surface: #FBFCFE;
  --surface-2: #E4E9F4;
  --hover: #EBEFF8;
  --text: #0F1838;
  --muted: #4A5568;
  --line: #D3DAE8;
  --field-bg: #FFFFFF;
  --field-line: #7D879C;
  --fill: #2B4399;
  --on-fill: #F4F6FB;
  --done-fg: #FEC01D;
  --btn-dark: #13205C;
  --btn-dark-fg: #F4F6FB;
  --btn-dark-hover: #1C2E78;
  --sidebar: #13205C;
  --toast: #13205C;
  --good: #1F5A38;
  --good-fg: #1F5A38;
  --good-bg: #DCEFE3;
  --bad: #8F2A20;
  --bad-fg: #8F2A20;
  --bad-bg: #F6DDD9;
  --warn: #6B4F08;
  --warn-bg: #F7E8C4;
  --info: #1E3A5F;
  --info-bg: #DCE4F0;
  --exam: #3B3A78;
  --exam-bg: #E4E3F4;
  /* The focus ring. Gold on the cream page is only 2:1, so on light pages the ring is the dark gold (5.5:1 on the page and the cards).
     The sidebar and the sign-in page are dark in both themes and keep the bright gold. */
  --focus: var(--gold-ink);
  --scroll-shadow: rgba(15, 24, 56, 0.28);
  --tag-fta-bg: #E1E8F3; --tag-fta: #1E3A5F;
  --tag-fto-bg: #F3E7C9; --tag-fto: #6B4F08;
  --tag-cadet-bg: #DDEBDD; --tag-cadet: #26512F;
  --tag-volunteer-bg: #EADFF0; --tag-volunteer: #5A2E73;
  --c-fta: #1E3A5F; --c-cadet: #4F8A5B; --c-volunteer: #7A4B94;
  --shadow: 0 1px 2px rgba(15, 24, 56, 0.06), 0 4px 14px rgba(15, 24, 56, 0.05);

  --radius: 12px;
  --font-body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-head: 'Oswald', 'Arial Narrow', Impact, sans-serif;
}

/* The dark tokens apply on screen only. Paper stays white, so printing from the dark theme uses the light tokens above:
   dark ink on white, with no navy cards and no pale text (see also the print block in portal.css). */
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0A1028;
    --surface: #111A3B;
    --surface-2: #1A2550;
    --hover: #16214A;
    --text: #EEF1F8;
    --muted: #AEBBD6;
    --line: #2A3B7A;
    --field-bg: #0C1430;
    --field-line: #5F7BC0;
    --fill: #A9BBEA;
    --on-fill: #13205C;
    --done-fg: #13205C;
    --btn-dark: #2B4399;
    --btn-dark-fg: #F4F6FB;
    --btn-dark-hover: #3651B0;
    --sidebar: #070C22;
    --toast: #22357F;
    --good: #2F7D4F;
    --good-fg: #9FDDB6;
    --good-bg: #173A27;
    --bad: #B8392B;
    --bad-fg: #F4B3AB;
    --bad-bg: #4A1E1A;
    --warn: #F0D58A;
    --warn-bg: #3D3012;
    --info: #BBD0EE;
    --info-bg: #1C2E63;
    --exam: #CFCFFA;
    --exam-bg: #2A2A55;
    --focus: var(--gold);
    --scroll-shadow: rgba(0, 0, 0, 0.6);
    --tag-fta-bg: #1C2E63; --tag-fta: #BBD0EE;
    --tag-fto-bg: #3D3012; --tag-fto: #F0D58A;
    --tag-cadet-bg: #173A27; --tag-cadet: #9FDDB6;
    --tag-volunteer-bg: #3A2748; --tag-volunteer: #DCC1F0;
    --c-fta: #6F9BD6; --c-cadet: #5FAE70; --c-volunteer: #B07ED0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35);
  }
}

*, *::before, *::after { box-sizing: border-box; }
/* Text a person typed (a name, a note, a title, a certification) can be one long word with no spaces. In the page, a dialog, the search results,
   the account block, and the messages it wraps inside its box and never pushes the page sideways. `anywhere` also lowers the minimum width of
   the box that holds it, so a flex or grid item can shrink to fit. A table keeps whole words and scrolls inside its own wrapper when it must. */
#main, .modal, .search-pop, .sidebar .who, .toasts { overflow-wrap: anywhere; }
.table, .table-wrap { overflow-wrap: normal; }
/* The top bar is sticky and about 60px tall: keep anything scrolled to or tabbed to clear of it. */
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.15; }
/* A long word in a title ("RECOMMENDATIONS", on a 320px phone or with wide text spacing) breaks rather than pushing the page sideways. */
h1, h2 { font-family: var(--font-head); text-transform: uppercase; letter-spacing: 0.01em; overflow-wrap: anywhere; }
/* The plural s of an acronym in a heading or table header ("DORs", "FTAs") stays lowercase; U.h wraps it in this span. */
.lc { text-transform: none; }
h1 { font-size: 34px; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::placeholder { color: var(--muted); opacity: 0.8; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* The page area and the dialog box are focused by script (after a page change, when a dialog opens) so keyboard and screen-reader users
   land in the right place. They are not controls, so they get no ring: a ring around the whole page looked like a gold bar under it. */
#main:focus, #main:focus-visible, .modal:focus, .modal:focus-visible { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap; }
/* The skip link waits above the top edge and drops into view on focus. --gold and --navy do not change with the theme, so it reads in both. */
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 16px; border-radius: 10px; border: 2px solid var(--navy);
  background: var(--gold); color: var(--navy); font-weight: 700; text-decoration: none; transform: translateY(calc(-100% - 24px));
}
.skip-link:focus, .skip-link:focus-visible { transform: none; outline: 3px solid var(--text); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
:root[data-theme="dark"] .sidebar { border-right: 1px solid var(--navy-3); }
.sidebar, .login { --focus: var(--gold); } /* dark in both themes, so the bright gold ring keeps its contrast here */
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; background: var(--gold); color: var(--navy);
  display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 17px; letter-spacing: 0.02em; flex: none;
}
/* The Florida Highway Patrol seal in the top left corner (a picture with a clear background, so no box behind it). It is a background picture
   because a stylesheet finds its pictures from its own folder (../img/), so it shows wherever the page is opened, test pages included. The
   picture is 96 pixels and shown 48, so it stays sharp on a screen that draws two device pixels for each one. */
.brand-mark.brand-logo { width: 48px; height: 48px; border-radius: 0; background: url(../img/fhp-seal-96.png) center / contain no-repeat; display: block; }
.brand-name { font-family: var(--font-head); font-size: 17px; text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--steel); }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none;
  color: var(--steel); font-weight: 600; font-size: 14px;
}
/* The icon keeps its size (it used to give way and shrink to a sliver beside a long label). A name never wraps onto a second line, which made its
   row taller than the others: the names are short enough to fit, and if one ever does not (a number of three or four digits in the badge takes
   more room), it is cut with an ellipsis and the row keeps its height. */
.nav a svg { flex: none; }
.nav a .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a:hover { background: var(--navy-2); color: var(--cream); }
.nav a[aria-current="page"] { background: var(--gold); color: var(--navy); }
.nav .badge { flex: none; margin-left: auto; background: var(--navy-3); color: var(--cream); border-radius: 999px; padding: 0 8px; font-size: 12px; min-width: 24px; text-align: center; }
.nav a[aria-current="page"] .badge { background: var(--navy); color: var(--gold); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--navy-3); padding-top: 16px; }
.who { display: flex; gap: 12px; align-items: center; padding: 0 8px 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--navy-3); color: var(--cream); display: grid; place-items: center;
  font-weight: 700; font-size: 14px; flex: none;
}
.avatar.on-page { background: var(--fill); color: var(--on-fill); }
.avatar.avatar-pic { display: block; object-fit: cover; } /* a Discord picture in place of the initials */
.who-name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.who-role { font-size: 12px; color: var(--steel); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 32px; background: var(--surface); border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--muted); position: sticky; top: 0; z-index: 5;
}
.topbar .demo-tag { background: var(--warn-bg); color: var(--warn); border-radius: 999px; padding: 2px 10px; font-weight: 600; font-size: 12px; white-space: nowrap; }
.btn.menu-btn, .btn.drawer-close { display: none; }
.scrim { display: none; }
.content { padding: 32px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--muted); margin-top: 6px; }
.crumb { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13px; margin-bottom: 12px; }
.crumb:hover { color: var(--text); }
/* On a phone the link back is a 44px touch target, not just the 20px of its text. */
@media (max-width: 760px) { .crumb { min-height: 44px; } }

/* Theme switch */
.theme-switch {
  position: relative; width: 48px; height: 28px; padding: 0; flex: none; cursor: pointer;
  border-radius: 14px; border: 1px solid var(--field-line); background: var(--surface-2);
}
.theme-switch:hover { border-color: var(--text); }
.theme-switch .knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--gold); color: var(--navy);
  display: grid; place-items: center; transition: transform 0.18s ease;
}
.theme-switch[aria-checked="true"] .knob { transform: translateX(20px); }
.theme-switch .knob svg { width: 12px; height: 12px; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 18px; flex: 1 1 auto; min-width: 0; }
/* A button in a card header keeps its label on one line. When the title and the button do not fit together (a phone), the button drops under the title. */
.card-head .btn { flex: none; white-space: nowrap; }
.card-body { padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 20px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi-value { font-family: var(--font-head); font-size: 40px; font-weight: 600; line-height: 1; margin-top: 6px; }
.kpi-sub { font-size: 13px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px;
  padding: 9px 16px; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; line-height: 1.2; min-height: 40px;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--gold); color: var(--navy); }
.btn-primary:hover { background: #E3B257; }
.btn-dark { background: var(--btn-dark); color: var(--btn-dark-fg); }
.btn-dark:hover { background: var(--btn-dark-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(0.9); }
.btn-good { background: var(--good); color: #fff; }
.btn-good:hover { filter: brightness(0.9); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 5px 12px; min-height: 32px; font-size: 13px; }
.sidebar .btn-ghost { color: var(--cream); border-color: var(--navy-3); width: 100%; }
.sidebar .btn-ghost:hover { background: var(--navy-2); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.6;
  white-space: nowrap; background: var(--surface-2); color: var(--muted);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.review { background: var(--warn-bg); color: var(--warn); }
.pill.exam { background: var(--exam-bg); color: var(--exam); }
.pill.decision { background: var(--gold); color: var(--navy); }
.pill.good { background: var(--good-bg); color: var(--good-fg); }
.pill.bad { background: var(--bad-bg); color: var(--bad-fg); }
.pill.muted { background: var(--surface-2); color: var(--muted); }
.pill.plain::before { display: none; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 700; }
.tag.fta { background: var(--tag-fta-bg); color: var(--tag-fta); }
.tag.fto { background: var(--tag-fto-bg); color: var(--tag-fto); }
.tag.cadet { background: var(--tag-cadet-bg); color: var(--tag-cadet); }
.tag.volunteer, .tag.fts { background: var(--tag-volunteer-bg); color: var(--tag-volunteer); }
.tag.ftd { background: var(--gold); color: var(--navy); }

/* Session scoring */
.score-grid { display: flex; flex-direction: column; }
.score-row { display: grid; grid-template-columns: minmax(200px, 1.1fr) minmax(170px, 1fr) 2fr; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.score-row:last-child { border-bottom: 0; }
.score-row label { font-weight: 600; font-size: 14px; }
.score-view-list { display: flex; flex-direction: column; }
.score-view { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.score-view:last-child { border-bottom: 0; }
.score-view .full { grid-column: 1 / -1; }
@media (max-width: 900px) { .score-row { grid-template-columns: 1fr; } }

/* Division stats */
.bigstat { padding: 22px 24px; display: flex; flex-direction: column; gap: 4px; }
.bigstat .big { font-family: var(--font-head); font-size: 64px; font-weight: 600; line-height: 1; margin: 6px 0; color: var(--text); }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: end; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 16px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.pod.p1 { padding-top: 28px; padding-bottom: 24px; border-color: var(--gold); background: var(--surface); box-shadow: var(--shadow); }
.pod-name { font-weight: 700; font-size: 16px; }
.pod-val { font-family: var(--font-head); font-size: 40px; line-height: 1; }
.pod.p1 .pod-val { font-size: 52px; }
.medal { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 800; font-size: 13px; color: #1a1a1a; }
.medal.m1 { background: #FEC01D; } .medal.m2 { background: #C5CCD6; } .medal.m3 { background: #C98A5B; }
.rank-n { display: inline-grid; place-items: center; width: 28px; color: var(--muted); font-weight: 700; }
.table tbody tr.me td { background: rgba(254, 192, 29, 0.16); } /* the FHP gold (--gold #FEC01D), faint */
.login-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.persona[disabled] { opacity: 0.55; cursor: not-allowed; }
@media (max-width: 700px) { .login-grid, .podium { grid-template-columns: 1fr; } }

/* Phase bar, scores, segmented control, tabs */
.phasebar { display: flex; gap: 4px; width: 112px; }
.phasebar span { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); }
.phasebar span.done { background: var(--fill); border-color: var(--fill); }
.phasebar span.cur { background: var(--gold); border-color: var(--gold); }
.sc { display: inline-grid; place-items: center; min-width: 32px; height: 26px; padding: 0 6px; border-radius: 8px; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; background: var(--surface-2); color: var(--text); }
.sc-1, .sc-bad { background: var(--bad-bg); color: var(--bad-fg); } /* sc-bad: an average below 3 (U.avgChip) */
.sc-2 { background: var(--warn-bg); color: var(--warn); }
.sc-3 { background: var(--surface-2); color: var(--text); }
.sc-4 { background: var(--good-bg); color: var(--good-fg); }
.sc-5 { background: var(--gold); color: var(--navy); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 14px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--muted); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--btn-dark); color: var(--btn-dark-fg); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a { padding: 10px 16px; text-decoration: none; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--gold); }

/* Tables. A table shows every column and lets text wrap (headers too) before it scrolls. When a table really is wider than its card it scrolls
   sideways and says so: a shadow on each side that has more to see, and a hint line under it (.scrolls, set by U.table). */
.table-wrap {
  overflow-x: auto; position: relative;
  background:
    linear-gradient(to right, var(--surface), var(--surface)) left center / 28px 100% no-repeat local,
    linear-gradient(to left, var(--surface), var(--surface)) right center / 28px 100% no-repeat local,
    linear-gradient(to right, var(--scroll-shadow), transparent) left center / 14px 100% no-repeat scroll,
    linear-gradient(to left, var(--scroll-shadow), transparent) right center / 14px 100% no-repeat scroll;
}
.table-hint { display: none; position: sticky; left: 0; width: 100%; padding: 6px 16px; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12px; }
.table-wrap.scrolls .table-hint { display: block; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; vertical-align: bottom; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; padding: 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact th, .table.compact td { padding: 10px; }
.table.compact th:first-child, .table.compact td:first-child { padding-left: 14px; }
.table.compact th:last-child, .table.compact td:last-child { padding-right: 14px; }
@media (max-width: 1440px) {
  table.table { font-size: 13.5px; }
  .table th, .table td { padding-left: 9px; padding-right: 9px; }
  .table th:first-child, .table td:first-child { padding-left: 14px; }
  .table th:last-child, .table td:last-child { padding-right: 14px; }
  .table.compact th, .table.compact td { padding-left: 8px; padding-right: 8px; }
  /* Laptop screens give the page 8px less margin on each side, which is room a table can use. The top bar keeps its edge in line with the page. */
  .topbar { padding-left: 24px; padding-right: 24px; }
  .content { padding-left: 24px; padding-right: 24px; }
}
/* A pill in a table stays on one line, whatever its length: a status that wraps into two or three lines reads as a blob. The columns around it
   give way first (their text wraps), and a table that still cannot fit scrolls inside its wrapper. */
.table .pill { white-space: nowrap; }
/* Down to a small laptop, a compact table full of pills (the permission matrix on Settings) gets a little more room from tighter cell padding. */
@media (max-width: 1100px) {
  .table.compact th, .table.compact td { padding-left: 6px; padding-right: 6px; }
}
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover { background: var(--hover); }
.table .name { font-weight: 600; }
.table .sub { color: var(--muted); font-size: 13px; }
.table a.row-link { text-decoration: none; color: inherit; }
.table a.row-link:focus-visible { outline-offset: 4px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-weight: 600; font-size: 14px; }
.field .hint { font-size: 13px; color: var(--muted); }
/* An error message looks the same wherever it sits: under a field, or under a whole form (a refusal such as "That callsign is already used"). */
.err, .field .err { font-size: 13px; color: var(--bad-fg); font-weight: 600; }
/* Characters left under a text box that has a limit (U.limitText). It warns near the limit and turns to an error when text is over it. */
.field .count { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; margin-top: -2px; }
.field .count.low { color: var(--warn); font-weight: 600; }
.field .count.over { color: var(--bad-fg); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; background: var(--field-bg); border: 1px solid var(--field-line); border-radius: 10px; padding: 9px 12px; min-height: 42px;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--text); outline: 3px solid var(--focus); outline-offset: 0; } /* the same ring as every other control: dark gold on light pages, bright gold on dark ones */
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad); }
.input:disabled, .select:disabled { opacity: 0.75; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--fill); flex: none; }
.checks { display: grid; gap: 10px; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }
.toolbar .search { position: relative; flex: 1; min-width: 220px; }
.toolbar .search .input { width: 100%; padding-left: 38px; }
.toolbar .search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--btn-dark); color: var(--btn-dark-fg); border-color: var(--btn-dark); }

/* Stepper */
.stepper { list-style: none; margin: 0; padding: 0; display: flex; gap: 0; }
.stepper li { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; position: relative; font-size: 13px; font-weight: 600; color: var(--muted); }
.stepper li::before { content: ''; position: absolute; top: 15px; left: -50%; width: 100%; height: 3px; background: var(--line); z-index: 0; }
.stepper li:first-child::before { display: none; }
.stepper .dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 3px solid var(--line); z-index: 1; font-size: 13px; }
.stepper .dot svg { width: 16px; height: 16px; }
.stepper li.done .dot { background: var(--fill); border-color: var(--fill); color: var(--done-fg); }
.stepper li.done::before, .stepper li.current::before { background: var(--fill); }
.stepper li.current .dot { background: var(--gold); border-color: var(--fill); color: var(--navy); }
.stepper li.current, .stepper li.done { color: var(--text); }
.stepper li.good .dot { background: var(--good); border-color: var(--good); color: #fff; }
.stepper li.bad .dot { background: var(--bad); border-color: var(--bad); color: #fff; }

/* Checklist */
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.checklist li { display: grid; grid-template-columns: 24px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.checklist .mark svg { width: 14px; height: 14px; }
.checklist .pass .mark { background: var(--good-bg); color: var(--good-fg); }
.checklist .fail .mark { background: var(--bad-bg); color: var(--bad-fg); }
.checklist .warn .mark { background: var(--warn-bg); color: var(--warn); }
.checklist .t { font-weight: 600; font-size: 14px; }
.checklist .d { font-size: 13px; color: var(--muted); }

/* Key-value */
.kv { margin: 0; display: grid; grid-template-columns: minmax(130px, 200px) 1fr; gap: 10px 20px; }
.kv dt { color: var(--muted); font-weight: 600; font-size: 13px; }
.kv dd { margin: 0; word-break: break-word; }
.kv dd.long { white-space: pre-wrap; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: 14px; padding-bottom: 18px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }
.timeline .pt { width: 14px; height: 14px; border-radius: 50%; background: var(--fill); margin-top: 4px; }
.timeline .note .pt { background: var(--gold); }
.timeline .meta { font-size: 12px; color: var(--muted); }
.timeline .text { margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.internal-tag { background: var(--warn-bg); color: var(--warn); font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 4px; margin-left: 6px; text-transform: uppercase; letter-spacing: 0.04em; }

/* Charts */
/* The value column grows to fit a longer value ("8 of 13 · 62%") and the bar gives way, so a row never pushes the page sideways. */
.hbar { display: grid; grid-template-columns: 130px minmax(40px, 1fr) minmax(52px, auto); gap: 12px; align-items: center; font-size: 14px; padding: 6px 0; }
.hbar > span:first-child { overflow-wrap: anywhere; }
.hbar .track { height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--fill); border-radius: 7px; min-width: 2px; }
.hbar .fill.gold { background: var(--gold); }
.hbar .fill.good { background: var(--good); }
.hbar .val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stackbar { display: flex; height: 22px; border-radius: 11px; overflow: hidden; background: var(--surface-2); }
.stackbar span { display: block; height: 100%; }
.legend { display: grid; gap: 8px; margin-top: 16px; font-size: 14px; }
.legend div { display: flex; align-items: center; gap: 10px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend .n { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.c-fta { background: var(--c-fta); } .c-fto { background: var(--gold); } .c-cadet { background: var(--c-cadet); } .c-volunteer { background: var(--c-volunteer); }
.cols { display: flex; gap: 10px; align-items: flex-end; height: 150px; padding-top: 8px; }
.cols .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; font-size: 12px; color: var(--muted); }
.cols .bar { width: 100%; max-width: 48px; background: var(--fill); border-radius: 6px 6px 0 0; min-height: 2px; }
.cols .col b { color: var(--text); font-size: 13px; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .t { font-weight: 600; }
.list a { text-decoration: none; }
.list li.click { cursor: pointer; }
.list li.click:hover { background: var(--hover); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .empty-title { color: var(--text); margin-bottom: 6px; font-size: 16px; font-weight: 600; line-height: 1.15; }
.notice { display: flex; gap: 12px; padding: 12px 16px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 14px; }
.notice.info { background: var(--info-bg); color: var(--info); }
.notice.bad { background: var(--bad-bg); color: var(--bad-fg); }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }

/* Type cards */
.type-card { display: flex; flex-direction: column; gap: 12px; padding: 20px; height: 100%; }
.type-card h3 { font-family: var(--font-head); font-size: 22px; text-transform: uppercase; }
.type-card .reqs { display: flex; flex-wrap: wrap; gap: 6px; }
.type-card .btn { margin-top: auto; align-self: flex-start; }

/* Login (always dark). The grid column and the card may shrink below their content, so a long word wraps instead of pushing the page wider than a phone. */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 24px; background: var(--navy); color: var(--cream); }
.login:focus { outline: none; } /* focused by script after sign-out so keyboard focus is not lost; it is not a control, so no ring around the whole page */
.login-card { width: min(560px, 100%); min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.login-card h1 { font-size: clamp(30px, 9vw, 44px); line-height: 1.05; overflow-wrap: anywhere; }
.login-card .eyebrow { font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; font-size: 12px; color: var(--gold); }
.persona { display: flex; gap: 16px; align-items: center; text-align: left; width: 100%; background: var(--navy-2); border: 1px solid var(--navy-3); color: var(--cream); border-radius: 12px; padding: 16px; cursor: pointer; }
.persona:hover { border-color: var(--gold); }
.persona .avatar { background: var(--gold); color: var(--navy); }
.persona b { display: block; }
.persona span { color: var(--steel); font-size: 13px; }
.persona > span:last-child { min-width: 0; overflow-wrap: anywhere; }

/* Modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(15, 24, 56, 0.55); display: grid; place-items: center; padding: 20px; z-index: 50; }
:root[data-theme="dark"] .overlay { background: rgba(0, 0, 0, 0.65); }
/* The dialog scrolls inside its box when it is taller than the window. The action buttons stay at the bottom of the box (sticky) so a long
   dialog never hides Close or Save, and a field tabbed to is scrolled clear of them (scroll-padding-bottom). */
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; width: min(560px, 100%); max-height: 90vh; overflow: auto; scroll-padding-bottom: 84px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.modal-head { padding: 20px 24px 0; }
.modal-body { padding: 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { position: sticky; bottom: 0; z-index: 1; display: flex; justify-content: flex-end; gap: 10px; padding: 8px 24px 20px; flex-wrap: wrap; background: var(--surface); }
/* Toasts: two live regions in one box (see U.toastBox). Errors carry a close button and stay until dismissed. */
.toasts { position: fixed; left: 20px; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; pointer-events: none; }
.toast-list { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.toast-list:not(:empty) + .toast-list:not(:empty) { margin-top: 10px; }
.toast { --focus: var(--gold); display: flex; align-items: flex-start; gap: 10px; pointer-events: auto; background: var(--toast); color: var(--cream); padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); font-weight: 600; font-size: 14px; max-width: 360px; overflow-wrap: anywhere; border-left: 4px solid var(--gold); }
.toast.bad { border-left-color: #E26D5C; }
.toast.good { border-left-color: #6DC38A; }
.toast.warn { border-left-color: #F2C14E; }
.toast-x { flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; margin: -2px -8px -2px 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; opacity: 0.85; }
.toast-x:hover { opacity: 1; background: rgba(255, 255, 255, 0.14); }
/* A standing error would sit over the buttons of a dialog, so it waits behind the dialog and is there again when the dialog closes (body.has-dialog
   is set by U.modal). An error raised while a dialog is open is drawn inside that dialog, above its buttons, by U.toast. */
body.has-dialog .toasts .toast.bad { display: none; }
.modal-alert { flex: 1 1 100%; display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); color: var(--bad-fg); font-size: 14px; font-weight: 600; text-align: left; }
.modal-alert > span { flex: 1; min-width: 0; }
.modal-alert .toast-x { margin: -2px -4px -2px 0; }
.modal-alert .toast-x:hover { background: rgba(0, 0, 0, 0.1); }

.score-live { font-weight: 700; font-size: 14px; min-height: 21px; }
.nowrap { white-space: nowrap; }
.log-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; align-items: start; }
.log-grid .s2 { grid-column: span 2; } .log-grid .s4 { grid-column: span 4; } .log-grid .s6 { grid-column: span 6; }
.log-grid .btn { width: 100%; }
@media (max-width: 1100px) { .log-grid .s2, .log-grid .s4, .log-grid .s6 { grid-column: span 6; } }
@media (max-width: 640px) { .log-grid .s2, .log-grid .s4, .log-grid .s6 { grid-column: 1 / -1; } }

@media (max-width: 1100px) {
  .grid.split, .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); }
}
.stack > *, .grid > * { min-width: 0; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  /* The drawer. Closed, it is slid off screen and visibility:hidden (after the slide), so its links leave the tab order and the
     accessibility tree. Open, a scrim covers the page behind it (z-index 39, under the drawer's 40, over the top bar's 5). */
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 86vw); z-index: 40; transform: translateX(-100%); visibility: hidden; transition: transform 0.2s, visibility 0s linear 0.2s; height: 100%; }
  .sidebar.open { transform: none; visibility: visible; transition: transform 0.2s; box-shadow: 0 0 40px rgba(0, 0, 0, 0.5); }
  .sidebar.open ~ .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(15, 24, 56, 0.55); }
  :root[data-theme="dark"] .sidebar.open ~ .scrim { background: rgba(0, 0, 0, 0.65); }
  body.drawer-open { overflow: hidden; }
  .btn.menu-btn { display: inline-flex; }
  .sidebar .drawer-close { display: inline-flex; width: auto; min-height: 40px; padding: 8px 10px; margin-left: auto; flex: none; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .topbar-date { display: none; }
  .content { padding: 20px 16px 40px; }
  h1 { font-size: 28px; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
  .hbar { grid-template-columns: 96px minmax(24px, 1fr) minmax(44px, auto); }
  .stepper li { font-size: 12px; }
}
@media (max-width: 640px) { .topbar .tb-note { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
