:root {
  --navy: #0C3A5E; --navy-ink: #06243B; --blue: #1E9BE9; --blue-text: #0A6AAE; --sky: #BFE3FA; --mist: #D6E6F2;
  --ink: #10263A; --ink-2: #34495C; --muted: #4A5D6E; --line: #C3D0DB; --line-2: #DCE4EB; --bg: #F2F5F8; --card: #FFFFFF; --soft: #EEF3F7;
  --green: #1E8E3E; --green-bg: #E6F4EA; --green-ink: #136C2E;
  --amber: #E37400; --amber-bg: #FFF1E0; --amber-ink: #8A4500;
  --red: #D03E27; --red-bg: #FDECEA; --red-ink: #A12B1A;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 16px; }
body { overscroll-behavior-y: none; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
h1, h2, .display { font-family: "Exo 2", Inter, sans-serif; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue-text); }
.hidden { display: none !important; }

/* Header */
.top { background: var(--navy); color: #fff; padding: calc(16px + var(--safe-top)) 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.top-row { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.top-row .mid { font-size: 13px; color: var(--mist); text-align: center; flex: 1; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-row .side { width: 64px; font-size: 12px; color: var(--sky); text-align: right; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: none; background: transparent; color: inherit; padding: 0; border-radius: 22px; }
.top h1 { margin: 0; font-size: 28px; }
.top p { margin: 0; font-size: 14px; color: var(--mist); }
.progress { display: flex; gap: 4px; }
.progress span { flex: 1; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.25); }
.progress span.on { background: var(--blue); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 36px; margin-left: -4px; }
.brand span { font-size: 11px; letter-spacing: 4px; font-weight: 600; color: var(--sky); }

/* Layout */
main { flex: 1; padding: 20px 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 1px 2px rgba(12,58,94,0.06); }
.card h2 { margin: 0; font-size: 19px; color: var(--navy); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.group { display: flex; flex-direction: column; gap: 8px; }
.lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); line-height: 1.45; margin: 0; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.section-title { margin: 6px 0 0; font-size: 13px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); font-family: Inter, sans-serif; font-weight: 600; }

