/* ============================================================
   WebGIS PSU Jalan – Dinas Perumahan Rakyat Kab. Ngawi
   Design: Professional Government GIS Dashboard
   Koreksi & Penyempurnaan
   ============================================================ */

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

:root {
  --brand-dark:   #0f2942;
  --brand-mid:    #1a4a7a;
  --brand-accent: #e8a020;
  --road-red:     #e74c3c;
  --road-orange:  #f39c12;
  --road-green:   #27ae60;
  --road-grey:    #95a5a6;   /* FIX: tambah warna untuk kondisi unknown */
  --kel-blue:     #2980b9;
  --surface:      #ffffff;
  --surface-dim:  #f0f4f8;
  --text-main:    #1a2a3a;
  --text-muted:   #6b7c8d;
  --shadow-sm:    0 2px 8px rgba(0,0,0,.12);
  --shadow-md:    0 4px 20px rgba(0,0,0,.18);
  --radius:       10px;
  --font:         'Plus Jakarta Sans', 'Segoe UI', sans-serif;
  --mono:         'JetBrains Mono', monospace;
  --topbar-h:     62px;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: #e8edf2;
  overflow: hidden; /* FIX: cegah scroll di luar peta */
}

/* ============ TOPBAR ============ */
.topbar {
  height: var(--topbar-h);
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-mid) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
  position: relative;
  z-index: 1100;
  flex-shrink: 0; /* FIX: pastikan topbar tidak menyusut */
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  height: 42px;
  width: 42px;
  object-fit: contain;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  padding: 3px;
  flex-shrink: 0;
}

.topbar-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.title-main {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .02em;
  color: #fff;
  white-space: nowrap;
}

.title-sub {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  padding: 6px 12px;
  transition: background .2s;
}

.stat-chip:hover { background: rgba(255,255,255,.2); }

.stat-icon { font-size: 16px; }

.stat-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.stat-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255,255,255,.65);
}

.stat-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-accent);
  font-family: var(--mono);
}

/* ============ MAP ============ */
#map {
  position: absolute;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
}

/* ============ LEAFLET OVERRIDES ============ */
/* FIX: posisi zoom control kanan atas agar tidak tumpang-tindih legenda */
.leaflet-top.leaflet-right { top: 12px !important; right: 12px !important; }

.leaflet-control-zoom a {
  font-size: 16px !important;
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  border-radius: 6px !important;
  color: var(--brand-dark) !important;
  font-weight: 700 !important;
}

.leaflet-bar {
  border-radius: 8px !important;
  border: none !important;
  box-shadow: var(--shadow-md) !important;
  overflow: hidden;
}

.leaflet-bar a:first-child { border-radius: 8px 8px 0 0 !important; }
.leaflet-bar a:last-child  { border-radius: 0 0 8px 8px !important; }
.leaflet-bar a:only-child  { border-radius: 8px !important; }

.leaflet-control-scale-line {
  background: rgba(255,255,255,.9);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  border-color: var(--brand-mid) !important;
}

/* FIX: skala di kanan bawah tidak tumpang-tindih basemap switcher */
.leaflet-bottom.leaflet-right {
  bottom: 10px !important;
  right: 200px !important; /* geser ke kiri dari layer panel */
}

/* Geser legenda ke atas agar tidak menutupi tombol basemap switcher */
.leaflet-bottom.leaflet-left {
  bottom: 180px !important;
}

/* ============ INFO PANEL ============ */
#info-panel {
  position: absolute;
  top: calc(var(--topbar-h) + 14px);
  right: 14px;
  width: 300px;
  max-height: calc(100vh - var(--topbar-h) - 28px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 1050;
  animation: slideIn .25s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.info-header {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand-mid));
  color: #fff;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
  position: sticky;
  top: 0;
}

#info-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 230px;
}

.btn-close {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
.btn-close:hover { background: rgba(255,255,255,.4); }

#info-content {
  padding: 14px;
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.7;
}

#info-content .row-attr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--surface-dim);
}
#info-content .row-attr:last-child { border-bottom: none; }

#info-content .attr-key {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  flex-shrink: 0;
}
#info-content .attr-val {
  font-weight: 600;
  color: var(--text-main);
  text-align: right;
  word-break: break-word;
}

