:root {
  --bg: #f7f7f5;
  --bg-card: #ffffff;
  --fg: #1a1a1a;
  --fg-muted: #666;
  --fg-faint: #999;
  --border: #e0e0dd;
  --border-strong: #cfcfcb;
  --accent: #1f3a6e;
  --accent-fg: #ffffff;
  --good: #1f6e3a;
  --warn: #a05a1f;
  --bad: #a01f3a;
  --radius: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.4;
}

header {
  padding: 18px 32px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.brand {
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 13px;
  color: var(--accent);
}
.sub {
  color: var(--fg-muted);
  font-size: 12.5px;
  margin-top: 2px;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 32px 48px;
}

section.search { margin-bottom: 24px; }
section.search label {
  display: block;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 6px;
}
.input-row {
  display: flex;
  gap: 8px;
}
.input-row input {
  flex: 1;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-card);
}
.input-row input:focus {
  outline: none;
  border-color: var(--accent);
}
.autocomplete-wrap {
  position: relative;
  flex: 1;
}
.autocomplete-wrap input {
  width: 100%;
}
ul.suggestions {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  max-height: 280px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
ul.suggestions li {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13.5px;
  border-bottom: 1px solid #f0f0ed;
}
ul.suggestions li:last-child { border-bottom: none; }
ul.suggestions li:hover,
ul.suggestions li.active {
  background: #eef3fb;
}
ul.suggestions li .ezi {
  font-weight: 500;
}
ul.suggestions li .meta {
  color: var(--fg-faint);
  font-size: 11.5px;
  margin-top: 1px;
}
.parcel-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.parcel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.vicplan-btn {
  display: inline-block;
  background: var(--bg);
  color: var(--accent);
  text-decoration: none;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
}
.vicplan-btn:hover {
  background: #eef3fb;
  border-color: var(--accent);
}
.vicplan-btn.danger { color: var(--bad); }
.vicplan-btn.danger:hover { background: #fbecec; border-color: var(--bad); }

.aggregate-card {
  background: linear-gradient(180deg, #eef3fb 0%, #f6f8fb 100%);
  border: 1px solid #c9d6ec;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-top: 32px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.aggregate-card.hidden { display: none; }
.aggregate-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.aggregate-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.aggregate-head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.aggregate-parcel-count {
  font-size: 12px;
  color: var(--fg-muted);
  font-weight: 600;
}
.aggregate-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #c9d6ec;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}
.aggregate-footer .caveat {
  font-size: 11.5px;
  color: var(--fg-muted);
  line-height: 1.5;
  max-width: 60ch;
}
.import-btn {
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.import-btn:hover { filter: brightness(1.1); }
.import-btn.success { background: var(--good); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  animation: toast-in 200ms ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Vicplan modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 25, 0.55);
}
.modal-panel {
  position: relative;
  width: 95vw;
  height: 90vh;
  max-width: 1400px;
  background: var(--bg-card);
  border-radius: 6px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.modal-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--fg);
}
.modal-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.modal-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
}
.modal-link:hover { text-decoration: underline; }
.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--fg-muted);
  padding: 0 6px;
}
.modal-close:hover { color: var(--fg); }
.modal-body {
  position: relative;
  flex: 1;
  background: var(--bg);
}
.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
#map-container {
  position: absolute;
  inset: 0;
  background: #dde1e3;
}
.map-legend {
  position: absolute;
  right: 16px;
  bottom: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  max-width: min(360px, calc(100vw - 40px));
  max-height: min(420px, calc(100vh - 160px));
  overflow: auto;
  z-index: 500;
}
.map-legend .legend-title {
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10.5px;
  color: var(--fg-muted);
}
.map-legend .legend-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 7px 0;
  font-size: 12px;
  cursor: pointer;
}
.map-legend .legend-row input {
  margin: 2px 0 0;
  accent-color: var(--accent);
}
.map-legend .legend-row.muted {
  color: var(--fg-muted);
}
.map-legend .swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.2);
  flex: 0 0 auto;
  margin-top: 2px;
}
.map-legend .legend-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.map-legend .legend-main {
  font-weight: 650;
  color: var(--fg);
}
.map-legend .legend-meta {
  color: var(--fg-muted);
  font-size: 11px;
  line-height: 1.25;
}
.map-legend .legend-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}
.basemap-toggle {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.basemap-toggle button {
  background: var(--bg-card);
  border: none;
  padding: 6px 11px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--fg-muted);
  font-family: inherit;
}
.basemap-toggle button.active {
  background: var(--accent);
  color: var(--accent-fg);
}
.input-row button {
  padding: 10px 20px;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.input-row button:hover { filter: brightness(1.1); }
.input-row button:disabled { opacity: 0.6; cursor: wait; }
.hint { font-size: 12px; color: var(--fg-faint); margin-top: 6px; }
.hint code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: #eee;
  padding: 1px 4px;
  border-radius: 2px;
}

