:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2230;
  --border: rgba(255,255,255,0.07);
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #f0a500;
  --accent2: #3fb68b;
  --red: #e85d4a;
  --blue: #4a9eff;
  --font-display: 'DM Serif Display', serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* HEADER */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 1000;
}

.logo {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text);
  letter-spacing: -0.5px;
}
.logo span { color: var(--accent); }

.layer-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}
.layer-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  transition: all 0.15s;
  white-space: nowrap;
}
.layer-tab.active {
  background: var(--surface2);
  color: var(--text);
}
.layer-tab:hover:not(.active) { color: var(--text); }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-live {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent2);
  border: 1px solid var(--accent2);
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* MAIN LAYOUT */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: 300px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-title {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.search-box {
  position: relative;
}
.search-box input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px 8px 34px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s;
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--muted); }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
}

.kec-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.kec-list::-webkit-scrollbar { width: 4px; }
.kec-list::-webkit-scrollbar-track { background: transparent; }
.kec-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.kec-item {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  border: 1px solid transparent;
  margin-bottom: 4px;
}
.kec-item:hover { background: var(--surface2); }
.kec-item.selected {
  background: var(--surface2);
  border-color: var(--accent);
}

.kec-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.kec-price-main {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 2px;
}
.kec-price-sub {
  font-size: 11px;
  color: var(--muted);
}
.kec-bar {
  height: 3px;
  border-radius: 2px;
  margin-top: 8px;
  background: var(--border);
  overflow: hidden;
}
.kec-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* LEGEND */
.legend-box {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.legend-label {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.legend-gradient {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #3fb68b, #f0a500, #e85d4a);
  margin-bottom: 4px;
}
.legend-range {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
}

/* MAP */
#map {
  flex: 1;
  background: #0d1117;
}

/* DETAIL PANEL */
.detail-panel {
  width: 280px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: none;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.detail-panel.open { display: flex; }
.detail-panel::-webkit-scrollbar { width: 4px; }
.detail-panel::-webkit-scrollbar-thumb { background: var(--border); }

.detail-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  z-index: 1;
}

.detail-hero {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.detail-kec-label {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.detail-kec-name {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 4px;
}
.detail-kec-sub {
  font-size: 12px;
  color: var(--muted);
}

.detail-metrics {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.metric-card {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  border: 1px solid var(--border);
}
.metric-label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.metric-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
}
.metric-note {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.detail-notes {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.detail-notes-title {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.note-tag {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text);
  margin: 0 4px 4px 0;
}

.detail-chart {
  padding: 16px;
}
.detail-chart-title {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}
.bar-label { color: var(--muted); width: 60px; flex-shrink: 0; }
.bar-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.bar-val { font-family: var(--font-mono); font-size: 11px; color: var(--text); min-width: 60px; text-align: right; }

.data-source {
  padding: 12px 16px;
  font-size: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  border-top: 1px solid var(--border);
  line-height: 1.6;
}

/* Leaflet overrides */
.leaflet-container { background: #0d1117; }
.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--surface2) !important; }
.leaflet-control-attribution {
  background: rgba(13,17,23,0.7) !important;
  color: var(--muted) !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }

.custom-tooltip {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  color: var(--text) !important;
  font-family: var(--font-body) !important;
  font-size: 12px !important;
  padding: 8px 12px !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4) !important;
}
.custom-tooltip::before { display: none !important; }

/* status indicator */
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent2);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Trend badges — sidebar & detail hero */
.trend-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}
.trend-up   { background: rgba(63,182,139,0.15); color: var(--accent2); border: 1px solid rgba(63,182,139,0.3); }
.trend-down { background: rgba(232,93,74,0.15);  color: var(--red);     border: 1px solid rgba(232,93,74,0.3); }
.trend-flat { background: rgba(139,148,158,0.12);color: var(--muted);   border: 1px solid rgba(139,148,158,0.25); }

/* Demand section */
.detail-demand {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.detail-poi {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.detail-section-title {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.demand-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.demand-bar-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.demand-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease, background 0.3s;
}
.demand-score {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  min-width: 44px;
  text-align: right;
}
.demand-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

/* POI list */
.poi-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.poi-item:last-child { border-bottom: none; }
.poi-icon { font-size: 13px; flex-shrink: 0; }
.poi-name { font-size: 12px; color: var(--text); flex: 1; }
.poi-dist {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
}

/* Sub-area markers */
.sub-marker {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
}
.sub-marker-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid rgba(13,17,23,0.8);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(74,158,255,0.5);
}
.sub-marker-name {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  background: rgba(22,27,34,0.88);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 5px;
  line-height: 1.3;
  backdrop-filter: blur(4px);
}

/* Visually hidden — in DOM for crawlers, invisible to users */
.seo-content {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 768px) {
  .sidebar { width: 100%; position: absolute; z-index: 900; bottom: 0; height: 40vh; border-right: none; border-top: 1px solid var(--border); }
  .detail-panel { display: none !important; }
  .layer-tabs { display: none; }
}
