/* ASM Lead Form — matches the approved design */
:root {
    --navy: #12294A;
    --orange: #C2540A;
    --orange-bar: #F08A3C;
    --bg: #F3F5F8;
    --ink: #1B2430;
    --ink-2: #4B5563;
    --muted: #5A6472;
    --line: #DCE2EA;
    --field: #C3CBD6;
    --red: #B3261E;
    --hdr-muted: #D5DDE8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.45;
    color: var(--ink);
}
a { color: var(--navy); }
a:hover { color: var(--orange); }
.muted { color: var(--ink-2); }

/* ---------- Header ---------- */
.hdr { background: var(--navy); color: #fff; padding-top: env(safe-area-inset-top); }
.hdr-in { max-width: 480px; margin: 0 auto; padding: 20px 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.hdr-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; }
.logo-chip { display: inline-flex; align-items: center; background: #fff; border-radius: 8px; padding: 6px 10px; }
.logo { display: block; height: 26px; width: auto; max-width: 140px; object-fit: contain; }
.logo-text { font-size: 14px; font-weight: 700; letter-spacing: .02em; }
.asm { font-size: 12px; color: var(--hdr-muted); text-align: right; }
.asm strong { color: #fff; font-weight: 600; }
.hdr-title { display: flex; flex-direction: column; gap: 4px; }
.hdr h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.hdr p { margin: 0; font-size: 14px; color: var(--hdr-muted); }
.prog { display: flex; flex-direction: column; gap: 6px; }
.prog-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--hdr-muted); }
.prog-track { height: 6px; border-radius: 3px; background: rgba(255,255,255,.18); overflow: hidden; }
.prog-bar { height: 6px; width: 0; border-radius: 3px; background: var(--orange-bar); transition: width .25s ease; }

/* ---------- Body ---------- */
.body { max-width: 480px; margin: 0 auto; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); }
#leadForm { display: flex; flex-direction: column; gap: 20px; }
.stack-8 { display: flex; flex-direction: column; gap: 8px; }
.stack-12 { display: flex; flex-direction: column; gap: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sec { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.meta { font-size: 12px; color: var(--muted); }

.card { display: flex; flex-direction: column; gap: 16px; background: #fff; border-radius: 14px; padding: 18px 16px; border: 1px solid var(--line); }
.card.gap-12 { gap: 12px; }
.card.center { text-align: center; align-items: center; padding: 32px 20px; }
.card.center h2 { margin: 0; font-size: 20px; }
.card.center p { margin: 0; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; background: #E2E7EE; border-radius: 12px; }
.tab {
    flex: 1; min-height: 48px; border: 0; border-radius: 9px; background: transparent;
    font: inherit; font-size: 15px; font-weight: 600; color: var(--ink-2); cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: background .15s, color .15s, box-shadow .15s;
}
.tab.on { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(18,41,74,.18); }
.tab:focus-visible { outline: 2px solid var(--orange-bar); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.btn-scan, .btn-submit {
    min-height: 56px; border: 0; border-radius: 12px; color: #fff;
    font: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    transition: filter .15s, transform .05s;
}
.btn-scan { background: var(--orange); }
.btn-submit { background: var(--navy); font-size: 17px; }
.btn-scan:hover, .btn-submit:hover { filter: brightness(1.08); }
.btn-scan:active, .btn-submit:active { transform: translateY(1px); }
.btn-submit:disabled { opacity: .7; cursor: progress; }

.ghost {
    position: relative; min-height: 44px; padding: 0 14px;
    border: 1.5px dashed #9AA6B5; border-radius: 10px; background: #fff;
    font: inherit; font-size: 14px; font-weight: 600; color: var(--navy); cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.ghost:hover { border-color: var(--navy); }
.ghost:focus-within { outline: 2px solid var(--orange-bar); outline-offset: 2px; }
.sr-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

.icon-btn {
    width: 44px; height: 44px; flex: none; border: 0; border-radius: 10px; background: transparent;
    color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #EEF1F5; color: var(--red); }

/* ---------- Fields ---------- */
.fld { display: flex; flex-direction: column; gap: 6px; }
.lbl { font-size: 14px; font-weight: 600; color: var(--ink); }
.req { color: var(--red); margin-left: 2px; }
.opt { font-weight: 500; color: var(--muted); font-size: 13px; }
.inp {
    width: 100%; min-height: 48px; padding: 12px 14px;
    border: 1.5px solid var(--field); border-radius: 10px; background: #fff;
    font: inherit; font-size: 16px; color: var(--ink); outline: none;
    transition: border-color .15s, box-shadow .15s, background .3s;
}
.inp::placeholder { color: #8A94A3; }
.inp:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(18,41,74,.15); }
.inp.bad { border-color: var(--red); }
.inp.got { background: #FFF6EE; border-color: #E3A06B; }
textarea.inp { min-height: 96px; resize: vertical; }
select.inp {
    appearance: none; -webkit-appearance: none; padding-right: 40px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231B2430' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.loc-row { display: flex; gap: 6px; align-items: center; }
.err { font-size: 13px; color: var(--red); }

.note {
    padding: 12px 14px; border-radius: 10px; background: #FFF6EE; border: 1px solid #E3A06B;
    font-size: 14px; color: #7A3606; display: flex; gap: 10px; align-items: flex-start;
}
.alert { padding: 12px 14px; border-radius: 10px; background: #FCEBEA; color: #8C1D18; font-size: 14px; font-weight: 600; }
.foot { margin: -8px 0 12px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Attachments ---------- */
.file { display: flex; align-items: center; gap: 10px; padding: 6px 4px 6px 10px; border: 1px solid var(--line); border-radius: 10px; }
.file-thumb { width: 36px; height: 36px; flex: none; border-radius: 6px; object-fit: cover; background: #EEF1F5; display: flex; align-items: center; justify-content: center; color: var(--navy); }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub { font-size: 12px; color: var(--muted); }

/* ---------- Success ---------- */
.done { max-width: 480px; margin: 0 auto; padding: 40px 20px; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.done-icon { width: 64px; height: 64px; border-radius: 32px; background: #E3F1E8; color: #1E6B3A; display: flex; align-items: center; justify-content: center; }
.done h2 { margin: 0; font-size: 22px; font-weight: 700; }
.done p { margin: 0; font-size: 15px; color: var(--ink-2); max-width: 300px; }
.btn-again { min-height: 48px; padding: 0 22px; border: 0; border-radius: 10px; background: var(--navy); color: #fff; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }

/* ---------- Scanner ---------- */
.scan { position: fixed; inset: 0; z-index: 40; background: rgba(9,18,32,.96); color: #fff; overflow-y: auto; }
.scan-in { max-width: 480px; min-height: 100%; margin: 0 auto; padding: calc(20px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 20px; }
.scan-head { display: flex; align-items: center; justify-content: space-between; font-size: 18px; font-weight: 700; }
.scan-close { width: 44px; height: 44px; border: 0; border-radius: 22px; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.scan-view { position: relative; margin-top: 8vh; aspect-ratio: 1.7 / 1; border-radius: 14px; background: #1E2B3D; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.scan-view video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-ph { position: relative; font-size: 14px; color: #B9C4D3; padding: 0 20px; text-align: center; }
.scan-view .c { position: absolute; width: 28px; height: 28px; border: 0 solid var(--orange-bar); z-index: 2; }
.c.tl { left: 14px; top: 14px; border-left-width: 3px; border-top-width: 3px; border-radius: 6px 0 0 0; }
.c.tr { right: 14px; top: 14px; border-right-width: 3px; border-top-width: 3px; border-radius: 0 6px 0 0; }
.c.bl { left: 14px; bottom: 14px; border-left-width: 3px; border-bottom-width: 3px; border-radius: 0 0 0 6px; }
.c.br { right: 14px; bottom: 14px; border-right-width: 3px; border-bottom-width: 3px; border-radius: 0 0 6px 0; }
.scan-hint { margin: 0; font-size: 15px; color: var(--hdr-muted); text-align: center; }
.scan-progress { height: 6px; border-radius: 3px; background: rgba(255,255,255,.18); overflow: hidden; }
.scan-progress div { height: 100%; width: 0; background: var(--orange-bar); transition: width .25s; }
.scan-actions { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.shutter { width: 76px; height: 76px; border-radius: 38px; border: 4px solid #fff; background: var(--orange); cursor: pointer; transition: transform .1s; }
.shutter:active { transform: scale(.94); }
.shutter:disabled { opacity: .45; cursor: default; }
.scan-upload { position: relative; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1.5px solid rgba(255,255,255,.4); display: flex; align-items: center; font-size: 14px; font-weight: 600; cursor: pointer; }
.scan.busy .shutter, .scan.busy .scan-upload { pointer-events: none; opacity: .45; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; width: max-content; max-width: min(92vw, 440px); padding: 12px 16px; border-radius: 10px; background: #8C1D18; color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

/* ---------- Header nav (New lead / My leads) ---------- */
.hdr-nav { display: flex; gap: 4px; padding: 4px; background: rgba(255,255,255,.10); border-radius: 12px; }
.hdr-nav a { flex: 1; min-height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 9px; color: var(--hdr-muted); font-size: 14px; font-weight: 600; text-decoration: none; }
.hdr-nav a:hover { color: #fff; }
.hdr-nav a.on { background: #fff; color: var(--navy); }

/* ---------- My leads ---------- */
.stack-20 { display: flex; flex-direction: column; gap: 20px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 16px; font-size: 14px; font-weight: 600; text-decoration: none; }
.pill-type { font-size: 12px; font-weight: 600; color: var(--navy); background: #E8EEF6; border-radius: 6px; padding: 3px 8px; }
.locked { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.ro { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; margin: 0; font-size: 14px; }
.ro dt { color: var(--muted); }
.ro dd { margin: 0; color: var(--ink-2); word-break: break-word; }
.btn-cancel { display: block; margin: -8px 0 12px; text-align: center; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 8px; }
.ok-note { padding: 12px 14px; border-radius: 10px; background: #E3F1E8; color: #1E6B3A; font-size: 14px; font-weight: 600; margin-bottom: 16px; }

.search { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 420px) { .search { grid-template-columns: 1.5fr 1fr; } }
.list-meta { margin: 14px 2px 8px; display: block; }

.lead-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lead-list a {
    display: flex; align-items: center; gap: 10px; padding: 14px 10px 14px 16px;
    background: #fff; border: 1px solid var(--line); border-radius: 12px; color: inherit; text-decoration: none;
}
.lead-list a:hover { border-color: #9AA6B5; }
.ll-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ll-name { font-size: 15px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ll-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ll-chev { color: #9AA6B5; flex: none; display: flex; }
.stage { flex: none; max-width: 42%; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 99px; background: #EEF1F5; color: #3A465B; text-align: center; line-height: 1.25; }
.stage-requirement, .stage-quote-pending { background: #FFF3DD; color: #8A5A00; }
.stage-quote-sent, .stage-negotiation { background: #FFE9DA; color: #9A3F08; }
.stage-won { background: #E3F1E8; color: #1E6B3A; }
.stage-lost { background: #F6E5E5; color: #8E1F1F; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }
.pager .ghost { min-height: 40px; text-decoration: none; }
.btn-again { text-decoration: none; display: inline-flex; align-items: center; }

/* ---------- Activity timeline ---------- */
.tl { list-style: none; margin: 0 0 4px; padding: 0 0 0 18px; position: relative; font-size: 14px; }
.tl::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: #E1E6EF; }
.tl li { position: relative; padding: 0 0 14px 8px; }
.tl li:last-child { padding-bottom: 0; }
.tl li::before { content: ""; position: absolute; left: -17px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid #12294A; }
.tl li.tl-created::before { background: #C2540A; border-color: #C2540A; }
.tl-what { line-height: 1.45; word-break: break-word; }
.tl-meta { font-size: 12px; color: #5A6472; margin-top: 2px; }
.tl-old { color: #5A6472; text-decoration: line-through; }
.tl-new { color: #12294A; font-weight: 600; }

/* ---------- ASM login ---------- */
.login-body { background: var(--navy); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 28px 22px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-logo { display: block; height: 40px; width: auto; margin-bottom: 18px; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; font-weight: 800; color: var(--navy); }
.login-card > p.muted { margin: 0 0 18px; font-size: 14px; }
.login-card .alert { margin-bottom: 14px; }
.stack-16 { display: flex; flex-direction: column; gap: 16px; }
.inp.pin { letter-spacing: .35em; font-size: 20px; }
.login-foot { margin: 16px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.5; }
.hdr-logout { color: #fff; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.hdr-logout:hover { color: var(--orange-bar); }

/* Documents on update page */
.file-link { text-decoration: none; color: inherit; padding-right: 12px; }
.file-link:hover { border-color: #9AA6B5; }
.file-new { border-style: dashed; border-color: #E3A06B; background: #FFF9F3; }
.file-bad { border-color: var(--red); background: #FCEBEA; }
.file-bad .file-sub { color: var(--red); }
.tl li.tl-doc::before { border-color: #1E6B3A; background: #E3F1E8; }

.tl li.tl-msg::before { border-color: #1D6FB8; background: #E3EEF9; }
.tl li.tl-fail::before { border-color: #B3261E; background: #FCEBEA; }
.tl li.tl-fail .tl-what strong { color: #B3261E; }
