:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --sidebar-w: 420px;
  --navbar-h: 72px;
  --menu-h: 56px;
  --border: #e5e7eb;
  --bg-light: #f9fafb;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }
body { overflow: hidden; background: var(--bg-light); color: #111827; }

/* NAVBAR */
.navbar {
  height: var(--navbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: relative;
  z-index: 1000;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}
.top-search {
  flex: 1;
  max-width: 700px;
  margin: 0 40px;
  position: relative;
}
.top-search i {
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
}
.top-search input {
  width: 100%;
  height: 44px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding-left: 45px;
  font-size: 15px;
  transition: all 0.2s;
}
.top-search input:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}
.nav-right { display: flex; gap: 20px; color: #6b7280; font-size: 18px; }
.nav-right i { cursor: pointer; transition: 0.2s; }
.nav-right i:hover { color: var(--primary); }

/* MENU */
.menu {
  height: var(--menu-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 0 24px;
}
.menu a {
  text-decoration: none;
  color: #6b7280;
  font-size: 14px;
  font-weight: 500;
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}
.menu a.active { color: var(--primary); font-weight: 700; }
.menu a.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 2px;
  background: var(--primary);
}

/* MAIN */
.main { display: flex; height: calc(100vh - (var(--navbar-h) + var(--menu-h))); }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  overflow: hidden;
  min-height: 0;
  flex-direction: column;
  z-index: 10;
}
.sidebar-search-area { padding: 20px; border-bottom: 1px solid var(--border); }
.search-box {
  height: 42px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
}
.search-box input {
  border: none; background: transparent; outline: none; width: 100%; font-size: 14px;
}

/* ANALYTICS */
.viewport-analytics {
  max-height: 340px;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 20px;
  border-bottom: 1px solid #f3f4f6;
  background: #fafafa;
}
.viewport-analytics::-webkit-scrollbar { width: 4px; }
.viewport-analytics::-webkit-scrollbar-track { background: transparent; }
.viewport-analytics::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 999px; }
.viewport-analytics::-webkit-scrollbar-thumb:hover { background: #d1d5db; }

.analytics-score {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}
.score-card {
  flex: 1;
  background: white;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 14px;
}
.score-value {
  font-size: 28px;
  font-weight: 800;
  margin-top: 6px;
}
.analytics-section { margin-top: 18px; }
.analytics-title {
  font-size: 13px;
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 10px;
  text-transform: uppercase;
}
.analytics-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.analytics-chip {
  background: white;
  border: 1px solid #eee;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
}

/* CATEGORY CHIP BAR */
#catFilterBar {
  padding: 10px 16px 0;
  border-bottom: 1px solid #f3f4f6;
}
#catFilterBar {
  padding: 10px 0 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#catFilterBar .chip-scroll {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0 12px 10px;
  flex-wrap: nowrap;
  cursor: grab;
  user-select: none;
}
#catFilterBar .chip-scroll:active { cursor: grabbing; }
#catFilterBar .chip-scroll::-webkit-scrollbar { display: none; }
.cat-chip {
  flex-shrink: 0;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  background: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-family: inherit;
  transition: background .15s, color .15s, transform .15s, box-shadow .15s;
}
.cat-chip:hover { opacity: .85; }
.cat-chip.active {
  color: #fff !important;
  transform: scale(1.06);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
#catFilterBadge {
  display: none;
  align-items: center;
  gap: 5px;
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
}

