:root {
  --bg: #0B1220;
  --panel: #131B2E;
  --panel-2: #182238;
  --border: #253251;
  --text: #E8EDF6;
  --muted: #8B98B8;
  --accent: #2FB6C4;
  --accent-soft: rgba(47, 182, 196, 0.14);
  --lancar: #3FB27F;
  --padat: #E8A93B;
  --macet: #E15A52;
  --unknown: #55617E;
  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  height: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #1C7F8A);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  color: #06171A;
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.25;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }

.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.nav-item.active .nav-dot { background: var(--accent); }

.status-box {
  margin-top: auto;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-row { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.status-label { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: 12px; }

.pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
}
.pill-on { background: rgba(63, 178, 127, .15); color: var(--lancar); }
.pill-off { background: rgba(225, 90, 82, .15); color: var(--macet); }

.legend {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.legend-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 3px 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-lancar { background: var(--lancar); }
.dot-padat { background: var(--padat); }
.dot-macet { background: var(--macet); }
.dot-unknown { background: var(--unknown); }
.dot-map { background: var(--accent); }
.dot-cluster { background: var(--padat); }
.dot-report { background: #9C8CF0; }
.dot-grafik { background: #F43F5E; }
.dot-notifikasi { background: #10B981; }

/* ===== MAIN ===== */
.main {
  padding: 22px 26px 40px;
  overflow-x: hidden;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.kpi-value { font-family: var(--font-display); font-size: 28px; font-weight: 700; }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-macet .kpi-value { color: var(--macet); }
.kpi-padat .kpi-value { color: var(--padat); }
.kpi-cluster .kpi-value { color: var(--accent); }

.critical-alert {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 10000;
  display: none;
  width: min(430px, calc(100vw - 36px));
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  background: rgba(225, 90, 82, 0.12);
  border: 1px solid rgba(225, 90, 82, 0.45);
  border-left: 4px solid var(--macet);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
}
.critical-alert.active { display: flex; }
.critical-alert-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 50%;
  background: rgba(11, 18, 32, 0.18);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}
.critical-alert-close:hover { background: rgba(11, 18, 32, 0.32); }
.critical-alert-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}
.critical-alert-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--macet);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  flex-shrink: 0;
}
.critical-alert-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 3px;
}
.critical-alert-summary {
  color: #f4c4bf;
  font-size: 12.5px;
  line-height: 1.4;
}
.critical-alert-list {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}
.critical-alert-chip {
  background: rgba(11, 18, 32, 0.55);
  border: 1px solid rgba(225, 90, 82, 0.3);
  border-radius: 999px;
  color: #ffe7e4;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 10px;
  white-space: nowrap;
}

.panel { display: none; }
.panel.active-panel { display: block; }

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
}

.map-card, .side-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

#map {
  width: 100%;
  height: 560px;
  border-radius: 10px;
  overflow: hidden;
}

.side-card h3 { font-family: var(--font-display); font-size: 14px; margin: 4px 0 10px; }
.side-card h3.mt { margin-top: 18px; }

.watchlist { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.watch-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px;
}
.watch-name { font-weight: 500; }
.watch-area { color: var(--muted); font-size: 11px; }
.badge {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .03em;
}
.badge-lancar { background: rgba(63,178,127,.15); color: var(--lancar); }
.badge-padat { background: rgba(232,169,59,.15); color: var(--padat); }
.badge-macet { background: rgba(225,90,82,.15); color: var(--macet); }
.badge-unknown { background: rgba(85,97,126,.2); color: var(--muted); }

