:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #75746f;
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --grid: #e8e7e2;
  --good: #0a7a3c;
  --critical: #c42b2b;
  --danger-bg: #fdecec;
  --warn-bg: #fff4dc;
  --ok-bg: #e7f5ec;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 1px rgba(0, 0, 0, .03);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2f2f2c;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --text-3: #9a998f;
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --grid: #2a2a27;
    --good: #4cc27a;
    --critical: #f07070;
    --danger-bg: #3a1d1d;
    --warn-bg: #3a2f14;
    --ok-bg: #16301f;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232321;
  --border: #2f2f2c;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --text-3: #9a998f;
  --accent: #3987e5;
  --accent-ink: #ffffff;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --grid: #2a2a27;
  --good: #4cc27a;
  --critical: #f07070;
  --danger-bg: #3a1d1d;
  --warn-bg: #3a2f14;
  --ok-bg: #16301f;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
:root[data-theme="dark"] a { color: color-mix(in srgb, var(--accent) 50%, white); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) a { color: color-mix(in srgb, var(--accent) 50%, white); } }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
.muted { color: var(--text-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num, .kpi-value, .table td.num { font-variant-numeric: tabular-nums; text-align: right; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 38px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
label { display: grid; gap: 4px; font-weight: 500; font-size: 13px; color: var(--text-2); }
label input, label select, label textarea { font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
  border-radius: 8px; padding: 8px 14px; min-height: 38px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--critical); }
.btn.primary.danger-fill { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.icon { padding: 6px 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); display: grid; gap: 14px; padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.login-card p { margin: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700;
}
.form-error { color: var(--critical); margin: 0; min-height: 1em; font-size: 13px; }

/* Shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 20px;
  padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a {
  color: var(--text-2); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-weight: 500;
}
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar nav a.active { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; display: grid; gap: 6px; }
.who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 4px 4px; }
.badge {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2);
}
.badge.cr { background: var(--ok-bg); color: var(--good); }
.badge.db { background: var(--danger-bg); color: var(--critical); }
.badge.warn { background: var(--warn-bg); color: var(--text); }

.main { min-width: 0; padding: 0 24px 40px; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 0; background: var(--bg);
}
.topbar h1 { margin-right: auto; }
.period { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.custom-range { display: inline-flex; align-items: center; gap: 6px; }
.menu-btn { display: none; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  display: grid; gap: 2px; padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.kpi-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi-value { text-align: left; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.kpi-sub { color: var(--text-3); font-size: 12px; }
.kpi-sub .up { color: var(--good); }
.kpi-sub .down { color: var(--critical); }

/* Cards */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-width: 0; margin-bottom: 16px;
}
.grid-2 .card { margin-bottom: 0; }
.card.wide { grid-column: 1 / -1; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head.pad { padding: 16px 16px 0; }
.card-head h2 { margin-right: auto; }
.hint { color: var(--text-3); font-size: 12px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.s1 { background: var(--series-1); }
.sw.s2 { background: var(--series-2); }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 320px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table.compact td, .table.compact th { padding: 8px 4px; }
.table th.num { text-align: right; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable[aria-sort="ascending"]::after { content: " ▲"; font-size: 10px; }
.table th.sortable[aria-sort="descending"]::after { content: " ▼"; font-size: 10px; }
.table .amt-cr { color: var(--good); font-weight: 600; }
.table .amt-db { color: var(--text); font-weight: 600; }
.table .desc-main { font-weight: 500; }
.table .desc-sub { color: var(--text-3); font-size: 12px; }
.table .empty-row td { text-align: center; color: var(--text-2); padding: 28px; }
.actions-col { width: 1%; white-space: nowrap; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.bar-cell { position: relative; }
.bar-cell .bar { height: 6px; border-radius: 3px; margin-top: 4px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar p { margin: 0; }
.toolbar input[type="search"] { flex: 1 1 240px; min-width: 0; }
.spacer { flex: 1; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 12px;
}
.chip button { border: 0; background: none; color: var(--text-2); cursor: pointer; font-size: 14px; padding: 0 4px; }
.tx-summary { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; margin-bottom: 10px; }
.tx-summary strong { color: var(--text); font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager .btns { display: flex; gap: 6px; }

/* Upload */
.dropzone {
  display: grid; gap: 4px; justify-items: center; text-align: center; padding: 28px 16px; cursor: pointer;
  border: 1.5px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text);
}
.dropzone.drag { border-color: var(--accent); }
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.upload-files { font-size: 13px; color: var(--text); font-weight: 500; }
.upload-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); }
.check input { min-height: 0; }
.result-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.result-list li { padding: 10px 12px; border-radius: 8px; font-size: 13px; background: var(--surface-2); }
.result-list li.ok { background: var(--ok-bg); }
.result-list li.err { background: var(--danger-bg); }
.result-list li.skip { background: var(--warn-bg); }

.empty { text-align: center; padding: 64px 16px; }
.empty h2 { font-size: 18px; margin-bottom: 6px; }

/* Modal */
dialog {
  width: min(520px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 14px;
  padding: 0; background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
#modal-form { display: grid; gap: 14px; padding: 22px; }
#modal-body { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.detail-grid { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.detail-grid dt { color: var(--text-2); }
.detail-grid dd { margin: 0; word-break: break-word; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0;
  padding: 10px 16px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 13px;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


/* White label */
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; display: block; }
.brand-mark.has-logo { background: var(--surface); border: 1px solid var(--border); overflow: hidden; }
.brand-login .brand-mark { width: 40px; height: 40px; }
[data-brand-name] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.settings-grid .card { margin: 0; }
.settings-grid .wide-col { grid-column: 1 / -1; }
.form-stack { display: grid; gap: 14px; }
.form-stack .hint { font-weight: 400; }
.color-row { display: flex; gap: 8px; }
.color-row input[type="color"] { width: 48px; padding: 4px; flex: none; cursor: pointer; }
.color-row input:not([type]) { flex: 1; min-width: 0; }
.logo-row { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.logo-preview {
  width: 112px; height: 112px; border-radius: 16px; border: 1px dashed var(--border); background: var(--surface-2);
  display: grid; place-items: center; overflow: hidden; flex: none; color: var(--text-3); font-size: 12px; text-align: center;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-row .form-stack { flex: 1; min-width: 200px; }
.logo-row label.btn, .logo-row button.btn { justify-self: start; }
.brand-preview { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding: 16px; border-radius: 10px; background: var(--bg); }

/* Pilih & hapus massal */
.sel-col { width: 1%; padding-right: 0 !important; }
.sel-col input { width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; accent-color: var(--accent); cursor: pointer; }
.table tbody tr.selected td { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.bulk-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; padding: 8px 12px;
  border-radius: 10px; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  position: sticky; top: 70px; z-index: 4;
}
.bulk-bar.inset { margin: 12px 16px 0; position: static; }

/* Pilihan rekening */
.account-row { margin: -4px 0 16px; }
.account-tabs {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); max-width: 100%;
}
.account-tabs button {
  display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 500; cursor: pointer;
  border: 0; border-radius: 7px; padding: 7px 14px; min-height: 36px; background: transparent; color: var(--text-2);
}
.account-tabs button:hover { color: var(--text); background: var(--surface-2); }
.account-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.account-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.bank-BCA { background: var(--series-3); }
.dot.bank-JAGO { background: var(--series-4); }
.account-tabs button[aria-selected="true"] .dot { box-shadow: 0 0 0 2px var(--accent-ink); }
.badge.bank { text-transform: none; letter-spacing: 0; border: 1px solid transparent; }
.badge.bank-BCA { background: color-mix(in srgb, var(--series-3) 16%, transparent); border-color: color-mix(in srgb, var(--series-3) 45%, transparent); color: var(--text); }
.badge.bank-JAGO { background: color-mix(in srgb, var(--series-4) 18%, transparent); border-color: color-mix(in srgb, var(--series-4) 50%, transparent); color: var(--text); }
.badge.internal { background: transparent; border: 1px dashed var(--border); }
.note {
  margin: 0 0 12px; padding: 10px 14px; border-radius: 8px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}
.nowrap { white-space: nowrap; }
.kpi-sub .badge { font-size: 10px; padding: 1px 6px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .settings-grid { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 20; left: 0; top: 0; width: 240px; transform: translateX(-100%);
    transition: transform .2s; box-shadow: 0 0 24px rgba(0, 0, 0, .2);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .main { padding: 0 16px 32px; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpi-value { font-size: 19px; }
  .form-row { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 17px; }
}
@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr; }
}
