:root {
  /* --- PREMIUM LIGHT MODE (Default) --- */
  --bg: #f8fafc;
  /* Latar belakang utama: Putih kebiruan segar */
  --bg-elev: #ffffff;
  /* Elemen melayang: Putih bersih */
  --paper: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-2: #f1f5f9;
  /* Latar belakang sekunder */
  --bg-3: #e2e8f0;
  /* Hover state */

  --ink: #0f172a;
  /* Teks Utama: Slate Gelap */
  --ink-2: #334155;
  /* Teks Sekunder */
  --ink-3: #64748b;
  /* Teks Lemah */
  --ink-4: #94a3b8;
  /* Teks Placeholder / Muted */

  --rule: rgba(15, 23, 42, 0.06);
  /* Garis halus */
  --rule-2: rgba(15, 23, 42, 0.12);
  /* Garis tegas */

  --accent: #f97316;
  /* Oranye Branding */
  --accent-soft: rgba(249, 115, 22, 0.1);
  --accent-bg: rgba(249, 115, 22, 0.05);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, 0.1);

  --radius: 14px;
  --serif: 'Newsreader', 'Source Serif Pro', Georgia, serif;
  --sans: 'Inter Tight', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;
}

body.dark-mode {
  /* --- PREMIUM DARK MODE --- */
  --bg: #0b0c10;
  --bg-elev: #16181e;
  --paper: #1c1f26;
  --bg-card: rgba(22, 24, 30, 0.8);
  --bg-2: #242933;
  --bg-3: #2f3642;

  --ink: #f8fafc;
  --ink-2: #cbd5e1;
  --ink-3: #94a3b8;
  --ink-4: #64748b;

  --rule: rgba(255, 255, 255, 0.05);
  --rule-2: rgba(255, 255, 255, 0.1);

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  cursor: pointer;
}

#root {
  min-height: 100vh;
}

/* ===== Loading ===== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 16px;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid var(--rule-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-family: var(--mono);
  color: var(--ink-4);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.app {
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100vh;
  position: relative;
}

/* ===== Header ===== */
.app-head {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) auto;
  align-items: center;
  gap: 20px;
  padding: 14px 28px 13px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: 22px;
  font-weight: 400;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 2px;
}

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-4);
  pointer-events: none;
}

