:root {
  --canvas: #0a0f16;
  --surface: #151e29;
  --glass: rgb(20 29 40 / 82%);
  --line: #2d3e51;
  --text: #ecf4ff;
  --muted: #a9bacf;
  --accent: #85c5ff;
  --bar: #397de7;
  --radius: 18px;
  --gap: 16px;
  --blur: 24px;
  --motion: 440ms cubic-bezier(.2,.7,.25,1);
  --glow: #1c3048; --masthead: #101822; --chip: #1e3956; --hover: #243b54; --btn: #2a67d4;
  --pos: #7fe0b5; --neg: #ffb07f; --out-a: #ffb48a; --out-b: #e0703f; --tint: #1b3652;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --canvas: #eef3f9; --surface: #fff; --glass: rgb(255 255 255 / 82%); --line: #cdd9e6; --text: #0f1b2a; --muted: #4a5d73;
  --accent: #1456b8; --bar: #2f6fdb; --glow: #cfe0f5; --masthead: #fff; --chip: #dbe8f8; --hover: #e2ecf8;
  --pos: #13795b; --neg: #b4421a; --out-a: #f2955f; --out-b: #c85a2a; --tint: #dbe9fb; color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(ellipse at 75% 0%, var(--glow), transparent 54%), var(--canvas);
  font: 15px/1.55 system-ui, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, select, input { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.skip { position: fixed; z-index: 3; top: 12px; left: 12px; background: var(--surface); padding: 10px; transform: translateY(-150%); }
.skip:focus { transform: none; }
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px clamp(16px, 4vw, 52px);
  border-bottom: 1px solid var(--line);
  background: var(--masthead);
}
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 750; }
.brand-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--chip); color: var(--accent); font-size: 12px; }
.version, footer, p { color: var(--muted); }
.glass {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px rgb(255 255 255 / 5%), 0 12px 30px rgb(0 0 0 / 18%);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .dock.glass {
    background: var(--glass);
    -webkit-backdrop-filter: blur(var(--blur));
    backdrop-filter: blur(var(--blur));
  }
}
.dock { position: fixed; z-index: 2; left: 20px; top: 96px; display: grid; gap: 5px; width: 105px; padding: 7px; }
.dock a { display: grid; align-content: center; justify-items: center; min-height: 62px; border-radius: 11px; font-size: 12px; color: var(--muted); transition: background 160ms; }
.dock a span { font-size: 18px; }
.dock a:hover, .dock a[aria-current="page"] { background: var(--hover); color: var(--text); }
main { max-width: 1420px; margin: auto; padding: 34px 34px 24px 152px; }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: var(--gap); margin-bottom: 24px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(34px, 5vw, 54px); line-height: 1.15; letter-spacing: -.045em; margin: 5px 0; }
h2 { font-size: 17px; }
.kicker { color: var(--accent); text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 700; }
.period { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.period[hidden] { display: none; }
select { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); animation: appear var(--motion) both; }
.card { padding: clamp(15px, 2.5vw, 24px); min-width: 0; }
.wide { grid-column: span 2; }
.full { grid-column: 1 / -1; }
.metric { background: linear-gradient(145deg, var(--tint), var(--surface) 80%); }
.metric strong { display: block; margin: 8px 0 1px; font-size: clamp(24px, 4vw, 35px); font-variant-numeric: tabular-nums; }
.metric p, .chart-meta, footer { font-size: 13px; }
.chart-meta { margin: 4px 0 16px; }
.chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: clamp(3px, 1vw, 10px);
  height: 190px;
  background: repeating-linear-gradient(to top, var(--line) 0 1px, transparent 1px 25%);
}
.column { display: flex; align-items: end; min-width: 0; padding: 0; border: 0; border-radius: 5px; background: transparent; cursor: pointer; }
.column:hover, .column[aria-pressed="true"] { background: rgb(133 197 255 / 12%); }
.bar { width: 100%; height: var(--height); border-radius: 5px 5px 0 0; background: linear-gradient(var(--accent), var(--bar)); transform-origin: bottom; animation: grow var(--motion) both; animation-delay: var(--delay); }
.chart-readout { min-height: 24px; margin-top: 12px; }
.summary { margin: 12px 0 0; }
.summary div { display: flex; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-variant-numeric: tabular-nums; }
.toggle { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 12px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
footer { padding: 22px 0; }
@keyframes grow { from { transform: scaleY(.03); } }
@keyframes appear { from { opacity: 0; transform: translateY(7px); } }
@media (max-width: 900px) {
  main { padding-inline: 128px 20px; }
  .dock { left: 12px; width: 96px; }
  .wide { grid-column: 1 / -1; }
  .wide + .card { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  main { padding: 22px 14px calc(84px + env(safe-area-inset-bottom)); }
  .dock { inset: auto 14px calc(10px + env(safe-area-inset-bottom)) 14px; width: auto; grid-template-columns: repeat(3, 1fr); --blur: 16px; }
  .dock a { min-height: 48px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(3) { grid-column: 1 / -1; }
  .page-header { align-items: start; flex-direction: column; }
  .chart { height: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
html[data-motion="off"] * { animation: none !important; transition: none !important; }

/* ---- Kas DPC PSI Tabanan ---- */
.masthead nav, .actions, .head, .filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.head { justify-content: space-between; margin-bottom: 8px; }
.t1 { --tint: #1b3652; } .t2 { --tint: #173b3c; } .t3 { --tint: #3a2a2a; }
:root[data-theme="light"] .t1 { --tint: #dbe9fb; } :root[data-theme="light"] .t2 { --tint: #d6efe9; } :root[data-theme="light"] .t3 { --tint: #f8e4da; }
.metric strong { font-size: clamp(20px, 3.2vw, 32px); overflow-wrap: anywhere; }
.pair { display: flex; align-items: end; gap: 3px; width: 100%; height: 100%; }
.pair .bar { flex: 1; min-width: 0; }
.bar.out { background: linear-gradient(var(--out-a), var(--out-b)); }
.column { height: 100%; }
.months { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: clamp(3px, 1vw, 10px); margin-top: 6px; font-size: 12px; color: var(--muted); text-align: center; }
.tx { display: grid; grid-template-columns: 96px 1fr auto; gap: 4px 14px; align-items: baseline; padding: 14px 0; border-bottom: 1px solid var(--line); }
.tx:last-child { border-bottom: 0; }
.tx time { color: var(--muted); font-size: 13px; }
.tx .amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.amt.in { color: var(--pos); } .amt.out { color: var(--neg); }
.tx .meta { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.badge { padding: 2px 10px; border-radius: 99px; background: var(--chip); color: var(--text); font-size: 12px; }
.badge.warn { background: transparent; border: 1px dashed var(--muted); color: var(--muted); }
.btn { min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--chip); color: var(--text); cursor: pointer; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--btn); border-color: var(--btn); color: #fff; }
.btn.danger { color: var(--neg); } .btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; } .btn:disabled { opacity: .55; cursor: wait; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 12px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; }
input, textarea { min-height: 44px; width: 100%; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); color: var(--text); font-size: 16px; }
input[type="file"] { padding: 9px 12px; } input[type="radio"], input[type="checkbox"] { min-height: 0; width: 20px; }
.seg { display: flex; gap: 8px; margin: 0; padding: 0; border: 0; } .seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.seg span { display: grid; place-items: center; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); color: var(--muted); }
.seg input:checked + span { background: var(--btn); border-color: var(--btn); color: #fff; font-weight: 700; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.msg { min-height: 22px; color: var(--accent); } .msg.err { color: var(--neg); }
dialog { max-width: min(92vw, 720px); padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); text-align: center; }
dialog::backdrop { background: rgb(0 0 0 / 60%); } dialog img { max-width: 100%; max-height: 74vh; border-radius: 10px; }
@media (max-width: 600px) {
  .form { grid-template-columns: 1fr; } .tx { grid-template-columns: 1fr auto; } .tx time { grid-column: 1 / -1; } .tx .meta { grid-column: 1 / -1; }
  .metric:nth-child(1) { grid-column: 1 / -1; } .metric:nth-child(3) { grid-column: auto; } .wide { grid-column: 1 / -1; }
}

.brand img { display: block; height: 52px; width: auto; }
html[data-theme="dark"] .logo-l, html[data-theme="light"] .logo-d { display: none; }
@media (min-width: 601px) { .dock { top: 118px; } }
@media (max-width: 600px) { .brand img { height: 44px; } }

/* ---- Perbaikan baris transaksi: nominal tidak lagi terpotong di kartu sempit ---- */
.card.glass { container-type: inline-size; } /* kartu jadi acuan lebar untuk tata letak baris */
.tx { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "tgl amt" "judul judul" "meta meta"; gap: 4px 12px; align-items: baseline; } /* default sempit: tanggal + nominal di atas, judul di bawahnya */
.tx time { grid-area: tgl; } /* tanggal di pojok kiri atas */
.tx strong { grid-area: judul; min-width: 0; overflow-wrap: anywhere; } /* judul memakai lebar penuh dan boleh turun baris */
.tx .amt { grid-area: amt; white-space: nowrap; } /* nominal di pojok kanan atas, tidak pernah patah */
.tx .meta { grid-area: meta; } /* kategori, tombol bukti, dan aksi admin di baris bawah */
.tx > span:empty { display: none; } /* sembunyikan kolom kosong pada daftar admin */
@container (min-width: 560px) { /* kartu lebar (halaman Transaksi dan Admin): kembali ke satu baris */
  .tx { grid-template-columns: 110px minmax(0, 1fr) auto; grid-template-areas: "tgl judul amt" ". meta meta"; gap: 4px 16px; } /* tiga kolom: tanggal, judul, nominal */
}
