/* Tema Biru & Emas */
:root {
  --navy: #0b1f44; --navy2: #12306b; --blue: #2f6fde; --blue-soft: #e8effc;
  --gold: #c9a227; --gold2: #e3c65b; --gold-soft: #fbf4dc;
  --bg: #f3f6fc; --card: #fff; --ink: #1b2740; --muted: #67748f; --line: #e1e7f2;
  --red: #b94a48; --green: #2e8b57;
  --side-w: 264px; --radius: 14px;
  --shadow: 0 1px 2px rgba(11,31,68,.06), 0 6px 20px rgba(11,31,68,.06);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; }
button { font-family: inherit; }

#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- Sidebar ---------- */
#side { width: var(--side-w); flex: none; background: linear-gradient(180deg, var(--navy) 0%, #0d2756 100%); color: #cfd9ef; display: flex; flex-direction: column; border-right: 1px solid rgba(201,162,39,.35); z-index: 30; }
.brand { padding: 22px 20px 18px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid rgba(255,255,255,.08); }
.crest { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, var(--gold2), var(--gold)); color: var(--navy); display: grid; place-items: center; font-size: 19px; box-shadow: 0 4px 12px rgba(201,162,39,.35); flex: none; }
.brand h1 { font-family: 'Playfair Display', Georgia, serif; font-size: 17px; color: #fff; line-height: 1.15; font-weight: 700; }
.brand small { color: var(--gold2); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
#nav { flex: 1; overflow-y: auto; padding: 10px 10px 24px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.ngroup { margin: 16px 0 4px; padding: 0 12px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold2); font-weight: 600; opacity: .9; }
.nitem { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 1px 0; border-radius: 9px; color: #cfd9ef; text-decoration: none; font-size: 13px; border-left: 3px solid transparent; transition: background .12s; line-height: 1.25; }
.nitem i { width: 16px; text-align: center; opacity: .75; font-size: 13px; flex: none; }
.nitem span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nitem small { display: block; font-size: 10.5px; opacity: .55; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nitem:hover { background: rgba(255,255,255,.07); color: #fff; }
.nitem.on { background: rgba(201,162,39,.16); color: #fff; border-left-color: var(--gold); font-weight: 600; }
.nitem.on i { color: var(--gold2); opacity: 1; }
.side-foot { padding: 12px 18px 14px; font-size: 11px; color: rgba(255,255,255,.4); border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 10px; }
.side-note { line-height: 1.4; }
.lang { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; padding: 3px; background: rgba(255,255,255,.07); border: 1px solid rgba(201,162,39,.35); border-radius: 999px; }
.lang > i { color: var(--gold2); font-size: 13px; padding: 0 6px 0 8px; }
.lang-btn { border: 0; background: transparent; color: #cfd9ef; font: 600 11px 'Inter', sans-serif; letter-spacing: .06em; padding: 5px 11px; border-radius: 999px; cursor: pointer; transition: background .12s, color .12s; }
.lang-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.lang-btn.on { background: linear-gradient(135deg, var(--gold2), var(--gold)); color: var(--navy); }
.lang-btn:focus-visible { outline: 2px solid var(--gold2); outline-offset: 2px; }

/* ---------- Utama ---------- */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#top { height: 58px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--line); }
#burger { display: none; }
#crumb { font-weight: 600; font-size: 15px; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#crumb small { color: var(--muted); font-weight: 400; margin-left: 8px; }
.spacer { flex: 1; }
#status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#status.ok i { color: var(--green); } #status.busy i { color: var(--gold); }
#main-nav { display: flex; align-items: center; gap: 6px; flex: none; }
.main-menu { min-width: 90px; max-width: 124px; width: auto; height: 36px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--navy); font-size: 12px; font-weight: 500; cursor: pointer; }
.main-menu span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-menu i { flex: none; font-size: 12px; }
.main-menu:hover { border-color: var(--gold); background: var(--gold-soft); }
.main-menu.on { background: var(--navy); border-color: var(--navy); color: var(--gold2); font-weight: 600; }
.main-menu:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
#top > .btn { flex: none; }
#crumb { min-width: 0; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--navy); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 7px; transition: all .12s; white-space: nowrap; }
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn.gold { background: linear-gradient(135deg, var(--gold2), var(--gold)); border-color: var(--gold); color: var(--navy); font-weight: 600; }
.btn.gold:hover { filter: brightness(1.05); color: var(--navy); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.blue:hover { background: var(--navy2); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; }
.btn.danger { color: var(--red); } .btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn[disabled] { opacity: .4; pointer-events: none; }
#view { flex: 1; min-height: 0; overflow: auto; padding: 22px 26px 40px; }

/* ---------- Papan pemuka ---------- */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.dash-head h2 { font-family: 'Playfair Display', Georgia, serif; font-size: 26px; color: var(--navy); }
.dash-head p { margin: 4px 0 0; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpis.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.kpi { background: var(--card); border-radius: var(--radius); padding: 16px 18px; display: flex; gap: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(180deg, var(--gold2), var(--gold)); }
.kic { width: 42px; height: 42px; border-radius: 12px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-size: 17px; flex: none; }
.kbody { min-width: 0; }
.klb { font-size: 12px; color: var(--muted); font-weight: 500; }
.kv { font-size: 24px; font-weight: 700; color: var(--navy); margin: 2px 0; letter-spacing: -.01em; white-space: nowrap; }
.kv.neg { color: var(--red); }
.ksub { font-size: 12px; color: var(--muted); }
.dl { font-weight: 600; margin-left: 4px; white-space: nowrap; } .dl.up { color: var(--green); } .dl.dn { color: var(--red); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card.span2 { grid-column: span 2; }
.ch { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.ch h3 { font-size: 14px; font-weight: 600; color: var(--navy); }
.chip { font-size: 11px; background: var(--gold-soft); color: #86690f; padding: 3px 9px; border-radius: 99px; font-weight: 600; }
.cv { position: relative; height: 270px; }
.tablecard { margin-top: 14px; }
.tw { overflow-x: auto; }
table.mini { border-collapse: collapse; width: 100%; font-size: 13px; }
table.mini th { text-align: right; font-weight: 600; font-size: 11.5px; color: var(--navy); background: var(--blue-soft); padding: 8px 12px; white-space: nowrap; position: sticky; top: 0; }
table.mini th:first-child { text-align: left; border-radius: 8px 0 0 8px; } table.mini th:last-child { border-radius: 0 8px 8px 0; }
table.mini td { padding: 7px 12px; border-bottom: 1px solid #eef1f8; white-space: nowrap; }
table.mini td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.mini td.neg { color: var(--red); } table.mini td.err { color: #9a7b12; text-align: right; }
table.mini tr.sec td { background: var(--gold-soft); font-weight: 600; color: #6d550a; }
table.mini tbody tr:hover td { background: #f6f9ff; }
table.tx th.n { text-align: right; }
table.tx td:nth-child(3), table.tx td:nth-child(4) { white-space: normal; min-width: 160px; }
.empty-td { text-align: center; color: var(--muted); padding: 30px !important; }
td.act { white-space: nowrap; text-align: right; }
.ib { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 5px 7px; border-radius: 7px; }
.ib:hover { background: var(--blue-soft); color: var(--blue); } .ib.dn:hover { background: #fbe9e8; color: var(--red); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters input[type=search], .filters select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; min-width: 140px; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.filters input:focus, .filters select:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.chk { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding-top: 14px; color: var(--muted); }

.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty i { font-size: 40px; color: var(--gold); margin-bottom: 12px; display: block; }
.empty .btn { margin-top: 14px; }

/* ---------- Laporan sheet (gaya web) ---------- */
.rpt .dash-head { align-items: center; }
.rpt .filters input[type=search] { min-width: 220px; flex: none; }
.rcard { padding-bottom: 6px; }
.rwrap { overflow: auto; max-height: calc(100vh - 230px); border-radius: 10px; }
table.rt { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.rt th { position: sticky; top: 0; z-index: 2; background: var(--navy); color: #fff; font-weight: 600; font-size: 12px; padding: 9px 14px; white-space: nowrap; text-align: center; border-bottom: 1px solid rgba(255,255,255,.15); }
table.rt thead tr + tr th { top: 36px; background: var(--navy2); }
table.rt th.lbl, table.rt th.lbl2 { text-align: left; }
table.rt th.n { text-align: right; }
table.rt th.grp { border-left: 1px solid rgba(255,255,255,.18); border-right: 1px solid rgba(255,255,255,.18); color: var(--gold2); letter-spacing: .04em; text-transform: uppercase; font-size: 11px; }
table.rt td { padding: 7px 14px; border-bottom: 1px solid #eef1f8; background: #fff; vertical-align: middle; }
table.rt td.lbl { position: sticky; left: 0; z-index: 1; min-width: 230px; max-width: 420px; background: #fff; font-weight: 500; color: var(--ink); border-right: 1px solid #eef1f8; }
table.rt th.lbl { position: sticky; left: 0; z-index: 4; min-width: 230px; }
table.rt td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.rt td.s { color: var(--muted); white-space: nowrap; }
table.rt td.c { text-align: center; font-weight: 600; color: var(--navy); white-space: nowrap; }
table.rt td.neg { color: var(--red); }
table.rt td.z { color: #b4bdd0; }
table.rt td.err { color: #9a7b12; cursor: help; }
table.rt tbody tr:hover td { background: #f4f8ff; }
table.rt tr.gap td { border-top: 10px solid #fff; }
table.rt tr.sec td { background: var(--blue-soft); color: var(--navy); font-weight: 700; letter-spacing: .02em; padding-top: 9px; padding-bottom: 9px; border-left: 3px solid var(--gold); position: static; }
table.rt tr.subh td { background: var(--blue-soft); }
table.rt tr.tot td { background: var(--gold-soft); font-weight: 700; color: #5d4707; border-top: 1px solid #ecd98c; border-bottom-color: #ecd98c; }
table.rt tr.tot:hover td { background: #f8edc4; }
table.tbl td.s { color: var(--ink); white-space: normal; min-width: 90px; }
table.tbl td.n { white-space: nowrap; }
.rpt .cards .card.span2 { grid-column: 1 / -1; }

/* ---------- Modal, toast, loader ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(11,31,68,.5); display: grid; place-items: center; z-index: 100; padding: 16px; backdrop-filter: blur(2px); }
.modal { background: #fff; border-radius: 16px; padding: 24px; width: min(520px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); border-top: 4px solid var(--gold); max-height: 92vh; overflow: auto; }
.modal h3 { font-family: 'Playfair Display', Georgia, serif; font-size: 20px; color: var(--navy); margin-bottom: 14px; }
.modal label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.modal input[type=text], .modal input[type=number], .modal input[type=date] { display: block; width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font: 14px 'Inter', sans-serif; color: var(--ink); }
.modal input:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.modal .fg { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal p { color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.modal .opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; font-weight: 400; color: var(--ink); font-size: 13px; }
.modal .opt input { margin-top: 3px; } .modal .opt b { display: block; color: var(--navy); }
.mact { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 11px; box-shadow: 0 8px 24px rgba(0,0,0,.25); border-left: 4px solid var(--gold); font-size: 13px; animation: tin .2s ease; max-width: 340px; }
.toast.err { border-left-color: #e0645f; } .toast.ok { border-left-color: #4fbf85; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
#loader { position: fixed; inset: 0; background: linear-gradient(135deg, var(--navy), #0d2756); z-index: 300; display: grid; place-items: center; color: #fff; text-align: center; }
#loader .crest { width: 64px; height: 64px; font-size: 28px; margin: 0 auto 18px; animation: pulse 1.4s infinite; }
#loader p { color: var(--gold2); margin: 6px 0 0; }
@keyframes pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 12px rgba(201,162,39,.12); } }
.settings-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.settings-grid .card p { color: var(--muted); line-height: 1.55; margin: 6px 0 14px; }
.settings-grid dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 8px 0 0; }
.settings-grid dt { color: var(--muted); } .settings-grid dd { margin: 0; font-weight: 600; color: var(--navy); }

/* ---------- Cetak ---------- */
#print-area { display: none; }
.ptable { border-collapse: collapse; width: 100%; font-size: 10px; }
.ptable td { border: 1px solid #cfd6e6; padding: 2px 5px; white-space: nowrap; }
.ptable td.n { text-align: right; } .ptable td.neg { color: #b03a3a; }
.ptitle { font-family: 'Playfair Display', Georgia, serif; font-size: 18px; color: var(--navy); margin: 0 0 2px; }
.psub { color: var(--muted); font-size: 11px; margin: 0 0 10px; }
.pnote { font-size: 11px; color: var(--muted); }
@page { size: A4 landscape; margin: 10mm; }
@media print {
  body { background: #fff; }
  #side, #top, #toasts, #loader { display: none !important; }
  #app, #main { display: block; height: auto; overflow: visible; }
  #view { overflow: visible; padding: 0; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  .cv { height: 230px; }
  .rwrap { max-height: none; overflow: visible; }
  table.rt th, table.rt td.lbl { position: static; }
  .btn, .filters, .pager, .ib, td.act, th:last-child.act { display: none !important; }
  body.print-sheet #main { display: none; }
  body.print-sheet #print-area { display: block; }
}

/* ---------- Responsif ---------- */
@media (max-width: 1400px) {
  #top { gap: 8px; padding: 0 12px; }
  #status span { display: none; }
  .main-menu { min-width: 80px; }
}
@media (max-width: 1150px) {
  #top { height: auto; min-height: 58px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  #main-nav { order: 1; width: 100%; overflow-x: auto; padding-bottom: 2px; justify-content: flex-end; }
  .main-menu { flex: 0 0 auto; }
}
@media (max-width: 600px) {
  #main-nav { justify-content: flex-start; }
}
@media (max-width: 860px) {
  #side { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open #side { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.5); }
  #burger { display: inline-flex; }
  #view { padding: 16px 14px 36px; }
  .card.span2 { grid-column: auto; }
  .cards { grid-template-columns: 1fr; }
  #top .lbl { display: none; }
  .modal .fg { grid-template-columns: 1fr; }
}
