/* Web onboarding (/apply): phone first, big tap targets, 16px inputs (no iOS zoom). */
:root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --text: #18202b;
    --muted: #5d6878;
    --border: #d6dce4;
    --accent: #1f5fbf;
    --accent-text: #ffffff;
    --navy: #16233a;
    --ok: #1d7a45;
    --ok-bg: #e5f4ea;
    --warn: #8a5300;
    --warn-bg: #fff3dc;
    --bad: #b42318;
    --bad-bg: #fdecea;
    --info-bg: #e8f0fb;
    --radius: 10px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #11161d;
        --surface: #1a212b;
        --text: #e6eaf0;
        --muted: #9aa5b4;
        --border: #2e3846;
        --accent: #5b9bff;
        --accent-text: #0b1220;
        --navy: #0b1220;
        --ok: #5fd08a;
        --ok-bg: #16301f;
        --warn: #f0b85a;
        --warn-bg: #33270f;
        --bad: #ff8a80;
        --bad-bg: #3a1714;
        --info-bg: #172338;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding: 80px 0 110px; }   /* sticky step bar + nav never cover a field */
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: .25rem 0 .75rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }

.ap-shell { min-height: 100vh; display: flex; flex-direction: column; }
.ap-top {
    background: var(--navy); color: #fff;
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .7rem 16px;
}
.ap-brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .01em; }
.ap-brand span { font-weight: 400; opacity: .85; }
.ap-top-right { display: flex; align-items: center; gap: .9rem; }
.ap-top .ap-lang, .ap-top .ap-link { color: #fff; font-size: .95rem; }
.ap-inline { display: inline; margin: 0; }
.ap-main { width: 100%; max-width: 720px; margin: 0 auto; padding: 16px 16px 48px; flex: 1; }
.ap-foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 16px 24px; }

.ap-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; margin: 0 0 16px;
}
fieldset.ap-card { min-width: 0; }
fieldset.ap-card legend { font-weight: 700; padding: 0 .35rem; margin-left: -.35rem; }
.ap-narrow { max-width: 440px; margin: 8px auto 16px; }
.ap-muted { color: var(--muted); }
.ap-small { font-size: .88rem; }
.ap-back { margin: 0 0 .25rem; }
.ap-back a { text-decoration: none; }
.ap-head-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.ap-head-row h2 { margin: 0; }

label { display: block; font-weight: 600; margin: .9rem 0 .3rem; }
.ap-grid label { margin-top: 0; }
input, select, textarea {
    width: 100%; font: inherit; font-size: 16px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: .7rem .75rem; min-height: 48px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
input[type=checkbox] { width: 1.3rem; height: 1.3rem; min-height: 0; vertical-align: middle; margin-right: .5rem; }

.ap-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 560px) {
    .ap-grid { grid-template-columns: 1fr 1fr; }
    .ap-field.wide { grid-column: 1 / -1; }
}
.ap-field[hidden] { display: none; }
.ap-field.check label { font-weight: 500; display: flex; align-items: center; min-height: 48px; }
.ap-req { color: var(--bad); margin-left: .15rem; }
.ap-hint { display: block; color: var(--muted); font-size: .85rem; margin-top: .3rem; }
.ap-err { display: block; color: var(--bad); font-size: .88rem; margin-top: .3rem; font-weight: 600; }
.ap-field.invalid input, .ap-field.invalid select, .ap-field.invalid textarea { border-color: var(--bad); }
.ap-fixed { padding: .7rem 0; font-weight: 600; }
.ap-pw { display: flex; gap: .5rem; align-items: center; }
.ap-masked { -webkit-text-security: disc; text-security: disc; }
.ap-masked.shown { -webkit-text-security: none; text-security: none; }
.ap-pw .ap-link { white-space: nowrap; }
.ap-tag {
    display: inline-block; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
    color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 .45rem; margin-left: .35rem; vertical-align: middle;
}

.ap-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 48px; padding: .7rem 1.1rem; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; position: relative;
}
.ap-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.ap-btn.small { min-height: 40px; padding: .45rem .8rem; font-size: .92rem; }
.ap-btn.busy { opacity: .65; pointer-events: none; }
.ap-btn:disabled { opacity: .55; }
.ap-block { width: 100%; margin-top: 1rem; }
.ap-link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

