/* Field app — mobile first, high contrast for outdoor use */
:root {
  --green: #16805C; --green-2: #0F6346; --green-ink: #0A3A2A; --green-tint: #E7F3ED;
  --amber: #E8883A; --amber-tint: #FBEFE3;
  --ink: #15211B; --gray: #566159; --gray-2: #8C988F; --line: #DCE5DF;
  --paper: #FFFFFF; --mist: #F3F7F4;
  --bad: #C7372D; --bad-tint: #FBE9E7; --good: #1F9D5F;
  --radius: 14px;
  --font: 'Noto Sans Lao', 'Phetsarath OT', 'Lao UI', 'Saysettha OT', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); color: var(--ink); background: var(--mist);
  font-size: 17px; line-height: 1.55; -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--green-ink); color: #fff;
  padding: calc(env(safe-area-inset-top) + 10px) 0 10px;
}
.topbar .wrap { display: flex; align-items: center; gap: 10px; }
.topbar h1 { font-size: 16px; font-weight: 700; margin: 0; flex: 1; line-height: 1.3; }
.topbar .sub { font-size: 12.5px; opacity: .78; font-weight: 400; display: block; }
.net { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; background: rgba(255,255,255,.12); padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.net::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #5BD69A; }
.net.off::before { background: var(--amber); }
.icon-btn { background: transparent; border: 0; color: #fff; padding: 6px; border-radius: 8px; cursor: pointer; display: inline-flex; }
.icon-btn svg { width: 22px; height: 22px; }

.progress { height: 4px; background: rgba(255,255,255,.18); margin-top: 10px; }
.progress > i { display: block; height: 100%; background: var(--amber); transition: width .25s; }

/* ---- generic ---- */
/* leave room for the fixed Back/Next bar (≈ 72px + phone home-bar area) */
main.wrap { padding: 18px 16px calc(120px + env(safe-area-inset-bottom)); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.step-title { font-size: 21px; font-weight: 700; margin: 4px 0 2px; line-height: 1.3; }
.step-en { font-size: 13px; color: var(--gray-2); margin: 0 0 16px; }
.muted { color: var(--gray); font-size: 14px; }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 18px; border-radius: 12px; border: 1.5px solid transparent;
  font-weight: 700; font-size: 16.5px; cursor: pointer; text-decoration: none; user-select: none;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:active { background: var(--green-2); }
.btn.secondary { background: var(--paper); color: var(--green-2); border-color: var(--green); }
.btn.ghost { background: transparent; color: var(--gray); border-color: var(--line); }
.btn.amber { background: var(--amber); color: #fff; }
.btn.danger { background: var(--paper); color: var(--bad); border-color: var(--bad); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---- fields ---- */
.field { margin-bottom: 22px; }
.field > label, .field > .label { display: block; font-weight: 700; font-size: 16.5px; margin-bottom: 8px; line-height: 1.4; }
.req { color: var(--bad); margin-left: 3px; }
.hint { font-size: 13.5px; color: var(--gray); margin: -4px 0 8px; }
.err { color: var(--bad); font-size: 14px; margin-top: 6px; font-weight: 600; }
.field.invalid .opts, .field.invalid input, .field.invalid select, .field.invalid textarea, .field.invalid .widget { border-color: var(--bad) !important; box-shadow: 0 0 0 3px var(--bad-tint); border-radius: 12px; }

input[type=text], input[type=tel], input[type=number], input[type=password], select, textarea {
  width: 100%; min-height: 52px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--paper); font-size: 17px; outline: none; appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--gray) 50%), linear-gradient(135deg, var(--gray) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-tint); }
.kip-echo { font-size: 13.5px; color: var(--green-2); margin-top: 6px; font-weight: 600; }

.opts { display: grid; gap: 8px; }
.opt {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 11px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); cursor: pointer; text-align: left; width: 100%;
  font-size: 16px; line-height: 1.35;
}
.opt .mk { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--gray-2); flex: none; display: grid; place-items: center; }
.opt.multi .mk { border-radius: 6px; }
.opt.on { border-color: var(--green); background: var(--green-tint); font-weight: 600; }
.opt.on .mk { border-color: var(--green); background: var(--green); }
.opt.on .mk::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.opt.multi.on .mk::after { width: 10px; height: 6px; border-radius: 0; background: transparent; border: solid #fff; border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) translate(1px, -1px); }
.opts.cols2 { grid-template-columns: 1fr 1fr; }

.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale button { border: 1.5px solid var(--line); background: var(--paper); border-radius: 12px; padding: 10px 2px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 76px; }
.scale b { font-size: 22px; line-height: 1; }
.scale span { font-size: 11.5px; color: var(--gray); line-height: 1.25; text-align: center; }
.scale button.on { border-color: var(--green); background: var(--green); color: #fff; }
.scale button.on span { color: #E1F3EA; }

.note { background: var(--amber-tint); border-left: 4px solid var(--amber); border-radius: 10px; padding: 14px 16px; font-size: 16px; line-height: 1.65; }
.note .label { font-size: 13px; font-weight: 700; color: #A65A1C; margin-bottom: 6px; display: block; }

/* GPS + photo widgets */
.widget { border: 1.5px dashed var(--line); border-radius: 12px; padding: 14px; background: var(--paper); }
.gps-read { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.acc { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-weight: 700; font-size: 14px; }
.acc.good { background: var(--green-tint); color: var(--green-2); }
.acc.warn { background: var(--amber-tint); color: #A65A1C; }
.acc.bad { background: var(--bad-tint); color: var(--bad); }
.coords { font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; color: var(--gray); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.photo-prev { width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; display: block; margin-bottom: 10px; background: var(--mist); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 10px; }
.chip { border: 1.5px solid var(--line); background: var(--paper); border-radius: 99px; padding: 8px 14px; font-size: 14.5px; cursor: pointer; }
.chip b { font-weight: 700; }
.chip.on { border-color: var(--green); background: var(--green-tint); }
.chip small { color: var(--gray); margin-left: 4px; }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 15px; margin-top: 10px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--green); }

/* bottom nav */
.bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding: 10px 0 calc(env(safe-area-inset-bottom) + 10px); backdrop-filter: blur(6px); }
.bottombar .wrap { display: flex; gap: 10px; }
.bottombar .btn { flex: 1; }
.bottombar .btn.back { flex: 0 0 auto; min-width: 96px; }
/* while the keyboard is open: extra room so the last field can scroll above the bar (the bar itself is lifted above the keyboard in app.js) */
body.typing main.wrap { padding-bottom: 45vh; }

/* home */
.hero-btn { width: 100%; min-height: 76px; font-size: 19px; border-radius: 16px; }
.sync { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-bottom: 12px; }
.sync div { background: var(--mist); border-radius: 12px; padding: 10px 4px; }
.sync b { display: block; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sync span { font-size: 12.5px; color: var(--gray); }
.sync .pending b { color: var(--amber); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:last-child { border-bottom: 0; }
.list .t { font-weight: 700; font-size: 15.5px; }
.list .s { font-size: 13px; color: var(--gray); }
.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.badge.draft { background: var(--mist); color: var(--gray); border: 1px solid var(--line); }
.badge.pending { background: var(--amber-tint); color: #A65A1C; }
.badge.sent { background: var(--green-tint); color: var(--green-2); }
.badge.revisit { background: var(--bad-tint); color: var(--bad); }
.section-h { font-size: 13px; font-weight: 700; color: var(--gray); text-transform: uppercase; letter-spacing: .05em; margin: 18px 0 8px; }

/* review */
.rv-step { margin-bottom: 14px; }
.rv-step h3 { font-size: 15px; margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; }
.rv-step h3 button { font-size: 13.5px; background: none; border: 0; color: var(--green); font-weight: 700; cursor: pointer; padding: 4px; }
.rv-row { display: grid; grid-template-columns: 44% 1fr; gap: 10px; font-size: 14px; padding: 6px 0; border-top: 1px solid var(--mist); }
.rv-row .k { color: var(--gray); }
.rv-row .v { font-weight: 600; word-break: break-word; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.banner { background: var(--amber-tint); color: #7A4210; border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 12px; }
.banner.bad { background: var(--bad-tint); color: var(--bad); }
.login-logo { width: 64px; height: 64px; border-radius: 16px; background: var(--green); display: grid; place-items: center; margin: 24px auto 12px; }
.login-logo svg { width: 36px; height: 36px; color: #fff; }

/* map picker */
.acc.map { background: #E8F0FA; color: #2F6FB3; }
.acc.map svg { width: 15px; height: 15px; }
.sheet { position: fixed; inset: 0; z-index: 100; background: #111; display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; background: var(--green-ink); color: #fff; }
.sheet-head h2 { margin: 0; font-size: 16px; line-height: 1.3; }
.sheet-head h2 span { display: block; font-size: 12.5px; font-weight: 400; opacity: .8; }
.sheet-body { flex: 1; min-height: 0; position: relative; }
.sheet-map { position: absolute; inset: 0; }
.crosshair { position: absolute; left: 50%; top: 50%; z-index: 500; pointer-events: none; color: var(--bad);
  transform: translate(-50%, calc(-100% + 4px)); filter: drop-shadow(0 2px 2px rgba(0,0,0,.45)); }
.crosshair svg { display: block; width: 44px; height: 44px; fill: #fff; stroke-width: 2.2; }
.map-tools { position: absolute; right: 12px; top: 12px; z-index: 500; display: grid; gap: 8px; }
.map-tool { min-width: 48px; height: 48px; padding: 0 12px; border-radius: 12px; border: 0; background: #fff; color: var(--ink); font-weight: 700; font-size: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.3); display: grid; place-items: center; cursor: pointer; }
.map-tool svg { width: 22px; height: 22px; }
.sheet-foot { background: #fff; padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px); display: grid; gap: 10px; }
.pk-read { font-size: 14.5px; min-height: 40px; }
