@font-face { font-family: "Plex Sans"; src: url("/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Condensed"; src: url("/fonts/ibm-plex-sans-condensed-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Condensed"; src: url("/fonts/ibm-plex-sans-condensed-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

/* Kertas buku kas kehijauan dan tinta biru-hitam. Alasan tiap pilihan ada di DESIGN.md. */
:root {
  --paper: #F3F5F1;
  --surface: #FBFCFA;
  --ink: #16233B;
  --muted: #4F5B73;
  --rule: #CDD5CC;
  --rule-strong: #7C8798;
  --accent: #1F4FBF;
  --on-accent: #FFFFFF;
  --gain: #17693F;
  --loss: #B3261E;
  --wait: #8A5300;
  --cost: #B86A00;
  --rev: #2A5BD7;
  --hover: rgba(22, 35, 59, 0.07);
  --shadow: 0 12px 32px rgba(22, 35, 59, 0.18);
  --sans: "Plex Sans", system-ui, sans-serif;
  --cond: "Plex Condensed", "Plex Sans", system-ui, sans-serif;
  --gutter: clamp(1rem, 4vw, 2.5rem);
}
[data-theme="dark"] {
  --paper: #141C2B;
  --surface: #1B2536;
  --ink: #E6EAF2;
  --muted: #A3AEC2;
  --rule: #303C52;
  --rule-strong: #74819A;
  --accent: #8FB0F7;
  --on-accent: #141C2B;
  --gain: #5CC08C;
  --loss: #F0857A;
  --wait: #E0A85A;
  --cost: #CC8B2C;
  --rev: #5F8DEB;
  --hover: rgba(230, 234, 242, 0.08);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }
html[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
}
h1, h2, h3, p, dl, dd, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent); text-underline-offset: 0.18em; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#isi:focus { outline: none; }

.skip { position: absolute; left: 0.5rem; top: -4rem; background: var(--surface); padding: 0.75rem 1rem; z-index: 10; }
.skip:focus { top: 0.5rem; }

.muted { color: var(--muted); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.wait { color: var(--wait); }

/* ---------- Tombol dan isian ---------- */

.btn, select, input {
  font: 500 0.9375rem/1.2 var(--sans);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  min-height: 44px;
  padding: 0.5rem 0.875rem;
}
.btn { cursor: pointer; }
.btn:hover:not(:disabled), .seg-btn:hover { background: var(--hover); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { color: var(--muted); border-color: var(--rule); cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(0.92); }
input:disabled { color: var(--muted); border-color: var(--rule); }

.link {
  font: inherit; color: var(--accent); background: none; border: 0; padding: 0;
  text-decoration: underline; text-underline-offset: 0.18em; cursor: pointer; min-height: 44px;
}

.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.field-label { font-size: 0.8125rem; color: var(--muted); }
.field-grow { flex: 1 1 14rem; }
.field-custom { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 0.5rem; align-self: flex-end; }

.seg { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.seg-btn {
  font: 500 0.9375rem/1.2 var(--sans);
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  min-height: 44px;
  padding: 0.5rem 0.875rem;
  cursor: pointer;
}
.seg-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- Login dan layar tunggu ---------- */

.boot { padding: 4rem var(--gutter); color: var(--muted); }
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--gutter); }
.login-form { width: min(100%, 22rem); display: grid; gap: 0.75rem; }
.login-form h1 { font: 600 1.75rem/1.15 var(--cond); padding-bottom: 0.75rem; border-bottom: 3px double var(--ink); }
.login-form label { font-size: 0.8125rem; color: var(--muted); margin-bottom: -0.5rem; }
.login-form input { font-size: 1.25rem; letter-spacing: 0.2em; }
.form-error { color: var(--loss); min-height: 1.5rem; }

/* ---------- Kepala halaman ---------- */

.top { padding: 1rem var(--gutter) 0; }
.top-row { display: flex; align-items: center; gap: 0.75rem 1rem; flex-wrap: wrap; }
.brand { font: 600 1.25rem/1.2 var(--cond); margin-right: auto; }
.updated { font-size: 0.8125rem; color: var(--muted); }
.actions { display: flex; gap: 0.375rem; flex-wrap: wrap; }
.actions .btn { border-color: transparent; background: transparent; padding-inline: 0.625rem; }
.actions .btn:hover:not(:disabled) { background: var(--hover); }
.menu-toggle { display: none; }

.controls { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; padding: 1rem 0; }
.controls-inline { padding: 0 0 1rem; }

.jump {
  display: flex; gap: 0.25rem; overflow-x: auto;
  padding: 0 var(--gutter);
  border-block: 1px solid var(--rule);
  scrollbar-width: none;
}
.jump a { color: var(--ink); text-decoration: none; padding: 0.75rem 0.625rem; white-space: nowrap; font-size: 0.9375rem; min-height: 44px; }
.jump a:first-child { padding-left: 0; }
.jump a:hover { text-decoration: underline; }

/* ---------- Isi ---------- */

#isi { padding: 0 var(--gutter) 4rem; max-width: 92rem; }
.sec { padding-top: 3rem; scroll-margin-top: 1rem; }
.sec-first { padding-top: 2rem; }
.sec-head { display: grid; gap: 0.25rem; margin-bottom: 1rem; }
.sec h2 { font: 600 1.25rem/1.25 var(--cond); }
.sec-first h2 { font: 500 1rem/1.4 var(--sans); color: var(--muted); }
.sub { font: 600 1rem/1.3 var(--cond); margin: 2rem 0 0.5rem; }
.footnote { font-size: 0.8125rem; color: var(--muted); margin-top: 0.75rem; }

/* Kalimat hasil adalah satu-satunya unsur besar di halaman. Garis ganda di
   bawahnya adalah tanda "jumlah akhir" di buku kas, dipakai lagi di baris total tabel. */
.verdict {
  font: 600 clamp(1.75rem, 1.1rem + 3.2vw, 3.25rem)/1.1 var(--cond);
  letter-spacing: -0.01em;
  max-width: 24ch;
  text-wrap: balance;
}
.lede {
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.125rem);
  max-width: 62ch;
  margin-top: 0.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 3px double var(--ink);
}

.figs { display: grid; gap: 1rem 2rem; margin-top: 1.25rem; }
.figs-main { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.figs-more { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-top: 1rem; border-top: 1px solid var(--rule); }
@media (min-width: 44rem) { .figs-more { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.fig dt { font-size: 0.8125rem; color: var(--muted); }
.fig dd { font: 500 1.125rem/1.3 var(--cond); font-variant-numeric: tabular-nums; }
.figs-main .fig dd { font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem); font-weight: 600; }
.delta { display: block; font: 400 0.8125rem/1.4 var(--sans); color: var(--muted); }
.delta.gain { color: var(--gain); }
.delta.loss { color: var(--loss); }
.extremes { margin-top: 1.5rem; }

.notice { padding: 1.25rem; border: 1px solid var(--rule-strong); border-radius: 3px; max-width: 46rem; margin-top: 2rem; display: grid; gap: 0.5rem; }
.notice h2, .notice h3 { font: 600 1.125rem/1.3 var(--cond); color: var(--ink); }
.notice-error { border-color: var(--loss); }
.notice-error h2::before { content: "Gagal: "; color: var(--loss); }

.todo ul { display: grid; gap: 0.75rem; margin-top: 0.75rem; max-width: 62rem; }
.todo li { display: grid; gap: 0.125rem; padding: 0.75rem 0; border-top: 1px solid var(--rule); }
.todo li span { color: var(--wait); }
.todo a { min-height: 44px; display: inline-flex; align-items: center; justify-self: start; }

/* ---------- Grafik ---------- */

.legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; font-size: 0.875rem; margin-bottom: 0.5rem; }
.legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.sw { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 2px; flex: none; }
.sw-cost { background: var(--cost); }
.sw-rev { background: var(--rev); }
.sw-profit { height: 2px; width: 1rem; background: var(--ink); border-radius: 0; }

.chart { position: relative; min-width: 0; }
.chart svg { display: block; touch-action: pan-y; }
.chart svg:focus-visible { outline-offset: 4px; }
.chart-grid { stroke: var(--rule); stroke-width: 1; }
.chart-zero { stroke: var(--rule-strong); stroke-width: 1; }
.chart-ref { stroke: var(--rule-strong); stroke-width: 1; stroke-dasharray: 4 4; }
.chart-axis { fill: var(--muted); font: 400 0.75rem var(--sans); font-variant-numeric: tabular-nums; }
.chart-guide { fill: var(--hover); pointer-events: none; }
.bar-cost { fill: var(--cost); }
.bar-rev { fill: var(--rev); }
.line-profit, .line-single { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot-profit, .dot-single { fill: var(--ink); stroke: var(--paper); stroke-width: 2; }
.chart-empty { padding: 1rem 0; max-width: 40ch; }

.chart-tip {
  position: absolute; top: 0; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 3px;
  box-shadow: var(--shadow); /* tooltip memang melayang di atas grafik */
  padding: 0.5rem 0.75rem; font-size: 0.8125rem; pointer-events: none; z-index: 2;
  min-width: 13rem; max-width: calc(100vw - 2rem);
}
.chart-tip dl { display: grid; gap: 0.125rem; margin-top: 0.25rem; }
.chart-tip div { display: flex; justify-content: space-between; gap: 1rem; }
.chart-tip dt { color: var(--muted); display: inline-flex; align-items: center; gap: 0.4rem; }
.chart-tip dd { font: 500 0.875rem var(--cond); font-variant-numeric: tabular-nums; white-space: nowrap; }

.minis { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 2rem; margin-top: 2.5rem; }
.mini h3 { font: 600 1rem/1.3 var(--cond); }
.mini figcaption p { font-size: 0.8125rem; }
.mini-range { font-family: var(--cond); font-weight: 500; font-variant-numeric: tabular-nums; margin-bottom: 0.5rem; }

/* ---------- Tabel ---------- */

.scroll { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font: 500 0.9375rem/1.35 var(--cond); font-variant-numeric: tabular-nums; }
th, td { padding: 0.5rem 0.75rem; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
th:first-child, td:first-child { padding-left: 0; }
thead th { font: 500 0.8125rem/1.3 var(--sans); color: var(--muted); border-bottom: 1px solid var(--ink); vertical-align: middle; }
tbody th { font-weight: 500; }
.n { text-align: right; }
tbody tr:hover { background: var(--hover); }
tfoot th, tfoot td { font-weight: 600; border-bottom: 3px double var(--ink); border-top: 1px solid var(--ink); }
/* Kolom pertama tetap terlihat saat tabel lebar digeser ke samping. */
.scroll th:first-child { position: sticky; left: 0; background: var(--paper); z-index: 1; }
.scroll tbody tr:hover th:first-child { background: color-mix(in srgb, var(--paper), var(--ink) 7%); }

.sort { font: inherit; color: inherit; background: none; border: 0; padding: 0.625rem 0; cursor: pointer; min-height: 44px; }
.sort:hover { color: var(--ink); text-decoration: underline; }
th[aria-sort="ascending"] .sort, th[aria-sort="descending"] .sort { color: var(--ink); }

.share { min-width: 9rem; }
.share-bar { display: inline-block; height: 0.625rem; background: var(--cost); border-radius: 0 2px 2px 0; vertical-align: middle; max-width: calc(100% - 4rem); }
.share-num { margin-left: 0.5rem; color: var(--muted); }

.tablinks { display: grid; gap: 0.25rem; }
.tablinks li { display: flex; flex-wrap: wrap; align-items: center; gap: 0 1.25rem; }
.tablinks a { min-height: 44px; display: inline-flex; align-items: center; }

/* ---------- Dialog ---------- */

.dialog {
  width: min(46rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem);
  padding: 0; border: 1px solid var(--rule-strong); border-radius: 4px;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); /* dialog berada di atas halaman */
}
.dialog::backdrop { background: rgba(10, 16, 28, 0.55); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--rule); position: sticky; top: 0; background: var(--surface); }
.dialog-head h2 { font: 600 1.25rem/1.2 var(--cond); }
.dialog-body { padding: 1.25rem; display: grid; gap: 1rem; }
.dialog-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--rule); display: flex; justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface); }
.prose section { display: grid; gap: 0.625rem; max-width: 68ch; }
.prose section + section { padding-top: 1rem; border-top: 1px solid var(--rule); }
.prose h3 { font: 600 1.0625rem/1.3 var(--cond); }
.src-list { display: grid; gap: 1rem; }
.src-list li { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; padding-bottom: 1rem; border-bottom: 1px solid var(--rule); }
.src-list input { width: 100%; }
#add-source { justify-self: start; }

/* ---------- Layar sempit ---------- */

@media (max-width: 52rem) {
  .menu-toggle { display: inline-block; }
  .actions { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; border-block: 1px solid var(--rule); padding: 0.375rem 0; }
  .actions.is-open { display: flex; }
  .actions .btn { text-align: left; padding-inline: 0; }
  .updated { order: 3; flex-basis: 100%; }
}
@media (max-width: 36rem) {
  .sec { padding-top: 2.25rem; }
  .controls { gap: 0.75rem; }
  .controls > .field { flex: 1 1 100%; }
  .field-custom { align-self: stretch; }
  .field-custom input { flex: 1 1 8rem; }
  .seg-btn { flex: 1 1 auto; }
  th, td { padding: 0.5rem 0.5rem; }
  .minis { gap: 1.5rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .seg-btn { transition: background-color 120ms; }
}
@media (forced-colors: active) {
  .bar-cost, .bar-rev, .sw { forced-color-adjust: none; }
}
