:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1d232b; --muted: #6a7480; --line: #e2e5ea; --line2: #eef0f3;
  --head: #26313d; --head-ink: #fff; --accent: #1f6feb; --red: #c62828; --green: #1b7f3b; --orange: #b45309;
  --hover: #eef4ff; --stick: #fafbfc;
  --g-ajl: #f3eefc; --g-ins: #eaf4fb; --g-fol: #eef8f0; --g-kirim: #fff6e8; --g-jual: #fdeeee; --g-side: #f3f4f6;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body.noscroll { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
small { color: var(--muted); }
.merah { color: var(--red) !important; } .hijau { color: var(--green); }

header.top { display: flex; align-items: center; gap: 24px; padding: 10px 16px; background: var(--head); color: var(--head-ink); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; } .brand span { font-weight: 400; opacity: .7; margin-left: 6px; font-size: 13px; }
header nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
header nav a { color: #cfd6de; padding: 6px 10px; border-radius: 6px; }
header nav a.on, header nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
header nav a.out { margin-left: auto; }
main { padding: 12px 16px 24px; }

.bar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.bar .info { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); }
.bar .info b { color: var(--ink); }
form.bulan { display: flex; gap: 4px; align-items: center; }
form.bulan input { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: var(--panel); }
.btn, button.btn { display: inline-block; padding: 5px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer; font: inherit; }
.btn.pri { background: var(--accent); color: #fff; border-color: var(--accent); }
p.ket { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; max-width: 1100px; }

/* ---------- tabel ledger ---------- */
.tbl-wrap { overflow: auto; max-height: calc(100vh - 165px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table.ledger { border-collapse: separate; border-spacing: 0; min-width: 100%; }
table.ledger th, table.ledger td { border-bottom: 1px solid var(--line2); border-right: 1px solid var(--line2); padding: 0; white-space: nowrap; }
table.ledger thead th { position: sticky; top: 0; z-index: 3; background: var(--head); color: #fff; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; padding: 9px 10px; min-width: 128px; text-align: right; }
table.ledger tfoot td { position: sticky; bottom: 0; z-index: 2; background: #e9edf2; border-top: 2px solid #c9d0d8; }
.c-no { position: sticky; left: 0; z-index: 2; width: 44px; min-width: 44px !important; text-align: center !important; background: var(--stick); color: var(--muted); padding: 0 6px !important; }
.c-tgl { position: sticky; left: 44px; z-index: 2; min-width: 150px !important; text-align: left !important; background: var(--stick); padding: 6px 10px !important; box-shadow: 2px 0 0 var(--line); }
thead .c-no, thead .c-tgl { z-index: 4; background: var(--head); color: #fff; }
tfoot .c-no, tfoot .c-tgl { z-index: 3; background: #e2e7ed; }
.c-tgl b { display: block; font-weight: 600; } .c-tgl small { font-size: 11px; }
.c-tgl.rusak { background: #fdecea; }
table.ledger tbody tr:hover td { background-color: var(--hover); }
table.ledger tbody tr:hover .c-no, table.ledger tbody tr:hover .c-tgl { background: #e3ecfb; }
td.kosong { padding: 30px !important; text-align: center; color: var(--muted); }
.nol { display: block; text-align: right; padding: 8px 10px; color: #c3c8cf; }

.k-potongan_ajl { background: var(--g-ajl); } .k-inspect_grey, .k-inspect_finish { background: var(--g-ins); }
.k-folding_grey, .k-folding_finish { background: var(--g-fol); } .k-kirim_rjs_pst { background: var(--g-kirim); }
.k-jual_rjs, .k-jual_pst { background: var(--g-jual); }
.k-tanpa_potongan, .k-nonori_grey, .k-nonori_finish, .k-bs_grey, .k-bs_finish { background: var(--g-side); }
td.k-tanpa_potongan { border-left: 3px solid #c9d0d8; }
thead th.k-tanpa_potongan { border-left: 3px solid #5b6875; }
thead th.k-potongan_ajl { background: #4a3a6b; } thead th.k-inspect_grey, thead th.k-inspect_finish { background: #1f4e6e; }
thead th.k-folding_grey, thead th.k-folding_finish { background: #24573a; } thead th.k-kirim_rjs_pst { background: #7a5214; }
thead th.k-jual_rjs, thead th.k-jual_pst { background: #7a2525; }
thead th.k-tanpa_potongan, thead th.k-nonori_grey, thead th.k-nonori_finish, thead th.k-bs_grey, thead th.k-bs_finish { background: #4b5563; }

button.cell { display: block; width: 100%; border: 0; background: transparent; padding: 6px 10px; text-align: right; cursor: pointer; font: inherit; color: inherit; }
button.cell:hover { background: rgba(31,111,235,.1); }
button.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
button.cell b { display: block; font-size: 14.5px; font-variant-numeric: tabular-nums; }
button.cell small { display: block; font-size: 11.5px; }

i.tag { display: inline-block; font-style: normal; font-size: 10.5px; padding: 1px 6px; border-radius: 9px; margin: 2px 0 0; white-space: nowrap; }
i.tag.sus { background: #fff1d6; color: var(--orange); }
i.tag.red { background: #fde2e1; color: var(--red); } i.tag.org { background: #fff1d6; color: var(--orange); }
i.tag.gry { background: #eceff3; color: #4b5563; }

/* ---------- popup ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,20,28,.55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 3vh 12px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border-radius: 10px; width: min(1200px, 100%); max-height: 94vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; } #m-sub { color: var(--muted); font-size: 13px; }
button.x { border: 0; background: transparent; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.modal-body { overflow: auto; padding: 14px 18px 18px; }
.res-wrap { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.res { flex: 1 1 320px; max-width: 560px; } .res h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
table.mini, table.detail, table.std { border-collapse: collapse; width: 100%; font-size: 13px; }
table.mini th, table.mini td, table.detail th, table.detail td, table.std th, table.std td { padding: 5px 8px; border-bottom: 1px solid var(--line2); text-align: left; }
table.mini thead th, table.detail thead th, table.std thead th { background: #f0f2f5; font-size: 12px; color: #4b5563; position: sticky; top: 0; }
table.mini tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.r { text-align: right !important; font-variant-numeric: tabular-nums; }
.cari { margin: 14px 0 6px; } .cari input { width: min(360px, 100%); padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.detail-wrap { overflow: auto; } table.detail td { white-space: nowrap; } table.detail td:last-child { white-space: normal; min-width: 160px; }
.muat { padding: 40px; text-align: center; color: var(--muted); }
.err { background: #fde2e1; color: var(--red); padding: 10px 12px; border-radius: 6px; margin: 8px 0; }
.ok { background: #e3f4e8; color: var(--green); padding: 10px 12px; border-radius: 6px; margin: 8px 0; }

/* ---------- halaman lain ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; overflow: auto; }
.panel h2 { margin: 0 0 4px; font-size: 16px; } .panel p.sub { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.form-grid { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.form-grid input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; width: 130px; }
.form-grid input.lebar { width: 260px; }

body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--panel); padding: 28px; border-radius: 10px; width: min(340px, calc(100% - 32px)); box-shadow: 0 6px 30px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 10px; }
.login-box h1 { margin: 0; font-size: 20px; } .login-box p { margin: 0 0 8px; color: var(--muted); }
.login-box input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.login-box button { padding: 9px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }

@media (max-width: 640px) {
  .c-tgl { min-width: 118px !important; } table.ledger thead th { min-width: 112px; }
  main { padding: 10px 10px 20px; }
}
