:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #c8102e;        /* merah */
  --brand-700: #9b0b22;
  --accent: #0ea5e9;
  --ring: rgba(14,165,233,.35);
  --shadow: 0 10px 30px rgba(15,23,42,.12);
  --radius: 14px;
  font-synthesis-weight: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--panel-2);
  overflow: hidden;
}

#app { display: flex; height: 100vh; width: 100vw; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 360px;
  flex: 0 0 360px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  z-index: 1200;
}
.side-head {
  padding: 18px 18px 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-700));
  color: #fff;
}
.side-head h1 { font-size: 18px; margin: 0; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; }
.side-head p { margin: 6px 0 0; font-size: 12.5px; opacity: .92; }
.side-head .badge {
  display: inline-block; margin-top: 10px; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.18); padding: 3px 9px; border-radius: 999px;
}

.stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
  background: var(--line); border-bottom: 1px solid var(--line);
}
.stat { background: var(--panel); padding: 11px 14px; }
.stat .num { font-size: 18px; font-weight: 800; color: var(--brand); line-height: 1; }
.stat .lbl { font-size: 10.5px; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .04em; }

.controls { padding: 12px 16px 6px; border-bottom: 1px solid var(--line); }
.search-wrap { position: relative; }
#search {
  width: 100%; padding: 10px 12px 10px 34px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 14px; outline: none; background: var(--panel-2);
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); background: #fff; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.metric-row { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.metric-row label { font-size: 12px; color: var(--muted); }
#metric { flex: 1; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: var(--panel-2); }

#breadcrumb {
  padding: 9px 16px; font-size: 12.5px; color: var(--muted);
  border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}
#breadcrumb a { color: var(--accent); cursor: pointer; text-decoration: none; font-weight: 600; }
#breadcrumb a:hover { text-decoration: underline; }
#breadcrumb .sep { color: #cbd5e1; }

#list { flex: 1; overflow-y: auto; padding: 6px 8px 12px; }
.list-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer; font-size: 13.5px;
}
.list-item:hover { background: var(--panel-2); }
.list-item .name { font-weight: 600; }
.list-item .sub { font-size: 11px; color: var(--muted); font-weight: 400; }
.list-item .count {
  font-size: 11px; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--line); padding: 2px 7px; border-radius: 999px; white-space: nowrap;
}
.list-empty { padding: 20px 12px; color: var(--muted); font-size: 13px; text-align: center; }

.side-foot { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.side-foot a { color: var(--accent); text-decoration: none; }

/* ---------- Map ---------- */
#map { flex: 1; height: 100%; background: #aadaff; }
.leaflet-container { font-family: inherit; }

.legend {
  background: rgba(255,255,255,.95); padding: 10px 12px; border-radius: 10px;
  box-shadow: var(--shadow); font-size: 12px; line-height: 1.5; color: var(--ink);
}
.legend h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.legend i { width: 16px; height: 12px; display: inline-block; margin-right: 6px; border-radius: 2px; vertical-align: -1px; }

/* Info panel for a selected feature */
#info {
  position: absolute; right: 12px; top: 12px; width: 300px; max-width: calc(100% - 24px);
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 1100; overflow: hidden; display: none;
}
#info.show { display: block; }
#info .ih { background: linear-gradient(135deg, var(--accent), #0369a1); color: #fff; padding: 12px 14px; position: relative; }
#info .ih .t { font-size: 15px; font-weight: 800; }
#info .ih .s { font-size: 12px; opacity: .9; margin-top: 2px; }
#info .close { position: absolute; right: 10px; top: 10px; cursor: pointer; opacity: .85; font-size: 18px; line-height: 1; }
#info .ib { padding: 6px 14px 14px; max-height: 50vh; overflow-y: auto; }
#info .kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
#info .kv:last-child { border-bottom: 0; }
#info .kv .k { color: var(--muted); }
#info .kv .v { font-weight: 600; text-align: right; }

.map-loading {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  background: rgba(15,23,42,.88); color: #fff; padding: 8px 16px; border-radius: 999px;
  font-size: 12.5px; z-index: 1150; box-shadow: var(--shadow); display: none; align-items: center; gap: 8px;
}
.map-loading.show { display: flex; }
.spinner { width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile */
#menu-toggle { display: none; }
@media (max-width: 820px) {
  #sidebar {
    position: absolute; left: 0; top: 0; height: 100%; width: 86%; max-width: 360px;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  #sidebar.open { transform: translateX(0); }
  #menu-toggle {
    display: flex; position: absolute; left: 12px; top: 12px; z-index: 1300;
    background: var(--brand); color: #fff; border: 0; width: 44px; height: 44px;
    border-radius: 12px; font-size: 20px; cursor: pointer; box-shadow: var(--shadow);
    align-items: center; justify-content: center;
  }
  #info { top: 66px; }
}

/* ---------- Daftar: tombol yang dapat diakses keyboard ---------- */
button.list-item {
  width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
button.list-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.list-item .sub { display: block; margin-top: 2px; }
.list-item.undef .name { color: var(--muted); font-style: italic; font-weight: 500; }
.list-head {
  padding: 10px 12px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); background: var(--panel-2);
}
.side-foot .disclaimer { margin: 0 0 6px; color: #92400e; }

/* ---------- Notifikasi ---------- */
#toast {
  position: absolute; left: 50%; top: 14px; transform: translate(-50%, -20px); z-index: 1100;
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Seluler: beri ruang untuk tombol menu agar tidak menutupi judul sidebar. */
@media (max-width: 820px) {
  .side-head { padding-left: 72px; min-height: 76px; }
}