.search {
  width: 100%;
  padding: 9px 34px 9px 36px;
  border: 1.5px solid var(--rule-2);
  background: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search::placeholder {
  color: var(--ink-4);
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-clear {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}

.search-clear:hover {
  background: var(--rule-2);
  color: var(--ink);
}

.view-toggle {
  display: flex;
  border: 1.5px solid var(--rule-2);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 3px;
  flex-shrink: 0;
  gap: 1px;
}

.vt-btn {
  border: none;
  background: transparent;
  padding: 6px 11px;
  font-size: 11.5px;
  font-family: var(--sans);
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.01em;
  border-radius: calc(var(--radius) - 2px);
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}

.vt-btn:hover {
  color: var(--ink);
  background: var(--rule);
}

.vt-btn.is-on {
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

/* ===== Filter strip ===== */
.filter-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 28px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg-elev);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-strip::-webkit-scrollbar {
  display: none;
}

.filter-sep {
  width: 1px;
  height: 16px;
  background: var(--rule-2);
  flex-shrink: 0;
}

.filt {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.filt-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-4);
  white-space: nowrap;
}

.filt select {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 5px 24px 5px 8px;
  background: var(--paper);
  border: 1.5px solid var(--rule-2);
  color: var(--ink);
  border-radius: calc(var(--radius) - 2px);
  outline: none;
  cursor: pointer;
  transition: border-color 0.12s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%23a39e93'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
}

.filt select:focus {
  border-color: var(--accent);
}

.seg {
  display: flex;
  border: 1.5px solid var(--rule-2);
  border-radius: calc(var(--radius) - 2px);
  background: var(--paper);
  overflow: hidden;
  flex-shrink: 0;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 5px 11px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  font-family: var(--sans);
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.seg-btn+.seg-btn {
  border-left: 1px solid var(--rule-2);
}

.seg-btn:hover:not(.is-on) {
  background: var(--rule);
  color: var(--ink);
}

.seg-btn.is-on {
  background: var(--ink);
  color: var(--bg);
}

/* Result count */
.result-count {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0 2px;
}

/* Stats block */
.stats {
  display: flex;
  margin-left: auto;
  flex-shrink: 0;
  border: 1px solid var(--rule-2);
  border-radius: calc(var(--radius) - 2px);
  background: var(--paper);
  overflow: hidden;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 14px;
  border-right: 1px solid var(--rule-2);
  gap: 1px;
}

.stat:last-child {
  border-right: none;
}

.stat .sn {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  font-feature-settings: 'tnum';
  line-height: 1;
}

.stat .sl {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  white-space: nowrap;
}

.stat--accent .sn {
  color: var(--accent);
}

/* ===== Body ===== */
.app-body {
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.view-matrix,
.view-prov,
.view-admin {
  overflow-y: auto;
  padding: 24px 28px 80px;
  height: 100%;
}

/* ===== Map ===== */
.map-canvas {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

.leaflet-container {
  background: var(--bg) !important;
  font-family: var(--sans) !important;
}

.leaflet-control-attribution {
  background: var(--bg) !important;
  font-family: var(--mono) !important;
  font-size: 9px !important;
  color: var(--ink-4) !important;
  padding: 3px 8px !important;
  opacity: 0.8;
}

.leaflet-bar a {
  background: var(--paper) !important;
  color: var(--ink) !important;
  border-color: var(--rule-2) !important;
  font-size: 15px !important;
}

.leaflet-bar a:hover {
  background: var(--bg-elev) !important;
}

.map-tip {
  background: var(--paper) !important;
  color: var(--ink) !important;
  border: 1px solid var(--rule-2) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 12px 16px !important;
  font-size: 12px !important;
  border-radius: var(--radius) !important;
  font-family: var(--sans) !important;
  line-height: 1.5 !important;
  min-width: 180px !important;
  backdrop-filter: blur(8px);
}

.map-tip::before {
  border-top-color: var(--paper) !important;
}

.map-tip-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.map-tip-meta {
  color: var(--ink-3);
  font-size: 11px;
  font-family: var(--mono);
}

.map-tip-bar-track {
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.map-tip-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

.map-tip-cov {
  margin-top: 4px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--ink-4);
}

/* ===== Matrix ===== */
.matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  max-width: 1600px;
}

.matrix-card {
  background: var(--paper);
  border: 1.5px solid var(--rule-2);
  padding: 15px 15px 13px;
  text-align: left;
  border-radius: var(--radius);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 148px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  /* Skip paint/layout for off-screen cards — native windowing */
  content-visibility: auto;
  contain-intrinsic-size: auto 160px;
}

/* Invisible sentinel that triggers IntersectionObserver for infinite scroll */
.load-sentinel {
  grid-column: 1 / -1;
  height: 1px;
  pointer-events: none;
}

.matrix-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}

.matrix-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.matrix-card:hover::after {
  transform: scaleX(1);
}

.mc-head {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mc-name {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.25;
  color: var(--ink);
  letter-spacing: -0.01em;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mc-loc {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.mc-stack {
  display: flex;
  align-items: center;
  min-height: 32px;
  padding: 2px 0;
}

.mc-av {
  border-radius: 50%;
  border: 2px solid var(--paper);
  margin-left: -7px;
  flex-shrink: 0;
  transition: margin 0.15s;
}

.mc-av:first-child {
  margin-left: 0;
}

.matrix-card:hover .mc-av {
  margin-left: -4px;
}

.mc-empty {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  font-style: italic;
}

.mc-more {
  margin-left: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  font-weight: 600;
  flex-shrink: 0;
}

.mc-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 9px;
  border-top: 1px solid var(--rule);
}

.mc-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.03em;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.mc-count-n {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.01em;
  line-height: 1;
}

.mc-count-zero {
  color: var(--ink-4);
}

.mc-foot-right {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

.mc-prov {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-4);
  letter-spacing: 0.03em;
  text-align: right;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mc-type {
  font-family: var(--mono);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-4);
  background: var(--bg);
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid var(--rule-2);
  white-space: nowrap;
  flex-shrink: 0;
}

/* mini ig-count bar — absolutely positioned at card bottom */
.mc-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--rule);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.mc-bar-fill {
  height: 100%;
  background: var(--accent);
  min-width: 2px;
  transition: width 0.3s ease;
}

.mc-noig .mc-bar-fill {
  opacity: 0;
}

/* no-ig card state */
.matrix-card.mc-noig {
  opacity: 0.72;
}

.matrix-card.mc-noig:hover {
  opacity: 1;
}

/* ===== Provinsi ===== */
.prov-list {
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.prov-block {
  border-top: 2px solid var(--ink);
  padding-top: 18px;
}

.prov-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 24px;
  flex-wrap: wrap;
}

.prov-name {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
  line-height: 1.1;
}

.prov-stats-row {
  display: flex;
  border: 1.5px solid var(--rule-2);
  border-radius: calc(var(--radius) - 2px);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--paper);
}

.prov-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 12px;
  border-right: 1px solid var(--rule-2);
  gap: 1px;
}

.prov-stat:last-child {
  border-right: none;
}

.prov-stat-n {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1;
}

.prov-stat-l {
  font-family: var(--mono);
  font-size: 8.5px;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* Admin UI */
.admin-status-bar {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  display: flex;
  gap: 10px;
}

.btn-login-trigger {
  background: var(--bg-card);
  border: 1px solid var(--rule-1);
  color: var(--ink-3);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.2s;
}

.btn-login-trigger:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-10);
}