.ap-alert { border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 16px; background: var(--bad-bg); color: var(--bad); }
.ap-alert.ok { background: var(--ok-bg); color: var(--ok); }
.ap-alert.warn { background: var(--warn-bg); color: var(--warn); }
.ap-alert.info { background: var(--info-bg); color: var(--text); }
.ap-banner { background: var(--info-bg); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 16px; }
.ap-banner strong { display: block; }

.ap-help { margin-top: 1.25rem; }
.ap-help summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 32px; }

/* home */
.ap-next { list-style: none; padding: 0; margin: 0 0 .5rem; counter-reset: n; }
.ap-next li { counter-increment: n; border-top: 1px solid var(--border); }
.ap-next li:first-child { border-top: 0; }
.ap-next a { display: grid; grid-template-columns: 2rem 1fr; padding: .8rem 0; text-decoration: none; color: var(--text); }
.ap-next a::before {
    content: counter(n); width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); color: var(--accent-text);
    display: grid; place-items: center; font-size: .85rem; font-weight: 700; grid-row: span 2;
}
.ap-next li.urgent a::before { background: var(--bad); color: #fff; }
.ap-next-title { font-weight: 600; text-decoration: underline; text-decoration-color: var(--border); }
.ap-next-detail { color: var(--muted); font-size: .9rem; grid-column: 2; }
.ap-tiles { display: grid; gap: 10px; }
@media (min-width: 560px) { .ap-tiles { grid-template-columns: 1fr 1fr; } }
.ap-tile {
    display: flex; flex-direction: column; gap: .3rem; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius);
    text-decoration: none; color: var(--text); min-height: 72px;
}
.ap-tile-title { font-weight: 700; }
.ap-status { font-size: .9rem; font-weight: 600; }
.ap-status.ok { color: var(--ok); }
.ap-status.wait { color: var(--warn); }
.ap-status.bad { color: var(--bad); }
.ap-status.todo { color: var(--accent); }
.ap-docs { list-style: none; padding: 0; margin: 0; }
.ap-docs li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.ap-docs li:first-child { border-top: 0; }
.ap-doc-main { display: flex; flex-direction: column; min-width: 0; }
.ap-doc-name { font-weight: 600; }
.ap-reason { color: var(--bad); font-size: .9rem; }
.ap-dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
.ap-dl dt { color: var(--muted); }
.ap-dl dd { margin: 0; font-weight: 600; }
.ap-steps-list { padding-left: 1.25rem; }
.ap-steps-list li { margin-bottom: .4rem; }

/* upload */
.ap-slot { border: 2px dashed var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.ap-slot.filled { border-style: solid; border-color: var(--ok); }
.ap-slot-label { font-weight: 700; margin-bottom: .5rem; }
.ap-slot-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ap-slot-buttons .ap-btn { overflow: hidden; }
.ap-file { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; min-height: 0; }
.ap-slot-preview { margin-top: .6rem; display: flex; align-items: center; gap: .6rem; color: var(--ok); font-weight: 600; word-break: break-all; }
.ap-slot-preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.ap-progress { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; margin: .5rem 0; }
.ap-progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* application wizard: one step at a time with script; all steps without it */
.js .ap-step { display: none; }
.js .ap-step.active { display: block; }
.ap-steps { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: .5rem 0 .75rem; }
.ap-steps-bar { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.ap-steps-bar > div { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.ap-steps-label { font-size: .9rem; color: var(--muted); margin-top: .35rem; font-weight: 600; }
html:not(.js) .ap-steps { display: none; }
.ap-wizard-nav {
    position: sticky; bottom: 0; z-index: 2; display: flex; gap: 10px; justify-content: space-between;
    background: var(--bg); padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
}
.ap-wizard-nav .ap-btn { flex: 1; }
.ap-wizard-nav [hidden] { display: none; }
html:not(.js) [data-prev], html:not(.js) [data-next] { display: none; }

/* signature */
.ap-sig { position: relative; margin: 1rem 0; }
.ap-sig canvas {
    display: block; width: 100%; height: 190px; background: #fff; border: 2px solid var(--border); border-radius: var(--radius);
    touch-action: none; cursor: crosshair;
}
.ap-sig-hint {
    position: absolute; left: 16px; right: 16px; bottom: 44px; border-top: 1px solid #b8c0cc; color: #8a94a3;
    font-size: .85rem; padding-top: .2rem; pointer-events: none;
}
.ap-sig.inked .ap-sig-hint { color: transparent; }
.ap-sig [data-sig-clear] { margin-top: .5rem; }
