:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f1f3f0;
  --ink: #15201b;
  --ink-2: #4c5852;
  --muted: #7d8882;
  --line: #e2e6e2;
  --line-2: #cfd6d1;
  --accent: #1f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0ea;
  --danger: #c0392b;
  --danger-soft: #fbeaea;
  --good: #0a7d0a;
  --good-soft: #e5f4e5;
  --warn-soft: #fff4dc;
  --warn-ink: #8a5a00;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101412;
    --surface: #181d1a;
    --surface-2: #202622;
    --ink: #eef2ef;
    --ink-2: #b9c3bd;
    --muted: #8a958f;
    --line: #2a312d;
    --line-2: #39423d;
    --accent: #3fa57c;
    --accent-ink: #06130d;
    --accent-soft: #1d3329;
    --danger: #e66767;
    --danger-soft: #3a1f1f;
    --good: #2fbf4f;
    --good-soft: #17301c;
    --warn-soft: #3a2f12;
    --warn-ink: #f0c060;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2c2c2a;
    --axis: #383835;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); }
a { color: var(--accent); }
.app { display: flex; min-height: 100vh; }

/* sidebar */
.sidebar { width: 240px; flex: none; background: var(--surface); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 10px 24px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.logo { width: 34px; height: 34px; color: var(--accent); flex: none; }
.logo svg { width: 100%; height: 100%; display: block; }
.brand-title { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); line-height: 1.3; }
nav a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--ink-2); text-decoration: none; margin: 1px 0; }
nav a:hover { background: var(--surface-2); color: var(--ink); }
nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }

.sidebar { display: flex; flex-direction: column; }
.sidebar nav { flex: 1; }
.userbox { border-top: 1px solid var(--line); margin-top: 14px; padding: 12px 8px 0; }
.userbox .who { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; font-weight: 600; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; }
.ub-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* login / setup */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth[hidden], .app[hidden] { display: none; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px 26px; }
.auth-card .logo { width: 48px; height: 48px; margin: 0 auto 10px; }
.auth-card h1 { font-size: 20px; text-align: center; margin: 0; }
.auth-card .org { text-align: center; color: var(--ink-2); margin: 4px 0 20px; }
.auth-card form { display: grid; gap: 12px; }
.auth-card button.primary { justify-content: center; padding: 9px; margin-top: 4px; }
.auth-card .err { color: var(--danger); font-size: 13px; min-height: 18px; }
.auth-card .note { font-size: 12.5px; color: var(--muted); margin-top: 14px; text-align: center; }
.readonly-note { background: var(--warn-soft); color: var(--warn-ink); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }

/* main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 18px; margin: 0; }
.spacer { flex: 1; }
.year-pick { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.view { padding: 20px 24px 60px; max-width: 1400px; width: 100%; }
.menu-btn { display: none; }

/* controls */
button, .btn { font: inherit; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  padding: 7px 13px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
button:hover, .btn:hover { background: var(--surface-2); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.07); }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
button.danger:hover { background: var(--danger-soft); }
button.small { padding: 3px 8px; font-size: 12.5px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { padding: 4px 9px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 7px; padding: 6px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card h2 { font-size: 15px; margin: 0 0 12px; }
.card h3 { font-size: 14px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small-text { font-size: 12.5px; }
.grid { display: grid; gap: 14px; }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.form { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .lbl { font-size: 12.5px; color: var(--ink-2); }
.tile .val { font-size: 22px; font-weight: 650; margin-top: 4px; letter-spacing: -.01em; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; font-size: 12.5px; color: var(--ink-2); position: sticky; top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.b td { font-weight: 650; }
tr.t td { border-top: 1px solid var(--ink-2); border-bottom: 3px double var(--ink-2); font-weight: 700; }
tr.sec td { font-weight: 700; padding-top: 14px; border-bottom: none; }
tr.hdr td { color: var(--ink-2); font-weight: 600; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tr.vstart td { border-top: 2px solid var(--line-2); }
td.code { font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.ind1 { padding-left: 22px !important; } .ind2 { padding-left: 38px !important; } .ind3 { padding-left: 54px !important; } .ind4 { padding-left: 70px !important; } .ind5 { padding-left: 86px !important; }
.report table td, .report table th { border-bottom-color: transparent; }
.report table tr:not(.sec):not(.t) td { border-bottom: 1px dotted var(--line); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.badge.ok { background: var(--good-soft); color: var(--good); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge.mute { background: var(--surface-2); color: var(--ink-2); }

/* report header */
.rep-head { text-align: center; margin: 4px 0 18px; }
.rep-head .org { font-weight: 700; font-size: 16px; text-transform: uppercase; }
.rep-head .ttl { font-weight: 700; font-size: 15px; margin-top: 2px; }
.rep-head .per { font-size: 13px; color: var(--ink-2); }
.sign { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 36px; text-align: center; }
.sign .space { height: 70px; }
.sign .nm { font-weight: 650; text-decoration: underline; }

/* journal form */
.jform .lines td { padding: 4px 5px; }
.jform .lines input, .jform .lines select { width: 100%; }
.jform .acc-name { font-size: 12px; color: var(--muted); margin-top: 2px; }
.balance-bar { display: flex; gap: 18px; align-items: center; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); margin-top: 10px; flex-wrap: wrap; }
.tmpl { display: flex; gap: 6px; flex-wrap: wrap; }

/* modal & toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 5vh 16px; overflow-y: auto; }
.modal[hidden] { display: none; }
.modal .box { background: var(--surface); border-radius: 12px; padding: 20px; width: min(640px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal .box.wide { width: min(1100px, 100%); }
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--danger); color: #fff; }
.tip { position: fixed; z-index: 70; background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 10px; box-shadow: var(--shadow); font-size: 12.5px; pointer-events: none; min-width: 170px; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* chart */
.chart { width: 100%; height: 280px; display: block; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: color-mix(in srgb, var(--ink) 5%, transparent); }

.empty { text-align: center; padding: 40px; color: var(--muted); }
.checks li { margin: 6px 0; list-style: none; }
.checks { padding: 0; margin: 0; }
.page-break { break-after: page; }
details summary { cursor: pointer; }

/* Tampilan desktop (default): tata letak tetap seperti di PC, jendela sempit cukup di-scroll */
html:not(.responsive) .app { min-width: 1100px; }

/* Tampilan mobile: hanya aktif bila pengguna memilihnya (kelas .responsive pada <html>) */
@media (max-width: 900px) {
  html.responsive .sidebar { position: fixed; left: -260px; z-index: 40; transition: left .2s; box-shadow: var(--shadow); }
  html.responsive .sidebar.open { left: 0; }
  html.responsive .menu-btn { display: inline-flex; }
  html.responsive .view { padding: 14px 16px 60px; }
  html.responsive .topbar { padding: 10px 16px; }
  html.responsive .grid.two { grid-template-columns: 1fr; }
  html.responsive { font-size: 15px; }
  /* 16px mencegah iPhone otomatis memperbesar halaman saat mengetik */
  html.responsive input, html.responsive select, html.responsive textarea { font-size: 16px; }
  html.responsive .topbar h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html.responsive .year-pick { font-size: 0; gap: 0; }
  html.responsive .year-pick select { font-size: 16px; }
  html.responsive .grid.tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  html.responsive .tile { padding: 10px 12px; }
  html.responsive .tile .val { font-size: 17px; word-break: break-word; }
  html.responsive .card { padding: 12px; }
  html.responsive .toolbar { gap: 6px; }
  html.responsive .toolbar label.f { flex: 1 1 140px; }
  html.responsive .toolbar label.f input, html.responsive .toolbar label.f select { width: 100%; min-width: 0 !important; }
  html.responsive .grid.form { grid-template-columns: 1fr; }
  html.responsive .grid.form label.f { grid-column: auto !important; }
  html.responsive th, html.responsive td { padding: 6px 7px; }
  html.responsive .sign { grid-template-columns: 1fr 1fr; gap: 10px; font-size: 13px; }
  html.responsive .modal { padding: 12px 8px; }
  html.responsive .modal .box { padding: 16px; }
  html.responsive .balance-bar { gap: 8px 14px; }
  html.responsive .balance-bar .spacer { flex-basis: 100%; }
  html.responsive .sidebar.open + .main::before { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }
}

@media print {
  :root { color-scheme: light; --bg: #fff; --surface: #fff; --ink: #000; --ink-2: #222; --line: #ddd; --surface-2: #f2f2f2; }
  .sidebar, .topbar, .toolbar, .no-print, .toast { display: none !important; }
  .view { padding: 0; max-width: none; }
  .card { box-shadow: none; border: none; padding: 0; }
  body { font-size: 11.5px; }
  th { position: static; }
  a { color: inherit; text-decoration: none; }
}