.admin-controls {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  padding: 6px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 30px var(--shadow);
  backdrop-filter: blur(20px);
}

.admin-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  padding: 0 10px;
}

.btn-admin {
  background: var(--bg-2);
  border: 1px solid var(--rule-2);
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-admin:hover {
  background: var(--bg-3);
  border-color: var(--ink-4);
}

.btn-save {
  background: var(--accent);
  color: white;
  border: none;
}

.btn-save:hover {
  background: var(--accent);
  filter: brightness(1.1);
}

.btn-logout {
  color: #ef4444;
}

/* Edit Form inside Side Panel */
.sp-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-edit-trigger {
  background: var(--accent-10);
  color: var(--accent);
  border: 1px solid var(--accent-20);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.btn-cancel-edit {
  display: none;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  border-radius: 24px;
  border: 1px solid var(--rule-2);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 24px 30px;
  border-bottom: 1px solid var(--rule-1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
}

.modal-close {
  background: var(--bg-3);
  border: none;
  color: var(--ink-2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  padding: 30px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  margin-left: 4px;
}

.form-group input {
  background: var(--bg-2);
  border: 1px solid var(--rule-2);
  color: var(--ink-1);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  transition: all 0.2s;
}

.form-group input:focus {
  border-color: var(--accent);
  outline: none;
  background: var(--bg-3);
}

.modal-ig-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-ig-row {
  display: flex;
  gap: 12px;
  background: var(--bg-3);
  padding: 16px;
  border-radius: 16px;
  align-items: flex-start;
  border: 1px solid var(--rule-1);
}

.modal-ig-inputs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-ig-inputs input {
  font-size: 13px;
  padding: 8px 12px;
}

.btn-remove {
  background: #ef444415;
  color: #ef4444;
  border: 1px solid #ef444430;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.btn-add-new {
  background: transparent;
  border: 2px dashed var(--rule-2);
  color: var(--ink-3);
  padding: 15px;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-add-new:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.modal-footer {
  padding: 20px 30px;
  background: var(--bg-2);
  border-top: 1px solid var(--rule-1);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-cancel {
  background: transparent;
  border: 1px solid var(--rule-2);
  color: var(--ink-2);
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-save-main {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--shadow);
}

/* Login Specific */
.modal-content--login {
  max-width: 400px;
}

.login-error {
  margin-top: 10px;
  color: #ef4444;
  font-size: 13px;
  font-weight: 600;
  background: #ef444410;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #ef444430;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

.animate-pop {
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.btn-cancel-edit:hover {
  background: var(--bg-3);
  border-color: var(--ink-4);
}

/* Admin Table View Styles */
.admin-table-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
  animation: fadeIn 0.3s ease-out;
}

.at-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.at-header h2 {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  color: var(--ink-1);
}

.at-search {
  flex: 1;
  min-width: 300px;
  position: relative;
}

.at-search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.5;
}

.at-search input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--rule-2);
  color: var(--ink-1);
  padding: 12px 15px 12px 45px;
  border-radius: 12px;
  font-size: 15px;
  transition: all 0.2s;
}

.at-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-10);
  outline: none;
}

.at-stats {
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 500;
}

.at-table-wrapper {
  background: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--rule-1);
  overflow: hidden;
  box-shadow: 0 4px 20px var(--shadow);
}

.at-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.at-table th {
  background: var(--bg-2);
  padding: 15px 20px;
  font-weight: 700;
  color: var(--ink-2);
  border-bottom: 1px solid var(--rule-2);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.at-table td {
  padding: 15px 20px;
  border-bottom: 1px solid var(--rule-1);
  vertical-align: middle;
}

.at-table tr:hover td {
  background: var(--bg-3);
}

.at-name {
  font-weight: 700;
  color: var(--ink-1);
  margin-bottom: 2px;
}

.at-full {
  font-size: 12px;
  color: var(--ink-3);
}

.at-loc {
  font-weight: 600;
  color: var(--ink-2);
}

.at-prov {
  font-size: 12px;
  color: var(--ink-4);
}

.at-ig-count {
  font-weight: 700;
  color: var(--accent);
  font-size: 12px;
  margin-bottom: 5px;
}

.at-ig-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.at-ig-tag {
  font-size: 10px;
  background: var(--bg-2);
  color: var(--ink-3);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--rule-1);
}

.at-btn-edit {
  background: var(--bg);
  border: 1px solid var(--rule-2);
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.at-btn-edit:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-10);
}

