/* CleanMap — calm, trustworthy, mobile-first civic reporting. */
:root {
  --primary: #0B6B48;
  --primary-hover: #07563A;
  --primary-soft: #EAF5EF;
  --ink: #13251D;
  --muted: #607069;
  --bg: #F4F7F4;
  --card: #FFFFFF;
  --line: #DCE5DF;
  --line-strong: #C6D4CC;
  --warn: #C56A08;
  --danger: #B63E37;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 2px 8px rgba(19, 37, 29, .08);
  --shadow: 0 12px 32px rgba(19, 37, 29, .14);
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body { height: 100%; }
a { color: var(--primary); text-underline-offset: 3px; }
button, input, textarea { -webkit-tap-highlight-color: transparent; }

/* ---- app shell ---------------------------------------------------- */
.app { display: flex; flex-direction: column; height: 100dvh; min-height: 520px; }
.flow-app { height: auto; min-height: 100dvh; }

header.bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 16px;
  min-height: 62px;
  padding: 9px max(16px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--ink);
  font-weight: 780;
  font-size: 18px;
  letter-spacing: -.025em;
  line-height: 1;
  text-decoration: none;
}
.brand > span:last-child { display: flex; align-items: baseline; gap: 7px; }
.brand small { color: var(--muted); font-size: 11px; font-weight: 580; letter-spacing: .01em; }
.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 4px 10px rgba(11, 107, 72, .22);
}
.brand-mark svg { width: 21px; height: 21px; fill: currentColor; }

.stats {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.stats strong { color: var(--primary); font-weight: 800; }
.header-link { padding: 10px 2px; color: var(--muted); font-size: 14px; font-weight: 650; text-decoration: none; }
.header-link:hover { color: var(--ink); }

/* ---- buttons ------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 720;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { background: #F7F9F7; border-color: #AFC0B6; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .chip:focus-visible, .dropzone:focus-within, .library-link:focus-visible, .text-button:focus-visible {
  outline: 3px solid rgba(33, 145, 103, .35);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 5px 14px rgba(11, 107, 72, .2);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-cta { min-height: 54px; font-size: 16px; width: 100%; }
.btn-ghost { background: transparent; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { min-width: 0; }
.btn-row > :last-child { flex: 1; }
.btn-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- map ---------------------------------------------------------- */
.map-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#map, #pickmap { position: absolute; inset: 0; }
#pickmap { position: relative; height: 300px; }

.filters {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 4;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 2px 7px;
  scroll-padding-inline: 2px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid rgba(198, 212, 204, .9);
  border-radius: 999px;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow-sm);
  color: #293B33;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.chip[aria-pressed="true"] { color: #fff; background: var(--primary); border-color: var(--primary); }

#map .maplibregl-ctrl-top-right { top: 58px; right: 2px; }
.maplibregl-ctrl-group { overflow: hidden; border: 1px solid var(--line) !important; border-radius: 12px !important; box-shadow: var(--shadow-sm) !important; }

.map-key {
  position: absolute;
  z-index: 4;
  left: 14px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 11px;
  border: 1px solid rgba(220, 229, 223, .9);
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-sm);
  color: #4F6259;
  font-size: 11px;
  font-weight: 650;
}
.map-key span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.key-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.key-urgent { background: var(--danger); }
.key-cleared { background: #95A39B; }

.cta-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 24px 14px calc(13px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(244,247,244,.99) 58%, rgba(244,247,244,0));
}
.cta-dock .btn { box-shadow: 0 8px 22px rgba(11, 107, 72, .28); }

.pin { border-radius: 50%; border: 2px solid #fff; box-shadow: var(--shadow-sm); cursor: pointer; }
.pin-1, .pin-2 { width: 14px; height: 14px; background: #4F9E77; }
.pin-3 { width: 20px; height: 20px; background: var(--primary); }
.pin-4 { width: 26px; height: 26px; background: var(--warn); }
.pin-5 { width: 30px; height: 30px; background: var(--danger); }
.pin-resolved { background: #95A39B !important; }
.cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255,255,255,.9);
  border-radius: 50%;
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(19, 37, 29, .25);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

/* ---- cards / popups ----------------------------------------------- */
.card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-sm); }
.card-body { padding: 16px; }
.card img.photo { display: block; width: 100%; height: auto; background: #EAF0EC; }
.maplibregl-popup-content { overflow: hidden; width: 270px; padding: 0; border-radius: var(--radius); box-shadow: var(--shadow); }
.maplibregl-popup-close-button { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.92); font-size: 22px; }

