:root {
  --ink: #0d2634;
  --ink-deep: #071a24;
  --ink-panel: #102c3b;
  --ink-panel-2: #143244;
  --line: #e9f3ee;
  --line-dim: #b9d3ce;
  --muted: #7fa2ab;
  --grid: rgba(233, 243, 238, 0.08);
  --grid-strong: rgba(233, 243, 238, 0.16);
  --brass: #c9a35f;
  --brass-bright: #e0bd7d;

  --series-1: #4fa7c9;
  --series-2: #8b7ec8;
  --series-3: #c9a35f;
  --series-4: #d08a2e;
  --series-5: #6b8cae;
  --series-6: #9c6b4f;
  --series-7: #7aa889;
  --series-8: #b5473a;

  --good: #5c9a70;
  --warning: #d08a2e;
  --critical: #b5473a;
  --neutral: #7fa2ab;
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-color: #3a5966 var(--ink-deep);
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse at 5% 0%, rgba(201,163,95,0.09), transparent 38%),
    radial-gradient(ellipse at 95% 8%, rgba(79,167,201,0.05), transparent 38%),
    repeating-linear-gradient(0deg, rgba(201,163,95,0.045) 0 1px, transparent 1px 44px),
    repeating-linear-gradient(90deg, rgba(201,163,95,0.045) 0 1px, transparent 1px 44px),
    #060f17;
  color: var(--line);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---- Header / title block ---- */

header {
  padding: 14px 28px;
  border-bottom: 1px solid rgba(201,163,95,0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(7,15,23,0.95), rgba(6,15,23,0.88));
  position: sticky;
  top: 0;
  z-index: 1200;
  backdrop-filter: blur(14px);
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand .mark {
  flex-shrink: 0;
  color: var(--brass);
  filter: drop-shadow(0 0 8px rgba(201, 163, 95, 0.35));
}

.brand .eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
}

header h1 {
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin: 1px 0 0;
  letter-spacing: 0.01em;
  color: var(--line);
}

header h1 span {
  color: var(--brass-bright);
}

header .brand-sub {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 22px;
}

.field {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.field-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-value {
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 6px var(--good);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.75); }
}

header .subtitle {
  color: var(--line-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-family: "IBM Plex Mono", monospace;
}

main {
  padding: 24px 28px 60px;
  max-width: 1440px;
  margin: 0 auto;
}

/* ---- KPI instrument row ---- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-tile {
  background: linear-gradient(160deg, rgba(20,50,68,0.9), rgba(16,44,59,0.9));
  border: 1px solid rgba(201,163,95,0.22);
  border-top: 2px solid var(--brass);
  border-radius: 2px;
  padding: 20px 20px 16px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.kpi-tile:hover {
  border-color: rgba(201,163,95,0.5);
  box-shadow: 0 4px 24px rgba(201,163,95,0.1);
}

.kpi-label {
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-label::before {
  content: "▸";
  color: var(--brass);
}

.kpi-value {
  font-family: "Space Grotesk", sans-serif;
  font-size: 44px;
  font-weight: 700;
  margin-top: 6px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--brass-bright);
}

.kpi-rule {
  margin-top: 14px;
  height: 1px;
  background: rgba(201,163,95,0.2);
}

/* ---- Panels ---- */

.panel {
  background: linear-gradient(160deg, rgba(16,44,59,0.95), rgba(14,37,53,0.95));
  border: 1px solid rgba(201,163,95,0.16);
  border-radius: 2px;
  padding: 20px;
  margin-bottom: 20px;
  position: relative;
}

.panel h2 {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--line-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel h2::before {
  content: "";
  width: 3px;
  height: 12px;
  background: var(--brass);
  display: inline-block;
}

.panel.accent-status h2::before { background: var(--good); }
.panel.accent-map h2::before { background: var(--series-1); }

/* Chart grid 3 kolom — baris atas */
.chart-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.chart-panel {
  height: 360px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chart-panel canvas {
  flex: 1;
  min-height: 0;
}

/* Provinsi — full width, lebih pendek */
.chart-provinsi-wrap {
  height: 280px;
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
  overflow: hidden;
}

.chart-provinsi-wrap canvas {
  flex: 1;
  min-height: 0;
}

/* ---- Map: survey console ---- */

.map-wrap {
  position: relative;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid rgba(201,163,95,0.2);
}

.map-wrap .corner-tl,
.map-wrap .corner-tr,
.map-wrap .corner-bl,
.map-wrap .corner-br {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  z-index: 1000;
  pointer-events: none;
}

.map-wrap .corner-tl,
.map-wrap .corner-tr,
.map-wrap .corner-bl,
.map-wrap .corner-br {
  border: 1.5px solid rgba(224, 189, 125, 0.75);
}

.map-wrap .corner-tl { top: 8px; left: 8px; border-right: none; border-bottom: none; }
.map-wrap .corner-tr { top: 8px; right: 8px; border-left: none; border-bottom: none; }
.map-wrap .corner-bl { bottom: 8px; left: 8px; border-right: none; border-top: none; }
.map-wrap .corner-br { bottom: 8px; right: 8px; border-left: none; border-top: none; }

.map-sweep {
  position: absolute;
  inset: 0;
  z-index: 900;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(79, 167, 201, 0.35), transparent);
  width: 40%;
  transform: translateX(-120%);
  animation: sweep 2.2s cubic-bezier(0.4, 0, 0.2, 1) 1;
}

@keyframes sweep {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(340%); }
}

.map-readout {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1000;
  background: rgba(7, 26, 36, 0.82);
  border: 1px solid var(--grid-strong);
  padding: 8px 12px;
  font-size: 11px;
  color: var(--line-dim);
  backdrop-filter: blur(4px);
  text-align: right;
  font-family: "IBM Plex Mono", monospace;
}

.map-readout .n {
  font-family: "Space Grotesk", sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--brass-bright);
  font-variant-numeric: tabular-nums;
  display: block;
}

