/* ============================================================
   FONTS
   ============================================================ */
@font-face {
  font-family: 'AeroviasBrasil';
  src: url('../fonts/AeroviasBrasilNF.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Reserve the scrollbar's width even when hidden, so locking the page under a
   modal does not shift the layout sideways. */
html { font-size: 16px; scrollbar-gutter: stable; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-page); color: var(--text-body);
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  transition: background .2s, color .2s; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
ul { list-style: none; }

/* ============================================================
   DESIGN TOKENS — DARK (default)
   ============================================================ */
:root[data-theme="dark"], :root {
  /* Native controls (picker icons, calendar/clock popups, scrollbars) draw in
     the theme's scheme; without it they stay light on dark inputs. */
  color-scheme: dark;
  --navy:      #0f1929;
  --navy-mid:  #162035;
  --navy-lt:   #1e2e4f;
  --gold:      #c9a227;
  --gold-lt:   #e8c547;
  --gold-pale: #2a2210;
  --white:     #e8edf5;
  --gray-50:   #151e2e;
  --gray-100:  #1c2740;
  --gray-200:  #7a8ba8;
  --gray-400:  #8d9ab5;
  --gray-600:  #a8b5cc;
  --gray-800:  #c8d0e0;
  --green:     #2ecc78;
  --green-lt:  #0d2d1e;
  --red:       #e05560;
  --red-lt:    #2d1015;
  --orange:    #e07b39;
  --orange-lt: #2d1e0d;
  --blue:      #4a90e8;
  --blue-lt:   #0d1e38;
  --form-check-gap: .55rem;
  --radius:    8px;
  --radius-lg: 14px;
  --shadow:    0 2px 8px rgba(0,0,0,.35);
  --shadow-lg: 0 6px 24px rgba(0,0,0,.5);
  --bg-page:   #0d1524;
  --bg-card:   #131d30;
  --bg-input:  #0f1929;
  --bg-table-head: #0f1929;
  --bg-row-hover:  #1a2540;
  --bg-answer:     #1b2742;
  --border:    #243050;
  --text-body: #cdd5e8;
  --text-muted-val: #6b7a96;
  --footer-text:    #172743; /* >= 4.5:1 on --bg-page at small size */
  /* Score slider. Edge values are chosen for >= 3:1 against --bg-card, the
     non-text contrast minimum, since the track is the control's outline. */
  --range-track:      #1c2740;
  --range-track-edge: #6b7a96;
  --range-fill:       #c9a227;
  --range-thumb-edge: #e8c547;
  --range-stripe-a:   #1c2740;
  --range-stripe-b:   #2a3858;
  /* Score shading on the judge's comparison. --heat-max caps the tint so body
     text keeps >= 4.5:1 on the strongest cell. */
  --heat:     #c9a227;
  --heat-max: 45%;
}

/* ============================================================
   DESIGN TOKENS — LIGHT
   ============================================================ */
:root[data-theme="light"] {
  color-scheme: light;
  --navy:      #1a2744;
  --navy-mid:  #243358;
  --navy-lt:   #2e4070;
  --gold:      #c9a227;
  --gold-lt:   #e8c547;
  --gold-pale: #fdf6e3;
  --white:     #ffffff;
  --gray-50:   #f4f6fb;
  --gray-100:  #e8ecf3;
  --gray-200:  #cdd3df;
  --gray-400:  #8d97ae;
  --gray-600:  #5a6478;
  --gray-800:  #2e3545;
  --green:     #2a9d5c;
  --green-lt:  #e6f7ee;
  --red:       #d64045;
  --red-lt:    #fdeaea;
  --orange:    #e07b39;
  --orange-lt: #fef0e6;
  --blue:      #2a6fc9;
  --blue-lt:   #e8f0fb;
  --radius:    8px;
  --radius-lg: 14px;
  --shadow:    0 2px 8px rgba(26,39,68,.10);
  --shadow-lg: 0 6px 24px rgba(26,39,68,.14);
  --bg-page:   #f4f6fb;
  --bg-card:   #ffffff;
  --bg-input:  #ffffff;
  --bg-table-head: #f4f6fb;
  --bg-row-hover:  #f4f6fb;
  --bg-answer:     #f4f6fb;
  --border:    #cdd3df;
  --text-body: #1a2744;
  --text-muted-val: #8d97ae;
  --footer-text:    #d6d8dd; /* --text-muted-val is under 4.5:1 here */
  /* --gold is only 2.4:1 on white, so the light slider fills and edges with a
     darker gold; --gray-400 is 2.9:1, so the track edge is darker too. */
  --range-track:      #e8ecf3;
  --range-track-edge: #7d879e;
  --range-fill:       #b08b17;
  --range-thumb-edge: #8a6d0f;
  --range-stripe-a:   #dde2ec;
  --range-stripe-b:   #f7f8fb;
  --heat:     #d4ad2e;
  --heat-max: 55%;
}

/* ============================================================
   LAYOUT
   ============================================================ */
/* body is the full-height column; #app fills it and the footer follows, so
   the footer sits at the bottom of short pages and after long ones. */
#app { display: flex; flex-direction: column; flex: 1 0 auto; }

.app-footer {
  flex-shrink: 0; text-align: center; padding: .75rem 1rem;
  font-size: .75rem; color: var(--footer-text);
}
.app-footer a:hover { text-decoration: underline; }
@media print { .app-footer { display: none; } }

.app-status-banner {
  padding: .7rem 1rem;
  text-align: center;
  font-size: .84rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.app-status-banner-offline {
  background: var(--orange-lt);
  color: var(--orange);
}
.app-status-banner-update {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}
/* A sandbox is a copy of a real branding. The stripe is there so it cannot be
   mistaken for the original in the next tab. */
.app-status-banner-sandbox {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem 1rem;
  flex-wrap: wrap;
  color: #fff;
  background: repeating-linear-gradient(135deg,
    var(--blue) 0 14px,
    color-mix(in srgb, var(--blue) 78%, #000) 14px 28px);
}
.app-status-banner-sandbox a { color: #fff; text-decoration: underline; }
.app-status-banner-passkey {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem 1rem;
  flex-wrap: wrap;
  background: var(--blue-lt);
  color: var(--blue);
}
.passkey-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .5rem; }
.passkey-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  flex-wrap: wrap;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.passkey-row-main { min-width: 0; flex: 1 1 12rem; overflow-wrap: anywhere; }
.passkey-row-actions { display: flex; gap: .35rem; flex-shrink: 0; }
.passkey-row .form-input { flex: 1 1 12rem; min-width: 0; }
.app-status-banner-maintenance {
  background: var(--red-lt);
  color: var(--red);
}
.app-status-banner-maintenance-upcoming {
  background: var(--blue-lt);
  color: var(--blue);
}
.maintenance-message { white-space: pre-line; margin-bottom: 1rem; }
.maintenance-admin { margin-top: 1.25rem; font-size: .9rem; }
.maintenance-admin summary { cursor: pointer; color: var(--gray-400); }

.topbar {
  background: var(--navy);
  color: var(--white);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.topbar-brand { font-size: 2.2rem; font-weight: 700; letter-spacing: .5px; font-family: 'AeroviasBrasil', sans-serif;
  display: flex; align-items: center; gap: .5rem; min-width: 0; flex: 1; overflow: hidden; }
.topbar-brand span.gold { color: var(--gold); flex-shrink: 0; }
.topbar-right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.topbar-user { font-size: .85rem; color: var(--gray-200); }
.topbar-project { font-size: .78rem; background: var(--navy-lt); color: var(--gold-lt);
  padding: 2px 10px; border-radius: 99px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 600;
  letter-spacing: normal;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }

/* Hamburger menu */
.hamburger-btn { background: none; border: none; color: var(--white); cursor: pointer;
  font-size: 1.4rem; padding: .2rem .4rem; line-height: 1; flex-shrink: 0; }
.hamburger-btn i { display: block; }
.topbar-menu {
  position: absolute; top: 56px; right: 0;
  background: var(--navy-mid); border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 220px; z-index: 200;
  padding: .5rem 0;
}
.topbar-menu-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem 1.1rem; font-size: .9rem;
  color: var(--white); cursor: pointer; background: none; border: none;
  width: 100%; text-align: left;
  transition: background .12s;
}
.topbar-menu-item:hover { background: var(--navy-lt); }
.topbar-menu-item-label { display: inline-flex; align-items: center; gap: .6rem; }
.topbar-menu-icon { width: 1rem; text-align: center; flex-shrink: 0; }
.topbar-menu-divider { border: none; border-top: 1px solid var(--border); margin: .35rem 0; }
.topbar-menu-label { padding: .3rem 1.1rem; font-size: .72rem; color: var(--gray-400);
  text-transform: uppercase; letter-spacing: .5px; }
.toggle-track {
  display: inline-flex; align-items: center;
  width: 36px; height: 20px; border-radius: 10px;
  background: var(--gray-600); flex-shrink: 0;
  transition: background .2s; position: relative;
}
.toggle-track.on { background: var(--gold); }
.toggle-thumb {
  position: absolute; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff;
  transition: left .2s;
}
.toggle-track.on .toggle-thumb { left: 18px; }

@media (max-width: 700px) {
  .topbar-user { display: none; }
  .role-switcher-desktop { display: none; }
}

.nav-tabs {
  background: var(--navy-mid);
  display: flex;
  padding: 0 1.5rem;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  padding: .75rem 1.1rem;
  font-size: .88rem;
  color: var(--gray-200);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.nav-tab:hover { color: var(--white); }
.nav-tab.active { color: var(--gold-lt); border-bottom-color: var(--gold); }

.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-body);
  margin-bottom: 1rem;
}
.card-sm { padding: 1rem; }

.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-lt) 100%);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 1.5rem;
}
.hero h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: .4rem; }
.hero p { color: var(--gray-200); font-size: .95rem; }

