/* Erfscope — dark mapping UI. Tokens first; 8px spacing scale. */
:root {
  --bg-0: #0a0f17; --bg-1: #0f1620; --bg-2: #151e2b; --bg-3: #1c2737; --bg-4: #243247;
  --glass: rgba(13, 19, 29, .8);
  --line: rgba(148, 163, 184, .14); --line-2: rgba(148, 163, 184, .26);
  --t0: #f1f5f9; --t1: #cbd5e1; --t2: #94a3b8; --t3: #7c8ba1;
  --accent: #38bdf8; --accent-2: #0ea5e9; --accent-ink: #04202e;
  --green: #22c55e; --orange: #f59e0b; --red: #ef4444;
  /* text-safe variants (class colours as text/icons) and other themeable literals; redefined for the light UI at the end of this file */
  --accent-t: #38bdf8; --accent-ring: rgba(56, 189, 248, .18);
  --green-t: #86efac; --orange-t: #f59e0b; --red-t: #fca5a5;
  --warn-t: #fcd9a0; --warn-t2: #fde2b0; --warn-bg: rgba(40, 26, 4, .85); --danger-t: #fca5a5;
  --pill-ink: #fff; --scrim: rgba(4, 8, 14, .6); --tt-bg: rgba(10, 15, 23, .94); --attrib-bg: rgba(10, 15, 23, .7);
  --ctrl-filter: invert(1) opacity(.85); --attrib-btn-filter: invert(1); --seg-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --btn-grad: #4cc3fa;
  color-scheme: dark;
  --sp-0: 4px; --sp-1: 8px; --sp-2: 16px; --sp-3: 24px; --sp-4: 32px;
  --r-1: 8px; --r-2: 12px; --r-3: 16px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --shadow: 0 24px 60px -16px rgba(0, 0, 0, .65), 0 2px 8px rgba(0, 0, 0, .3);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --panel-w: 400px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--bg-0); color: var(--t0); font-family: var(--font); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
.ico { flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; left: 8px; top: -48px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; transition: top .15s; }
.skip:focus { top: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, .card-n, .row-area, .pill, .metric dd, .count, .kbd { font-variant-numeric: tabular-nums; }
.kbd { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; color: var(--t2); background: var(--bg-2); }
.muted { color: var(--t3); }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg-0); }

#map { position: fixed; inset: 0; background: var(--bg-0); }
.maplibregl-ctrl-group { background: var(--glass) !important; backdrop-filter: blur(14px); border: 1px solid var(--line-2); border-radius: 10px !important; box-shadow: none !important; }
.maplibregl-ctrl-group button { width: 34px; height: 34px; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }
.maplibregl-ctrl-group .maplibregl-ctrl-icon { filter: var(--ctrl-filter); }
.maplibregl-ctrl-attrib { background: var(--attrib-bg) !important; color: var(--t2) !important; border-radius: 8px; font-size: 11px; }
.maplibregl-ctrl-attrib a { color: var(--t1) !important; }
.maplibregl-ctrl-attrib-button { filter: var(--attrib-btn-filter); }

/* ---- glass panel ---- */
.panel { position: fixed; z-index: 5; top: var(--sp-2); left: var(--sp-2); bottom: var(--sp-2); width: var(--panel-w); display: flex; flex-direction: column; background: var(--glass); backdrop-filter: blur(22px) saturate(150%); -webkit-backdrop-filter: blur(22px) saturate(150%); border: 1px solid var(--line-2); border-radius: var(--r-3); box-shadow: var(--shadow); overflow: hidden; transition: bottom .25s var(--ease); }
.panel.is-collapsed { bottom: auto; }
.panel.is-collapsed .panel-body, .panel.is-collapsed .detail { display: none; }
.sheet-handle { display: none; }
.only-desktop { display: grid; }
.brand { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; flex: none; }
.logo { flex: none; border-radius: 9px; box-shadow: 0 0 0 1px var(--line-2); }
.brand-text { flex: 1; min-width: 0; }
.brand h1 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; line-height: 1.15; }
.brand p { color: var(--t2); font-size: 12px; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--t2); transition: background .15s, color .15s; flex: none; }
.icon-btn:hover { background: var(--bg-3); color: var(--t0); }
.icon-btn-sm { width: 24px; height: 24px; border-radius: 6px; }
.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.controls { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; flex: none; border-bottom: 1px solid var(--line); }
.scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--bg-4) transparent; padding: 16px; }