.map-coords {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 1000;
  background: rgba(7, 26, 36, 0.82);
  border: 1px solid var(--grid-strong);
  padding: 6px 10px;
  font-size: 11px;
  color: var(--line-dim);
  backdrop-filter: blur(4px);
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.02em;
}

.map-coords .lbl {
  color: var(--muted);
  margin-right: 6px;
}

#map {
  height: 520px;
  background: var(--ink-panel);
}

.map-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.map-controls select,
.map-controls button,
.table-controls input,
.table-controls select {
  background: rgba(14,37,53,0.9);
  color: var(--line);
  border: 1px solid rgba(201,163,95,0.2);
  border-radius: 2px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.map-controls select:focus,
.table-controls input:focus,
.table-controls select:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 2px rgba(201,163,95,0.15);
}

.map-controls button {
  cursor: pointer;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.map-controls button:hover,
.table-controls input:hover {
  border-color: var(--grid-strong);
}

.map-controls button.active {
  border-color: var(--brass);
  color: var(--brass-bright);
  background: rgba(201, 163, 95, 0.12);
}

/* ---- Tabs / table controls ---- */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.tabs button {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 4px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.03em;
  transition: color 0.15s ease;
}

.tabs button:hover {
  color: var(--line-dim);
}

.tabs button.active {
  color: var(--line);
  border-bottom-color: var(--brass);
}

.table-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.table-controls input {
  min-width: 240px;
}

.table-scroll {
  overflow-x: auto;
  border-radius: 2px;
  border: 1px solid rgba(201,163,95,0.18);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  background: rgba(14,37,53,0.98);
  z-index: 5;
  border-bottom: 1px solid rgba(201,163,95,0.3);
}

th, td {
  text-align: left;
  padding: 9px 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

td { font-variant-numeric: tabular-nums; }
td.mono-cell { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--line-dim); }

th {
  color: rgba(201,163,95,0.75);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.08em;
  font-family: "IBM Plex Mono", monospace;
}

th.col-photo, td.col-photo {
  width: 44px;
  max-width: 44px;
  padding-left: 12px;
  padding-right: 4px;
}

tbody tr {
  transition: background 0.1s ease;
}

tbody tr.row-clickable {
  cursor: pointer;
}

tbody tr:nth-child(even) {
  background: rgba(201,163,95,0.03);
}

tbody tr:hover {
  background: rgba(201,163,95,0.09) !important;
}

.row-hint {
  color: var(--muted);
  font-size: 11.5px;
  font-family: "IBM Plex Mono", monospace;
  margin-top: 10px;
}

.pagination {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12.5px;
  font-family: "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.pagination button {
  background: rgba(14,37,53,0.9);
  color: var(--line-dim);
  border: 1px solid rgba(201,163,95,0.2);
  border-radius: 2px;
  padding: 6px 16px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--brass);
  background: rgba(201,163,95,0.1);
  color: var(--brass-bright);
}

.pagination button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ---- Thumbnails ---- */

.thumb {
  width: 30px;
  height: 30px;
  border-radius: 2px;
  border: 1px solid var(--grid-strong);
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  background: var(--ink-deep);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.thumb:hover {
  border-color: var(--brass);
  transform: scale(1.06);
}

.thumb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 2px;
  border: 1px dashed var(--grid-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  background: var(--ink-deep);
}

/* ---- Stamp badges ---- */

.stamp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border: 1px solid currentColor;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.stamp.good    { color: var(--good);     background: rgba(92,154,112,0.12); }
.stamp.warning { color: var(--warning);  background: rgba(208,138,46,0.12); }
.stamp.critical{ color: var(--critical); background: rgba(181,71,58,0.12);  }
.stamp.neutral { color: var(--neutral);  background: rgba(127,162,171,0.08); border-style: dashed; }

.nik-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}