.panel-header-row {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.panel-header-row h2 { font-family: var(--font-display); font-size: 19px; margin: 0 0 6px; }
.muted { color: var(--muted); font-size: 13px; max-width: 640px; line-height: 1.5; margin: 0; }

.btn-primary {
  background: var(--accent); color: #06171A; border: none;
  font-family: var(--font-body); font-weight: 700; font-size: 13px;
  padding: 10px 18px; border-radius: 8px; cursor: pointer;
  white-space: nowrap; transition: filter .15s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.cluster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.cluster-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.cluster-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cluster-card-head b { font-family: var(--font-display); font-size: 15px; }
.cluster-meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.cluster-members { display: flex; flex-direction: column; gap: 6px; max-height: 150px; overflow-y: auto; }
.cluster-member { font-size: 12px; display: flex; justify-content: space-between; }
.empty-state { color: var(--muted); font-size: 13px; padding: 30px; text-align: center; }

.table-wrap {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px; overflow-x: auto;
}
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .04em; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.report-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.report-table tr:last-child td { border-bottom: none; }
.dl-link {
  color: var(--accent); text-decoration: none; font-weight: 600; font-size: 12.5px;
  margin-right: 12px;
}
.dl-link:hover { text-decoration: underline; }

/* Leaflet popup theming */
.leaflet-popup-content-wrapper {
  background: var(--panel-2); color: var(--text); border-radius: 10px;
  font-family: var(--font-body);
}
.leaflet-popup-tip { background: var(--panel-2); }
.popup-title { font-family: var(--font-display); font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.popup-row { font-size: 12px; color: var(--muted); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .panel-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .critical-alert,
  .critical-alert.active {
    align-items: flex-start;
    flex-direction: column;
  }
  .critical-alert-list { justify-content: flex-start; }
}

/* ===== LANDING PAGE ===== */
.landing-page {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 85% 15%, rgba(45,212,191,0.10) 0%, transparent 45%),
    radial-gradient(circle at 10% 90%, rgba(225,90,82,0.08) 0%, transparent 40%),
    linear-gradient(160deg, #05070d 0%, #0b1120 60%, #0a0f1c 100%);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.landing-page.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.landing-inner {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 56px;
  max-width: 1080px;
  width: 92%;
  padding: 40px;
}
.landing-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: #6fe0cf;
  margin-bottom: 22px;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2dd4bf;
  animation: live-pulse 2s ease-out infinite;
}
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(45,212,191,0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(45,212,191,0); }
  100% { box-shadow: 0 0 0 0 rgba(45,212,191,0); }
}
.landing-title {
  font-family: "Sora", sans-serif;
  font-weight: 800;
  font-size: clamp(34px, 4.6vw, 54px);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: #f3f7fb;
  margin: 0 0 20px;
}
.landing-title-accent {
  background: linear-gradient(90deg, #2dd4bf, #7ee8dc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.landing-desc {
  font-family: "Inter", sans-serif;
  font-size: 15.5px;
  line-height: 1.75;
  color: #93a3bd;
  max-width: 440px;
  margin: 0 0 32px;
}
.landing-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: #06251f;
  background: linear-gradient(90deg, #2dd4bf, #5eead4);
  border: none;
  padding: 15px 28px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 24px rgba(45,212,191,0.18);
}
.landing-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(45,212,191,0.28);
}
.landing-btn:focus-visible {
  outline: 2px solid #2dd4bf;
  outline-offset: 3px;
}
.landing-btn-arrow { transition: transform 0.2s ease; }
.landing-btn:hover .landing-btn-arrow { transform: translateX(3px); }
.landing-ticker {
  margin-top: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #55627c;
}
.landing-ticker .dot-sep { color: #2dd4bf; }
.landing-graphic {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.node-map {
  width: 100%;
  max-width: 380px;
  height: auto;
  overflow: visible;
}
.node-line {
  stroke: #1e2c47;
  stroke-width: 1.4;
}
.node {
  fill: currentColor;
  animation: node-pulse 6s ease-in-out infinite;
}
.node-a { color: #3FB27F; animation-delay: 0s; }
.node-b { color: #E8A93B; animation-delay: 1.4s; }
.node-c { color: #E15A52; animation-delay: 2.8s; }
@keyframes node-pulse {
  0%, 100% { opacity: 0.5; filter: drop-shadow(0 0 4px currentColor); }
  50%      { opacity: 1; filter: drop-shadow(0 0 10px currentColor); }
}
@media (max-width: 980px) {
  .landing-inner { grid-template-columns: 1fr; text-align: center; gap: 32px; }
  .landing-desc { margin-left: auto; margin-right: auto; }
  .landing-graphic { order: -1; }
  .node-map { max-width: 240px; }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot, .node { animation: none !important; }
}

/* Hotspot Pulse Animation */
.hotspot-pulse {
  animation: pulse-hotspot 2s infinite;
}
@keyframes pulse-hotspot {
  0% { fill-opacity: 0.1; stroke-opacity: 0.5; stroke-width: 2px; }
  50% { fill-opacity: 0.5; stroke-opacity: 1; stroke-width: 4px; }
  100% { fill-opacity: 0.1; stroke-opacity: 0.5; stroke-width: 2px; }
}
.empty-state { padding: 1rem; color: #94a3b8; font-size: 0.9rem; text-align: center; border: 1px dashed #334155; border-radius: 8px; margin-top: 0.5rem; }

/* CCTV Tooltip */
.cctv-tooltip {
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 18px;
  filter: drop-shadow(0px 2px 3px rgba(0,0,0,0.6));
}
.cctv-tooltip::before {
  display: none !important;
}