/* Inputs */
.field { height: 48px; width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; font-size: 16px; font-weight: 500; background: #fff; }
textarea.field { height: 96px; padding: 12px 14px; resize: vertical; font-weight: 400; line-height: 1.4; }
.field:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.col { flex-direction: column; }
.chips.grid5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.chip { min-height: 44px; padding: 8px 14px; border-radius: 22px; border: 1px solid var(--line); background: #fff; color: var(--navy); font-size: 14px; font-weight: 500; text-align: left; line-height: 1.3; }
.chips.grid5 .chip { padding: 0; text-align: center; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.seg { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.seg button { height: 44px; padding: 0 2px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink-2); font-size: 12px; font-weight: 600; }
.seg .on-OK, .seg .on-Fixed { background: var(--green-bg); border-color: var(--green); color: var(--green-ink); }
.seg .on-Defect { background: var(--red); border-color: var(--red); color: #fff; }
.seg .on-Noaccess { background: var(--amber-bg); border-color: var(--amber); color: var(--amber-ink); }
.seg .on-NA { background: var(--navy); border-color: var(--navy); color: #fff; }
.toggle { display: flex; justify-content: space-between; align-items: center; min-height: 44px; font-size: 15px; font-weight: 500; gap: 12px; }
.switch { flex: none; width: 52px; height: 32px; border-radius: 16px; background: var(--line); border: none; padding: 3px; display: flex; justify-content: flex-start; }
.switch::after { content: ""; width: 26px; height: 26px; border-radius: 13px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.switch.on { background: var(--navy); justify-content: flex-end; }

/* Buttons */
.btn { min-height: 54px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; border-radius: 14px; border: none; font-weight: 700; font-size: 16px; text-decoration: none; padding: 0 18px; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-accent { background: var(--blue); color: var(--navy-ink); }
.btn-ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); font-weight: 600; }
.btn-link { background: transparent; border: none; color: var(--blue-text); font-weight: 600; font-size: 14px; min-height: 44px; padding: 0 8px; }
.btn:disabled { opacity: 0.55; }
.btn-block { width: 100%; }
.foot { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line-2); padding: 14px 20px calc(14px + var(--safe-bottom)); display: flex; gap: 12px; z-index: 5; }
.foot .back { flex: 0 0 96px; }
.foot .next { flex: 1; }

/* Pills and lists */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 20px; white-space: nowrap; }
.pill.green { background: var(--green-bg); color: var(--green-ink); }
.pill.amber { background: var(--amber-bg); color: var(--amber-ink); }
.pill.red { background: var(--red-bg); color: var(--red-ink); }
.pill.grey { background: var(--soft); color: var(--ink-2); }
.pill.blue { background: #E2F1FC; color: #0B4F80; }
.list { background: #fff; border-radius: 14px; display: flex; flex-direction: column; box-shadow: 0 1px 2px rgba(12,58,94,0.06); }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #E6ECF1; text-align: left; background: transparent; border-left: none; border-right: none; border-top: none; width: 100%; color: inherit; text-decoration: none; }
.list-item:last-child { border-bottom: none; }
.list-item .t { font-weight: 600; font-size: 15px; }
.list-item .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.list-item .note { font-size: 13px; color: var(--red-ink); margin-top: 6px; }
.job-card { display: flex; flex-direction: column; gap: 10px; background: #fff; border-radius: 14px; padding: 16px; border: none; text-align: left; box-shadow: 0 1px 2px rgba(12,58,94,0.08); width: 100%; }
.empty { font-size: 14px; color: var(--muted); padding: 14px 16px; background: #fff; border-radius: 14px; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.4; }
.banner.amber { background: var(--amber-bg); color: #5E3000; }
.banner.blue { background: #E2F1FC; color: #0B3A5E; }
.banner.red { background: var(--red-bg); color: #7A1E10; }
.banner svg { flex: none; margin-top: 1px; }

/* Bottom nav */
.tabs { position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: #fff; border-top: 1px solid var(--line-2); padding: 6px 8px calc(8px + var(--safe-bottom)); }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px; border: none; background: transparent; font-size: 12px; font-weight: 500; color: var(--muted); min-height: 52px; }
.tabs button.on { color: var(--navy); font-weight: 700; }

/* Login */
.login { flex: 1; background: var(--navy); color: #fff; display: flex; flex-direction: column; align-items: center; padding: calc(40px + var(--safe-top)) 24px calc(24px + var(--safe-bottom)); gap: 22px; }
.login img { width: 240px; max-width: 70%; }
.login h1 { margin: 6px 0 0; font-size: 26px; }
.dots { display: flex; gap: 14px; height: 18px; }
.dots span { width: 16px; height: 16px; border-radius: 8px; border: 2px solid var(--sky); }
.dots span.on { background: var(--sky); }
.pad { display: grid; grid-template-columns: repeat(3, 80px); gap: 14px; }
.pad button { height: 72px; border-radius: 36px; border: none; background: rgba(255,255,255,0.1); color: #fff; font-size: 26px; font-weight: 600; font-family: "Exo 2", sans-serif; }
.pad button:active { background: rgba(255,255,255,0.25); }
.login .err { color: #FFD1C9; font-weight: 600; min-height: 20px; font-size: 14px; text-align: center; }

/* Method tiles and result tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; padding: 12px 14px; min-height: 72px; border-radius: 14px; border: 1px solid var(--line); background: #fff; color: var(--navy); text-align: left; }
.tile b { font-size: 16px; }
.tile small { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.tile.on { border: 2px solid var(--navy); background: #EAF5FD; }
.res { font-family: "Exo 2", sans-serif; font-size: 18px; font-weight: 700; border-width: 2px; background: #fff; }
.res small { font-family: Inter, sans-serif; }
.res-PASS { border-color: var(--green); color: var(--green-ink); }
.res-RETEST { border-color: var(--amber); color: var(--amber-ink); }
.res-FAIL { border-color: var(--red); color: var(--red-ink); }
.res-INCOMPLETE { border-color: #7A8A97; color: var(--ink-2); }
.res.on.res-PASS { background: var(--green); color: #fff; } .res.on.res-PASS small { color: #fff; }
.res.on.res-RETEST { background: #B35900; border-color: #B35900; color: #fff; } .res.on.res-RETEST small { color: #fff; }
.res.on.res-FAIL { background: var(--red); color: #fff; } .res.on.res-FAIL small { color: #fff; }
.res.on.res-INCOMPLETE { background: #4F5F6C; border-color: #4F5F6C; color: #fff; } .res.on.res-INCOMPLETE small { color: #fff; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: #fff; color: var(--navy); font-size: 22px; font-weight: 600; }
.stepper span { width: 44px; text-align: center; font-family: "Exo 2", sans-serif; font-size: 26px; font-weight: 700; }

/* Kit */
.kit { display: flex; gap: 12px; align-items: center; border-radius: 14px; background: var(--soft); padding: 14px; }
.kit .t { font-weight: 700; font-size: 15px; }
.kit .s { font-size: 13px; color: var(--ink-2); }

/* Times */
.time-box { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: #fff; min-height: 84px; }
.time-box.set { background: var(--green-bg); border-color: var(--green-bg); }
.time-box .lbl { color: var(--ink-2); }
.time-box input { border: none; background: transparent; font-family: "Exo 2", sans-serif; font-size: 24px; font-weight: 600; color: var(--navy-ink); padding: 0; width: 100%; }
.time-box button { min-height: 40px; border: 2px dashed var(--navy); border-radius: 10px; background: #fff; color: var(--navy); font-weight: 700; font-size: 14px; }

/* Weather */
.wx { display: flex; gap: 14px; align-items: center; }
.wx .big { font-family: "Exo 2", sans-serif; font-size: 22px; font-weight: 600; color: var(--navy); }

/* Photos */
.photo { display: flex; gap: 12px; align-items: flex-start; background: #fff; border-radius: 14px; padding: 10px; box-shadow: 0 1px 2px rgba(12,58,94,0.08); }
.photo .thumb { position: relative; flex: none; width: 88px; height: 88px; border-radius: 10px; overflow: hidden; background: var(--soft); border: none; padding: 0; }
.photo .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .num { position: absolute; left: 5px; bottom: 5px; font-size: 12px; font-weight: 700; color: #fff; background: rgba(6,36,59,0.8); padding: 2px 7px; border-radius: 8px; }
.photo .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.photo .t { font-weight: 700; font-size: 15px; }
.photo .d { font-size: 13px; color: var(--ink-2); line-height: 1.35; }
.photo .acts { display: flex; flex-direction: column; }
.photo-edit { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }

/* Sheet (photo editor) */
.sheet-wrap { position: fixed; inset: 0; background: rgba(6,36,59,0.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 20px calc(20px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 20px; color: var(--navy); }
.sheet img.preview { width: 100%; max-height: 260px; object-fit: contain; border-radius: 12px; background: #000; }

/* Plan */
.plan-wrap { position: relative; border-radius: 16px; overflow: hidden; background: #fff; border: 1px solid var(--line); touch-action: none; }
.plan-wrap canvas { display: block; width: 100%; aspect-ratio: 1 / 1; touch-action: none; }
.plan-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px; color: var(--muted); font-size: 14px; pointer-events: none; }
.tools { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.tools button { height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--navy); font-size: 12px; font-weight: 600; }
.tools button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.swatches { display: flex; gap: 10px; align-items: center; }
.swatches button { width: 36px; height: 36px; border-radius: 18px; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.swatches button.on { box-shadow: 0 0 0 3px var(--navy); }

/* Review */
.summary { background: #fff; border-radius: 16px; overflow: hidden; }
.summary .band { color: #fff; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; }
.summary .band b { font-family: "Exo 2", sans-serif; font-size: 22px; }
.summary .info { padding: 14px 18px; display: flex; flex-direction: column; gap: 3px; font-size: 14px; color: var(--ink-2); }
.summary .info strong { font-size: 17px; color: var(--ink); }
.check { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 16px; border: none; border-bottom: 1px solid #E6ECF1; background: transparent; width: 100%; text-align: left; color: inherit; }
.check:last-child { border-bottom: none; }
.check .t { font-weight: 600; font-size: 15px; }
.check .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.check .go { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--blue-text); white-space: nowrap; }

/* Done screen */
.done { flex: 1; background: var(--navy); color: #fff; display: flex; flex-direction: column; padding: calc(28px + var(--safe-top)) 24px calc(28px + var(--safe-bottom)); gap: 18px; }
.done .logo { height: 60px; align-self: center; }
.done .mid { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; }
.done .tick { width: 96px; height: 96px; border-radius: 48px; background: var(--blue); display: flex; align-items: center; justify-content: center; }
.done .tick.wait { background: #F2B566; }
.done h1 { margin: 0; font-size: 30px; }
.done p { margin: 0; font-size: 16px; line-height: 1.5; color: var(--mist); max-width: 320px; }
.done .facts { width: 100%; background: rgba(255,255,255,0.08); border-radius: 16px; padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.done .facts div { display: flex; justify-content: space-between; font-size: 14px; gap: 12px; }
.done .facts span:first-child { color: var(--sky); }
.done .btn { background: #fff; color: var(--navy); }

#toast { position: fixed; left: 50%; bottom: calc(120px + var(--safe-bottom)); transform: translateX(-50%); background: var(--navy-ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500; max-width: 90vw; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100; }
#toast.show { opacity: 1; }
.spin { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
