/* =========================================================
   Aplikasi Bendahara — gaya buku kas
   ========================================================= */
:root {
  --ink: #14323a;         /* tinta buku kas: sidebar, judul */
  --ink-2: #24505b;
  --paper: #f2f5f3;       /* latar halaman */
  --surface: #ffffff;
  --line: #d6ded9;        /* garis buku kas */
  --muted: #5c6f6a;
  --text: #1b2a2a;
  --masuk: #1e7a55;
  --masuk-bg: #e3f2ea;
  --keluar: #b3263e;
  --keluar-bg: #f8e6e9;
  --gold: #a88419;        /* cap / stempel */
  --gold-bg: #f6efd9;
  --focus: #2f7fd1;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { color: var(--ink); line-height: 1.25; margin: 0; }
a { color: var(--ink-2); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- tombol & form ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 16px; font-weight: 600; font-size: 14px;
  cursor: pointer; background: var(--ink); color: #fff;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--ink-2); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #e8eeea; }
.btn-danger { background: var(--keluar); }
.btn-danger:hover { background: #95182e; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 6px 9px; background: transparent; color: var(--muted); border-color: var(--line); }
.btn-icon:hover { color: var(--ink); background: #eef2ef; }
.btn-icon.danger:hover { color: var(--keluar); background: var(--keluar-bg); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field small { color: var(--muted); font-size: 12px; }
.input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff;
}
.input:focus { border-color: var(--ink-2); outline: none; box-shadow: 0 0 0 3px rgba(47,127,209,.25); }
.input-money { text-align: right; font-weight: 600; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }

.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; }
.alert-error { background: var(--keluar-bg); color: #7d1426; }

/* =========================================================
   LOGIN
   ========================================================= */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side {
  background-color: var(--ink);
  /* garis buku kas */
  background-image:
    linear-gradient(90deg, transparent 72px, rgba(255,255,255,.18) 72px, rgba(255,255,255,.18) 74px, transparent 74px),
    repeating-linear-gradient(0deg, transparent 0 35px, rgba(255,255,255,.07) 35px 36px);
  color: #dfe9e6; padding: 56px 56px 56px 104px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-side .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; color: #fff; font-size: 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid var(--gold); color: var(--gold);
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.login-side h1 { color: #fff; font-size: clamp(30px, 3.4vw, 46px); font-weight: 700; max-width: 14ch; margin-bottom: 16px; letter-spacing: -.01em; }
.login-side p { max-width: 40ch; margin: 0; color: #bcd0cb; }
.login-side .foot { font-size: 13px; color: #8fb0a9; }
.login-main { display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 24px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); margin: 0 0 24px; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; margin-top: 6px; }
.pw-wrap { position: relative; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; padding: 6px 8px;
}

@media (max-width: 820px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { padding: 32px 24px 32px 56px; min-height: auto; gap: 28px;
    background-image:
      linear-gradient(90deg, transparent 32px, rgba(255,255,255,.18) 32px, rgba(255,255,255,.18) 34px, transparent 34px),
      repeating-linear-gradient(0deg, transparent 0 35px, rgba(255,255,255,.07) 35px 36px); }
  .login-side h1 { font-size: 28px; }
}

/* =========================================================
   LAYOUT APLIKASI
   ========================================================= */
.app { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--ink); color: #cfe0db;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 20px 14px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; padding: 4px 8px 22px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: #cfe0db; text-decoration: none; font-size: 14px;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--gold); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-group { margin-top: 16px; }
.nav-group > span { display: block; font-size: 12px; color: #86a7a0; padding: 0 10px 6px; font-weight: 600; }
.nav-group a { padding-left: 38px; position: relative; }
.nav-group a::before { content: ""; position: absolute; left: 19px; top: 50%; width: 8px; height: 1px; background: #5f8a82; }
.nav-group a.nav-top { padding-left: 10px; }
.nav-group a.nav-top::before { display: none; }
.nav-bottom { border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; }
.sidebar .side-foot { margin-top: auto; padding: 16px 8px 0; font-size: 12px; color: #7f9f98; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 19px; font-weight: 700; }
.topbar .crumb { color: var(--muted); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 14px; color: var(--muted); }
.topbar .who b { color: var(--ink); }
.menu-btn { display: none; }
.content { padding: 24px 28px 48px; max-width: 1240px; width: 100%; }

/* ---------- panel ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { font-size: 16px; }
.panel-body { padding: 18px 20px; }
.stack { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.stack > *, .grid-2 > *, .grid-2-even > * { min-width: 0; }

/* ---------- dashboard ---------- */
.ledger-total {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden;
}
.ledger-total .big { padding: 26px 28px; border-right: 1px solid var(--line); }
.ledger-total .big h2 { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.saldo-figure {
  display: inline-block; font-size: clamp(32px, 4.4vw, 50px); font-weight: 800; color: var(--ink);
  letter-spacing: -.02em; line-height: 1.1;
  /* garis ganda tanda total akuntansi */
  border-bottom: 5px double var(--ink); padding-bottom: 6px;
}
.saldo-figure.neg { color: var(--keluar); border-color: var(--keluar); }
.ledger-total .big p { margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.ledger-lines { display: grid; }
.ledger-lines div { display: flex; justify-content: space-between; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); font-size: 14px; }
.ledger-lines div:last-child { border-bottom: 0; }
.ledger-lines span { color: var(--muted); }
.ledger-lines b { font-weight: 700; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; text-decoration: none; color: inherit; display: block; }
.tile:hover { border-color: var(--ink-2); }
.tile .t { font-size: 13px; color: var(--muted); }
.tile .v { font-size: 20px; font-weight: 700; color: var(--ink); margin-top: 2px; }
.tile .s { font-size: 12px; color: var(--muted); }
.tile.warn { background: var(--gold-bg); border-color: #e4d39c; }
.tile.warn .v { color: #7a5f0d; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* grafik batang 6 bulan */
.chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: end; height: 220px; padding-top: 10px; }
.chart .col { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 6px; }
.chart .bars { display: flex; align-items: flex-end; justify-content: center; gap: 4px; border-bottom: 1px solid var(--line); }
.chart .bar { width: 38%; max-width: 22px; border-radius: 3px 3px 0 0; min-height: 2px; transition: height .5s ease; }
.chart .bar.m { background: var(--masuk); }
.chart .bar.k { background: var(--keluar); }
.chart .lbl { text-align: center; font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* daftar peringkat */
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.rank li { display: grid; gap: 5px; }
.rank .top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.rank .track { height: 6px; background: #edf1ee; border-radius: 3px; overflow: hidden; }
.rank .fill { height: 100%; border-radius: 3px; }

/* ---------- tabel ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: #f7f9f8; white-space: nowrap; }
tbody tr:hover { background: #f8faf9; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
td.act { white-space: nowrap; text-align: right; }
td.act .btn-icon + .btn-icon { margin-left: 4px; }
tfoot td { font-weight: 700; background: #f7f9f8; }
tfoot td.num { border-bottom: 4px double var(--ink); }
.amt-in { color: var(--masuk); font-weight: 600; }
.amt-out { color: var(--keluar); font-weight: 600; }
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.pill-in { background: var(--masuk-bg); color: var(--masuk); }
.pill-out { background: var(--keluar-bg); color: var(--keluar); }
.pill-gold { background: var(--gold-bg); color: #7a5f0d; }
.pill-muted { background: #edf1ee; color: var(--muted); }
.row-opening td { background: #f7f9f8; font-style: italic; color: var(--muted); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; font-size: 15px; }

/* filter */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters .field { margin: 0; min-width: 140px; }
.filters .grow { flex: 1; min-width: 180px; }

/* ringkasan rincian saldo */
.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.summary-strip div { padding: 12px 16px; border-right: 1px solid var(--line); }
.summary-strip div:last-child { border-right: 0; }
.summary-strip span { display: block; font-size: 12.5px; color: var(--muted); }
.summary-strip b { font-size: 17px; }

/* galeri bukti */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.receipt { border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; overflow: hidden; display: flex; flex-direction: column; }
.receipt .thumb { aspect-ratio: 4/3; background: #eef2ef; display: grid; place-items: center; overflow: hidden; border: 0; padding: 0; cursor: pointer; width: 100%; }
.receipt .thumb img { width: 100%; height: 100%; object-fit: cover; }
.receipt .thumb .doc { font-weight: 800; color: var(--keluar); font-size: 22px; border: 2px solid currentColor; border-radius: 4px; padding: 8px 10px; }
.receipt .thumb.none { cursor: default; color: var(--muted); font-size: 13px; background: repeating-linear-gradient(135deg, #f4f6f5 0 10px, #eef2ef 10px 20px); }
.receipt .meta { padding: 12px 14px; display: grid; gap: 2px; flex: 1; }
.receipt .meta .k { font-weight: 600; color: var(--ink); }
.receipt .meta .d { font-size: 12.5px; color: var(--muted); }
.receipt .ops { display: flex; gap: 6px; padding: 0 14px 12px; flex-wrap: wrap; }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.tabs button { border: 0; background: transparent; padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button + button { border-left: 1px solid var(--line); }
.tabs button.on { background: var(--ink); color: #fff; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20,50,58,.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 480px; max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: 0 20px 50px rgba(20,50,58,.3); animation: pop .18s ease-out; }
.modal.wide { max-width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal .preview-img { width: 100%; border-radius: var(--radius-sm); display: block; }
.modal iframe { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.x { border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* toast */
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 60; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.2); animation: pop .2s ease-out; }
.toast.err { background: var(--keluar); }

.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- responsif ---------- */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2-even { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(20,50,58,.4); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .topbar { gap: 8px; }
  .topbar .who { display: none; }
  .topbar > div:nth-child(2) { min-width: 0; flex: 1; }
  .topbar h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .spacer { display: none; }
  .topbar .btn-sm { padding: 5px 8px; font-size: 12.5px; }
  .topbar .crumb { display: none; }
  .content { padding: 18px 16px 40px; }
  .ledger-total { grid-template-columns: 1fr; }
  .ledger-total .big { border-right: 0; border-bottom: 1px solid var(--line); }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-strip div:nth-child(2) { border-right: 0; }
  .summary-strip div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .row2 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .tiles { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- cetak ---------- */
@media print {
  .sidebar, .topbar, .no-print, .filters, td.act, th.act { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .panel { border: 0; }
  body { background: #fff; font-size: 12px; }
  .print-title { display: block !important; margin-bottom: 12px; }
}
.print-title { display: none; }

/* ---------- pengaturan ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-nav { display: grid; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 8px; position: sticky; top: 84px; }
.settings-nav button { text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; color: var(--text); }
.settings-nav button small { display: block; color: var(--muted); font-size: 12px; }
.settings-nav button:hover { background: #eef2ef; }
.settings-nav button.on { background: var(--ink); color: #fff; }
.settings-nav button.on small { color: #bcd0cb; }
.form-narrow { max-width: 560px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 4px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; max-width: 64ch; }
.kv { display: grid; grid-template-columns: 180px 1fr; border-top: 1px solid var(--line); }
.kv div { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.action-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.action-row:last-child { border-bottom: 0; }
.action-row h3 { font-size: 15px; margin-bottom: 2px; }
.action-row p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 56ch; }
.danger-zone { border-color: #e7b9c1; }
.danger-zone .panel-head { background: var(--keluar-bg); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.danger-zone .panel-head h2 { color: #7d1426; }
.kop { display: none; }
@media (max-width: 860px) {
  .settings { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .settings-nav button small { display: none; }
  .kv { grid-template-columns: 1fr; }
  .kv div:nth-child(odd) { border-bottom: 0; padding-bottom: 0; }
}
@media print {
  .kop { display: block; text-align: center; border-bottom: 3px double #000; padding-bottom: 8px; margin-bottom: 14px; }
  .kop h2 { font-size: 18px; color: #000; }
  .kop div { font-size: 12px; }
  .ttd { display: grid !important; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 36px; text-align: center; font-size: 12px; page-break-inside: avoid; }
  .ttd .nm { margin-top: 64px; font-weight: 700; text-decoration: underline; }
  .print-title { text-align: center; }
}
.ttd { display: none; }
