/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Tokens ── */
:root {
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --surface2:  #f0f2f5;
  --border:    #e2e5ea;
  --text:      #111318;
  --muted:     #6b7280;
  --accent:    #2563eb;

  --launched:  #16a34a;
  --upcoming:  #d97706;
  --pending:   #4f46e5;
  --ec:        #db2777;
  --mrt-active:#0ea5e9;

  --ccr-bg:#f5f0ff; --ccr-text:#6d28d9; --ccr-border:#ddd6fe;
  --rcr-bg:#eff6ff; --rcr-text:#1d4ed8; --rcr-border:#bfdbfe;
  --ocr-bg:#f0fdf4; --ocr-text:#15803d; --ocr-border:#bbf7d0;

  --panel-w:   340px;
  --header-h:  52px;
  --fbar-h:    44px;
}

/* ── Base ── */
body {
  font-family: 'Inter Tight', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── NAV ── */
header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 200;
}
.nav-left  { display: flex; align-items: center; }
.nav-center{ display: flex; justify-content: center; }
.nav-right { display: flex; align-items: center; justify-content: flex-end; }

.logo {
  font-family: 'Inter Tight', sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.3px;
  color: var(--accent);
  white-space: nowrap;
}
.logo span { color: var(--text); font-weight: 500; }

.header-stats { display: flex; gap: 14px; align-items: center; }
.hstat { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.hstat strong { color: var(--text); font-weight: 600; font-family: 'DM Mono', monospace; }

/* List button in nav (desktop + mobile) */
.nav-list-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  font-family: 'Inter Tight', sans-serif;
  transition: all 0.15s;
}
.nav-list-btn svg { width: 15px; height: 15px; }
.nav-list-btn:hover { color: var(--accent); border-color: var(--accent); background: #eff6ff; }
/* hide on desktop — list is in the sidebar */
@media (min-width: 769px) { .nav-list-btn { display: none; } }

/* ── FILTER BAR ── */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--fbar-h);
  flex-shrink: 0;
  z-index: 190;
  display: flex;
  align-items: center;
  justify-content: center;
}
.filter-bar-inner {
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

/* ── Filter chips ── */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 20px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  transition: all 0.15s;
  font-family: 'Inter Tight', sans-serif;
  white-space: nowrap;
  letter-spacing: 0.1px;
}
.filter-chip .chip-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border); transition: background 0.15s; flex-shrink: 0;
}
.filter-chip:not(.active) { opacity: 0.45; }