#status {
  margin-top: 10px;
  font-size: 13px;
  color: var(--fg-muted);
  min-height: 18px;
}
#status.error { color: var(--bad); }
#status.loading::after { content: ' …'; }

.hidden { display: none !important; }

.parcel-block {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px dashed var(--border);
  overflow-x: auto;
}
.parcel-block:last-child { border-bottom: none; }
.parcel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
}
.parcel-head { margin-bottom: 16px; }
.parcel-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--fg);
}
.parcel-subtitle {
  font-size: 12.5px;
  color: var(--fg-muted);
  margin-top: 3px;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.metric {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.metric.primary {
  background: #eef3fb;
  border-color: #c9d6ec;
}
.metric .label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 4px;
}
.metric .value {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.metric .value.warn { color: var(--warn); }
.zoning {
  font-size: 13px;
  color: var(--fg);
  margin-top: 8px;
}
.zoning .z-tag {
  display: inline-block;
  background: #f0ecdd;
  color: #6e5b1f;
  border: 1px solid #d9d2b6;
  padding: 2px 8px;
  border-radius: 2px;
  font-weight: 600;
  margin-right: 6px;
}
.zoning .topo-line {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--fg-muted);
}
.zoning .pale {
  color: var(--fg-faint);
  font-style: italic;
}

#smoke-test-warning {
  margin-top: 12px;
  padding: 8px 12px;
  background: #fcf2ec;
  border: 1px solid #e8c6a8;
  color: var(--warn);
  border-radius: var(--radius);
  font-size: 13px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
}
.section-hint {
  margin: 0 0 14px;
  color: var(--fg-muted);
  font-size: 12.5px;
}

table.overlays {
  width: 100%;
  min-width: 1060px;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13px;
}
table.overlays th, table.overlays td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
table.overlays th:nth-child(1) { width: 46px; }
table.overlays th:nth-child(2) { width: 92px; }
table.overlays th:nth-child(3) { width: auto; }
table.overlays th:nth-child(4) { width: 110px; }
table.overlays th:nth-child(5) { width: 110px; }
table.overlays th:nth-child(6) { width: 270px; }
table.overlays th:nth-child(7) { width: 115px; }
table.overlays th {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--fg-muted);
  background: #f2f2ee;
}
table.overlays tr:last-child td { border-bottom: none; }
table.overlays td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tick-cell {
  text-align: center;
  vertical-align: middle !important;
}
.tick-cell input[type=checkbox] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}
.code-wrap {
  vertical-align: middle !important;
  white-space: nowrap;
}
.metric-cell {
  color: var(--fg);
  font-size: 12.5px;
}
.code-cell {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 600;
}
.row-needs-review {
  background: #fbf7e3;
}
.review-badge {
  display: inline-block;
  font-size: 10px;
  background: #e8c644;
  color: #3a2a00;
  padding: 1px 6px;
  border-radius: 2px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.name-cell .rationale {
  display: block;
  font-size: 11.5px;
  color: var(--fg-muted);
  margin-top: 3px;
  max-width: 66ch;
  line-height: 1.45;
}
.name-cell .rat-label {
  color: var(--fg);
  font-weight: 600;
}
.slider-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
  vertical-align: middle !important;
}
.slider-cell input[type=range] {
  flex: 1;
  min-width: 170px;
  accent-color: var(--accent);
}
.slider-cell .pct {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  width: 48px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  text-align: right;
}
.row-off .slider-cell { opacity: 0.45; }

.meta {
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--fg-faint);
}
