:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-2: #0b1728;
  --card: rgba(11, 23, 40, 0.82);
  --card-2: rgba(18, 34, 57, 0.9);
  --line: rgba(255, 255, 255, 0.08);
  --text: #e7f0f7;
  --muted: #91a4b8;
  --accent: #77d9b7;
  --accent-2: #50bfb7;
  --warn: #f6c177;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(119, 217, 183, 0.16), transparent 28%),
    radial-gradient(circle at 80% 0%, rgba(80, 191, 183, 0.14), transparent 30%),
    linear-gradient(180deg, var(--bg) 0%, #091420 45%, #07111f 100%);
  color: var(--text);
}

code {
  color: #c7f6e7;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.1rem 0.35rem;
}

.bg-glow {
  position: fixed;
  inset: auto;
  pointer-events: none;
  filter: blur(120px);
  z-index: 0;
}
.bg-glow-a {
  width: 22rem; height: 22rem; left: -6rem; top: 10rem; background: rgba(80, 191, 183, 0.18);
}
.bg-glow-b {
  width: 18rem; height: 18rem; right: -5rem; top: 18rem; background: rgba(119, 217, 183, 0.16);
}

.shell {
  position: relative;
  z-index: 1;
  max-width: none;
  margin: 0;
  padding: 0;
}

.card {
  background: linear-gradient(180deg, rgba(18, 34, 57, 0.88), rgba(11, 23, 40, 0.88));
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  padding: 22px 22px 26px;
}
.hero__topline {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  border: 1px solid rgba(119, 217, 183, 0.2);
  background: rgba(119, 217, 183, 0.1);
  color: #dffcf2;
}
.badge--soft {
  background: rgba(255,255,255,0.04);
  color: #c7d5e6;
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(290px, 0.7fr);
  gap: 18px;
}
.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .24em;
  font-size: 12px;
}
.hero h1,
.side h2 {
  margin: 0;
  line-height: 1.05;
}
.hero h1 {
  font-size: clamp(34px, 5vw, 60px);
  max-width: 14ch;
}
.hero__lead {
  max-width: 72ch;
  color: var(--muted);
  line-height: 1.9;
  margin: 16px 0 0;
  font-size: 15px;
}
.hero__stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}
.stat,
.panel-card,
.toolbar,
.map-wrap,
.side,
.footer {
  border: 1px solid var(--line);
}
.stat {
  border-radius: 18px;
  padding: 16px;
  background: rgba(255,255,255,0.04);
}
.stat__label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}
.stat__value {
  font-size: 26px;
  font-weight: 800;
}
.hero__panel {
  display: grid;
  gap: 14px;
  align-content: start;
}
.panel-card {
  border-radius: 20px;
  background: rgba(255,255,255,0.04);
  padding: 18px;
}
.panel-card--accent {
  background: linear-gradient(180deg, rgba(119, 217, 183, 0.12), rgba(255,255,255,0.04));
}
.panel-card__title {
  color: #ecfff8;
  font-weight: 700;
  margin-bottom: 10px;
}
.panel-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}
.panel-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.legend {
  display: grid;
  gap: 10px;
}
.legend__row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.legend__marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: white;
  background: #77d9b7;
  border: 1px solid rgba(255,255,255,0.18);
}
.legend__marker--site { background: #ff5b5f; }
.legend__marker--building { background: #f59e0b; }
.legend__marker--tomb { background: #a855f7; }
.legend__marker--stone { background: #14b8a6; }
.legend__marker--modern { background: #3b82f6; }
.legend__gradient {
  display: inline-block;
  width: 28px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff4d4f 0%, #fb7185 22%, #f59e0b 45%, #38bdf8 78%, #3b82f6 100%);
  border: 1px solid rgba(255,255,255,0.15);
}

.toolbar {
  margin-top: 18px;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) auto;
  gap: 16px;
  align-items: end;
}
.toolbar label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}
.toolbar input,
.toolbar select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(4, 10, 20, 0.68);
  color: var(--text);
  outline: none;
  padding: 13px 14px;
  font-size: 14px;
}
.toolbar select[multiple] {
  min-height: 128px;
  padding: 10px;
}
.multi-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.toolbar__selects {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.toolbar__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.btn,
.file-btn {
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease, border-color .15s ease;
}
.btn:hover,
.file-btn:hover { transform: translateY(-1px); }
.btn--ghost {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
  color: var(--text);
}
.btn--primary,
.file-btn {
  background: linear-gradient(135deg, rgba(119, 217, 183, 0.95), rgba(80, 191, 183, 0.88));
  color: #052026;
}
.file-btn input { display: none; }

.content-grid {
  display: block;
  margin-top: 0;
}
.map-wrap {
  position: fixed;
  inset: 0;
  overflow: hidden;
  min-height: 100vh;
  padding: 0;
  border-radius: 0;
  z-index: 1;
}
#map {
  width: 100%;
  height: 100vh;
  border-radius: 0;
  overflow: hidden;
}
.map-hint {
  position: absolute;
  left: 24px;
  bottom: 24px;
  z-index: 500;
  background: rgba(4,10,20,0.82);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 10px 14px;
  color: #d8e7f2;
  font-size: 13px;
  max-width: min(560px, calc(100% - 48px));
}
.map-hint.is-hidden { display: none; }
.sidebar-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: min(50vw, 560px);
  height: 100vh;
  padding: 14px;
  display: grid;
  gap: 14px;
  overflow: auto;
  z-index: 1200;
  transform: translateX(calc(-100% - 18px));
  transition: transform .22s ease;
  background: linear-gradient(180deg, rgba(18, 34, 57, 0.94), rgba(11, 23, 40, 0.96));
  border-right: 1px solid var(--line);
  box-shadow: 24px 0 80px rgba(0, 0, 0, 0.35);
  font-size: 12px;
}
body.sidebar-open .sidebar-panel {
  transform: translateX(0);
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 20, 0.52);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
  z-index: 1100;
}
body.sidebar-open .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}
.sidebar-fab {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1300;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(4,10,20,0.82);
  color: #edf8ff;
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 18px 40px rgba(0,0,0,0.26);
}
.sidebar-fab:hover {
  border-color: rgba(119,217,183,0.3);
  background: rgba(10,18,30,0.9);
}

