:root {
  --teal: #0f6d5f; --teal-dark: #0b4f45; --teal-light: #e5f3f0;
  --polri: #21325c; --jr: #7c3aed; --red: #c62828; --amber: #f9a825;
  --gray: #5f6b76; --bg: #f2f5f4; --card: #fff; --line: #e3e8e6;
  --radius: 10px; --shadow: 0 1px 3px rgba(15,40,35,.12);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: #1e2a28; font-size: 14px; }
a { color: var(--teal); text-decoration: none; }

/* ---------- LOGIN ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, #d5efe9, transparent),
              radial-gradient(1000px 500px at 110% 110%, #e3e0f7, transparent), var(--bg); }
.login-card { width: 400px; max-width: 100%; background: var(--card); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(10,40,35,.18); overflow: hidden; }
.login-head { background: linear-gradient(135deg, var(--teal-dark), var(--teal)); color: #fff;
  padding: 26px; text-align: center; }
.login-head .logo { width: 64px; height: 64px; border-radius: 50%; background: #fff; display: inline-grid;
  place-items: center; margin-bottom: 10px; font-weight: 800; color: var(--teal); font-size: 10px;
  line-height: 1.15; text-align: center; }
.login-head h1 { font-size: 22px; letter-spacing: .5px; }
.login-head p { opacity: .85; font-size: 12px; margin-top: 4px; }
.login-body { padding: 24px; }
.login-body label { display: block; font-size: 12px; font-weight: 600; color: var(--gray); margin: 12px 0 4px; }
.login-body input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.login-body .btn { width: 100%; margin-top: 18px; }
.login-body .err { color: var(--red); font-size: 12.5px; margin-top: 10px; min-height: 18px; }
.login-body .hint { margin-top: 14px; background: var(--teal-light); border-radius: 8px; padding: 10px 12px;
  font-size: 11.5px; color: var(--teal-dark); line-height: 1.7; }
.login-bottom { display: flex; justify-content: space-between; align-items: center; padding: 10px 24px 20px; font-size: 11.5px; color: var(--gray); }
.inst-badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 10.5px; font-weight: 700; letter-spacing: .4px; }
.inst-rsu { background: var(--teal-light); color: var(--teal-dark); }
.inst-polri { background: #e4e9f8; color: var(--polri); }
.inst-jr { background: #f0e8fd; color: var(--jr); }
.inst-admin { background: #eef1f0; color: var(--gray); }

/* ---------- LAYOUT ---------- */
#app { display: none; }
.topbar { background: var(--teal-dark); color: #fff; display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.topbar .brand { font-weight: 800; font-size: 15px; letter-spacing: .5px; }
.topbar .brand small { display: block; font-weight: 400; font-size: 10.5px; opacity: .75; }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.topbar .who button { background: rgba(255,255,255,.14); color: #fff; }
nav.tabs { display: flex; gap: 4px; padding: 0 20px; background: var(--card); border-bottom: 1px solid var(--line);
  overflow-x: auto; position: sticky; top: 56px; z-index: 15; }
nav.tabs button { border: 0; background: transparent; padding: 12px 14px; font-size: 13.5px; font-weight: 600;
  color: var(--gray); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
nav.tabs button.active { color: var(--teal); border-bottom-color: var(--teal); }
#main { padding: 20px; max-width: 1200px; margin: 0 auto; }
#main > h2.title { font-size: 18px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }

/* ---------- KARTU & TABEL ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.kpi .val { font-size: 26px; font-weight: 800; color: var(--teal-dark); margin-top: 4px; }
.kpi .lbl { font-size: 12px; color: var(--gray); font-weight: 600; }
.kpi.sub { border-left: 4px solid var(--teal); }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--gray); padding: 8px 10px; border-bottom: 2px solid var(--line); }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
table.t tr:hover td { background: #fafcfb; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--gray); font-size: 12px; }
.small { font-size: 12px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.b-CREATED, .b-AWAITING_POLICE, .b-AWAITING_JR, .b-PENDING, .b-BELUM_DIVERIFIKASI { background: #fdeee0; color: #ad5d00; }
.b-MEDICAL_ONGOING, .b-IN_TREATMENT, .b-JAMINAN_BPJS, .b-PERLU_DOKUMEN, .b-NEED_DATA { background: #fef4d6; color: #8a6500; }
.b-POLICE_VERIFIED, .b-REFERRED, .b-VALID { background: #e0eefc; color: #14538f; }
.b-JR_VERIFIED, .b-TERJAMIN, .b-DISCHARGED, .b-DIVERIFIKASI, .b-DIBERIKAN { background: #e2f4e9; color: #147a45; }
.b-CLOSED { background: #e6ecea; color: #3c4b47; }
.b-INVALID, .b-TIDAK_TERJAMIN, .b-DIAJUKAN { background: #fdeaea; color: #b0392e; }
.b-LAKA_GANDA { background: #fde9e9; color: #b0392e; }
.b-LAKA_TUNGGAL { background: #e8eef6; color: #2c4f9c; }
.b-GARANTOR_JR, .b-GARANTOR_BPJS, .b-GARANTOR_PRIBADI, .b-GARANTOR_ASURANSI { background: #e7e1f6; color: #5b3aa8; }
.b-DOC_KTP, .b-DOC_LP, .b-DOC_TTP, .b-DOC_MEDICAL, .b-DOC_OTHER { background: #eef1f0; color: #4a5551; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 8px; padding: 8px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.polri { background: var(--polri); color: #fff; }
.btn.jr { background: var(--jr); color: #fff; }
.btn.ghost { background: #eff5f3; color: var(--teal-dark); border: 1px solid #cfe3dd; }
.btn.danger { background: #fbeeee; color: var(--red); border: 1px solid #f3c8c8; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, textarea, select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
label.f { display: block; font-size: 12px; font-weight: 600; color: var(--gray); margin: 10px 0 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
.hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--gray); }
.tl { border-left: 2px solid var(--line); margin: 10px 0 0 8px; padding-left: 16px; }
.tl .it { position: relative; padding: 4px 0 12px; }
.tl .it::before { content: ""; position: absolute; left: -22px; top: 8px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--teal); }
.tl .t { font-weight: 600; font-size: 13px; }
.tl .d { font-size: 12px; color: var(--gray); }
.notice { background: var(--teal-light); border-left: 4px solid var(--teal); padding: 10px 14px;
  border-radius: 8px; font-size: 13px; }
.notice.warn { background: #fff7e6; border-color: var(--amber); }
.notice.danger { background: #fdeaea; border-color: var(--red); }
.modal-back { position: fixed; inset: 0; background: rgba(10,30,26,.45); display: grid; place-items: start center;
  padding: 24px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 14px; width: 940px; max-width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .mhead { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal .mbody { padding: 20px; }
.modal .mfoot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px;
  justify-content: flex-end; background: #fafcfb; border-radius: 0 0 14px 14px; }
.hidden { display: none !important; }
.section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  color: var(--teal-dark); margin: 16px 0 8px; }
.mono { font-family: Consolas, monospace; font-size: 12.5px; background: var(--teal-light); padding: 2px 6px; border-radius: 5px; }
.p2 { padding: 2px; } .w100 { width: 100%; }
.empty { text-align: center; color: var(--gray); padding: 30px 10px; }
@media (max-width: 720px) {
  .topbar, nav.tabs { position: static; }
  .topbar { padding: 8px 12px; flex-direction: column; gap: 8px; align-items: flex-start; }
  .topbar .who { margin-left: 0; width: 100%; justify-content: space-between; flex-wrap: wrap; }
  nav.tabs { padding: 0 8px; gap: 2px; }
  nav.tabs button { padding: 10px 10px; font-size: 12px; }
  #main { padding: 12px; }
  .grid.c2 { grid-template-columns: 1fr; }
  .grid.c3 { grid-template-columns: 1fr; }
  .grid.c4 { grid-template-columns: repeat(2, 1fr); }
  .modal { border-radius: 10px; }
  .modal .mbody { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  table.t { font-size: 12px; }
  table.t th, table.t td { padding: 6px 8px; }
  .kpi .val { font-size: 20px; }
  .login-card { width: 100%; }
  .login-head { padding: 20px; }
  .login-head h1 { font-size: 18px; }
}
@media (max-width: 480px) {
  .grid.c4 { grid-template-columns: 1fr; }
  .row { flex-direction: column; align-items: stretch; }
  .topbar .brand { font-size: 13px; }
  .badge { font-size: 10px; padding: 2px 7px; }
}