.at-more-info {
  padding: 20px;
  text-align: center;
  color: var(--ink-4);
  font-size: 13px;
  background: var(--bg-2);
}

/* Responsive Table */
@media (max-width: 768px) {
  .admin-table-container {
    padding: 20px 10px;
  }
  
  .at-header {
    flex-direction: column;
    align-items: stretch;
  }

  .at-search {
    min-width: 100%;
  }

  .at-table th:nth-child(2), 
  .at-table td:nth-child(2) {
    display: none; /* Sembunyikan kolom Lokasi di HP */
  }

  .at-table th, .at-table td {
    padding: 10px 12px;
  }

  .at-name {
    font-size: 13px;
  }

  .at-ig-list {
    display: none; /* Sembunyikan tag IG di HP, hanya tampilkan jumlah */
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.prov-coverage {
  margin-bottom: 14px;
}

.prov-cov-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}

.prov-cov-pct {
  font-weight: 600;
  color: var(--ink-3);
}

.prov-bar-track {
  height: 4px;
  background: var(--rule-2);
  border-radius: 2px;
  overflow: hidden;
}

.prov-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  min-width: 2px;
}

.prov-cities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prov-chip {
  border: 1.5px solid var(--rule-2);
  background: var(--paper);
  padding: 7px 10px 7px 13px;
  border-radius: calc(var(--radius) - 1px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink);
  transition: all 0.15s;
  font-weight: 450;
}

