/* SpateLabs: mobile-first styles, no framework */
:root {
  --bg: #f4f7f9;
  --card: #ffffff;
  --ink: #12222b;
  --muted: #5b6b74;
  --line: #d9e2e7;
  --brand: #0b4f6c;
  --brand-ink: #ffffff;
  --accent: #0e7c9b;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: .7rem 1.1rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer; user-select: none;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { width: 100%; min-height: 56px; font-size: 1.1rem; }
.btn.small { min-height: 36px; padding: .35rem .75rem; font-size: .9rem; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.file-btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- public page ---------- */
.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--brand); letter-spacing: .02em; }
.lang-btn {
  margin-inline-start: auto; min-height: 40px; padding: .3rem 1rem;
  border: 1px solid var(--brand); border-radius: 99px; background: #fff; color: var(--brand);
  font: inherit; font-weight: 700; cursor: pointer; letter-spacing: 0;
}
.lang-btn:lang(ur) { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Urdu Typesetting", "Noto Naskh Arabic", serif; font-size: 1.05rem; line-height: 1.6; }

/* ---------- Urdu: Nastaliq font that iPhone and Android already have, right-to-left ---------- */
html[lang=ur] body {
  font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Urdu Typesetting", "Noto Naskh Arabic",
               system-ui, sans-serif;
  line-height: 2;
}
html[lang=ur] h1 { line-height: 1.9; font-size: 1.5rem; }
html[lang=ur] .step h2 { font-size: 1.05rem; line-height: 1.9; }
html[lang=ur] .btn { line-height: 1.7; padding-top: .45rem; padding-bottom: .45rem; }
html[lang=ur] .chip small, html[lang=ur] .hint, html[lang=ur] .consent { line-height: 2; }
html[lang=ur] .brand, html[lang=ur] .lang-btn:lang(en) { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.5; }
html[lang=ur] .g-status, html[lang=ur] .g-sub { line-height: 1.9; }
.pick-map { direction: ltr; }   /* Leaflet expects left-to-right inside the map */
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 1.2rem; }

h1 { font-size: 1.6rem; line-height: 1.2; margin: 1.1rem 0 .4rem; }
.lead { color: var(--muted); margin: 0 0 1rem; }

.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
.step h2 { font-size: 1.05rem; margin: 0 0 .7rem; display: flex; align-items: center; gap: .5rem; }
.step h2 small { font-weight: 400; color: var(--muted); }
.num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .85rem; }

.btn-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 420px) { .btn-row { grid-template-columns: 1fr 1fr; } }

.hint { font-size: .88rem; color: var(--muted); margin: .5rem 0 0; }
.hint.right { text-align: end; }
.hint.center { text-align: center; }

.guided-offer .hint.or { text-align: center; margin: .6rem 0; }

