/* Land Information System — light theme (Staff GIS Portal family) */
:root {
  --bg: #F3F1EB;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #FFFFFF;
  --surface-hover: #FFFFFF;
  --border: rgba(28, 42, 33, 0.10);
  --border-strong: rgba(28, 42, 33, 0.20);
  --hover: rgba(28, 42, 33, 0.05);
  --text: #1C2A21;
  --text-secondary: #46564B;
  --text-muted: #7A887D;
  --accent: #76a193;
  --accent-dim: #A9B9C9;
  --accent-soft: rgba(78, 100, 120, 0.10);
  --shadow: 0 1px 2px rgba(28, 42, 33, 0.04), 0 4px 16px rgba(28, 42, 33, 0.05);

  /* top bar */
  --topbar-bg: #7f9c88;
  --topbar-text: #EDE8DC;
  --topbar-text-2: #C3CFC4;

  --font-serif: 'Source Serif 4', Georgia, serif;
  --font-sans: 'Inter', -apple-system, sans-serif;

  /* housing series (from the printed plan, deepened for white) */
  --hu-1: #E8875F;
  --hu-2: #E0B24A;
  --hu-3: #4E9DA1;
  --hu-4: #A3B865;

  --panel-w: 420px;
  --drawer-w: 352px;
  --lot-w: 340px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  color: var(--text);
  font-family: var(--font-sans);
  background: var(--bg);
}

body { position: relative; overflow: hidden; }

/* ---------- Background: portal photo under a light wash ---------- */
.bg-photo {
  position: fixed; inset: 0;
  background-color: var(--bg);
  background-image: url('../assets/land-bg.jpg');
  background-size: cover; background-position: center;
  z-index: -2;
}
.bg-scrim {
  position: fixed; inset: 0;
  background: linear-gradient(180deg, rgba(243,241,235,0.90) 0%, rgba(243,241,235,0.95) 55%, rgba(243,241,235,0.98) 100%);
  z-index: -1;
}