.prov-chip:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.prov-chip:hover .chip-num {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

.chip-name {
  letter-spacing: -0.01em;
}

.chip-num {
  background: var(--bg);
  color: var(--ink-3);
  padding: 1px 7px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  font-feature-settings: 'tnum';
  transition: background 0.15s, color 0.15s;
}

/* ===== Panel overlay (backdrop, mobile only — shown via media query) ===== */
.panel-overlay {
  display: none;
}

/* ===== Side panel ===== */
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 94vw);
  background: var(--paper);
  border-left: 1px solid var(--rule-2);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  animation: slide-in 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
    opacity: 0.6;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.sp-accent-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, oklch(0.65 0.14 55) 100%);
  flex-shrink: 0;
}

.sp-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 22px 15px;
  border-bottom: 1px solid var(--rule);
  gap: 12px;
}

.sp-eyebrow {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 5px;
}

.sp-title {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.015em;
  line-height: 1.15;
  color: var(--ink);
}

.sp-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
  margin-top: 6px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.sp-badge {
  background: var(--accent-bg);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  border: 1px solid rgba(194, 65, 12, 0.12);
}

.sp-x {
  border: 1.5px solid var(--rule-2);
  background: transparent;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.sp-x:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.sp-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.sp-row {
  border-bottom: 1px solid var(--rule);
  padding: 11px 22px;
  transition: background 0.1s;
}

.sp-row:hover {
  background: var(--bg);
}

.sp-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  text-align: left;
  gap: 12px;
}

.sp-row-head:hover .sp-name {
  color: var(--accent);
}

.sp-name {
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  transition: color 0.12s;
  line-height: 1.3;
}

.sp-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  white-space: nowrap;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.sp-igs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.sp-ig {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--ink-2);
  padding: 3px 8px 3px 3px;
  background: var(--bg-elev);
  border: 1px solid var(--rule-2);
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--mono);
  transition: background 0.12s, color 0.12s, transform 0.12s, border-color 0.12s;
}

.sp-ig:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  transform: translateY(-1px);
}

.sp-u {
  letter-spacing: 0;
}

.sp-more {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
  align-self: center;
  padding-left: 2px;
}

/* Kampus panel */
.kampus-igs {
  display: flex;
  flex-direction: column;
}

.kig-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 22px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--rule);
  transition: background 0.12s;
}

.kig-row:hover {
  background: var(--bg);
}

.kig-row:hover .kig-arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.kig-text {
  flex: 1;
  min-width: 0;
}

.kig-full {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kig-handle {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 2px;
}

.kig-arrow {
  font-size: 13px;
  color: var(--ink-4);
  transition: color 0.12s, transform 0.12s;
  flex-shrink: 0;
}

.sp-noig {
  padding: 48px 24px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-4);
  font-style: italic;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.sp-noig-icon {
  font-size: 32px;
  opacity: 0.35;
}

/* ===== Empty state ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 32px;
  text-align: center;
  gap: 10px;
}

.empty-icon {
  font-size: 36px;
  opacity: 0.25;
  margin-bottom: 4px;
}

.empty-title {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--ink-2);
  margin: 0;
}

.empty-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
}

/* Density variant */
[data-density="compact"] .matrix-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 7px;
}

[data-density="compact"] .matrix-card {
  padding: 11px 12px 10px;
  min-height: 120px;
  gap: 8px;
}

[data-density="compact"] .mc-name {
  font-size: 13.5px;
}

/* Scrollbars */
.view-matrix::-webkit-scrollbar,
.view-prov::-webkit-scrollbar,
.sp-body::-webkit-scrollbar {
  width: 6px;
}

