:root {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-elevated: #334155;
  --bg-surface-translucent: rgba(30, 41, 59, 0.85);
  --border-subtle: rgba(148, 163, 184, 0.15);
  --border-strong: rgba(148, 163, 184, 0.3);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --color-brand: #0284c7;
  --color-brand-hover: #0369a1;
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.15);
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.15);
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.15);
  --color-info: #3b82f6;
  --color-info-bg: rgba(59, 130, 246, 0.15);
  --form-green: #10b981;
  --form-blue: #3b82f6;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --header-height: 64px;
  --sidebar-width: 380px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-surface-translucent: rgba(255, 255, 255, 0.9);
  --border-subtle: rgba(148, 163, 184, 0.25);
  --border-strong: rgba(148, 163, 184, 0.5);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
#app-container { display: flex; flex-direction: column; height: 100vh; width: 100vw; overflow: hidden; }
.navbar {
  height: var(--header-height);
  background: var(--bg-surface-translucent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 1000;
  flex-shrink: 0;
}
.nav-brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #0284c7, #10b981);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.25rem;
}
.brand-info h1 { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.brand-info span { font-size: 0.75rem; color: var(--text-muted); }
.nav-tabs {
  display: flex; align-items: center; gap: 0.25rem;
  background: var(--bg-surface-elevated);
  padding: 0.25rem; border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}
.tab-btn {
  background: transparent; border: none;
  color: var(--text-secondary); font-size: 0.85rem; font-weight: 600;
  padding: 0.45rem 1rem; border-radius: var(--radius-full);
  cursor: pointer; display: flex; align-items: center; gap: 0.5rem;
  transition: all var(--transition-fast);
}
.tab-btn.active { background: var(--color-brand); color: #fff; }
.nav-actions { display: flex; align-items: center; gap: 0.75rem; }
.btn-icon {
  background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle);
  color: var(--text-secondary); width: 36px; height: 36px;
  border-radius: var(--radius-md); display: flex; align-items: center;
  justify-content: center; cursor: pointer;
}
.sync-status {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.75rem; color: var(--text-muted);
  background: var(--bg-surface); padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full); border: 1px solid var(--border-subtle);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-success); }
