:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0f172a;
  background: #e2e8f0;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body, #root { width: 100%; height: 100%; margin: 0; }
button, input, select { font: inherit; }
.app-shell { width: 100%; height: 100%; position: relative; overflow: hidden; }
#map { width: 100%; height: 100%; background: #dbeafe; }
.floating-panel {
  position: absolute; z-index: 1000; background: rgba(255,255,255,.97);
  border: 1px solid rgba(148,163,184,.4); border-radius: 15px;
  box-shadow: 0 12px 34px rgba(15,23,42,.22); overflow: auto;
  resize: both; min-width: 280px; min-height: 54px;
}
.main-panel { left: 12px; top: 12px; width: 370px; max-height: calc(100vh - 24px); }
.layer-panel { right: 12px; top: 12px; width: 390px; max-height: 44vh; }
.importance-panel { right: 12px; bottom: 12px; width: 390px; height: 330px; }
.detail-panel { left: 398px; bottom: 12px; width: 390px; max-height: 310px; }
.panel-header {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center;
  justify-content: space-between; gap: 8px; padding: 12px 13px 8px;
  background: rgba(255,255,255,.98); border-bottom: 1px solid #eef2f7;
}
.panel-header h1, .panel-header h2 { margin: 0; font-size: 15px; line-height: 1.25; }
.panel-body { padding: 10px 13px 13px; }
.panel-collapsed { width: 280px !important; height: auto !important; min-height: 0; resize: none; }
.panel-collapsed .panel-body { display: none; }
.icon-btn { width: 31px; height: 27px; padding: 0; border-radius: 8px; border: 1px solid #cbd5e1; background: #f8fafc; font-weight: 900; cursor: pointer; }
.muted { color: #64748b; font-size: 12px; line-height: 1.45; }
.notice { margin-top: 8px; padding: 8px 9px; border-radius: 9px; font-size: 11px; line-height: 1.4; }
.notice.info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }
.control { margin-top: 11px; padding-top: 10px; border-top: 1px solid #e5e7eb; }
.control.no-border { border-top: 0; padding-top: 0; }
.control label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 850; }
.control input[type="range"] { width: 100%; }
.control input[type="text"], .control select, .search-row input {
  width: 100%; padding: 8px 9px; border: 1px solid #cbd5e1; border-radius: 9px; background: #fff;
}
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segment { border: 1px solid #cbd5e1; border-radius: 9px; padding: 8px 7px; background: #f8fafc; color: #334155; font-weight: 800; cursor: pointer; font-size: 11.5px; }
.segment.active { color: #fff; background: #1d4ed8; border-color: #1d4ed8; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 10px 0 4px; }
.kpi-card { padding: 8px; border: 1px solid #e2e8f0; border-radius: 9px; background: #f8fafc; min-width: 0; }
.kpi-label { color: #64748b; font-size: 10px; }
.kpi-value { margin-top: 2px; font-size: 13px; font-weight: 900; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-value.small { font-size: 11px; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.btn { border: 0; border-radius: 9px; padding: 8px 12px; cursor: pointer; font-weight: 800; font-size: 12px; }
.btn-dark { background: #111827; color: #fff; }
.status-box { margin-top: 10px; padding: 8px 9px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 9px; font-size: 11.5px; line-height: 1.4; }
.toggle-row { display: flex; align-items: center; gap: 8px; margin-top: 13px; font-size: 12px; font-weight: 800; cursor: pointer; }
.toggle-row input { width: 16px; height: 16px; }
.chart-wrap { height: 235px; margin-top: 8px; }
.top-feature-label { margin-top: 6px; padding: 7px 8px; border-radius: 8px; background: #eff6ff; color: #1e3a8a; font-size: 11px; font-weight: 750; }
.detail-title { font-size: 12.5px; font-weight: 900; margin-bottom: 5px; }
.metric-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 7px; }
.metric-table th, .metric-table td { padding: 6px 5px; border-bottom: 1px solid #edf2f7; text-align: left; vertical-align: top; }
.metric-table th { width: 38%; background: #f8fafc; color: #334155; }
.loading-overlay { position: absolute; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(15,23,42,.28); }
.loading-card { padding: 16px 20px; border-radius: 12px; background: white; box-shadow: 0 12px 35px rgba(15,23,42,.28); font-weight: 850; }
.map-badge { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 900; background: rgba(15,23,42,.88); color: white; border-radius: 999px; padding: 8px 13px; font-size: 11px; font-weight: 800; box-shadow: 0 6px 18px rgba(15,23,42,.25); }
@media (max-width: 1050px) {
  .main-panel { width: 340px; }
  .layer-panel, .importance-panel { width: 350px; }
  .detail-panel { left: 12px; bottom: 12px; width: 340px; }
}
@media (max-width: 760px) {
  .main-panel, .layer-panel, .importance-panel, .detail-panel { left: 8px; right: 8px; width: auto; resize: vertical; }
  .main-panel { top: 8px; max-height: 39vh; }
  .layer-panel { top: auto; bottom: 8px; max-height: 34vh; }
  .importance-panel, .detail-panel, .map-badge { display: none; }
}

/* v5: multi-brand layer toggles, outlet popup, and selected-grid driver chart */
.notice.warning { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }
.main-panel { width: 410px; }
.layer-panel { width: 430px; max-height: 56vh; }
.importance-panel { width: 430px; height: 390px; }
.detail-panel { left: 434px; bottom: 12px; width: 650px; max-height: 520px; }
.driver-list { display: grid; gap: 6px; margin-top: 8px; }
.driver-row {
  display: grid; grid-template-columns: 66px 1fr auto; gap: 8px; align-items: center;
  padding: 7px 8px; border: 1px solid #e2e8f0; border-radius: 9px; background: #f8fafc;
  font-size: 11px;
}
.driver-rank { color: #1d4ed8; font-weight: 900; }
.driver-name { color: #334155; line-height: 1.3; }
.driver-value { font-weight: 900; font-variant-numeric: tabular-nums; }
.subheading { margin: 12px 0 4px; font-size: 12px; }
.driver-table { min-width: 100%; }
.driver-table th { width: auto; white-space: nowrap; }
.driver-table td { font-variant-numeric: tabular-nums; }
.layer-toggle-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.toggle-card {
  display: grid; grid-template-columns: auto 12px 1fr; gap: 7px; align-items: center;
  padding: 8px; border: 1px solid #cbd5e1; border-radius: 9px; background: #f8fafc;
  font-size: 11.5px; font-weight: 800; cursor: pointer;
}
.toggle-card input { width: 16px; height: 16px; margin: 0; }
.layer-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.layer-swatch.grid-alfamart { background: #2563eb; }
.layer-swatch.grid-indomaret { background: #dc2626; }
.layer-swatch.outlet-alfamart { background: #2563eb; border-radius: 50%; }
.layer-swatch.outlet-indomaret { background: #dc2626; border-radius: 50%; }
.local-chart-wrap { height: 220px; margin-top: 7px; }
.direction-badge {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 7px;
  font-weight: 850; font-size: 10px; white-space: nowrap;
}
.direction-badge.up { color: #047857; background: #d1fae5; }
.direction-badge.down { color: #b91c1c; background: #fee2e2; }
.outlet-popup { min-width: 220px; font-size: 12px; line-height: 1.55; color: #0f172a; }
.outlet-popup-title { font-size: 13px; font-weight: 900; margin-bottom: 5px; }
.leaflet-popup-content-wrapper { border-radius: 12px; }

@media (max-width: 1200px) {
  .main-panel { width: 370px; }
  .layer-panel, .importance-panel { width: 390px; }
  .detail-panel { left: 394px; width: 560px; }
}


/* v6 raster legend */
.raster-legend-card {
  margin: 12px 0 14px;
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
}

.raster-legend-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.raster-legend-title {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
  color: #0f172a;
}

.raster-owner-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 0.67rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.raster-owner-badge.shared {
  color: #334155;
  background: #e2e8f0;
}

.raster-owner-badge.brand-specific {
  color: #1d4ed8;
  background: #dbeafe;
}

.raster-gradient {
  width: 100%;
  height: 18px;
  border-radius: 5px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.raster-legend-scale {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 7px;
}

.raster-scale-end {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.7rem;
  line-height: 1.2;
  color: #475569;
}

.raster-scale-end strong {
  font-size: 0.75rem;
  color: #0f172a;
}

.raster-scale-end.high {
  text-align: right;
  align-items: flex-end;
}

.raster-legend-meta {
  margin-top: 9px;
  font-size: 0.68rem;
  line-height: 1.35;
  color: #475569;
}

.raster-legend-note {
  margin-top: 5px;
  font-size: 0.67rem;
  line-height: 1.35;
}