/* search */
.search { position: relative; }
.search-box { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 10px 0 12px; background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--r-2); color: var(--t2); transition: border-color .15s, box-shadow .15s; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.search-box.has-error { border-color: var(--red); }
.search-box .si { display: grid; }
.search-box input { flex: 1; min-width: 0; height: 100%; background: transparent; border: 0; outline: 0; color: var(--t0); font-size: 15px; }
.search-box input::placeholder { color: var(--t3); }
.search-box:focus-within .kbd { display: none; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--bg-4); border-top-color: var(--accent); animation: spin .7s linear infinite; flex: none; }
.spinner[hidden] { display: none; }
.field-msg { margin-top: 6px; color: var(--danger-t); font-size: 12px; }
.suggest { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); max-height: 320px; overflow-y: auto; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-2); box-shadow: var(--shadow); padding: 4px; }
.suggest li[role=option] { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--t2); }
.suggest li.is-active { background: var(--bg-4); color: var(--t0); }
.sg-text { display: flex; flex-direction: column; min-width: 0; }
.sg-name { color: var(--t0); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-detail { font-size: 12px; color: var(--t2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-empty { padding: 12px; color: var(--t2); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; color: var(--t1); font-size: 12px; transition: background .15s, border-color .15s, transform .1s; white-space: nowrap; }
.chip:hover:not(:disabled) { background: var(--bg-3); border-color: var(--line-2); }
.chip:active:not(:disabled) { transform: scale(.97); }
.chip small { color: var(--t3); font-size: 11px; }
.chip[aria-pressed=true] { background: rgba(56, 189, 248, .14); border-color: rgba(56, 189, 248, .5); color: var(--t0); }
.sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }

.field { display: flex; align-items: center; gap: 12px; }
.field-label { color: var(--t2); font-size: 12px; font-weight: 500; }
.seg { display: flex; flex: 1; padding: 3px; gap: 2px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; }
.seg { width: max-content; max-width: 100%; }
.seg button { flex: 1 0 auto; white-space: nowrap; height: 28px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; border: 0; border-radius: 7px; background: transparent; color: var(--t2); font-weight: 500; font-variant-numeric: tabular-nums; transition: background .15s, color .15s; }
.seg button small { font-size: 11px; opacity: .7; margin-left: 1px; }
.seg button:hover { color: var(--t0); }
.seg button[aria-checked=true] { background: var(--bg-4); color: var(--t0); box-shadow: var(--seg-shadow); }
.seg-sm { flex: none; }
.seg-sm button { height: 24px; font-size: 12px; }

.btn-primary { display: flex; align-items: center; justify-content: center; gap: 8px; height: 44px; border: 0; border-radius: var(--r-2); background: linear-gradient(180deg, var(--btn-grad), var(--accent-2)); color: var(--accent-ink); font-weight: 650; font-size: 15px; box-shadow: 0 6px 18px -6px rgba(14, 165, 233, .6), inset 0 1px 0 rgba(255, 255, 255, .3); transition: transform .1s, filter .15s, box-shadow .15s; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px) scale(.995); }
.btn-primary.is-busy { filter: saturate(.7); }
.btn-ghost { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 12px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; color: var(--t1); font-weight: 500; text-decoration: none; transition: background .15s, border-color .15s, color .15s; }
.btn-ghost:hover:not(:disabled) { background: var(--bg-3); color: var(--t0); }
.btn-ghost[aria-pressed=true], .btn-ghost.is-ok { border-color: rgba(56, 189, 248, .55); color: var(--accent-t); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; gap: 6px; }
.btn-link { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--accent-t); font-weight: 500; padding: 4px 0; border-radius: 6px; }
.btn-link:hover { text-decoration: underline; }
.alt-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: -4px; }
.hint { color: var(--t3); font-size: 12px; }

/* map basemap switcher */
.map-ui { position: fixed; z-index: 4; top: var(--sp-2); right: var(--sp-2); }
.seg-map { background: var(--glass); backdrop-filter: blur(14px); border-color: var(--line-2); box-shadow: var(--shadow); }
.seg-map button { padding: 0 12px; height: 30px; }

.panel[data-view=results] .chips, .panel[data-view=results] .hint { display: none; }
.panel[data-view=results] .controls { gap: 8px; padding-bottom: 12px; }

