:root {
  --bg: #f5efe3;
  --panel: rgba(245, 239, 227, 0.88);
  --panel-strong: rgba(255, 249, 239, 0.94);
  --ink: #201714;
  --muted: #6f6158;
  --line: rgba(86, 59, 47, 0.16);
  --accent: #c9492f;
  --accent-2: #efc454;
  --active: #d94f3d;
  --paused: #4f8f8b;
  --closed: #7d1f15;
  --shadow: 0 20px 50px rgba(34, 20, 13, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(239, 196, 84, 0.16), transparent 30%),
    radial-gradient(circle at bottom right, rgba(201, 73, 47, 0.12), transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family: "Noto Sans SC", sans-serif;
}

body {
  padding: 18px;
}

.app-shell {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 36px);
}

.sidebar,
.map-stage {
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.sidebar {
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  padding: 22px;
  overflow-y: auto;
}

.hero {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
}

.hero h1 {
  margin: 0;
  font-size: 31px;
  line-height: 1.15;
  font-weight: 800;
}

.lede {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.75;
  color: var(--muted);
}

.metric-grid {
  margin: 18px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(86, 59, 47, 0.1);
  border-radius: 20px;
  padding: 14px 16px;
}

.metric-card .label {
  font-size: 12px;
  color: var(--muted);
}

.metric-card .value {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 800;
}

.panel {
  margin-top: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.44);
  border: 1px solid rgba(86, 59, 47, 0.1);
  border-radius: 22px;
}

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

.panel-head h2,
.map-toolbar h2 {
  margin: 0;
  font-size: 18px;
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}

.field select,
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(86, 59, 47, 0.12);
  background: rgba(255, 255, 255, 0.85);
  font: inherit;
  color: var(--ink);
}

.ghost-btn,
.chip {
  border: 1px solid rgba(86, 59, 47, 0.14);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  font: inherit;
}

.ghost-btn:hover,
.chip:hover,
.chip.is-active {
  background: linear-gradient(90deg, rgba(201, 73, 47, 0.14), rgba(239, 196, 84, 0.24));
  border-color: rgba(201, 73, 47, 0.28);
}

.chip-row,
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle-row {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.ranking {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ranking-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.ranking-item .meta {
  min-width: 0;
}

.ranking-item .name {
  font-weight: 700;
}

.ranking-item .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.ranking-item .bar {
  margin-top: 8px;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(86, 59, 47, 0.08);
}

.ranking-item .bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
}

.detail-panel {
  margin-bottom: 18px;
}

.detail-empty {
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

.detail-list {
  display: grid;
  gap: 10px;
  font-size: 14px;
}

.detail-list strong {
  color: var(--muted);
}

.map-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: #f7f2e8;
}

.map-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 249, 239, 0.88), rgba(255, 249, 239, 0.54));
}

.map-toolbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot.active { background: var(--active); }
.dot.paused { background: var(--paused); }
.dot.closed { background: var(--closed); }

#map {
  min-height: 720px;
}

.maplibregl-popup-content {
  background: rgba(255, 251, 244, 0.98);
  color: var(--ink);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 18px 40px rgba(34, 20, 13, 0.18);
  font-family: "Noto Sans SC", sans-serif;
}

.popup-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 800;
}

.popup-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

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

  .sidebar {
    max-height: none;
  }

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