:root {
  --bg: #f4f8f9;
  --surface: #ffffff;
  --text: #16232a;
  --text-muted: #526b73;
  --border: #dde8ea;

  --brand-700: #123f4d;
  --brand-600: #1d6577;
  --brand-500: #2d8398;
  --brand-400: #4aa4b8;
  --brand-100: #e3f1f4;
  --accent-contrast: #ffffff;

  --ok: #1c7a4b;
  --ok-bg: #e5f4ec;
  --warn: #9a5b12;
  --warn-bg: #fbeedd;

  --heading-font: "Poppins", "Segoe UI", system-ui, -apple-system, sans-serif;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(18, 63, 77, 0.08);
  --shadow-md: 0 10px 30px rgba(18, 63, 77, 0.16);

  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */

.site-header {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-600) 55%, var(--brand-500) 100%);
  color: var(--accent-contrast);
  padding: 40px 0 48px;
}

.header-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.9;
}

.header-bg svg {
  width: 100%;
  height: 100%;
}

.header-row {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.built-by {
  position: absolute;
  top: 16px;
  right: 24px;
  z-index: 1;
  text-align: right;
  font-size: 0.78rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.75);
}

.built-by strong { color: #ffffff; font-weight: 600; }
.built-by a { color: rgba(255, 255, 255, 0.75); text-decoration: none; }
.built-by a:hover { text-decoration: underline; }

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logomark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

.site-header h1 {
  margin: 0 0 4px;
  font-family: var(--heading-font);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: 1.7rem;
}

.subtitle {
  margin: 0;
  opacity: 0.88;
  font-size: 0.95rem;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.user-area[hidden] { display: none; }

.text-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: var(--accent-contrast);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease;
}

.text-btn:hover { background: rgba(255, 255, 255, 0.18); }

/* ---------- Login gate ---------- */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
  padding: 24px;
}

.auth-gate[hidden] { display: none; }

.auth-gate-box { max-width: 320px; }

.auth-user-badge {
  position: absolute;
  top: 16px;
  left: 24px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.85);
}

.auth-user-badge[hidden] { display: none; }

.auth-user-badge button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #ffffff;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 0.72rem;
  font-family: inherit;
}

.auth-user-badge button:hover { background: rgba(255, 255, 255, 0.18); }

/* ---------- Disclaimer banner ---------- */

.disclaimer {
  margin: -22px 0 32px;
  position: relative;
  z-index: 2;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-500);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 16px 20px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.disclaimer strong { color: var(--text); }

/* ---------- Wizard steps ---------- */

.step {
  margin: 0 0 32px;
}

.step h2 {
  font-family: var(--heading-font);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: 1rem;
  color: var(--brand-700);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-600);
  color: #fff;
  font-size: 0.75rem;
  flex: 0 0 auto;
}

.step-hint {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.search-input {
  width: 100%;
  max-width: 480px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}

.search-input:focus {
  outline: none;
  border-color: var(--brand-500);
}

.chip {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover { border-color: var(--brand-400); }

.chip[aria-pressed="true"] {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
  font-weight: 600;
}

.chip.chip-sm {
  padding: 7px 14px;
  font-size: 0.82rem;
}

.qualify-filter-block {
  margin-bottom: 18px;
}

.qualify-filter-row {
  margin-top: 12px;
}

.chip-ok[aria-pressed="true"] {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.chip-warn[aria-pressed="true"] {
  background: var(--warn);
  border-color: var(--warn);
  color: #fff;
}

.qualify-filter-hint {
  margin-top: 8px;
  margin-bottom: 0;
}

details.step2-details summary {
  cursor: pointer;
  font-family: var(--heading-font);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: 1rem;
  color: var(--brand-700);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

details.step2-details summary::-webkit-details-marker { display: none; }

details.step2-details summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

details.step2-details[open] summary::after { transform: rotate(180deg); }

details.step2-details .step-hint { margin-top: 4px; }
details.step2-details .chip-row { margin-top: 14px; }

/* ---------- Results ---------- */

.results-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 16px;
  flex-wrap: wrap;
}

.results-meta h2 {
  font-family: var(--heading-font);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: 1rem;
  color: var(--brand-700);
  margin: 0;
}

.results-count {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.program-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin: 0 0 48px;
}

.program-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
}

.program-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.program-card h3 {
  margin: 0;
  font-size: 1.15rem;
  font-family: var(--heading-font);
  font-weight: 700;
  color: var(--brand-700);
}

.badge {
  display: inline-block;
  background: var(--brand-100);
  color: var(--brand-700);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge.badge-field {
  background: var(--warn-bg);
  color: var(--warn);
}

.program-summary {
  color: var(--text);
  margin: 6px 0 14px;
}

.program-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.program-detail dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 3px;
  font-weight: 600;
}

.program-detail dd {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
}

.eligibility-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.eligibility-note.ok { background: var(--ok-bg); color: var(--ok); }
.eligibility-note.warn { background: var(--warn-bg); color: var(--warn); }
.eligibility-note.neutral { background: var(--brand-100); color: var(--brand-700); }

.program-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--brand-600);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
}

.program-link:hover { text-decoration: underline; }

.program-link svg { width: 14px; height: 14px; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  text-align: center;
}

.logomark-small {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  opacity: 0.7;
}

.footer-row p { margin: 0; }
.footer-note { font-size: 0.78rem; opacity: 0.85; }

@media (max-width: 560px) {
  .site-header { padding: 32px 0 40px; }
  .disclaimer { margin-top: -18px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2025;
    --text: #eef0f2;
    --text-muted: #9aa2ad;
    --border: #2c3038;
    --brand-100: #2a3a3d;
    --ok-bg: #16301f;
    --warn-bg: #3a2c14;
  }
}