/* empty + progress */
.empty-card { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }
.empty-card h2 { font-size: 16px; font-weight: 650; }
.empty-card p { color: var(--t2); }
.empty-card .btn-ghost { align-self: flex-start; }
.empty-ico { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: rgba(56, 189, 248, .12); color: var(--accent-t); border: 1px solid rgba(56, 189, 248, .3); }
.empty-ico.warn { background: rgba(245, 158, 11, .12); color: var(--orange-t); border-color: rgba(245, 158, 11, .3); }
.tip { font-size: 12px; color: var(--t3) !important; }
.rules { display: flex; flex-direction: column; gap: 8px; }
.rules li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; }
.rules li div { display: flex; flex-direction: column; }
.rules b { font-weight: 600; }
.rules span { color: var(--t2); font-size: 12.5px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; margin-top: 5px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
.cls-green { --c: var(--green); } .cls-orange { --c: var(--orange); } .cls-red { --c: var(--red); } .cls-none { --c: #94a3b8; }
.rules .dot { background: var(--c); }
.card-top .dot, .row .dot, .badge .dot { margin-top: 0; }

.progress { display: flex; flex-direction: column; gap: 12px; }
.progress-head { display: flex; align-items: center; gap: 12px; }
.progress-head strong { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.elapsed { font-size: 12px; color: var(--t2); font-variant-numeric: tabular-nums; }
.bar { height: 3px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .4s var(--ease); }
.steps { display: flex; flex-direction: column; gap: 2px; }
.step { display: flex; align-items: center; gap: 12px; padding: 8px 4px; color: var(--t3); transition: color .2s; }
.step-ico { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--bg-4); flex: none; position: relative; }
.step-label { flex: 1; }
.step-detail { font-size: 11.5px; color: var(--t2); font-variant-numeric: tabular-nums; }
.step.is-active { color: var(--t0); }
.step.is-active .step-ico { border-color: var(--bg-4); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.step.is-done { color: var(--t1); }
.step.is-done .step-ico { background: var(--green); border-color: var(--green); }
.step.is-done .step-ico::after { content: ''; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #04210f; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.step.is-warn { color: var(--t1); }
.step.is-warn .step-ico { background: var(--orange); border-color: var(--orange); }
.step.is-warn .step-ico::after { content: '!'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #2a1800; }

/* results */
.results { display: flex; flex-direction: column; gap: 16px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px; text-align: left; background: color-mix(in srgb, var(--c) 9%, var(--bg-1)); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); border-radius: var(--r-2); transition: transform .12s, opacity .2s, filter .2s, border-color .2s; overflow: hidden; }
.card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--c); }
.card:hover { transform: translateY(-1px); }
.card[aria-pressed=false] { opacity: .45; filter: grayscale(.8); border-style: dashed; }
.card { min-width: 0; }
.card-top { display: flex; align-items: center; gap: 6px; font-size: 11.5px; white-space: nowrap; max-width: 100%; font-weight: 600; color: var(--t1); }
.card-n { font-family: var(--font); font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.card-a { font-size: 12px; color: var(--t2); font-variant-numeric: tabular-nums; }
.meta-line { display: flex; gap: 8px; align-items: flex-start; color: var(--t2); font-size: 12.5px; margin-top: -4px; }
.meta-line .ico { margin-top: 2px; }
.meta-line b { color: var(--t1); font-variant-numeric: tabular-nums; }
.notices { display: flex; flex-direction: column; gap: 8px; }
.notice { display: flex; gap: 8px; align-items: flex-start; padding: 8px 12px; font-size: 12.5px; color: var(--t2); background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; }
.notice .ico { margin-top: 2px; }
.notice-warn { color: var(--warn-t); border-color: rgba(245, 158, 11, .35); background: rgba(245, 158, 11, .07); }
.ov { display: flex; flex-direction: column; gap: 8px; }
.ov-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--t2); }
.ov-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; position: sticky; top: -16px; z-index: 2; margin: 0 -16px; padding: 8px 16px; background: color-mix(in srgb, var(--bg-0) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.toolbar h3 { font-size: 13px; font-weight: 600; flex: 1; min-width: 100px; }
.count { color: var(--t2); font-weight: 500; margin-left: 4px; }
.tools { display: flex; gap: 6px; }
.list { display: flex; flex-direction: column; gap: 4px; margin-top: -8px; }
.list-empty { padding: 24px 8px; text-align: center; color: var(--t2); }
.row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 10px; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 10px; transition: background .12s, border-color .12s; }
.row:hover, .row.is-hover { background: var(--bg-2); border-color: var(--line-2); }
.row.is-selected { background: var(--bg-3); border-color: color-mix(in srgb, var(--c) 60%, transparent); }
.row .dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12px; color: var(--t2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.row-area { font-size: 12px; color: var(--t2); font-weight: 500; }
.pill { display: inline-grid; place-items: center; min-width: 30px; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--pill-ink); background: color-mix(in srgb, var(--c) 32%, var(--bg-1)); border: 1px solid color-mix(in srgb, var(--c) 70%, transparent); }
.more { width: 100%; }

/* detail */
.detail { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; background: color-mix(in srgb, var(--bg-0) 96%, transparent); backdrop-filter: blur(22px); transform: translateX(104%); transition: transform .3s var(--ease), visibility 0s .3s; visibility: hidden; }
.detail.is-open { transform: none; visibility: visible; transition: transform .3s var(--ease); }
.detail-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 16px; flex: none; background: var(--bg-0); border-bottom: 1px solid var(--line); }
.detail-head .btn-ghost { border-color: transparent; background: transparent; padding-left: 6px; }
.detail-head .btn-ghost:hover { background: var(--bg-3); }
.detail-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 16px 32px; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; scrollbar-color: var(--bg-4) transparent; }
.badges .pill { margin-left: auto; }
.badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-weight: 600; font-size: 12px; background: color-mix(in srgb, var(--c) 18%, var(--bg-1)); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); }
.cat { color: var(--t1); font-weight: 500; font-size: 12.5px; }
.conf { height: 22px; padding: 0 8px; font-size: 11.5px; cursor: default; }
.conf-high { color: var(--green-t); border-color: rgba(34, 197, 94, .4); } .conf-medium { color: var(--orange-t); border-color: rgba(245, 158, 11, .4); } .conf-low { color: var(--red-t); border-color: rgba(239, 68, 68, .4); }
.d-title { font-size: 20px; font-weight: 650; letter-spacing: -.015em; line-height: 1.2; overflow-wrap: anywhere; }
.d-sub { color: var(--t2); margin-top: -8px; }
.d-headline { padding: 10px 12px; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 8%, transparent); border-radius: 0 10px 10px 0; color: var(--t0); }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { padding: 10px 12px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }  /* cards: used by the Residential panel */
.metric dt { font-size: 12px; color: var(--t2); font-weight: 500; }
.metric dd { font-family: var(--font); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; overflow-wrap: anywhere; }
.metric small { display: block; font-family: var(--font); font-size: 11.5px; color: var(--t2); font-weight: 400; }
.tag { display: inline-block; font-family: var(--font); font-size: 10.5px; font-weight: 500; padding: 1px 5px; border-radius: 4px; color: var(--orange-t); border: 1px solid rgba(245, 158, 11, .4); vertical-align: 2px; }
.raw-zone { font-size: 12px; color: var(--t1); display: flex; flex-direction: column; gap: 2px; }
.raw-zone span { color: var(--t2); font-size: 12px; font-weight: 500; }
.util-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--t2); margin-bottom: 6px; }
.util-top b { color: var(--t0); font-weight: 600; font-variant-numeric: tabular-nums; }
.util-bar { height: 8px; background: var(--bg-3); border-radius: 8px; overflow: hidden; }
.util-bar i { display: block; height: 100%; background: var(--c); border-radius: 8px; min-width: 2px; animation: grow .6s var(--ease); transform-origin: left; }
.d-h { font-size: 13px; color: var(--t0); font-weight: 650; margin: var(--sp-3) 0 var(--sp-1); }
.detail-scroll > .d-h:first-child, .yield > .d-h { margin-top: 0; }
.reasons, .constraints { display: flex; flex-direction: column; gap: 6px; }
.reasons li, .constraints li { display: flex; gap: 10px; align-items: flex-start; }
.reasons .ico { color: var(--green-t); margin-top: 2px; }
.constraints li { padding: 8px 10px; background: rgba(245, 158, 11, .08); border: 1px solid rgba(245, 158, 11, .3); border-radius: 10px; color: var(--warn-t2); }
.constraints .ico { color: var(--orange-t); margin-top: 2px; }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
.links .btn-ghost { justify-content: flex-start; font-size: 12.5px; height: 32px; padding: 0 10px; background: transparent; }
.links .btn-ghost:hover:not(:disabled) { background: var(--bg-3); }
.links .ext { margin-left: auto; opacity: .55; }
.d-foot { font-size: 11.5px; color: var(--t3); margin-top: 4px; }

