:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #111827; --ink2: #4b5563; --muted: #6b7280; --line: #e5e7eb; --line2: #d1d5db;
  --brand: #1f2a44; --brand2: #2f3e63; --accent: #4f46e5; --accent-weak: #eef2ff;
  --ok: #15803d; --ok-bg: #ecfdf3; --warn: #b45309; --warn-bg: #fffbeb; --err: #b91c1c; --err-bg: #fef2f2; --info-bg: #eff6ff; --info: #1d4ed8;
  --r: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 13px; margin: 14px 0 6px; font-weight: 650; color: var(--ink2); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #cbd5e1; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .brand { color: #fff; font-weight: 700; letter-spacing: .08em; font-size: 15px; padding: 4px 10px 2px; }
.side .brand-sub { font-size: 11px; color: #94a3b8; padding: 0 10px 16px; letter-spacing: .02em; }
.side nav a { display: flex; align-items: center; gap: 10px; color: #cbd5e1; padding: 8px 10px; border-radius: 6px; font-size: 13.5px; }
.side nav a:hover { background: var(--brand2); color: #fff; text-decoration: none; }
.side nav a.on { background: #fff; color: var(--brand); font-weight: 600; }
.side nav .sep { font-size: 11px; color: #7c8aa5; text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 4px; }
.side .me { margin-top: auto; border-top: 1px solid var(--brand2); padding: 12px 10px 0; font-size: 12.5px; }
.side .me b { color: #fff; display: block; font-weight: 600; }
.side .me .role { display: inline-block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; background: var(--brand2); color: #e2e8f0; padding: 1px 6px; border-radius: 4px; margin-top: 3px; }
.side .me a { color: #cbd5e1; margin-right: 10px; font-size: 12px; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top .sp { flex: 1; }
.content { padding: 20px 24px 60px; max-width: 1500px; }

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
label { display: block; font-size: 12px; color: var(--ink2); font-weight: 550; }
label > input, label > select, label > textarea { margin-top: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line2); border-radius: 6px; padding: 7px 9px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
textarea { resize: vertical; min-height: 60px; }
input[type=checkbox], input[type=radio] { width: auto; margin: 0 6px 0 0; vertical-align: -2px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); background: #fff; color: var(--ink); padding: 7px 13px; border-radius: 6px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn.pri { background: var(--brand); color: #fff; border-color: var(--brand); } .btn.pri:hover { background: var(--brand2); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: var(--err); border-color: #fecaca; } .btn.danger:hover { background: var(--err-bg); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--ink2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafafa; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: #f9fafb; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #f3f4f6; color: var(--ink2); white-space: nowrap; }
.b-draft { background: #f3f4f6; color: #374151; } .b-submitted { background: var(--warn-bg); color: var(--warn); }
.b-returned { background: var(--err-bg); color: var(--err); } .b-verified, .b-issued { background: var(--info-bg); color: var(--info); }
.b-approved, .b-accepted, .b-partial { background: #f5f3ff; color: #6d28d9; } .b-paid, .b-closed { background: var(--ok-bg); color: var(--ok); }
.b-cancelled, .b-void { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }
.type { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line2); color: var(--ink2); }
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .l { font-size: 12px; color: var(--muted); } .kpi .v { font-size: 22px; font-weight: 650; margin-top: 2px; letter-spacing: -.01em; } .kpi .s { font-size: 12px; color: var(--ink2); }
.alert { border-radius: 6px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; border: 1px solid; }
.alert.err { background: var(--err-bg); color: var(--err); border-color: #fecaca; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: #bbf7d0; }
.alert.info { background: var(--info-bg); color: var(--info); border-color: #bfdbfe; }
.checks { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.checks li { padding: 6px 0 6px 22px; position: relative; border-bottom: 1px dashed var(--line); }
.checks li::before { position: absolute; left: 2px; top: 6px; font-weight: 800; font-size: 12px; }
.checks li.ok::before { content: "\2713"; color: var(--ok); } .checks li.warn::before { content: "!"; color: var(--warn); left: 6px; } .checks li.error::before { content: "\2715"; color: var(--err); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 8px 12px; color: var(--ink2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a.on { color: var(--ink); border-color: var(--brand); } .tabs a:hover { text-decoration: none; color: var(--ink); }

/* editor */
.editor { display: grid; grid-template-columns: minmax(520px, 1fr) minmax(460px, 820px); gap: 16px; align-items: start; }
.previewbox { position: sticky; top: 72px; background: #e5e7eb; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.previewbox .bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: #fff; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.previewbox iframe { width: 100%; height: calc(100vh - 130px); border: 0; display: block; background: #e5e7eb; }
.item { border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-bottom: 8px; background: #fcfcfd; }
.item .hd { display: grid; grid-template-columns: 1fr 70px 80px 130px 30px; gap: 8px; align-items: end; }
.item .x, .term .x { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px; } .item .x:hover, .term .x:hover { color: var(--err); }
.term { display: grid; grid-template-columns: 1.3fr 70px 110px 1.5fr 30px; gap: 8px; align-items: end; margin-bottom: 6px; }
.suggest { position: relative; } .suggest .dd { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line2); border-radius: 6px; box-shadow: var(--shadow); z-index: 30; max-height: 260px; overflow: auto; }
.suggest .dd div { padding: 7px 10px; cursor: pointer; font-size: 13px; } .suggest .dd div:hover { background: var(--accent-weak); }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; font-size: 13px; max-width: 360px; margin-left: auto; }
.totals .g { font-weight: 700; font-size: 15px; border-top: 1px solid var(--line); padding-top: 4px; }

/* detail */
.detail { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(400px, 1fr); gap: 16px; align-items: start; }
.docframe { width: 100%; height: calc(100vh - 150px); border: 1px solid var(--line); border-radius: var(--r); background: #e5e7eb; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.timeline li { padding: 6px 0 6px 14px; border-left: 2px solid var(--line); margin-left: 4px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--line2); }
.sigbox { border: 1px dashed var(--line2); border-radius: 6px; background: #fff; height: 110px; display: flex; align-items: center; justify-content: center; }
.sigbox img { max-height: 100px; max-width: 100%; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 10px; width: min(640px, 100%); max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.modal .ft { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
canvas.pad { width: 100%; height: 200px; border: 1px solid var(--line2); border-radius: 6px; background: #fff; touch-action: none; display: block; }
#toast { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
#toast div { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 6px; font-size: 13px; box-shadow: var(--shadow); max-width: 420px; }
#toast div.err { background: var(--err); }
.bell { position: relative; } .bell .n { position: absolute; top: -6px; right: -6px; background: var(--err); color: #fff; font-size: 10px; border-radius: 999px; padding: 1px 5px; font-weight: 700; }
.notif { position: absolute; right: 24px; top: 56px; width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.12); max-height: 420px; overflow: auto; z-index: 50; }
.notif div { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 12.5px; cursor: pointer; } .notif div.unread { background: var(--accent-weak); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--brand); padding: 20px; }
.login .box { background: #fff; width: 380px; border-radius: 12px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login img { height: 30px; margin-bottom: 18px; }

@media (max-width: 1100px) { .editor, .detail { grid-template-columns: 1fr; } .previewbox { position: static; } .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; } .side { position: static; height: auto; } .side nav { display: flex; flex-wrap: wrap; gap: 2px; } .side nav .sep { display: none; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } .content { padding: 14px; } .item .hd, .term { grid-template-columns: 1fr 1fr; }
}
.grid2 > *, .grid3 > *, .grid4 > *, .detail > *, .editor > * { min-width: 0; }
.card { overflow-x: auto; }

/* brand */
.brandpick { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.bopt { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 1px solid var(--line2); border-radius: 8px; padding: 10px 14px; cursor: pointer; min-width: 170px; background: #fff; font-weight: 500; }
.bopt input { position: absolute; opacity: 0; pointer-events: none; }
.bopt:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; }
.bopt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.bopt .bimg { height: 34px; display: flex; align-items: center; } .bopt .bimg img { max-height: 34px; max-width: 170px; }
.bopt .bname { font-size: 12px; color: var(--ink2); }
.brandlist { display: grid; gap: 8px; }
.brandcard { display: grid; grid-template-columns: 200px 1fr auto; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.brandcard.off { opacity: .55; }
.brandcard .bimg img { max-height: 40px; max-width: 190px; }

.copyrow { display: flex; gap: 8px; align-items: flex-end; } .copyrow label { flex: 1; min-width: 0; } .copyrow .btn { margin-bottom: 1px; }
.copyrow input[readonly], .copyrow textarea[readonly] { background: #f9fafb; }

.bar { background: #eef0f4; border-radius: 4px; height: 10px; overflow: hidden; } .bar span { display: block; height: 100%; background: var(--brand); }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 4px; }
#mf label { width: auto; min-width: 150px; }

/* langkah berikutnya (UI sederhana) */
.nextstep { border: 2px solid var(--brand); }
.step + .step { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.step h2 { margin-bottom: 8px; }
.step.subtle { font-size: 13px; }
.step.hl { background: var(--warn-bg); border-radius: 6px; padding: 8px; }
.tick { display: flex; align-items: center; gap: 4px; font-weight: 500; font-size: 13.5px; color: var(--ink); margin: 10px 0; cursor: pointer; }
.tick input { width: 18px; height: 18px; }
.btn.wa { background: #128c3a; border-color: #128c3a; color: #fff; } .btn.wa:hover { background: #0f7a32; }
details.more { margin-top: 12px; } details.more summary, details.more-card summary { cursor: pointer; color: var(--ink2); font-size: 13px; font-weight: 550; }
details.more-card[open] summary { margin-bottom: 8px; }

@media (max-width: 1100px) {
  .detail > div:last-child { order: -1; }            /* langkah berikutnya tampil di atas dokumen */
  .docframe { height: 70vh; }
}
@media (max-width: 760px) {
  .top { flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
  .top .btn { padding: 6px 10px; font-size: 13px; }
  .side { padding: 10px 10px 6px; } .side .brand-sub { display: none; } .side nav a { padding: 6px 8px; font-size: 13px; }
  .side .me { padding-top: 6px; } .kpis { grid-template-columns: 1fr 1fr !important; }
  .step .row .btn { flex: 1 1 auto; justify-content: center; }
}
