:root {
  --navy: #0f2744;
  --navy-2: #16345a;
  --ink: #122033;
  --muted: #66768a;
  --line: #dce3ec;
  --bg: #f3f6fa;
  --card: #ffffff;
  --teal: #0f766e;
  --gold: #c9a227;
  --green: #15803d;
  --red: #b42318;
  --orange: #c2410c;
  --blue: #1d4ed8;
  --shadow: 0 10px 30px rgba(15, 39, 68, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Plus Jakarta Sans", sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  grid-template-columns: 240px 1fr;
}

button, input, textarea, select { font-family: inherit; }

.sidebar {
  background: linear-gradient(180deg, var(--navy), #0b1c31);
  color: #fff;
  min-height: 100vh;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--gold); color: var(--navy);
  display: grid; place-items: center; font-weight: 800;
}
.brand-title { font-weight: 800; }
.brand-sub { font-size: 12px; opacity: 0.7; }

.nav { display: flex; flex-direction: column; gap: 8px; }
.nav-btn {
  background: transparent; border: 0; color: #d7e3f2;
  text-align: left; padding: 12px 14px; border-radius: 10px;
  cursor: pointer; font-weight: 600;
}
.nav-btn.active, .nav-btn:hover { background: var(--navy-2); color: #fff; }

.sidebar-foot { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  padding: 6px 10px; border-radius: 999px; background: #1b8a5a;
}
.pill-muted { background: #314867; }
.pill.warn { background: #9a3412; }

.main { padding: 28px 32px 48px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
h1 { margin: 0; font-size: 28px; letter-spacing: 0.04em; }
.subtitle { margin: 6px 0 0; color: var(--muted); }
.top-actions, .row, .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.stat-card { padding: 14px 16px; }
.stat-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-card strong { font-size: 26px; }
.accent-green strong { color: var(--green); }
.accent-red strong { color: var(--red); }
.accent-orange strong { color: var(--orange); }
.accent-gray strong { color: var(--muted); }

.panel { padding: 20px; margin-bottom: 16px; }
.progress-panel { padding: 18px 20px; }
.progress-head, .row-between, .toolbar, .pager {
  display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap;
}
.progress-track { height: 12px; background: #e8eef5; border-radius: 999px; overflow: hidden; margin: 12px 0 8px; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), #22c55e); transition: width 0.2s ease; }
.current-meta { color: var(--muted); font-size: 13px; text-align: right; }
.muted { color: var(--muted); font-size: 13px; }
.help { color: var(--muted); line-height: 1.5; }
.hidden { display: none !important; }

.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; }
textarea {
  width: 100%; min-height: 280px; resize: vertical;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
input, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }

.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 10px 14px; font-weight: 700; cursor: pointer;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-2); }
.btn-danger { background: #9f1239; color: #fff; border-color: #9f1239; }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.kv div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 8px 0; }
dt { color: var(--muted); } dd { margin: 0; font-weight: 700; }

.toolbar { margin-bottom: 12px; }
#searchNop { max-width: 280px; }
.filters, .year-filters, .layout-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 12px; cursor: pointer; font-weight: 700; font-size: 12px;
}
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.logout-btn { color: #d7e3f2; border-color: #314867; width: 100%; }
.login-body {
  display: block;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(201, 162, 39, 0.2), transparent 30%),
    linear-gradient(160deg, #081526 0%, #0f2744 46%, #0f766e 140%);
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { margin: 8px 0 0; font-size: 30px; color: var(--navy); }
.login-brand .brand-title, .login-brand .brand-sub { color: var(--navy); }
.login-brand .brand-sub { opacity: 0.65; }
.login-error { color: var(--red); font-weight: 700; margin: 0; }
.login-submit { width: 100%; margin-top: 8px; padding: 12px; }

.table-wrap { overflow: auto; max-height: 62vh; border: 1px solid var(--line); border-radius: 12px; }
.result-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
  gap: 20px;
  max-height: 68vh;
  overflow: auto;
  padding: 4px 2px 12px;
  align-items: start;
}
.result-groups.layout-full { grid-template-columns: 1fr; }
.nop-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.nop-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 40px rgba(15, 39, 68, 0.14);
}
.nop-card-head {
  display: grid;
  gap: 8px;
  padding: 18px 18px 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), transparent),
    linear-gradient(135deg, #0f2744, #16345a 58%, #0f766e);
  color: #fff;
  cursor: pointer;
}
.nop-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}
.nop-card-head .nop-cell { color: #fff; font-size: 18px; letter-spacing: 0.01em; }
.nop-wp { font-size: 14px; font-weight: 700; }
.nop-card-meta { color: rgba(255,255,255,0.78); font-size: 12px; line-height: 1.45; white-space: normal; }
.year-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px;
  padding: 14px 16px 6px;
}
.year-status-cell {
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
  background: #f8fafc;
  border: 1px solid var(--line);
}
.year-status-cell small { display: block; color: var(--muted); font-weight: 800; }
.year-status-cell strong { display: block; margin: 6px 0 4px; font-size: 12px; }
.year-status-cell span { display: block; font-size: 11px; color: var(--ink); font-weight: 700; }
.year-status-cell.is-lunas { background: #ecfdf3; border-color: #bbf7d0; }
.year-status-cell.is-belum { background: #fef2f2; border-color: #fecaca; }
.year-status-cell.is-error { background: #fff7ed; border-color: #fed7aa; }
.year-status-cell.is-pending { background: #f1f5f9; }
.year-status-cell.is-checking { background: #eff6ff; border-color: #bfdbfe; }
.nop-card-actions { padding: 8px 16px 14px; display: flex; justify-content: flex-end; }
.nop-year-table { width: 100%; }
.nop-year-table th { position: static; background: #f8fafc; }
.nop-year-table tbody tr:hover { background: #f4f8ff; }
.nop-year-block { padding: 0 16px 16px; border-top: 1px solid var(--line); }
.nop-year-block h5 { margin: 14px 0 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: #f8fafc; z-index: 1; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f4f8ff; }
.nop-cell { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; }
.money-cell { font-variant-numeric: tabular-nums; font-weight: 700; }
.ket-cell { white-space: normal; min-width: 140px; color: var(--muted); }
.row-actions { display: flex; gap: 8px; align-items: center; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 800;
}
.badge-lunas { background: #dcfce7; color: #166534; }
.badge-belum { background: #fee2e2; color: #991b1b; }
.badge-error { background: #ffedd5; color: #9a3412; }
.badge-pending { background: #e2e8f0; color: #475569; }
.badge-checking { background: #dbeafe; color: #1e3a8a; }
.badge-unknown { background: #f3e8ff; color: #6b21a8; }
.open-btn, .json-btn {
  margin-left: 0; border: 0; background: transparent; color: var(--blue);
  cursor: pointer; font-weight: 700; font-size: 11px;
}

.modal {
  position: fixed; inset: 0; background: rgba(15, 39, 68, 0.45);
  display: grid; place-items: center; padding: 24px; z-index: 20;
}
#jsonModal { z-index: 40; }
.modal-card {
  background: #fff; width: min(820px, 100%); max-height: 86vh; overflow: auto;
  border-radius: 18px; padding: 20px; box-shadow: var(--shadow);
}
.json-card, .detail-card { width: min(1100px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.year-block { border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 12px 0; background: #fbfdff; }
.year-block-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.field-group { margin: 14px 0; }
.field-group h5 {
  margin: 0 0 8px; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--teal);
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.field-row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.field-row:last-child { border-bottom: 0; }
.field-row span { color: var(--muted); font-size: 12px; display: flex; flex-direction: column; }
.field-row small { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; color: #94a3b8; }
.field-row b { font-size: 13px; text-align: right; max-width: 62%; white-space: normal; }
.raw-code { margin-left: 6px; color: #64748b; font-weight: 600; font-size: 11px; }
.detail-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 16px;
  margin: 10px 0 12px;
  font-size: 14px;
}
.detail-grid span { color: var(--muted); }
.detail-grid b { font-weight: 700; }
.json-inline { margin-top: 12px; }
.json-view {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 12px;
  overflow: auto;
  max-height: 68vh;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin: 0;
}
.json-key { color: #7dd3fc; }
.json-string { color: #86efac; }
.json-number { color: #fde68a; }
.json-boolean { color: #c4b5fd; }
.json-null { color: #fda4af; }

@media (max-width: 1100px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: relative; min-height: auto; flex-direction: row; flex-wrap: wrap; }
  .nav { flex-direction: row; }
  .stats-grid, .grid-2, .form-grid, .kv { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .main { padding: 16px; }
  .stats-grid, .grid-2, .form-grid, .kv, .detail-grid, .field-grid { grid-template-columns: 1fr; }
}