/* map bits */
.centre-dot { width: 14px; height: 14px; pointer-events: none; }
.centre-dot .core { position: absolute; inset: 2px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 4px rgba(56, 189, 248, .25), 0 2px 6px rgba(0, 0, 0, .5); }
.centre-dot .ring { display: none; position: absolute; left: 50%; top: 50%; width: var(--d, 200px); height: var(--d, 200px); margin: calc(var(--d, 200px) / -2) 0 0 calc(var(--d, 200px) / -2); border-radius: 50%; border: 2px solid var(--accent); background: radial-gradient(circle, transparent 55%, rgba(56, 189, 248, .22)); opacity: 0; transform: scale(0); }
.centre-dot.is-scanning .ring { display: block; animation: ring 2.4s ease-out infinite; }
.centre-dot .r2 { animation-delay: .8s !important; } .centre-dot .r3 { animation-delay: 1.6s !important; }
.maplibregl-popup.tt .maplibregl-popup-content { background: var(--tt-bg); color: var(--t0); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow); font-family: var(--font); pointer-events: none; }
.maplibregl-popup.tt .maplibregl-popup-tip { display: none; }
.tt-title { font-weight: 600; }
.tt-sub { display: flex; align-items: center; gap: 6px; color: var(--t1); font-size: 12px; }
.tt-sub .dot { margin: 0; width: 8px; height: 8px; box-shadow: none; }
.ctx { position: fixed; z-index: 30; min-width: 200px; padding: 4px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); }
.ctx[hidden] { display: none; }
.ctx-coords { padding: 6px 10px; font-variant-numeric: tabular-nums; font-size: 11.5px; color: var(--t2); }
.ctx button { width: 100%; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; background: none; border: 0; border-radius: 8px; color: var(--t0); text-align: left; }
.ctx button:hover, .ctx button:focus-visible { background: var(--bg-4); }

