/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:       #f4f6f8;
  --card:     #fff;
  --ink:      #1d2733;
  --muted:    #6b7888;
  --line:     #e1e6ec;
  --accent:   #1f6f54;
  --accent-d: #16523e;
  --warn:     #b35900;
  --err:      #c0392b;
  --ok:       #1f6f54;
  --footer-h: 60px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* ── App layout ──────────────────────────────────────────────────────────────── */
:root { --topbar-h: 48px; --sidebar-w: 220px; }

.app-topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  z-index: 100;
}
.topbar-brand {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; color: #1a202c; flex-shrink: 0;
}
.tb-badge {
  width: 30px; height: 30px;
  background: url("/land_app_logo.png") center / contain no-repeat;
  flex-shrink: 0;
  /* The mark carries the brand now; the "LA" letters behind it would show
     through the transparent PNG. */
  text-indent: -9999px; overflow: hidden;
}
.tb-name { font-size: 0.875rem; font-weight: 700; }
.tb-hail-logo { display: none; width: 176px; height: 46px; object-fit: cover; object-position: center; background: #315f36; border-radius: 4px; }
html[data-association="hail"] .tb-badge,
html[data-association="hail"] .tb-name { display: none; }
html[data-association="hail"] .tb-hail-logo { display: block; }
.topbar-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: #718096; flex: 1;
}
.topbar-breadcrumb a { color: #718096; text-decoration: none; }
.topbar-breadcrumb a:hover { color: #2d3748; }
.bc-sep { color: #cbd5e0; }
.bc-current { color: #2d3748; font-weight: 500; }
.job-badge {
  font-size: 11px; font-weight: 700;
  background: #eef2f5; border: 1px solid var(--line);
  border-radius: 20px; padding: 3px 11px; color: var(--ink);
  letter-spacing: .4px; white-space: nowrap;
}
.job-badge:empty { display: none; }

.app-body {
  display: flex;
  margin-top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}
.app-sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--line);
  height: 100%; overflow-y: auto;
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
}
.app-main {
  margin-left: var(--sidebar-w);
  flex: 1; overflow-y: auto;
  height: 100%;
  display: flex; flex-direction: column;
}

/* ── Sidebar stepper ─────────────────────────────────────────────────────────── */
.stepper { padding: 20px 0; }
.step {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 18px;
  color: #64748b;
  font-size: 0.815rem;
  border-left: 3px solid transparent;
  user-select: none;
}
.step.reachable { cursor: pointer; }
.step.reachable:hover { background: #f1f5f9; color: #1a202c; }
.step.active {
  color: #1a202c; font-weight: 600;
  border-left-color: #3dba78;
  background: #f1f5f9;
}
.step.done { color: #475569; }
.step-num {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid #cbd5e0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; flex-shrink: 0;
  color: #94a3b8;
}
.step.active .step-num { border-color: #3dba78; background: #3dba78; color: #fff; }
.step.done .step-num   { border-color: #94a3b8; color: #475569; }
.step-label { line-height: 1.25; }


/* ── Page layout ─────────────────────────────────────────────────────────────── */
#pages { max-width: none; padding: 28px 32px 8px; flex: 1; }
.page.hidden { display: none; }
.page-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 32px 36px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.page-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
}
.page-intro {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 22px;
}
.info-box {
  background: #eef7f2;
  border: 1px solid #cfe8db;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--ink);
}

/* ── Forms ───────────────────────────────────────────────────────────────────── */
label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 13px; color: var(--muted); font-weight: 600;
}
input[type=text], input[type=search], input[type=file], select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
}
input[type=text]:focus, input[type=search]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31,111,84,.1);
}
input[readonly] { background: #f7f9fb; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.span2  { grid-column: span 2; }
.row    { display: flex; gap: 8px; }
.row input { flex: 1; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
/* Windows 98 chrome: a 2px bevel (white top/left, grey bottom/right) that
   inverts when pressed, square corners, Tahoma, and the compact padding of the
   era. The pressed state shifts the label 1px down-right without changing the
   box size, so dense toolbars never reflow. */
:root {
  --w98-face:   #c0c0c0;
  --w98-light:  #ffffff;
  --w98-shadow: #808080;
  --w98-dark:   #0a0a0a;
}
button {
  color: #090909;
  font-family: "Tahoma", "Segoe UI", sans-serif;
  font-size: 13px; font-weight: 400;
  background: var(--w98-face);
  border: 2px solid;
  border-color: var(--w98-light) var(--w98-shadow) var(--w98-shadow) var(--w98-light);
  border-radius: 0;
  padding: 5px 14px; cursor: pointer;
  transition: background .12s;
}
button:hover:not(:disabled) { background: #d0d0d0; }
button:active:not(:disabled) {
  border-color: var(--w98-shadow) var(--w98-light) var(--w98-light) var(--w98-shadow);
  padding: 6px 13px 4px 15px;      /* same box, label nudged down-right */
}
button:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
button:disabled { color: var(--w98-shadow); text-shadow: 1px 1px 0 var(--w98-light); cursor: default; }

/* The default action keeps the brand colour, with the same bevel. */
button.primary {
  background: var(--accent); color: #fff; font-weight: 700;
  border-color: rgba(255,255,255,.55) rgba(0,0,0,.45) rgba(0,0,0,.45) rgba(255,255,255,.55);
}
button.primary:hover:not(:disabled) { background: var(--accent-d); }
button.primary:active:not(:disabled) {
  border-color: rgba(0,0,0,.45) rgba(255,255,255,.55) rgba(255,255,255,.55) rgba(0,0,0,.45);
}
button.primary:disabled { color: #eef2f5; text-shadow: none; }

button.ghost { background: var(--w98-face); color: var(--ink); }
button.ghost:hover:not(:disabled) { background: #d0d0d0; }

button.small { font-size: 11.5px; padding: 3px 9px; }
button.small:active:not(:disabled) { padding: 4px 8px 2px 10px; }

.btn-analyse { margin-top: 20px; }
a.btnlink {
  display: inline-block;
  background: var(--accent); color: #fff;
  font-family: "Tahoma", "Segoe UI", sans-serif;
  text-decoration: none; padding: 5px 14px;
  border: 2px solid;
  border-color: rgba(255,255,255,.55) rgba(0,0,0,.45) rgba(0,0,0,.45) rgba(255,255,255,.55);
  border-radius: 0; font-weight: 700; font-size: 13px;
}
a.btnlink:hover { background: var(--accent-d); }
a.btnlink:active {
  border-color: rgba(0,0,0,.45) rgba(255,255,255,.55) rgba(255,255,255,.55) rgba(0,0,0,.45);
  padding: 6px 13px 4px 15px;
}

/* ── Status ──────────────────────────────────────────────────────────────────── */
.status { margin: 12px 0 0; font-size: 13px; min-height: 18px; }
.status.err { color: var(--err); }
.status.ok  { color: var(--ok); }
.muted      { color: var(--muted); font-size: 12px; }

/* HAIL-only LINZ parcel boundary selector */
.hail-only, .hail-only-inline { display: none !important; }
html[data-association="hail"] .hail-only { display: block !important; }
html[data-association="hail"] .hail-only-inline { display: inline !important; }
.parcel-selector {
  border: 1px solid #c9daca;
  border-radius: 10px;
  padding: 18px;
  background: #f7fbf7;
}
.parcel-selector-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.parcel-selector-head h3 { margin: 0 0 2px; font-size: 16px; color: var(--ink); }
.parcel-selector-head p { margin: 0; color: var(--muted); font-size: 13px; }
.parcel-source-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #315f36;
  color: #fff;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}
.parcel-search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.parcel-search-row input { flex: 1; min-width: 0; }
#parcel-map {
  height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8edf0;
}
.parcel-map-help, .parcel-caution {
  color: var(--muted);
  font-size: 12px;
  margin: 7px 0 0;
}
.parcel-search-results, .parcel-candidates {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px;
  margin: 0 0 10px;
}
.parcel-search-results.hidden, .parcel-candidates.hidden, .parcel-selected.hidden { display: none; }
.parcel-result, .parcel-candidate {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  color: var(--ink);
}
.parcel-result:hover, .parcel-candidate:hover { background: #eef5ef; }
.parcel-candidate strong, .parcel-candidate span { display: block; }
.parcel-candidate span { color: var(--muted); font-size: 12px; font-weight: 400; }
.parcel-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #aac9ad;
  border-radius: 8px;
  background: #eaf5eb;
  padding: 10px 12px;
}
.parcel-selected strong, .parcel-selected span { display: block; }
.parcel-selected span { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ── Page 2: Map ─────────────────────────────────────────────────────────────── */
.split {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 22px;
}
#map {
  height: 340px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.fields { display: flex; flex-direction: column; gap: 14px; }
.attrs  { font-size: 12px; color: var(--muted); }
.attrs code {
  background: #f0f3f6;
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── Page 3: Authorities ──────────────────────────────────────────────────────── */
.auth {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fafcfd;
}
.auth h3 {
  margin: 0 0 6px;
  font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
}
.auth .name { font-size: 19px; font-weight: 700; }
.auth .meta { font-size: 13px; color: var(--muted); margin-top: 6px; }
/* one entry per council when a site straddles a boundary */
.auth-entry + .auth-entry { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.auth-share { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.auth-note { margin-top: 12px; font-size: 12px; color: #8a6414; background: #fff8ec;
  border: 1px solid #ecd9ac; border-radius: 6px; padding: 8px 10px; }

/* ── Page 4: Emails ──────────────────────────────────────────────────────────── */
.contact-block { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 20px; }
.contact-block:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.contact-block h3 { margin: 0 0 14px; font-size: 15px; }
.hail-controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 18px; margin-bottom: 10px;
}
label.inline {
  flex-direction: row; align-items: center; gap: 8px;
  font-size: 14px; color: var(--ink); font-weight: 600;
}
label.inline input[type=text] { width: 170px; }
.email {
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; overflow: hidden; margin-bottom: 12px;
}
.email .to {
  background: #f7f9fb; padding: 8px 12px; font-size: 13px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}
.email .subject {
  padding: 8px 12px; font-weight: 600;
  border-bottom: 1px solid var(--line); font-size: 14px;
}
.email .body {
  margin: 0; padding: 12px;
  white-space: pre-wrap;
  font: 13px/1.5 ui-monospace, Menlo, monospace;
  max-height: 260px; overflow: auto;
}
.email .actions {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--line); background: #fafcfd;
}
.online-link {
  display: flex; align-items: center; gap: 14px;
  background: #eef7f2; border: 1px solid #cfe8db;
  border-radius: 8px; padding: 14px 16px;
}
.online-link .tag {
  background: var(--accent); color: #fff;
  font-size: 11px; padding: 3px 8px;
  border-radius: 20px; font-weight: 700; letter-spacing: .3px;
  white-space: nowrap;
}
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.email-badge { background: #fdf0e3; color: var(--warn); }
.verify { color: var(--warn); font-size: 12px; margin-top: 8px; }
.reg-own {
  padding: 10px 12px; border-radius: 7px;
  background: #f0f3f6; margin: 6px 0 12px; font-size: 13px;
}
.reg-own.listed { background: #fdf0e3; border: 1px solid #f0d6b5; }
.reg-near-h { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.near-item {
  flex-direction: row; align-items: flex-start; gap: 9px;
  font-weight: 400; color: var(--ink);
  padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 7px; margin-bottom: 6px; font-size: 13px; cursor: pointer;
}
.near-item:hover { background: #fafcfd; }
.near-item input { margin-top: 3px; }
.dist { color: var(--warn); font-weight: 600; margin-left: 6px; }
.cls  { color: var(--muted); margin-left: 6px; }
.cats { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ── Page 5: Retrolens ────────────────────────────────────────────────────────── */
.retro-controls {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 0 10px; flex-wrap: wrap; gap: 8px;
}
.retro-sel-btns { display: flex; gap: 8px; }
.retro-table-scroll { overflow-x: auto; }
.retro-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.retro-table th {
  text-align: left; padding: 8px 10px;
  border-bottom: 2px solid var(--line);
  color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .4px;
}
.retro-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.retro-table tr:last-child td { border-bottom: 0; }
.retro-table tr:hover td { background: #fafcfd; }
.col-check { width: 32px; }
/* Wide enough for the archive tag that sits under the year on both tables. */
.col-year  { width: 96px; }
.retro-done { color: var(--ok, #1f8a4c); font-weight: 800; }

/* Retrolens and LINZ rows share one timeline, so each row says which archive
   it came from — they behave differently once downloaded. */
.src-tag {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: 1px 5px; border-radius: 3px; vertical-align: 1px;
}
.src-retro { background: #eef2f6; color: #4a5b6b; }
.src-linz  { background: #e4efe6; color: #2c6135; }
.fit-exact { font-size: 12px; font-weight: 600; color: var(--ok, #1f8a4c); }
.col-scale { width: 90px; }
.col-score { width: 160px; }
.col-thumb { width: 110px; }
.score-wrap { display: flex; align-items: center; gap: 8px; }
.score-bar  {
  flex: 1; height: 8px; background: #e9eef3;
  border-radius: 4px; overflow: hidden;
}
.score-fill { height: 100%; border-radius: 4px; transition: width .3s; }
.score-num  { font-size: 12px; font-weight: 700; width: 36px; }
.thumb-img  {
  width: 90px; height: 66px;
  object-fit: cover; border-radius: 5px;
  border: 1px solid var(--line);
  cursor: zoom-in; display: block;
}
.retro-actions {
  display: flex; align-items: center; gap: 16px;
  margin-top: 16px; flex-wrap: wrap;
}
.small-note { font-size: 12px; color: var(--muted); }
.retro-log {
  margin-top: 14px;
  background: #1d2733;
  border-radius: 8px;
  padding: 12px 14px;
  font: 12px/1.6 ui-monospace, Menlo, monospace;
  color: #cdd5de;
  max-height: 200px;
  overflow-y: auto;
}
.log-line     { margin: 0; }
.log-line.log-ok  { color: #6fcf8e; }
.log-line.log-err { color: #f08080; }

/* ── Aerials gallery ──────────────────────────────────────────────────────────── */
.retro-gallery { margin-top: 24px; }
.gallery-heading {
  font-size: 14px; font-weight: 700;
  margin-bottom: 12px; color: var(--ink);
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.aerial-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f7f9fb;
  transition: box-shadow .15s;
}
.aerial-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
/* remove cross, shared by the aerials gallery and the saved-fit thumbnails */
.aerial-remove, .georef-thumb-remove {
  position: absolute; top: 5px; right: 5px; z-index: 2;
  width: 22px; height: 22px; padding: 0;
  border: 0; border-radius: 50%;
  background: rgba(24,28,33,.62); color: #fff;
  font-size: 12px; line-height: 22px; text-align: center;
  cursor: pointer; opacity: 0; transition: opacity .12s, background .12s;
}
.aerial-card:hover .aerial-remove,
.georef-thumb:hover .georef-thumb-remove,
.aerial-remove:focus-visible, .georef-thumb-remove:focus-visible { opacity: 1; }
.aerial-remove:hover, .georef-thumb-remove:hover { background: #c0392b; }
.aerial-card img {
  width: 100%; height: 110px;
  object-fit: cover; display: block;
  cursor: zoom-in;
}
.aerial-year {
  font-weight: 700; font-size: 14px;
  padding: 6px 10px 2px;
}
.aerial-meta {
  font-size: 11px; color: var(--muted);
  padding: 0 10px 8px;
}

/* ── Retrolens approximate georeference aid ───────────────────────────────── */
.georef-empty {
  padding: 28px 18px; border: 1px dashed #aab7c3; border-radius: 6px;
  background: #f7f9fb; color: var(--muted); text-align: center;
}
.georef-empty.hidden, #georef-workspace.hidden { display: none; }
.georef-toolbar {
  display: flex; justify-content: space-between; align-items: end;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.georef-toolbar label { min-width: min(360px, 100%); }
.georef-toolbar select { width: 100%; }
.georef-rotate-actions { display: flex; gap: 6px; }
/* toolbar controls swap depending on the image type */
.georef-alt-select.hidden, #georef-apply-uploads.hidden { display: none; }
/* pick which uploads receive the current fit */
/* Above Leaflet, whose controls sit at z-index 1000. */
.apply-fit-dialog { position: fixed; inset: 0; z-index: 3000; background: rgba(18,22,27,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.apply-fit-dialog.hidden { display: none; }
.apply-fit-panel { background: #fff; border-radius: 10px; padding: 20px 22px; width: min(520px, 100%);
  max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 10px 34px rgba(0,0,0,.28); }
.apply-fit-panel h3 { margin: 0 0 4px; font-size: 16px; }
.apply-fit-actions-top { display: flex; gap: 8px; margin: 12px 0 8px; }
.apply-fit-list { overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.apply-fit-row { display: flex; align-items: center; gap: 11px; padding: 9px 11px; cursor: pointer;
  border-bottom: 1px solid var(--line); }
.apply-fit-row:last-child { border-bottom: 0; }
.apply-fit-row:hover { background: #f6f8fa; }
.apply-fit-row img { width: 64px; height: 44px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.apply-fit-row img.missing { background: #f0d9d5; border: 1px dashed #c0796d; font-size: 9px; color: #8a3527; }
.apply-fit-row span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.apply-fit-row small { color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
.apply-fit-saved { color: #8a6414; }
.apply-fit-mismatch { margin: 6px 0 0; font-size: 12px; color: var(--warn); line-height: 1.4; }
.apply-fit-mismatch:empty { display: none; }
.apply-fit-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.georef-rotate-actions .icon-btn {
  width: 38px; height: 38px; padding: 0; font-size: 21px; line-height: 1;
}
.georef-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 270px;
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  background: #fff;
}
#georef-map { height: 540px; min-height: 360px; background: #c9d1d9; }
.georef-controls {
  padding: 18px; border-left: 1px solid var(--line); background: #f7f9fb;
}
.georef-controls > label { display: block; margin-bottom: 20px; }
/* Number box and readout on top, slider full width beneath: the extra travel
   makes fine adjustment much easier than sharing one row. */
.georef-range-row, .hist-range-row, .fig-range-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr);
  align-items: center; gap: 8px 10px; margin-top: 7px;
}
.georef-range-row output, .hist-range-row output, .fig-range-row output {
  color: var(--accent-d); font-size: 12px; font-weight: 700; text-align: right;
}
.georef-range-row input[type="range"],
.hist-range-row input[type="range"],
.fig-range-row input[type="range"] { grid-column: 1 / -1; width: 100%; }

/* Windows 98 slider: sunken track, raised thumb. */
.georef-range-row input[type="range"],
.hist-range-row input[type="range"],
.fig-range-row input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 22px; margin: 0; background: transparent; cursor: pointer;
}
.georef-range-row input[type="range"]::-webkit-slider-runnable-track,
.hist-range-row input[type="range"]::-webkit-slider-runnable-track,
.fig-range-row input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; background: #a8a8a8;
  border: 2px solid;
  border-color: var(--w98-shadow) var(--w98-light) var(--w98-light) var(--w98-shadow);
}
.georef-range-row input[type="range"]::-webkit-slider-thumb,
.hist-range-row input[type="range"]::-webkit-slider-thumb,
.fig-range-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 22px; margin-top: -10px;
  background: var(--w98-face); border-radius: 0;
  border: 2px solid;
  border-color: var(--w98-light) var(--w98-shadow) var(--w98-shadow) var(--w98-light);
}
.georef-range-row input[type="range"]:active::-webkit-slider-thumb,
.hist-range-row input[type="range"]:active::-webkit-slider-thumb,
.fig-range-row input[type="range"]:active::-webkit-slider-thumb {
  border-color: var(--w98-shadow) var(--w98-light) var(--w98-light) var(--w98-shadow);
}
.georef-range-row input[type="range"]::-moz-range-track,
.hist-range-row input[type="range"]::-moz-range-track,
.fig-range-row input[type="range"]::-moz-range-track {
  height: 6px; background: #a8a8a8;
  border: 2px solid;
  border-color: var(--w98-shadow) var(--w98-light) var(--w98-light) var(--w98-shadow);
}
.georef-range-row input[type="range"]::-moz-range-thumb,
.hist-range-row input[type="range"]::-moz-range-thumb,
.fig-range-row input[type="range"]::-moz-range-thumb {
  width: 12px; height: 20px; border-radius: 0;
  background: var(--w98-face);
  border: 2px solid;
  border-color: var(--w98-light) var(--w98-shadow) var(--w98-shadow) var(--w98-light);
}
.georef-details {
  display: grid; grid-template-columns: 82px minmax(0, 1fr);
  gap: 7px 10px; margin: 24px 0 0; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 12px;
}
.georef-details dt { color: var(--muted); font-weight: 600; }
.georef-details dd { margin: 0; overflow-wrap: anywhere; }
.georef-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.georef-image-layer { position: absolute; pointer-events: none; }
#georef-map.georef-panning { cursor: grabbing; }
#georef-map.georef-panning .georef-image-layer img { cursor: grabbing; }
/* the image file is gone from the server and could not be recovered */
.georef-image-layer.georef-image-missing {
  border: 3px dashed #c0392b; background: rgba(192, 57, 43, .12);
}
/* A wide-angle frame can scale to tens of thousands of CSS pixels. A filter or
   will-change on an element that size forces the browser to rasterise the whole
   thing every frame, which is what made large images stutter — so neither is
   used here. */
.georef-image-layer img {
  display: block; width: 100%; height: 100%; transform-origin: 50% 50%;
  object-fit: fill;
}
.georef-drag-hint { margin: 0 0 14px; }
.georef-danger { color: #b42318; border-color: #f0c2bd; }
.georef-danger:hover { background: #b42318; border-color: #b42318; color: #fff; }
.georef-upload-top { margin-top: 0; margin-bottom: 16px; padding-top: 0; border-top: 0; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
/* saved fitted images */
.georef-saved { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.georef-saved.hidden { display: none; }
.georef-saved-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.georef-saved-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.georef-thumb {
  position: relative; margin: 0; border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; background: #f7f9fb; cursor: pointer; transition: box-shadow .15s;
}
.georef-thumb:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.georef-thumb img { display: block; width: 100%; height: 96px; object-fit: cover; }
.georef-thumb figcaption { font-size: 12px; font-weight: 600; padding: 6px 9px 8px; }
/* Wide enough to read a decimal place without truncating. */
.georef-num {
  width: 92px; padding: 6px 8px; font: inherit; font-size: 13px;
  background: #fff; border: 2px solid; border-radius: 0;
  border-color: var(--w98-shadow) var(--w98-light) var(--w98-light) var(--w98-shadow);
}
.save-warning { position: fixed; top: var(--topbar-h, 48px); left: 0; right: 0; z-index: 90;
  background: #fff4e5; border-bottom: 1px solid #f0c98a; color: #8a5a10;
  font-size: 13px; padding: 9px 18px; }
.save-warning.hidden { display: none; }
.georef-alt-select { max-width: 260px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; font: inherit; font-size: 12px; color: var(--ink); }
.georef-alt-select:disabled { color: var(--muted); background: #f4f6f8; }
/* ── Image Review step ── */
.review-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.review-viewbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.review-label-input { flex: 1; min-width: 220px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 13px; }
.review-colour-pair { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.review-colour-pair input { width: 38px; height: 28px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
#review-canvas { cursor: crosshair; }
.review-zoom-group { display: inline-flex; align-items: center; gap: 6px; }
.review-zoom-group output {
  min-width: 44px; text-align: center; font-size: 12px; font-weight: 700; color: var(--accent-d);
}
.review-title { font-size: 15px; }
.review-title b { font-size: 17px; }
.review-stage { background: #2b3138; border: 1px solid var(--line); border-radius: 8px; padding: 10px; text-align: center; }
#review-canvas { max-width: 100%; height: auto; border-radius: 4px; }
.georef-upload-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
}
.georef-upload-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.georef-upload-label input { display: block; margin-top: 6px; font-size: 12px; }
@media (max-width: 850px) {
  .georef-layout { grid-template-columns: 1fr; }
  #georef-map { height: 400px; }
  .georef-controls { border-left: 0; border-top: 1px solid var(--line); }
}

/* ── Page 4: Site Context ────────────────────────────────────────────────────── */
.ctx-block {
  border-top: 1px solid var(--line);
  padding-top: 22px; margin-top: 22px;
}
.ctx-block:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.ctx-block-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 14px;
}
.ctx-block-title { font-size: 16px; font-weight: 700; margin: 0; }
.ctx-block-actions { display: flex; align-items: center; gap: 10px; }

/* ── Page 4: LINZ parcels ────────────────────────────────────────────────────── */
.linz-section {
  margin-top: 24px; border-top: 1px solid var(--line);
  padding-top: 20px;
}
.linz-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 10px;
}
.linz-key-wrap { display: flex; gap: 8px; align-items: center; }
.linz-key-wrap input { width: 240px; font-size: 12px; }
.linz-results { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.parcel-card {
  border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; background: #fff;
}
.parcel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; background: #f7f9fb; border-bottom: 1px solid var(--line);
}
.parcel-num        { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.parcel-appellation { font-weight: 700; font-size: 14px; flex: 1; }
.parcel-toggle     { flex-direction: row; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; }
.parcel-badge       { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.parcel-badge.primary   { background: #dbeafe; color: #1d4ed8; }
.parcel-badge.intersect { background: #fef9c3; color: #92400e; }
.parcel-table      { width: 100%; border-collapse: collapse; font-size: 13px; }
.parcel-table td   { padding: 6px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.parcel-table tr:last-child td { border-bottom: 0; }
.pk                { color: var(--muted); font-weight: 600; width: 140px; white-space: nowrap; }
.pk-check          { width: 28px; padding: 4px 6px; text-align: center; }
.narrative-wrap    { margin-top: 14px; }
.narrative-label   { font-size: 13px; font-weight: 700; color: var(--ink); gap: 6px; }
.narrative-ta {
  width: 100%; font: 13px/1.6 inherit;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px;
  color: var(--ink); resize: vertical; min-height: 90px;
  margin-top: 6px;
}
.narrative-ta:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,111,84,.1); }

/* ── Page 2: Planning & Zoning ───────────────────────────────────────────────── */
.planning-section {
  margin-top: 24px; border-top: 1px solid var(--line); padding-top: 20px;
}
.planning-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.planning-title { font-weight: 700; font-size: 14px; }
.rest-url-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.rest-url-input { flex: 1; min-width: 200px; font-size: 12px; }
.buffer-wrap label { font-size: 12px; font-weight: 600; color: var(--muted); }
.buffer-wrap input { padding: 6px 8px; font: inherit; border: 1px solid var(--line); border-radius: 6px; }
.planning-data { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.planning-map-panel { margin-bottom: 6px; }
.planning-map-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 9px;
}
.planning-map-actions { display:flex; align-items:center; flex-wrap:wrap; gap:7px; }
.map-orientation-seg .seg-btn { padding:5px 8px; font-size:11px; }
.planning-map-wrap, .wells-map-wrap { position: relative; min-width: 0; min-height: 0; }
.planning-map {
  width: 100%; height: 430px; border: 1px solid var(--line); border-radius: 7px;
  background: #e5e9ed;
}
.map-brand-logo {
  position: absolute; left: 12px; bottom: 12px; z-index: 500;
  width: min(150px, 24%); max-height: 94px; object-fit: contain; object-position: left bottom;
  pointer-events: none; filter: drop-shadow(0 1px 3px rgba(0,0,0,.5));
}
#planning-map-note { margin: 7px 0 0; }
.planning-map-legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 7px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.planning-map-legend > div { display: flex; align-items: center; gap: 6px; min-width: 0; }
.planning-map-legend img, .planning-map-legend span {
  width: 18px; height: 18px; flex: 0 0 18px; object-fit: contain; border: 1px solid rgba(15,23,42,.18);
}
.planning-map-legend b { font-size: 11px; font-weight: 600; color: var(--text); }
.planning-map-legend-neutral { background: #fff; }
.zone-section  { }
.zone-section-head {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted); margin-bottom: 8px;
}
.zone-detail {
  border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; margin-bottom: 8px;
}
.zone-detail summary {
  padding: 9px 14px; background: #f7f9fb;
  font-weight: 700; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid transparent;
}
.zone-detail[open] summary { border-bottom-color: var(--line); }
.zone-table { background: #fff; }
.zone-chip {
  display: inline-block; font-size: 12px; font-weight: 600;
  background: #e8f0f8; color: #1d4370; border-radius: 12px;
  padding: 2px 10px; margin: 2px 3px 2px 0; white-space: nowrap;
}
.zone-section { margin-bottom: 14px; }
.narrative-pair { margin-top: 20px; display: flex; flex-direction: column; gap: 16px; }

/* ── Lightbox ─────────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center;
  gap: 0;
}
.lightbox.hidden { display: none; }
.lb-inner {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  max-width: calc(100vw - 120px);
  max-height: 100vh;
  gap: 12px;
}
.lb-img {
  max-width: 100%; max-height: calc(100vh - 80px);
  object-fit: contain; border-radius: 4px;
  box-shadow: 0 4px 32px rgba(0,0,0,.5);
}
.lb-caption {
  color: rgba(255,255,255,.8);
  font-size: 13px; text-align: center;
}
.lb-close {
  position: fixed; top: 18px; right: 22px;
  background: rgba(255,255,255,.12); color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%; width: 36px; height: 36px;
  font-size: 16px; cursor: pointer; z-index: 1001;
  display: flex; align-items: center; justify-content: center;
}
.lb-close:hover { background: rgba(255,255,255,.22); }
.lb-nav {
  background: rgba(255,255,255,.1); color: #fff;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 50%; width: 48px; height: 48px;
  font-size: 28px; font-weight: 300;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.lb-nav:hover { background: rgba(255,255,255,.22); }
.lb-prev { margin-right: 12px; }
.lb-next { margin-left:  12px; }

/* ── Page 6: Environment ──────────────────────────────────────────────────────── */
.env-results { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.env-card {
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; overflow: hidden;
}
.env-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: #fafcfd;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap; gap: 10px;
}
.env-card-title {
  display: flex; align-items: center; gap: 12px; flex: 1;
}
.env-icon { display: none; }
.env-name { font-weight: 700; font-size: 15px; }
.env-source { font-size: 11px; color: var(--muted); margin-top: 1px; }
.env-source-link { font-size: 11px; color: var(--accent); text-decoration: none; margin-left: 4px; }
.env-source-link:hover { text-decoration: underline; }
.env-badge {
  font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px;
  white-space: nowrap;
}
.env-badge.ok     { background: #e8f5ee; color: #1f6f54; }
.env-badge.warn   { background: #fdf0e3; color: #b35900; }
.env-badge.manual { background: #eef0f3; color: #6b7888; }
.env-toggle {
  flex-direction: row; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--ink);
  cursor: pointer;
}
.env-card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.env-text {
  width: 100%; font: 13px/1.55 inherit;
  padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 7px;
  color: var(--ink); resize: vertical; min-height: 80px;
}
.env-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,111,84,.1); }
.env-error { color: var(--err); font-size: 13px; margin: 0; }
.env-raw { font-size: 12px; color: var(--muted); }
.env-raw summary { cursor: pointer; margin-bottom: 6px; }
.env-raw pre {
  background: #f7f9fb; border: 1px solid var(--line);
  border-radius: 6px; padding: 10px 12px;
  font: 11px/1.5 ui-monospace, Menlo, monospace;
  max-height: 200px; overflow: auto; margin: 0;
  white-space: pre-wrap; word-break: break-all;
}

/* ── Wells map panel (embedded in hydrogeology env-card) ─────────────────────── */
.wells-panel {
  display: grid;
  grid-template-columns: 1fr 228px;
  gap: 12px;
  margin-top: 14px;
  height: 380px;
}
.wells-map {
  width: 100%; height: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  min-height: 200px;
}
.wells-map-wrap { height: 380px; }
.wells-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}
.wl-block {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 10px;
}
.wl-block:last-of-type { border-bottom: none; margin-bottom: 4px; }
.wl-label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 3px; font-weight: 700; }
.wl-val   { font-size: 20px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.wl-sub   { font-size: 11px; color: var(--muted); margin-top: 1px; }
.wells-filter-btns { display: flex; gap: 5px; }
.wells-filter-btn {
  flex: 1; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px;
  font-size: 11px; font-weight: 600; cursor: pointer; background: #fff; color: var(--ink);
}
.wells-filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.wl-legend { display: flex; flex-direction: column; gap: 4px; }
.wl-row { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.wl-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.wl-use { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-row b { font-weight: 700; min-width: 18px; text-align: right; }
.wells-csv-btn {
  margin-top: auto; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer;
  background: #fff; color: var(--ink); width: 100%;
}
.wells-csv-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.wells-download-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: auto;
}
.wells-download-actions .wells-csv-btn {
  margin-top: 0; padding-inline: 4px; font-size: 10.5px; white-space: nowrap;
}
.wells-download-actions .wells-csv-btn:disabled { opacity: .65; cursor: wait; }
.wells-figure-orientation .map-orientation-seg { display:flex; width:100%; }
.wells-figure-orientation .seg-btn { flex:1; padding-inline:4px; }

.site-summary-table-wrap {
  overflow-x: auto; border: 1px solid var(--line); border-radius: 7px;
}
.site-summary-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.site-summary-table th,
.site-summary-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.site-summary-table tr:last-child th,
.site-summary-table tr:last-child td { border-bottom: none; }
.site-summary-table th {
  width: 210px; background: #f7f9fb; color: var(--ink); text-align: left; font-weight: 700;
}
.site-summary-table td { white-space: pre-line; color: var(--ink); }
.site-summary-table td.is-empty { color: var(--muted); }
.site-summary-copy-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.site-summary-copy-row .status { margin: 0; }

/* ── Page 7: Report ───────────────────────────────────────────────────────────── */
.summary-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  background: #f7f9fb; border: 1px solid var(--line);
  border-radius: 8px; padding: 16px; margin-bottom: 24px;
}
.summary-item {
  display: flex; flex-direction: column; gap: 2px;
}
.summary-item.span2 { grid-column: span 2; }
.sum-label {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted); font-weight: 700;
}
.report-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-bottom: 24px;
}
.report-action-card {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 22px; background: #fafcfd;
  display: flex; flex-direction: column; gap: 10px;
}
.report-action-card h3 { margin: 0; font-size: 16px; }
.report-action-card .muted { margin: 0; flex: 1; }
.rac-icon { font-size: 28px; }
.divider  { border: 0; border-top: 1px solid var(--line); margin: 4px 0 20px; }

/* ── Page footer nav ─────────────────────────────────────────────────────────── */
.page-footer {
  position: sticky; bottom: 0;
  height: var(--footer-h);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 50;
  box-shadow: 0 -2px 8px rgba(0,0,0,.05);
  flex-shrink: 0;
}
.page-label {
  font-size: 13px; color: var(--muted); font-weight: 600;
}
.nav-btn { min-width: 100px; }

/* ── Responsive ───────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .app-topbar { gap: 8px; padding: 0 10px; }
  .tb-hail-logo { width: 120px; }
  .topbar-breadcrumb { min-width: 0; gap: 4px; font-size: 0.7rem; }
  .topbar-breadcrumb > :nth-child(3),
  .topbar-breadcrumb > :nth-child(4) { display: none; }
  .bc-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .job-badge { display: none; }
  .app-body { display: block; height: calc(100vh - var(--topbar-h)); }
  .app-sidebar {
    top: var(--topbar-h); right: 0; bottom: auto; width: 100%; height: 48px;
    overflow-x: auto; overflow-y: hidden; z-index: 90;
  }
  .stepper { min-width: max-content; height: 48px; padding: 0 8px; display: flex; align-items: stretch; }
  .step { min-width: 40px; padding: 0 9px; justify-content: center; border-left: 0; border-bottom: 3px solid transparent; }
  .step.active { border-left-color: transparent; border-bottom-color: #3dba78; }
  .app-main { width: 100%; height: 100%; margin-left: 0; padding-top: 48px; }
  #pages { padding: 16px 12px 8px; }
  .page-card { padding: 20px 16px; border-radius: 8px; }
  .page-footer { height: 54px; padding: 0 12px; }
  .nav-btn { min-width: 82px; padding: 8px 12px; }
  .split       { grid-template-columns: 1fr; }
  .grid2       { grid-template-columns: 1fr; }
  .span2       { grid-column: span 1; }
  .report-actions { grid-template-columns: 1fr; }
  .summary-grid   { grid-template-columns: 1fr; }
  .summary-item.span2 { grid-column: span 1; }
  .step-label  { display: none; }
  .step-line   { min-width: 12px; }
  #map         { height: 240px; }
  #parcel-map  { height: 300px; }
  .parcel-selector { padding: 13px; }
  .parcel-search-row { align-items: stretch; }
  .planning-map { height: 340px; }
  .wells-panel { grid-template-columns: 1fr; height: auto; }
  .wells-map-wrap { height: 330px; }
}

/* ── Page 6: Location Figures ─────────────────────────────────────────────── */
.fig-toolbar { display:flex; justify-content:space-between; align-items:center; gap:12px; margin:4px 0 12px; flex-wrap:wrap; }
.seg { display:inline-flex; background:#eef2f5; border:1px solid var(--line); border-radius:8px; padding:3px; gap:3px; }
.seg-btn { border:0; background:transparent; color:var(--muted); font-weight:600; font-size:13px; padding:6px 18px; border-radius:6px; cursor:pointer; }
.seg-btn.active { background:var(--accent); color:#fff; }
.fig-tool-actions { display:flex; gap:6px; }

.fig-stage { position:relative; width:100%; aspect-ratio:1280/900; max-height:64vh; border:1px solid var(--line); border-radius:10px; overflow:hidden; background:#c9d1d9; }
.fig-stage[data-orientation="portrait"] { width:min(100%, calc(64vh * 0.703125)); aspect-ratio:900/1280; margin-inline:auto; }
#fig-map { position:absolute; inset:0; }

.fig-inset { position:absolute; top:12px; left:12px; width:30%; height:36%; border:1px solid rgba(0,0,0,.25); background:#e8edf1; overflow:hidden; box-shadow:0 1px 4px rgba(0,0,0,.25); z-index:500; }
.fig-inset.hidden { display:none; }
#fig-overview { position:absolute; inset:0; }
.fig-locator { position:absolute; top:50%; left:50%; width:40%; height:30%; transform:translate(-50%,-50%); border:3px solid #be1e2d; background:rgba(190,30,45,.12); box-shadow:0 0 0 2px rgba(255,255,255,.9), 0 1px 4px rgba(0,0,0,.4); pointer-events:none; }
.fig-locator::before { content:""; position:absolute; left:50%; top:-12px; transform:translateX(-50%); width:0; height:0; border-left:5px solid transparent; border-right:5px solid transparent; border-top:10px solid #be1e2d; }
.fig-site-target { position:absolute; z-index:600; left:50%; top:50%; width:16px; height:16px; transform:translate(-50%,-50%); border:4px solid #fff; border-radius:50%; background:#be1e2d; box-shadow:0 1px 5px rgba(0,0,0,.65); pointer-events:none; }
.fig-site-target span { position:absolute; left:17px; top:50%; transform:translateY(-50%); padding:2px 6px; border:1px solid #be1e2d; border-radius:4px; background:rgba(255,255,255,.97); color:#8f1522; font:700 10px/1.3 Arial,sans-serif; letter-spacing:.04em; box-shadow:0 1px 3px rgba(0,0,0,.3); }

.fig-logo { position:absolute; bottom:14px; left:14px; width:15%; max-width:150px; height:auto; pointer-events:none; filter:drop-shadow(0 1px 2px rgba(0,0,0,.55)); z-index:500; }
.fig-north { position:absolute; top:10px; right:14px; font:700 16px Arial, sans-serif; text-align:center; z-index:500; pointer-events:none; }
.fig-north-tri { display:block; width:0; height:0; margin:2px auto 0; border-left:5px solid transparent; border-right:5px solid transparent; border-bottom:12px solid currentColor; }
.fig-legend { position:absolute; bottom:14px; left:50%; transform:translateX(-50%); display:flex; align-items:center; gap:8px; background:rgba(255,255,255,.95); border:1px solid rgba(0,0,0,.1); border-radius:4px; padding:5px 10px; font-size:12px; color:#111; box-shadow:0 1px 3px rgba(0,0,0,.2); z-index:500; pointer-events:none; }
.fig-legend-sw { width:22px; height:14px; border:2px solid #be1e2d; border-radius:2px; }

.fig-scale { position:absolute; bottom:16px; right:18px; height:24px; z-index:500; pointer-events:none; }
.fig-scale .lbls { position:relative; height:13px; font-size:11px; }
.fig-scale .lbls span { position:absolute; transform:translateX(-50%); white-space:nowrap; }
.fig-scale .lbls span:first-child { transform:none; }
.fig-scale .lbls span:last-child { transform:translateX(-100%); }
.fig-scale .ln { position:relative; height:8px; border:2px solid currentColor; border-top:0; }
.fig-scale .ln .t { position:absolute; top:0; width:0; height:8px; border-left:1px solid currentColor; }

.fig-stage:not(.aerial-ink) .fig-north, .fig-stage:not(.aerial-ink) .fig-scale { color:var(--ink); text-shadow:0 0 3px rgba(255,255,255,.95); }
.fig-stage.aerial-ink .fig-north, .fig-stage.aerial-ink .fig-scale { color:#fff; text-shadow:0 1px 2px rgba(0,0,0,.6); }

.fig-advanced { margin-top:14px; }
.fig-advanced summary { cursor:pointer; font-weight:600; color:var(--accent); font-size:14px; }
.fig-advanced .grid2 { margin-top:12px; }

/* Per-figure imagery and scale. Every control here redraws the figures below. */
.fig-sources { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin-top:14px; }
.fig-source { border:1px solid var(--line); border-radius:8px; padding:10px 13px 13px; margin:0; min-width:0; }
.fig-source legend { font-size:12px; font-weight:700; color:var(--accent-d); padding:0 5px; }
.fig-source label { margin-top:8px; font-size:12px; }
.fig-source select { width:100%; }
.fig-source-note { margin:6px 0 0; font-size:11.5px; color:var(--warn); line-height:1.35; }
.fig-source-note:empty { display:none; }
.fig-range-row { display:grid; grid-template-columns:minmax(0,1fr); gap:4px; margin-top:5px; }
.fig-range-row output { color:var(--accent-d); font-size:12px; font-weight:700; text-align:left; }
@media (max-width:900px){ .fig-sources { grid-template-columns:1fr; } }
.fig-build-row { display:flex; align-items:center; gap:16px; margin-top:16px; }
.fig-outputs { margin-top:16px; display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.fig-outputs.hidden { display:none; }
.fig-output { margin:0; }
.fig-output figcaption { font-size:13px; font-weight:600; margin-bottom:6px; color:var(--ink); }
.fig-output img { width:100%; display:block; border:1px solid var(--line); border-radius:6px; }
.fig-output .btnlink.small { margin-top:8px; font-size:12px; padding:6px 12px; }
@media (max-width:760px){ .fig-outputs{ grid-template-columns:1fr; } }

/* ── Page 9: Historical Aerial Appendix ──────────────────────────────────── */
.hist-drop { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:150px; padding:24px; border:2px dashed #aab7c3; border-radius:10px; background:#f7fafc; cursor:pointer; text-align:center; }
.hist-drop:hover { border-color:var(--accent); background:#f1f8f5; }
.hist-drop-title { color:var(--accent-d); font-size:17px; font-weight:700; }
.hist-drop-sub { color:var(--muted); font-size:12px; margin-top:5px; }
.hist-drop input { margin-top:14px; max-width:100%; }
.hist-file-list { margin-top:16px; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
.hist-file-row { display:grid; grid-template-columns:minmax(220px,1fr) 130px minmax(200px,1fr) auto; gap:14px; align-items:center; padding:10px 12px; border-bottom:1px solid var(--line); }
.hist-remove { padding:4px 9px; line-height:1; }
.hist-file-row:last-child { border-bottom:0; }
.hist-file-row.has-error { background:#fff4f3; }
.hist-file-name { font-weight:600; overflow-wrap:anywhere; }
.hist-file-row label { display:flex; align-items:center; gap:7px; font-size:12px; }
.hist-file-row input { width:82px; padding:6px; }
.hist-orientation-row { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:16px; color:var(--muted); font-size:12px; font-weight:700; }
.hist-georef { color:var(--muted); font-size:12px; overflow-wrap:anywhere; }
.has-error .hist-georef { color:#b42318; }
.hist-build-row { display:flex; align-items:center; gap:16px; margin-top:18px; }
.hist-outputs { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:20px; }
.hist-output { margin:0; }
.hist-output figcaption { font-size:14px; font-weight:700; margin-bottom:6px; }
.hist-output img { display:block; width:100%; border:1px solid var(--line); border-radius:6px; }
.hist-output .btnlink { display:inline-block; margin-top:7px; }

/* Configure appendix — settings applied to every figure in the appendix. */
.hist-config-summary { margin:8px 0 0; color:var(--muted); font-size:12px; }
.hist-config-summary.is-set { color:var(--accent-d); font-weight:700; }
.hist-config-panel { width:min(680px,100%); overflow-y:auto; }
.hist-config-panel > .muted { margin:0 0 4px; font-size:12px; }
.hist-config-panel .hist-orientation-row { margin-top:14px; }
.hist-zoom-label { display:block; margin-top:18px; color:var(--muted); font-size:12px; font-weight:700; }
.hist-preview-wrap { margin-top:16px; }
.hist-preview { display:block; margin:0 auto; max-width:100%; max-height:44vh;
  width:auto; height:auto; background:#798086;
  border:1px solid var(--line); border-radius:6px; }
.hist-preview-note { margin:7px 0 0; font-size:11.5px; overflow-wrap:anywhere; }
@media (max-width:800px){ .hist-file-row{grid-template-columns:1fr}.hist-outputs{grid-template-columns:1fr} }

/* ── Page 3: Previous Projects ────────────────────────────────────────────── */
.prev-controls { display:flex; gap:22px; align-items:flex-start; flex-wrap:wrap; margin-bottom:16px; }
.prev-field { display:flex; flex-direction:column; gap:6px; font-size:13px; color:var(--muted); font-weight:600; }
.prev-field select { font:inherit; padding:8px 10px; border:1px solid var(--line); border-radius:7px; background:#fff; color:var(--ink); }
.prev-types { flex:1; min-width:280px; }
.prev-types-head { display:flex; justify-content:space-between; align-items:center; gap:10px; }
.prev-types-btns { display:flex; gap:6px; }
.prev-type-chips { display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
.prev-chip { display:inline-flex; align-items:center; gap:6px; font-size:12.5px; font-weight:500; color:var(--ink);
  background:#eef2f5; border:1px solid var(--line); border-radius:16px; padding:5px 11px; cursor:pointer; }
.prev-chip input { margin:0; }
.prev-chip-n { color:var(--muted); font-size:11px; }
.prev-results { margin-top:14px; overflow:auto; }
.prev-table { width:100%; border-collapse:collapse; font-size:13px; }
.prev-table th, .prev-table td { text-align:left; padding:8px 10px; border-bottom:1px solid var(--line); vertical-align:top; }
.prev-table th { color:var(--muted); font-weight:600; position:sticky; top:0; background:#fff; }
.prev-table tr:hover td { background:#fafcfd; }
.prev-table td:nth-child(3) { white-space:nowrap; color:var(--warn); font-weight:600; }

/* ── Page 9: embedded CSM builder ─────────────────────────────────────────── */
.csm-embed-wrap { height: 74vh; min-height: 520px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
#csm-frame { width: 100%; height: 100%; border: 0; display: block; }

/* ── Retrolens: per-year frame picker ─────────────────────────────────────── */
.col-frame { min-width: 220px; }
.retro-frame { font: inherit; font-size: 12.5px; padding: 5px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: var(--ink); max-width: 260px; }
.frame-why { font-size: 11.5px; margin-top: 4px; line-height: 1.35; }


/* ── Protected areas map modal ──────────────────────────────────────────── */
.pa-modal {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.pa-modal.hidden { display: none; }
.pa-modal-inner {
  background: #fff; border-radius: 10px; overflow: hidden;
  width: min(920px, 100%); max-height: 100%;
  display: flex; flex-direction: column;
  box-shadow: 0 18px 48px rgba(0,0,0,.28);
}
.pa-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; border-bottom: 1px solid #e2e8f0;
}
#protected-map { height: min(60vh, 520px); width: 100%; }
.pa-modal-note { margin: 0; padding: 10px 16px; font-size: .78rem; }
.env-map-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }


/* ── HAIL listing block (Site Context, under 2.3) ───────────────────────── */
.hail-block {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fbfcfd;
}
.hail-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.hail-title { margin: 0; font-size: 0.95rem; font-weight: 600; }
.hail-summary { margin: 10px 0 0; line-height: 1.5; }
/* A listed site is the finding the whole report turns on — it should not read
   like the muted "not listed" case. */
.hail-summary.listed {
  color: #7c2d12;
  background: #fff7ed;
  border-left: 3px solid #c2410c;
  padding: 8px 12px;
  border-radius: 4px;
}
#hail-figure-status:empty { display: none; }


/* ── Collapsible LINZ parcels (2.1) ─────────────────────────────────────── */
details.parcel-card > summary.parcel-head {
  cursor: pointer;
  list-style: none;
  align-items: center;
}
details.parcel-card > summary.parcel-head::-webkit-details-marker { display: none; }
/* A caret of our own, so the row still reads as expandable with the native
   marker hidden. */
details.parcel-card > summary.parcel-head::after {
  content: "be";
  margin-left: auto;
  color: #94a3b8;
  transition: transform .15s;
}
details.parcel-card[open] > summary.parcel-head::after { transform: rotate(180deg); }
.parcel-bulk {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
}
