:root {
  --bg: #f3f4f8;
  --bg-alt: #eaecf3;
  --card: #ffffff;
  --card-translucent: rgba(255, 255, 255, .85);
  --text: #14161a;
  --muted: #6b7280;
  --border: #e3e5ea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eaf1ff;
  --primary-text: #ffffff;
  --masuk: #16a34a;
  --masuk-bg: #dcfce7;
  --keluar: #dc2626;
  --keluar-bg: #fee2e2;
  --transfer: #4f46e5;
  --transfer-bg: #e0e7ff;
  --danger: #dc2626;
  --radius-sm: 9px;
  --radius: 14px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .07);
  --shadow: 0 6px 20px rgba(15, 23, 42, .09);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, .16);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --bg-alt: #171a21;
    --card: #1a1d24;
    --card-translucent: rgba(26, 29, 36, .85);
    --text: #e8eaed;
    --muted: #97a0ac;
    --border: #2a2e38;
    --primary: #3b82f6;
    --primary-dark: #60a5fa;
    --primary-light: #17223b;
    --primary-text: #ffffff;
    --masuk: #22c55e;
    --masuk-bg: #12301f;
    --keluar: #f87171;
    --keluar-bg: #391818;
    --transfer: #818cf8;
    --transfer-bg: #211f45;
    --danger: #f87171;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35);
    --shadow: 0 6px 20px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; }
p { margin: 0 0 8px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--card-translucent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .logo { font-size: 1.35rem; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; }

.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav a {
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
}
.nav a:hover { background: var(--bg-alt); text-decoration: none; }
.nav a.nav-keluar { color: var(--danger); }

@media (max-width: 760px) {
  .nav-toggle { display: flex; }
  .nav {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
  }
  .nav.nav-open { display: flex; }
  .nav a { padding: 12px 14px; }
}

/* ---------- Layout ---------- */
.konten { max-width: 1080px; margin: 0 auto; padding: 24px 20px 80px; }

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.92rem;
  cursor: pointer;
  border: 1px solid transparent;
}
.flash-sukses { background: var(--masuk-bg); color: var(--masuk); border-color: var(--masuk); }
.flash-error { background: var(--keluar-bg); color: var(--keluar); border-color: var(--keluar); }
.flash-sukses::before { content: "✅"; }
.flash-error::before { content: "⚠️"; }

.kartu {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.grid-akun { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.akun-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.akun-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.akun-item .nama { font-weight: 700; }
.akun-item .tipe { color: var(--muted); font-size: 0.78rem; text-transform: capitalize; }
.akun-item .saldo { font-size: 1.25rem; font-weight: 800; margin-top: 8px; }

.ringkasan-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.ringkasan-2 .kartu { margin-bottom: 0; }
.ringkasan-2 .nilai { font-size: 1.4rem; font-weight: 800; margin-top: 6px; }
.label { color: var(--muted); font-size: 0.85rem; }
.judul-kartu { font-size: 1rem; margin: 0 0 14px; }
.nilai.masuk { color: var(--masuk); }
.nilai.keluar { color: var(--keluar); }

/* ---------- Utilities ---------- */
.muted { color: var(--muted); }
.teks-kecil { font-size: 0.88rem; margin-top: -6px; }
.angka-besar { font-size: 1.85rem; font-weight: 800; }
.section-judul { font-size: 1.02rem; margin-top: 28px; }
.kartu-scroll { overflow-x: auto; }
.tombol-lebar { width: 100%; }
.pusat { text-align: center; }
.debug-pre { white-space: pre-wrap; font-family: monospace; padding: 20px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { color: var(--muted); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-alt); }
td[colspan] { text-align: center; color: var(--muted); padding: 28px 10px; }
td[colspan]:hover { background: none; }

.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.tag-masuk { background: var(--masuk-bg); color: var(--masuk); }
.tag-keluar { background: var(--keluar-bg); color: var(--keluar); }
.tag-transfer_masuk, .tag-transfer_keluar { background: var(--transfer-bg); color: var(--transfer); }

.jumlah.masuk, .jumlah.transfer_masuk { color: var(--masuk); font-weight: 700; white-space: nowrap; }
.jumlah.keluar, .jumlah.transfer_keluar { color: var(--keluar); font-weight: 700; white-space: nowrap; }

.aksi-baris { display: flex; gap: 12px; align-items: center; }
.aksi-baris button.tautan {
  background: none; border: none; padding: 0; font: inherit; cursor: pointer;
  color: var(--danger); text-decoration: underline;
}

@media (max-width: 700px) {
  .tabel-responsif thead { display: none; }
  .tabel-responsif, .tabel-responsif tbody, .tabel-responsif tr, .tabel-responsif td { display: block; width: 100%; }
  .tabel-responsif tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    padding: 2px 14px;
  }
  .tabel-responsif tr:hover { background: none; }
  .tabel-responsif td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: right;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border);
  }
  .tabel-responsif td:last-child { border-bottom: none; }
  .tabel-responsif td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    text-align: left;
  }
  .tabel-responsif td[colspan] { display: block; text-align: center; border: none; }
  .tabel-responsif .aksi-baris { justify-content: flex-end; }
}

/* ---------- Buttons ---------- */
.tombol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.tombol:hover { background: var(--primary-dark); text-decoration: none; }
.tombol:active { transform: scale(.97); }
.tombol.sekunder { background: var(--bg-alt); color: var(--text); border: 1px solid var(--border); }
.tombol.sekunder:hover { background: var(--border); }
.tombol-baris { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

a.tombol, button.tombol { text-decoration: none; }

.tombol:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Forms ---------- */
.form-kartu { max-width: 480px; }
.form-baris { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-baris label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
  background: var(--card);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  outline: none;
}
textarea { resize: vertical; }

.filter-baris { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: end; }
.filter-baris .form-baris { margin-bottom: 0; min-width: 150px; }

/* ---------- Login / setup ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top, var(--primary-light), var(--bg) 65%);
}
.login-kartu { width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); }
.login-logo { text-align: center; font-size: 2.3rem; margin-bottom: 6px; }
.login-kartu h1 { text-align: center; font-size: 1.35rem; margin-bottom: 4px; }
.login-kartu .teks-kecil { text-align: center; margin-bottom: 18px; }

/* ---------- Page header / misc ---------- */
.judul-halaman { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.judul-halaman h1 { font-size: 1.35rem; margin: 0; }

.progres-bar { background: var(--bg-alt); border-radius: 999px; overflow: hidden; height: 8px; margin-top: 6px; }
.progres-isi { width: 0; height: 100%; border-radius: 999px; transition: width .3s ease; }
.progres-isi.masuk { background: var(--masuk); }
.progres-isi.keluar { background: var(--keluar); }

.baris-kategori { display: flex; justify-content: space-between; padding: 9px 0 3px; font-size: 0.92rem; }
