:root {
  --bg: #f5f5f5;
  --panel-bg: #ffffff;
  --border: #dddddd;
  --text-main: #222222;
  --text-muted: #666666;

  /* single-hue merah bertingkat: 1 paling muda → 4 paling tua */
  --cluster-1: #fddede;
  --cluster-2: #f7a9a3;
  --cluster-3: #fc8d59;
  --cluster-4: #d73027;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text-main);
}

.app-header {
  padding: 1rem 1.5rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  margin: 0;
  font-size: 1.25rem;
}

.app-header .subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem 1rem 1rem;
  min-height: calc(100vh - 64px);
  box-sizing: border-box;
}

.map-panel {
  height: calc(100vh - 64px - 0.75rem);
}

.table-panel {
  margin-top: 0.5rem;
}

.map-panel,
.table-panel {
  background: var(--panel-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

/* toolbar filter di atas peta */
.map-toolbar {
  padding: 0.75rem 1rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* kartu pembungkus filter (klaster & pulau) */
.filter-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.75rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-card-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #666666;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* tabs klaster & pulau */
.cluster-tabs,
.island-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.province-select {
  min-width: 180px;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid #dddddd;
  background: #fafafa;
  color: #333333;
}

/* tombol dasar */
.cluster-tab,
.island-tab {
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid transparent;
  background: #f5f5f5;
  color: #333333;
  transition: all 0.18s ease;
}

/* tombol klaster: pakai tone merah bertingkat */
.cluster-tab.cluster-1 {
  background: #fef5f5;
  border-color: #f5d8d8;
}

.cluster-tab.cluster-2 {
  background: #fde7e4;
  border-color: #f7bcb6;
}

.cluster-tab.cluster-3 {
  background: #fde1d6;
  border-color: #f7b396;
}

.cluster-tab.cluster-4 {
  background: #f6c5bf;
  border-color: #e88d7f;
}

/* state aktif klaster */
.cluster-tab.active {
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}

.cluster-tab.cluster-1.active {
  background: var(--cluster-1);
}

.cluster-tab.cluster-2.active {
  background: var(--cluster-2);
}

.cluster-tab.cluster-3.active {
  background: var(--cluster-3);
  color: #ffffff;
}

.cluster-tab.cluster-4.active {
  background: var(--cluster-4);
  color: #ffffff;
}

/* tombol pulau: netral, fokus area bukan nilai */
.island-tab {
  background: #f7f7f7;
  color: #3b3b3b;
  border-color: #e1e1e1;
}

.island-tab.active {
  background: #e8f1ff;
  color: #114a8f;
  border-color: #b8d0f3;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(17, 74, 143, 0.06);
}

/* efek hover ringan */
.cluster-tab:hover,
.island-tab:hover {
  transform: translateY(-1px);
}

/* peta */
#map {
  flex: 1;
  min-height: 320px;
  border-bottom: 1px solid var(--border);
  margin-top: 0.4rem;
}

/* legenda */
.legend {
  padding: 0.75rem 1rem 1rem;
  font-size: 0.85rem;
}

.legend h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.legend ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.legend li {
  display: flex;
  align-items: center;
  margin-bottom: 0.25rem;
}

.legend-color {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  margin-right: 0.5rem;
  border: 1px solid rgba(0,0,0,0.15);
}

/* legenda pakai tone yang sama */
.legend-color.cluster-1 { background: var(--cluster-1); }
.legend-color.cluster-2 { background: var(--cluster-2); }
.legend-color.cluster-3 { background: var(--cluster-3); }
.legend-color.cluster-4 { background: var(--cluster-4); }

/* tabel */
.table-panel {
  padding: 0.75rem 1rem 1rem;
}

.table-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.table-wrapper {
  flex: 1;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  position: sticky;
  top: 0;
  background: #fafafa;
  z-index: 1;
}

th,
td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

tbody tr:hover {
  background: #f0f0f0;
}

tbody tr.selected {
  background: #cfe8ff !important;
}

/* pewarnaan baris sesuai klaster (lembut, tone sama) */
.cluster-row.cluster-1 {
  background: #fef7f7;
}

.cluster-row.cluster-2 {
  background: #fde9e7;
}

.cluster-row.cluster-3 {
  background: #fde3da;
}

.cluster-row.cluster-4 {
  background: #f8cec7;
}

.cluster-row:hover {
  filter: brightness(0.97);
}

/* responsif */
@media (max-width: 768px) {
  .map-toolbar {
    gap: 0.5rem;
  }

  .filter-card {
    width: 100%;
  }
}

.province-filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.province-select {
  min-width: 180px;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid #dddddd;
  background: #fafafa;
  color: #333333;
}

.province-reset-btn {
  border: 1px solid #dddddd;
  background: #ffffff;
  color: #555555;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  line-height: 1.2;
}

.province-reset-btn:hover {
  background: #f3f3f3;
}