/* toasts */
.toasts { position: fixed; z-index: 50; right: var(--sp-2); bottom: var(--sp-2); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; max-width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 10px 8px 10px 12px; background: var(--bg-2); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); border-radius: 10px; box-shadow: var(--shadow); animation: toastIn .25s var(--ease); }
.toast.out { opacity: 0; transform: translateY(6px); transition: .2s; }
.toast .ico { margin-top: 1px; color: var(--accent-t); }
.toast-error { border-left-color: var(--red); } .toast-error .ico { color: var(--red-t); }
.toast-warn { border-left-color: var(--orange); } .toast-warn .ico { color: var(--orange-t); }
.toast-success { border-left-color: var(--green); } .toast-success .ico { color: var(--green-t); }
.toast-msg { flex: 1; font-size: 13px; }
.toast-x { background: none; border: 0; color: var(--t2); padding: 2px; border-radius: 6px; display: grid; }
.toast-x:hover { color: var(--t0); background: var(--bg-4); }

/* modal */
.modal { padding: 0; border: 1px solid var(--line-2); border-radius: var(--r-3); background: var(--bg-1); color: var(--t0); width: min(560px, calc(100vw - 32px)); max-height: min(720px, calc(100dvh - 32px)); box-shadow: var(--shadow); }
.modal::backdrop { background: var(--scrim); backdrop-filter: blur(4px); }
.modal[open] { display: flex; animation: toastIn .25s var(--ease); }
.modal-card { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 24px; }
.modal h2 { font-size: 18px; font-weight: 650; }
.modal-body { padding: 8px 24px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; color: var(--t1); }
.modal-body h3 { font-size: 13px; font-weight: 650; color: var(--t0); margin-top: var(--sp-1); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ring { 0% { transform: scale(0); opacity: .9; } 100% { transform: scale(1); opacity: 0; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---- mobile bottom sheet ---- */
@media (max-width: 767px) {
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--sheet-h, 55vh); max-height: 92dvh; border-radius: 20px 20px 0 0; border-width: 1px 0 0; transition: height .3s var(--ease); padding-bottom: env(safe-area-inset-bottom); }
  .panel.is-dragging { transition: none; }
  .panel.is-collapsed { bottom: 0; }
  .only-desktop { display: none; }
  .sheet-handle { display: flex; justify-content: center; align-items: center; height: 24px; flex: none; cursor: grab; touch-action: none; }
  .sheet-handle span { width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); transition: background .15s; }
  .sheet-handle:hover span, .sheet-handle:focus-visible span { background: var(--t3); }
  .brand { padding: 0 16px 8px; }
  .logo { width: 28px; height: 28px; }
  .controls { padding-bottom: 12px; gap: 8px; }
  .hint { display: none; }
  .kbd { display: none; }
  .toasts { left: 16px; right: 16px; bottom: auto; top: 56px; align-items: stretch; max-width: none; }
  .map-ui { top: 12px; right: 12px; }
  .seg-map button span { display: none; }
  .seg-map button { padding: 0 10px; }
  .cards { gap: 6px; }
  .card { padding: 10px 8px; }
  .card-top { font-size: 11px; gap: 5px; }
  .card-top .dot { width: 8px; height: 8px; }
  .card-n { font-size: 20px; }
  .detail { transform: translateY(104%); }
  .detail.is-open { transform: none; }
  .toolbar { margin: 0 -16px; }
}
@media (max-width: 380px) {
  .key-figs { grid-template-columns: 1fr 1fr; }
  .row-meta .row-area { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .centre-dot.is-scanning .ring { animation: none; opacity: .5; transform: scale(1); }
}

/* Links out to real listings (js/listing-links.js) */
.ll-links { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-2); overflow: hidden; background: var(--bg-1); }
.ll-links .ll-link { height: auto; min-height: 44px; padding: 8px 12px; align-items: center; justify-content: flex-start; gap: 10px; border: 0; border-radius: 0; background: transparent; font-size: 13px; }
.ll-links .ll-link + .ll-link { border-top: 1px solid var(--line); }
.ll-links .ll-link:hover { background: var(--bg-2); }
.ll-links .ext { margin-left: auto; opacity: .55; }
.ll-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; text-align: left; }
.ll-txt b { font-weight: 600; font-size: 13px; }
.ll-txt small { color: var(--t3); font-size: 11.5px; font-weight: 400; overflow-wrap: anywhere; }
.ll-note { margin-top: 6px; }
.ll-sat { position: relative; margin: 0; flex: none; }
.ll-sat img { width: 100%; height: 190px; object-fit: cover; display: block; border-radius: var(--r-2); background: var(--bg-2); }
.ll-satimg { position: relative; }
.ll-pin { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--prop-rent, #38bdf8); border: 2px solid #fff; box-shadow: 0 0 0 4px rgba(0,0,0,.25); }
.ll-sat figcaption { font-size: 11.5px; color: var(--t3); margin-top: 6px; }
@media (max-width: 760px) { .ll-sat img { height: 170px; } }

/* yield */
.yield { display: flex; flex-direction: column; gap: var(--sp-1); }
.yield-na { font-size: 12.5px; }
.yield-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.yield-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--t2); font-weight: 500; }
.yield-field input { width: 100%; padding: 8px 10px; background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--r-1); font-family: var(--font); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; color: var(--t0); }
.yield-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.yield-notes { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--t2); padding-left: 14px; list-style: disc; }
@media (max-width: 760px) { .yield-inputs { grid-template-columns: 1fr; } }

