:root {
  --brand: #8e0a96;
  --brand-dark: #6c0773;
  --brand-soft: #f6e9f7;
  --accent: #7cb82f;
  --bg: #f5f4f7;
  --surface: #ffffff;
  --text: #1f1a24;
  --muted: #6b6474;
  --line: #e4e0e8;
  --ok: #1f8a4c; --ok-bg: #e5f5ec;
  --warn: #a35a00; --warn-bg: #fff3df;
  --bad: #b3261e; --bad-bg: #fde8e6;
  --info: #2a5db0; --info-bg: #e8f0fd;
  --chart-1: #8e0a96;
  --chart-2: #7cb82f;
  --chart-total: #4a3a8c;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Open Sans', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--brand); }
h1 { font-size: 1.45rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input:disabled, textarea:disabled, select:disabled { background: #f7f6f9; color: var(--muted); }
textarea { resize: vertical; }
code { background: var(--brand-soft); padding: 1px 6px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.r { text-align: right; }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); font-weight: 600; }
.grow { flex: 1; }

/* Tombol */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; text-decoration: none; color: var(--text); font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #f0c4c0; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 6px 0; text-decoration: underline; }
.icon-btn { border: 0; background: none; font-size: 1.3rem; color: var(--muted); cursor: pointer; padding: 0 6px; }
.icon-btn:hover { color: var(--bad); }

/* Shell */
.demo-bar { background: #fff3c4; color: #6b4e00; text-align: center; padding: 6px 12px; font-size: .85rem; }
.demo-bar .link { color: #6b4e00; padding: 0 4px; }
.topbar { display: flex; align-items: center; gap: 20px; padding: 10px 24px; background: var(--surface); border-bottom: 3px solid var(--brand); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); font-weight: 700; }
.brand img { height: 34px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 600; }
.topbar nav a.active, .topbar nav a:hover { background: var(--brand-soft); color: var(--brand); }
.me { display: flex; align-items: center; gap: 12px; text-align: right; line-height: 1.2; }
main { max-width: 1180px; margin: 0 auto; padding: 24px; }

.page-head, .editor-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head select { width: auto; }
.period-picker { display: flex; gap: 8px; }
.period-picker select { width: auto; }
.back { display: inline-block; margin-bottom: 6px; text-decoration: none; font-size: .9rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card > p.muted { margin-top: -6px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two-col .card { margin-bottom: 0; }

/* Status */
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.st-none { background: #eeecf1; color: var(--muted); }
.st-draft { background: var(--info-bg); color: var(--info); }
.st-submitted { background: var(--warn-bg); color: var(--warn); }
.st-revision { background: var(--bad-bg); color: var(--bad); }
.st-approved { background: var(--ok-bg); color: var(--ok); }

.alert { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; }
.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-warn { background: var(--warn-bg); color: #6d3c00; }
.alert-info { background: var(--info-bg); color: #1e437e; }

.loading { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 60px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 3px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Stat */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; border-left: 4px solid var(--brand); }
.card .stat { background: #fbfafc; }
.stat.warn { border-left-color: #e59a1a; }
.stat.bad { border-left-color: var(--bad); }
.stat-val { font-size: 1.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-lbl { color: var(--muted); font-size: .85rem; }
.stat-sub { font-size: .8rem; font-weight: 600; margin-top: 2px; }
.stat.warn .stat-sub { color: var(--warn); }
.stat.bad .stat-sub { color: var(--bad); }

/* Tabel */
.table-wrap { overflow-x: auto; }
.list-table { width: 100%; border-collapse: collapse; }
.list-table th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.list-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
.list-table th.r, .list-table td.r { text-align: right; }
.list-table tr.hl td { background: #fffaf0; }
.list-table select { min-width: 160px; }
.actions { white-space: nowrap; }
.actions .btn + .btn { margin-left: 6px; }
.attention { margin: 0; padding-left: 18px; }
.attention li { margin: 4px 0; }

/* Form laporan */
.editor-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.save-state { font-size: .82rem; color: var(--muted); }
.save-state.error { color: var(--bad); font-weight: 600; }
.save-state.saved::before { content: '✓ '; color: var(--ok); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; position: sticky; top: 59px; background: var(--bg); z-index: 10; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-nav { display: flex; justify-content: space-between; margin: 8px 0 40px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 12px; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.grid .field { margin-bottom: 0; }
.field-label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field-hint { font-size: .78rem; color: var(--muted); }
.readout { padding: 8px 10px; background: var(--brand-soft); border-radius: 8px; font-weight: 700; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; }
.check input { width: auto; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.row-inline { display: flex; gap: 8px; align-items: center; }
.w-jabatan { max-width: 170px; }
.num { text-align: right; font-variant-numeric: tabular-nums; max-width: 140px; }
.num.compact { max-width: 84px; padding: 6px 8px; }
.add-row { margin-top: 10px; }
.add-row select { max-width: 320px; border-style: dashed; color: var(--brand); font-weight: 600; }

.item { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.item.open { border-color: var(--brand); }
.item-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; background: none; cursor: pointer; text-align: left; }
.item-title { font-weight: 700; }
.item-head .muted { flex: 1; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-body { padding: 4px 12px 12px; }
.item-body .btn.danger { margin-top: 10px; }

.grid-table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.grid-table th, .grid-table td { border: 1px solid var(--line); padding: 4px 6px; text-align: center; }
.grid-table thead th { background: #faf8fb; font-size: .78rem; font-weight: 600; min-width: 84px; }
.grid-table tfoot td, .grid-table tfoot th, .grid-table .tot { font-weight: 700; background: var(--brand-soft); }
.daily { max-height: 70vh; }
.daily thead th { position: sticky; top: 0; z-index: 2; }
.daily .sticky { position: sticky; left: 0; background: #faf8fb; z-index: 1; }
.daily thead .sticky { z-index: 3; }

.kv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 6px 20px; margin-bottom: 12px; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.kv.total { border-bottom: 0; font-weight: 700; }
.checklist { color: var(--warn); }

/* Data master site */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 240px; }
.filters select { width: auto; }
.filters .check { margin: 0; }
.list-table tr.dim td { opacity: .55; }
.list-table td code { white-space: nowrap; }
.checks { display: flex; gap: 20px; flex-wrap: wrap; }
.site-form h3.sub { font-size: .95rem; margin: 10px 0 8px; }
.contacts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.contact-row { display: grid; grid-template-columns: 190px 1.2fr 150px 100px 1fr 32px; gap: 6px; align-items: center; }
.advanced { margin: 12px 0; border-top: 1px solid var(--line); padding-top: 10px; }
.advanced summary { cursor: pointer; font-weight: 600; color: var(--brand); margin-bottom: 10px; }
.form-actions .grow { flex: 1; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.contact-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.contact-chip { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; min-width: 170px; }
.contact-chip .badge { align-self: flex-start; }

/* Modul operasional */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.module-grid.compact { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-bottom: 8px; }
.module-tile { display: flex; flex-direction: column; gap: 6px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.module-tile:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(142,10,150,.08); }
.module-grid.compact .module-tile { flex-direction: row; align-items: center; padding: 10px 12px; font-size: .9rem; }
.module-icon { font-size: 1.5rem; line-height: 1; }
.module-grid.compact .module-icon { font-size: 1.1rem; }
.head-actions { display: flex; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 3px 10px; font-size: .82rem; cursor: pointer; }
.chip.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.list-table tr.clickable { cursor: pointer; }
.list-table tr.clickable:hover td { background: #faf6fb; }
.record-form { border-color: var(--brand); }
.record-form .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.record-form .field.wide { grid-column: 1 / -1; }
.items { display: flex; flex-direction: column; gap: 6px; }
.items-row { display: grid; gap: 6px; align-items: center; }
.items-head span { font-size: .75rem; color: var(--muted); font-weight: 600; }
.items-row input, .items-row select { padding: 6px 8px; }
.calc-table { border-collapse: collapse; min-width: 320px; }
.calc-table td { padding: 3px 12px 3px 0; }
.calc-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.calc-table tr.strong td { font-weight: 700; border-top: 1px solid var(--line); }
.pull-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--info-bg); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }

/* Foto */
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.photo { position: relative; width: 112px; height: 84px; border-radius: 8px; overflow: hidden; background: #eee; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; line-height: 1; }
.photo-add { width: 112px; height: 84px; border: 2px dashed #d6c2d8; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--brand); font-weight: 600; cursor: pointer; text-align: center; font-size: .82rem; padding: 4px; }
.photo-add input { display: none; }
.photo-add.busy { cursor: progress; background: var(--brand-soft); }

/* Grafik */
.chart { margin: 8px 0 16px; }
.chart figcaption { font-weight: 700; font-size: .9rem; margin-bottom: 10px; text-align: center; }
.chart-empty { color: var(--muted); font-size: .9rem; padding: 10px 0; }
.hbar { display: flex; flex-direction: column; gap: 5px; }
.hbar-row { display: grid; grid-template-columns: minmax(120px, 42%) 1fr 48px; align-items: center; gap: 8px; font-size: .8rem; }
.hbar-label { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 14px; background: #f1eef3; border-radius: 3px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 3px; }
.hbar-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.hbar-row.strong { font-weight: 700; }
.vbar { width: 100%; height: auto; display: block; }
.vbar .axis { stroke: var(--line); }
.vbar .val { font-size: 12px; text-anchor: middle; fill: var(--text); font-weight: 600; }
.vbar .lbl { font-size: 12px; text-anchor: middle; fill: var(--muted); }

/* Login */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, var(--brand-soft), var(--bg)); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 10px 40px rgba(80,20,90,.12); border-top: 5px solid var(--brand); }
.auth-logo { height: 46px; display: block; margin: 0 auto 10px; }
.auth-card h1 { text-align: center; font-size: 1.2rem; margin-bottom: 18px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; }
.seg { display: flex; background: #f1eef3; border-radius: 8px; padding: 3px; margin-bottom: 16px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px; border-radius: 6px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.active { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.demo-users { display: flex; flex-direction: column; gap: 8px; }
.demo-user { display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; text-align: left; }
.demo-user:hover { border-color: var(--brand); background: var(--brand-soft); }
.demo-user span { color: var(--muted); font-size: .85rem; }

.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { padding: 10px 16px; border-radius: 8px; background: #1f1a24; color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.2); max-width: 360px; }
.toast-error { background: var(--bad); }

/* ================= Tampilan laporan (pratinjau & cetak) ================= */
.view-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; position: sticky; top: 62px; z-index: 10; }
.view-toolbar .back { margin: 0; }
.printable { background: #fff; max-width: 210mm; margin: 0 auto; box-shadow: 0 2px 20px rgba(0,0,0,.08); font-family: Calibri, 'Open Sans', sans-serif; font-size: 11.5pt; color: #111; position: relative; }
.print-bg { display: none; }
.print-frame { width: 100%; border-collapse: collapse; table-layout: fixed; }
.print-frame > thead > tr > td, .print-frame > tfoot > tr > td { padding: 0; }
.print-head-space { height: 12mm; }
.print-foot-space { height: 12mm; }
.print-body { padding: 0 20mm 0 18mm; }
.pg { padding-top: 6mm; }
.pg + .pg { border-top: 1px dashed #ddd; margin-top: 8mm; }
.pg.cont { border-top: 0; margin-top: 0; }
.printable h3 { font-size: 12.5pt; margin: 4mm 0 3mm; }
.printable h4 { font-size: 11.5pt; margin: 5mm 0 2mm; }
.printable .center { text-align: center; }
.para { text-align: justify; text-indent: 1.2cm; margin: 0 0 3mm; line-height: 1.6; }
.cover { text-align: center; padding-top: 30mm; min-height: 230mm; display: flex; flex-direction: column; }
.cover h1 { font-size: 22pt; text-decoration: underline; margin: 0; }
.cover h2 { font-size: 17pt; margin: 3mm 0 25mm; }
.cover-sub { font-size: 15pt; font-weight: 700; line-height: 1.5; }
.cover-no { margin-top: auto; font-weight: 700; text-decoration: underline; font-size: 10pt; }
.toc { list-style: none; padding: 0; line-height: 1.6; font-size: 10.5pt; }
.sign { margin-top: 12mm; text-align: right; }
.personel { display: grid; grid-template-columns: 70mm 1fr; margin-bottom: 3mm; }
.personel-j { font-weight: 700; }
.personel ul { margin: 0; padding-left: 0; list-style: none; }
.personel li::before { content: ': - '; }
.muted-print { color: #555; }
.rtable { width: 100%; border-collapse: collapse; margin: 3mm 0 5mm; font-size: 10.5pt; }
.rtable th { background: #8e0a96; color: #fff; padding: 2mm; border: 1px solid #8e0a96; }
.rtable td { border: 1px solid #bbb; padding: 1.8mm 2mm; text-align: center; }
.rtable th, .rtable td { overflow-wrap: anywhere; }
.rtable tfoot th { background: #f1e3f2; color: #111; border-color: #bbb; }
.rtable.small { max-width: 130mm; margin-left: auto; margin-right: auto; }
.printable .chart { border: 1px solid #ddd; border-radius: 4px; padding: 4mm; break-inside: avoid; }
.docs-title { font-weight: 700; margin: 5mm 0 3mm; }
.docs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm; }
.docs-grid img { width: 100%; height: 58mm; object-fit: cover; display: block; break-inside: avoid; background: #eee; }

@media print {
  @page { size: A4; margin: 0; }
  html, body { background: transparent !important; }
  .no-print, .topbar, .demo-bar, .toasts { display: none !important; }
  main { padding: 0; max-width: none; }
  .printable { box-shadow: none; max-width: none; margin: 0; background: transparent; }
  .print-bg { display: block; position: fixed; inset: 0; z-index: -1; }
  .print-bg img { width: 210mm; height: 297mm; display: block; }
  .print-head-space { height: 30mm; }
  .print-foot-space { height: 30mm; }
  .print-frame { width: 210mm; table-layout: fixed; }
  .print-body { padding: 0 26mm 0 20mm; }
  .pg { break-before: page; padding-top: 0; }
  .pg + .pg { border-top: 0; margin-top: 0; }
  .pg.cont { break-before: auto; margin-top: 4mm; }
  .cover { break-before: avoid; min-height: 225mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ================= HP ================= */
@media screen and (max-width: 760px) {
  main { padding: 14px 12px; }
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; position: static; }
  .brand span { display: none; }
  .topbar nav { order: 3; flex-basis: 100%; }
  .me { margin-left: auto; font-size: .85rem; }
  .tabs { top: 0; }
  .view-toolbar { top: 0; }
  .two-col { grid-template-columns: 1fr; }
  .two-col .card { margin-bottom: 16px; }
  .card { padding: 14px; }
  .kv-list { grid-template-columns: 1fr; }
  .contact-row { grid-template-columns: 1fr 1fr; }
  .items-head { display: none; }
  .items-row { grid-template-columns: 1fr 1fr !important; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
  .head-actions { width: 100%; }
  .contact-row .icon-btn { justify-self: end; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .hbar-row { grid-template-columns: minmax(90px, 40%) 1fr 40px; }
  .printable { font-size: 10pt; }
  .print-body { padding: 0 5mm; }
  .docs-grid img { height: 32vw; }
  .personel { grid-template-columns: 1fr; }
}
