/* ===== Buku Kas — mobile-first ===== */
:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --green-bg: #dcfce7;
  --brown: #9a5b2d;
  --brown-dark: #7c4a24;
  --brown-bg: #f6e8dc;
  --navy: #1e293b;
  --navy-light: #334155;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: calc(66px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

/* ===== Header ===== */
.app-header {
  background: var(--navy);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header h1 { font-size: 17px; font-weight: 700; }
.book-switcher {
  margin-top: 2px;
  background: rgba(255,255,255,.12);
  border: none;
  color: #e2e8f0;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

/* ===== Layout ===== */
main { max-width: 640px; margin: 0 auto; padding: 14px; }
.view { display: none; }
.view.active { display: block; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ===== Balance card ===== */
.balance-card {
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
}
.balance-label { font-size: 13px; opacity: .8; }
.balance-amount { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin: 2px 0; }
.balance-meta { font-size: 12px; opacity: .7; margin-bottom: 14px; }
.summary-row { display: flex; gap: 10px; }
.summary-item {
  flex: 1;
  background: rgba(255,255,255,.1);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.summary-icon {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; flex-shrink: 0;
}
.summary-item.income .summary-icon { background: var(--green); }
.summary-item.expense .summary-icon { background: var(--brown); }
.summary-title { font-size: 11px; opacity: .75; }
.summary-value { font-size: 14px; font-weight: 700; word-break: break-all; }

/* ===== Buttons ===== */
.action-row { display: flex; gap: 10px; margin: 14px 0; }
.btn-action {
  flex: 1; border: none; border-radius: var(--radius);
  padding: 14px; font-size: 15px; font-weight: 700; color: #fff;
  cursor: pointer; box-shadow: var(--shadow);
}
.btn-income { background: var(--green); }
.btn-income:active { background: var(--green-dark); }
.btn-expense { background: var(--brown); }
.btn-expense:active { background: var(--brown-dark); }

.btn-primary, .btn-secondary, .btn-danger {
  border: none; border-radius: 10px; padding: 11px 14px;
  font-size: 14px; font-weight: 600; cursor: pointer; flex: 1;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:disabled { opacity: .55; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.link-btn { background: none; border: none; color: var(--navy); font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px; }
.link-btn.danger { color: var(--danger); }

/* ===== Section ===== */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 8px; }
.section-head h2 { font-size: 15px; font-weight: 700; }

/* ===== Transaction list ===== */
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-group-date {
  font-size: 12px; font-weight: 700; color: var(--muted);
  margin: 10px 0 2px; text-transform: uppercase; letter-spacing: .3px;
}
.tx-item {
  background: var(--card); border-radius: var(--radius);
  padding: 11px 13px; display: flex; gap: 11px; align-items: center;
  box-shadow: var(--shadow); cursor: pointer; border-left: 4px solid transparent;
}
.tx-item.in { border-left-color: var(--green); }
.tx-item.out { border-left-color: var(--brown); }
.tx-ind {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px;
}
.tx-item.in .tx-ind { background: var(--green-bg); color: var(--green-dark); }
.tx-item.out .tx-ind { background: var(--brown-bg); color: var(--brown-dark); }
.tx-body { flex: 1; min-width: 0; }
.tx-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-note { font-size: 12px; color: var(--muted); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-right { text-align: right; flex-shrink: 0; }
.tx-amount { font-weight: 700; font-size: 14px; }
.tx-item.in .tx-amount { color: var(--green-dark); }
.tx-item.out .tx-amount { color: var(--brown-dark); }
.tx-balance { font-size: 11px; color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); padding: 34px 16px; font-size: 14px; }

/* ===== Search & filters ===== */
.search-bar input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 14px; background: #fff;
}
.filter-chips { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 20px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip.small { padding: 4px 10px; font-size: 12px; }
.filter-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.month-input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; background: #fff; }

/* ===== Cards & forms ===== */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.hint { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.field { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--navy-light); }
.field input, .field select, .field textarea {
  display: block; width: 100%; margin-top: 5px;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--navy); outline-offset: -1px;
}
.stack { display: flex; flex-direction: column; gap: 9px; }

/* ===== Report ===== */
.report-summary { margin: 12px 0; border-top: 1px solid var(--line); }
.rs-item {
  display: flex; justify-content: space-between; padding: 9px 0;
  border-bottom: 1px solid var(--line); font-size: 14px;
}
.rs-item.total { font-size: 15px; }
.text-income { color: var(--green-dark); }
.text-expense { color: var(--brown-dark); }
.range-row { display: flex; gap: 10px; margin-top: 4px; }
.range-row label { font-size: 12px; font-weight: 600; color: var(--muted); flex: 1; }
.range-row input { width: 100%; margin-top: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }

/* ===== Books / categories ===== */
.book-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.book-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff;
}
.book-item.active-book { border-color: var(--navy); background: #f0f4ff; }
.book-item .b-name { flex: 1; font-weight: 600; font-size: 14px; cursor: pointer; }
.book-item .b-meta { font-size: 11px; color: var(--muted); display: block; font-weight: 400; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 15px; padding: 5px; color: var(--muted); }
.cat-cols { display: flex; gap: 14px; }
.cat-cols > div { flex: 1; }
.cat-cols h3 { font-size: 13px; margin-bottom: 7px; }
.cat-list { display: flex; flex-direction: column; gap: 5px; }
.cat-item {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; background: var(--bg); border-radius: 8px; padding: 6px 10px;
}
.logo-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.logo-row img { width: 48px; height: 48px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.logo-row input[type=file] { font-size: 12px; font-weight: 400; }
.app-version { text-align: center; font-size: 11px; color: var(--muted); margin: 6px 0 14px; }

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
  max-width: 100%;
}
.nav-btn {
  flex: 1; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px 7px; color: var(--muted); font-size: 11px; font-weight: 600;
}
.nav-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn.active { color: var(--navy); }

/* ===== Overlays / sheets ===== */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, .5);
  display: flex; align-items: flex-end; justify-content: center;
}
.overlay.center { align-items: center; padding: 20px; }
.overlay[hidden] { display: none; }
.sheet {
  background: var(--card); width: 100%; max-width: 640px;
  border-radius: 18px 18px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 90vh; overflow-y: auto;
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(40%); } to { transform: none; } }
.sheet-handle { width: 42px; height: 4px; background: var(--line); border-radius: 2px; margin: 4px auto 12px; }
.sheet-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.dialog {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  width: 100%; max-width: 360px;
}
.dialog h3 { margin-bottom: 8px; font-size: 16px; }
.dialog p { font-size: 14px; color: var(--muted); margin-bottom: 16px; }

/* ===== Detail ===== */
.detail-head { text-align: center; padding: 6px 0 14px; border-bottom: 1px dashed var(--line); margin-bottom: 12px; }
.detail-amount { font-size: 28px; font-weight: 800; }
.detail-badge {
  display: inline-block; font-size: 12px; font-weight: 700;
  border-radius: 20px; padding: 3px 12px; margin-bottom: 6px;
}
.detail-badge.in { background: var(--green-bg); color: var(--green-dark); }
.detail-badge.out { background: var(--brown-bg); color: var(--brown-dark); }
.detail-rows { margin-bottom: 14px; }
.d-row { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; font-size: 14px; border-bottom: 1px solid var(--bg); }
.d-row span { color: var(--muted); flex-shrink: 0; }
.d-row strong { font-weight: 600; text-align: right; word-break: break-word; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.detail-actions .btn-danger { grid-column: 1 / -1; }

/* ===== Toast ===== */
/* ===== Akun ===== */
.account-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.account-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.account-row strong { word-break: break-all; }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--navy); color: #fff; font-size: 14px; font-weight: 600;
  padding: 11px 20px; border-radius: 30px; z-index: 99;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  animation: fadeIn .2s ease; max-width: 90vw; text-align: center;
}

@media (min-width: 700px) {
  body { font-size: 15px; }
  .overlay { align-items: center; }
  .sheet { border-radius: 18px; }
}
