:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --text: #1b1f24;
    --muted: #5f6b7a;
    --border: #dde2e8;
    --accent: #1f6feb;
    --accent-text: #ffffff;
    --danger: #c62828;
    --danger-bg: #fdecec;
    --warning: #9a6200;
    --warning-bg: #fff4dc;
    --info: #1f5fa8;
    --info-bg: #e8f1fc;
    --success: #1e7b3c;
    --success-bg: #e6f5ea;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1216;
        --surface: #171b21;
        --surface-2: #1e242c;
        --text: #e6e9ee;
        --muted: #98a3b1;
        --border: #2b333d;
        --accent: #4c8dff;
        --accent-text: #0b1220;
        --danger: #ff7b72;
        --danger-bg: #3a1716;
        --warning: #e3b341;
        --warning-bg: #33280f;
        --info: #79b8ff;
        --info-bg: #10243d;
        --success: #56d364;
        --success-bg: #12301b;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.mt { margin-top: 1rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.topbar-inner { display: flex; align-items: center; gap: 1.5rem; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); font-size: 1.1rem; }
.nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--muted); padding: .35rem .65rem; border-radius: 8px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { color: var(--text); background: var(--surface-2); font-weight: 600; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat { margin: 0; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

/* buttons */
.btn, button {
    display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
    background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent);
    padding: .5rem .95rem; border-radius: 8px; font: inherit; font-weight: 600; text-decoration: none;
}
.btn:hover, button:hover { filter: brightness(1.07); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: .3rem .65rem; font-size: .875rem; }
.btn-link { background: none; border: none; color: var(--accent); padding: 0; font-weight: 500; }
form.inline { display: inline; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
tr:last-child td { border-bottom: none; }

/* badges */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--surface-2); color: var(--muted); }

/* alerts & flashes */
.alert, .flash { border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .6rem; border: 1px solid transparent; }
.alert { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; }
.alert strong { display: block; }
.alert-danger, .flash-error { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.flash-success { background: var(--success-bg); color: var(--success); }
.alert .detail { color: var(--text); opacity: .85; }

/* forms */
.form-card { max-width: 640px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }
.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .925rem; }
.field-check label { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
.req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
    width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.help-text, .field > div[id$=_help] { color: var(--muted); font-size: .825rem; margin-top: .25rem; }
.errors { list-style: none; padding: 0; margin: .3rem 0 0; color: var(--danger); font-size: .85rem; }
.has-error input, .has-error select { border-color: var(--danger); }

/* steps */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: .75rem; padding: .6rem 0; border-bottom: 1px dashed var(--border); }
.steps li:last-child { border-bottom: none; }
.steps .dot { flex: 0 0 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.steps .done .dot { background: var(--success-bg); color: var(--success); }
.steps .todo .dot { background: var(--warning-bg); color: var(--warning); }
.steps .late .dot { background: var(--danger-bg); color: var(--danger); }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; margin: .4rem 0; }