/* ============================================================
   STATS ROW
   ============================================================ */
.stats-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  flex: 1; min-width: 130px;
  display: flex; flex-direction: column; gap: .25rem;
}
.stat-val { font-size: 1.8rem; font-weight: 800; color: var(--text-body); }
.stat-lbl { font-size: .78rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: .5px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; padding: .6rem .9rem; background: var(--bg-table-head);
  color: var(--gray-600); font-weight: 600; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .4px; border-bottom: 2px solid var(--border); }
td { padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-body); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-row-hover); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .3px;
}
.badge-draft     { background: var(--gray-100); color: var(--gray-600); }
.badge-open      { background: var(--green-lt); color: var(--green); }
.badge-submitted { background: var(--blue-lt);  color: var(--blue); }
.badge-approved  { background: var(--blue-lt);  color: var(--blue); }
.badge-released  { background: var(--orange-lt);color: var(--orange); }
.badge-complete  { background: var(--green-lt); color: var(--green); }
.badge-pending_submit { background: var(--orange-lt); color: var(--orange); border: 1px solid var(--orange); }
.badge-winner    { background: var(--gold-pale); color: var(--gold); }
.badge-flagged_only  { background: var(--orange-lt); color: var(--orange); border: 1px solid var(--orange); }
.badge-disqualified  { background: var(--red-lt); color: var(--red); }
/* A self-registered user who never finished the profile form (personNameHtml). */
.badge-incomplete    { background: var(--orange-lt); color: var(--orange); cursor: help; }

/* Staff Applications list: rows ticked for a bulk action. */
tr.row-selected td { background: var(--blue-lt); }
.badge-danger    { background: var(--red-lt);    color: var(--red); }
.badge-published { background: var(--green-lt);  color: var(--green); }
.badge-judging   { background: var(--orange-lt); color: var(--orange); }
.badge-closed    { background: var(--gray-100);  color: var(--gray-600); }
.badge-setup     { background: var(--blue-lt);   color: var(--blue); }
.badge-gold      { background: var(--gold-pale); color: var(--gold);   border: 1px solid var(--gold); }
.badge-silver    { background: var(--gray-100);  color: var(--gray-600); border: 1px solid var(--gray-400); }
.badge-bronze    { background: var(--orange-lt); color: var(--orange); border: 1px solid var(--orange); }
.badge-admin     { background: var(--navy); color: var(--white); }
.badge-staff     { background: var(--navy-mid); color: var(--white); }
.badge-judge     { background: var(--blue-lt); color: var(--blue); }
.badge-observer  { background: transparent; color: var(--navy-mid); border: 1px solid var(--navy-mid); }
.badge-applicant { background: var(--gray-100); color: var(--gray-600); }
.badge-sandbox   { background: var(--blue); color: #fff; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  font-size: .88rem; font-weight: 600;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--navy-lt); color: var(--white); }
.btn-primary:hover { background: var(--navy-mid); }
.btn-gold { background: var(--gold); color: #1a1a00; }
.btn-gold:hover { background: var(--gold-lt); }
.btn-outline { background: transparent; color: var(--text-body); border: 1.5px solid var(--border); }
.btn-outline:hover { background: var(--bg-row-hover); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { opacity: .85; }
.btn-ghost { background: transparent; color: var(--gray-600); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg-row-hover); color: var(--text-body); }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* A button waiting on the server, or one whose click is spent. Without this a
   disabled button still lit up on hover and dipped on :active, which reads as
   "that did not register" and invites the second click the disable exists to
   prevent. The hover rules above are per-variant, so they are overridden here
   by keeping the element's own background rather than naming each one. */
.btn:disabled { opacity: .6; cursor: default; }
.btn:disabled:active { transform: none; }
.btn:disabled:hover { filter: none; }

.btn-spinner {
  width: .8em; height: .8em; flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin .6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* The label swap alone carries the message; the spin is decoration. */
@media (prefers-reduced-motion: reduce) {
  .btn-spinner { animation: none; }
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--gray-600);
  margin-bottom: .35rem; }
.form-label .req { color: var(--red); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--text-body);
  background: var(--bg-input);
  transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--gold); }
.form-textarea { min-height: 90px; resize: vertical; }
.form-help { font-size: .78rem; color: var(--gray-400); margin-top: .25rem; }

/* Question and answer (answer-view.js). The question is a quiet caption and
   the entrant's words carry the weight, always in the same box, so a short
   answer can never be mistaken for another label. */
.qa-list { margin: 0 0 1rem; }
.qa-list:last-child { margin-bottom: 0; }
.qa-item { padding: 1rem 0; border-top: 1px solid var(--border); }
.qa-item:first-child { border-top: 0; padding-top: 0; }
.qa-q { font-size: .8rem; font-weight: 400; color: var(--gray-600); line-height: 1.4;
  margin-bottom: .35rem; }
.qa-num { font-weight: 700; color: var(--text-body); margin-right: .4rem; }
.qa-a { margin: 0; padding: .6rem .8rem; background: var(--bg-answer);
  border-left: 3px solid var(--blue); border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-body); font-size: .92rem; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; }
/* The attachment list draws its own box; a tint around it doubles the frame. */
.qa-a--files { white-space: normal; background: none; padding-top: 0; padding-bottom: 0; }
.qa-a--empty { background: none; border-left-color: var(--border); font-style: italic;
  color: var(--gray-400); font-size: .85rem; padding-top: .2rem; padding-bottom: .2rem; }
.qa-list--compact .qa-item { padding: .6rem 0; }
.qa-list--compact .qa-item:first-child { padding-top: 0; }
.qa-list--compact .qa-a { font-size: .85rem; padding: .45rem .65rem; }
.qa-list--compact .qa-a--empty { padding-top: .1rem; padding-bottom: .1rem; }
.form-error { font-size: .78rem; color: var(--red); margin-top: .25rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }
/* A deadline: date and time side by side, the date taking the spare width.
   The minimums fit the value plus the native picker icon; in a narrow column
   (paired fields in a modal) the time wraps under the date rather than
   clipping either. */
.deadline-input { display: flex; flex-wrap: wrap; gap: .5rem; }
.deadline-input input[type="date"] { flex: 3 1 10rem; min-width: 10rem; }
.deadline-input input[type="time"] { flex: 1 0 7.5rem; min-width: 7.5rem; }
/* One control row: a checkbox or radio beside its label, always wrapped in the
   label so the whole row is a hit target. `flex-start` is the single default
   rather than a per-context override, because a label long enough to wrap is
   ordinary and centring it against a 16px box reads as misaligned. The gap is a
   custom property so help text can indent to the label edge with no magic
   number. */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--form-check-gap);
  font-size: .88rem;
  line-height: 1.35;
  cursor: pointer;
}
.form-check input[type=checkbox],
.form-check input[type=radio] {
  flex: 0 0 16px;
  width: 16px; height: 16px;
  margin-top: .1rem;
  accent-color: var(--gold);
  cursor: pointer;
}
/* A disabled control gives no signal of its own once it sits inside a label,
   so the row carries it. */
.form-check:has(input:disabled) { color: var(--gray-400); cursor: default; }
.form-check:has(input:disabled) input { cursor: default; }
/* Help text belonging to the row above it, aligned to the label rather than
   the checkbox. */
.form-check-help { margin: .25rem 0 0 calc(var(--form-check-gap) + 16px); line-height: 1.4; }
/* A column of control rows. One rhythm wherever checkboxes stack. */
.form-check-group { display: flex; flex-direction: column; gap: .4rem; }
.range-row { display: flex; align-items: center; gap: .75rem; }
/* Score slider, drawn from scratch. The native one can only be tinted, and it
   paints a fill up to wherever it rests, which on an unscored criterion is its
   midpoint and reads as a score. `--fill` (0..1) is set inline and kept in step
   by handlers.js; WebKit has no progress pseudo-element, so the fill is a
   gradient stop placed where the thumb's centre actually is (it travels
   thumb/2 .. width - thumb/2, not 0 .. width). */