.side {
  padding: 0;
  display: grid;
  gap: 14px;
}
.sidebar-panel .hero h1 {
  font-size: clamp(24px, 2.8vw, 38px);
}
.sidebar-panel .hero__grid,
.sidebar-panel .toolbar,
.sidebar-panel .footer {
  grid-template-columns: 1fr;
}
.sidebar-panel .hero__grid {
  gap: 12px;
}
.sidebar-panel .hero__stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.sidebar-panel .toolbar {
  gap: 12px;
  align-items: stretch;
}
.sidebar-panel .toolbar__selects {
  grid-template-columns: 1fr;
}
.sidebar-panel .toolbar__actions {
  justify-content: stretch;
}
.sidebar-panel .toolbar__actions > * {
  flex: 1 1 auto;
}
.sidebar-panel .hero__lead,
.sidebar-panel .panel-text,
.sidebar-panel .panel-list,
.sidebar-panel .distribution__title,
.sidebar-panel .list-item__meta,
.sidebar-panel .detail__meta {
  font-size: 11px;
}
.sidebar-panel .stat__value {
  font-size: 22px;
}
.sidebar-panel .stat__label,
.sidebar-panel .toolbar label,
.sidebar-panel .toggle-item__label,
.sidebar-panel .legend-item__label {
  font-size: 11px;
}
.sidebar-panel .list-item {
  padding: 10px 12px;
}
.sidebar-panel .detail__title {
  font-size: 18px;
}
.side__header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}
.side__count {
  min-width: 54px;
  text-align: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(119, 217, 183, 0.12);
  border: 1px solid rgba(119, 217, 183, 0.2);
  font-weight: 800;
}
.distribution,
.switch-panel {
  border-radius: 20px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 14px;
}
.distribution__title {
  color: #edf5fb;
  font-weight: 700;
  margin-bottom: 12px;
}
.switch-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.switch-panel__actions {
  display: flex;
  gap: 8px;
}
.switch-btn {
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.04);
  color: #dbe8f2;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.switch-btn:hover {
  border-color: rgba(119,217,183,0.26);
  background: rgba(119,217,183,0.08);
}
.bars,
.toggle-list,
.legend-list {
  display: grid;
  gap: 10px;
}
.bar-row {
  display: grid;
  grid-template-columns: 86px 1fr 42px;
  gap: 8px;
  align-items: center;
}
.bar-row__label {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bar-row__swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2);
  flex: 0 0 auto;
}
.bar-row__track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.bar-row__fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(119,217,183,0.95), rgba(80,191,183,0.65));
}
.bar-row__count {
  text-align: right;
  color: #d6e5f0;
  font-size: 12px;
}
.toggle-item,
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}
.toggle-item__label,
.legend-item__label {
  flex: 1;
  color: #dbe8f2;
  font-size: 13px;
}
.toggle-item__count,
.legend-item__count {
  color: var(--muted);
  font-size: 12px;
}
.toggle-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
.legend-item__swatch {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.18);
  flex: 0 0 auto;
}
.list {
  display: grid;
  gap: 10px;
  max-height: 380px;
  overflow: auto;
  padding-right: 4px;
}
.list::-webkit-scrollbar,
.detail::-webkit-scrollbar { width: 10px; }
.list::-webkit-scrollbar-thumb,
.detail::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 999px; }
.list-item {
  padding: 14px 14px 13px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.list-item:hover {
  transform: translateY(-1px);
  border-color: rgba(119, 217, 183, 0.28);
  background: rgba(119, 217, 183, 0.06);
}
.list-item__title {
  font-weight: 800;
  margin-bottom: 6px;
}
.list-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #dbe8f2;
}
.pill--accent {
  background: rgba(119, 217, 183, 0.12);
  border-color: rgba(119, 217, 183, 0.18);
}
.pill--soft {
  background: rgba(118, 199, 255, 0.1);
  border-color: rgba(118, 199, 255, 0.16);
}
.detail {
  min-height: 180px;
  max-height: 340px;
  overflow: auto;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(119,217,183,0.09), rgba(255,255,255,0.03));
  border: 1px solid rgba(119,217,183,0.14);
  padding: 14px;
}
.detail__empty {
  min-height: 150px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  line-height: 1.8;
  border: 1px dashed rgba(255,255,255,0.09);
  border-radius: 16px;
  background: rgba(255,255,255,0.02);
}
.detail__title {
  font-size: 20px;
  font-weight: 900;
  margin: 0 0 10px;
}
.detail__meta {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}
.detail__desc {
  margin-top: 12px;
  line-height: 1.9;
  color: #d9e7f3;
  white-space: pre-wrap;
}
.footer {
  margin-top: 18px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  color: var(--muted);
  line-height: 1.8;
}
.footer strong {
  display: block;
  color: #edf8f5;
  margin-bottom: 6px;
}