/* status active states */
.filter-chip.chip-launched.active { border-color: var(--launched); color: var(--launched); background: #f0fdf4; }
.filter-chip.chip-launched.active .chip-dot { background: var(--launched); }
.filter-chip.chip-upcoming.active { border-color: var(--upcoming); color: var(--upcoming); background: #fffbeb; }
.filter-chip.chip-upcoming.active .chip-dot { background: var(--upcoming); }
.filter-chip.chip-pending.active  { border-color: var(--pending);  color: var(--pending);  background: #eef2ff; }
.filter-chip.chip-pending.active .chip-dot  { background: var(--pending); }

/* MRT chip */
.filter-chip.chip-mrt { opacity: 1; }
.filter-chip.chip-mrt.active { border-color: var(--mrt-active); color: var(--mrt-active); background: #f0f9ff; }
.mrt-icon { width: 14px; height: 14px; flex-shrink: 0; }

/* ── Layout ── */
.main { display: flex; flex: 1; overflow: hidden; position: relative; }
#map  { flex: 1; z-index: 1; }
.leaflet-container { background: #e8ecf0 !important; }

/* ── MRT layer styles (set via Leaflet, but class hooks here) ── */
.mrt-line-popup .leaflet-popup-content-wrapper {
  background: #fff !important;
  border-radius: 8px !important;
  font-size: 12px !important;
  font-family: 'Inter Tight', sans-serif !important;
}

/* ── Desktop sidebar ── */
.panel {
  width: var(--panel-w);
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}
.panel-header { padding: 14px 18px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.panel-header h2 { font-size: 13px; font-weight: 700; color: var(--text); }

.search-wrap { padding: 10px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter Tight', sans-serif;
  outline: none;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

.panel-scroll { overflow-y: auto; flex: 1; }
.panel-scroll::-webkit-scrollbar { width: 4px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── List ── */
.list-section-header {
  padding: 7px 16px;
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); background: var(--surface2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.project-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.project-item:hover  { background: var(--surface2); }
.project-item.selected { background: #eff6ff; border-left: 2px solid var(--accent); }
.item-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.item-tag  { font-size: 10px; padding: 2px 6px; border-radius: 8px; flex-shrink: 0; font-weight: 600; }

/* ── Legend ── */
.legend { padding: 10px 16px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--surface); }
.legend-items { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.legend-item  { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-sq  { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.legend-dia { width: 8px; height: 8px; transform: rotate(45deg); border-radius: 1px; flex-shrink: 0; }

/* ── Badges ── */
.region-badge { display: inline-flex; padding: 2px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-ccr { background: var(--ccr-bg); color: var(--ccr-text); border: 1px solid var(--ccr-border); }
.badge-rcr { background: var(--rcr-bg); color: var(--rcr-text); border: 1px solid var(--rcr-border); }
.badge-ocr { background: var(--ocr-bg); color: var(--ocr-text); border: 1px solid var(--ocr-border); }
.type-badge { display: inline-flex; padding: 2px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.ec-badge   { background: #fdf2f8; color: var(--ec); border: 1px solid #fbcfe8; }

/* ── Popup ── */
.leaflet-popup-content-wrapper {
  background: var(--surface) !important; border: 1px solid var(--border) !important;
  border-radius: 10px !important; box-shadow: 0 4px 20px rgba(0,0,0,0.1) !important;
  color: var(--text) !important; padding: 0 !important;
}
.leaflet-popup-content { margin: 0 !important; padding: 11px 13px !important; min-width: 170px; font-family: 'Inter Tight', sans-serif; }
.leaflet-popup-tip { background: var(--surface) !important; }
.leaflet-popup-close-button { color: var(--muted) !important; font-size: 16px !important; right:8px !important; top:5px !important; }
.popup-name { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.popup-dev  { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.popup-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.popup-tag  { font-size: 10px; padding: 2px 7px; border-radius: 8px; font-weight: 600; }
.popup-units { font-size: 12px; color: var(--muted); }
.popup-units span { color: var(--text); font-weight: 600; font-family: 'DM Mono', monospace; }

/* ── Detail drawer (mobile) ── */
.detail-drawer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 32px rgba(0,0,0,0.12);
  z-index: 500;
  max-height: 55vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(.32,.72,0,1);
}
.detail-drawer.open { transform: translateY(0); }

.drawer-handle-wrap { padding: 10px 0 4px; display: flex; justify-content: center; cursor: pointer; flex-shrink: 0; }
.drawer-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; }
.drawer-scroll { overflow-y: auto; flex: 1; padding: 0 18px 24px; }
.drawer-scroll::-webkit-scrollbar { display: none; }

/* detail content */
.detail-inner .status-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 12px; margin-bottom: 8px;
}
.detail-inner .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-launched { background: #f0fdf4; color: var(--launched); border: 1px solid #bbf7d0; }
.tag-tblaunch { background: #fffbeb; color: var(--upcoming); border: 1px solid #fde68a; }
.tag-pending  { background: #eef2ff; color: var(--pending);  border: 1px solid #c7d2fe; }

.detail-inner h1 { font-size: 17px; font-weight: 800; line-height: 1.2; margin-bottom: 2px; }
.detail-inner .dev-name { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 12px; }
.meta-card { background: var(--surface2); border-radius: 8px; padding: 8px 10px; border: 1px solid var(--border); }
.meta-label { font-size: 9px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.meta-value { font-size: 14px; font-weight: 600; color: var(--text); font-family: 'DM Mono', monospace; }
.meta-value.big { font-size: 15px; }
.meta-value.region { font-family: 'Inter Tight', sans-serif; font-size: 13px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.info-row { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--muted); min-width: 96px; flex-shrink: 0; font-size: 12px; }
.info-val   { color: var(--text); line-height: 1.4; }

/* ── List drawer (mobile) ── */
.list-drawer {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 72vh;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 32px rgba(0,0,0,0.12);
  z-index: 500;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(.32,.72,0,1);
}
.list-drawer.open { transform: translateY(0); }

.list-drawer-header {
  padding: 4px 16px 10px; border-bottom: 1px solid var(--border);
  flex-shrink: 0; display: flex; flex-direction: column; gap: 8px;
}
.list-drawer-header span { font-size: 14px; font-weight: 700; color: var(--text); }
.list-drawer-scroll { overflow-y: auto; flex: 1; }
.list-drawer-scroll::-webkit-scrollbar { display: none; }

/* ── Scrim ── */
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.25); z-index: 400; }
.scrim.active { display: block; }

/* ── Desktop: hide mobile-only elements ── */
@media (min-width: 769px) {
  .detail-drawer  { display: none !important; }
  .list-drawer    { display: none !important; }
  .scrim          { display: none !important; }
  .header-stats   { display: flex; }
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .panel          { display: none; }
  .header-stats   { display: none; }
  .main           { flex: 1; }
  .detail-drawer  { display: flex; }
  .list-drawer    { display: flex; }
}
