@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@600;700&display=swap");

:root {
  --page: #eef1ec;
  --surface: #fbfcf8;
  --surface-soft: #e4e9e2;
  --ink: #102e24;
  --muted: #64736b;
  --line: #d3dbd3;
  --accent: #e66a3c;
  --accent-soft: #f8ded3;
  --shadow: 0 24px 70px rgba(16, 46, 36, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
}

body {
  background:
    radial-gradient(circle at 10% 5%, rgba(230, 106, 60, 0.13), transparent 25rem),
    radial-gradient(circle at 95% 85%, rgba(50, 123, 98, 0.12), transparent 28rem),
    var(--page);
}

.page-shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(320px, 520px) minmax(170px, 1fr);
  align-items: center;
  gap: 24px;
  max-width: 1500px;
  margin: 0 auto 18px;
  padding: 16px 20px;
  background: rgba(251, 252, 248, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 22px;
  box-shadow: 0 10px 40px rgba(16, 46, 36, 0.07);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: var(--ink);
  color: white;
  border-radius: 13px;
  font: 700 1.2rem "Manrope", sans-serif;
}

.brand-name,
.brand-subtitle,
.eyebrow,
.territory-meta,
.kpi-label,
.kpi-value,
.kpi-detail,
.empty-title,
.empty-copy,
.map-hint {
  margin: 0;
}

.brand-name {
  font: 700 1rem "Manrope", sans-serif;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.76rem;
}

.search-wrap label {
  display: block;
  margin: 0 0 6px 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.city-search .Select-control {
  height: 44px;
  background: #f1f4ef;
  border: 1px solid transparent;
  border-radius: 12px;
  box-shadow: none;
}

.city-search .Select-control:hover,
.city-search.is-focused .Select-control {
  border-color: #9bad9f;
}

.city-search .Select-placeholder,
.city-search .Select-value-label,
.city-search .Select-input {
  line-height: 42px !important;
}

.city-search .Select-menu-outer {
  border: 0;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.api-status {
  justify-self: end;
  padding: 8px 12px;
  color: #24634e;
  background: #dcefe6;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}

.api-status::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  background: #2b8c75;
  border-radius: 50%;
  content: "";
}

.api-status--error {
  color: #9a3f2a;
  background: var(--accent-soft);
}

.api-status--error::before {
  background: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(340px, 0.85fr);
  gap: 18px;
  max-width: 1500px;
  min-height: calc(100vh - 132px);
  margin: 0 auto;
}

.map-panel,
.details-panel {
  overflow: hidden;
  background: rgba(251, 252, 248, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.map-panel {
  display: flex;
  min-height: 680px;
  flex-direction: column;
  padding: 18px;
}

.map-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 4px 4px 16px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: "Manrope", sans-serif;
  letter-spacing: -0.04em;
}

h1 {
  font-size: clamp(1.55rem, 2.4vw, 2.35rem);
}

h2 {
  font-size: clamp(1.65rem, 2.4vw, 2.4rem);
}

.metric-selector {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.metric-selector label {
  display: inline-flex;
  align-items: center;
  padding: 8px 11px;
  color: var(--muted);
  background: #edf1ec;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
}

.metric-selector input {
  margin: 0 6px 0 0;
  accent-color: var(--accent);
}

.time-control {
  padding: 4px 8px 14px;
}

.time-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.play-button {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font: 700 0.78rem "DM Sans", sans-serif;
  transition: background 150ms ease, color 150ms ease;
}

.play-button:hover {
  border-color: var(--accent);
}

.play-button--on {
  color: #fff;
  background: var(--accent);
}

.time-control label {
  display: block;
  margin: 0 0 2px 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.year-slider .rc-slider-track {
  background: var(--accent);
}

.year-slider .rc-slider-handle {
  border-color: var(--accent);
  background: var(--accent);
  opacity: 1;
}

.year-slider .rc-slider-dot-active {
  border-color: var(--accent);
}

.year-slider .rc-slider-mark-text {
  color: var(--muted);
  font-size: 0.72rem;
}

.year-slider .rc-slider-mark-text-active {
  color: var(--ink);
  font-weight: 700;
}

.trend-panel {
  margin-top: 18px;
  padding: 16px 18px;
  background: rgba(251, 252, 248, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(16, 46, 36, 0.06);
}

.trend-title {
  margin-bottom: 10px;
}

.price-trend {
  width: 100%;
  height: 150px;
}

.history-panel:empty {
  display: none;
}

.history-panel {
  margin-top: 18px;
  padding: 16px 18px;
  background: rgba(251, 252, 248, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(16, 46, 36, 0.06);
}

.history-scroll {
  max-height: 220px;
  overflow-y: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.history-table th {
  position: sticky;
  top: 0;
  text-align: left;
  padding: 6px 8px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.history-table td {
  padding: 6px 8px;
  color: var(--ink);
  border-bottom: 1px solid rgba(16, 46, 36, 0.06);
  white-space: nowrap;
}

.history-table tbody tr:hover {
  background: rgba(230, 106, 60, 0.06);
}

.territory-map {
  width: 100%;
  height: min(70vh, 720px);
  min-height: 540px;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(251, 252, 248, 0.98);
}

.maplibregl-ctrl-attrib {
  font-size: 10px;
}

.map-legend {
  position: absolute;
  z-index: 5;
  bottom: 14px;
  left: 14px;
  width: 208px;
  padding: 12px 14px;
  background: rgba(251, 252, 248, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(16, 46, 36, 0.14);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.legend-title {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.legend-bar {
  height: 10px;
  border-radius: 99px;
  box-shadow: inset 0 0 0 1px rgba(16, 46, 36, 0.08);
}

.legend-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(16, 46, 36, 0.12);
}

.map-hint {
  padding: 13px 4px 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.details-panel {
  padding: 24px;
  background: rgba(224, 231, 223, 0.92);
}

.details-heading {
  min-height: 112px;
  padding: 4px 4px 20px;
  border-bottom: 1px solid #c5d0c7;
}

.territory-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.kpi-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.kpi-card {
  min-height: 148px;
  padding: 20px;
  background: rgba(251, 252, 248, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(16, 46, 36, 0.06);
}

.kpi-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kpi-value {
  margin-top: 8px;
  font: 700 clamp(1.7rem, 3vw, 2.5rem) "Manrope", sans-serif;
  letter-spacing: -0.05em;
}

.kpi-detail {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.kpi-bar {
  height: 7px;
  margin-top: 20px;
  overflow: hidden;
  background: #dce3dc;
  border-radius: 99px;
}

.kpi-bar-fill {
  height: 100%;
  min-width: 3%;
  border-radius: inherit;
  transition: width 350ms ease;
}

.empty-state {
  display: grid;
  min-height: 440px;
  padding: 30px;
  place-content: center;
  text-align: center;
}

.empty-title {
  font: 700 1.2rem "Manrope", sans-serif;
}

.empty-copy {
  max-width: 300px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

@media (max-width: 1050px) {
  .topbar {
    grid-template-columns: 1fr minmax(300px, 1fr);
  }

  .api-status {
    display: none;
  }

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

  .details-panel {
    min-height: auto;
  }

  .kpi-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .empty-state {
    min-height: 240px;
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 10px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 14px;
    border-radius: 18px;
  }

  .brand-subtitle {
    display: none;
  }

  .workspace {
    min-height: auto;
  }

  .map-panel,
  .details-panel {
    border-radius: 20px;
  }

  .map-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-selector {
    justify-content: flex-start;
  }

  .territory-map {
    height: 62vh;
    min-height: 440px;
  }

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