/* Tema SPE (terang): Montserrat bila terpasang, indigo/ungu, aksen merah, kartu membulat. */
:root {
  --bg: #ffffff; --surface: #ffffff; --surface2: #f3f0ff; --text: #1a1855; --muted: #6f6d8a;
  --border: #e8e5f4; --border2: #d3d7f3;
  --ink: #1a1855; --violet: #6b2ad5; --violet2: #4f0fb5; --blue: #427bc7;
  --accent: #6b2ad5; --good: #1fb57a; --amber: #f0a020; --red: #d72828;
  --ok-bg: #dcf5ea; --ok-fg: #0d7a50; --amb-bg: #fff0d6; --amb-fg: #8a5200; --red-bg: #ffe0e4; --red-fg: #a3001e;
  --radius: 14px; --radius-lg: 20px; --shadow: 0 8px 24px rgba(60, 40, 140, .10);
  color-scheme: light;
  font-family: Montserrat, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }

/* ---------- header ---------- */
header.top { display: flex; align-items: center; gap: 18px; padding: 10px 24px; background: #fff; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.brand img { display: block; height: 44px; width: auto; }
.brand .sep { width: 1px; height: 32px; background: var(--border); }
.brand .appname { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .2px; }
nav.tabs { display: flex; gap: 8px; flex: 1; justify-content: center; flex-wrap: wrap; }
nav.tabs a {
  padding: 8px 16px; border-radius: 999px; background: #eef0fb; color: var(--ink); border: 1.5px solid var(--border2);
  font-weight: 700; font-size: 12.5px; text-decoration: none; white-space: nowrap;
}
nav.tabs a:hover { background: #e3e6f9; }
nav.tabs a.on { background: var(--violet); color: #fff; border-color: var(--violet); box-shadow: 0 4px 12px rgba(107, 42, 213, .35); }
.ctx { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ctx label { margin: 0; white-space: nowrap; }
.cta { background: var(--red); color: #fff; border: none; border-radius: 999px; padding: 10px 18px; font-weight: 700; font-size: 12px; text-decoration: none; white-space: nowrap; }
.cta:hover { filter: brightness(.94); }

/* ---------- hero ---------- */
.hero {
  padding: 22px 0 34px;
  background:
    radial-gradient(circle at 88% 18%, rgba(244, 170, 150, .55), transparent 38%),
    radial-gradient(circle at 62% 78%, rgba(150, 212, 226, .6), transparent 44%),
    radial-gradient(circle at 92% 98%, rgba(150, 160, 232, .5), transparent 40%),
    linear-gradient(90deg, #faf8ff, #f2efff);
}
.hero h1 {
  margin: 0 0 12px; font-size: 30px; line-height: 1.05; font-weight: 800; letter-spacing: -.8px;
  background: linear-gradient(180deg, var(--violet2) 0%, var(--ink) 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .per { margin: 0; padding: 0; background: none; border-radius: 0; }
#content { padding-top: 0; padding-bottom: 40px; }
#view { margin-top: -18px; }
#view > .fl:first-child, #view > .banner:first-child { margin-top: 24px; }

/* ---------- elemen dasar ---------- */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
select, input, textarea {
  padding: 8px 14px; border: 1.5px solid var(--border); border-radius: 999px; background: #fff;
  color: var(--text); font: inherit; font-size: 13px; max-width: 100%;
}
textarea { border-radius: var(--radius); }
select:focus, input:focus { outline: 2px solid rgba(107, 42, 213, .35); outline-offset: 1px; border-color: var(--violet); }
input[type=date] { min-height: 36px; }
input[type=checkbox], input[type=radio] { padding: 0; accent-color: var(--violet); }
.btn {
  padding: 8px 16px; border: 1.5px solid var(--violet); border-radius: 999px; background: #fff; color: var(--violet);
  cursor: pointer; font: inherit; font-weight: 700; font-size: 12.5px; text-decoration: none; display: inline-block; white-space: nowrap;
}
.btn:hover { background: var(--surface2); }
.btn.p { background: var(--violet); color: #fff; }
.btn.p:hover { background: var(--violet2); }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.sm { padding: 3px 12px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: default; }
.fl { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.fl .grow { flex: 1; }
.per .fl { margin: 0; }
.sub { font-size: 12px; color: var(--muted); }
.note { font-size: 12px; color: var(--muted); }

/* ---------- kartu ringkasan ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card { background: #fff; border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow); border-top: 4px solid var(--violet); }
.card:nth-child(2) { border-top-color: var(--good); }
.card:nth-child(3) { border-top-color: var(--amber); }
.card:nth-child(4) { border-top-color: var(--red); }
.card .l { font-size: 11px; font-weight: 600; color: var(--muted); }
.card .v { font-size: clamp(21px, 2vw, 25px); font-weight: 800; margin: 2px 0; white-space: nowrap; }
.card .v small { font-size: 12px; font-weight: 700; color: var(--muted); margin-right: 5px; }
.card .s { font-size: 11px; color: var(--muted); }

/* ---------- kotak, grid ---------- */
.box { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 14px; }
.box h3 { font-size: 14px; font-weight: 800; margin: 0 0 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- pita biru bergrid + kartu bucket ---------- */
.band {
  margin: 22px -20px 18px; padding: 22px 20px 26px; background-color: var(--blue);
  background-image: linear-gradient(rgba(255, 255, 255, .14) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .14) 1px, transparent 1px);
  background-size: 26px 26px; border-radius: var(--radius-lg);
}
.band h2 { margin: 0 0 14px; color: #fff; font-size: 16px; font-weight: 800; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; }
.band h2 span { font-size: 11px; font-weight: 600; opacity: .92; }
.bcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.bc { background: #fff; border-radius: var(--radius-lg); padding: 14px 16px 16px; border: 3px solid var(--violet); box-shadow: 0 10px 26px rgba(10, 20, 80, .25); }
.bc:nth-child(4n+2) { border-color: var(--good); }
.bc:nth-child(4n+3) { border-color: var(--red); }
.bc:nth-child(4n) { border-color: var(--amber); }
.bc h4 { margin: 0 0 2px; font-size: 12.5px; font-weight: 800; line-height: 1.25; min-height: 32px; }
.bc p { margin: 0 0 8px; font-size: 11px; color: var(--muted); min-height: 32px; }
.bc .pc { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-weight: 800; font-size: 18px; }
.trk { height: 10px; background: #ece9f8; border-radius: 999px; position: relative; overflow: hidden; }
.trk i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.trk .tm { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); opacity: .55; }

/* ---------- batang & baris ---------- */
.row { display: grid; grid-template-columns: 200px 1fr 56px; gap: 8px; align-items: center; margin: 7px 0; font-size: 13px; }
.row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) { .row { grid-template-columns: 100px 1fr 52px; } }
.bar { height: 9px; background: #ece9f8; border-radius: 999px; position: relative; overflow: hidden; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.bar .tm { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); opacity: .55; }
.r { text-align: right; color: var(--muted); }

/* ---------- chip, tag ---------- */
.chip { border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.chip.aman { background: var(--ok-bg); color: var(--ok-fg); }
.chip.hampir { background: var(--amb-bg); color: var(--amb-fg); }
.chip.habis, .chip.over { background: var(--red-bg); color: var(--red-fg); }
.tag { background: #efeafd; color: var(--violet2); border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 700; }
.al { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-top: 1px solid var(--border); gap: 8px; }
.al:first-of-type { border-top: none; }

/* ---------- grafik bulanan ---------- */
.mb { display: flex; align-items: flex-end; gap: 6px; height: 130px; margin-top: 6px; }
.mb div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 10px; font-weight: 600; color: var(--muted); min-width: 0; }
.mb b { width: 100%; border-radius: 8px 8px 0 0; background: linear-gradient(180deg, #8b5cf6, var(--violet2)); display: block; min-height: 1px; }
.mb .off b { background: repeating-linear-gradient(45deg, #d9d3f3, #d9d3f3 4px, #ece9f8 4px, #ece9f8 8px); }

/* ---------- tabel ---------- */
.tw { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow-x: auto; background: #fff; margin-bottom: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 700; color: var(--muted); padding: 10px 10px; font-size: 11px; background: #faf9ff; white-space: nowrap; }
td { padding: 9px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.n { text-align: right; white-space: nowrap; }
.nw { white-space: nowrap; }
tr.b td { font-weight: 800; background: var(--surface2); }
tr.it td:first-child { padding-left: 26px; }
tr.former td { color: var(--muted); font-style: italic; }
td.neg, .neg { color: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.banner { padding: 10px 14px; border-radius: var(--radius); background: var(--amb-bg); color: var(--amb-fg); margin-bottom: 12px; font-size: 13px; }
.info { padding: 10px 14px; border-radius: var(--radius); background: var(--surface2); margin: 10px 0; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; align-items: end; }
.form-grid > div > input, .form-grid > div > select { width: 100%; }

/* ---------- dialog & toast ---------- */
dialog { border: 1px solid var(--border2); border-radius: var(--radius-lg); padding: 0; background: #fff; color: var(--text); width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 24px 60px rgba(26, 24, 85, .35); }
dialog::backdrop { background: rgba(26, 24, 85, .45); }
.mform { padding: 18px 20px; }
.mform h3 { margin: 0 0 10px; font-size: 17px; font-weight: 800; }
.mform label { margin-top: 10px; }
.mform input, .mform select, .mform textarea { width: 100%; }
.mform .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.mform .err { color: var(--red); margin: 10px 0 0; font-size: 13px; }
.menu-list { display: grid; gap: 6px; margin-top: 8px; }
.menu-list .btn { text-align: left; width: 100%; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); z-index: 50; }
#toast.show { opacity: 1; }
#toast.err { background: var(--red); }

/* ---------- footer ---------- */
.foot { background: var(--ink); color: #cfcdf0; font-size: 11px; font-weight: 500; padding: 14px 0; }
.foot .wrap { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.foot b { color: #fff; }

@media (max-width: 560px) {
  .cards { grid-template-columns: 1fr; } /* angka penuh butuh lebar: satu kartu per baris di layar sempit */
  .ctx label { display: none; } /* agar pilihan tahun dan tombol Catat Transaksi muat satu baris */
}
@media (max-width: 760px) {
  header.top { padding: 10px 14px; }
  nav.tabs { justify-content: flex-start; order: 3; flex-basis: 100%; }
  .band { margin-left: -20px; margin-right: -20px; border-radius: 0; }
}
