:root {
  --navy: #0e3047;
  --navy-2: #17425f;
  --orange: #f69220;
  --orange-ink: #9a4f00;
  --paper: #f6f7f9;
  --sheet: #ffffff;
  --ink: #172430;
  --muted: #5b6b78;
  --rule: #d6dce3;
  --ok: #24724f;
  --ok-bg: #e5f3ec;
  --err: #b42318;
  --err-bg: #fdecea;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --focus: #1f6fd1;
  --sans: "Public Sans", system-ui, sans-serif;
  --serif: "Source Serif 4", "Bookman Old Style", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--navy-2); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
small, .muted { color: var(--muted); }

/* Bilah atas: navy dengan potongan diagonal oranye, gema sampul */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 56px; color: #fff;
  background: linear-gradient(115deg, var(--navy) 0 70%, var(--orange) 70% 71.5%, var(--navy) 71.5%);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; }
.brand small { font-weight: 400; opacity: .8; margin-left: 4px; }
.brand-mark { width: 22px; height: 22px; background: var(--orange); clip-path: polygon(0 0, 100% 0, 0 100%); }
.bar-actions { display: flex; gap: 16px; align-items: center; }
.bar-actions a, .bar-actions .link { color: #fff; text-decoration: none; }

main { max-width: 1440px; margin: 0 auto; padding: 24px 20px 80px; outline: none; }

/* Kontrol */
button, .btn {
  font: 600 14px var(--sans); border-radius: 6px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--rule); background: var(--sheet); color: var(--ink); text-decoration: none;
  display: inline-flex; gap: 6px; align-items: center;
}
button:hover { border-color: var(--navy-2); }
button.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
button.accent { background: var(--orange); color: #1d1200; border-color: var(--orange); }
button.danger { color: var(--err); }
button.link { border: 0; background: none; padding: 0; font-weight: 500; text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  font: 14px/1.4 var(--sans); color: var(--ink); width: 100%;
  border: 1px solid var(--rule); border-radius: 5px; padding: 7px 9px; background: #fff;
}
textarea { resize: vertical; min-height: 60px; }
input[type=number] { width: 4.8em; text-align: right; font-variant-numeric: tabular-nums; }
input[readonly], textarea[readonly] { background: #f1f3f6; color: #33434f; }
label { display: block; font-weight: 600; font-size: 13px; margin: 0 0 4px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Login & daftar */
.login { max-width: 360px; margin: 10vh auto; background: var(--sheet); padding: 28px; border-radius: 8px; border: 1px solid var(--rule); }
.list { background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; }
.list a { display: flex; justify-content: space-between; padding: 14px 18px; border-top: 1px solid var(--rule); text-decoration: none; color: var(--ink); }
.list a:first-child { border-top: 0; }
.list a:hover { background: #f0f4f8; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.start { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0 28px; }
.start > div { background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; padding: 18px; }

/* Editor tiga kolom */
.editor { display: grid; grid-template-columns: 190px minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.sections { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; }
.sections a { padding: 8px 10px; border-radius: 5px; text-decoration: none; color: var(--ink); display: flex; gap: 8px; }
.sections a b { width: 1.2em; color: var(--muted); font-weight: 600; }
.sections a.on { background: var(--navy); color: #fff; }
.sections a.on b { color: var(--orange); }
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; padding: 22px 24px; min-width: 0; }
.sheet-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 16px; }
.save-state { font-size: 13px; color: var(--muted); }
.save-state.dirty { color: var(--orange-ink); font-weight: 600; }

/* Neraca JP: elemen yang diingat */
.ledger { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 14px; }
.tally { background: var(--navy); color: #fff; border-radius: 8px; padding: 16px 18px; font-variant-numeric: tabular-nums; }
.tally h3 { color: #c9d6e2; font-weight: 500; font-size: 13px; margin-bottom: 10px; }
.tally .line { display: flex; justify-content: space-between; padding: 3px 0; }
.tally .sum { border-top: 2px solid var(--orange); margin-top: 6px; padding-top: 8px; font-size: 1.5rem; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; }
.tally .verdict { font-size: 13px; margin-top: 6px; }
.tally .verdict.bad { color: #ffb4a8; }
.tally .verdict.good { color: #9de3c0; }
.issues { background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; padding: 14px 16px; max-height: 55vh; overflow: auto; }
.issues ul { list-style: none; margin: 0; padding: 0; }
.issues li { padding: 7px 0 7px 10px; border-left: 3px solid var(--err); margin-bottom: 6px; font-size: 13px; }
.issues li.warning { border-left-color: var(--orange); }
.issues li b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.cost { font-size: 12.5px; color: var(--muted); }

/* Tabel */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { border-bottom: 1px solid var(--rule); padding: 6px 6px; text-align: left; vertical-align: top; }
table.t th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
.bad-num { color: var(--err); font-weight: 700; }
.ok-num { color: var(--ok); font-weight: 600; }

/* Silabus */
.unit { border: 1px solid var(--rule); border-radius: 8px; margin-bottom: 18px; }
.unit > header { padding: 12px 16px; background: #f3f6f9; border-bottom: 1px solid var(--rule); border-radius: 8px 8px 0 0; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.unit > header h3 { margin: 0; font-family: var(--serif); font-size: 1.05rem; }
.unit .body { padding: 14px 16px; }
.ek { border-top: 1px dashed var(--rule); padding-top: 12px; margin-top: 12px; }
.ek-title { display: flex; gap: 10px; align-items: baseline; font-family: var(--serif); font-weight: 600; }
.kuk { display: grid; grid-template-columns: 3.2em 1fr 1fr; gap: 8px; margin: 6px 0; align-items: start; }
.kuk .no { font-variant-numeric: tabular-nums; color: var(--muted); padding-top: 7px; }
.skkni { font-family: var(--serif); font-size: 14px; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #e8edf2; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.run { background: var(--warn-bg); color: var(--warn); }

.barang-tools { gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.blist { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.brow { display: grid; grid-template-columns: 2.2em 2fr 2fr 8.5em 1fr 1.4fr 2em; gap: 6px; align-items: center; }
.brow input { padding: 4px 7px; font-size: 14px; min-width: 0; }
.bhead { font-size: 12px; font-weight: 600; color: var(--muted); padding-bottom: 2px; border-bottom: 1px solid var(--rule); }
.bno { font-size: 13px; color: var(--muted); text-align: right; }
.bdel { padding: 2px 0; line-height: 1.4; }
.stepper { display: flex; }
.stepper input { width: 100%; min-width: 3.5em; border-radius: 0; text-align: center; }
.stepper button { padding: 3px 9px; border-radius: 0; }
.stepper button:first-child { border-radius: 5px 0 0 5px; }
.stepper button:last-child { border-radius: 0 5px 5px 0; }
.cover-preview { width: 100%; max-width: 330px; border: 1px solid var(--rule); border-radius: 4px; display: block; }
.notice { background: var(--warn-bg); border: 1px solid #f1d39a; padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 14px; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.err { background: var(--err); }

@media (max-width: 1100px) {
  .editor { grid-template-columns: 1fr; }
  .sections { position: static; flex-direction: row; flex-wrap: wrap; }
  .ledger { position: static; }
}
@media (max-width: 640px) {
  main { padding: 16px; }
  .start, .grid2 { grid-template-columns: 1fr; }
  .kuk { grid-template-columns: 1fr; }
  .brow { grid-template-columns: 1.6em 8em 1fr 1fr 2em; grid-template-areas: "no nm nm nm del" ". sp sp sp sp" ". jm su kt kt"; padding: 6px 0; border-bottom: 1px solid var(--rule); }
  .bno { grid-area: no; } .bn { grid-area: nm; } .bs { grid-area: sp; } .bj { grid-area: jm; } .bu { grid-area: su; } .bk { grid-area: kt; } .bdel { grid-area: del; }
  .bhead { display: none; }
  .sheet { padding: 16px; }
  .bar { background: var(--navy); }
  table.t { min-width: 680px; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
