:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --ink: #1c1b18;
  --muted: #6f6659;
  --line: #d8d0c3;
  --panel: #fffdf8;
  --focus: #155eb6;
  --accent: #145a42;
  --shadow: 0 10px 25px rgba(31, 28, 23, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  min-height: 92px;
  padding: 18px clamp(14px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow,
.counts,
.warning,
.confidence,
.empty,
.list-head span {
  color: var(--muted);
  font-size: 0.84rem;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.42rem;
  line-height: 1.12;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.layout {
  display: grid;
  grid-template-rows: auto minmax(360px, 54vh) auto;
  min-height: calc(100% - 92px);
}

.controls,
.list-panel {
  padding: 12px clamp(12px, 3vw, 24px);
  background: var(--panel);
}

.controls {
  display: grid;
  grid-template-columns: minmax(150px, 1.5fr) minmax(140px, 0.8fr) minmax(250px, 1.5fr) auto;
  gap: 10px 14px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.search-label,
.filter-row label,
.status-filter legend {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.search-label {
  grid-column: 1;
  grid-row: 1;
}

#search {
  grid-column: 1;
  grid-row: 2;
}

.filter-row {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.status-filter {
  grid-column: 3;
  grid-row: 1 / span 2;
}

.action-row {
  grid-column: 4;
  grid-row: 2;
}

#search,
#area {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.status-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.status-filter legend {
  width: 100%;
}

.status-filter label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  white-space: nowrap;
}

.action-row {
  display: flex;
  gap: 8px;
}

.action-row button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 0 12px;
  cursor: pointer;
}

.action-row button + button {
  background: #fff;
  color: var(--ink);
}

.warning {
  grid-column: 1 / -1;
  margin: 0;
}

.map-panel {
  min-height: 360px;
  overflow: hidden;
}

#map {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 360px;
  overflow: hidden;
}

.leaflet-container {
  overflow: hidden;
}

.list-panel {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--line);
}

.list-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.location-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}

.location-card {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 76px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(31, 28, 23, 0.04);
}

.location-card:hover {
  border-color: #a99f91;
  box-shadow: var(--shadow);
}

.status-uncertain {
  border-left-color: #a46409;
}

.status-planned {
  border-left-color: #2869b8;
}

.status-historical {
  border-left-color: #696969;
}

.card-main {
  display: grid;
  gap: 4px;
}

.card-main span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.3;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #eee9df;
  color: var(--ink);
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 700;
}

.pin-wrap {
  background: transparent;
  border: 0;
}

.pin {
  display: block;
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  background: var(--pin-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transform: rotate(-45deg);
}

.pin::after {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  margin: 5px;
  border-radius: 50%;
  background: #fff;
}

.popup-card {
  max-width: 290px;
}

.popup-card h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.popup-card p {
  margin-bottom: 7px;
  line-height: 1.35;
}

.popup-brand {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.popup-card ul {
  margin: 0 0 8px 18px;
  padding: 0;
}

.popup-actions {
  display: flex;
  gap: 8px;
}

.popup-actions a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 0 10px;
  text-decoration: none;
}

.popup-actions a + a {
  background: #e9e2d8;
  color: var(--ink);
}

@media (min-width: 980px) {
  .layout {
    grid-template-columns: minmax(310px, 24vw) 1fr;
    grid-template-rows: auto 1fr;
  }

  .controls {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .map-panel {
    grid-column: 2;
    grid-row: 2;
    min-height: calc(100vh - 206px);
  }

  .list-panel {
    grid-column: 1;
    grid-row: 2;
    max-height: calc(100vh - 206px);
    overflow: auto;
    border-top: 0;
    border-right: 1px solid var(--line);
  }

  .location-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: start;
    flex-direction: column;
    min-height: 112px;
  }

  .layout {
    min-height: calc(100% - 112px);
    grid-template-rows: auto 58vh auto;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .search-label,
  #search,
  .filter-row,
  .status-filter,
  .action-row {
    grid-column: 1;
    grid-row: auto;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .status-filter label {
    flex: 1 1 calc(50% - 8px);
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: 1.26rem;
  }

  .location-list {
    grid-template-columns: 1fr;
  }

  .location-card {
    flex-direction: column;
  }

  .badge {
    align-self: start;
  }
}
