:root {
  color-scheme: light;
  --bg: #f5f5f3;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6e6d68;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-track: #cde2fb;
  --good-bg: #e3f4e8;
  --good-ink: #145c2c;
  --danger: #c0392b;
  --wm-ink: #0b0b0b;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2f2f2c;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9a998f;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-track: #0d366b;
    --good-bg: #12351f;
    --good-ink: #8fd9a6;
    --danger: #ef7d70;
    --wm-ink: #f0efec;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232321;
  --border: #2f2f2c;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #9a998f;
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-track: #0d366b;
  --good-bg: #12351f;
  --good-ink: #8fd9a6;
  --danger: #ef7d70;
  --wm-ink: #f0efec;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 48px;
}
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

main { max-width: 1400px; margin: 0 auto; padding: 20px 16px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.btn-icon { width: 40px; height: 40px; padding: 0; font-size: 18px; line-height: 1; }
.brand-mark { color: var(--accent); font-size: 20px; }
.brand-title { font-weight: 650; }
.brand-sub { font-size: 12px; color: var(--muted); }

/* Buttons & fields */
.btn {
  font: inherit; font-size: 14px; font-weight: 550; cursor: pointer;
  border-radius: 8px; padding: 9px 14px; border: 1px solid transparent;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-outline { border-color: var(--border); color: var(--text); background: var(--surface); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); min-width: 0; }
select, input[type="text"], input[type="search"] {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; width: 100%; min-width: 0;
}
select:focus, input:focus, .btn:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Lock screen */
.lock { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 360px); gap: 20px; justify-content: center; padding-top: 24px; }
.lock-card { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.lock-card p { margin: 0; }
.msg { min-height: 1.2em; font-size: 14px; color: var(--danger); }
.lock-foot { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 14px; font-size: 14px; }
.lock-list { padding: 20px 24px; }
.lock-list ul { list-style: none; margin: 12px 0 0; padding: 0; }
.lock-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.lock-list li:last-child { border-bottom: 0; }
.lock-list .count { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--good-bg); color: var(--good-ink); margin-left: 6px; }

/* Dashboard */
.dash-head { margin-bottom: 16px; }
.dash-head p { margin: 4px 0 0; font-size: 14px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile-label { font-size: 13px; color: var(--text-2); }
.tile-value { font-size: 26px; font-weight: 650; margin-top: 2px; }
.tile-sub { font-size: 12px; color: var(--muted); }

.filters { padding: 16px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 14px; }
.filters-top { display: flex; gap: 12px; align-items: center; }
.cari-row { flex: 1; display: flex; gap: 8px; min-width: 0; }
.cari-row input { flex: 1; }
#btnFilter { display: none; }
.filters-more { display: flex; flex-direction: column; gap: 14px; }
.filters-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.filters-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface-2); flex-shrink: 0; }
.seg button { font: inherit; font-size: 14px; border: 0; background: transparent; color: var(--text-2); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }

.multi { position: relative; }
.multi summary {
  list-style: none; cursor: pointer; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 28px 9px 10px; background: var(--surface);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative;
}
.multi summary::-webkit-details-marker { display: none; }
.multi summary::after { content: "▾"; position: absolute; right: 10px; color: var(--muted); }
.multi-list {
  position: absolute; z-index: 5; left: 0; top: calc(100% + 4px); min-width: 100%; width: max-content; max-width: min(360px, 90vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px; box-shadow: 0 8px 24px rgb(0 0 0 / .12);
  max-height: 300px; overflow: auto;
}
.multi-list label { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px; font-size: 14px; color: var(--text); cursor: pointer; }
.multi-list label:hover { background: var(--surface-2); }
.multi-list input { accent-color: var(--accent); }

/* Table */
.table-card { overflow: hidden; }
.table-wrap { position: relative; overflow-x: auto; }
.table-wrap::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: var(--wm); background-repeat: repeat; opacity: .045;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th {
  position: sticky; top: 0; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--text-2);
  cursor: pointer; user-select: none; white-space: nowrap;
}
th:hover { color: var(--text); }
th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }
th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.lok { color: var(--text-2); font-size: 13px; min-width: 220px; }
td.ins { min-width: 180px; font-weight: 550; }
td.jab { min-width: 180px; }
td.gaji { white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
.frm { font-size: 12px; color: var(--text-2); white-space: nowrap; }

.pel { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 96px; }
.pel b { font-weight: 600; }
.pel small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.meter { width: 80px; height: 4px; border-radius: 4px; background: var(--accent-track); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.badge-good { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--good-bg); color: var(--good-ink); white-space: nowrap; }

.empty { padding: 32px; text-align: center; color: var(--muted); margin: 0; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; gap: 8px; font-size: 14px; }
.note { font-size: 12px; margin-top: 12px; }

/* Watermark kecil */
.wm-badge {
  position: fixed; right: 12px; bottom: 10px; z-index: 20;
  font-size: 11px; color: var(--muted); letter-spacing: .3px;
  background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--border);
  padding: 3px 10px; border-radius: 99px; pointer-events: none;
}

/* Responsif */
@media (max-width: 1100px) {
  .filters-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .lock { grid-template-columns: minmax(0, 1fr); padding-top: 0; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-top { flex-direction: column; align-items: stretch; }
  .seg { align-self: flex-start; }
}
@media (max-width: 720px) {
  main { padding: 16px; }
  h1 { font-size: 19px; }
  .tile-value { font-size: 22px; }
  .filters-grid { grid-template-columns: minmax(0, 1fr); }
  .lock-card, .lock-list { padding: 18px; }
  select, input[type="text"], input[type="search"] { font-size: 16px; } /* cegah auto-zoom iOS */
  #btnFilter { display: inline-flex; }
  #btnFilter[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
  .filters-more:not(.open) { display: none; }

  /* Tabel jadi kartu */
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  td { border: 0; padding: 2px 0; min-width: 0 !important; text-align: left; }
  td.ins { font-size: 15px; }
  td.num { display: flex; justify-content: space-between; gap: 12px; }
  td.num::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
  td.pelc { padding-top: 6px; }
  .pel { align-items: flex-end; }
  .filters-actions { width: 100%; }
  .filters-actions select { flex: 1; }
}
.filters-actions { display: flex; gap: 8px; align-items: center; }
.filters-actions select { width: auto; }
