* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --blue: #3b82f6;
  --green: #10b981;
  --green-dark: #059669;
  --red: #ef4444;
  --pink: #ec4899;
  --yellow: #f59e0b;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --bg: #ffffff;
  --bg-card: #f9fafb;
  --radius: 12px;
  --radius-lg: 16px;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(60px + env(safe-area-inset-bottom));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  background: var(--bg);
}
.header h1 { font-size: 20px; font-weight: 700; }

.header-actions { display: flex; align-items: center; gap: 8px; }

#userInfo {
  display: none; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500;
  max-width: 120px; overflow: hidden;
}
#userPic { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; }
#userName { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#logoutBtn {
  display: none;
  padding: 6px 12px; font-size: 12px; font-weight: 500;
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  min-height: 36px; white-space: nowrap;
}

.dark-toggle {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  background: #f0f2f5; border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; flex-shrink: 0;
}

.month-picker {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.picker-row {
  display: flex; gap: 8px;
}
.picker-row select {
  flex: 1; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 15px; font-weight: 600; font-family: inherit;
  background: var(--bg-card); color: var(--text);
  outline: none; -webkit-appearance: none;
}
#createYearBtn {
  margin-top: 8px; text-align: center;
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 6px 0 env(safe-area-inset-bottom);
  z-index: 100;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
  color: var(--text-secondary);
}
.nav-item.active { color: var(--blue); }
.nav-icon { font-size: 20px; line-height: 1; margin-bottom: 2px; }
.nav-label { font-size: 9px; font-weight: 600; }

.page-container { min-height: calc(100vh - 160px); }
.page { width: 100%; }

.hero {
  background: linear-gradient(135deg, var(--blue), #1d4ed8);
  color: white; text-align: center;
  padding: 32px 16px 28px;
}
.hero-amount { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; word-break: break-all; }
.hero-label { font-size: 13px; opacity: 0.8; font-weight: 500; }

section { padding: 16px; border-bottom: 1px solid var(--border); }
section:last-child { border-bottom: none; }
section h3 {
  font-size: 16px; font-weight: 600; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}

.bank-cards { display: flex; flex-direction: column; gap: 10px; }

.bank-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.bank-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.bank-name { font-size: 16px; font-weight: 700; }
.bank-count { font-size: 11px; color: var(--text-secondary); }
.bank-saldo { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.bank-detail { display: flex; gap: 16px; font-size: 12px; }

.green { color: var(--green); }
.red { color: var(--red); }

#chartBanks {
  display: block; width: 100% !important;
  max-height: 200px;
  margin: 0 auto;
}

.anggaran-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.anggaran-table th, .anggaran-table td {
  padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left;
}
.anggaran-table th { font-weight: 600; background: var(--bg-card); font-size: 12px; }
.anggaran-table td.right { text-align: right; }
.anggaran-table th:last-child, .anggaran-table td:last-child { text-align: right; }
.anggaran-table .total-row { background: var(--bg-card); font-weight: 700; }
.surplus { color: var(--green); }
.defisit { color: var(--red); }

.bank-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px; margin-bottom: 16px;
}
.bank-tab {
  padding: 10px 0; text-align: center;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--bg-card); color: var(--text-secondary);
  transition: all 0.2s;
}
.bank-tab.active {
  background: var(--blue); color: white; border-color: var(--blue);
}

.form-group { margin-bottom: 12px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  margin-bottom: 4px; color: var(--text-secondary);
}
.form-note {
  font-size: 12px; color: var(--text-secondary);
  font-style: italic; margin-top: 8px;
}
.form-row { display: flex; gap: 10px; }
.form-group.half { flex: 1; }

input, select {
  width: 100%; padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px; font-family: inherit;
  background: var(--bg-card); color: var(--text);
  outline: none; -webkit-appearance: none;
  transition: border-color 0.2s, background 0.2s;
}
input:focus, select:focus {
  border-color: var(--blue); background: var(--bg);
}

