:root {
  --bg: #f4f5f1;
  --surface: #ffffff;
  --ink: #1b2420;
  --muted: #6b766f;
  --line: #e3e6df;
  --brand: #0f6e56;
  --brand-ink: #ffffff;
  --brand-soft: #e2f1eb;
  --danger: #b4372f;
  --warn: #a86a00;
  --radius: 12px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1em; margin: 6px 0; }
.num { text-align: right; font-family: var(--mono); font-size: 13px; white-space: nowrap; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 13px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); padding: 28px; border-radius: 16px; border: 1px solid var(--line); }
.login-card label { display: block; margin-top: 14px; font-weight: 600; font-size: 13px; }

/* Form controls */
input, select, textarea { width: 100%; padding: 9px 11px; margin-top: 5px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: inherit; }
input:focus, select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.btn { border: 1px solid transparent; border-radius: 8px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; background: var(--brand-soft); color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.danger { background: transparent; color: var(--danger); border-color: #f0d4d1; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 18px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Layout */
#app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: #12241d; color: #e8efe9; padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a { padding: 9px 12px; border-radius: 8px; cursor: pointer; color: #c9d6cd; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); }
.sidebar nav a.active { background: #1f3b30; color: #fff; font-weight: 600; }
.nav-label { margin: 14px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7f9488; }
.sidebar-foot { display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot .btn.ghost { color: #e8efe9; border-color: #2c4a3e; }
.sidebar-foot .muted { color: #9db0a4; font-size: 12px; }
main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 19px; margin: 0; flex: 1; }
.user-pick { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.user-pick select { width: auto; margin: 0; }
.menu-btn { display: none; }
.view { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.card h2 .spacer { flex: 1; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-family: var(--mono); font-size: 21px; margin-top: 6px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.main { background: var(--brand); color: #fff; border-color: var(--brand); }
.kpi.main .label, .kpi.main .sub { color: #c4e6d9; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.chart-box { position: relative; height: 260px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 8px 0 -6px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbf8; }
th.num { font-family: inherit; font-size: 12px; white-space: normal; }
table.compact td { white-space: nowrap; }
.badge { white-space: nowrap; }
.pos { color: var(--brand); }
.neg { color: var(--danger); }
.harga-input { margin: 0; padding: 5px 8px; text-align: right; font-family: var(--mono); font-size: 13px; width: 96px; }
table.compact th, table.compact td { padding-left: 8px; padding-right: 8px; }
table.compact .hint { white-space: normal; max-width: 180px; }
.card h2 select { font-size: 13px; font-weight: 500; padding: 6px 10px; }
tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: none; }
tr:hover td { background: #fafbf8; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn { margin-left: 4px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.badge.warn { background: #fbefd9; color: var(--warn); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }
.bar-cell { position: relative; }
.bar-cell .bar { height: 6px; border-radius: 3px; background: var(--brand-soft); margin-top: 4px; }
.bar-cell .bar span { display: block; height: 100%; border-radius: 3px; background: var(--brand); }

/* Grid input (gaya spreadsheet seperti gambar) */
.sheet td { padding: 4px 6px; }
.sheet select, .sheet input { margin: 0; border-color: transparent; background: transparent; }
.sheet select:hover, .sheet input:hover { border-color: var(--line); background: #fff; }
.sheet tr.dirty td { background: #fffbea; }
.sheet input.nilai { text-align: right; font-family: var(--mono); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar select, .toolbar input { width: auto; margin: 0; }
.hint { font-size: 12px; color: var(--muted); }

/* Modal */
dialog { border: none; border-radius: 14px; padding: 0; width: min(520px, 94vw); }
dialog::backdrop { background: rgba(15, 25, 20, .45); }
#modalForm { padding: 22px; }
#modalForm h3 { margin: 0 0 8px; }
#modalBody label { display: block; margin-top: 12px; font-weight: 600; font-size: 13px; }
#modalBody .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; transition: transform .25s; z-index: 50; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.empty { padding: 26px; text-align: center; color: var(--muted); }

@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-block; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .view { padding: 16px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
