﻿:root {
  --bg: #f5efe4;
  --paper: rgba(255, 250, 242, 0.95);
  --paper-strong: #fff9ef;
  --ink: #182126;
  --muted: #58646d;
  --border: rgba(24, 33, 38, 0.09);
  --shadow: 0 18px 50px rgba(38, 33, 24, 0.14);
  --open-fill: rgba(81, 162, 94, 0.24);
  --open-stroke: #3f8e51;
  --closed-fill: rgba(205, 88, 88, 0.22);
  --closed-stroke: #bb4f4f;
  --accent: #17324d;
  --chip: rgba(23, 50, 77, 0.08);
  --font: "Assistant", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(228, 143, 93, 0.24), transparent 28%),
    radial-gradient(circle at bottom left, rgba(86, 150, 121, 0.18), transparent 22%),
    linear-gradient(180deg, #efe5d4 0%, #f5efe4 42%, #f2ecdf 100%);
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 24px;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.94), rgba(251, 244, 232, 0.96));
  backdrop-filter: blur(12px);
}

.hero {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #8f5f37;
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1,
.legend h2,
.results h2,
.unmatched h2 {
  margin: 0;
  font-family: "David Libre", "Times New Roman", serif;
  font-weight: 700;
}

.hero h1 {
  font-size: clamp(2rem, 3vw, 2.65rem);
  line-height: 1.04;
  margin-bottom: 12px;
}

.hero-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.controls,
.legend,
.results,
.unmatched {
  padding: 18px;
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.field span {
  font-size: 0.95rem;
}

.field input {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus {
  border-color: rgba(23, 50, 77, 0.35);
  box-shadow: 0 0 0 4px rgba(23, 50, 77, 0.08);
}

.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  color: var(--accent);
  padding: 10px 14px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.chip:hover {
  transform: translateY(-1px);
}

.chip-active {
  background: var(--accent);
  color: #fff;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button {
  border-radius: 16px;
  padding: 12px 14px;
  border: 1px solid transparent;
}

.primary-button {
  background: linear-gradient(135deg, #1d3c58, #2f5879);
  color: #fff;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.75);
  border-color: var(--border);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 16px;
  border-radius: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  background: var(--paper-strong);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.9rem;
}

.stat-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-open {
  background: linear-gradient(180deg, rgba(241, 255, 243, 0.95), rgba(225, 245, 230, 0.95));
}

.stat-closed {
  background: linear-gradient(180deg, rgba(255, 243, 243, 0.95), rgba(250, 229, 229, 0.95));
}

.stat-total {
  background: linear-gradient(180deg, rgba(247, 247, 247, 0.95), rgba(239, 239, 239, 0.95));
}

.stat-unmatched {
  background: linear-gradient(180deg, rgba(255, 248, 235, 0.95), rgba(248, 237, 214, 0.95));
}

.legend-row,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.legend-row {
  gap: 10px;
  justify-content: flex-start;
  margin-top: 12px;
}

.legend-swatch {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.legend-open {
  background: var(--open-fill);
  border-color: var(--open-stroke);
}

.legend-closed {
  background: var(--closed-fill);
  border-color: var(--closed-stroke);
}

.section-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.settlement-list,
.unmatched-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.list-item,
.unmatched-item {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
}

.list-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.list-item button {
  all: unset;
  display: block;
  cursor: pointer;
  width: 100%;
}

.list-item-title {
  font-weight: 700;
  display: block;
}

.list-item-meta,
.unmatched-item {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}

.badge {
  white-space: nowrap;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.badge-open {
  background: rgba(81, 162, 94, 0.14);
  color: var(--open-stroke);
}

.badge-closed {
  background: rgba(205, 88, 88, 0.14);
  color: var(--closed-stroke);
}

.map-panel {
  position: relative;
  min-height: 100vh;
}

.info-popup {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 700;
  width: min(420px, calc(100% - 36px));
  background: rgba(255, 250, 242, 0.9);
  backdrop-filter: blur(10px);
  padding: 14px 18px 16px;
}

.info-popup-content {
  display: grid;
  gap: 12px;
}

.info-popup-close {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--accent);
  font-size: 1.25rem;
  line-height: 1;
}

.info-popup-close:hover {
  background: rgba(255, 255, 255, 0.98);
}

.info-popup.hidden {
  display: none;
}

.topbar-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 4px;
}

#map {
  min-height: 100vh;
}

.hidden {
  display: none;
}

.leaflet-popup-content-wrapper {
  border-radius: 18px;
}

.popup-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.popup-meta {
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .map-panel {
    order: 1;
    min-height: 72vh;
  }

  #map {
    min-height: 72vh;
  }
}

@media (max-width: 720px) {
  .sidebar,
  .info-popup {
    padding: 16px;
  }

  .summary-grid,
  .actions {
    grid-template-columns: 1fr;
  }

  .info-popup {
    left: 12px;
    right: 12px;
    top: 12px;
    width: auto;
    padding: 16px;
  }
}