/* landing */
.hero { padding: 2.5rem 0 1.5rem; max-width: 720px; }
.hero h1 { font-size: 2.2rem; line-height: 1.2; margin-bottom: .75rem; }
.hero p { font-size: 1.1rem; color: var(--muted); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

.footer { padding: 2rem 16px; font-size: .8rem; }

@media (max-width: 640px) {
    .topbar-inner { gap: .5rem; padding-top: .5rem; padding-bottom: .5rem; }
    h1 { font-size: 1.35rem; }
    .hero h1 { font-size: 1.7rem; }
    dl.kv { grid-template-columns: 1fr; gap: 0 1rem; }
    dl.kv dt { margin-top: .4rem; }
}

/* printable documents */
.doc { background: #fff; color: #111; max-width: 800px; margin: 0 auto 2rem; padding: 2.5rem 3rem; border: 1px solid var(--border); font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.6; }
.doc h1 { text-align: center; font-size: 1.35rem; text-transform: uppercase; letter-spacing: .03em; }
.doc h2 { font-size: 1rem; margin-top: 1.25rem; }
.doc .center { text-align: center; }
.doc .signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 3rem; }
.doc .missing { background: #fff1a8; padding: 0 .2rem; }
.doc table td, .doc table th { border: 1px solid #bbb; color: #111; }
.doc table th { width: 40%; background: #f4f4f4; }
.no-print { margin-bottom: 1rem; }
@media print {
    .topbar, .footer, .no-print, .flash, .tabbar, .btn-fab, .lp-dock { display: none !important; }
    body { background: #fff; }
    .wrap { max-width: none; padding: 0; }
    .doc { border: none; padding: 0; margin: 0; max-width: none; }
}

/* ───────────── landing page ───────────── */
:root {
    --c-blue: #2563eb; --c-violet: #7c3aed; --c-green: #16a34a;
    --c-amber: #d97706; --c-red: #dc2626; --c-slate: #475569;
    --hero-top: #eaf2ff; --hero-bottom: #fff6ea;
    --sky-sun: #ffd27a; --sky-far: #d6e2f3; --sky-mid: #b9cbe6; --sky-near: #8fa8cf;
    --sky-roof: #c2410c; --sky-door: #6b4f3a; --sky-tree: #6fae7a; --sky-trunk: #7a5a3c;
    --win: #e9f0fb; --win-lit: #ffd166; --win-near: #dfe8f6;
}
@media (prefers-color-scheme: dark) {
    :root {
        --c-blue: #60a5fa; --c-violet: #a78bfa; --c-green: #4ade80;
        --c-amber: #fbbf24; --c-red: #f87171; --c-slate: #94a3b8;
        --hero-top: #0b1730; --hero-bottom: #1a1530;
        --sky-sun: #f3e7c0; --sky-far: #16233d; --sky-mid: #1d2d4c; --sky-near: #26395e;
        --sky-roof: #5b2a1c; --sky-door: #3b2c22; --sky-tree: #234a35; --sky-trunk: #3b2c22;
        --win: #22365a; --win-lit: #ffcf5c; --win-near: #2b4166;
    }
}
body.landing { overflow-x: clip; }
body.landing .topbar { margin-bottom: 0; background: color-mix(in srgb, var(--hero-top) 80%, transparent); backdrop-filter: blur(8px); border-bottom-color: transparent; position: sticky; top: 0; z-index: 10; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1.05rem; border-radius: 10px; }
.btn-ghost { background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--text); border-color: var(--border); }
.btn-light { background: #fff; color: #1e3a8a; border-color: #fff; }

.lp-hero {
    position: relative; margin-inline: calc(50% - 50vw); padding: 3.5rem 16px 0;
    background: linear-gradient(180deg, var(--hero-top) 0%, var(--hero-bottom) 100%);
    overflow: hidden;
}
.lp-hero-inner {
    position: relative; z-index: 1; max-width: 1080px; margin: 0 auto;
    display: grid; grid-template-columns: 1.15fr .85fr; gap: 3rem; align-items: center;
    padding-bottom: 250px;
}
.lp-eyebrow { display: inline-block; font-size: .85rem; font-weight: 600; padding: .3rem .75rem; border-radius: 999px; background: color-mix(in srgb, var(--c-blue) 12%, transparent); color: var(--c-blue); margin-bottom: 1rem; }
.lp-copy h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.05; letter-spacing: -.02em; margin-bottom: 1rem; }
.lp-highlight { background: linear-gradient(90deg, var(--c-blue), var(--c-violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lp-lead { font-size: 1.15rem; color: var(--muted); max-width: 34rem; margin-bottom: 1.5rem; }
.lp-fine { display: flex; align-items: center; gap: .4rem; margin-top: .9rem; font-size: .9rem; color: var(--muted); }
.lp-fine svg { width: 18px; height: 18px; color: var(--c-green); }

.lp-mock {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
    box-shadow: 0 24px 60px -20px rgba(30, 58, 138, .35), 0 4px 12px rgba(0, 0, 0, .06);
    transform: rotate(1.5deg); animation: lp-float 6s ease-in-out infinite;
}
@keyframes lp-float { 50% { transform: rotate(1.5deg) translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .lp-mock { animation: none; } }
.lp-mock-bar { display: flex; gap: 6px; padding: .6rem .8rem; background: var(--surface-2); }
.lp-mock-bar span { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.lp-mock-body { padding: 1rem; display: grid; gap: .55rem; }
.lp-mock-title { font-weight: 700; margin-bottom: .1rem; }
.lp-mock-item { padding: .6rem .75rem; border-radius: 10px; border-left: 4px solid; display: grid; }
.lp-mock-item small { color: var(--muted); }
.lp-mock-warn { background: var(--warning-bg); border-color: var(--c-amber); }
.lp-mock-danger { background: var(--danger-bg); border-color: var(--c-red); }
.lp-mock-ok { background: var(--success-bg); border-color: var(--c-green); }
.lp-mock-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .25rem; }
.lp-mock-stats div { background: var(--surface-2); border-radius: 10px; padding: .55rem .75rem; display: grid; }
.lp-mock-stats small { color: var(--muted); font-size: .75rem; }
.lp-mock-stats b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.skyline { position: absolute; left: 0; bottom: 0; width: 100%; height: 260px; z-index: 0; }
.sky-sun { fill: var(--sky-sun); opacity: .8; }
.sky-far { fill: var(--sky-far); opacity: .6; }
.sky-mid { fill: var(--sky-mid); }
.sky-near { fill: var(--sky-near); }
.sky-roof { fill: var(--sky-roof); }
.sky-door { fill: var(--sky-door); }
.sky-tree { fill: var(--sky-tree); }
.sky-trunk { fill: var(--sky-trunk); }
.sky-ground { fill: var(--sky-near); }
.win { fill: var(--win); }
.win-near { fill: var(--win-near); }
.win-lit { fill: var(--win-lit); }

.lp-facts {
    position: relative; z-index: 2; margin: -2.25rem auto 0; max-width: 960px;
    display: grid; grid-template-columns: repeat(3, 1fr);
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.lp-facts div { padding: 1.1rem 1.25rem; display: grid; gap: .15rem; }
.lp-facts div + div { border-left: 1px solid var(--border); }
.lp-facts b { font-size: 1.5rem; color: var(--c-blue); }
.lp-facts span { color: var(--muted); font-size: .9rem; }

.lp-section { padding: 4rem 0 1rem; }
.lp-h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); text-align: center; letter-spacing: -.01em; margin-bottom: .4rem; }
.lp-sub { text-align: center; color: var(--muted); margin-bottom: 2rem; }

.lp-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 1.1rem; }
.lp-feature {
    position: relative; overflow: hidden; padding: 1.5rem; border-radius: 16px;
    background: var(--surface); border: 1px solid var(--border);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.lp-feature::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
    background: linear-gradient(90deg, var(--tone), color-mix(in srgb, var(--tone) 30%, transparent));
}
.lp-feature::after {
    content: ""; position: absolute; width: 160px; height: 160px; right: -60px; top: -60px; border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--tone) 14%, transparent), transparent 70%);
}
.lp-feature:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--tone) 45%, var(--border)); box-shadow: 0 18px 40px -18px color-mix(in srgb, var(--tone) 55%, transparent); }
.lp-icon {
    width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 1rem;
    color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent);
}
.lp-feature h3 { font-size: 1.1rem; margin-bottom: .4rem; }
.lp-feature p { color: var(--muted); margin: 0; }