/* RESULTS */
.results { flex: 1; overflow-y: auto; }
.result-item {
  padding: 20px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  display: flex; gap: 16px;
  transition: 0.2s;
}
.result-item:hover { background: #f8faff; }
.result-icon {
  width: 44px; height: 44px;
  background: #eef2ff;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); flex-shrink: 0; font-size: 18px;
}
.result-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; color: #111827; }
.result-address { font-size: 13px; color: #6b7280; line-height: 1.4; margin-bottom: 8px; }
.result-meta { font-size: 12px; color: #9ca3af; font-weight: 500; }

/* MAP */
.map-wrap { flex: 1; position: relative; }
#map { width: 100%; height: 100%; z-index: 1; }

/* MAP CARD */
.map-card {
  position: absolute;
  top: 20px; right: 20px;
  width: 340px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  z-index: 1000;
  display: none;
  overflow: hidden;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }
.map-card-body { padding: 20px; }
.card-close { position: absolute; top: 15px; right: 15px; cursor: pointer; color: #9ca3af; }
.card-footer {
  padding: 15px 20px; background: #f9fafb;
  display: flex; gap: 10px;
}
.btn-main {
  flex: 1; height: 40px; background: var(--primary); color: #fff;
  border: none; border-radius: 8px; font-weight: 600; cursor: pointer;
}
.btn-icon {
  width: 40px; height: 40px; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer;
}

/* CLUSTER */
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(99, 102, 241, 0.8);
  color: white;
}
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(99, 102, 241, 0.4);
}

/* REPORT DRAWER */
#reportDrawer {
  position: fixed;
  top: 0;
  right: -480px;
  width: 480px;
  height: 100vh;
  background: white;
  z-index: 1001;
  overflow-y: auto;
  transition: right .35s cubic-bezier(.4,0,.2,1);
  box-shadow: -8px 0 32px rgba(0,0,0,.12);
}
#reportDrawer.open { right: 0; }

/* Map geser ke kiri saat report terbuka */
.report-open .map-wrap {
  margin-right: 480px;
  transition: margin-right .35s cubic-bezier(.4,0,.2,1);
}
.map-wrap {
  transition: margin-right .35s cubic-bezier(.4,0,.2,1);
}
.report-header {
  padding: 24px;
  border-bottom: 1px solid #f3f4f6;
}
.report-section {
  padding: 24px;
  border-bottom: 1px solid #f3f4f6;
}
.report-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.metric-card {
  padding: 16px;
  border-radius: 12px;
  background: #f9fafb;
}

/* SEARCH HISTORY DROPDOWN */
.search-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
  color: #374151;
}
.search-history-item:hover { background: #f9fafb; }

/* ONBOARDING */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* SPINNER (report loading) */
@keyframes spin { to { transform: rotate(360deg); } }

/* SCORE GAUGE */
.gauge-wrap { text-align: center; }

/* ANALYTICS BAR CHART */
.analytics-section { margin-top: 16px; }

/* SIDEBAR TABS */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  height: 44px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  position: relative;
  transition: color 0.2s;
}

.sidebar-tab:hover { color: var(--primary); background: #f9fafb; }

.sidebar-tab.active {
  color: var(--primary);
  font-weight: 700;
}

.sidebar-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}

/* SIDEBAR PANEL */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Analytics panel — full scroll */
#panelAnalytics {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

#panelAnalytics::-webkit-scrollbar { width: 4px; }
#panelAnalytics::-webkit-scrollbar-track { background: transparent; }
#panelAnalytics::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 999px; }

/* reset viewport-analytics — biarkan panel yang handle scroll */
.viewport-analytics {
  max-height: none;
  overflow-y: visible;
  overflow-x: hidden;
  flex-shrink: 0;
}

/* search dropdown styling */
#searchDropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  z-index: 9999;
  overflow: hidden;
}

/* USER MENU */
.user-menu { position: relative; cursor: pointer; }

.user-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  overflow: hidden;
  border: 2px solid rgba(99,102,241,.2);
  transition: border-color .2s;
}
.user-avatar:hover { border-color: var(--primary); }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px); right: 0;
  width: 220px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  z-index: 9999;
  overflow: hidden;
  animation: fadeIn .15s ease;
}
.user-dropdown.open { display: block; }

.user-dropdown-header {
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
  background: #fafafa;
}
.user-dropdown-name { font-weight: 700; font-size: 14px; color: #111827; margin-bottom: 2px; }
.user-dropdown-email { font-size: 12px; color: #6b7280; margin-bottom: 8px; }

.user-plan-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  background: #eef2ff; color: #4f46e5;
  text-transform: uppercase; letter-spacing: .4px;
}

.user-dropdown-item {
  padding: 11px 16px;
  font-size: 13px;
  color: #374151;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; transition: background .15s;
}
.user-dropdown-item:hover { background: #f9fafb; }
.user-dropdown-item i { color: #9ca3af; font-size: 14px; }
.user-dropdown-item:last-child { color: #ef4444; }
.user-dropdown-item:last-child i { color: #ef4444; }