:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5d6975;
  --line: #d9e1e8;
  --panel: #ffffff;
  --band: #eef3f6;
  --accent: #006c67;
  --accent-strong: #004f4b;
  --warn: #8f4a00;
  --shadow: 0 12px 30px rgba(23, 32, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f7f9fb;
  color: var(--ink);
}

.app-header {
  min-height: 160px;
  padding: 34px clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: linear-gradient(120deg, #17324d, #006c67 72%, #9a6428);
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.8rem;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.86;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1;
  letter-spacing: 0;
}

.source-pill {
  min-width: 132px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  text-align: right;
  background: rgba(255, 255, 255, 0.1);
}

.source-pill span {
  display: block;
  font-size: 0.78rem;
  opacity: 0.85;
}

.source-pill strong {
  font-size: 1.4rem;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 56px;
}

.control-band,
.summary-grid,
.map-shell,
.table-shell {
  margin-bottom: 18px;
}

.control-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

select,
input,
button {
  min-height: 42px;
  border-radius: 7px;
  font: inherit;
}

select,
input {
  width: 100%;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: #ffffff;
  color: var(--ink);
}

button {
  border: 0;
  padding: 0 16px;
  align-self: end;
  background: var(--accent);
  color: #ffffff;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  background: #9aa7b3;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.summary-grid article {
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.summary-grid span {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.summary-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.45rem;
}

.map-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.map-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--band);
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  justify-content: flex-end;
}

.map-actions button {
  min-height: 36px;
}

.map-toggle {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 750;
}

.map-toggle input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.address-search {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfc;
}

.address-search button {
  min-width: 140px;
}

.map-toolbar h2 {
  margin-bottom: 4px;
  font-size: 1.1rem;
}

.map-toolbar p,
.map-detail p {
  margin-bottom: 0;
  color: var(--muted);
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 18px;
  padding: 18px;
}

#geo-map {
  width: 100%;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
}

.leaflet-container {
  font: inherit;
}

.map-feature-tooltip {
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-weight: 700;
}

.address-marker {
  width: 14px;
  height: 14px;
  border: 3px solid #ffffff;
  border-radius: 999px;
  background: #b42318;
  box-shadow: 0 0 0 2px #7a271a;
}

.map-detail {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.map-detail span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.map-detail strong {
  overflow-wrap: anywhere;
  font-size: 1.3rem;
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--band);
}

.table-toolbar h2 {
  margin-bottom: 4px;
  font-size: 1.1rem;
}

.table-toolbar p {
  margin-bottom: 0;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  max-width: 330px;
  text-align: left;
  white-space: normal;
  background: #ffffff;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fbfcfd;
}

tr:hover td,
tr:hover td:first-child {
  background: #f3f8f8;
}

.empty-row td {
  padding: 28px 14px;
  color: var(--muted);
  text-align: left;
}

@media (max-width: 860px) {
  .app-header,
  .map-toolbar,
  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .source-pill {
    text-align: left;
  }

  .control-band,
  .summary-grid,
  .address-search,
  .map-layout {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }
}
