:root {
  /* Purnam palette, shared with the finance dashboard */
  --brand: #005495;        /* USAFA blue */
  --brand-600: #00467c;
  --whale: #09304D;        /* blue whale */
  --sky: #3399CC;          /* celestial blue */
  --hippie: #5095B3;
  --mist: #CCECFF;         /* pattens blue */
  --saffron: #FFBD59;
  --navajo: #FFDFAE;
  --brand-50: #eef5fb;
  --brand-100: #d9e8f5;
  --ink: #1E293B;
  --ink-2: #475569;
  --muted: #64748B;
  --line: #E2E8F0;
  --line-2: #EDF1F6;
  --bg: #F4F6F9;
  --card: #ffffff;
  --ok: #2E7D32;
  --ok-50: #E8F5E9;
  --warn: #9A5B00;
  --warn-50: #FFF5E0;
  --bad: #C62828;
  --bad-50: #FDECEA;
  --radius: 18px;
  --shadow: 0 4px 20px rgba(9, 48, 77, .04), 0 1px 2px rgba(9, 48, 77, .04);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ── Frame ─────────────────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px max(16px, calc((100vw - 640px) / 2));
  background: rgba(246, 248, 251, .88);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line-2);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; }
.brand-name { font-family: 'Times New Roman', Georgia, serif; font-weight: 700; letter-spacing: .08em; color: var(--brand); font-size: 18px; }
h1, h2, .display { font-family: Outfit, Inter, sans-serif; }
.top-note { color: var(--muted); font-size: 13px; font-weight: 500; }
.page { max-width: 640px; margin: 0 auto; padding: 20px 16px 24px; }

.hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: 24px 22px 22px; margin-bottom: 16px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #1d7bbf 0%, transparent 55%), linear-gradient(135deg, var(--whale) 0%, var(--brand) 100%);
  box-shadow: 0 10px 30px rgba(9, 48, 77, .18);
}
.hero::after {
  content: ''; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%;
  border: 2px solid rgba(204, 236, 255, .18); box-shadow: 0 0 0 26px rgba(204, 236, 255, .05);
}
.hero h1 { font-size: 26px; line-height: 1.15; letter-spacing: -.01em; margin: 0 0 6px; font-weight: 600; }
.hero p { margin: 0; color: rgba(255,255,255,.82); max-width: 460px; }
.hero .perks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hero .perk { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; padding: 6px 10px; border-radius: 999px; background: rgba(255,255,255,.12); color: #fff; }
.hero .perk svg { width: 14px; height: 14px; color: var(--saffron); }

.card {
  background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.card-head { align-items: center; }
.sec-ico {
  flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-50), var(--mist)); color: var(--brand);
}
.sec-ico svg { width: 19px; height: 19px; }
.card-head h2 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: -.005em; }
.card-head .sub { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 1px; font-family: Inter, sans-serif; }
.card-head .aside { margin-left: auto; font-size: 13px; color: var(--muted); }