.meta { color: var(--muted); font-size: 13px; }
.title { margin: 0 0 5px; font-size: 16px; font-weight: 760; }
.sev { letter-spacing: 2px; font-size: 13px; }
.sev b { color: var(--primary); }
.sev-4 b { color: var(--warn); }
.sev-5 b { color: var(--danger); }
.sev i { color: #C9D2CB; font-style: normal; }
.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-hover); font-size: 12px; font-weight: 700; }
.tag-hazard { background: #FDECEA; color: var(--danger); }
.tag-resolved { background: #EFF1EE; color: var(--muted); }

/* ---- reporting flow ----------------------------------------------- */
.page { width: 100%; max-width: 600px; margin: 0 auto; padding: 22px 18px 48px; }
.flow-page { flex: 1; }
.page h1 { margin: 5px 0 8px; font-size: clamp(26px, 7vw, 34px); line-height: 1.12; letter-spacing: -.035em; }
.page p.lead { margin: 0 0 22px; color: var(--muted); font-size: 16px; line-height: 1.45; }
.eyebrow { margin-bottom: 5px; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.step { display: none; }
.step.active { display: block; }

.stepper { display: flex; align-items: center; margin: 0 0 30px; }
.stepper div { display: flex; align-items: center; gap: 7px; color: #8A9891; }
.stepper div span { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--card); font-size: 12px; font-weight: 800; }
.stepper div small { font-size: 12px; font-weight: 700; }
.stepper div.on { color: var(--primary); }
.stepper div.on span { border-color: var(--primary); background: var(--primary); color: #fff; }
.stepper i { flex: 1; height: 1px; margin: 0 10px; background: var(--line); }

.dropzone {
  display: flex;
  min-height: 226px;
  padding: 26px 20px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px dashed #9DB8A9;
  border-radius: var(--radius-lg);
  background: linear-gradient(150deg, #FFF 0%, #F2F8F4 100%);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone:active { transform: scale(.995); }
.dropzone strong { color: var(--ink); font-size: 18px; }
.dropzone > span:last-of-type { max-width: 280px; font-size: 14px; }
.camera-icon { display: grid; width: 58px; height: 58px; margin-bottom: 4px; place-items: center; border-radius: 18px; background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(11, 107, 72, .2); }
.camera-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.library-link { display: block; width: max-content; margin: 14px auto 6px; padding: 8px; color: var(--primary); font-size: 14px; font-weight: 750; text-decoration: underline; cursor: pointer; }

.photo-preview { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); box-shadow: var(--shadow-sm); }
.preview { display: block; width: 100%; max-height: 430px; object-fit: cover; background: #EAF0EC; }
.photo-preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 15px; }
.photo-preview-bar strong, .photo-preview-bar small { display: block; }
.photo-preview-bar strong { font-size: 14px; }
.photo-preview-bar small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.text-button { min-height: 40px; padding: 6px 4px; border: 0; background: none; color: var(--primary); font: inherit; font-size: 14px; font-weight: 750; cursor: pointer; }
.upload-status { min-height: 0; }
.upload-status:not(:empty) { display: flex; align-items: center; gap: 9px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.mini-spinner { width: 16px; height: 16px; border: 2px solid #C9D8D0; border-top-color: var(--primary); border-radius: 50%; animation: spin .75s linear infinite; }

.privacy-tip { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0 2px; padding: 13px 14px; border-radius: 13px; background: var(--primary-soft); color: #36564A; font-size: 13px; line-height: 1.4; }
.privacy-tip svg { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: var(--primary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.privacy-tip strong { color: var(--ink); }

.flow-actions { margin-top: 20px; }
.flow-actions .btn-ghost { flex: 0 0 auto; min-width: 92px; }
.secondary-action { margin-top: 10px; color: var(--primary); border-color: #B9CEC2; }
.lone-back { width: 100%; margin-top: 12px; }

.map-instruction { display: flex; justify-content: space-between; gap: 10px; margin: 22px 0 10px; }
.map-instruction strong { font-size: 15px; }
.map-instruction span { color: var(--muted); font-size: 12px; text-align: right; }
.picker-shell { overflow: hidden; border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
#accuracy { margin: 9px 2px 0; }

.review-card .photo { max-height: 380px; object-fit: cover; }
.location-confirmed { position: relative; margin: 0; padding-left: 25px; color: #345347; font-size: 14px; font-weight: 680; }
.location-confirmed::before { position: absolute; left: 0; top: -2px; content: "✓"; display: grid; width: 18px; height: 18px; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 12px; }

label.field { display: flex; justify-content: space-between; margin: 22px 0 7px; font-size: 14px; font-weight: 750; }
label.field span { color: var(--muted); font-size: 12px; font-weight: 600; }
input[type=text], textarea, select { width: 100%; padding: 13px 14px; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--card); color: var(--ink); font: inherit; outline: none; }
textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11, 107, 72, .11); }
.field-help { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.submit-note { margin: 14px 6px 0; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: center; }
.result-step { padding-top: 18px; text-align: center; }
.result-step .card { text-align: left; }
.success-mark, .error-mark { display: grid; width: 62px; height: 62px; margin: 0 auto 18px; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 30px; font-weight: 800; }
.error-mark { background: #FCECEB; color: var(--danger); }

.notice { margin: 12px 0; padding: 12px 14px; border: 1px solid #D2E5D9; border-radius: 13px; background: var(--primary-soft); color: #244A3B; font-size: 14px; line-height: 1.4; }
.notice-warn { border-color: #EED7AE; background: #FFF5E5; color: #815109; }
.notice-error { border-color: #EDCAC7; background: #FCECEB; color: #852F2A; }
.radios { display: grid; gap: 8px; }
.radios label { display: flex; min-height: 46px; padding: 12px; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); cursor: pointer; }

.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.pin-hint { position: absolute; left: 50%; top: 50%; z-index: 3; transform: translate(-50%, -100%); pointer-events: none; }
footer.foot { padding: 18px 16px 30px; color: var(--muted); font-size: 12px; text-align: center; }

/* Admin keeps a deliberately plain, dense layout. */
table.admin { width: 100%; border-collapse: collapse; font-size: 14px; }
table.admin th, table.admin td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.admin img { display: block; width: 110px; border-radius: 8px; }

@media (min-width: 720px) {
  .flow-app { background: linear-gradient(135deg, #F5F8F5, #EDF4F0); }
  .flow-page { max-width: 650px; margin-top: 32px; margin-bottom: 48px; padding: 34px 44px 44px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.92); box-shadow: 0 18px 50px rgba(19,37,29,.09); }
  .page h1 { font-size: 34px; }
}

@media (min-width: 900px) {
  header.bar { padding-inline: 22px; }
  .filters { right: auto; max-width: calc(100% - 120px); }
  .cta-dock { left: auto; right: 22px; bottom: 22px; width: 320px; padding: 0; background: none; }
  .map-key { bottom: 22px; }
}

@media (max-width: 430px) {
  header.bar { min-height: 58px; padding-block: 8px; }
  .brand-mark { width: 34px; height: 34px; flex-basis: 34px; }
  .brand small { display: none; }
  .stats { max-width: 150px; font-size: 11px; }
  .page { padding: 19px 16px 38px; }
  .stepper { margin-bottom: 26px; }
  .stepper div small { font-size: 11px; }
  .stepper i { margin-inline: 7px; }
  .map-key { right: auto; max-width: calc(100% - 28px); gap: 9px; }
}

@media (max-width: 350px) {
  .map-key span:last-child { display: none; }
  .stepper div small { display: none; }
}