.heritage-marker {
  background: transparent;
  border: none;
}
.heritage-marker__wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transform: translateY(0);
  white-space: nowrap;
}
.heritage-marker__dot {
  width: 7px;
  height: 7px;
  border: none;
  box-shadow: none;
  background: var(--marker-color, #77d9b7);
  flex: 0 0 auto;
}
.heritage-marker__dot--circle {
  border-radius: 50%;
}
.heritage-marker__dot--square {
  border-radius: 2px;
}
.heritage-marker__dot--diamond {
  transform: rotate(45deg);
  border-radius: 2px;
}
.heritage-marker__dot--triangle {
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  border-radius: 0;
}
.heritage-marker__dot--hexagon {
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  border-radius: 0;
}
.heritage-marker__label {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ecf8ff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(4,10,20,0.72);
  border: 1px solid rgba(255,255,255,0.1);
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.leaflet-container {
  background: #07111f;
}
.leaflet-tile-pane {
  filter: brightness(0.72) contrast(1.12) saturate(0.75) sepia(0.08) hue-rotate(180deg);
}
.leaflet-control-attribution,
.leaflet-control-zoom a {
  background: rgba(4,10,20,0.84) !important;
  color: #d8e7f2 !important;
}
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: rgba(4,10,20,0.96);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
}
.leaflet-popup-content {
  margin: 12px 14px;
  line-height: 1.7;
}

@media (max-width: 1280px) {
  .hero__grid,
  .toolbar,
  .footer {
    grid-template-columns: 1fr;
  }
  .hero__stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar__selects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-panel { width: min(50vw, 560px); }
  .map-wrap { min-height: 100vh; }
  #map { height: 100vh; }
}

@media (max-width: 720px) {
  .hero, .toolbar, .footer, .side { border-radius: 20px; }
  .hero { padding: 16px; }
  .hero h1 { font-size: 30px; }
  .hero__stats { grid-template-columns: 1fr 1fr; }
  .toolbar__actions { justify-content: stretch; }
  .toolbar__actions > * { flex: 1 1 auto; }
  .toolbar__selects { grid-template-columns: 1fr; }
  .sidebar-panel { width: min(100vw, 520px); }
  .bar-row { grid-template-columns: 70px 1fr 36px; }
}