.signin-gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: #FBF7EE;
  color: #1C2A21;
}
.signin-gate[hidden] { display: none; }
.signin-box { text-align: center; max-width: 420px; }
.signin-logo { width: 40px; height: 40px; margin: 0 auto 22px; display: block; }
.signin-title { font-family: var(--font-serif); font-weight: 500; font-size: 30px; color: #2E8B4A; margin-bottom: 14px; }
.signin-lede { font-size: 14px; color: #B9BDB4; line-height: 1.6; margin-bottom: 30px; }
.signin-btn {
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  color: #101B15; background: #EAE6DD;
  border: none; border-radius: 6px; padding: 14px 22px;
  cursor: pointer; transition: background 0.15s ease;
}
.signin-btn:hover { background: #E0DBD0; }
.signin-btn:disabled { opacity: 0.6; cursor: default; }
.signin-btn[hidden] { display: none; }

/* ---------- App shell ---------- */
.app {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  margin-bottom: 16px;
  position: relative; z-index: 20;
  flex: none;
  background: var(--topbar-bg);
}
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand-logo { height: 36px; width: auto; display: block; }
.brand-divider { width: 1px; height: 22px; background: rgba(255,255,255,0.22); }
.brand-name { font-size: 13px; letter-spacing: 0.01em; color: var(--topbar-text-2); font-weight: 500; white-space: nowrap; }

.util-nav { display: flex; align-items: center; gap: 6px; }
.util-btn {
  background: transparent; border: 1px solid transparent;
  color: var(--topbar-text-2);
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500;
  padding: 8px 12px; border-radius: 6px;
  cursor: pointer; text-decoration: none;
  display: flex; align-items: center; gap: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}
.util-btn:hover, .util-btn[aria-expanded="true"] { color: var(--topbar-text); background: rgba(255,255,255,0.08); }
.util-btn:disabled { opacity: 0.6; cursor: default; }
.util-btn svg { width: 11px; height: 11px; opacity: 0.7; }
.topbar :focus-visible { outline-color: var(--topbar-text-2); }


/* ---------- Workspace: map + side panel ---------- */
.workspace {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  gap: 16px;
  padding: 0 20px 20px;
}

.map-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #E9ECE6;
  box-shadow: var(--shadow);
  min-height: 0;
}
#viewDiv { position: absolute; inset: 0; }

.map-status {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  max-width: 360px; text-align: center;
  font-size: 13.5px; line-height: 1.55; color: var(--text-secondary);
  padding: 16px 20px;
  background: var(--surface); backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.map-status[hidden] { display: none; }
.map-status.error { color: var(--text); border-color: rgba(200,70,60,0.45); }
.map-status a { color: var(--accent); }

.panel {
  flex: 1; min-width: 0;
  min-height: 0;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(28,42,33,0.2) transparent;
}

.panel-head { padding: 6px 4px 6px; }
.eyebrow { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; margin-bottom: 6px; }
.panel-head h1 {
  font-family: var(--font-serif); font-weight: 500;
  font-size: 30px; line-height: 1.15; letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.lede { font-size: 13.5px; line-height: 1.55; color: var(--text-secondary); margin-bottom: 16px; }

.segmented {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
}
.seg-btn {
  flex: 1;
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary); background: transparent;
  border: 1px solid transparent; border-radius: 6px;
  padding: 8px 6px; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.seg-btn:hover { color: var(--text); background: var(--hover); }
.seg-btn.active { color: #FFFFFF; background: var(--accent); border-color: var(--accent); }
.seg-btn:disabled { opacity: 0.45; cursor: default; }

.card {
  background: var(--surface); backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 18px 18px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card h2 { font-family: var(--font-serif); font-size: 18px; font-weight: 500; }
.badge {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); white-space: nowrap;
}
.badge.live { color: #3F8A55; }
.badge.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 0; }
.kpi { padding: 16px 18px; }
.kpi + .kpi { border-left: 1px solid var(--border); }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; }
.kpi-value { font-family: var(--font-serif); font-size: 28px; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-family: var(--font-sans); font-size: 13px; color: var(--text-secondary); font-weight: 500; margin-left: 3px; }
.kpi-sub { margin-top: 6px; font-size: 12px; color: var(--text-muted); line-height: 1.45; font-variant-numeric: tabular-nums; }

/* Donut */
.donut-wrap { position: relative; width: 190px; height: 190px; margin: 2px auto 16px; }
.donut { width: 100%; height: 100%; display: block; }
.donut path { cursor: pointer; transition: opacity 0.15s ease; stroke: var(--surface-solid); stroke-width: 1; }
.donut.has-focus path:not(.focus) { opacity: 0.25; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; text-align: center; padding: 0 44px;
}
.dc-value { font-family: var(--font-serif); font-size: 24px; font-weight: 500; font-variant-numeric: tabular-nums; }
.dc-label { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; line-height: 1.3; }

.lu-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.lu-row {
  display: grid; grid-template-columns: 12px 1fr auto auto; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 6px;
  font-size: 13px; color: var(--text-secondary);
  cursor: pointer; border: 1px solid transparent;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  width: 100%; background: transparent; font-family: var(--font-sans); text-align: left;
}
.lu-row:hover { background: var(--hover); color: var(--text); }
.lu-row.focus { background: var(--accent-soft); border-color: var(--accent-dim); color: var(--text); }
.lu-list.has-focus .lu-row:not(.focus) { opacity: 0.55; }
/* hairline so pale land-use colours still read on white */
.lu-swatch { width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(28,42,33,0.12); }
.lu-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lu-ha { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.lu-pct { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; min-width: 44px; text-align: right; }

.text-btn {
  margin-top: 10px; background: none; border: none; cursor: pointer;
  color: var(--accent); font-family: var(--font-sans); font-size: 12.5px; font-weight: 500;
  padding: 4px 8px;
}
.text-btn:hover { color: var(--text); }

.panel-foot { font-size: 11px; line-height: 1.6; color: var(--text-muted); padding: 4px 4px 2px; }
.disclaimer { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 10px; line-height: 1.5; color: var(--text-muted); }
.disclaimer b { font-weight: 600; }
.layer-line { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px; word-break: break-all; }

/* ---------- ArcGIS widgets (light theme CSS + portal fonts) ---------- */
.esri-view .esri-view-surface--inset-outline:focus::after { outline: none !important; }
.esri-ui .esri-widget,
.esri-ui .esri-widget--button {
  background-color: #FFFFFF !important;
  color: var(--text) !important;
  font-family: var(--font-sans);
}
.esri-ui .esri-widget--button { color: var(--text-secondary) !important; }
.esri-ui .esri-widget--button:hover { background-color: #F1F3EF !important; color: var(--text) !important; }
.esri-ui-corner .esri-component { box-shadow: var(--shadow); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.esri-attribution { background: rgba(255,255,255,0.85) !important; color: var(--text-muted) !important; }
.esri-attribution a { color: var(--text-secondary) !important; }
.esri-scale-bar__line { background: rgba(255,255,255,0.7) !important; }
.esri-scale-bar__label { color: var(--text-secondary) !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


/* ==========================================================
   Components (one block per feature module)
   ========================================================== */

/* ---------- Side wrapper ---------- */
.side { position: relative; min-height: 0; display: flex; }

/* ---------- Land use drawer (landuse-drawer.js) ---------- */
.drawer-clip {
  position: absolute; top: 12px; bottom: 12px; right: 0;
  width: var(--drawer-w);
  overflow: hidden;
  pointer-events: none;
  z-index: 15;
}
.lu-drawer {
  height: 100%;
  padding: 0 12px 0 10px;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
  pointer-events: auto;
}
.workspace.drawer-open .lu-drawer { transform: none; }
.lu-drawer .card {
  max-height: 100%;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 10px 30px rgba(28, 42, 33, 0.16);
  scrollbar-width: thin;
}

.drawer-tab {
  position: absolute; right: 0; top: 92px; z-index: 16;
  width: 26px; padding: 12px 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--accent); color: #FFFFFF;
  border: none; border-radius: 8px 0 0 8px;
  cursor: pointer; box-shadow: var(--shadow);
  font-family: var(--font-sans);
  transition: right 0.28s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.15s ease;
}
.workspace.drawer-open .drawer-tab { right: calc(var(--drawer-w) - 10px); }
.drawer-tab:hover { filter: brightness(0.92); }
.drawer-tab svg { width: 14px; height: 14px; transition: transform 0.25s ease; }
.workspace.drawer-open .drawer-tab svg { transform: rotate(180deg); }
.drawer-tab span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; }

/* ---------- Lot details (lot-info.js) ---------- */
.lot-clip {
  position: absolute; top: 0; right: 0;
  width: calc(var(--lot-w) + 30px);
  max-height: 100%;
  display: flex;
  overflow: hidden;
  pointer-events: none;
  z-index: 20;
}
.lot-info {
  position: relative;
  flex: 1; min-width: 0;
  margin: 12px 12px 40px 40px;
  padding: 18px 18px 16px;
  max-height: calc(100% - 52px);
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 30px rgba(28, 42, 33, 0.18);
  transform: translateX(calc(100% + 24px));
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
  pointer-events: auto;
}
.workspace.lot-open .lot-info { transform: none; }
/* while lot details are open, the land use card and its tab step aside;
   closing the details brings them back as they were */
.workspace.lot-open.drawer-open .lu-drawer { transform: translateX(100%); }
.workspace.lot-open .drawer-tab,
.workspace.lot-open.drawer-open .drawer-tab { right: 0; opacity: 0; pointer-events: none; }
.lot-info .eyebrow { margin-bottom: 2px; }
.lot-info .lot-title { font-family: var(--font-serif); font-weight: 500; font-size: 26px; line-height: 1.15; margin-bottom: 12px; }
.lot-dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13px; }
.lot-dl dt { color: var(--text-muted); }
.lot-dl dd { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.lot-sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: 0; box-shadow: inset 0 0 0 1px rgba(28,42,33,0.12); }
.lot-close { position: absolute; top: 10px; right: 10px; }

.icon-btn {
  width: 28px; height: 28px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 6px;
  color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn[hidden] { display: none; }
.icon-btn svg { width: 16px; height: 16px; }


/* ---------- Developer lot list (lot-list.js) ---------- */
.ll-title { font-family: var(--font-serif); font-size: 22px; font-weight: 500; line-height: 1.2; margin-bottom: 10px; }
.ll-total { display: flex; align-items: baseline; gap: 10px; padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.ll-total .big-num { display: inline; }
.ll-total .big-cap { display: inline; margin: 0; }
.ll-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.ll-row {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 10px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; cursor: pointer; text-align: left;
  font-family: var(--font-sans); color: var(--text);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.ll-row:hover { background: var(--hover); }
.ll-row.active { background: var(--accent-soft); border-color: var(--accent-dim); }
.ll-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ll-no { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ll-sub { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ll-sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; box-shadow: inset 0 0 0 1px rgba(28,42,33,0.12); }
.ll-status { flex: none; display: inline-flex; align-items: center; font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; }

.tl-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tl-head .ll-title { margin-bottom: 12px; }
.tl-dl { margin-bottom: 14px; }
.tl-ov { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-variant-numeric: tabular-nums; }
.tl-ov b { font-size: 12.5px; font-weight: 600; color: #B24E22; }
.tl-status.tl-active { color: #2F8F4E; font-weight: 600; }
.tl-status.tl-expired { color: #C8463C; font-weight: 600; }
.tl-ov small { font-size: 11px; color: var(--text-muted); }

.map-toggles {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 12; display: flex; gap: 6px; padding: 4px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow);
}
.map-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 8px; border-radius: 999px;
  border: none; background: transparent; cursor: pointer;
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 500; color: var(--text-secondary); white-space: nowrap;
}
.map-toggle:hover { background: var(--hover); color: var(--text); }
.mt-switch { position: relative; width: 26px; height: 15px; flex: none; border-radius: 999px; background: rgba(28, 42, 33, 0.18); transition: background 0.15s ease; }
.mt-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform 0.15s ease; }
.map-toggle.on { color: var(--text); }
.map-toggle.on .mt-switch { background: var(--accent); }
.map-toggle.on .mt-switch::after { transform: translateX(11px); }
@media (max-width: 480px) { .map-toggles { left: 56px; transform: none; } }

/* ---------- Search (search.js) ---------- */
.search { position: relative; }
.search[hidden] { display: none; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 6px 0 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong); border-radius: 8px;
  box-shadow: var(--shadow);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box > svg { width: 16px; height: 16px; color: var(--text-muted); flex: none; }
#searchInput {
  flex: 1; min-width: 0;
  border: none; outline: none; background: transparent;
  font-family: var(--font-sans); font-size: 14px; color: var(--text);
}
#searchInput::placeholder { color: var(--text-muted); }
#searchInput::-webkit-search-cancel-button { display: none; }

.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  list-style: none;
  max-height: 340px; overflow-y: auto;
  padding: 6px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(28, 42, 33, 0.16);
}
.search-results[hidden] { display: none; }
.search-hit {
  width: 100%;
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 10px; border-radius: 6px;
  border: none; background: transparent; cursor: pointer; text-align: left;
  font-family: var(--font-sans); font-size: 13.5px; color: var(--text);
}
.search-hit:hover, .search-hit.cursor { background: var(--accent-soft); }
.sh-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-meta { flex: none; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.search-hit.sh-missing { opacity: 0.55; cursor: default; }
.search-group {
  display: flex; justify-content: space-between;
  padding: 8px 10px 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
}
.search-group:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 10px; }
.search-group span { font-weight: 500; letter-spacing: 0; }
.sh-meta .ll-sw { vertical-align: 0; }
.search-all {
  width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 10px; border-radius: 6px; border: none; cursor: pointer; text-align: left;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--font-sans); font-size: 13px; font-weight: 600;
}
.search-all.cursor, .search-all:hover { background: rgba(78, 100, 120, 0.18); }
.ll-go { flex: none; font-size: 18px; color: var(--text-muted); line-height: 1; }
.ll-row:disabled { opacity: 0.5; cursor: default; }
.ll-back { margin: -4px 0 10px; padding: 4px 0; }
.search-summary, .search-empty { padding: 6px 10px; font-size: 11.5px; color: var(--text-muted); }

/* ---------- Status chips (status-filter.js) ---------- */
.status-filter[hidden], .lease-filter[hidden] { display: none; }
.lease-filter { margin-top: 10px; padding: 10px 0 0 12px; border-left: 2px solid var(--accent-dim); animation: card-in 0.25s ease both; }
.filter-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; margin: 2px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--font-sans); font-size: 12px; font-weight: 500;
  padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-secondary); cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.chip:hover { color: var(--text); border-color: var(--accent-dim); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; box-shadow: inset 0 0 0 1px rgba(28,42,33,0.12); }

/* ---------- Applied filters (stats-panel.js) ---------- */
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.active-filters[hidden] { display: none; }
.af-chip {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%;
  padding: 4px 7px 4px 10px; border-radius: 999px;
  background: var(--text); color: #FFFFFF; border: none; cursor: pointer;
  font-family: var(--font-sans); font-size: 12px; font-weight: 500;
}
.af-chip:hover { background: #33433A; }
.af-x { width: 12px; height: 12px; flex: none; }
.af-clear { margin-top: 0; }

/* ---------- Cards arriving after a search ---------- */
@keyframes card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stats-cards.cards-in > .card { animation: card-in 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.stats-cards.cards-in > .card:nth-child(2) { animation-delay: 0.07s; }
.stats-cards.cards-in > .card:nth-child(3) { animation-delay: 0.14s; }
.stats-cards.cards-in > .card:nth-child(4) { animation-delay: 0.21s; }
.stats-cards.cards-in > .card:nth-child(n+5) { animation-delay: 0.28s; }
.stats-cards.cards-in .ll-list > li { animation: card-in 0.3s ease both; animation-delay: 0.12s; }

/* ---------- Figures (stats-panel.js + charts.js) ---------- */
.stats-cards { display: flex; flex-direction: column; gap: 12px; }
.kpis { overflow: hidden; }
.kpi-ic { width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; color: var(--accent); }
.kpi-link { cursor: pointer; transition: background 0.12s ease; }
.kpi-link:hover { background: var(--hover); }

.hbars { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.hbar {
  width: 100%;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px;
  padding: 6px 8px; border-radius: 6px;
  border: 1px solid transparent; background: transparent; text-align: left;
  font-family: var(--font-sans); font-size: 13px; color: var(--text-secondary);
}
button.hbar { cursor: pointer; transition: background 0.12s ease, opacity 0.12s ease; }
button.hbar:hover { background: var(--hover); color: var(--text); }
.hbar.active { background: var(--accent-soft); border-color: var(--accent-dim); color: var(--text); }
.hbars.has-active .hbar:not(.active) { opacity: 0.5; }
.hbar-label { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-label i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.hbar-val { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; }
.hbar-val small { color: var(--text-muted); font-weight: 400; }
.hbar-track { grid-column: 1 / -1; height: 5px; background: rgba(28, 42, 33, 0.07); border-radius: 3px; overflow: hidden; }
.hbar-track > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.big-figure { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.big-ic { width: 46px; height: 46px; flex: none; padding: 9px; border-radius: 10px; color: var(--accent); background: var(--accent-soft); }
.big-ic.green { color: #3F8A55; background: rgba(63, 138, 85, 0.1); }
.big-num { display: block; font-family: var(--font-serif); font-size: 34px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.big-cap { display: block; margin-top: 4px; font-size: 12.5px; color: var(--text-secondary); }

.icon-grid { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 6px; }
.icon-grid .ic { width: 22px; height: 22px; color: var(--accent); }

.sub-h { margin: 16px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; }
.hint, .icon-note { margin-top: 6px; font-size: 11.5px; color: var(--text-muted); }
.note { margin-top: 8px; padding: 8px 10px; border-radius: 6px; background: rgba(224, 178, 74, 0.13); font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); }
.empty { font-size: 12.5px; color: var(--text-muted); padding: 4px 0; }

/* open space index illustration */
.osi-fig { width: 100%; height: auto; display: block; margin: 2px 0 8px; }
.osi-sq { fill: rgba(63, 138, 85, 0.2); stroke: #3F8A55; stroke-width: 1.2; }
.osi-sq.low { fill: rgba(232, 135, 95, 0.18); stroke: #E8875F; }
.osi-bench { fill: none; stroke: var(--text-muted); stroke-width: 1.2; stroke-dasharray: 4 3; }
.osi-tree, .osi-person { fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.osi-tree { stroke: #3F8A55; }
.osi-person { stroke: var(--text-secondary); }
.osi-ground { stroke: var(--border-strong); }
.osi-cap { font: 600 11px var(--font-sans); fill: var(--text); }
.osi-sub { font: 11px var(--font-sans); fill: var(--text-muted); }
.osi-calc { display: flex; justify-content: center; gap: 8px; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ---------- Layers list transparency slider (layer-list.js) ---------- */
.ll-opacity { padding: 8px 12px 12px; font-family: var(--font-sans); }
.ll-opacity label { display: block; }
.ll-opacity-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.ll-opacity output { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; }
.ll-opacity input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ---------- Map tools (map-widgets.js) ---------- */
.measure-box { width: 260px; padding: 12px; background: #FFFFFF; font-family: var(--font-sans); }
.measure-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.measure-btns { display: flex; gap: 6px; margin-bottom: 8px; }
.measure-btns button {
  flex: 1; padding: 7px 4px;
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border-strong); border-radius: 6px;
  background: #FFFFFF; color: var(--text); cursor: pointer;
}
.measure-btns button:hover { background: #F1F3EF; }
.measure-btns button.active { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { :root { --panel-w: 360px; } }

@media (max-width: 860px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; }
  .workspace { grid-template-columns: 1fr; padding: 0 16px 16px; }
  .map-wrap { height: 62vh; min-height: 360px; }
  .panel { overflow: visible; padding-right: 0; }
  .topbar { padding: 12px 16px; }
  .brand-logo { height: 30px; }

  /* drawer becomes a collapsible card above the panel */
  :root { --drawer-w: calc(100vw - 72px); --lot-w: calc(100vw - 56px); }
}

@media (max-width: 480px) {
  .brand-divider, .brand-name { display: none; }
  .kpi-value { font-size: 23px; }
  .util-btn { padding: 8px; }
}
/* ---------- Help (index.html dialog) ---------- */
.help {
  width: min(720px, calc(100vw - 32px)); max-height: min(86vh, 900px);
  margin: auto; padding: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-solid); color: var(--text);
  box-shadow: 0 24px 60px rgba(28, 42, 33, 0.25);
  font-family: var(--font-sans);
}
.help[open] { display: flex; flex-direction: column; animation: card-in 0.25s ease both; }
.help::backdrop { background: rgba(28, 42, 33, 0.35); }
.help-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.help-head h2 { font-family: var(--font-serif); font-weight: 500; font-size: 21px; }
.help-body { overflow-y: auto; padding: 6px 20px 20px; font-size: 13.5px; line-height: 1.55; color: var(--text-secondary); }
.help-body h3 { margin: 16px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; }
.help-body ul { padding-left: 18px; display: flex; flex-direction: column; gap: 5px; }
.help-body b { color: var(--text); font-weight: 600; }
.help-body kbd { font-family: var(--font-sans); font-size: 11.5px; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: #F6F5F1; color: var(--text); }
.help-foot { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }

/* ---------- Print sheet (A3 landscape, light paper) ---------- */
.print-sheet { display: none; }

@media print {
  @page { size: A3 landscape; margin: 10mm; }

  html, body.print-ready { background: #fff !important; }
  body.print-ready { height: auto; overflow: visible; }
  body.print-ready > *:not(.print-sheet) { display: none !important; }
  body.print-ready .print-sheet { display: block !important; }

  .ps-page {
    display: grid;
    grid-template-columns: 118mm 1fr;
    grid-template-rows: 100%;
    gap: 7mm;
    height: 275mm;
  }

  .print-sheet {
    font-family: var(--font-sans);
    /* re-map the theme to dark ink on white */
    --text: #1C2A21; --text-secondary: #3D4B41; --text-muted: #6E7C71;
    --border: #D6DBD3; --border-strong: #C2C9BF;
    --surface: transparent; --surface-solid: #FFFFFF;
    --accent: #4E6478; --accent-dim: #A9B9C9;
    color: var(--text);
  }
  .print-sheet * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .ps-side { display: flex; flex-direction: column; gap: 4mm; min-height: 0; overflow: hidden; }
  .ps-logo { height: 11mm; width: auto; align-self: flex-start; filter: brightness(0) saturate(0); opacity: 0.85; }
  .ps-side h1 { font-family: var(--font-serif); font-weight: 500; font-size: 21pt; line-height: 1.1; }
  .ps-sub { margin-top: 1mm; font-size: 10pt; color: var(--text-secondary); }

  .ps-stats { display: flex; flex-direction: column; gap: 2.5mm; }
  .ps-stats .card { background: none; backdrop-filter: none; border: 0.3mm solid var(--border); border-radius: 2.5mm; padding: 3mm 4mm; break-inside: avoid; }
  .ps-stats .card-head { margin-bottom: 2mm; }
  .ps-stats .card h2 { font-size: 11pt; }
  .ps-stats .badge { font-size: 6pt; }
  .ps-stats .badge.live { color: #3F8A55; }

  .ps-stats .kpis { padding: 0; }
  .ps-stats .kpi { padding: 3mm 4mm; }
  .ps-stats .kpi-label { font-size: 6.5pt; margin-bottom: 1mm; }
  .ps-stats .kpi-value { font-size: 16pt; }
  .ps-stats .kpi-value small { font-size: 8pt; }
  .ps-stats .kpi-sub { font-size: 7pt; margin-top: 1mm; }

  /* land use: donut on the left, list on the right */
  .ps-stats .card:has(.donut) { display: grid; grid-template-columns: 34mm 1fr; column-gap: 4mm; align-items: start; }
  .ps-stats .card:has(.donut) .card-head { grid-column: 1 / -1; }
  .ps-stats .donut-wrap { width: 34mm; height: 34mm; margin: 0; }
  .ps-stats .donut-center { padding: 0 8mm; }
  .ps-stats .dc-value { font-size: 11pt; }
  .ps-stats .dc-label { font-size: 6pt; }
  .ps-stats .donut path { stroke: #fff; }
  .ps-stats .lu-list { gap: 0; }
  .ps-stats .lu-row { padding: 0.5mm 1mm; gap: 2mm; font-size: 7.5pt; grid-template-columns: 2.6mm 1fr auto auto; border: none; }
  .ps-stats .lu-swatch { width: 2.6mm; height: 2.6mm; border-radius: 0.6mm; }
  .ps-stats .lu-ha { font-size: 6.5pt; }
  .ps-stats .lu-pct { min-width: 9mm; }
  .ps-stats .lu-row.focus { background: #EEF2F5; }



  .ps-foot { margin-top: auto; font-size: 6.2pt; line-height: 1.5; color: var(--text-muted); }

  .ps-map { border: 0.3mm solid var(--border); border-radius: 2.5mm; overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 0; }
  .ps-map img { width: 100%; height: 100%; object-fit: contain; display: block; }
  .ps-nomap { font-size: 11pt; color: var(--text-muted); }

  .ps-stats .card { max-height: none; overflow: visible; box-shadow: none; background: none; }
  .ps-stats .hint, .ps-stats .note { display: none; }
  .ps-stats .kpi-ic { width: 3mm; height: 3mm; }
  .ps-stats .hbars { gap: 0; }
  .ps-stats .hbar { padding: 0.6mm 1mm; gap: 0.6mm 3mm; font-size: 7.5pt; border: none; }
  .ps-stats .hbar-track { height: 1mm; }
  .ps-stats .big-figure { gap: 3mm; margin-bottom: 2mm; }
  .ps-stats .big-ic { width: 9mm; height: 9mm; padding: 1.6mm; }
  .ps-stats .big-num { font-size: 18pt; }
  .ps-stats .big-cap { font-size: 7pt; }
  .ps-stats .icon-grid { gap: 0.8mm; }
  .ps-stats .icon-grid .ic { width: 4mm; height: 4mm; }
  .ps-stats .icon-note { font-size: 6.5pt; }
  .ps-stats .sub-h { font-size: 6.5pt; margin: 2mm 0 1mm; }
  .ps-stats .osi-fig { max-height: 42mm; }
  .ps-stats .osi-calc { font-size: 7pt; padding-top: 1.5mm; }
  .ps-stats .lot-info { position: static; transform: none; margin: 0; max-height: none; overflow: visible; }
  .ps-stats .lot-title, .ps-stats .ll-title { font-size: 16pt; }
  .ps-stats .lot-dl { font-size: 9pt; }
}
