/* Gaya khusus halaman keuangan. Pakai variabel warna dari style.css (:root) supaya mode gelap ikut. */
/* Semua halaman keuangan dibungkus .keu (jurnal, laporan, pajak, daftar akun, aset tetap, impor). */

.keu .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.keu input[type=search], .keu input[type=month] {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: inherit;
}
:root[data-tema="gelap"] .keu input[type=search], :root[data-tema="gelap"] .keu input[type=month] { background-color: var(--surface-2); }
.keu input, .keu select, .keu textarea { color: var(--ink); }
.keu .keu-lebar { flex: 2; }
.keu .keu-lebar3 { flex: 3; }
.keu .keu-tgl { flex: 0 0 170px; }
.keu .keu-kode { width: 130px; }
.keu .keu-tahun { width: 140px; }
.keu .keu-bulan { width: 190px; }
.keu .keu-batas { max-width: 260px; }
.keu .keu-pilih-tahun { width: auto; min-width: 130px; }
.keu .keu-tombol-baris { display: flex; gap: 6px; flex-wrap: wrap; }
.keu .keu-lencana { margin-left: 6px; }
.keu .keu-stat { margin-bottom: 16px; }
.keu .keu-petunjuk { margin: -2px 0 8px; }
.keu .keu-tahun-tutup { display: inline-flex; align-items: center; gap: 2px; margin: 0 10px 6px 0; }
.keu .keu-kepala-kartu { padding: 16px 20px 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.keu .keu-langkah { margin: 8px 0 0; padding-left: 20px; color: var(--ink-2); }
.keu .keu-kotak { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.keu .keu-tempel { min-height: 220px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.keu .keu-ringkas > div { min-width: 120px; }
.keu .kartu-aksi { white-space: nowrap; }
.keu .kartu-aksi .btn + .btn { margin-left: 6px; }
.keu .kartu-redup td { color: var(--ink-3); }
.keu td.indent2 { padding-left: 42px; }
.keu td.minus, .keu .minus { color: var(--danger); }
.keu .memudar { opacity: .6; }
.keu .hanya-cetak { display: none; }
.keu tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.keu tr.terbuka td { background: var(--surface-2); }

/* rincian baris jurnal (dibuka dengan mengeklik transaksi) */
.keu .keu-rincian > td { background: var(--surface-2); padding: 2px 12px 12px 58px; }
.keu .keu-rincian table th { background: transparent; }

/* progres impor */
.keu .keu-progres { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 12px; }
.keu .keu-progres > span { display: block; height: 100%; background: var(--accent); transition: width .15s linear; }

/* tab laporan: satu baris yang bisa digeser di layar sempit */
.keu .keu-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.keu .keu-tabs button { white-space: nowrap; flex: 0 0 auto; }

/* lembar laporan */
.keu .sheet { transition: opacity .15s; }
.keu .tabel-gulir > table.keu-besar { min-width: 620px; }
.keu .tabel-gulir > table.keu-saldo { min-width: 480px; }
.keu table.keu-dua td:last-child, .keu table.keu-tiga td.num { white-space: nowrap; width: 1%; padding-left: 14px; }
.keu table.keu-dua td:first-child { overflow-wrap: anywhere; }

/* ---------- Baris form jurnal (grid, jadi kartu di HP) ---------- */
.keu .baris-jurnal {
  display: grid; grid-template-columns: minmax(0, 1fr) 132px 132px minmax(0, 170px) 36px;
  gap: 6px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line);
}
.keu .baris-jurnal.kepala { font-size: 13px; color: var(--ink-2); font-weight: 500; padding-top: 0; border-bottom-color: var(--line-2); }
.keu .baris-jurnal > label { margin: 0; min-width: 0; }
.keu .baris-jurnal .bj-label { display: none; }
.keu .baris-jurnal select, .keu .baris-jurnal input { padding: 6px 8px; }
.keu .baris-jurnal .del {
  color: var(--ink-3); background: none; border: 1px solid transparent; cursor: pointer; font-size: 20px; line-height: 1;
  width: 36px; height: 36px; border-radius: var(--radius);
}
.keu .baris-jurnal .del:hover, .keu .baris-jurnal .del:focus-visible { color: var(--danger); border-color: var(--danger-line); }
.keu .keu-selisih { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Modal keuangan ---------- */
.keu .keu-modal.kecil { max-width: 440px; }
.keu .keu-modal .modal-foot { position: sticky; bottom: -22px; background: var(--surface); padding: 12px 0 2px; margin-bottom: -2px; }

/* ---------- Tabel yang menjadi kartu di layar sempit ---------- */
@media (max-width: 640px) {
  .keu .keu-kartu, .keu .keu-kartu tbody { display: block; width: 100%; }
  .keu .keu-kartu thead { display: none; }
  .keu .keu-kartu tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px;
    padding: 12px 14px; border-bottom: 1px solid var(--line);
  }
  .keu .keu-kartu td { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 2px 0; border: 0; text-align: right; grid-column: 1 / -1; min-width: 0; }
  .keu .keu-kartu td[data-label]::before { content: attr(data-label); color: var(--ink-3); font-size: 13px; text-align: left; font-weight: 400; }
  .keu .keu-kartu td > .badge { flex: 0 0 auto; align-self: center; }
  .keu .keu-kartu td.kartu-judul { display: block; text-align: left; font-weight: 500; order: -1; overflow-wrap: anywhere; }
  .keu .keu-kartu td.kartu-judul .small { font-weight: 400; }
  .keu .keu-kartu td.kartu-aksi { justify-content: flex-start; padding-top: 8px; flex-wrap: wrap; gap: 8px; }
  .keu .keu-kartu td.kartu-aksi:empty { display: none; }
  .keu .keu-kartu td.kartu-aksi .btn + .btn { margin-left: 0; }
  .keu .keu-kartu td.kartu-penuh { flex-direction: column; align-items: stretch; text-align: left; gap: 4px; }
  .keu .keu-kartu td.kartu-sembunyi, .keu .keu-kartu td:empty { display: none; }
  .keu .keu-kartu tr.section { display: block; padding: 8px 14px; background: var(--surface-2); }
  .keu .keu-kartu tr.section td { display: block; text-align: left; background: transparent; padding: 0; }
  .keu .keu-kartu tr.total { background: var(--surface-2); }
  .keu .keu-kartu tr.total td { border: 0; }
  .keu .keu-kartu tr.total td:first-child { display: block; text-align: left; }
  .keu .keu-kartu tr.clickable:hover td { background: transparent; }
  .keu .keu-kartu tr.terbuka { background: var(--surface-2); }
  .keu .keu-kartu tr.terbuka td { background: transparent; }
  .keu .keu-kartu .keu-rincian { display: block; padding: 0 14px 12px; background: var(--surface-2); }
  .keu .keu-kartu .keu-rincian > td { display: block; padding: 0; text-align: left; background: transparent; }
  .keu .keu-kartu .keu-rincian table { display: table; width: 100%; }
  .keu .keu-kartu .keu-rincian table thead { display: table-header-group; }
  .keu .keu-kartu .keu-rincian table tbody { display: table-row-group; }
  .keu .keu-kartu .keu-rincian table tr { display: table-row; padding: 0; }
  .keu .keu-kartu .keu-rincian table td, .keu .keu-kartu .keu-rincian table th { display: table-cell; padding: 6px 4px; border-bottom: 1px solid var(--line); }
  .keu .keu-kartu .keu-rincian table td:first-child { text-align: left; }
  .keu .keu-kartu .keu-rincian table td.num { width: 1%; }
  .keu table.keu-gagal { border-top: 1px solid var(--line); }
}
/* sel yang hanya berarti di tampilan kartu (HP) */
@media (min-width: 641px) { .keu td.kartu-hp { visibility: hidden; } }

/* ---------- HP ---------- */
@media (max-width: 640px) {
  .keu .keu-tgl { flex: 1 1 100%; }
  .keu .row > * { min-width: 0; flex-basis: 100%; }
  .keu .row > .fixed { flex-basis: auto; }
  .keu .keu-kode { width: 100%; }
  .keu .keu-tahun, .keu .keu-bulan { width: auto; flex: 1 1 140px; }
  .keu .keu-preset .field-label { display: none; }
  .keu .keu-ringkas > div { flex: 1 1 40%; }
  .keu .keu-ringkas > .fixed { flex-basis: 100%; }
  .keu .keu-ringkas > .fixed .btn { width: 100%; justify-content: center; }
  .keu .keu-ringkas > .fixed .field-label { display: none; }
  .keu .btn { min-height: 40px; }
  .keu .btn.sm { min-height: 36px; padding: 6px 12px; }
  .keu .check { min-height: 36px; }
  .keu .check input { width: 20px; height: 20px; }
  .keu .page-actions { width: 100%; }
  .keu .page-actions > .btn, .keu .page-actions > select { flex: 1 1 auto; justify-content: center; }
  .keu .sheet { padding: 16px 12px 20px; }
  .keu .sheet-head h2 { font-size: 18px; }
  .keu .keu-neraca { gap: 0; }
  .keu .sheet td { padding: 6px 4px; }
  .keu td.indent { padding-left: 14px; }
  .keu td.indent2 { padding-left: 26px; }
  .keu .keu-kepala-kartu { padding: 14px 14px 6px; }
  /* neraca saldo muat di layar HP: kolom kode disembunyikan, angka lebih kecil */
  .keu .tabel-gulir > table.keu-saldo { min-width: 0; font-size: 13px; }
  .keu table.keu-saldo th, .keu table.keu-saldo td { width: auto !important; }
  .keu table.keu-saldo .keu-kode-sel { display: none; }
  .keu .tabel-gulir > table.keu-besar { font-size: 13px; }
  .keu input, .keu select, .keu textarea { font-size: 16px; }   /* iOS tidak memperbesar layar saat fokus */

  /* form jurnal: setiap baris menjadi kartu */
  .keu .baris-jurnal.kepala { display: none; }
  .keu .baris-jurnal {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; grid-template-areas: "akun akun hapus" "d k k" "memo memo memo";
    gap: 8px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
  }
  .keu .baris-jurnal .bj-label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 3px; }
  .keu .baris-jurnal .bj-akun { grid-area: akun; }
  .keu .baris-jurnal .bj-d { grid-area: d; }
  .keu .baris-jurnal .bj-k { grid-area: k; }
  .keu .baris-jurnal .bj-memo { grid-area: memo; }
  .keu .baris-jurnal .bj-hapus { grid-area: hapus; align-self: end; width: 40px; height: 40px; border-color: var(--line-2); }

  /* modal menjadi layar penuh, tombol simpan tetap terlihat di bawah */
  .keu .modal-back { padding: 0; place-items: stretch; }
  .keu .keu-modal, .keu .keu-modal.wide, .keu .keu-modal.kecil {
    max-width: none; width: 100%; height: 100%; max-height: none; border-radius: 0; padding: 18px 16px 0;
    display: flex; flex-direction: column;
  }
  .keu .keu-modal.kecil { height: auto; margin-top: auto; border-radius: 16px 16px 0 0; padding-bottom: 8px; }
  .keu .keu-modal .modal-foot {
    position: sticky; bottom: 0; margin: auto -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); background: var(--surface);
  }
  .keu .keu-modal .modal-foot .btn { flex: 1; justify-content: center; }
  .keu .balance-bar { font-size: 14px; }
}