/* Public transport (detail) and Near transport filter (results) */
.transit { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.transit li { display: flex; justify-content: space-between; gap: 10px; }
.transit li span { color: var(--t2); }
.transit li b { font-weight: 500; color: var(--t0); text-align: right; }
.near { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* shortlist */
.sl-btn { position: relative; }
.sl-count-btn { gap: 6px; white-space: nowrap; }
@media (max-width: 767px) { .sl-count-btn .sl-lbl { display: none; } .sl-count-btn { gap: 4px; padding: 0 10px; } .detail-head [data-back].btn-ghost { white-space: nowrap; } }
.sl-badge { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 10.5px; font-weight: 700; line-height: 16px; text-align: center; font-variant-numeric: tabular-nums; }
.head-actions { display: flex; align-items: center; gap: 4px; }
.head-actions .btn-ghost { padding-left: 10px; }
.head-actions .btn-ghost { height: 32px; min-height: 32px; }
.head-actions .btn-ghost[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.head-actions .btn-ghost[aria-pressed=true] .ico { fill: currentColor; }
.save-note, .sl-note { display: flex; flex-direction: column; gap: 4px; }
.save-note span, .sl-note span { font-size: 12px; color: var(--t2); font-weight: 500; }
.save-note textarea, .sl-note textarea { width: 100%; resize: vertical; min-height: 56px; padding: 8px 10px; background: var(--bg-1); border: 1px solid var(--line-2); border-radius: 10px; color: var(--t0); font: inherit; }
.save-note textarea:focus-visible, .sl-note textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sl-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sl-confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--t1); font-size: 13px; }
.sl-danger { border-color: rgba(239, 68, 68, .55); color: var(--danger-t); }
.sl-list { display: flex; flex-direction: column; gap: 10px; }
.sl-item { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-2); }
.sl-main { display: flex; align-items: center; gap: 10px; }
.sl-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sl-title { font-weight: 600; color: var(--t0); overflow-wrap: anywhere; }
.sl-sub { font-size: 12px; color: var(--t2); overflow-wrap: anywhere; }
.sl-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sl-print-note { display: none; }
.sl-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 24px 8px; color: var(--t2); }
.sl-empty h3 { color: var(--t0); font-size: 16px; }

