:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --text: #1c1f1d;
  --muted: #5d655f;
  --line: #dde2dc;
  --primary: #2f6b4f;
  --primary-soft: #dcebe2;
  --danger: #a33a32;
  --residential: #d9a441;
  --open: #5aa36a;
  --road: #9aa0a6;
  --utility: #7d8fb3;
  --unit: #b0739b;
  --other: #b9b2a3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121513;
    --surface: #1b1f1c;
    --surface-2: #232925;
    --text: #e6eae6;
    --muted: #a2aaa4;
    --line: #2f3631;
    --primary: #8fcfac;
    --primary-soft: #23382d;
    --danger: #f0a39b;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); }
button { font: inherit; cursor: pointer; }

.bar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; text-decoration: none; color: var(--text); white-space: nowrap; }
.spacer { flex: 1; }
.account { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.estate-button {
  min-width: 0; max-width: 50vw;
  border: 0; border-radius: 10px; padding: 6px 12px;
  background: var(--primary-soft); color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.estate-button::after { content: " ▾"; color: var(--muted); }
.text-button { border: 0; background: none; color: var(--primary); padding: 6px 4px; }

.tabs {
  display: flex; gap: 4px; overflow-x: auto;
  padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.tabs a {
  padding: 10px 12px; text-decoration: none; color: var(--muted); white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
main.wide { max-width: none; padding: 0; }

h1 { font-size: 22px; margin: 4px 0; }
h2 { font-size: 16px; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 13px; }
a.stat { text-decoration: none; color: inherit; }

.rows { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; }

.overview-map { height: 300px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
#map { height: calc(100vh - 100px); }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: clip; }
.list .group { background: var(--surface-2); padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.list .item { display: flex; gap: 12px; align-items: baseline; padding: 9px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.list .item:hover { background: var(--surface-2); }
.list .item .grow { flex: 1; min-width: 0; }
.list .item .right { text-align: right; white-space: nowrap; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
input[type="search"], input[type="email"], input[type="password"], select {
  font: inherit; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
input[type="search"] { flex: 1; min-width: 180px; }

.primary { border: 0; border-radius: 10px; padding: 9px 16px; background: var(--primary); color: var(--surface); font-weight: 600; }
.signin { max-width: 360px; margin: 10vh auto; display: grid; gap: 10px; }
.error { color: var(--danger); }

dialog#picker {
  width: min(560px, 100vw - 24px); height: min(80vh, 760px);
  padding: 0; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--text);
}
dialog#picker::backdrop { background: rgb(0 0 0 / 0.35); }
.picker-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.picker-list { overflow-y: auto; height: calc(100% - 62px); }
.picker-list .group { position: sticky; top: 0; background: var(--surface-2); padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--primary); }
.picker-list .item { padding: 9px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.picker-list .item:hover, .picker-list .item.selected { background: var(--primary-soft); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.leaflet-container { background: var(--surface-2); font: inherit; }
.map-legend { background: var(--surface); color: var(--text); padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); }

.detail { position: fixed; right: 16px; bottom: 16px; z-index: 1100; width: min(380px, 100vw - 32px); max-height: 70vh; overflow-y: auto; box-shadow: 0 6px 24px rgb(0 0 0 / 0.2); }
.detail .close { float: right; }
table.sales { width: 100%; border-collapse: collapse; font-size: 14px; }
table.sales td { padding: 3px 0; border-top: 1px solid var(--line); }
table.sales td:last-child { text-align: right; }

@media (max-width: 600px) {
  .account { display: none; }
  main { padding: 12px; }
}
