:root {
  --bg: #f4f6fb; --card: #fff; --ink: #1b2233; --muted: #6b7489; --line: #e3e7f0;
  --primary: #1f4fd8; --primary-soft: #e8eefc; --ok: #1a9d5c; --warn: #e08a00; --bad: #d63b3b;
  --radius: 16px; --shadow: 0 2px 10px rgba(20, 30, 60, .07);
  font-size: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
button { font: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px; background: var(--primary); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.brand img { width: 32px; height: 32px; border-radius: 8px; background: #fff; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.net { font-size: .8rem; padding: 6px 10px; border-radius: 99px; background: rgba(255,255,255,.18); white-space: nowrap; }
.net.off { background: #ffb020; color: #3a2600; }
.sync-btn, .icon-btn { position: relative; border: 0; background: rgba(255,255,255,.18); color: #fff; padding: 10px 16px; border-radius: 12px; min-height: 48px; }
.icon-btn { font-size: 1.3rem; width: 48px; padding: 0; }
.sync-btn.spin .sync-ico { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge { position: absolute; top: -6px; right: -6px; background: #ff5a36; color: #fff; border-radius: 99px; font-size: .75rem; min-width: 24px; height: 24px; display: grid; place-items: center; padding: 0 6px; font-weight: 700; }

main { max-width: 900px; margin: 0 auto; padding: 20px 18px 120px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 14px 22px; min-height: 56px;
  font-weight: 600; background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-danger { background: #fde8e8; color: var(--bad); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-lg { font-size: 1.1rem; min-height: 64px; padding: 16px 28px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Login */
.login { max-width: 460px; margin: 8vh auto; }
.login .logo { width: 84px; height: 84px; margin: 0 auto 16px; display: block; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.input, .fe-input { width: 100%; font: inherit; font-size: 1.1rem; padding: 16px; border: 2px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); }
.input:focus, .fe-input:focus { outline: none; border-color: var(--primary); }
.error { color: var(--bad); margin: 8px 0; }

/* Home */
.hello { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { flex: 1; border: 0; background: #fff; padding: 14px; border-radius: 14px; font-weight: 600; color: var(--muted); box-shadow: var(--shadow); min-height: 52px; }
.tab.on { background: var(--primary); color: #fff; }
.form-card h3 { font-size: 1.2rem; }
.form-card .contract { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); font-weight: 700; margin-bottom: 4px; }
.stats { display: flex; gap: 18px; margin: 12px 0 16px; flex-wrap: wrap; }
.stat b { display: block; font-size: 1.4rem; }
.stat span { font-size: .8rem; color: var(--muted); }
.draft { border: 2px dashed var(--warn); background: #fff8eb; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.hist-item { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.hist-item:last-child { border-bottom: 0; }
.pill { font-size: .75rem; font-weight: 700; padding: 5px 10px; border-radius: 99px; white-space: nowrap; }
.pill.pendente { background: #fff1d6; color: #8a5600; }
.pill.enviada { background: #dff5e9; color: #0d6b3c; }
.pill.erro { background: #fde8e8; color: var(--bad); }

/* Entrevista */
.iv-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress { flex: 1; height: 10px; background: #dfe4f0; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); transition: width .25s; }
.gps-chip { font-size: .8rem; padding: 6px 10px; border-radius: 99px; background: #dff5e9; color: #0d6b3c; white-space: nowrap; }
.gps-chip.weak { background: #fff1d6; color: #8a5600; }
.gps-chip.none { background: #fde8e8; color: var(--bad); }
.iv-card { min-height: 46vh; padding: 28px; }
.iv-nav { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 12px; z-index: 5; }
.iv-nav .btn { flex: 1; }
.iv-nav .btn.back { flex: 0 0 30%; }
.qnum { color: var(--muted); font-size: .85rem; margin-bottom: 8px; }

.fe-label { font-size: 1.45rem; font-weight: 700; }
.fe-req { color: var(--bad); }
.fe-help { color: var(--muted); margin: 4px 0 14px; }
.fe-body { margin-top: 18px; }
.fe-note { font-size: 1.3rem; line-height: 1.5; }
.fe-choices { display: grid; gap: 12px; }
.fe-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.fe-yesno { grid-template-columns: 1fr 1fr; }
.fe-choice { display: flex; align-items: center; gap: 14px; text-align: left; border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 18px; min-height: 64px; font-size: 1.1rem; color: var(--ink); }
.fe-yesno .fe-choice { justify-content: center; font-size: 1.3rem; font-weight: 700; min-height: 90px; }
.fe-choice.on { border-color: var(--primary); background: var(--primary-soft); }
.fe-radio, .fe-check { flex: 0 0 26px; height: 26px; border: 2px solid #b8c2d8; border-radius: 50%; position: relative; }
.fe-check { border-radius: 7px; }
.fe-choice.on .fe-radio, .fe-choice.on .fe-check { border-color: var(--primary); background: var(--primary); }
.fe-choice.on .fe-radio::after { content: ""; position: absolute; inset: 6px; background: #fff; border-radius: 50%; }
.fe-choice.on .fe-check::after { content: "✓"; position: absolute; inset: 0; color: #fff; display: grid; place-items: center; font-size: 16px; font-weight: 900; }
.fe-other { margin-top: 12px; }
.fe-scale { display: flex; gap: 8px; flex-wrap: wrap; }
.fe-scale-btn { flex: 1 0 56px; min-height: 64px; border: 2px solid var(--line); background: #fff; border-radius: 12px; font-size: 1.3rem; font-weight: 700; color: var(--ink); }
.fe-scale-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.fe-scale-btn.det.on { background: var(--bad); border-color: var(--bad); }
.fe-scale-btn.neu.on { background: var(--warn); border-color: var(--warn); }
.fe-scale-btn.pro.on { background: var(--ok); border-color: var(--ok); }
.fe-scale-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; margin-top: 8px; }
.fe-num { max-width: 280px; font-size: 1.6rem; }
.fe-unit { margin-left: 10px; color: var(--muted); }
.fe-gps-info { margin-top: 12px; color: var(--muted); }
.fe-file { display: none; }
.fe-photo { display: block; max-width: 100%; max-height: 50vh; margin-top: 14px; border-radius: 12px; }
.fe-error { margin-top: 16px; padding: 12px 14px; background: #fde8e8; color: var(--bad); border-radius: 12px; font-weight: 600; }

.review-item { padding: 14px 0; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.review-item .q { flex: 1; }
.review-item .a { font-weight: 600; margin-top: 4px; word-break: break-word; }
.review-item .a.missing { color: var(--bad); }

.gps-wait { text-align: center; padding: 40px 24px; }
.gps-wait .big { font-size: 3.2rem; margin-bottom: 10px; }
.acc { font-size: 2rem; font-weight: 800; margin: 12px 0; }

.done { text-align: center; padding: 48px 24px; }
.done .big { font-size: 4rem; }

.toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%) translateY(30px); background: #1b2233; color: #fff; padding: 14px 20px; border-radius: 14px; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-bg { position: fixed; inset: 0; background: rgba(10,15,30,.45); display: grid; place-items: center; z-index: 40; padding: 18px; }
.modal { background: #fff; border-radius: 20px; padding: 24px; width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 12px; }

@media (max-width: 560px) { :root { font-size: 16px; } .net { display: none; } #sync-label { display: none; } }

[hidden] { display: none !important; }

/* Área de trabalho */
.area-box { text-align: left; border-radius: 14px; padding: 14px 16px; margin-top: 16px; }
.area-box p { margin: 6px 0; }
.area-box.ok { background: #dff5e9; color: #0d6b3c; }
.area-box.wait { background: #eef2fb; color: var(--ink); }
.area-box.out { background: #fde8e8; color: #7a1d1d; border: 2px solid var(--bad); }
.area-title { font-size: 1.25rem; font-weight: 800; color: var(--bad); }
.area-dist { font-size: 1.15rem; font-weight: 700; }
.area-sketch { width: 100%; max-height: 220px; background: #fff; border-radius: 10px; margin: 8px 0; }
.area-poly { fill: rgba(31, 79, 216, .12); stroke: #1f4fd8; stroke-width: 2; }
.area-path { stroke: #d63b3b; stroke-width: 2; stroke-dasharray: 6 5; }
.me-dot { fill: #d63b3b; stroke: #fff; stroke-width: 2; }
.me-halo { fill: rgba(214, 59, 59, .2); }
.area-n { font-size: 12px; fill: #6b7489; font-weight: 700; }
.area-route { background: #1b2233; color: #fff; margin-top: 6px; }
.btn-warn { background: #fff1d6; color: #8a5600; }
.area-line { font-size: .9rem; color: #0d6b3c; margin: 6px 0 0; }
.area-line.out { color: var(--bad); font-weight: 700; }