/* ---------- guided recording (full screen) ---------- */
body.no-scroll { overflow: hidden; }
/* sizes in em: guided.js scales the root font so the controls stay phone-sized in "Desktop site" mode */
.guided { position: fixed; inset: 0; z-index: 2000; background: #000; color: #fff; font-size: 16px; overflow: hidden; }
.guided video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.g-grid { position: absolute; inset: 0; pointer-events: none; }
.g-grid i { position: absolute; background: rgba(255,255,255,.45); }
.g-grid i:nth-child(1), .g-grid i:nth-child(2) { top: 0; bottom: 0; width: 1px; }
.g-grid i:nth-child(1) { left: 33.333%; }
.g-grid i:nth-child(2) { left: 66.666%; }
.g-grid i:nth-child(3), .g-grid i:nth-child(4) { left: 0; right: 0; height: 1px; }
.g-grid i:nth-child(3) { top: 33.333%; }
.g-grid i:nth-child(4) { top: 66.666%; }
.g-top {
  position: absolute; left: 0; right: 0; top: 0;
  padding: max(.75em, env(safe-area-inset-top)) 1em .9em;
  background: linear-gradient(rgba(0,0,0,.65), rgba(0,0,0,0)); text-align: center;
}
.g-status { margin: 0 auto; display: inline-block; font-weight: 700; font-size: 1.1em; padding: .35em .9em; border-radius: 99em; background: rgba(0,0,0,.55); }
.g-status.g-bad { background: #dc2626; }
.g-status.g-ok { background: #16a34a; }
.g-meter { height: .5em; max-width: 20em; margin: .6em auto 0; background: rgba(255,255,255,.25); border-radius: 99em; overflow: hidden; }
.g-meter span { display: block; height: 100%; width: 0; background: #dc2626; transition: width .15s linear; }
.g-meter.g-ok span { background: #16a34a; }
.g-sub { margin: .5em 0 0; font-size: .9em; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.g-hint { color: #fde68a; font-weight: 600; }
.g-torch {
  position: absolute; right: .9em; bottom: 5.4em; z-index: 1;   /* above the bottom buttons, thumb reach */
  font: inherit; font-size: .95em; font-weight: 700; color: #fff;
  min-width: 4.5em; min-height: 2.8em; padding: .4em .9em; border-radius: 99em;
  border: 2px solid rgba(255,255,255,.8); background: rgba(0,0,0,.45); cursor: pointer;
}
.g-torch::before { content: "\26A1 "; }               /* lightning sign */
.g-torch[aria-pressed=true] { background: #fde047; color: #111; border-color: #fde047; }
.g-count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 7em; font-weight: 800; text-shadow: 0 2px 12px rgba(0,0,0,.7); pointer-events: none; }
.g-rec { position: absolute; left: 1em; bottom: 5.6em; background: rgba(0,0,0,.6); border-radius: 99em; padding: .3em .9em; font-weight: 700; display: flex; align-items: center; gap: .5em; }
.g-dot { width: .75em; height: .75em; border-radius: 50%; background: #ef4444; animation: g-blink 1s infinite; }
@keyframes g-blink { 50% { opacity: .2; } }
.g-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: .9em 1em max(1em, env(safe-area-inset-bottom));
  display: flex; gap: .6em; justify-content: center;
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.65));
}
.g-bottom .btn { flex: 1; max-width: 12.5em; font-size: 1em; min-height: 3em; padding: .7em 1.1em; border-radius: .75em; }

.preview { margin-top: 10px; }
.preview video { width: 100%; max-height: 50vh; border-radius: 8px; background: #000; }
.meta { font-size: .88rem; color: var(--ok); margin: .3rem 0 0; font-weight: 600; }

.map-box { margin-top: 10px; }
.pick-map { height: 320px; border-radius: 10px; border: 1px solid var(--line); }
.map-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.map-tools .hint { margin: 0; }

.status { margin: .6rem 0 0; font-size: .93rem; color: var(--muted); }
.status:empty { display: none; }
.status.ok { color: var(--ok); font-weight: 600; }
.status.warn { color: var(--warn); }

.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chips-3 { grid-template-columns: 1fr; }
@media (min-width: 420px) { .chips-3 { grid-template-columns: 1fr 1fr 1fr; } }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip > span { display: block; padding: .55rem .7rem; border: 2px solid var(--line); border-radius: var(--radius); background: #fff; min-height: 100%; }
.chip small { display: block; color: var(--muted); font-size: .8rem; }
.chip input:checked + span { border-color: var(--accent); background: #e7f4f8; }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

textarea, input[type=text], input[type=password], select {
  width: 100%; font: inherit; padding: .65rem .75rem;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }

.consent { font-size: .85rem; color: var(--muted); background: #eef3f6; border-radius: 10px; padding: .7rem .8rem; margin: 4px 0 12px; }

.error { background: #fdecec; color: var(--err); border: 1px solid #f5c2c2; border-radius: 10px; padding: .7rem .8rem; margin: 0 0 12px; }

.progress { margin: 0 0 12px; }
.progress .bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress p { margin: .35rem 0 0; font-size: .9rem; color: var(--muted); text-align: center; }

.done { text-align: center; padding-top: 2rem; }
.done .tick { width: 72px; height: 72px; margin: 0 auto; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 2.2rem; }
.done p { color: var(--muted); }
.done-lead strong { color: var(--ink); }
.done-card { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 1.2rem 0; }
.done-card h2 { font-size: 1rem; margin: 0 0 .4rem; }
.done-card ul { margin: 0 0 .6rem; padding-left: 1.2rem; }
.done-card li { margin: .2rem 0; }
.done-actions { display: grid; gap: 8px; }

/* ---------- admin: login ---------- */
.login-card { max-width: 380px; margin: 10vh auto 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.login-card h1 { margin-top: .6rem; font-size: 1.35rem; }
.login-card label { display: block; font-weight: 600; margin: .8rem 0 .3rem; }
.login-card .btn { width: 100%; margin-top: 1.1rem; }

/* ---------- admin: map ---------- */
body.admin { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 8px 12px; background: var(--brand); color: #fff;
}
.topbar .brand { color: #fff; }
.topbar .logo { background: #fff; color: var(--brand); }
.topbar .counts { display: flex; gap: 10px; font-size: .9rem; flex-wrap: wrap; }
.topbar .counts span { white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar select { width: auto; padding: .35rem .5rem; min-height: 36px; }
.topbar form { margin: 0; }
.topbar .btn { min-height: 36px; padding: .35rem .75rem; font-size: .9rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; border: 1px solid #fff; }
.dot.pending { background: #f59e0b; }
.dot.verified { background: #16a34a; }
.dot.rejected { background: #dc2626; }

.workspace { flex: 1; display: flex; min-height: 0; }
#map { flex: 1; min-height: 300px; }
.report-list { width: 400px; max-width: 45vw; overflow: auto; background: var(--card); border-right: 1px solid var(--line); }
.workspace.no-list .report-list { display: none; }
.report-list table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.report-list th { position: sticky; top: 0; background: #eef3f6; z-index: 1; text-align: left; padding: 0; border-bottom: 1px solid var(--line); }
.report-list th button { all: unset; display: block; width: 100%; box-sizing: border-box; padding: .5rem .5rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.report-list th button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.report-list th[aria-sort=ascending] button::after { content: " \25B2"; font-size: .7em; }
.report-list th[aria-sort=descending] button::after { content: " \25BC"; font-size: .7em; }
.report-list td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.report-list tbody tr { cursor: pointer; }
.report-list tbody tr:hover { background: #f3f8fa; }
.report-list tbody tr.selected { background: #e1f1f6; box-shadow: inset 3px 0 0 var(--accent); }
.report-list tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.report-list tbody tr[title] td:first-child::after { content: " \26A0"; color: var(--warn); }
.list-empty { padding: 1rem; color: var(--muted); }
#list-toggle[aria-pressed=true] { background: #e1f1f6; }
@media (max-width: 760px) {
  .workspace { flex-direction: column-reverse; }
  .report-list { width: auto; max-width: none; height: 40%; border-right: 0; border-top: 1px solid var(--line); }
}
.map-msg { position: absolute; z-index: 500; left: 50%; top: 70px; transform: translateX(-50%); background: #fff; border-radius: 10px; padding: .5rem .9rem; box-shadow: 0 2px 10px rgba(0,0,0,.15); font-size: .92rem; }

/* clusters: coloured by the status most of their reports have */
.cl { background: transparent; }
.cl div {
  width: 100%; height: 100%; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: .9rem;
  border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.35);
  box-sizing: border-box;
}
.cl-l div { font-size: .8rem; }
.cl-pending div { background: #f59e0b; }
.cl-verified div { background: #16a34a; }
.cl-rejected div { background: #dc2626; }
.cl-mixed div { border-style: dashed; }   /* contains more than one status */

/* popup */
.rp h3 { margin: 0 0 .4rem; font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.rp dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0 0 .5rem; font-size: .86rem; }
.rp dt { color: var(--muted); }
.rp dd { margin: 0; word-break: break-word; }
.rp video { width: 100%; height: 220px; object-fit: contain; background: #000; border-radius: 6px; display: block; }
.rp .vlink { font-size: .82rem; display: inline-block; margin: .25rem 0 .5rem; }
.rp textarea { font-size: .88rem; padding: .4rem .5rem; }
.rp .review { border-top: 1px solid var(--line); padding-top: .5rem; margin-top: .2rem; }
.rp .review-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.rp .rf span { display: block; font-size: .74rem; color: var(--muted); margin-bottom: 2px; }
.rp .rf input, .rp .rf select { width: 100%; font: inherit; font-size: .86rem; padding: .3rem .35rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.rp .actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.rp .msg { font-size: .82rem; margin: .3rem 0 0; min-height: 1em; }
.rp .warn { font-size: .82rem; color: var(--warn); background: #fff7e6; border-radius: 6px; padding: .3rem .5rem; margin: 0 0 .5rem; }
.badge { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 99px; color: #fff; }
.badge.pending { background: #d97706; }
.badge.verified { background: #16a34a; }
.badge.rejected { background: #dc2626; }

/* ---------- reporter network: join page ---------- */
.join-form label { display: block; font-weight: 600; margin: .9rem 0 .3rem; }
.join-form label:first-of-type { margin-top: 0; }
.join-form input[type=tel] { width: 100%; font: inherit; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.join-form .code-input { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; font-size: 1.2rem; }
.join-form .btn.big { margin-top: .6rem; }
html[lang=ur] .join-form input { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

/* ---------- reporter network: member map ---------- */
body.member { background: var(--bg); }
.member-top { background: var(--brand); color: #fff; padding: 10px 16px; }
.member-top .brand { color: #fff; }
.member-top .logo { background: #fff; color: var(--brand); }
.member-top .lang-btn { border-color: #fff; }
.member-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .9rem; margin-top: 4px; opacity: .95; }
.member-sub form { margin: 0; }
.linklike { all: unset; cursor: pointer; text-decoration: underline; color: inherit; font-size: .9rem; }
.member-main { max-width: 720px; margin: 0 auto; padding: 14px 16px 48px; }
.report-big { width: 100%; min-height: 64px; font-size: 1.25rem; box-shadow: 0 4px 14px rgba(11,79,108,.3); }
.joined-ok { background: #e8f6ee; color: var(--ok); border-radius: 10px; padding: .6rem .8rem; font-weight: 600; margin: 0 0 10px; }
.member-h1 { font-size: 1.3rem; margin: 1.2rem 0 .2rem; }
.member-map { height: 55vh; min-height: 300px; border-radius: 12px; border: 1px solid var(--line); direction: ltr; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; margin: 8px 0 0; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i, .near-item > i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); flex: none; }
.d-ankle { background: #facc15; } .d-knee { background: #f97316; } .d-waist { background: #dc2626; } .d-unknown { background: #94a3b8; }
.near-h { font-size: 1.15rem; margin: 1.4rem 0 .2rem; }
.near-list { list-style: none; margin: 0; padding: 0; }
.near-item { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .65rem .8rem; margin: 0 0 8px; cursor: pointer; }
.near-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.near-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.near-main .hint { margin: 0; }
.near-dist { font-weight: 700; white-space: nowrap; direction: ltr; }
.mp strong { display: block; margin-bottom: 2px; }

/* ---------- reporter network: banner on the report page for members ---------- */
.member-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #e7f4f8; border: 1px solid #b6dbe6; border-radius: 12px; padding: .6rem .8rem; margin: 10px 0 0; }
.member-banner strong { display: block; }
.member-banner .hint { margin: 0; }
.member-banner a { white-space: nowrap; font-weight: 600; }
@keyframes spl-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(14,124,155,.55); } 50% { box-shadow: 0 0 0 10px rgba(14,124,155,0); } }
.btn.pulse { animation: spl-pulse 1.6s ease-in-out 4; }

/* ---------- admin: groups pages ---------- */
body.admin-page { background: var(--bg); }
.admin-wrap { max-width: 1100px; margin: 0 auto; padding: 16px 16px 48px; }
.admin-wrap h1 { font-size: 1.4rem; margin: .6rem 0 .6rem; }
.admin-wrap h2 { font-size: 1.1rem; margin: 1.2rem 0 .5rem; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: .92rem; }
.admin-table th, .admin-table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table th { background: #eef3f6; }
.admin-table tr.inactive td { color: var(--muted); }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.actions-cell form { margin: 0; }
.join-code { font-weight: 700; letter-spacing: .12em; background: #eef3f6; padding: .1rem .35rem; border-radius: 6px; }
.admin-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-top: 16px; }
.admin-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.admin-card h2 { margin-top: 0; }
.admin-card label { display: block; font-weight: 600; margin: .6rem 0 .25rem; }
.admin-card input[type=tel] { width: 100%; font: inherit; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 10px; }
.admin-card .btn { margin-top: .8rem; }
.notice { background: #e8f6ee; color: var(--ok); border: 1px solid #bfe3cc; border-radius: 10px; padding: .6rem .8rem; margin: 0 0 12px; }
.link-box { background: #fff7e6; border: 1px solid #f3d29a; border-radius: 12px; padding: 12px 14px; margin: 0 0 14px; }
.link-input { width: 100%; font: inherit; font-size: .9rem; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; margin: 4px 0 8px; }
.found { margin: .6rem 0 0; padding-left: 1.1rem; }

/* attribution for the boundary data, under every map (required by the ODbL licence) */
.map-credit { font-size: .75rem; color: var(--muted); margin: .35rem 0 0; line-height: 1.4; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.admin-credit { margin: 0; padding: .2rem .6rem; background: var(--card); border-top: 1px solid var(--line); flex: none; }

/* upload page header: FloodSnap + StreetDepth */
.brand-name { display: inline-flex; align-items: baseline; gap: .35rem; }
.brand-sub { font-weight: 600; color: var(--muted); font-size: .8rem; letter-spacing: 0; }
html[lang=ur] .brand-name strong, html[lang=ur] .brand-name > span[data-i18n] { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Urdu Typesetting", serif; line-height: 1.8; }