/* ============ BADGE KONDISI ============ */
.badge-kondisi {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

/* FIX: class names disesuaikan dengan output badgeKondisi() di script.js */
.badge-baik         { background: #e8f8f0; color: #1a8c4e; }
.badge-rusak-ringan { background: #fff3cd; color: #b45309; }
.badge-rusak-sedang { background: #fefce8; color: #92400e; }
.badge-rusak-berat  { background: #fde8e8; color: #c0392b; }
.badge-unknown      { background: #ecf0f1; color: #7f8c8d; }

.hidden { display: none !important; }

/* ============ BASEMAP SWITCHER ============ */
#basemap-switcher {
  position: absolute;
  bottom: 40px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 1000;
}

.bm-btn {
  width: 40px;
  height: 40px;
  border: 2px solid #fff;
  border-radius: 8px;
  background: var(--surface);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.bm-btn:hover  { transform: scale(1.1); box-shadow: var(--shadow-md); }
.bm-btn.active {
  background: var(--brand-mid);
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(232,160,32,.3);
}

/* ============ LAYER PANEL ============ */
#layer-panel {
  position: absolute;
  bottom: 44px;
  right: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 14px 12px;
  box-shadow: var(--shadow-md);
  z-index: 900;
  min-width: 180px;
  transition: opacity .2s, z-index 0s;
}
#layer-panel.behind {
  z-index: 800;
  opacity: .55;
  pointer-events: none;
}

.lp-header {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--surface-dim);
}

.lp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  padding: 5px 0;
  user-select: none;
  transition: color .15s;
}
.lp-item:hover { color: var(--brand-mid); }
.lp-item input { cursor: pointer; accent-color: var(--brand-mid); }

.lp-swatch {
  width: 28px;
  height: 6px;
  border-radius: 3px;
  flex-shrink: 0;
}
.jalan-sw  { background: linear-gradient(90deg, var(--road-green), var(--road-orange), var(--road-red)); }
.kel-sw    { background: var(--kel-blue); opacity: .6; }
.fasum-sw  { width: 10px; height: 10px; border-radius: 50%; background: var(--road-green); }

/* ============ LEGEND (Leaflet control) ============ */
.map-legend {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  color: var(--text-main);
  min-width: 170px;
  max-height: calc(100vh - var(--topbar-h) - 120px);
  overflow-y: auto;
}

.map-legend h4 {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--surface-dim);
}

/* FIX: tambahkan sub-section header di legenda */
.legend-section {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--brand-mid);
  margin: 8px 0 4px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-weight: 600;
  font-size: 11.5px;
}

.lg-line {
  width: 28px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
  display: inline-block;
}
.lg-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.lg-poly {
  width: 20px;
  height: 14px;
  border-radius: 3px;
  border: 2px solid;
  flex-shrink: 0;
  display: inline-block;
}
/* Garis putus-putus untuk batas kelurahan */
.lg-dashed {
  width: 28px;
  height: 0;
  border-top: 3px dashed;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

/* ============ TOOLTIP JALAN ============ */
.jalan-tooltip.leaflet-tooltip {
  background: rgba(15,41,66,.92) !important;
  border: none !important;
  color: #fff !important;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px !important;
  border-radius: 6px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.25) !important;
  white-space: nowrap;
}
/* FIX: sembunyikan panah tooltip default Leaflet */
.jalan-tooltip.leaflet-tooltip::before,
.leaflet-tooltip-left.jalan-tooltip::before,
.leaflet-tooltip-right.jalan-tooltip::before {
  display: none !important;
}

/* ============ LOADING ============ */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,41,66,.88);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .4s ease;
}

.loading-box {
  background: #fff;
  border-radius: 16px;
  padding: 36px 52px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,.3);
}

.loading-box p {
  margin-top: 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e0e7ef;
  border-top-color: var(--brand-mid);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ JALAN CARD (info panel khusus jalan) ============ */
.jalan-card {
  padding: 0 0 6px;
  overflow: hidden;
}

.jc-strip {
  height: 5px;
  border-radius: 0 0 4px 4px;
  margin: 0 14px 12px;
}

.jc-badge-wrap {
  padding: 0 14px 6px;
}

.jc-nama {
  font-size: 15px;
  font-weight: 800;
  color: var(--brand-dark);
  line-height: 1.35;
  padding: 0 14px 12px;
  letter-spacing: -0.01em;
}

.jc-divider {
  height: 1px;
  background: var(--surface-dim);
  margin: 0 14px 10px;
}

.jc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  transition: background .12s;
}
.jc-row:hover { background: var(--surface-dim); }

.jc-row-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}

.jc-row-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  flex: 1;
  white-space: nowrap;
}

.jc-row-val {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  text-align: right;
  word-break: break-word;
  max-width: 130px;
}