.btn {
  width: 100%; padding: 14px;
  border: none; border-radius: var(--radius);
  font-size: 17px; font-weight: 600; font-family: inherit;
  background: var(--blue); color: white;
  cursor: pointer; transition: background 0.2s;
  min-height: 50px; margin-top: 8px;
}
.btn:active { background: #2563eb; }

.btn-cancel {
  width: 100%; padding: 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 17px; font-weight: 600; font-family: inherit;
  background: transparent; color: var(--text-secondary);
  cursor: pointer; min-height: 50px; margin-top: 8px;
}

.filter-bar {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 12px;
}
.filter-bar select, .filter-bar input {
  padding: 10px 12px; font-size: 15px;
  border-radius: 10px; min-height: 44px;
}

.transaction-item {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.transaction-item:last-child { border-bottom: none; }

.tx-info { flex: 1; min-width: 0; }
.tx-info b { font-size: 14px; font-weight: 600; line-height: 1.3; display: block; word-break: break-word; }
.tx-info small { font-size: 11px; color: var(--text-secondary); margin-top: 2px; display: block; }
.angkat-badge { font-size: 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; display: inline-block; margin-top: 3px; }

.tx-amounts { text-align: right; flex-shrink: 0; }
.tx-amounts span { display: block; font-size: 13px; font-weight: 600; }
.tx-amounts small { display: block; font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.tx-actions { display: flex; gap: 4px; flex-shrink: 0; }

.tx-delete {
  padding: 6px 10px; font-size: 11px; font-weight: 500;
  background: #fef2f2; color: var(--red);
  border: none; border-radius: 8px; cursor: pointer;
  min-height: 34px;
}

.tx-edit {
  padding: 6px 10px; font-size: 11px; font-weight: 500;
  background: #eff6ff; color: #2563eb;
  border: none; border-radius: 8px; cursor: pointer;
  min-height: 34px;
}

.empty-state {
  text-align: center; color: var(--text-secondary);
  padding: 40px 0; font-size: 14px;
}

.export-buttons {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.btn-export {
  padding: 12px;
  border: 1.5px solid var(--blue); border-radius: var(--radius);
  font-size: 13px; font-weight: 600; font-family: inherit;
  background: transparent; color: var(--blue);
  cursor: pointer;
  min-height: 44px;
}
.btn-export:active { background: #eff6ff; }

.laporan-cards {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.laporan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.laporan-card h4 { font-size: 14px; margin-bottom: 6px; }
.laporan-card p { font-size: 12px; margin-bottom: 2px; }
.laporan-card .small { font-size: 11px; color: var(--text-secondary); }

#logList { font-size: 13px; }
.log-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}
.log-item:last-child { border-bottom: none; }
.log-item .log-time { font-size: 11px; color: var(--text-secondary); }
.log-item .log-user { font-weight: 600; font-size: 13px; }
.log-item .log-aksi {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
}
.log-aksi.Tambah { background: #d1fae5; color: #065f46; }
.log-aksi.Edit { background: #dbeafe; color: #1e40af; }
.log-aksi.Hapus { background: #fee2e2; color: #991b1b; }
.log-item .log-detail { color: var(--text-secondary); font-size: 12px; margin-top: 2px; word-break: break-word; }

.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; padding: 20px;
}
.modal-card {
  background: var(--bg); border-radius: var(--radius-lg);
  width: 100%; max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  overflow: hidden;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; margin: 0; }
.modal-close {
  width: 32px; height: 32px; border: none; background: none;
  font-size: 24px; cursor: pointer; color: var(--text-secondary);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-card); }
.modal-body { padding: 16px; }
.modal-footer {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border); justify-content: flex-end;
}
.modal-footer .btn { width: auto; padding: 10px 20px; min-height: auto; margin-top: 0; }
.modal-footer .btn-cancel { width: auto; padding: 10px 20px; min-height: auto; margin-top: 0; }

.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.section-header h3 { margin: 0; }
.btn-add {
  padding: 8px 14px; font-size: 13px; font-weight: 600;
  background: var(--blue); color: white;
  border: none; border-radius: 8px; cursor: pointer;
}

#loadingOverlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 99999;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.menu-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.menu-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}
.menu-card:active { background: var(--border); }
.menu-icon { font-size: 28px; }
.menu-title { font-size: 16px; font-weight: 600; }
.menu-desc { font-size: 12px; color: var(--text-secondary); }

#loginOverlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 9999;
  background: linear-gradient(135deg, var(--blue), #1d4ed8);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.login-card {
  background: #ffffff; border-radius: 20px;
  padding: 36px 28px; text-align: center;
  max-width: 340px; width: 100%;
}
.login-icon { font-size: 48px; margin-bottom: 12px; }
.login-card h1 { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.login-sub { color: var(--text-secondary); font-size: 14px; margin-bottom: 28px; }
.login-hint { color: var(--text-secondary); font-size: 12px; margin-top: 16px; }

.google-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 14px;
  font-size: 16px; font-weight: 600; font-family: inherit;
  background: #fff; color: #333;
  border: 1.5px solid #dadce0; border-radius: var(--radius);
  cursor: pointer; min-height: 50px;
}

body.desktop {
  background: #e8eaed;
  padding: 24px;
}
body.desktop .header { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-width: 480px; margin: 0 auto; }
body.desktop .month-picker { max-width: 480px; margin: 0 auto; }
body.desktop .page-container {
  max-width: 480px; margin: 0 auto;
  background: var(--bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  overflow: hidden;
}
body.desktop .bottom-nav { max-width: 480px; margin: 0 auto; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
body.desktop .hero { padding: 40px 20px 32px; }
body.desktop .hero-amount { font-size: 38px; }
body.desktop section { padding: 20px; }
body.desktop .filter-bar { grid-template-columns: 1fr 1fr auto; }
body.desktop #loginOverlay { background: rgba(0,0,0,0.4); }
body.desktop .login-card { box-shadow: 0 8px 32px rgba(0,0,0,0.12); }
body.desktop .laporan-cards { grid-template-columns: 1fr 1fr; }

.dark,
.dark #loginOverlay { --text: #f1f5f9; --text-secondary: #94a3b8; --border: #334155; --bg: #0f172a; --bg-card: #1e293b; }
body.dark { background: #0a0f1c; }
body.desktop.dark { background: #0a0f1c; }
.dark .header { background: #0f172a; }
.dark .month-picker { background: #0f172a; }
.dark .bottom-nav { background: #0f172a; border-color: #334155; }
.dark .page-container { background: #0f172a; }
.dark .hero { background: linear-gradient(135deg, #1d4ed8, #1e3a8a); }
.dark .dark-toggle { background: #1e293b; border-color: #334155; }
.dark input, .dark select { background: #1e293b; color: #f1f5f9; }
.dark input:focus { background: #0f172a; border-color: var(--blue); }
.dark .login-card { background: #1e293b; }
.dark .login-card h1 { color: #f1f5f9; }
.dark .google-btn { background: #1e293b; color: #f1f5f9; border-color: #334155; }
.dark .bank-card { background: #1e293b; border-color: #334155; }
.dark .bank-tab { background: #1e293b; border-color: #334155; }
.dark .tx-delete { background: #451a1a; color: #fca5a5; }
.dark .tx-edit { background: #1e3a5f; color: #93c5fd; }
.dark .log-aksi.Tambah { background: #064e3b; color: #6ee7b7; }
.dark .log-aksi.Edit { background: #1e3a5f; color: #93c5fd; }
.dark .log-aksi.Hapus { background: #7f1d1d; color: #fca5a5; }
.dark .laporan-card { background: #1e293b; border-color: #334155; }
.dark .anggaran-table th { background: #1e293b; }
.dark .anggaran-table .total-row { background: #1e293b; }
.dark .btn-export { border-color: #60a5fa; color: #60a5fa; }
.dark .btn-export:active { background: #1e3a5f; }
.dark .menu-card { background: #1e293b; border-color: #334155; }
.dark .menu-card:active { background: #334155; }