.status-dot.loading { background: var(--color-warning); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.filter-toolbar {
  background: var(--bg-surface); border-bottom: 1px solid var(--border-subtle);
  padding: 0.6rem 1.5rem; display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; flex-wrap: wrap; z-index: 900;
}
.filter-group { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.filter-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
.form-pill-selector { display: flex; background: var(--bg-surface-elevated); padding: 2px; border-radius: var(--radius-md); }
.pill-btn {
  background: transparent; border: none; color: var(--text-secondary);
  font-size: 0.78rem; font-weight: 600; padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm); cursor: pointer;
}
.pill-btn.active { background: var(--bg-surface); color: var(--text-primary); }
.pill-btn.active[data-form="ekoregion_darat"] { color: var(--form-green); }
.pill-btn.active[data-form="sosial_budaya"] { color: var(--form-blue); }
.select-control, .input-control {
  background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle);
  color: var(--text-primary); font-size: 0.8rem; padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md); outline: none; font-family: inherit;
}
.main-content { flex: 1; position: relative; overflow: hidden; }
.tab-pane { position: absolute; inset: 0; display: none; opacity: 0; transition: opacity var(--transition-normal); }
.tab-pane.active { display: flex; opacity: 1; }
.map-view-container { display: flex; width: 100%; height: 100%; position: relative; }
#map { flex: 1; height: 100%; width: 100%; background: #090d16; }
.map-kpi-overlay { position: absolute; top: 1rem; left: 1rem; display: flex; flex-direction: column; gap: 0.6rem; z-index: 1000; pointer-events: none; }
.kpi-mini-card {
  background: var(--bg-surface-translucent); backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: 0.75rem 1.1rem; box-shadow: var(--shadow-lg); pointer-events: auto; min-width: 190px;
}
.kpi-mini-title { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); display: flex; justify-content: space-between; }
.kpi-mini-value { font-size: 1.4rem; font-weight: 800; color: var(--text-primary); margin-top: 0.2rem; }
.kpi-mini-badge { font-size: 0.65rem; font-weight: 700; padding: 2px 6px; border-radius: var(--radius-full); }
.map-layer-control {
  position: absolute; top: 1rem; right: 1rem;
  background: var(--bg-surface-translucent); backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: 0.5rem; box-shadow: var(--shadow-lg); z-index: 1000; display: flex; flex-direction: column; gap: 0.35rem; min-width: 155px;
}
.layer-mode-btn, .basemap-btn {
  background: transparent; border: none; color: var(--text-secondary);
  font-size: 0.75rem; font-weight: 600; padding: 0.38rem 0.7rem;
  border-radius: var(--radius-sm); cursor: pointer; display: flex; align-items: center; gap: 0.5rem; text-align: left;
  transition: all var(--transition-fast);
}
.layer-mode-btn:hover, .basemap-btn:hover { background: var(--bg-surface-elevated); color: var(--text-primary); }
.layer-mode-btn.active { background: var(--bg-surface-elevated); color: var(--text-primary); font-weight: 700; }
.basemap-btn.active { background: var(--color-brand); color: #fff; }

.map-drawer {
  position: absolute; top: 0; right: -460px; width: 460px; max-width: 90vw; height: 100%;
  background: var(--bg-surface); border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg); z-index: 1200; transition: right var(--transition-normal);
  display: flex; flex-direction: column; overflow: hidden;
}
.map-drawer.open { right: 0; }
.drawer-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; background: var(--bg-surface-elevated); }
.drawer-close { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.1rem; }
.drawer-body { flex: 1; padding: 1.25rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1.25rem; }
.detail-section { background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 0.9rem; }
.detail-section-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.6rem; display: flex; align-items: center; gap: 0.4rem; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
.detail-item { display: flex; flex-direction: column; }
.detail-item.full-width { grid-column: span 2; }
.detail-label { font-size: 0.68rem; color: var(--text-muted); }
.detail-value { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); word-break: break-word; }
.detail-photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; margin-top: 0.5rem; }
.photo-thumb { position: relative; width: 100%; height: 110px; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border-subtle); cursor: pointer; background: #000; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-tag { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.75); font-size: 0.62rem; padding: 3px 6px; color: #fff; }
.stats-view-container { width: 100%; height: 100%; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }
.kpi-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.kpi-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 1.25rem; display: flex; align-items: center; gap: 1rem; }
.kpi-card-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }
.kpi-card-content { display: flex; flex-direction: column; }
.kpi-card-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
.kpi-card-value { font-size: 1.6rem; font-weight: 800; color: var(--text-primary); line-height: 1.2; }
.kpi-card-desc { font-size: 0.72rem; color: var(--text-secondary); margin-top: 0.2rem; }
.charts-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1.25rem; }
.chart-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 1.25rem; display: flex; flex-direction: column; }
.chart-col-8 { grid-column: span 8; }
.chart-col-6 { grid-column: span 6; }
.chart-col-4 { grid-column: span 4; }
.chart-col-12 { grid-column: span 12; }
@media (max-width: 1024px) { .chart-col-8, .chart-col-6, .chart-col-4 { grid-column: span 12; } }
.chart-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.chart-title { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 0.5rem; }
.chart-body { position: relative; flex: 1; min-height: 260px; }
.table-view-container { width: 100%; height: 100%; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; overflow: hidden; }
.table-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.table-card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.table-search-box { display: flex; align-items: center; gap: 0.5rem; background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 0.35rem 0.75rem; width: 280px; }
.table-search-box input { background: transparent; border: none; color: var(--text-primary); outline: none; font-size: 0.82rem; width: 100%; }
.btn-primary { background: var(--color-brand); border: none; color: #fff; font-size: 0.8rem; font-weight: 600; padding: 0.45rem 1rem; border-radius: var(--radius-md); cursor: pointer; display: flex; align-items: center; gap: 0.4rem; }
.table-wrapper { flex: 1; overflow: auto; }
.custom-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; text-align: left; }
.custom-table th { background: var(--bg-surface-elevated); padding: 0.75rem 1rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; font-size: 0.7rem; position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--border-subtle); }
.custom-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-subtle); color: var(--text-primary); white-space: nowrap; }
.custom-table tr:hover td { background: var(--bg-surface-elevated); cursor: pointer; }
.badge-form { font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-full); display: inline-flex; align-items: center; gap: 0.3rem; }
.badge-darat { background: var(--color-success-bg); color: var(--color-success); }
.badge-sosial { background: var(--color-info-bg); color: var(--color-info); }
.table-footer { padding: 0.75rem 1.25rem; border-top: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; background: var(--bg-surface-elevated); font-size: 0.75rem; color: var(--text-muted); }
.pagination { display: flex; align-items: center; gap: 0.25rem; }
.page-btn { background: var(--bg-surface); border: 1px solid var(--border-subtle); color: var(--text-secondary); padding: 0.25rem 0.6rem; border-radius: var(--radius-sm); cursor: pointer; }
.lightbox-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); z-index: 9999; display: none; align-items: center; justify-content: center; padding: 2rem; }
.lightbox-modal.open { display: flex; }
.lightbox-content { position: relative; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; }
.lightbox-img { max-width: 100%; max-height: 80vh; border-radius: var(--radius-md); object-fit: contain; }
.lightbox-caption { margin-top: 0.75rem; color: #fff; font-size: 0.9rem; font-weight: 600; }
.lightbox-close { position: absolute; top: -40px; right: 0; background: transparent; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }
.auth-guard { position: fixed; inset: 0; background: var(--bg-primary); z-index: 10000; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 2.5rem; width: 100%; max-width: 400px; text-align: center; }
.auth-icon { width: 56px; height: 56px; background: linear-gradient(135deg, #0284c7, #10b981); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.6rem; margin: 0 auto 1.25rem; }
.leaflet-popup-content-wrapper { background: var(--bg-surface-translucent) !important; backdrop-filter: blur(12px) !important; color: var(--text-primary) !important; border-radius: var(--radius-md) !important; border: 1px solid var(--border-subtle) !important; }
.popup-container { padding: 0.85rem 1rem; min-width: 220px; }
.popup-header { border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.4rem; margin-bottom: 0.5rem; }
.popup-title { font-size: 0.88rem; font-weight: 700; color: var(--text-primary); }
.popup-meta { font-size: 0.72rem; color: var(--text-muted); }
.popup-body { font-size: 0.78rem; display: flex; flex-direction: column; gap: 0.25rem; }
.popup-btn { margin-top: 0.6rem; width: 100%; background: var(--color-brand); color: #fff; border: none; border-radius: var(--radius-sm); padding: 0.35rem 0.5rem; font-size: 0.75rem; font-weight: 600; cursor: pointer; }
.custom-map-pin { transition: transform var(--transition-fast); }
.custom-map-pin:hover { transform: scale(1.25); z-index: 1000 !important; }