.jc-panjang-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 14px 4px;
  background: var(--surface-dim);
  border-radius: 10px;
  padding: 10px 14px;
  border-left: 4px solid;
}

.jc-panjang-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.jc-panjang-val {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--mono);
  letter-spacing: -.02em;
}

/* ============ TOAST NOTIFICATION ============ */
/* FIX: tambah komponen notifikasi untuk error handling */
.toast-notif {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--brand-dark);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}
.toast-notif.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-notif.toast-error { background: #c0392b; }
.toast-notif.toast-info  { background: var(--brand-mid); }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .topbar-right { display: none; }
  .title-sub    { display: none; }

  #info-panel {
    width: calc(100vw - 28px);
    right: 14px;
    max-height: 45vh;
  }

  /* FIX: geser layer panel & basemap agar tidak tumpang-tindih di mobile */
  #layer-panel      { bottom: 90px; right: 10px; min-width: 160px; }
  #basemap-switcher { bottom: 90px; left: 10px; }

  .map-legend { max-height: 200px; font-size: 11px; }

  .leaflet-bottom.leaflet-right { right: 10px !important; bottom: 10px !important; }
}

@media (max-width: 480px) {
  .topbar { padding: 0 10px; }
  .title-main { font-size: 13px; }
  #info-panel { top: calc(var(--topbar-h) + 8px); }
}

/* ============================================================
   SEARCH BOX
   ============================================================ */
#search-box {
  position: absolute;
  top: calc(var(--topbar-h) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1050;
  width: 340px;
  max-width: calc(100vw - 28px);
}

.search-inner {
  display: flex;
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0 12px;
  height: 42px;
  gap: 8px;
  border: 2px solid transparent;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.search-inner:focus-within {
  border-color: var(--brand-accent);
  box-shadow: 0 4px 24px rgba(232,160,32,.22);
}

.search-icon {
  font-size: 16px;
  flex-shrink: 0;
  opacity: .7;
}

#search-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-main);
  background: transparent;
}

#search-input::placeholder { color: var(--text-muted); }

.search-clear {
  background: var(--surface-dim);
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}

.search-clear:hover { background: #dde3ea; }

.search-results {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin-top: 6px;
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
}

.search-results li {
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid #f0f4f8;
  transition: background .12s;
}

.search-results li:last-child { border-bottom: none; }

.search-results li:hover, .search-results li.active {
  background: #eef3fa;
}

.sr-nama {
  font-weight: 600;
  color: var(--text-main);
}

.sr-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.sr-kondisi-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  margin-top: 2px;
}

.search-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ============================================================
   KOORDINAT & FOTO pada Info Panel
   ============================================================ */
.jc-coord-box {
  margin: 8px 10px 2px;
  background: #f8fafb;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.jc-coord-title {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 5px;
  display: block;
}

.jc-coord-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.jc-coord-label {
  font-size: 10.5px;
  width: 48px;
  flex-shrink: 0;
  color: #8899aa;
}

.jc-coord-val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-main);
  flex: 1;
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 4px;
  transition: background .15s;
}

.jc-coord-val:hover { background: #dde8f5; }

.jc-coord-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 5px 0;
}

/* Foto jalan */
.jc-foto-box {
  margin: 8px 10px 10px;
}

.jc-foto-title {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.jc-foto-img {
  width: 100%;
  border-radius: 8px;
  object-fit: cover;
  max-height: 160px;
  display: block;
  cursor: pointer;
  transition: transform .15s ease;
  border: 1px solid #e2e8f0;
}

.jc-foto-img:hover { transform: scale(1.02); }

.jc-foto-placeholder {
  background: #f0f4f8;
  border: 2px dashed #c8d4e0;
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

.jc-foto-placeholder span { display: block; font-size: 24px; margin-bottom: 4px; }

/* Foto lightbox */
#foto-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

#foto-lightbox img {
  max-width: 90vw;
  max-height: 88vh;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}

#foto-lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Responsive: on smaller screens move search box */
@media (max-width: 600px) {
  #search-box {
    left: 14px;
    right: 14px;
    transform: none;
    width: auto;
  }
}

/* ============================================================
   CAROUSEL FOTO (multi-foto per ruas)
   ============================================================ */
.jc-foto-count {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 4px;
}

.jc-carousel {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #f0f4f8;
}

.jc-carousel-track {
  position: relative;
  width: 100%;
}

.jc-carousel-slide {
  display: none;
}

.jc-carousel-slide.active {
  display: block;
}

