:root {
    --ink: #17133d;
    --muted: #676486;
    --line: #e5e4f0;
    --page: #f7f7fb;
    --panel: #ffffff;
    --purple: #5438d8;
    --purple-dark: #3822aa;
    --purple-soft: #efedff;
    --green: #08783f;
    --green-soft: #e4f7ea;
    --red: #a81740;
    --red-soft: #fee8ed;
    --amber: #8f5700;
    --amber-soft: #fff2d8;
    --shadow: 0 8px 28px rgba(33, 25, 83, .08);
}

* { box-sizing: border-box; }
html { background: var(--page); }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--page); font: 16px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-shell { min-height: 100vh; padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
.app-header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 12px 20px; background: rgba(247, 247, 251, .95); border-bottom: 1px solid rgba(229, 228, 240, .9); backdrop-filter: blur(12px); }
.brand { display: inline-flex; max-width: 135px; }
.brand img { display: block; width: 100%; height: 32px; object-fit: contain; object-position: left; }
.header-label { color: var(--muted); font-size: .82rem; font-weight: 700; }
.page-content { width: min(100%, 720px); margin: 0 auto; padding: 24px 16px 32px; }
.page-loading, .empty-state { padding: 36px 18px; color: var(--muted); text-align: center; }

.bottom-nav { position: fixed; z-index: 20; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 7px 5px calc(7px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(27, 21, 70, .06); backdrop-filter: blur(12px); }
.bottom-nav a { display: flex; min-height: 54px; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .66rem; font-weight: 700; text-align: center; text-decoration: none; }
.bottom-nav a > span:first-child { display: grid; width: 24px; height: 24px; place-items: center; font-size: 1.25rem; line-height: 1; }
.bottom-nav a.active { color: var(--purple); }

.eyebrow { margin: 0 0 4px; color: var(--purple); font-size: .78rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(1.65rem, 6vw, 2.25rem); line-height: 1.12; letter-spacing: -.04em; }
h2 { margin-bottom: 6px; font-size: 1.45rem; letter-spacing: -.025em; }
h3 { margin-bottom: 10px; font-size: 1.05rem; }
.lead { margin-bottom: 22px; color: var(--muted); }
.section { margin-top: 28px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 1.13rem; }
.text-link { color: var(--purple); font-size: .9rem; font-weight: 700; text-decoration: none; }

.card { padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.stack { display: grid; gap: 12px; }
.action-card { display: grid; gap: 14px; }
.action-card p { margin: 0; color: var(--muted); }
.action-card.action-required { background: #fff0dc; border-color: #efb968; box-shadow: 0 8px 28px rgba(170, 97, 0, .13); }
.action-card.action-required h2 { color: #754000; }
.action-card.action-required p { color: #7e5724; }
.status-card { display: flex; gap: 12px; align-items: flex-start; }
.status-dot { width: 12px; height: 12px; flex: 0 0 12px; margin-top: 5px; border-radius: 50%; background: var(--purple); }
.status-card strong, .status-card p { display: block; }
.status-card p { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.status-card.success { background: var(--green-soft); border-color: #bce8cb; }
.status-card.success .status-dot { background: var(--green); }
.status-card.danger { background: var(--red-soft); border-color: #f7bdca; }
.status-card.danger .status-dot { background: var(--red); }
.status-card.warning { background: var(--amber-soft); border-color: #f3d197; }
.status-card.warning .status-dot { background: var(--amber); }

.activity-card { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.activity-icon { display: grid; width: 42px; height: 42px; place-items: center; overflow: hidden; background: var(--purple-soft); border-radius: 12px; }
.activity-icon img { width: 100%; height: 100%; padding: 6px; object-fit: contain; }
.activity-icon.fallback { color: var(--purple); font-size: 1.3rem; font-weight: 800; }
.activity-name { font-weight: 800; }
.activity-meta { margin-top: 3px; color: var(--muted); font-size: .9rem; }
.activity-price { color: var(--ink); font-size: .92rem; font-weight: 800; text-align: right; }
.activity-card.compact { grid-template-columns: 34px minmax(0, 1fr); gap: 9px; padding: 9px 12px; }
.activity-card.compact .activity-icon { width: 34px; height: 34px; border-radius: 10px; }
.activity-card.compact .activity-icon img { padding: 5px; }
.activity-card.compact .activity-name { display: inline; }
.activity-card.compact .activity-meta { display: inline; margin-left: 8px; }
.activity-card.compact .badge { float: right; margin-top: 0; }
.badge { display: inline-block; margin-top: 7px; padding: 3px 8px; border-radius: 99px; background: var(--purple-soft); color: var(--purple-dark); font-size: .75rem; font-weight: 800; }
.badge.paid { background: var(--green-soft); color: var(--green); }
.badge.due { background: var(--amber-soft); color: var(--amber); }
.payment-badge { text-decoration: none; }
.payment-badge:hover { background: #ffe5b6; }

.button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; padding: 10px 16px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 12px; font-weight: 800; text-align: center; text-decoration: none; }
.button.primary { color: #fff; background: linear-gradient(135deg, var(--purple), var(--purple-dark)); border-color: var(--purple-dark); box-shadow: 0 6px 14px rgba(72, 48, 188, .22); }
.button.secondary { color: var(--purple); border-color: #c9c2f6; }
.button.danger { color: var(--red); border-color: #f0b5c4; }
.button.full { width: 100%; }
.button.small { min-height: 38px; padding: 7px 11px; font-size: .86rem; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #b8acf8; outline-offset: 2px; }

.form-grid { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; color: var(--ink); font-size: .9rem; font-weight: 700; }
.field input { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #ceccdf; border-radius: 10px; }
.form-message { min-height: 22px; margin: 0; color: var(--muted); font-size: .9rem; }
.form-message.error { color: var(--red); }
.form-message.success { color: var(--green); }
.avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.avatar { display: grid; width: 84px; height: 84px; flex: 0 0 84px; overflow: hidden; place-items: center; color: var(--purple); background: var(--purple-soft); border: 2px solid #d9d3fc; border-radius: 50%; font-size: 1.6rem; font-weight: 800; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-row p { margin: 0; color: var(--muted); font-size: .9rem; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.account-link { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.account-link:hover { border-color: #c9c2f6; }
.account-link > span:last-child { margin-left: auto; color: var(--purple); font-size: 1.5rem; }
.account-link strong, .account-link small { display: block; }
.account-link small { margin-top: 2px; color: var(--muted); }
.account-link-avatar { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; color: var(--purple); background: var(--purple-soft); border-radius: 50%; font-weight: 800; }
.profile-summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px; }
.profile-summary .avatar { width: 58px; height: 58px; flex-basis: 58px; font-size: 1.1rem; }
.profile-summary-name { font-size: 1.05rem; font-weight: 800; }
.profile-summary-meta { overflow: hidden; max-width: 250px; color: var(--muted); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.home .section { margin-top: 18px; }
.home .section-heading { margin-bottom: 8px; }
.home-activities { gap: 7px; }
.collapsible-content { margin-top: 12px; }
.collapsible-content[hidden] { display: none; }
.collapsible-details { padding: 0 18px; }
.collapsible-details summary { padding: 16px 0; cursor: pointer; font-weight: 800; }
.history-content { padding-bottom: 8px; }

.official-preview { overflow: hidden; padding: 0; }
.cerfa-image { display: block; width: 100%; height: auto; background: #fff; }
.official-copy { padding: 18px; }
.official-copy p { color: var(--muted); font-size: .92rem; }
.official-note { margin: 14px 0; color: var(--muted); font-size: .78rem; }

.progress-meta { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: .85rem; font-weight: 700; }
.progress-track { height: 8px; margin-bottom: 28px; overflow: hidden; background: var(--line); border-radius: 99px; }
.progress-value { height: 100%; background: linear-gradient(90deg, var(--purple), #8068ed); border-radius: inherit; transition: width .2s ease; }
.step-card { min-height: 315px; display: flex; flex-direction: column; justify-content: space-between; }
.step-section { margin-bottom: 8px; color: var(--purple); font-size: .83rem; font-weight: 800; }
.step-question { max-width: 560px; margin: 0; font-size: clamp(1.35rem, 5vw, 1.8rem); line-height: 1.22; letter-spacing: -.03em; }
.answer-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 28px; }
.answer-button { min-height: 68px; color: var(--purple); background: #fff; border: 2px solid #d6d0fa; border-radius: 14px; font-size: 1.1rem; font-weight: 800; }
.answer-button.yes { color: var(--red); border-color: #f1bcc9; }
.step-back { align-self: flex-start; margin-top: 20px; color: var(--muted); background: transparent; border: 0; font-weight: 700; }
.summary-list { display: grid; gap: 10px; margin: 20px 0; }
.summary-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.summary-row span { color: var(--muted); font-size: .88rem; }
.summary-row strong.yes { color: var(--red); }
.summary-row strong.no { color: var(--green); }
.confirmation { display: flex; align-items: flex-start; gap: 10px; margin: 20px 0; color: var(--ink); font-size: .9rem; }
.confirmation input { width: 20px; height: 20px; flex: 0 0 20px; margin: 1px 0 0; }
.health-summary { padding-bottom: 142px; }
.health-submit-actions, .health-start-actions { position: fixed; z-index: 15; bottom: calc(78px + env(safe-area-inset-bottom)); left: 50%; width: min(calc(100% - 68px), 652px); padding: 10px 12px; background: rgba(255, 255, 255, .97); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px rgba(33, 25, 83, .16); transform: translateX(-50%); }
.health-submit-actions .confirmation { margin: 0 0 8px; font-size: .82rem; }

.payment-total { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 18px 0 6px; padding-top: 16px; border-top: 1px solid var(--line); }
.payment-total strong { font-size: 1.7rem; letter-spacing: -.04em; }
.payment-option { display: flex; gap: 12px; align-items: center; }
.payment-option input { width: 20px; height: 20px; }
.payment-option-main { display: grid; flex: 1; }
.payment-methods { margin-top: 18px; }
.payment-methods h2 { margin-bottom: 14px; }
.payment-method-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.payment-method-list > div { display: grid; gap: 7px; justify-items: center; color: var(--ink); font-size: .82rem; font-weight: 800; text-align: center; }
.payment-method-list small { color: var(--muted); font-size: .72rem; font-weight: 400; }
.payment-method-icon { display: grid; width: 42px; height: 42px; place-items: center; color: var(--purple); background: var(--purple-soft); border-radius: 12px; }
.payment-method-icon.paypal { color: #0876c9; background: #e5f2ff; font-size: 1.5rem; font-style: italic; font-weight: 900; }
.payment-method-icon svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.history details { border-top: 1px solid var(--line); }
.history summary { padding: 14px 0; cursor: pointer; font-weight: 800; }
.history-item { padding: 10px 0; color: var(--muted); font-size: .9rem; }

@media (min-width: 700px) {
    .app-shell { padding-bottom: 0; padding-left: 216px; }
    .app-header { padding: 18px 32px; }
    .header-label { display: none; }
    .page-content { width: min(100%, 860px); padding: 42px 32px 64px; }
    .bottom-nav { top: 0; right: auto; width: 216px; grid-template-columns: 1fr; align-content: center; gap: 8px; padding: 20px 12px; border-top: 0; border-right: 1px solid var(--line); box-shadow: none; }
    .bottom-nav a { min-height: 48px; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; border-radius: 10px; font-size: .9rem; text-align: left; }
    .bottom-nav a.active { background: var(--purple-soft); }
    .form-grid.two-columns { grid-template-columns: 1fr 1fr; }
    .card { padding: 22px; }
    .health-summary { padding-bottom: 0; }
    .health-submit-actions, .health-start-actions { position: static; width: auto; margin-top: 16px; padding: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none; transform: none; }
    .health-submit-actions .confirmation { margin: 0 0 12px; }
}