.range-row input[type=range] {
  --thumb: 20px;
  --track-h: 8px;
  flex: 1; min-width: 0;
  height: 28px; margin: 0;
  background: transparent;
  -webkit-appearance: none; appearance: none;
  cursor: pointer;
}
.range-row input[type=range]::-webkit-slider-runnable-track {
  box-sizing: border-box;
  height: var(--track-h);
  border: 1px solid var(--range-track-edge); border-radius: 999px;
  background: linear-gradient(to right,
    var(--range-fill) 0 calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--fill, 0)),
    var(--range-track) 0);
}
.range-row input[type=range]::-moz-range-track {
  box-sizing: border-box;
  height: var(--track-h);
  border: 1px solid var(--range-track-edge); border-radius: 999px;
  background: var(--range-track);
}
.range-row input[type=range]::-moz-range-progress {
  height: calc(var(--track-h) - 2px);
  border-radius: 999px;
  background: var(--range-fill);
}
.range-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  box-sizing: border-box;
  width: var(--thumb); height: var(--thumb);
  /* Centred on the track's 6px content box. */
  margin-top: calc((var(--track-h) - 2px - var(--thumb)) / 2);
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--bg-card);
  box-shadow: 0 0 0 1px var(--range-thumb-edge);
  transition: opacity .12s;
}
.range-row input[type=range]::-moz-range-thumb {
  box-sizing: border-box;
  width: var(--thumb); height: var(--thumb);
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--bg-card);
  box-shadow: 0 0 0 1px var(--range-thumb-edge);
  transition: opacity .12s;
}
.range-row input[type=range]:focus { outline: none; }
.range-row input[type=range]:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }

/* Unscored: stripes, no fill, no thumb. Stripes read as "nothing here yet" in
   both themes without relying on colour. The thumb shows faintly on hover and
   keyboard focus so the control still looks grabbable. */
.range-row input[type=range].score-unset::-webkit-slider-runnable-track {
  background: repeating-linear-gradient(135deg,
    var(--range-stripe-a) 0 4px, var(--range-stripe-b) 4px 8px);
}
.range-row input[type=range].score-unset::-moz-range-track {
  background: repeating-linear-gradient(135deg,
    var(--range-stripe-a) 0 4px, var(--range-stripe-b) 4px 8px);
}
.range-row input[type=range].score-unset::-moz-range-progress { background: transparent; }
.range-row input[type=range].score-unset::-webkit-slider-thumb { opacity: 0; }
.range-row input[type=range].score-unset::-moz-range-thumb { opacity: 0; }
.range-row input[type=range].score-unset:hover::-webkit-slider-thumb,
.range-row input[type=range].score-unset:focus-visible::-webkit-slider-thumb { opacity: .4; }
.range-row input[type=range].score-unset:hover::-moz-range-thumb,
.range-row input[type=range].score-unset:focus-visible::-moz-range-thumb { opacity: .4; }

/* Submitted: readable but plainly not editable. */
.range-row input[type=range]:disabled { cursor: default; opacity: .6; }

/* Forced colours strip custom backgrounds, which would leave an invisible
   track. Hand the control back to the platform; the empty number box and the
   progress count still say what is unscored. */
@media (forced-colors: active) {
  .range-row input[type=range] { -webkit-appearance: auto; appearance: auto; }
  .range-row input[type=range]::-webkit-slider-thumb { -webkit-appearance: auto; appearance: auto; opacity: 1; }
  .range-row input[type=range]::-moz-range-thumb { opacity: 1; }
}
/* Typed score beside each slider. Wide enough for a three-digit max and a
   comfortable tap target; bold because it is the value that counts. */
.score-num {
  width: 4.5rem; flex: none; min-height: 2.5rem;
  padding: .35rem .4rem; text-align: center;
  font-size: 1rem; font-weight: 700; color: var(--text-body);
  background: var(--bg-input);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s;
}
.score-num:focus { outline: none; border-color: var(--gold); }
.score-num::placeholder { color: var(--gray-400); font-weight: 400; }
.score-num:disabled { color: var(--text-body); opacity: .8; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; padding: 1rem;
}
/* The page behind an open modal must not scroll: a wheel over the backdrop, or
   one carried on past the end of the modal, otherwise moves it out of sight.
   Keyed on the overlay's presence rather than a class JS toggles, so there is
   no open/close bookkeeping to fall out of step. Inner panels still chain into
   the modal, which carries the user on toward its actions. */
body:has(.modal-overlay) { overflow: hidden; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.75rem;
}
/* A read-out modal focuses its own panel (showModal's focus: 'panel') so the
   keyboard starts at the top; a ring round the whole dialog says nothing. */
.modal:focus { outline: none; }
.modal-scroll-panel {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  max-height: var(--modal-scroll-max-h, 160px);
  overflow-y: auto;
  padding: .5rem;
  background: var(--gray-50);
  border-radius: var(--radius);
}
/* Award tier editor: one add/remove row per award level. */
.tier-rows { display: flex; flex-direction: column; gap: .35rem; }
.tier-row {
  display: grid;
  grid-template-columns: 1fr 5.5rem auto;
  gap: .35rem;
  align-items: center;
}
.tier-row .btn { padding: .3rem .6rem; line-height: 1; }
/* Rank mode asks how many entries a level holds; score bands ask the score
   it starts at. Both inputs stay in the row so switching loses nothing. */
.tier-editor:not([data-method="band"]) [data-tier-min],
.tier-editor[data-method="band"] [data-tier-count] { display: none; }
.tier-help-band, .tier-help-rank { display: none; }
.tier-editor:not([data-method="band"]) + .form-help .tier-help-rank,
.tier-editor[data-method="band"] + .form-help .tier-help-band { display: inline; }

/* Judging & Results: rules a category is judged by, and who is not ranked. */
.ranking-rules { margin-bottom: .5rem; }
.not-ranked { margin-top: .75rem; }
.not-ranked ul { margin: .25rem 0 0 1.1rem; }

/* Entry title recipe: the parts as chips in title order, then an add menu. */
.title-chips { display: flex; flex-wrap: wrap; gap: .35rem; min-height: 1.9rem; margin-bottom: .5rem; }
.title-chip {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  max-width: 100%;
  padding: .2rem .25rem .2rem .65rem;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: var(--gold-pale);
  font-size: .82rem;
}
.title-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-chip-btn {
  font: inherit;
  border: 0;
  background: transparent;
  color: var(--text-muted-val);
  cursor: pointer;
  padding: 0 .3rem;
  line-height: 1.4;
  border-radius: 999px;
}
.title-chip-btn:hover { color: var(--text-body); }
.title-chip-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
/* The first chip has nothing to move before. */
.title-chip:first-child [data-action="title-part-up"] { display: none; }
.title-add { display: flex; gap: .4rem; align-items: center; }
.title-add .form-select { flex: 1 1 auto; min-width: 0; }
.title-warning { color: var(--orange); }

/* The applicant form's "Listed as" line, where the title field used to be. */
.app-listed-as {
  margin-bottom: 1rem;
  padding: .6rem .8rem;
  border-radius: var(--radius);
  background: var(--gray-50);
}

.modal,
.modal-scroll-panel {
  scrollbar-width: thin;
  scrollbar-color: var(--navy-lt) transparent;
}
.modal::-webkit-scrollbar,
.modal-scroll-panel::-webkit-scrollbar {
  width: 12px;
}
.modal::-webkit-scrollbar-track,
.modal-scroll-panel::-webkit-scrollbar-track {
  background: transparent;
}
.modal::-webkit-scrollbar-thumb,
.modal-scroll-panel::-webkit-scrollbar-thumb {
  background: var(--navy-lt);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
.modal::-webkit-scrollbar-thumb:hover,
.modal-scroll-panel::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
  background-clip: content-box;
}
/* A modal holding something to read rather than fill in. 560px is right for a
   form and far too narrow for a document page. */
.modal-wide { max-width: 1100px; }
.modal-title { font-size: 1.15rem; font-weight: 700; color: var(--text-body); margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }

/* The unsaved-changes prompt, layered over the form it is protecting rather
   than replacing it: the form must still be there, scrolled and caret intact,
   when the answer is "keep editing". It fills the overlay it is appended to, so
   the form behind is visibly dimmed but never torn down. */
.modal-discard {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-discard-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px;
  padding: 1.75rem;
}

/* ============================================================
   ALERTS & BANNERS
   ============================================================ */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .88rem;
  margin-bottom: 1rem;
}
.alert-info   { background: var(--blue-lt);   color: var(--blue); }
.alert-success { background: var(--green-lt);  color: var(--green); }
.alert-warn    { background: var(--orange-lt); color: var(--orange); }
.alert-error   { background: var(--red-lt);    color: var(--red); }

/* One-time tip (src/hints.js). Quieter than an alert: it explains, it never
   warns, and it must not compete with the work beside it. */