.view-matrix::-webkit-scrollbar-thumb,
.view-prov::-webkit-scrollbar-thumb,
.sp-body::-webkit-scrollbar-thumb {
  background: var(--rule-2);
  border-radius: 3px;
}

.view-matrix::-webkit-scrollbar-track,
.view-prov::-webkit-scrollbar-track,
.sp-body::-webkit-scrollbar-track {
  background: transparent;
}

/* ===== Responsive ===== */

/* Large desktop: compact stats */
@media (max-width: 1080px) {
  .stat {
    padding: 5px 10px;
  }

  .stat .sn {
    font-size: 13px;
  }
}

/* Medium desktop → tablet landscape */
@media (max-width: 880px) {
  .app-head {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 10px;
    padding: 12px 16px;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
  }

  .view-toggle {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
  }

  .search-wrap {
    grid-column: 1;
    grid-row: 2;
  }

  .filter-strip {
    padding: 8px 16px;
    gap: 10px;
  }

  .view-matrix,
  .view-prov {
    padding: 16px 16px 80px;
  }

  .prov-stats-row {
    display: none;
  }

  .prov-coverage {
    display: none;
  }
}

@media (max-width: 860px) {
  .stats {
    display: none;
  }
}

/* Tablet portrait → filter strip wraps + panel backdrop */
@media (max-width: 640px) {
  .filter-strip {
    flex-wrap: wrap;
    gap: 7px 8px;
    padding: 8px 14px;
    overflow-x: visible;
  }

  .filter-sep {
    display: none;
  }

  .filt select {
    max-width: 200px;
  }

  .result-count {
    order: 5;
  }

  /* Backdrop behind side-panels on mobile */
  .panel-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 26, 0.42);
    z-index: 999;
    animation: fade-bg 0.22s ease;
  }
}

@keyframes fade-bg {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Mobile phone: header stays 2-col, view toggle icon-only */
@media (max-width: 540px) {
  .app-head {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 8px;
    padding: 10px 14px;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
  }

  .view-toggle {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
  }

  .search-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .brand-sub {
    display: none;
  }

  .brand-title {
    font-size: 14.5px;
  }

  /* Show only icons in the view toggle to save horizontal space */
  .vt-btn {
    font-size: 0;
    gap: 0;
    padding: 7px 9px;
  }

  .vt-btn svg {
    width: 14px;
    height: 14px;
  }

  .filter-strip {
    padding: 7px 14px;
    gap: 7px 8px;
  }

  .seg-btn {
    padding: 7px 10px;
  }

  .matrix-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 7px;
  }

  .mc-type {
    display: none;
  }

  /* Full-screen side panel */
  .side-panel {
    width: 100vw;
    border-left: none;
  }

  .sp-head {
    padding: 14px 16px 12px;
  }

  .sp-row {
    padding: 10px 16px;
  }

  .sp-igs {
    gap: 4px;
  }

  .kig-row {
    padding: 13px 16px;
  }

  /* Bigger tap target for close button */
  .sp-x {
    width: 36px;
    height: 36px;
    font-size: 17px;
  }

  .prov-name {
    font-size: 20px;
  }

  .prov-list {
    gap: 24px;
  }

  .prov-chip {
    padding: 8px 10px 8px 12px;
    font-size: 12px;
  }

  .view-matrix,
  .view-prov {
    padding: 12px 12px 80px;
  }
}

/* Very small phones */
@media (max-width: 360px) {
  .matrix-grid {
    grid-template-columns: 1fr;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 18px;
  }

  .brand-title {
    font-size: 13px;
  }
}

/* Fix 100vh on mobile browsers (hides URL bar) */
@supports (height: 100dvh) {
  .app {
    height: 100dvh;
  }
}

/* Safe area for iPhones with notch/home indicator */
@supports (padding: env(safe-area-inset-bottom)) {

  .view-matrix,
  .view-prov {
    padding-bottom: max(80px, calc(24px + env(safe-area-inset-bottom)));
  }
}