.jc-carousel .jc-foto-img {
  border-radius: 0;
  border: none;
  margin: 0;
}

/* Tombol prev/next */
.jc-carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15,41,66,.55);
  border: none;
  color: #fff;
  font-size: 22px;
  width: 30px;
  height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background .15s;
  border-radius: 4px;
}

.jc-carousel-btn:hover { background: rgba(15,41,66,.85); }
.jc-carousel-btn.prev  { left: 0; border-radius: 0 4px 4px 0; }
.jc-carousel-btn.next  { right: 0; border-radius: 4px 0 0 4px; }

/* Dots indikator */
.jc-carousel-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 6px 0 4px;
  background: #f8fafb;
}

.jc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c8d4e0;
  cursor: pointer;
  transition: background .2s, transform .2s;
}

.jc-dot.active {
  background: var(--brand-mid);
  transform: scale(1.25);
}

/* Counter x/n */
.jc-carousel-counter {
  text-align: center;
  font-size: 10.5px;
  color: var(--text-muted);
  padding-bottom: 5px;
  background: #f8fafb;
  font-family: var(--mono);
}

/* ── LIGHTBOX update: navigasi ─────────────────────────────── */
.lb-nav {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0,0,0,.45);
  border-radius: 30px;
  padding: 6px 18px;
}

.lb-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  opacity: .85;
  transition: opacity .15s;
}

.lb-btn:hover { opacity: 1; }

.lb-counter {
  color: #fff;
  font-size: 13px;
  font-family: var(--mono);
  min-width: 50px;
  text-align: center;
}

/* ── BREAKDOWN KONDISI PANEL ─────────────────────────────────────── */
.breakdown-wrap {
  padding: 4px 0;
}

.bk-bar-stack {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}

.bk-bar-seg {
  height: 100%;
  transition: opacity .2s;
}

.bk-bar-seg:hover { opacity: .8; }

.bk-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.bk-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text);
  padding: 7px 10px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.bk-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
}

.bk-label {
  font-weight: 600;
  color: var(--text);
}

.bk-count {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text);
}

.bk-panjang {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}

.bk-pct {
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
  min-width: 40px;
  text-align: right;
}

.bk-total {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
}

/* Badge warna fix untuk rusak ringan & sedang */
.badge-rusak-ringan { background: #fffbe6; color: #7d6008; }
.badge-rusak-sedang { background: #fff3e0; color: #7d3c00; }

/* Stat chip clickable hint */
.stat-chip[data-stat] {
  position: relative;
  transition: box-shadow .2s, transform .15s;
}
.stat-chip[data-stat]::after {
  content: '↗';
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 9px;
  opacity: .45;
  pointer-events: none;
}
.stat-chip[data-stat]:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  transform: translateY(-1px);
}

/* ── LEGENDA FASILITAS UMUM (grid rapi) ─────────────────────────── */
.lg-fasum-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 4px;
}

/* Alias untuk list layout (dipakai di buildLegendHTML baru) */
.lg-fasum-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 4px;
}

.lg-fasum-item,
.lg-fasum-item-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 7px;
  background: var(--surface-dim, #f4f6f9);
  transition: background .15s;
}
.lg-fasum-item:hover { background: var(--surface-hover, #eaf0fb); }

.lg-fasum-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid;
  font-size: 14px;
  flex-shrink: 0;
}

.lg-fasum-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

/* ── BREAKDOWN FASILITAS UMUM ─────────────────────────────────────── */
.bk-fasum-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.bk-fasum-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface);
  border-radius: 9px;
  border: 1px solid var(--border);
  transition: background .15s;
}

.bk-fasum-card:hover {
  background: var(--surface-dim, #f4f6f9);
}

.bk-fasum-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 17px;
  flex-shrink: 0;
}

.bk-fasum-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bk-fasum-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.bk-fasum-count {
  font-size: 11px;
  font-weight: 600;
}

.bk-fasum-pct {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

/* ── METRIC ROW (Panjang + Lebar berdampingan) ──────────────────── */
.jc-metrics-row {
  display: flex;
  gap: 8px;
  margin: 10px 14px 4px;
}

.jc-metric-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--surface-dim);
  border-radius: 10px;
  padding: 10px 10px 8px;
  border: 1px solid;
}

.jc-metric-icon {
  font-size: 16px;
  line-height: 1;
}

.jc-metric-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.jc-metric-val {
  font-size: 17px;
  font-weight: 800;
  font-family: var(--mono);
  letter-spacing: -.02em;
}