/* print */
@media print {
  @page { margin: 14mm; }
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; color: #000 !important; }
  body[data-print] { --bg-0: #fff; --bg-1: #fff; --bg-2: #fff; --bg-3: #eee; --bg-4: #ddd; --t0: #000; --t1: #111; --t2: #333; --t3: #444; --line: #bbb; --line-2: #999; --glass: #fff; }
  #map, .map-ui, .toasts, .ctx, .skip, .sheet-handle, .maplibregl-ctrl, .noscript, #how { display: none !important; }
  .btn-ghost, .icon-btn, .btn-primary, .sl-tools, .sl-actions, .sl-note, .head-actions, .links { display: none !important; }
  .panel, .detail { position: static !important; transform: none !important; visibility: visible !important; backdrop-filter: none !important; box-shadow: none !important; border: 0 !important; background: #fff !important; overflow: visible !important; height: auto !important; width: auto !important; }
  .detail-scroll { overflow: visible !important; }
  .detail:not(.is-open) { display: none !important; }
  /* saved list */
  body[data-print=saved] .panel { display: none !important; }
  body[data-print=saved] #saved { position: static !important; display: block !important; width: auto !important; max-height: none !important; border: 0 !important; box-shadow: none !important; background: #fff !important; color: #000 !important; }
  body[data-print=saved] #saved .modal-body { overflow: visible !important; padding: 0; }
  body[data-print=saved] #saved header { padding: 0 0 8px; }
  body[data-print=saved] .sl-item { break-inside: avoid; background: #fff; border-color: #999; }
  body[data-print=saved] .sl-print-note { display: block; font-size: 12px; white-space: pre-wrap; }
  /* open parcel */
  body[data-print=detail] .panel-body, body[data-print=detail] .brand, body[data-print=detail] #saved { display: none !important; }
  body[data-print=detail] .detail { display: block !important; }
  body[data-print=detail] .save-note textarea { border: 1px solid #999; background: #fff; color: #000; }
  body[data-print=detail] .d-foot { color: #333; }
}

/* ---- visual pass: hierarchy in the parcel detail ---- */
.detail-scroll > * { flex: none; }
.erf-fig { margin: 0; display: flex; flex-direction: column; gap: 4px; align-self: flex-start; }
.erf-svg { display: block; max-width: 100%; height: auto; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-1); }
.erf-fig figcaption { font-size: 11.5px; color: var(--t2); font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.key-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-1); margin-top: var(--sp-1); padding: var(--sp-2) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.kf { min-width: 0; }
.kf dt { font-size: 12px; font-weight: 500; color: var(--t2); }
.key-figs { container-type: inline-size; }
.kf dd { font-size: clamp(15px, 5cqi, 22px); font-weight: 650; line-height: 1.2; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; }
.kf .tag { display: block; width: max-content; margin-top: 4px; font-size: 10.5px; line-height: 1.3; letter-spacing: 0; vertical-align: baseline; }
.metrics-list { grid-template-columns: 1fr 1fr; gap: 0 var(--sp-3); }
.metrics-list .metric { padding: 8px 0; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.metrics-list .metric small { margin-top: 1px; }
.y-hero { display: flex; flex-direction: column; gap: 2px; padding: var(--sp-1) 0 var(--sp-2); }
.y-hero-l { font-size: 12px; font-weight: 500; color: var(--t2); }
.y-hero-n { font-size: 26px; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.yield-assume { margin-top: var(--sp-2); padding: var(--sp-1) var(--sp-2) var(--sp-2); background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-2); }
.yield-sub { margin: 0 0 var(--sp-1); font-size: 12px; font-weight: 600; color: var(--t2); }
.yield-notes { color: var(--t3); font-size: 11.5px; }
.yield .pi-fine { margin-top: var(--sp-1); }
.d-headline { margin-top: var(--sp-1); }
.d-title { margin-top: var(--sp-1); }
.seg-sm button { padding: 0 10px; }
.near { flex-wrap: wrap; }
@media (max-width: 767px) {
  .btn-ghost, .btn-sm, .links .btn-ghost, .head-actions .btn-ghost, .icon-btn, .chip { min-height: 40px; }
  .head-actions .btn-ghost { height: 40px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn-sm { width: 32px; height: 32px; }
  .seg button, .seg-sm button { min-height: 40px; height: 40px; }
  .seg-map button { height: 40px; }
  .links { gap: 8px; }
}
@media (max-width: 340px) { .metrics-list { grid-template-columns: 1fr; } .key-figs { grid-template-columns: 1fr; } .kf { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; } }
.erf-fig figcaption { overflow-wrap: anywhere; }

/* ---- light UI: token overrides only (set by js/ui/theme.js from the basemap choice; print always uses it) ---- */
:root[data-ui="light"] {
  color-scheme: light;
  --bg-0: #f3f6fa; --bg-1: #ffffff; --bg-2: #f1f4f8; --bg-3: #e5eaf1; --bg-4: #d3dbe6;
  --glass: rgba(255, 255, 255, .84);
  --line: rgba(15, 23, 42, .12); --line-2: rgba(15, 23, 42, .24);
  --t0: #0f172a; --t1: #334155; --t2: #475569; --t3: #5a6a7f;
  --accent: #0284c7; --accent-2: #0369a1; --accent-ink: #ffffff; --btn-grad: #0b8fd0;
  --accent-t: #0369a1; --accent-ring: rgba(2, 132, 199, .22);
  --green-t: #15803d; --orange-t: #b45309; --red-t: #b91c1c;
  --warn-t: #92400e; --warn-t2: #92400e; --warn-bg: #fef3c7; --danger-t: #b91c1c;
  --pill-ink: #0f172a; --scrim: rgba(15, 23, 42, .38); --tt-bg: rgba(255, 255, 255, .96); --attrib-bg: rgba(255, 255, 255, .78);
  --ctrl-filter: opacity(.8); --attrib-btn-filter: none; --seg-shadow: 0 1px 2px rgba(15, 23, 42, .18);
  --shadow: 0 24px 60px -16px rgba(15, 23, 42, .28), 0 2px 8px rgba(15, 23, 42, .1);
}
@media print {
  :root {
    color-scheme: light;
    --bg-0: #f3f6fa; --bg-1: #ffffff; --bg-2: #f1f4f8; --bg-3: #e5eaf1; --bg-4: #d3dbe6;
    --glass: rgba(255, 255, 255, .84);
    --line: rgba(15, 23, 42, .12); --line-2: rgba(15, 23, 42, .24);
    --t0: #0f172a; --t1: #334155; --t2: #475569; --t3: #5a6a7f;
    --accent: #0284c7; --accent-2: #0369a1; --accent-ink: #ffffff; --btn-grad: #0b8fd0;
    --accent-t: #0369a1; --accent-ring: rgba(2, 132, 199, .22);
    --green-t: #15803d; --orange-t: #b45309; --red-t: #b91c1c;
    --warn-t: #92400e; --warn-t2: #92400e; --warn-bg: #fef3c7; --danger-t: #b91c1c;
    --pill-ink: #0f172a; --scrim: rgba(15, 23, 42, .38); --tt-bg: rgba(255, 255, 255, .96); --attrib-bg: rgba(255, 255, 255, .78);
    --ctrl-filter: opacity(.8); --attrib-btn-filter: none; --seg-shadow: 0 1px 2px rgba(15, 23, 42, .18);
    --shadow: 0 24px 60px -16px rgba(15, 23, 42, .28), 0 2px 8px rgba(15, 23, 42, .1);
  }
}