.lp-steps { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; counter-reset: s; }
.lp-steps li { text-align: center; padding: 0 .5rem; }
.lp-steps span {
    display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; margin-bottom: .8rem;
    font-weight: 700; font-size: 1.15rem; color: #fff; background: linear-gradient(135deg, var(--c-blue), var(--c-violet));
    box-shadow: 0 8px 20px -8px var(--c-blue);
}
.lp-steps p { color: var(--muted); }

.lp-cta {
    margin: 3.5rem 0 1rem; padding: 3rem 1.5rem; text-align: center; border-radius: 20px; color: #fff;
    background: radial-gradient(circle at 15% 20%, rgba(255,255,255,.18), transparent 40%), linear-gradient(135deg, #1d4ed8, #7c3aed);
}
.lp-cta h2 { font-size: clamp(1.4rem, 3vw, 2rem); margin-bottom: .5rem; }
.lp-cta p { opacity: .9; margin-bottom: 1.5rem; }

@media (max-width: 860px) {
    .lp-hero-inner { grid-template-columns: 1fr; gap: 2rem; padding-bottom: 170px; }
    .lp-mock { max-width: 420px; transform: none; animation: none; }
    .skyline { height: 180px; }
}
@media (max-width: 640px) {
    .lp-hero { padding-top: 2rem; }
    .lp-facts { grid-template-columns: 1fr; margin-top: -1.5rem; }
    .lp-facts div + div { border-left: none; border-top: 1px solid var(--border); }
    .lp-steps { grid-template-columns: 1fr; }
    .lp-hero-inner { padding-bottom: 150px; }
    .skyline { height: 150px; }
}

/* ───────────── logo ───────────── */
.brand { display: inline-flex; text-decoration: none !important; }
.logo { display: inline-flex; align-items: center; gap: .55rem; line-height: 1; }
.logo-mark { flex: none; border-radius: 10px; box-shadow: 0 4px 12px -4px rgba(79, 70, 229, .55); }
.logo-word { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.logo-app { background: linear-gradient(90deg, #2563eb, #7c3aed); -webkit-background-clip: text; background-clip: text; color: transparent; }
@media (prefers-color-scheme: dark) {
    .logo-app { background-image: linear-gradient(90deg, #60a5fa, #a78bfa); }
}

/* honeypot: out of sight for people and screen readers, still in the DOM for bots */
.hp-field { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

/* ───────────── account menu (one icon for login / sign-up / profile) ───────────── */
.account { position: relative; margin-left: auto; }
.account > summary { list-style: none; }
.account > summary::-webkit-details-marker { display: none; }
.account-btn {
    width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
    color: var(--text); background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--border);
    transition: border-color .15s ease, color .15s ease, box-shadow .15s ease; -webkit-tap-highlight-color: transparent;
}
.account-btn:hover { border-color: var(--accent); color: var(--accent); }
.account[open] .account-btn { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.account-btn.is-user { background: linear-gradient(135deg, #2563eb, #7c3aed); border-color: transparent; color: #fff; }
.avatar { font-weight: 700; font-size: .85rem; letter-spacing: .03em; }
.account-menu {
    position: absolute; right: 0; top: calc(100% + 8px); width: 270px; z-index: 50;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: .5rem;
    box-shadow: 0 20px 50px -12px rgba(16, 24, 40, .3); display: grid; gap: .15rem;
    animation: menu-in .14s ease-out;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.account-who { display: grid; padding: .55rem .7rem .75rem; margin-bottom: .3rem; border-bottom: 1px solid var(--border); }
.account-who small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu a:not(.btn) { display: flex; align-items: center; gap: .65rem; padding: .65rem .7rem; border-radius: 10px; color: var(--text); font-weight: 500; }
.account-menu a:not(.btn) svg { color: var(--muted); }
.account-menu a:not(.btn):hover { background: var(--surface-2); text-decoration: none; }
.account-menu .btn { justify-content: center; padding: .7rem 1rem; margin: .15rem 0; }

/* bottom tab bar (logged in, phones) and landing CTA dock — hidden on larger screens */
.tabbar, .lp-dock { display: none; }

@media (max-width: 640px) {
    .topbar { position: sticky; top: 0; z-index: 30; margin-bottom: 1rem; padding-top: env(safe-area-inset-top); }
    .topbar-inner { flex-wrap: nowrap; min-height: 58px; padding-top: 0; padding-bottom: 0; }
    .has-tabbar .nav { display: none; }

    /* account menu becomes a bottom sheet (header lifted above the tab bar / dock while it is open) */
    .topbar:has(details.account[open]) { z-index: 60; }
    .account[open]::before {
        content: ""; position: fixed; inset: 0; z-index: 45; background: rgba(10, 14, 22, .45);
        animation: fade-in .18s ease-out;
    }
    .account-menu {
        position: fixed; top: auto; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto;
        border-radius: 22px; padding: .75rem; animation: sheet-in .22s cubic-bezier(.2, .9, .3, 1);
    }
    .account-menu::before { content: ""; justify-self: center; width: 38px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 0 .4rem; }
    .account-menu a:not(.btn) { padding: .85rem .8rem; font-size: 1rem; }
    .account-menu .btn { padding: .9rem 1rem; font-size: 1rem; border-radius: 12px; }
    @keyframes sheet-in { from { transform: translateY(105%); } }
    @keyframes fade-in { from { opacity: 0; } }

    .has-tabbar { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
    .tabbar {
        display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
        border-top: 1px solid var(--border);
    }
    .tabbar a {
        display: grid; justify-items: center; gap: 2px; padding: 4px 0; border-radius: 12px;
        color: var(--muted); font-size: .7rem; font-weight: 600; -webkit-tap-highlight-color: transparent;
    }
    .tabbar a:hover { text-decoration: none; }
    .tabbar a.active { color: var(--accent); }
    .tabbar a.active svg { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 999px; padding: 2px 14px; width: 54px; height: 28px; }
    .tabbar svg { width: 24px; height: 28px; padding: 2px 0; box-sizing: border-box; }
}

/* ───────────── landing on phones: app-like layout ───────────── */
@media (max-width: 640px) {
    body.landing { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
    /* no backdrop-filter here: it would trap the fixed account sheet inside the header */
    body.landing .topbar { margin-bottom: 0; backdrop-filter: none; background: var(--hero-top); }

    .lp-hero { padding-top: 1.75rem; }
    .lp-hero-inner { text-align: center; gap: 1.75rem; padding-bottom: 110px; }
    .lp-copy h1 { font-size: 2.4rem; }
    .lp-lead { font-size: 1.05rem; margin-inline: auto; margin-bottom: 0; }
    .lp-hero .actions { display: none; }
    .lp-fine { justify-content: center; }
    .lp-mock { max-width: 100%; text-align: left; transform: none; animation: none; border-radius: 20px; }
    .lp-mock-bar { display: none; }
    .lp-mock-body { padding: .9rem; }
    .skyline { height: 140px; }

    /* facts: swipeable cards */
    .lp-facts {
        display: flex; gap: .75rem; margin: -2rem -16px 0; padding: 0 16px .5rem; max-width: none;
        overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px; scrollbar-width: none;
        background: none; border: 0; border-radius: 0; box-shadow: none;
    }
    .lp-facts::-webkit-scrollbar { display: none; }
    .lp-facts div, .lp-facts div + div {
        flex: 0 0 76%; scroll-snap-align: center; padding: 1rem 1.1rem;
        background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow);
    }

    .lp-section { padding: 2.5rem 0 .5rem; }
    .lp-h2 { font-size: 1.45rem; }
    .lp-sub { margin-bottom: 1.25rem; }

    /* features: grouped list, like a settings screen */
    .lp-features {
        display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
        overflow: hidden; box-shadow: var(--shadow);
    }
    .lp-feature {
        display: grid; grid-template-columns: 44px 1fr; gap: .15rem .9rem; align-items: start;
        padding: .95rem 1rem; border: 0; border-radius: 0; background: none;
    }
    .lp-feature + .lp-feature { border-top: 1px solid var(--border); }
    .lp-feature::before, .lp-feature::after { display: none; }
    .lp-feature:hover { transform: none; box-shadow: none; }
    .lp-icon { width: 44px; height: 44px; border-radius: 12px; margin: 0; grid-row: span 2; }
    .lp-feature h3 { font-size: 1rem; margin: .1rem 0 0; }
    .lp-feature p { font-size: .9rem; }

    /* steps: vertical timeline */
    .lp-steps { grid-template-columns: 1fr; gap: 0; margin-top: 1.25rem; }
    .lp-steps li { position: relative; display: grid; grid-template-columns: 44px 1fr; gap: 0 1rem; text-align: left; padding: 0 0 1.4rem; }
    .lp-steps li::before {
        content: ""; position: absolute; left: 21px; top: 48px; bottom: 4px; width: 2px; border-radius: 2px;
        background: linear-gradient(var(--c-blue), color-mix(in srgb, var(--c-violet) 30%, transparent));
    }
    .lp-steps li:last-child { padding-bottom: 0; }
    .lp-steps li:last-child::before { display: none; }
    .lp-steps span { width: 44px; height: 44px; margin: 0; grid-row: span 2; font-size: 1.05rem; }
    .lp-steps h3 { margin: .55rem 0 .2rem; }
    .lp-steps p { margin: 0; }

    .lp-cta { margin-top: 2.5rem; padding: 2rem 1.25rem; border-radius: 22px; }
    .lp-cta .btn { display: none; }
    .lp-cta p { margin-bottom: 0; }

    /* sticky call-to-action dock */
    .lp-dock {
        display: flex; gap: .6rem; align-items: center; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
        padding: .7rem 16px calc(.7rem + env(safe-area-inset-bottom));
        background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
        border-top: 1px solid var(--border);
    }
    .lp-dock .btn { flex: 1; justify-content: center; border-radius: 14px; }
    .lp-dock-login {
        padding: .8rem 1.1rem; border-radius: 14px; font-weight: 600; color: var(--text);
        background: var(--surface-2); border: 1px solid var(--border);
    }
    .lp-dock-login:hover { text-decoration: none; }
}

/* ───────────── app screens: shared components (all sizes) ───────────── */
.only-mobile { display: none !important; }
.mb, .list.mb { margin-bottom: 1rem; }
.text-danger { color: var(--danger); }
.kicker { margin: 0 0 .1rem; font-size: .8rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.section-title { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; margin: 0 0 .6rem; }
.section-title .count { min-width: 22px; height: 22px; padding: 0 .4rem; border-radius: 999px; display: inline-grid; place-items: center; font-size: .75rem; background: var(--danger); color: #fff; }
.back-link { display: inline-flex; align-items: center; gap: .15rem; margin: -.4rem 0 .6rem -.35rem; padding: .2rem .35rem; border-radius: 8px; font-weight: 600; }
.back-link:hover { background: var(--surface-2); text-decoration: none; }
.card-link { display: block; color: inherit; text-decoration: none !important; transition: border-color .15s ease, transform .15s ease; }
.card-link:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-2px); }
.card-row { display: flex; justify-content: space-between; gap: 1rem; }
.danger-zone { margin-top: 1.25rem; }
.btn-block { width: 100%; justify-content: center; padding-block: .7rem; }
.auth-card { max-width: 440px; margin: 1rem auto 0; }
.btn svg, button svg { flex: none; }

/* grouped list (iOS/Android style rows) */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.list > li + li { border-top: 1px solid var(--border); }
.list-row { display: flex; align-items: center; gap: .8rem; min-height: 64px; padding: .7rem .9rem; color: var(--text); text-decoration: none !important; }
a.list-row:hover, .list-row > a.list-main:hover { background: var(--surface-2); }
a.list-row:active { background: var(--surface-2); }
.list-main { flex: 1; min-width: 0; display: grid; gap: .05rem; color: inherit; text-decoration: none !important; border-radius: 8px; }
.list-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-flag { justify-self: start; margin-top: .2rem; font-size: .75rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; }
.list-flag.is-warning { background: var(--warning-bg); color: var(--warning); }
.list-flag.is-danger { background: var(--danger-bg); color: var(--danger); }
.list-end { display: grid; justify-items: end; gap: .2rem; text-align: right; flex: none; }
.list-amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list-chevron { flex: none; display: grid; color: var(--muted); opacity: .6; margin-right: -.25rem; }
.list-icon {
    flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
    color: var(--tone, var(--accent)); background: color-mix(in srgb, var(--tone, var(--accent)) 13%, transparent);
}
.list-avatar {
    flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
    font-weight: 700; font-size: .85rem; color: #fff; background: linear-gradient(135deg, #60a5fa, #7c3aed);
}
.date-tile {
    flex: none; width: 46px; height: 50px; border-radius: 12px; display: grid; place-content: center; text-align: center; line-height: 1.1;
    background: var(--surface-2); color: var(--text);
}
.date-tile b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.date-tile small { font-size: .7rem; text-transform: uppercase; color: var(--muted); font-weight: 600; letter-spacing: .03em; }
.date-tile.is-ok { background: var(--success-bg); }
.date-tile.is-ok b { color: var(--success); }
.date-tile.is-danger { background: var(--danger-bg); }
.date-tile.is-danger b { color: var(--danger); }
.pill {
    display: inline-flex; align-items: center; padding: .3rem .75rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
    background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent);
}
.pill:hover { text-decoration: none; background: color-mix(in srgb, var(--accent) 20%, transparent); }

/* segmented control (year picker) */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented a { padding: .35rem .9rem; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.segmented a:hover { text-decoration: none; color: var(--text); }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }

/* ───────────── app screens on phones ───────────── */
@media (max-width: 640px) {
    .only-mobile { display: revert !important; }
    .only-desktop { display: none !important; }
    ul.only-mobile { display: block !important; }

    body { font-size: 16px; }
    main.wrap { padding-top: .25rem; }
    h1 { font-size: 1.75rem; letter-spacing: -.01em; }
    .page-head { margin-bottom: 1rem; }
    .page-head > .actions { width: 100%; }
    .page-head > .actions > .btn { flex: 1; justify-content: center; }
    .card { border-radius: 16px; padding: 1rem; }
    .back-link { margin-top: -.25rem; }

    /* inputs: 16px avoids iOS zoom-on-focus; taller touch targets */
    input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
        font-size: 16px; min-height: 46px; border-radius: 10px;
    }
    .btn, button { min-height: 44px; border-radius: 10px; }
    .btn-sm, button.btn-sm { min-height: 36px; }
    .btn-link, button.btn-link { min-height: 0; }
    .pill { min-height: 32px; }

    /* floating action button above the tab bar */
    .btn-fab {
        position: fixed; z-index: 25; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom));
        min-height: 54px; padding: 0 1.2rem 0 1rem; border-radius: 18px; font-size: 1rem;
        box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--accent) 70%, transparent), 0 2px 6px rgba(0, 0, 0, .12);
    }
    .page-head > .actions:has(> .btn-fab:only-child) { display: contents; }
    .page-head > .btn-fab { flex: none; }
    .has-tabbar main { padding-bottom: 72px; }

    /* summary numbers: swipeable chips */
    .stats-row { display: flex; gap: .6rem; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px; scrollbar-width: none; margin: 0 -16px 1rem; padding: 0 16px .25rem; }
    .stats-row::-webkit-scrollbar { display: none; }
    .stats-row > .card { flex: 0 0 58%; margin: 0; scroll-snap-align: start; padding: .8rem .95rem; }
    .stats-row .stat .value { font-size: 1.25rem; }
    .stats-row .stat .label { font-size: .78rem; }

    /* to-do alerts as cards with an accent edge and a full-width action */
    .alert { border-radius: 14px; border-left-width: 4px; padding: .85rem .95rem; gap: .65rem; }
    .alert-danger { border-left-color: var(--danger); }
    .alert-warning { border-left-color: var(--warning); }
    .alert-info { border-left-color: var(--info); }
    .alert > .btn, .alert > form, .alert > .actions { width: 100%; }
    .alert > .btn, .alert > form button { width: 100%; justify-content: center; }

    /* form save bar sticks above the tab bar */
    .form-actions {
        position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 5;
        margin: 1rem -1rem -1rem; padding: .75rem 1rem; flex-wrap: nowrap;
        background: color-mix(in srgb, var(--surface) 94%, transparent); border-top: 1px solid var(--border);
        border-radius: 0 0 16px 16px;
    }
    .form-actions > * { flex: 1; justify-content: center; }
    .form-card { max-width: none; }

    /* login / sign-up: full-screen form, no card chrome */
    .auth-card { background: none; border: 0; box-shadow: none; padding: .5rem 0 0; margin-top: 0; }
    .auth-card h1 { font-size: 2rem; margin-bottom: .5rem; }

    .segmented { display: flex; width: 100%; }
    .segmented a { flex: 1; text-align: center; }
    .page-head > .segmented { order: 2; }

    dl.kv dd { word-break: break-word; }
    .danger-zone button { width: 100%; justify-content: center; }
}
