:root {
  --ink: #172033;
  --ink-soft: #4d586c;
  --line: #d9dee7;
  --paper: #ffffff;
  --canvas: #f3f5f8;
  --navy: #172b4d;
  --blue: #2f63d8;
  --blue-dark: #204aa7;
  --blue-pale: #edf3ff;
  --amber: #a15c08;
  --amber-pale: #fff4df;
  --red: #a73535;
  --red-pale: #fff0f0;
  --green: #196548;
  --green-pale: #eaf7f1;
  --shadow: 0 16px 40px rgba(23, 32, 51, 0.08);
}

* { box-sizing: border-box; }

html {
  color: var(--ink);
  background: var(--canvas);
  font-family: "Lota Grotesque Alt 3", "Aptos", "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

body { margin: 0; min-height: 100vh; }

button, input, select, textarea { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; }

.site-header {
  min-height: 72px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 15px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.brand-label {
  padding-left: 15px;
  color: var(--ink-soft);
  border-left: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.text-link {
  color: var(--blue-dark);
  font-size: 0.9rem;
  font-weight: 750;
  text-underline-offset: 4px;
}

.page-shell,
.admin-shell {
  width: min(1180px, 90vw);
  margin: 0 auto;
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.75fr);
  gap: 64px;
  align-items: center;
  padding: 82px 0 64px;
}

.eyebrow,
.section-label {
  margin: 0 0 12px;
  color: var(--blue-dark);
  font-size: 0.73rem;
  font-weight: 850;
  letter-spacing: 0.16em;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  max-width: 760px;
  margin-bottom: 20px;
  font-size: clamp(2.2rem, 5vw, 4.65rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  letter-spacing: -0.025em;
}

h3 { font-size: 1rem; letter-spacing: -0.01em; }

.lede {
  max-width: 700px;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 1.08rem;
}

.lede.compact { max-width: 620px; font-size: 1rem; }

.process-card {
  padding: 28px;
  background: var(--navy);
  color: white;
  box-shadow: var(--shadow);
}

.process-card .section-label { color: #b9ceff; }

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  padding: 17px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.steps li > span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--navy);
  background: white;
  font-size: 0.78rem;
  font-weight: 900;
}

.steps strong, .steps small { display: block; }
.steps small { margin-top: 3px; color: #dce5f7; line-height: 1.35; }

.form-section,
.success-panel {
  margin-bottom: 80px;
  padding: clamp(24px, 5vw, 54px);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.section-heading p:last-child {
  color: var(--ink-soft);
  font-size: 0.8rem;
  white-space: nowrap;
}

.required-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 5px;
  background: var(--blue);
}

fieldset {
  margin: 0;
  padding: 34px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
}

legend {
  width: 100%;
  margin-bottom: 22px;
  padding: 0;
  font-size: 1.05rem;
  font-weight: 850;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.wide-field { grid-column: 1 / -1; }

label { display: block; color: var(--ink); font-weight: 720; }
label > span { display: block; margin-bottom: 7px; font-size: 0.86rem; }
label b { color: var(--blue); }

input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid #b9c1cf;
  border-radius: 0;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus {
  background: white;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 99, 216, 0.14);
}

label small {
  display: block;
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 500;
}

.check-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: start;
  margin: 26px 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
}

.check-row input {
  width: 19px;
  min-height: 19px;
  height: 19px;
  margin: 2px 0 0;
  accent-color: var(--blue);
}

.check-row span { margin: 0; }

.security-row {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.security-row p { margin: 0; color: var(--ink-soft); font-size: 0.82rem; }

.primary-button,
.secondary-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 0;
  cursor: pointer;
  font-weight: 800;
  transition: background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.primary-button {
  min-height: 48px;
  padding: 12px 22px;
  color: white;
  background: var(--blue);
}

.primary-button:hover { background: var(--blue-dark); }

.secondary-button {
  min-height: 44px;
  padding: 10px 18px;
  color: var(--ink);
  background: white;
  border-color: #b9c1cf;
}

.secondary-button:hover { background: var(--canvas); border-color: #8d98aa; }

.primary-button:disabled,
.secondary-button:disabled { cursor: wait; opacity: 0.58; }

.compact-button { min-height: 42px; padding: 9px 16px; font-size: 0.86rem; }

.form-message {
  min-height: 0;
  margin: 0 0 16px;
  font-size: 0.9rem;
  font-weight: 700;
}

.form-message:empty { margin: 0; }
.form-message.error { padding: 12px 14px; color: var(--red); background: var(--red-pale); border-left: 4px solid var(--red); }
.form-message.success { padding: 12px 14px; color: var(--green); background: var(--green-pale); border-left: 4px solid var(--green); }

.success-panel {
  max-width: 760px;
  margin-top: 64px;
}

footer {
  min-height: 92px;
  padding: 22px 5vw;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: #c8d2e4;
  background: var(--navy);
  font-size: 0.8rem;
  text-align: center;
}

footer a { text-underline-offset: 3px; }

/* Admin */

.admin-body { background: #eef1f5; }
.admin-header { position: sticky; top: 0; z-index: 10; }
.header-actions { display: flex; align-items: center; gap: 18px; }

.identity-chip {
  padding: 6px 9px;
  color: var(--ink-soft);
  background: var(--canvas);
  border: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 750;
}

.admin-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 54px 0 28px;
}

.admin-title-row h1 { margin-bottom: 10px; font-size: clamp(2rem, 4vw, 3.5rem); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: white;
}

.metric-grid article {
  min-height: 112px;
  padding: 22px;
  border-right: 1px solid var(--line);
}

.metric-grid article:last-child { border-right: 0; }
.metric-grid span { display: block; color: var(--ink-soft); font-size: 0.78rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.06em; }
.metric-grid strong { display: block; margin-top: 8px; font-size: 2.2rem; line-height: 1; }

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(180px, 0.35fr) auto auto;
  gap: 10px;
  padding: 22px 0;
}

.toolbar input, .toolbar select { min-height: 42px; background: white; }

.referral-list { display: grid; gap: 14px; padding-bottom: 80px; }

.referral-card {
  background: white;
  border: 1px solid var(--line);
  box-shadow: 0 5px 16px rgba(23, 32, 51, 0.035);
}

.referral-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px 16px;
}

.card-kicker { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.stage-badge, .status-badge { padding: 4px 8px; font-size: 0.68rem; font-weight: 850; letter-spacing: 0.045em; text-transform: uppercase; }
.stage-badge { color: var(--blue-dark); background: var(--blue-pale); }
.status-badge { color: var(--ink-soft); background: var(--canvas); }
.status-badge.review { color: var(--amber); background: var(--amber-pale); }
.status-badge.ineligible { color: var(--red); background: var(--red-pale); }
.status-badge.completed { color: var(--green); background: var(--green-pale); }

.referral-names { margin-bottom: 5px; font-size: 1.08rem; }
.referral-meta { margin: 0; color: var(--ink-soft); font-size: 0.8rem; }
.card-date { min-width: 155px; text-align: right; }
.card-date span { display: block; color: var(--ink-soft); font-size: 0.7rem; font-weight: 750; text-transform: uppercase; }
.card-date strong { display: block; margin-top: 3px; font-size: 0.91rem; }

.card-progress { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: 4px; gap: 2px; padding: 0 24px; }
.card-progress span { background: #dfe4ec; }
.card-progress span.complete { background: var(--blue); }

details { margin-top: 16px; border-top: 1px solid var(--line); }
summary { padding: 14px 24px; color: var(--blue-dark); cursor: pointer; font-size: 0.82rem; font-weight: 800; }
summary:hover { background: #fafbfc; }

.detail-layout {
  display: grid;
  grid-template-columns: 1.45fr 0.85fr;
  gap: 34px;
  padding: 24px;
  border-top: 1px solid var(--line);
}

.detail-layout .field-grid { gap: 14px; }
.detail-layout label > span { font-size: 0.76rem; }
.detail-layout input, .detail-layout select, .detail-layout textarea { min-height: 40px; padding: 8px 10px; font-size: 0.86rem; }
.details-form .secondary-button { margin-top: 16px; }
.next-action-copy { min-height: 42px; color: var(--ink-soft); font-size: 0.86rem; }
.advance-stage, .resend-notification { width: 100%; margin-bottom: 9px; }
.note-form { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.note-form .secondary-button { width: 100%; margin-top: 8px; }

.history-panel { padding: 20px 24px 24px; background: #fafbfc; border-top: 1px solid var(--line); }
.history-list { margin: 0; padding: 0; list-style: none; }
.history-list li { display: grid; grid-template-columns: minmax(150px, 0.25fr) 1fr; gap: 20px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 0.8rem; }
.history-list time { color: var(--ink-soft); }
.history-list p { margin: 0; }
.history-list small { display: block; margin-top: 3px; color: var(--ink-soft); }

.empty-state { padding: 60px 24px; color: var(--ink-soft); background: white; border: 1px solid var(--line); text-align: center; }

dialog {
  width: min(640px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(23, 32, 51, 0.28);
}

dialog::backdrop { background: rgba(23, 32, 51, 0.56); backdrop-filter: blur(2px); }
dialog form { padding: 28px; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; }
.icon-button { width: 38px; height: 38px; color: var(--ink); background: white; border-color: var(--line); font-size: 1.5rem; line-height: 1; }
.dialog-copy { color: var(--ink-soft); font-size: 0.86rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
#settings-form > label + label { margin-top: 16px; }

.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;
}

@media (max-width: 860px) {
  .intro-grid { grid-template-columns: 1fr; gap: 34px; padding-top: 54px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-grid article:nth-child(2) { border-right: 0; }
  .metric-grid article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .detail-layout { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .site-header { padding: 12px 5vw; align-items: start; }
  .brand { align-items: start; }
  .brand-label { max-width: 125px; }
  .site-header > .text-link, .identity-chip { display: none; }
  .page-shell, .admin-shell { width: min(94vw, 1180px); }
  .field-grid { grid-template-columns: 1fr; }
  .wide-field { grid-column: auto; }
  .section-heading, .admin-title-row { align-items: start; flex-direction: column; }
  .form-section { padding: 22px; }
  .security-row { align-items: start; flex-direction: column; }
  footer { flex-direction: column; gap: 6px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid article { min-height: 92px; padding: 16px; }
  .toolbar { grid-template-columns: 1fr; }
  .toolbar > * { grid-column: auto; }
  .referral-summary { align-items: start; }
  .card-date { min-width: 110px; }
  .detail-layout, .history-panel { padding: 18px; }
  .history-list li { grid-template-columns: 1fr; gap: 3px; }
}