/* ── Fields ────────────────────────────────────────────────────────── */
.field { margin-top: 14px; }
.field:first-child { margin-top: 0; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.label .opt { font-weight: 400; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; align-items: start; }
.row .field { margin-top: 0; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
  min-height: 48px;
}
.textarea { min-height: 84px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-100); }
.money { position: relative; }
.money span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.money .input { padding-left: 32px; font-weight: 600; font-variant-numeric: tabular-nums; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.error-text { font-size: 12.5px; color: var(--bad); margin-top: 6px; font-weight: 500; }
.has-error .input, .has-error .select, .has-error .choices, .has-error .drop { border-color: var(--bad); }
.link { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; font-size: 13px; }
.link:hover { text-decoration: underline; }

/* ── Chips ─────────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 9px 14px;
  font-weight: 500; font-size: 14px; transition: all .15s; min-height: 40px;
}
.chip:hover { border-color: #c9d3de; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.soft { background: var(--brand-50); border-color: transparent; color: var(--brand); }
.chip .amt { margin-left: 8px; font-weight: 500; opacity: .7; font-variant-numeric: tabular-nums; }
.hint { display: block; margin-top: 6px; font-size: 12.5px; }
.chip.soft:hover { background: var(--brand-100); }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding: 0 28px 4px 4px; margin: 0 -4px; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.scroll .chip { flex: none; }

.me { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--brand-50); color: var(--brand); font-weight: 700;
}
.me strong { display: block; font-size: 15px; }
.me .help { margin: 0; }
.me .link { margin-left: auto; }

/* ── Choice cards ─────────────────────────────────────────────────── */
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; border-radius: 14px; }
.choice {
  text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 14px;
  padding: 14px; transition: all .15s; display: flex; flex-direction: column; gap: 8px; min-height: 104px;
}
.choice:hover { border-color: #c9d3de; }
.choice .ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--bg); color: var(--ink-2); }
.choice .ico svg { width: 18px; height: 18px; }
.choice .txt { display: flex; flex-direction: column; gap: 2px; }
.choice b { font-size: 14px; font-weight: 600; }
.choice small { color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.choice.on { border-color: var(--brand); background: var(--brand-50); }
.choice.on .ico { background: var(--brand); color: #fff; }

.mode { margin-top: 18px; }
.mode .seg { display: flex; width: max-content; margin-top: 6px; }
.seg { display: inline-flex; background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px; margin-top: 12px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 8px 14px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.seg button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(16,32,43,.1); }

.panel { margin-top: 14px; padding: 16px; border-radius: 14px; background: var(--bg); }
.bank { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 8px; color: var(--ink-2); }
.bank.ok { color: var(--ok); } .bank.bad { color: var(--bad); }
.bank svg { width: 16px; height: 16px; flex: none; }

/* ── Bill upload ──────────────────────────────────────────────────── */
.drop {
  border: 1.5px dashed #c9d3de; border-radius: 14px; padding: 22px 16px; text-align: center;
  background: #fbfcfe; transition: all .15s; cursor: pointer; display: block;
}
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-50); }
.drop .ico { width: 44px; height: 44px; margin: 0 auto 8px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.drop .ico svg { width: 22px; height: 22px; }
.drop b { display: block; font-weight: 600; }
.drop small { color: var(--muted); }
.files { display: grid; gap: 8px; margin-top: 10px; }
.file { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 8px; border: 1px solid var(--line); border-radius: 12px; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--brand-50); display: grid; place-items: center; color: var(--brand); font-size: 11px; font-weight: 700; flex: none; }
.file .meta { flex: 1; min-width: 0; }
.file .meta b { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file .meta small { color: var(--muted); font-size: 12px; }
.icon-btn { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 9px; color: var(--muted); display: grid; place-items: center; }
.icon-btn:hover { background: var(--bg); color: var(--bad); }
.icon-btn svg { width: 18px; height: 18px; }

.toggle { display: flex; align-items: center; gap: 12px; margin-top: 14px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 40px; height: 24px; border-radius: 999px; background: #d4dbe3; position: relative; transition: background .15s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.toggle input:checked + .switch { background: var(--brand); }
.toggle input:checked + .switch::after { transform: translateX(16px); }
.toggle span:last-child { font-size: 14px; font-weight: 500; }

/* ── Category picker ──────────────────────────────────────────────── */
.combo { position: relative; }
.combo .input { padding-right: 40px; }
.combo .caret { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; max-height: 280px; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(16,32,43,.12); padding: 6px;
}
.menu .opt { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.menu .opt small { display: block; color: var(--muted); font-size: 12px; }
.menu .opt:hover, .menu .opt.active { background: var(--brand-50); }
.menu .empty { padding: 12px; color: var(--muted); font-size: 13px; }

.more { margin-top: 4px; }
.more summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--brand); padding: 4px 0; }
.more summary::-webkit-details-marker { display: none; }
.more summary svg { width: 16px; height: 16px; transition: transform .15s; }
.more[open] summary svg { transform: rotate(90deg); }

/* ── Submit bar ───────────────────────────────────────────────────── */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 12px max(16px, calc((100vw - 640px) / 2)) calc(12px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.94); backdrop-filter: blur(10px); border-top: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 12px;
}
.bar .sum { flex: 1; min-width: 0; }
.bar .sum b { display: block; font-family: Outfit, Inter, sans-serif; font-size: 19px; font-variant-numeric: tabular-nums; }
.bar .sum small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn {
  border: 0; border-radius: 12px; padding: 13px 22px; font-weight: 600; font-size: 15px;
  background: var(--brand); color: #fff; display: inline-flex; align-items: center; gap: 8px; min-height: 48px;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-600); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--brand-50); color: var(--brand); }
.btn svg { width: 18px; height: 18px; }

.turnstile { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.label svg.inline { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; color: var(--brand); }
.banner svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; }

/* ── States ───────────────────────────────────────────────────────── */
.loading { text-align: center; padding: 80px 0; color: var(--muted); }
.spinner { width: 28px; height: 28px; margin: 0 auto 14px; border-radius: 50%; border: 3px solid var(--brand-100); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; }
.banner.bad { background: var(--bad-50); color: var(--bad); }
.banner.warn { background: var(--warn-50); color: var(--warn); }

.done { text-align: center; padding: 36px 20px; }
.done .tick { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; background: var(--ok-50); color: var(--ok); display: grid; place-items: center; }
.done .tick svg { width: 32px; height: 32px; }
.done h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: -.02em; }
.done p { color: var(--ink-2); margin: 0 0 18px; }
.recap { text-align: left; border: 1px solid var(--line); border-radius: 14px; padding: 6px 16px; margin: 0 0 20px; }
.recap div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.recap div:last-child { border: 0; }
.recap span { color: var(--muted); }
.recap b { font-weight: 600; text-align: right; }

.first .fade-in { animation: fade .3s ease-out both; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (max-width: 520px) {
  .choices { grid-template-columns: 1fr; }
  .choice { flex-direction: row; align-items: center; min-height: 0; }
  .row { grid-template-columns: 1fr; }
  .card { padding: 18px 16px; }
}