/* HP: kartu jurnal ringkas & saringan dua kolom */
@media (max-width: 640px) {
  .keu .card.filters .row > .field { flex: 1 1 calc(50% - 6px); }
  .keu .card.filters .row > .keu-lebar { flex-basis: 100%; }
  .keu .card.filters { padding: 14px; }
  .keu .card.filters .fixed > .field-label, .keu .row > .fixed > .field-label[aria-hidden] { display: none; }
  .keu .keu-jurnal tr:not(.keu-rincian) { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
  .keu .keu-jurnal tr:not(.keu-rincian) > td { display: block; width: auto; flex: 0 0 auto; text-align: left; padding: 0; }
  .keu .keu-jurnal td::before { content: none !important; }
  .keu .keu-jurnal tr:not(.keu-rincian) > td.kartu-judul { flex-basis: 100%; order: 0; margin-bottom: 2px; }
  .keu .keu-jurnal tr:not(.keu-rincian) > td:nth-child(1) { order: 1; font-size: 13px; }
  .keu .keu-jurnal tr:not(.keu-rincian) > td:nth-child(1)::before { content: "#" !important; }
  .keu .keu-jurnal tr:not(.keu-rincian) > td:nth-child(2) { order: 2; font-size: 13px; color: var(--ink-2); }
  .keu .keu-jurnal tr:not(.keu-rincian) > td:nth-child(5) { order: 3; margin-left: auto; font-weight: 600; }
  .keu .keu-jurnal tr:not(.keu-rincian) > td:nth-child(4) { order: 4; }
  .keu .keu-jurnal tr:not(.keu-rincian) > td.kartu-aksi { order: 5; margin-left: auto; padding-top: 4px; display: flex; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .keu .sheet, .keu .keu-progres > span { transition: none; }
}

/* ---------- Cetak: hitam-putih, apa pun temanya ---------- */
@media print {
  :root:has(.keu), :root[data-tema="gelap"]:has(.keu) {
    --ink: black; --ink-2: black; --ink-3: dimgray; --paper: white; --surface: white; --surface-2: white;
    --line: silver; --line-2: gray; --accent: black; --accent-ink: black; --accent-soft: white;
    --danger: black; --danger-ink: black; --danger-soft: white; --warn: black; --warn-soft: white;
    color-scheme: light;
  }
  :root:has(.keu) body { background: white; color: black; }
  :root:has(.keu) *, :root:has(.keu) body { transition: none !important; }
  .keu .card.tight { border: 0; }
  .keu .card { border-color: silver; break-inside: avoid; }
  .keu .no-print, .keu .keu-modal, .keu .modal-back { display: none !important; }
  .keu .hanya-cetak { display: block; }
  .keu .sheet { border: 0; border-top: 2px solid black; padding: 8px 0 0; box-shadow: none; }
  .keu .tabel-gulir { overflow: visible; }
  .keu .tabel-gulir > table { min-width: 0; }
  .keu tr { break-inside: avoid; }
  .keu .badge { border: 1px solid gray; background: white; color: black; }
  .keu .grid.cols-2.keu-neraca { grid-template-columns: 1fr 1fr; }
  /* tabel kartu kembali menjadi tabel biasa saat dicetak */
  .keu .keu-kartu thead { display: table-header-group; }
}