.hint {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .55rem .75rem; margin-bottom: .75rem;
  border: 1px solid var(--blue-lt); border-left: 3px solid var(--blue);
  border-radius: var(--radius);
  font-size: .85rem; color: var(--gray-600);
}
.hint-icon { color: var(--blue); margin-top: .15rem; }
.hint-text { flex: 1; min-width: 0; }
.hint-dismiss { flex-shrink: 0; margin: -.2rem -.3rem -.2rem 0; }

/* Judge Help tab (src/judge-help.js) */
.judge-help { max-width: 52rem; }
.jh-actions-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.jh-section p { line-height: 1.6; margin: 0 0 .65rem; }
.jh-section p:last-child { margin-bottom: 0; }
.jh-badges { list-style: none; padding: 0; margin: 0 0 .65rem; }
.jh-badges li { display: flex; gap: .6rem; align-items: baseline; padding: .2rem 0; font-size: .9rem; }
.jh-badges .badge { flex-shrink: 0; min-width: 7.5rem; text-align: center; }
.jh-steps { padding-left: 1.25rem; line-height: 1.8; margin: 0; }
@media print {
  body:has(.judge-help) > :not(#app) { display: none !important; }
  body:has(.judge-help) #app > :not(.main-content) { display: none !important; }
  .judge-help .jh-actions, .judge-help .jh-preview-note { display: none !important; }
  .judge-help .card { box-shadow: none; break-inside: avoid; }
}

/* Judging guidance (src/guidance-view.js): staff's words to judges. */
.guidance-panel { border: 1px solid var(--border); border-left: 3px solid var(--blue); border-radius: var(--radius); padding: 0; margin-bottom: 1rem; }
.guidance-panel.card { padding: 0; }
.guidance-summary { cursor: pointer; padding: .6rem .85rem; font-weight: 600; font-size: .9rem; color: var(--blue); }
.guidance-summary i { margin-right: .25rem; }
.guidance-body { padding: 0 .85rem .75rem; }
.guidance-part + .guidance-part { margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.guidance-part-title { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted-val); margin-bottom: .3rem; }
.score-item-help { white-space: pre-line; }
.score-guide { list-style: none; margin: .45rem 0 0; padding: 0; display: grid; gap: .2rem; }
.score-band { display: flex; gap: .6rem; align-items: baseline; font-size: .8rem; padding: .2rem .45rem; border-radius: var(--radius); color: var(--text-muted-val); border: 1px solid transparent; }
.score-band-range { flex-shrink: 0; min-width: 4.2rem; font-variant-numeric: tabular-nums; font-weight: 600; }
.score-band.is-current { color: var(--text-body); background: var(--blue-lt); border-color: var(--blue); }
.score-guide--static .score-band { padding-left: 0; }
.sg-row { display: grid; grid-template-columns: 4.5rem auto 4.5rem 1fr auto; gap: .4rem; align-items: center; margin-bottom: .4rem; }
@media (max-width: 560px) {
  .sg-row { grid-template-columns: 4rem auto 4rem auto; }
  .sg-row .sg-text { grid-column: 1 / -1; grid-row: 2; }
}
.guidance-caution { color: var(--orange); }
/* The program book reads as paper in either theme (see its own block). */
.program-book .score-guide { margin: .3rem 0 0; }
.program-book .score-band { color: #333; background: none; border: none; padding: 0; font-size: inherit; }

/* Judge tour (src/judge-tour.js): the offer, the sample stage and the coach
   panel docked at the bottom, which works the same on a phone. */
.tour-offer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; border-left: 3px solid var(--blue); }
.tour-offer-text { flex: 1 1 18rem; }
.tour-offer-actions { display: flex; gap: .5rem; }
.tour-stage { padding-bottom: 14rem; }
.tour-banner { padding: .5rem .75rem; margin-bottom: .75rem; border-radius: var(--radius); background: var(--blue-lt); color: var(--blue); }
.tour-sample { pointer-events: none; user-select: none; }
.tour-focus {
  position: relative; z-index: 2;
  border-radius: var(--radius);
  box-shadow: 0 0 0 3px var(--blue), 0 0 0 100vmax rgba(15, 23, 42, .35);
}
/* A bare field group has no padding of its own; give the ring room without
   moving the layout. */
.form-group.tour-focus { padding: .5rem; margin-left: -.5rem; margin-right: -.5rem; }
.tour-panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; justify-content: center; padding: 0 16px 16px; pointer-events: none; }
.tour-panel-inner {
  pointer-events: auto; width: 100%; max-width: 34rem;
  background: var(--bg-card); color: var(--text-body);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); padding: 1rem 1.1rem;
}
.tour-panel-inner p { margin: .35rem 0 .85rem; line-height: 1.55; font-size: .92rem; }
.tour-buttons { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.tour-buttons-right { display: flex; gap: .5rem; }

.offline-banner {
  background: var(--orange);
  color: var(--white);
  text-align: center;
  padding: .4rem 1rem;
  font-size: .85rem;
  font-weight: 600;
}

/* ============================================================
   MISC UTILITY
   ============================================================ */
.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm     { gap: .5rem; }
.gap-md     { gap: 1rem; }
.mt-sm      { margin-top: .5rem; }
.mt-md      { margin-top: 1rem; }
.mt-lg      { margin-top: 1.5rem; }
.mb-sm      { margin-bottom: .5rem; }
.mb-md      { margin-bottom: 1rem; }
.mb-lg      { margin-bottom: 1.5rem; }
.text-sm    { font-size: .83rem; }
.text-xs    { font-size: .75rem; }
.text-muted { color: var(--gray-400); }
.text-gold  { color: var(--gold); }
.text-red   { color: var(--red); }
.text-green { color: var(--green); }
.fw-bold    { font-weight: 700; }
.hidden     { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.pill-list { display: flex; flex-wrap: wrap; gap: .4rem; }

/* Staff dashboard share card: one row per link, the field taking the width
   and its buttons wrapping below it on a phone. */
.share-link { margin-bottom: 1rem; }
.share-link-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.share-link-field { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .25rem; }
.share-link-field .form-input { flex: 1 1 16rem; min-width: 0; font-family: ui-monospace, monospace; font-size: .85rem; }

/* ============================================================
   LANDING PAGE
   ============================================================ */
.landing-wrap {
  flex: 1 0 auto;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-lt) 60%, #2e5090 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1rem;
}
/* On a landing page the gradient belongs to the whole page, so the footer
   sits on it rather than on a flat strip beneath it. Without :has() support
   the footer keeps the page background, which is only less tidy. */
body:has(.landing-wrap) {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-lt) 60%, #2e5090 100%);
}
body:has(.landing-wrap) .landing-wrap { background: none; }
body:has(.landing-wrap) .app-footer { color: var(--gray-400);
}
.landing-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%; max-width: 440px;
}
.landing-logo { text-align: center; margin-bottom: 1.75rem; }
.landing-logo h1 { font-size: 4rem; font-weight: 900; color: var(--text-body); font-family: 'AeroviasBrasil', sans-serif; }
.landing-logo h1 span { color: var(--gold); }
.landing-logo p { color: var(--gray-400); font-size: .9rem; margin-top: .25rem; }