.nik-note a {
  color: var(--series-1);
  text-decoration: none;
}

.nik-note a:hover {
  text-decoration: underline;
}

.leaflet-popup-content-wrapper {
  background: #0d2333 !important;
  color: #cfe3de !important;
  border: 1px solid rgba(201,163,95,0.35) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
  border-radius: 3px !important;
}

.leaflet-popup-tip {
  background: #0d2333 !important;
}

.leaflet-popup-close-button {
  color: rgba(201,163,95,0.7) !important;
}

.leaflet-popup-close-button:hover {
  color: var(--brass-bright) !important;
}

#map .marker-cluster-small,
#map .marker-cluster-medium,
#map .marker-cluster-large {
  background: rgba(201, 163, 95, 0.22);
}

#map .marker-cluster-small div,
#map .marker-cluster-medium div,
#map .marker-cluster-large div {
  background: var(--ink-panel-2);
  border: 1.5px solid var(--brass);
  color: var(--brass-bright);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
}

.map-legend {
  font-size: 12px;
  color: var(--line-dim);
  display: flex;
  gap: 14px;
  margin-top: 10px;
  flex-wrap: wrap;
  font-family: "IBM Plex Mono", monospace;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-legend .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 4px currentColor;
}

/* ---- Lightbox ---- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(7, 20, 27, 0.86);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: min(90vw, 480px);
  max-height: 80vh;
  border: 1px solid var(--grid-strong);
  background: var(--ink-panel);
}

.lightbox .lightbox-cap {
  position: absolute;
  bottom: 10%;
  color: var(--line-dim);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
}

/* ---- Detail drawer (koperasi record card) ---- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 20, 27, 0.72);
  backdrop-filter: blur(2px);
  z-index: 1500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(660px, 100vw);
  background: linear-gradient(160deg, #0e2535, #0b1e2c);
  border-left: 1px solid rgba(201,163,95,0.25);
  z-index: 1600;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  padding: 20px 22px 60px;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-close {
  position: sticky;
  top: 0;
  float: right;
  background: var(--ink-panel-2);
  border: 1px solid var(--grid-strong);
  color: var(--line);
  width: 32px;
  height: 32px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  z-index: 2;
}

.drawer-close:hover {
  border-color: var(--brass);
  color: var(--brass-bright);
}

.record-eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.record-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 21px;
  font-weight: 700;
  color: var(--line);
  margin: 0 0 12px;
  padding-right: 40px;
}

.record-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  margin-bottom: 20px;
  font-size: 12.5px;
}

.record-fields .f-label {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 2px;
}

.record-fields .f-value {
  color: var(--line-dim);
}

.drawer-section-title {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--line-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 22px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-section-title::before {
  content: "";
  width: 3px;
  height: 12px;
  background: var(--brass);
  display: inline-block;
}

.pimpinan-card {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--ink-panel);
  border: 1px solid var(--grid-strong);
  border-radius: 2px;
  padding: 14px;
}

.pimpinan-card .thumb,
.pimpinan-card .thumb-avatar {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.pimpinan-card .p-name {
  font-family: "Space Grotesk", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--line);
}

.pimpinan-card .p-role {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  color: var(--brass-bright);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 2px 0 4px;
}

.pimpinan-card .p-meta {
  font-size: 12px;
  color: var(--muted);
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.mini-table th, .mini-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--grid);
  text-align: left;
}

.mini-table th {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mini-table .thumb, .mini-table .thumb-avatar {
  width: 26px;
  height: 26px;
}

.drawer-empty {
  color: var(--muted);
  font-size: 12.5px;
  padding: 14px 0;
}

.drawer-loading {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  padding: 20px 0;
}

@media (prefers-reduced-motion: reduce) {
  .drawer { transition: none; }
}

/* focus visibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
.thumb:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 2px;
}

/* ── Dokumen section ── */
.doc-list { display: flex; flex-direction: column; gap: 8px; padding: 0 2px; }
.doc-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(201,163,95,0.06); border: 1px solid rgba(201,163,95,0.15); border-radius: 6px; }
.doc-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 1px solid rgba(201,163,95,0.3); flex-shrink: 0; }
.doc-link { color: var(--brass-bright); text-decoration: none; font-size: .85rem; word-break: break-word; }
.doc-link:hover { text-decoration: underline; }
.doc-unavail { color: rgba(255,255,255,0.35); font-size: .82rem; font-style: italic; }
