:root {
  --bg: #f4f6f9; --panel: #ffffff; --teks: #1f2933; --redup: #6b7785; --garis: #dde3ea;
  --utama: #1f5f99; --utama-gelap: #174a78; --sisi: #16324f; --sisi-teks: #d5e1ee; --sisi-aktif: #24527f;
  --baik: #1e7b4f; --buruk: #b3261e; --kuning: #fff6d6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 Tahoma, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--teks); }
a { color: var(--utama); text-decoration: none; }
a:hover { text-decoration: underline; }

/* kerangka */
.aplikasi { display: flex; min-height: 100vh; }
.sisi { width: 270px; flex-shrink: 0; background: var(--sisi); color: var(--sisi-teks); overflow-y: auto; max-height: 100vh; position: sticky; top: 0; }
.sisi .merek { padding: 16px; font-weight: bold; font-size: 17px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.1); }
.sisi .merek small { display: block; font-weight: normal; font-size: 12px; color: var(--sisi-teks); }
.menu, .menu ul { list-style: none; margin: 0; padding: 0; }
.menu ul { padding-left: 12px; }
.menu details > summary { cursor: pointer; padding: 6px 14px; list-style: none; }
.menu details > summary::before { content: "\25B8"; display: inline-block; width: 14px; transition: transform .15s; }
.menu details[open] > summary::before { transform: rotate(90deg); }
.menu summary:hover { background: rgba(255,255,255,.06); }
.menu .item { display: block; padding: 5px 14px 5px 28px; color: var(--sisi-teks); }
.menu .item.web { color: #fff; font-weight: bold; }
.menu .item.web::after { content: " \25CF"; color: #7fd1a8; font-size: 10px; }
.menu .item.aktif { background: var(--sisi-aktif); }
.menu .item.nonweb { opacity: .45; cursor: default; }
.menu .item.nonweb:hover { text-decoration: none; }
.utama { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.atas { background: var(--panel); border-bottom: 1px solid var(--garis); padding: 10px 20px; display: flex; align-items: center; gap: 12px; }
.atas h1 { font-size: 18px; margin: 0; flex: 1; }
.atas .user { color: var(--redup); }
.isi { padding: 20px; }
.tombol-menu { display: none; }

/* komponen */
.panel { background: var(--panel); border: 1px solid var(--garis); border-radius: 6px; padding: 16px; margin-bottom: 16px; }
.panel h2 { font-size: 15px; margin: 0 0 12px; }
.filter { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--redup); }
input[type=text], input[type=number], input[type=password], select {
  font: inherit; padding: 6px 8px; border: 1px solid #c3ccd6; border-radius: 4px; background: #fff; color: var(--teks); min-width: 0;
}
.pilihan { display: flex; gap: 12px; padding: 6px 0; color: var(--teks); font-size: 14px; }
.pilihan label { flex-direction: row; align-items: center; gap: 4px; color: var(--teks); font-size: 14px; }
.btn { font: inherit; padding: 7px 16px; border-radius: 4px; border: 1px solid var(--utama); background: var(--utama); color: #fff; cursor: pointer; display: inline-block; }
.btn:hover { background: var(--utama-gelap); text-decoration: none; }
.btn.garis { background: #fff; color: var(--utama); }
.btn.garis:hover { background: #eef4fa; }
.catatan { color: var(--redup); font-size: 12px; margin-top: 10px; }
.peringatan { background: var(--kuning); border: 1px solid #ecd48a; padding: 8px 12px; border-radius: 4px; margin-bottom: 12px; }
.ringkas { display: flex; flex-wrap: wrap; gap: 24px; margin-bottom: 12px; }
.ringkas div { font-size: 12px; color: var(--redup); }
.ringkas b { display: block; font-size: 18px; color: var(--teks); }

/* tabel */
.gulung { overflow: auto; max-height: 60vh; border: 1px solid var(--garis); border-radius: 4px; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th { position: sticky; top: 0; background: #eaf0f6; text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--garis); white-space: nowrap; }
table.data td { padding: 5px 8px; border-bottom: 1px solid #eef1f4; }
table.data tr:nth-child(even) td { background: #f8fafc; }
table.data .kanan { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data .tengah { text-align: center; }
table.data tr.total td { font-weight: bold; background: #eaf0f6; }
.min { color: var(--buruk); }
.label { font-size: 11px; padding: 1px 6px; border-radius: 8px; white-space: nowrap; }
.label.ok { background: #dff3e8; color: var(--baik); }
.label.belum { background: #fde2e0; color: var(--buruk); }

/* login */
.halaman-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, #16324f, #1f5f99); }
.kotak-login { background: #fff; border-radius: 8px; padding: 28px; width: 100%; max-width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.kotak-login h1 { margin: 0 0 4px; font-size: 20px; }
.kotak-login p { margin: 0 0 20px; color: var(--redup); }
.kotak-login label { display: block; font-size: 12px; color: var(--redup); margin-bottom: 4px; }
.kotak-login input { width: 100%; margin-bottom: 14px; }
.kotak-login .btn { width: 100%; }
.galat { background: #fde2e0; color: var(--buruk); padding: 8px 10px; border-radius: 4px; margin-bottom: 14px; font-size: 13px; }

@media (max-width: 800px) {
  .sisi { position: fixed; left: -280px; z-index: 10; transition: left .2s; height: 100vh; }
  .sisi.buka { left: 0; }
  .tombol-menu { display: inline-block; }
  .isi { padding: 12px; }
}

/* kartu stok */
table.data tr.masalah td { background: #fdecea; }
table.data tr.rinci > td { background: #f3f7fb; padding: 10px 14px 14px; border-bottom: 2px solid #c9d8e8; }
.fifo h4 { margin: 8px 0 6px; font-size: 13px; }
.fifo p { margin: 4px 0; color: var(--redup); }
.fifo table.data { width: auto; min-width: 60%; background: #fff; margin-bottom: 6px; }
.fifo table.data th { position: static; }
.label { background: #eef1f4; color: var(--redup); }

/* daftar transaksi gl */
table.data tr.kepala-akun td { background: #dfe9f4; font-weight: bold; padding-top: 8px; }
table.data td.teks-panjang { max-width: 320px; }
.ringkasan-akun { margin-bottom: 12px; }
.ringkasan-akun summary { cursor: pointer; color: var(--utama); margin-bottom: 8px; }

/* neraca & laba rugi */
.dua-kolom { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .dua-kolom { grid-template-columns: 1fr; } }
table.laporan td.kode { white-space: nowrap; color: var(--redup); width: 70px; }
table.laporan tr.akun-induk td { font-weight: bold; }
table.laporan tr.level-0 td { background: #f1f5f9; }
/* laba rugi: baris "Jumlah ..." di bawah rincian tiap kelompok akun */
table.laporan tr.jumlah-kelompok td { border-top: 1px solid #9aa7b4; }
table.data tr.hasil-lr td { font-weight: bold; background: #fff6d6; }
table.data tr.hasil-lr.akhir td { font-size: 14px; background: #ffe9a8; }

/* tab halaman (bingkai di Beranda) */
[hidden] { display: none !important; }
html.dalam-tab .sisi, html.dalam-tab .atas { display: none; }
html.dalam-tab .aplikasi { min-height: 0; }
body.shell .aplikasi { height: 100vh; }
body.shell .utama { height: 100vh; overflow: hidden; }
body.shell .atas h1 { font-size: 16px; }
.tab-bar { display: flex; gap: 2px; align-items: flex-end; background: #e3e9f0; padding: 5px 8px 0; overflow-x: auto; border-bottom: 1px solid var(--garis); flex-shrink: 0; min-height: 36px; }
.tab-bar .tab { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 12px; border: 1px solid #cfd8e2; border-bottom: none; border-radius: 6px 6px 0 0;
  background: #f1f4f8; color: var(--redup); cursor: pointer; white-space: nowrap; font-size: 13px; max-width: 230px; user-select: none; }
.tab-bar .tab:hover { background: #fafbfc; color: var(--teks); }
.tab-bar .tab.aktif { background: var(--bg); color: var(--teks); font-weight: bold; border-color: var(--garis); position: relative; top: 1px; }
.tab-bar .label-tab { overflow: hidden; text-overflow: ellipsis; }
.tab-bar .tutup { border: 0; background: none; cursor: pointer; color: var(--redup); font-size: 15px; line-height: 1; padding: 0 3px; border-radius: 3px; }
.tab-bar .tutup:hover { background: #d5dde6; color: var(--buruk); }
.tab-isi { flex: 1; position: relative; min-height: 0; }
.tab-isi > .panel-tab { position: absolute; inset: 0; overflow: auto; }
.tab-isi iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }

/* ===== cetak report (tombol Cetak / Ctrl+P) ===== */
.kop-cetak { display: none; }
@media print {
  @page { margin: 12mm 10mm 14mm; @bottom-right { content: "Halaman " counter(page) " dari " counter(pages); font: 8pt Tahoma, Arial, sans-serif; color: #555; } }
  html, body { background: #fff !important; color: #000; font-size: 9pt; }
  .sisi, .atas, .tab-bar, form.panel, .btn, .tanpa-cetak, .catatan, .buka-fifo::after, script { display: none !important; }
  .aplikasi, .utama, body.shell .aplikasi, body.shell .utama { display: block; height: auto; overflow: visible; min-height: 0; }
  .isi { padding: 0; }
  .panel { border: 0; padding: 0; margin: 0 0 8px; box-shadow: none; }
  .gulung { max-height: none !important; overflow: visible !important; border: 0; }
  .kop-cetak { display: block; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 10px; }
  .kop-nama { font-size: 13pt; font-weight: bold; }
  .kop-alamat { font-size: 8pt; color: #333; }
  .kop-judul { font-size: 12pt; font-weight: bold; margin-top: 6px; text-transform: uppercase; }
  .kop-filter { font-size: 8.5pt; margin-top: 2px; }
  .kop-dicetak { font-size: 7.5pt; color: #555; margin-top: 2px; }
  .ringkas { gap: 16px; margin-bottom: 6px; }
  .ringkas b { font-size: 10pt; }
  .peringatan { background: none; border: 1px solid #999; padding: 4px 6px; font-size: 8pt; }
  table.data { font-size: 8pt; width: 100%; }
  table.data th { position: static; background: #e6e6e6 !important; border-bottom: 1px solid #000; padding: 3px 4px; }
  table.data td { padding: 2px 4px; border-bottom: 1px solid #ddd; }
  table.data thead { display: table-header-group; }   /* judul kolom diulang tiap halaman */
  table.data tr { page-break-inside: avoid; break-inside: avoid; }
  table.data tr:nth-child(even) td { background: none; }
  table.data tr.total td, table.data tr.kepala-akun td, table.data tr.hasil-lr td, table.laporan tr.level-0 td { background: #f0f0f0 !important; }
  table.data td.teks-panjang { max-width: none; }
  a { color: #000 !important; text-decoration: none !important; }
  .label { border: 1px solid #999; background: none !important; color: #000 !important; }
  .min { color: #000 !important; }
  .dua-kolom { gap: 10px; }
  details.ringkasan-akun:not([open]) { display: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* monitoring tagihan: judul kolom 3 baris */
table.monitoring th { position: static; text-align: center; border: 1px solid var(--garis); vertical-align: middle; }
table.monitoring th.kanan { text-align: right; }
table.monitoring td { border-right: 1px dashed #e1e6ec; }
@media print { table.monitoring td { border-right: 1px dashed #bbb; } table.monitoring td:nth-child(11), table.monitoring td:nth-child(12) { min-width: 25mm; } }

/* daftar permintaan barang */
.label.sebagian { background: #fff1c7; color: #8a5a00; }
.catatan-nota { font-weight: normal; color: var(--redup); margin-left: 8px; }
table.data tr.masih-sisa td { background: #fffaf0; }

/* po per pemasok */
table.data tr.sub-kepala td { background: #f6f9fc; padding-top: 6px; }
table.data tr.sub-total td { font-style: italic; color: var(--redup); border-bottom: 1px solid var(--garis); }
@media print { table.data tr.sub-kepala td { background: none !important; } }

/* stok per hari / tren */
.batang { height: 7px; background: #eef1f4; border-radius: 3px; margin: 1px 0; overflow: hidden; }
.batang span { display: block; height: 100%; border-radius: 3px; }
.batang .masuk { background: #3fa66b; }
.batang .keluar { background: #d9534f; }
table.data tr.akhir-pekan td { color: var(--redup); }

/* kepala form transaksi model VB6 (Sales Order, DO/SJ): kiri pelanggan / alamat, kanan kotak-kotak berjudul */
.so-kepala { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(0, 1.3fr); gap: 10px 24px; align-items: start; }
.so-kiri { display: flex; flex-direction: column; gap: 4px; }
.so-baris { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; margin: 0; }
.so-baris.so-atas { align-items: start; }
.so-isi { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.so-isi input, .so-isi textarea, .so-isi select { width: 100%; box-sizing: border-box; }
.so-kanan { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.so-kotak { display: flex; flex-direction: column; margin: 0; min-width: 0; }
.so-kotak > span:first-child { text-align: center; font-size: 12px; padding: 3px 4px; border: 1px solid var(--garis); border-bottom: 0;
    border-radius: 4px 4px 0 0; background: var(--bg); color: var(--teks); }
.so-kotak .so-centang input { width: auto; margin: 0; border-radius: 0; }
.so-kotak input, .so-kotak select { width: 100%; box-sizing: border-box; border-radius: 0 0 4px 4px; }
.so-centang { display: flex; align-items: center; justify-content: flex-start; gap: 6px; font-weight: normal; padding: 5px 6px; border: 1px solid var(--garis); border-radius: 0 0 4px 4px; }
.so-uraian { grid-column: 1 / -1; }
.so-lebar { grid-column: span 2; }
.so-tombol { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; margin-bottom: -4px; }
.so-mode { margin-right: auto; align-self: center; font-weight: 600; color: var(--utama); }
.so-cari { display: flex; gap: 4px; min-width: 0; }
.so-cari input { flex: 1; min-width: 0; }
.so-kotak .so-cari input { border-radius: 0 0 0 4px; }
.tombol-cari { padding: 2px 8px; flex: none; }
#karyawan-nama { cursor: pointer; }
@media (max-width: 860px) {
    .so-kepala { grid-template-columns: 1fr; }
    .so-kanan { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .so-baris { grid-template-columns: 1fr; gap: 2px; }
    .so-kosong { display: none; }
}