/* Open programs on the logged-out landing page (self-registration). */
.landing-section-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--gray-400); margin-bottom: .6rem;
}
.landing-programs { margin-bottom: 1.5rem; }
.landing-program {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .75rem; margin-bottom: .5rem;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.landing-program-main { min-width: 0; }
.landing-program-name {
  font-weight: 600; color: var(--text-body);
  overflow: hidden; text-overflow: ellipsis;
}
.landing-program-meta { font-size: .78rem; color: var(--gray-400); margin-top: .15rem; }
/* "or sign in" rule between the apply list and the returning-user form. */
.landing-divider {
  display: flex; align-items: center; gap: .75rem;
  margin: 1.25rem 0; color: var(--gray-400); font-size: .8rem;
}
.landing-divider::before, .landing-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.magic-link-box {
  background: var(--gold-pale);
  border: 1.5px solid var(--gold);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
  font-size: .85rem;
}
.magic-link-box a { color: var(--blue); font-weight: 600; word-break: break-all; }
.project-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .5rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.project-list-item:hover { border-color: var(--gold); background: var(--bg-row-hover); }

/* ============================================================
   APPLICATION FORM
   ============================================================ */
.app-form-header {
  background: var(--gold-pale);
  border: 1.5px solid var(--gold);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: .85rem;
}
/* Terms (terms-view.js): the project's general terms open on the apply screen,
   collapsed on the form and the landing page; a category's own always shown. */
.terms-heading { font-size: 1rem; font-weight: 700; margin: 0 0 .5rem; }
.terms-card > summary.terms-heading { cursor: pointer; margin: 0; }
.terms-card[open] > summary.terms-heading { margin-bottom: .5rem; }
.category-terms {
  border-left: 3px solid var(--gold);
  padding: .5rem .85rem;
  margin-bottom: 1rem;
  background: var(--gold-pale);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.category-terms-heading { font-weight: 700; font-size: .85rem; margin-bottom: .3rem; }
.terms-body { font-size: .88rem; line-height: 1.5; overflow-wrap: anywhere; }
.terms-body p { margin: 0 0 .6rem; }
/* The global reset strips list markers; terms bullets need them back. */
.terms-body ul { margin: 0 0 .6rem; padding-left: 1.25rem; list-style: disc; }
.terms-body li { margin-bottom: .2rem; }
.terms-body > :last-child { margin-bottom: 0; }
.terms-body a { color: var(--blue); }
.terms-disclosure {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem 1rem;
}
.terms-disclosure > summary { cursor: pointer; font-weight: 700; font-size: .9rem; }
.terms-disclosure[open] > summary { margin-bottom: .5rem; }
.terms-landing { margin-top: .4rem; padding: .35rem .6rem; }
.terms-landing > summary { font-size: .78rem; font-weight: 600; color: var(--gray-400); }
.app-criteria-panel {
  background: var(--bg-table-head);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.app-criteria-title { font-weight: 700; font-size: .95rem; margin-bottom: .2rem; }
.app-criteria-subtitle { font-size: .8rem; color: var(--text-muted-val); margin-bottom: .85rem; }
.app-criteria-list { display: flex; flex-direction: column; gap: .65rem; }
.app-criteria-item {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem .85rem;
}
.app-criteria-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  font-weight: 600;
  font-size: .88rem;
}
.app-criteria-help { font-size: .8rem; color: var(--text-muted-val); margin-top: .35rem; }
.attachment-list { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.attachment-item {
  display: flex; align-items: center; gap: .5rem;
  background: var(--bg-table-head); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .5rem .75rem;
  font-size: .83rem; color: var(--text-body);
}
.attachment-item .remove-att { margin-left: auto; cursor: pointer; color: var(--red); font-size: 1rem; }
.attachment-item .att-name { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.attachment-item .att-actions { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; margin-left: auto; }
.attachment-item .att-btn { padding: .2rem .6rem; font-size: .78rem; text-decoration: none; }

/* An upload slot: its files, then its own button and status line. The native
   file input stays in the DOM for the button to open, but is never shown:
   cleared after each pick, it read "No file chosen" over a list of files. */
.upload-zone {
  border: 1px dashed transparent; border-radius: var(--radius);
  transition: border-color .15s ease, background-color .15s ease;
}
.upload-zone > .attachment-list { margin-top: 0; margin-bottom: .5rem; }
/* The template's whitespace defeats :empty. */
.upload-zone > .attachment-list:not(:has(*)) { display: none; }
.upload-control { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.form-help + .upload-zone { margin-top: .5rem; }
.upload-control .file-upload-input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Drag and drop needs a hovering pointer; touch devices use the button. */
.drop-hint { display: none; }
@media (hover: hover) and (pointer: fine) {
  .drop-hint { display: inline; }
  .upload-zone { border-color: var(--border); padding: .5rem .75rem .6rem; }
}
.upload-slot.is-drop-target .upload-zone {
  border-color: var(--gold); border-style: solid;
  background: color-mix(in srgb, var(--gold) 8%, transparent);
}
.upload-slot.drop-refused .upload-zone { border-color: var(--red); cursor: not-allowed; }
.upload-slot.drop-refused .upload-control-status::after {
  content: " \00b7  This slot is full"; color: var(--red); font-weight: 600;
}

/* A file still uploading, or one that failed, in its slot's list. */
.upload-row {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: .5rem .75rem; font-size: .83rem; color: var(--text-body);
}
.upload-row .att-name { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.upload-row .att-actions { display: flex; gap: .25rem; margin-left: auto; }
.upload-row .att-btn { padding: .2rem .6rem; font-size: .78rem; }
.upload-row .upload-status { color: var(--text-muted-val); font-variant-numeric: tabular-nums; }
.upload-row.upload-failed { border-style: solid; border-color: var(--red); }
.upload-row.upload-failed .upload-status { color: var(--red); font-weight: 600; }
.upload-bar { flex: 1 0 100%; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.upload-bar > span { display: block; height: 100%; background: var(--gold); transition: width .2s ease; }
/* Bytes sent, server still checking and converting: motion, not a frozen 100%. */
.upload-bar-busy > span { animation: upload-busy 1.2s ease-in-out infinite alternate; }
@keyframes upload-busy { from { opacity: 1; } to { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .upload-bar-busy > span { animation: none; } }
.upload-indicator { color: var(--gold); white-space: nowrap; }
/* Looks unavailable but takes the click, which explains what it waits for. */
.btn.btn-pending { opacity: .6; cursor: progress; }

/* Document viewer. The frame is sized in viewport units so a page is readable
   without the modal growing past the screen; the modal itself already caps at
   90vh and scrolls. */
.att-view-body {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-table-head);
}
.att-view-frame { display: block; width: 100%; height: 70vh; border: 0; background: #fff; }
.att-view-image { display: block; width: 100%; max-height: 70vh; object-fit: contain; }

/* ============================================================
   JUDGING SCORECARD
   ============================================================ */
.score-item {
  background: var(--bg-table-head);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .75rem;
}
.score-item-label { font-weight: 600; font-size: .9rem; margin-bottom: .5rem; }
.score-item-help { font-size: .78rem; color: var(--gray-400); margin-bottom: .5rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 700px) {
  .main-content { padding: 1rem .75rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-row { flex-direction: column; }
  .form-row { flex-direction: column; }
  .modal { padding: 1.25rem; }
  .hero { padding: 1.25rem; }
  .hero h1 { font-size: 1.25rem; }
  .topbar { padding: 0 1rem; }
}
@media (max-width: 480px) {
  .nav-tab { padding: .6rem .7rem; font-size: .82rem; }
}

/* ---------------------------------------------------------------
   Required-answer validation on the application form
   ---------------------------------------------------------------
   Shown after a submit attempt that found unanswered required
   questions. The banner is sticky below the 56px topbar and carries
   the control that leaves the filtered view: on a form with twenty
   questions, the way back to the other nineteen must not be
   something the entrant has to scroll to find.
   z-index stays under the topbar's 100 so it tucks beneath it. */
.validation-banner {
  position: sticky; top: 56px; z-index: 90;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .75rem;
  background: var(--red-lt);
  border: 1px solid var(--red);
  border-left: 4px solid var(--red);
  border-right: none;
  border-radius: 0;
  padding: .7rem .9rem;
  font-size: .88rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  /* Pulled out to the card's edges: sitting inside the 1.5rem padding would
     leave a transparent gutter either side for content to scroll through. */
  margin: 0 -1.5rem 1rem;
}
.validation-banner-filtered {
  background: var(--gold-pale);
  border-color: var(--gold);
  border-left-color: var(--gold);
}
.validation-banner-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
/* Every gap the banner named has been filled in; it stays to carry the next
   step rather than vanishing under the judge's cursor. */
.validation-banner-ok {
  background: var(--green-lt);
  border-color: var(--green);
  border-left-color: var(--green);
}
/* A category group's body is padded 1rem, not the card's 1.5rem. */
.cat-row-body > .validation-banner { margin: 0 -1rem 1rem; }
.validation-banner-lines { display: flex; flex-direction: column; gap: .2rem; }

/* The marker on an unanswered question. Doubles as the selector the
   filtered view keeps, so the mark and the filter cannot disagree. */
.field-missing {
  border-left: 3px solid var(--red);
  padding-left: .75rem;
  margin-left: -.75rem;
}
.field-missing-note { font-size: .78rem; color: var(--red); margin-top: .25rem; font-weight: 600; }

/* Keep a scrolled-to field clear of the two sticky bars above it: the 56px
   topbar and the banner itself. Without this, jumping to the first unanswered
   question lands it underneath them. */
#application-form .form-group { scroll-margin-top: 140px; }
#scorecard-form .score-item,
#scorecard-form .form-group,
.judge-group { scroll-margin-top: 140px; }

/* A criterion is its own boxed panel, so the marker recolours the box rather
   than hanging a rule off its left edge the way a bare form field does. */
.score-item.field-missing {
  border-color: var(--red);
  border-left-width: 3px;
  padding-left: 1rem;
  margin-left: 0;
}

/* Filtered view. Hiding with CSS rather than rendering a subset keeps
   every field in the DOM, so readApplicationForm's FormData still sees
   the answers already given: toggling the filter cannot blank them.
   Consent and the attachment box are plain .form-group blocks, so they
   hide too - neither is outstanding, and both return with the rest. */
#application-form.filter-missing .form-group:not(.field-missing):not(.always-shown) { display: none; }

/* --- Applicant list filters and compact category rows ---------------------
   A program can run to twenty-odd categories, each with a paragraph of
   description, terms and its judging criteria. Expanded, that is several
   screens of scrolling to reach one category, so the resting state is a
   single row and the detail is behind an expander. */

.list-filter {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
}
.list-filter-input { flex: 1 1 auto; min-width: 0; }
.list-filter-count { white-space: nowrap; }

/* The summary IS the row: it must be the first child of its <details>, or the
   browser does not treat it as a disclosure control and the row never opens.
   That is why the Apply button sits INSIDE it rather than beside it, pushed to
   the end with margin-left:auto. A click anywhere in a summary toggles the
   expander, so handlers.js calls preventDefault() for an action button inside
   one; the action still runs, the disclosure does not. */
.cat-row { padding: 0; }
.cat-row-summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  list-style: none;
  padding: .85rem 1rem;
}
.cat-row-summary::-webkit-details-marker { display: none; }
/* The disclosure caret, drawn rather than inherited, so it can sit at the
   start of the row and rotate on open in both themes. */
.cat-row-summary::before {
  content: '';
  flex: 0 0 auto;
  width: 0; height: 0;
  border-left: 5px solid var(--text-muted-val);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .15s ease;
  transform-origin: 25% 50%;
  align-self: center;
}
.cat-row[open] > .cat-row-summary::before { transform: rotate(90deg); }
.cat-row-name { font-weight: 700; font-size: 1.02rem; flex: 0 1 auto; min-width: 0; }
.cat-row-meta {
  font-size: .8rem;
  color: var(--text-muted-val);
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
/* Pushed to the end of the summary row, and kept out of the wrap that the
   name and meta share. */
.cat-row-apply { flex: 0 0 auto; margin-left: auto; }
.cat-row-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
  padding-top: .85rem;
}
/* Inside an open row the criteria panel is the last thing in the body, so it
   carries no trailing margin of its own. */
.cat-row-body .app-criteria-panel { margin-bottom: 0; }

/* --- Judge coverage (staff Judges page) ----------------------------------
   A cat-row card whose summary carries the verdict and the target stepper,
   so the card is useful collapsed; the table is only for finding which. */
.cov-bad  { color: var(--red); }
.cov-warn { color: var(--orange); }
.cov-ok   { color: var(--green); }
.coverage-target { display: flex; align-items: center; gap: .35rem; }
/* Square, glyph centred both ways: .btn is a left-packed inline-flex, and the
   minus and plus glyphs sit at different heights in the font's line box. */
.coverage-target .btn {
  width: 2rem; height: 2rem; padding: 0;
  justify-content: center;
  font-size: 1rem; line-height: 1;
}
.coverage-target-value { min-width: 1.4rem; text-align: center; }
.coverage-empty .btn { margin-top: .25rem; }

/* --- Judge assignment list ------------------------------------------------
   Grouped by category (the cat-row disclosure above), with a filter bar of
   status buttons and category chips, compact entry rows, and an optional
   table of the judge's own scores for comparing within a category. */

.judge-filter { margin-bottom: 1rem; }
.judge-filter .list-filter { margin-bottom: .5rem; }
.judge-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .5rem;
}
.filter-chip-row { margin: -.5rem 0 1rem; }
.judge-chip, .filter-chip {
  font: inherit;
  font-size: .8rem;
  padding: .3rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-body);
  cursor: pointer;
}
.judge-chip:hover, .filter-chip:hover { border-color: var(--gold); }
.judge-chip.is-on, .filter-chip.is-on {
  background: var(--gold-pale);
  border-color: var(--gold);
  color: var(--text-body);
  font-weight: 600;
}
.judge-chip:focus-visible, .filter-chip:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.judge-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .65rem 0;
  border-top: 1px solid var(--border);
}
.judge-entry-main { min-width: 0; flex: 1 1 14rem; }
.judge-entry-badges { margin-top: .25rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.judge-entry-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Looks disabled but still takes the click, so the handler can say what is
   missing. A real `disabled` would swallow it silently. */
.btn.is-disabled { opacity: .5; cursor: not-allowed; }

/* ---- Compare my scores ----
   Entries are rows, criteria columns under short headers, the full questions
   in a key above. Below 640px the table gives way to one card per entry. */
.judge-compare { margin-bottom: .75rem; }

.judge-compare-key { margin-bottom: .6rem; font-size: .85rem; }
.judge-compare-key > summary { cursor: pointer; font-weight: 600; padding: .2rem 0; }
.judge-compare-key dl { margin: .35rem 0 0; display: grid; gap: .35rem; }
.judge-compare-key-row { display: grid; grid-template-columns: minmax(5rem, max-content) 1fr; gap: .75rem; }
.judge-compare-key dt { font-weight: 600; }
.judge-compare-key dd { margin: 0; }

/* Sized to its content rather than the card: two criteria spread across a
   full-width table put the scores a long way from the names they belong to. */
.judge-compare-table table { width: auto; font-size: .85rem; }
.judge-compare-table th, .judge-compare-table td { padding: .45rem .6rem; }
.judge-compare-table thead th { vertical-align: bottom; min-width: 4.5rem; max-width: 8rem; text-align: center; }
/* Row headers are entry names, not column labels: none of the thead styling. */
.judge-compare-table tbody th, .judge-compare-table tfoot th {
  text-transform: none; font-size: inherit; color: var(--text-body);
}

.judge-compare-sort {
  font: inherit; color: inherit; background: none; border: 0; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  width: 100%; text-align: center; cursor: pointer;
}
.judge-compare-sort:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.judge-compare-head { font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.judge-compare-sort:hover .judge-compare-head,
.judge-compare-sort.is-sorted .judge-compare-head {
  text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px;
}
.judge-compare-sub { font-size: .72rem; font-weight: 400; color: var(--text-muted-val); white-space: nowrap; }
.judge-compare-arrow { margin-left: .3rem; color: var(--gold); }

/* The entry column stays put while the scores scroll under it. */
.judge-compare-entry {
  position: sticky; left: 0; z-index: 1;
  background: var(--bg-card);
  min-width: 11rem; max-width: 18rem;
  text-align: left; font-weight: 400;
}
.judge-compare-table thead th.judge-compare-entry {
  background: var(--bg-table-head); z-index: 2; vertical-align: bottom; text-align: left;
}
.judge-compare-entry-cell { display: grid; grid-template-columns: 1.8rem 1fr; gap: .25rem; align-items: start; }
.judge-compare-rank { color: var(--text-muted-val); font-variant-numeric: tabular-nums; }
.judge-compare-open {
  font: inherit; font-weight: 600; color: inherit; background: none; border: 0; padding: 0;
  text-align: left; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.judge-compare-open:hover { text-decoration: underline; }
.judge-compare-open:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Shaded by the score's share of its maximum (--pct, set per cell), so
   criteria out of different maxima read on one scale. */
.judge-compare-score, .judge-compare-chip {
  background: color-mix(in srgb, var(--heat) calc(var(--pct) * var(--heat-max)), transparent);
}
.judge-compare-score, .judge-compare-total { text-align: center; font-variant-numeric: tabular-nums; }

.judge-compare-spread th, .judge-compare-spread td {
  font-size: .75rem; color: var(--text-muted-val); border-bottom: 0; text-align: center;
}
.judge-compare-spread .judge-compare-entry { text-align: left; }
.judge-compare-flat { display: block; color: var(--orange); font-weight: 600; white-space: nowrap; }

.judge-compare-cards { display: none; list-style: none; margin: 0; padding: 0; }
.judge-compare-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .55rem .7rem; }
.judge-compare-card-open {
  font: inherit; color: inherit; background: none; border: 0; padding: 0;
  width: 100%; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: 1.8rem 1fr auto; gap: .5rem; align-items: baseline;
}
.judge-compare-card-open:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.judge-compare-card-title { font-weight: 600; overflow-wrap: anywhere; }
.judge-compare-card-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.judge-compare-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.judge-compare-chip {
  font-size: .75rem; padding: .15rem .5rem;
  border: 1px solid var(--border); border-radius: 999px;
}

@media (max-width: 640px) {
  .judge-compare-table { display: none; }
  .judge-compare-cards { display: grid; gap: .5rem; }
}

.judge-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.judge-clear { margin-left: auto; color: var(--red); }

/* The criteria expander on the application form, where the panel IS the
   expander rather than a section inside one. */
.app-expander-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.app-expander-summary::-webkit-details-marker { display: none; }
.app-expander-summary::before {
  content: '';
  width: 0; height: 0;
  border-left: 5px solid var(--text-muted-val);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .15s ease;
  transform-origin: 25% 50%;
}
details[open] > .app-expander-summary::before { transform: rotate(90deg); }
/* Collapsed, the title is the whole panel, so its bottom margin would leave a
   gap inside the box. It returns when the panel opens. */
details.app-criteria-panel:not([open]) > .app-expander-summary { margin-bottom: 0; }

/* ---- Reorderable lists (src/reorder.js) ----
   A handle is dragged on a desktop pointer, or tapped to show a target in
   every gap. Targets are 44px tall so they are easy to hit on a phone. */
.reorder-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.reorder-handle {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; margin: -.5rem 0 -.5rem -.75rem;
  border-radius: var(--radius); color: var(--gray-400);
  cursor: grab; touch-action: manipulation; user-select: none;
}
.reorder-handle:hover { color: var(--gold); background: var(--gold-pale); }
.reorder-handle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.reorder-handle.is-active { color: var(--gold); background: var(--gold-pale); }
.reorder-item.is-dragging { opacity: .45; }
.reorder-item.is-dragging .reorder-handle { cursor: grabbing; }
.reorder-source > .card { outline: 2px dashed var(--gold); outline-offset: 3px; }
.reorder-source-bar {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  flex-wrap: wrap; font-size: .83rem; margin-bottom: .5rem; color: var(--text-body);
}
.reorder-target {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 44px; margin: 0 0 1.25rem;
  border: 2px dashed var(--gold); border-radius: var(--radius);
  background: var(--gold-pale); color: var(--gold);
  font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  cursor: pointer;
}
.reorder-target:hover, .reorder-target:focus-visible { background: var(--gold); color: var(--navy); outline: none; }
.reorder-target span { pointer-events: none; }

/* Category quick view: everything a category asks and every setting in force.
   Two columns on a wide screen (questions left, settings right), one below. */
.qv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.qv-nav { display: flex; gap: .4rem; flex-wrap: wrap; }
.qv-cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.25rem; }
@media (max-width: 860px) { .qv-cols { grid-template-columns: minmax(0, 1fr); } }
.qv-section { border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: 1rem; }
.qv-section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.qv-section-head h3 { font-size: .95rem; font-weight: 700; margin: 0; }
.qv-sub { font-size: .8rem; font-weight: 700; margin: .75rem 0 .25rem; }
.qv-dl { margin: 0; }
.qv-row { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: .5rem; padding: .3rem 0; border-top: 1px solid var(--border); font-size: .88rem; }
.qv-row:first-child { border-top: none; }
.qv-row dt { color: var(--text-muted-val); }
.qv-row dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .qv-row { grid-template-columns: minmax(0, 1fr); gap: .1rem; } }
.qv-src { font-size: .72rem; color: var(--text-muted-val); border: 1px solid var(--border); border-radius: 999px; padding: 0 .45rem; white-space: nowrap; }
.qv-src-own { color: var(--gold); border-color: var(--gold); }
.qv-qs { list-style: none; margin: 0; padding: 0; }
.qv-q { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.qv-q:first-child { border-top: none; }
.qv-q-main { min-width: 0; display: flex; flex-direction: column; gap: .25rem; overflow-wrap: anywhere; }
.qv-q-badges { display: flex; flex-wrap: wrap; gap: .25rem; }
.qv-q-extra { font-size: .78rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.qv-q-actions { display: flex; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; max-width: 45%; }
@media (max-width: 600px) {
  .qv-q { flex-direction: column; }
  .qv-q-actions { max-width: none; justify-content: flex-start; }
}
.qv-add { display: flex; gap: .5rem; margin-top: .6rem; }
.qv-add .form-select { flex: 1; min-width: 0; }
.qv-problems { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.qv-problem { font-size: .85rem; padding: .4rem .7rem; border-radius: var(--radius); }
.qv-problem-bad  { background: var(--red-lt); color: var(--red); }
.qv-problem-warn { background: var(--orange-lt); color: var(--orange); }
.qv-badge-bad  { background: var(--red-lt); color: var(--red); cursor: help; }
.qv-badge-warn { background: var(--orange-lt); color: var(--orange); cursor: help; }

/* --------------------------------------------------------------------------
   Program book: the printable record of a project's definition.
   It reads as paper in either theme, since it is a preview of what prints.
   Print shows the book alone: chrome, banners and the toolbar drop out, each
   category starts a page, and an item never splits across two.
   -------------------------------------------------------------------------- */
.pb-toolbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .4rem; }
.pb-toolbar .btn-gold { margin-left: auto; }
.pb-toolbar-help { margin: 0 0 1rem; }
.program-book {
  background: #fff; color: #1d2330; border-radius: var(--radius); box-shadow: var(--shadow);
  max-width: 820px; margin: 0 auto; padding: 2.5rem 3rem; font-size: .95rem; line-height: 1.5;
  overflow-wrap: anywhere;
}
.program-book a { color: #1f5fa8; }
.program-book.pb-no-settings .pb-settings { display: none; }
.pb-section { border-top: 2px solid #d9dde5; margin-top: 2.5rem; padding-top: 1.5rem; }
.pb-running { font-size: .72rem; color: #6b7385; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 1rem; }
.pb-cover { padding: 1rem 0; }
.pb-kicker { font-size: .8rem; color: #6b7385; text-transform: uppercase; letter-spacing: .06em; }
.pb-title { font-size: 2.2rem; line-height: 1.15; margin: .3rem 0 .2rem; color: #10172a; }
.pb-subtitle { font-size: 1.1rem; color: #8a6d12; font-weight: 600; margin-bottom: 1rem; }
.pb-lede { font-size: 1rem; margin: .5rem 0 1rem; white-space: pre-line; }
.pb-h1 { font-size: 1.6rem; margin: .2rem 0 .6rem; color: #10172a; }
.pb-h2 { font-size: 1.1rem; margin: 1.5rem 0 .4rem; color: #10172a; }
.pb-h3 { font-size: 1rem; margin: 1.4rem 0 .5rem; padding-bottom: .2rem; border-bottom: 1px solid #e3e6ec; color: #10172a; }
.pb-dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1.25rem; margin: .5rem 0; }
.pb-dl > div { display: contents; }
.pb-dl dt { color: #6b7385; }
.pb-dl dd { margin: 0; }
.pb-note { font-size: .82rem; color: #6b7385; margin: .4rem 0; }
.pb-muted { color: #8a91a1; }
.pb-toc { margin: .3rem 0 0; padding: 0; list-style: none; }
.pb-toc li { padding-left: 2rem; text-indent: -2rem; }
.pb-toc li:not(:has(.pb-toc-num)) { padding-left: 0; text-indent: 0; }
.pb-toc-num { display: inline-block; width: 2rem; text-indent: 0; color: #8a6d12; }
.pb-list { list-style: none; margin: 0; padding: 0; }
.pb-item { padding: .6rem 0; border-top: 1px solid #eef0f4; break-inside: avoid; }
.pb-item:first-child { border-top: none; }
.pb-item-head { font-weight: 600; color: #10172a; }
.pb-num { display: inline-block; min-width: 2.4rem; color: #8a6d12; }
.pb-item-meta { font-size: .8rem; color: #6b7385; margin-top: .15rem; }
.pb-help { font-size: .88rem; margin-top: .3rem; white-space: pre-line; }
.pb-options { margin: .3rem 0 0; padding-left: 1.4rem; font-size: .88rem; }
.pb-checks { list-style: '\2610  '; }
.pb-table-wrap { overflow-x: auto; margin: .4rem 0 1rem; }
/* Every property the app-wide table rules set is restated: those use theme
   tokens, which in the dark theme put pale text and dark rows on the paper. */
/* break-word, not the book's `anywhere`: only `anywhere` lowers a column's
   minimum width, which split "Program" into "Progra/m" in a narrow column. */
.pb-table { width: 100%; border-collapse: collapse; font-size: .8rem; color: #1d2330; overflow-wrap: break-word; }
.pb-table th, .pb-table td {
  text-align: left; vertical-align: top; padding: .35rem .5rem;
  border: 1px solid #c9ced8; color: #1d2330; background: transparent;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.pb-table th {
  background: #eef0f4; color: #10172a; font-weight: 600; font-size: .78rem;
  text-transform: none; letter-spacing: 0; border-bottom: 2px solid #9aa1b0;
}
.pb-table tr:last-child td { border-bottom: 1px solid #c9ced8; }
.pb-table tr:hover td { background: transparent; }
.pb-table tbody tr:nth-child(even) td { background: #f7f8fa; }
.pb-table tr { break-inside: avoid; }
.pb-table thead { display: table-header-group; }
.pb-id { font-family: ui-monospace, Consolas, monospace; font-size: .7rem; color: #6b7385; margin-top: .15rem; }
.program-book .terms-body a { color: #1f5fa8; }
@media (max-width: 700px) {
  .program-book { padding: 1.5rem 1rem; }
  .pb-title { font-size: 1.7rem; }
}
@media print {
  body:has(.program-book) > :not(#app) { display: none !important; }
  body:has(.program-book) #app > :not(.main-content) { display: none !important; }
  body:has(.program-book) .main-content > :not(.program-book) { display: none !important; }
  body:has(.program-book), body:has(.program-book) #app { background: #fff !important; }
  body:has(.program-book) .main-content { padding: 0; max-width: none; }
  .program-book { box-shadow: none; border-radius: 0; max-width: none; padding: 0; font-size: 10.5pt; }
  .pb-section { border-top: none; margin-top: 0; padding-top: 0; break-before: page; }
  .pb-h1, .pb-h2, .pb-h3 { break-after: avoid; }
  .pb-table-wrap { overflow: visible; }
}
@page { margin: 18mm 16mm; }

/* ── Invoicing ─────────────────────────────────────────────────────────── */
.inv-entry-list { border: 1px solid var(--border); border-radius: var(--radius); padding: .25rem .75rem; }
.inv-entry { display: flex; align-items: baseline; gap: .5rem; padding: .35rem 0; }
.inv-entry + .inv-entry { border-top: 1px solid var(--border); }
.inv-entry > span:first-of-type { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.inv-entry-fee { white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-total { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; font-variant-numeric: tabular-nums; }
.inv-row { border-top: 1px solid var(--border); padding: .75rem 0; }
.inv-row:first-of-type { border-top: none; }
.inv-lines { margin: .5rem 0 .5rem 1.1rem; list-style: disc; font-size: .88rem; }
.inv-method-row { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; margin-bottom: .5rem; }
.inv-method-row .form-group { margin-bottom: .4rem; }
.inv-reminder-row { border-top: 1px solid var(--border); padding: .6rem 0; }
.inv-reminder-row .form-row { margin-top: .35rem; }

/* ── Settings finder ───────────────────────────────────────────────────── */
.topbar-find {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--navy-lt); color: var(--gray-200);
  border: 1px solid transparent; border-radius: 99px;
  padding: .3rem .8rem; font-size: .82rem; cursor: pointer;
}
.topbar-find:hover, .topbar-find:focus-visible { color: var(--white); border-color: var(--gold); }
@media (max-width: 700px) {
  .topbar-find { padding: .35rem .5rem; }
  .topbar-find-label { display: none; }
}
.sf-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.sf-project { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.sf-project .form-label { margin: 0; }
.sf-project .form-select { max-width: 24rem; }
.sf-input { font-size: 1.05rem; }
.sf-hint { margin: .35rem 0 .6rem; }
.sf-results { list-style: none; margin: 0; padding: 0; }
.sf-area {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted-val); padding: .9rem 0 .25rem;
}
.sf-result { border-top: 1px solid var(--border); padding: .6rem .5rem; border-radius: var(--radius); }
.sf-result.is-active { background: var(--gold-pale); outline: 1px solid var(--gold); }
.sf-head { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.sf-go {
  background: none; border: none; padding: 0; cursor: pointer; text-align: left;
  font: inherit; font-weight: 700; color: var(--gray-800);
  text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px;
}
.sf-go:hover { text-decoration-thickness: 2px; }
.sf-go[aria-disabled="true"] { cursor: default; text-decoration: none; }
.sf-copy { margin-left: auto; }
.sf-badge-locked { background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--border); }
.sf-where { font-size: .8rem; color: var(--text-muted-val); margin-top: .1rem; }
.sf-value { font-size: .88rem; margin-top: .2rem; overflow-wrap: anywhere; }
.sf-blurb { font-size: .85rem; margin-top: .2rem; }
.sf-note { font-size: .82rem; color: var(--gray-800); margin-top: .3rem; padding-left: .5rem; border-left: 3px solid var(--orange); }
.sf-cats { margin-top: .4rem; }
.sf-cats-lead { font-size: .82rem; color: var(--text-muted-val); }
.sf-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .3rem 0 .4rem; }
.sf-chip {
  font-size: .78rem; border: 1px solid var(--gold); color: var(--gray-800); background: none;
  border-radius: 99px; padding: .1rem .55rem; cursor: pointer; max-width: 100%;
  overflow-wrap: anywhere; text-align: left;
}
.sf-chip:hover { background: var(--gold-pale); }
.sf-cat-select { max-width: 24rem; font-size: .85rem; }
.sf-empty { padding: 1rem .5rem; color: var(--text-muted-val); }

/* Where the finder landed. Outline rather than background, so a field's own
   state colours stay readable while it shows. */
.setting-flash { animation: setting-flash 2.2s ease-out; border-radius: var(--radius); }
@keyframes setting-flash {
  0%, 35% { box-shadow: 0 0 0 3px var(--gold); }
  100% { box-shadow: 0 0 0 3px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .setting-flash { animation: none; box-shadow: 0 0 0 3px var(--gold); }
}

/* A project-level field's note on which categories set their own. */
.setting-overrides { color: var(--gray-800); padding-left: .5rem; border-left: 3px solid var(--orange); margin-top: .35rem; }

/* Follow-project-window confirmation: one category per row, what moves under it. */
.follow-window-row { align-items: flex-start; padding: .4rem 0; }
.follow-window-row .form-help { display: block; margin-top: .15rem; }
.follow-window-row .follow-window-warn { color: var(--orange); }
.own-dates-notice { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem .75rem; }

/* Taking entries: the state, who forced it, and the buttons (intake-view.js). */
.intake-control { display: flex; flex-direction: column; gap: .3rem; }
.intake-state { display: flex; align-items: baseline; flex-wrap: wrap; gap: .4rem; }
.intake-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.intake-stale { color: var(--orange); }

/* Read by screen readers, not drawn: a header for a column of controls. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Payments: invoice lists ----
   Fixed layout with set widths for the short columns, so the text columns
   take the slack and a long address cannot squeeze Status. Long values are
   cut to one line by .inv-clip, whole on hover; the opened row shows them
   in full. */
.inv-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.inv-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.inv-chip-count { opacity: .75; margin-left: .15rem; }
.inv-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.inv-filters .list-filter { flex: 1 1 16rem; margin-bottom: 0; }
.inv-filters .form-select { width: auto; max-width: 14rem; }

.inv-table { table-layout: fixed; }
.inv-table th.inv-c-sel { width: 2.75rem; }
.inv-table th.inv-c-entries { width: 6.5rem; }
.inv-table th.inv-c-total { width: 7rem; }
.inv-table th.inv-c-status { width: 11rem; }
.inv-c-status .badge { white-space: nowrap; }
.inv-table th.inv-c-act { width: 11rem; }
.inv-table th.inv-c-act-narrow { width: 3.5rem; }
.inv-table td { vertical-align: top; }
.inv-table td.inv-c-sel { padding-right: 0; }

.inv-sort {
  font: inherit; color: inherit; background: none; border: 0; padding: 0;
  cursor: pointer; text-align: left; white-space: nowrap;
}
.inv-sort:hover, .inv-sort.is-sorted {
  text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px;
}
.inv-sort:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.inv-sort-arrow { margin-left: .3rem; color: var(--gold); }

.inv-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.inv-clip-inline {
  display: inline-block; max-width: 18rem; vertical-align: bottom;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.inv-row { cursor: pointer; }
.inv-row.is-open td { border-bottom-color: transparent; }
.inv-act { display: flex; gap: .25rem; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.inv-toggle { min-width: 2rem; }

.inv-detail td { background: var(--bg-table-head); padding-top: .25rem; }
.inv-detail:hover td { background: var(--bg-table-head); }
.inv-detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem 2rem; }
.inv-detail-lines { list-style: none; font-size: .85rem; }
.inv-detail-lines li { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; overflow-wrap: anywhere; }
.inv-detail-total { border-top: 1px solid var(--border); margin-top: .2rem; font-weight: 600; }
.inv-amt { white-space: nowrap; }
.inv-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .25rem 1rem; }
.inv-facts dt { color: var(--text-muted-val); }
.inv-facts dd { overflow-wrap: anywhere; }
.inv-detail-actions { display: flex; gap: .25rem; flex-wrap: wrap; margin-top: .75rem; }

@media (max-width: 860px) {
  .inv-detail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Narrow screens: each row becomes a card. The sort headers stay, as a row
   of buttons; the select and action headers have nothing to show. */
@media (max-width: 640px) {
  .inv-table, .inv-table thead, .inv-table tbody, .inv-table td { display: block; }
  .inv-table thead tr { display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
  .inv-table th { display: block; width: auto !important; background: none; border: 0; padding: .25rem 0 .5rem; }
  .inv-table th.inv-c-sel, .inv-table th.inv-c-act { display: none; }
  .inv-table tbody tr { display: flex; flex-wrap: wrap; align-items: baseline; border-bottom: 1px solid var(--border); padding: .5rem 0; }
  .inv-table tbody tr.is-open { border-bottom: 0; }
  .inv-table tbody td { border: 0; padding: .2rem .5rem; }
  .inv-table td.inv-c-sel { flex: 0 0 2rem; padding: .2rem 0 0; }
  .inv-table td.inv-c-who, .inv-table td.inv-c-lines { flex: 1 1 calc(100% - 2rem); min-width: 0; }
  .inv-table td.inv-c-act { flex: 0 0 auto; margin-left: auto; }
  .inv-table tr.inv-detail { padding: 0; }
  .inv-table tr.inv-detail td { flex: 1 1 100%; padding: .75rem .5rem; }
}
