* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --primary: #4CAF50;
  --income: #2ecc71;
  --expense: #e74c3c;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #2c3e50;
  --muted: #95a5a6;
  --border: #e1e8ed;
  --nav-bg: #ffffff;
  --sidebar-width: 240px;
}

body.dark {
  --bg: #121212;
  --card: #1e1e1e;
  --text: #ecf0f1;
  --muted: #7f8c8d;
  --border: #2c2c2c;
  --nav-bg: #1e1e1e;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 80px;
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
}

.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--primary); color: white;
  padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.app-header h1 { font-size: 18px; font-weight: 600; }
.header-actions { display: flex; gap: 6px; align-items: center; }
.user-chip { font-size: 11px; background: rgba(255,255,255,0.2); padding: 5px 10px; border-radius: 20px; }
.theme-btn { background: rgba(255,255,255,0.2); border: none; color: white; font-size: 16px; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }
.theme-btn:hover { background: rgba(255,255,255,0.3); }

main { padding: 16px; max-width: 600px; margin: 0 auto; }

.page { display: none !important; }
.page.active { display: block !important; animation: fadeIn 0.3s; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.edit-tab-content { display: none !important; }
.edit-tab-content.active { display: block !important; }

.summary-cards { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.card { padding: 16px; border-radius: 14px; color: white; box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.card-label { display: block; font-size: 13px; opacity: 0.9; margin-bottom: 6px; }
.card-value { display: block; font-size: 20px; font-weight: 700; }
.income-card { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.expense-card { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.balance-card { background: linear-gradient(135deg, #3498db, #2980b9); grid-column: span 2; }
.section-title { margin: 20px 0 12px; font-size: 16px; }

.accounts-total-card {
  display: flex; align-items: center;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white; padding: 18px 22px; border-radius: 16px;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.35);
  transition: transform 0.2s;
}
.accounts-total-card:hover { transform: translateY(-2px); }
.atc-icon {
  font-size: 40px; margin-right: 16px;
  width: 60px; height: 60px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.15); border-radius: 14px;
}
.atc-info { flex: 1; }
.atc-label { display: block; font-size: 13px; opacity: 0.9; margin-bottom: 4px; font-weight: 500; }
.atc-value { display: block; font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }

.meters-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.meter-card { background: var(--card); border-radius: 16px; padding: 20px 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.06); text-align: center; transition: transform 0.2s; }
.meter-card:hover { transform: translateY(-3px); }
.meter-circle { position: relative; width: 100%; max-width: 120px; margin: 0 auto; aspect-ratio: 1; }
.meter-circle svg { width: 100%; height: 100%; display: block; transform: rotate(-90deg); }
.meter-bg { fill: none !important; stroke: var(--border); stroke-width: 10; opacity: 0.5; }
.meter-fill { fill: none !important; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1s ease-in-out; }
.income-fill { stroke: #2ecc71 !important; }
.expense-fill { stroke: #e74c3c !important; }
.balance-fill { stroke: #3498db !important; }
.meter-content { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.meter-percent { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1; }
.meter-label { font-size: 11px; color: var(--muted); margin-top: 3px; font-weight: 500; }
.meter-amount { margin-top: 10px; font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.transaction-list { display: flex; flex-direction: column; gap: 10px; }
.tx-item { background: var(--card); border-radius: 12px; padding: 14px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 6px rgba(0,0,0,0.05); border-left: 4px solid var(--income); cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; }
.tx-item:hover { transform: translateX(3px); box-shadow: 0 4px 14px rgba(0,0,0,0.1); }
.tx-item.expense { border-left-color: var(--expense); }
.tx-item.transfer { border-left-color: #f39c12; }
.tx-info { flex: 1; min-width: 0; }
.tx-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.tx-amount { font-weight: 700; font-size: 15px; white-space: nowrap; margin-left: 8px; }
.tx-amount.income { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
.tx-amount.transfer { color: #f39c12; }
.tx-actions { display: flex; gap: 4px; margin-left: 6px; }
.icon-btn { background: none; border: none; font-size: 15px; cursor: pointer; padding: 4px; }

.tx-receipt-badge {
  display: inline-block;
  background: rgba(76, 175, 80, 0.15);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 6px;
}

.tx-transfer-arrow {
  display: inline-block;
  background: rgba(243, 156, 18, 0.15);
  color: #f39c12;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 6px;
}

.form label { display: block; margin: 14px 0 6px; font-size: 14px; font-weight: 500; }
.form input, .form select, .form textarea { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); font-size: 15px; font-family: inherit; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--primary); }
.type-toggle { display: flex; background: var(--card); border-radius: 10px; padding: 4px; margin-bottom: 10px; }
.type-btn { flex: 1; padding: 12px; border: none; background: none; color: var(--text); font-size: 15px; font-weight: 600; border-radius: 8px; cursor: pointer; }
.type-btn.active[data-type="income"] { background: var(--income); color: white; }
.type-btn.active[data-type="expense"] { background: var(--expense); color: white; }
.type-btn.active[data-type="transfer"] { background: #f39c12; color: white; }
.type-toggle-3 .type-btn { font-size: 13px; padding: 10px 6px; }
.submit-btn { width: 100%; margin-top: 20px; padding: 14px; background: var(--primary); color: white; border: none; border-radius: 10px; font-size: 16px; font-weight: 600; cursor: pointer; }
.submit-btn:active { transform: scale(0.98); }
.submit-btn:hover { background: #43a047; }

.filter-bar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input { flex: 1; padding: 10px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--card); color: var(--text); min-width: 100px; font-size: 14px; }
.clear-btn { padding: 10px 14px; background: var(--card); border: 1.5px solid var(--border); border-radius: 8px; color: var(--text); cursor: pointer; font-size: 14px; }

.report-container { background: var(--card); border-radius: 12px; padding: 14px; margin-bottom: 12px; box-shadow: 0 2px 6px rgba(0,0,0,0.05); }
.report-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; align-items: center; }
.report-row:last-child { border-bottom: none; }

.chart-container { position: relative; background: var(--card); border-radius: 12px; padding: 18px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); height: 300px; display: flex; align-items: center; justify-content: center; }
.chart-container canvas { max-height: 100%; max-width: 100%; }

.settings-item { display: flex; justify-content: space-between; align-items: center; background: var(--card); padding: 14px; border-radius: 10px; margin-bottom: 10px; }
.small-btn { padding: 8px 14px; background: var(--primary); color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 13px; }
.small-btn.danger { background: var(--expense); }
.info-text { font-size: 12px; color: var(--muted); text-align: center; margin-top: 20px; }
.empty-msg { text-align: center; padding: 30px; color: var(--muted); font-size: 14px; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: #f0f4f8; }
.login-box { background: white; padding: 32px 24px; border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,0.1); max-width: 380px; width: 100%; }
.login-box h1 { color: #4CAF50; text-align: center; margin-bottom: 4px; font-size: 26px; }
.login-box p { text-align: center; color: #7f8c8d; margin-bottom: 20px; font-size: 14px; }
.login-box input { width: 100%; padding: 12px 14px; margin-bottom: 12px; border: 1.5px solid #dfe6ec; border-radius: 10px; font-size: 15px; box-sizing: border-box; }
.login-box input:focus { outline: none; border-color: #4CAF50; }
.login-box button { width: 100%; padding: 13px; background: #4CAF50; color: white; border: none; border-radius: 10px; font-size: 16px; font-weight: 600; cursor: pointer; }
.login-box small { display: block; text-align: center; margin-top: 14px; color: #95a5a6; font-size: 12px; }
.login-error { background: #fdecea; color: #a3241c; padding: 10px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; text-align: center; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; top: auto;
  width: 100%; max-width: 100vw;
  background: var(--nav-bg);
  display: flex; flex-direction: row;
  justify-content: space-around; align-items: center;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  border-top: 1px solid var(--border);
  border-right: none; gap: 0;
  z-index: 9999; height: auto;
}
.bottom-nav::before { display: none !important; content: none !important; }
.nav-btn { flex: 1; background: none; border: none; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px; padding: 6px 2px; cursor: pointer; color: var(--muted); transition: color 0.2s; border-radius: 0; border-left: none; font-size: 10px; }
.nav-btn.active { color: var(--primary); }
.nav-icon { font-size: 18px; }
.nav-label { font-size: 9px; font-weight: 500; }

.receipts-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.receipt-count { background: var(--primary); color: white; padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 700; }
.receipt-info { padding: 12px 14px; background: rgba(76, 175, 80, 0.08); border-left: 4px solid var(--primary); border-radius: 8px; margin-bottom: 16px; font-size: 13px; line-height: 1.7; color: var(--text); }
.receipt-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.receipt-item { background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.06); cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; position: relative; }
.receipt-item:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,0.12); }
.receipt-item img { width: 100%; height: 140px; object-fit: cover; display: block; background: #f0f0f0; }
.receipt-item-info { padding: 8px 10px; font-size: 11px; }
.receipt-item-title { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-item-meta { color: var(--muted); margin-top: 2px; display: flex; justify-content: space-between; }
.receipt-item-delete { position: absolute; top: 6px; right: 6px; background: rgba(231, 76, 60, 0.95); color: white; border: none; width: 28px; height: 28px; border-radius: 50%; font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; }
.receipt-item:hover .receipt-item-delete { opacity: 1; }

.receipt-upload-section { margin-top: 20px; padding: 16px; background: var(--card); border-radius: 12px; border: 1.5px dashed var(--border); }
.receipt-upload-section label { margin-top: 0 !important; font-size: 14px !important; color: var(--primary); }
.capture-btn { width: 100%; padding: 16px; background: linear-gradient(135deg, #4CAF50, #2ecc71); color: white; border: none; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; transition: transform 0.2s; }
.capture-btn:active { transform: scale(0.97); }
.capture-icon { font-size: 22px; }
.receipt-preview { margin-top: 12px; position: relative; display: none; }
.receipt-preview.has-image { display: block; }
.receipt-preview img { width: 100%; max-height: 300px; object-fit: contain; border-radius: 10px; background: #f0f0f0; }
.receipt-preview .remove-btn { position: absolute; top: 8px; right: 8px; background: rgba(231, 76, 60, 0.95); color: white; border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.file-size-info { position: absolute; bottom: 8px; left: 8px; background: rgba(0, 0, 0, 0.75); color: white; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; backdrop-filter: blur(8px); }

.receipt-mobile-only { display: none !important; }
.receipt-desktop-only { display: none !important; }

@media (max-width: 768px) {
  .receipt-mobile-only { display: block !important; }
  .receipt-desktop-only { display: none !important; }
}
@media (min-width: 769px) {
  .receipt-mobile-only { display: none !important; }
  .receipt-desktop-only { display: block !important; }
}

.desktop-info { padding: 14px; background: rgba(52, 152, 219, 0.08); border-left: 4px solid #3498db; border-radius: 8px; font-size: 13px; color: var(--text); line-height: 1.6; }

.receipt-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 9999; align-items: center; justify-content: center; padding: 20px; }
.receipt-modal.active { display: flex; }
.receipt-modal img { max-width: 95%; max-height: 85vh; object-fit: contain; border-radius: 8px; box-shadow: 0 0 40px rgba(0,0,0,0.5); }
.receipt-modal-close { position: absolute; top: 16px; right: 16px; background: rgba(255,255,255,0.15); color: white; border: none; width: 44px; height: 44px; border-radius: 50%; font-size: 22px; cursor: pointer; backdrop-filter: blur(8px); }
.receipt-modal-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.15); color: white; border: none; width: 48px; height: 48px; border-radius: 50%; font-size: 28px; cursor: pointer; backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; }
.receipt-modal-nav.prev { left: 16px; }
.receipt-modal-nav.next { right: 16px; }
.receipt-modal-info { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.75); color: white; padding: 10px 20px; border-radius: 24px; font-size: 13px; backdrop-filter: blur(8px); max-width: 90%; text-align: center; }

.accounts-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.total-balance-card { background: linear-gradient(135deg, #4CAF50, #2ecc71); color: white; padding: 20px; border-radius: 16px; text-align: center; margin-bottom: 20px; box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3); }
.tb-label { display: block; font-size: 13px; opacity: 0.9; margin-bottom: 6px; }
.tb-value { display: block; font-size: 26px; font-weight: 700; }
.accounts-list { display: flex; flex-direction: column; gap: 12px; }
.account-item { display: flex; align-items: center; background: var(--card); border-radius: 14px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-left: 5px solid #4CAF50; cursor: pointer; transition: transform 0.2s; position: relative; }
.account-item:hover { transform: translateX(4px); }
.acc-icon { font-size: 32px; margin-right: 14px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: rgba(0,0,0,0.03); }
.acc-info { flex: 1; }
.acc-name { font-weight: 700; font-size: 15px; color: var(--text); }
.acc-type { font-size: 12px; color: var(--muted); margin-top: 2px; text-transform: capitalize; }
.acc-balance { font-weight: 700; font-size: 16px; color: var(--text); text-align: right; }
.acc-balance.negative { color: var(--expense); }
.acc-actions { display: flex; gap: 4px; margin-left: 10px; }
.icon-picker, .color-picker { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.icon-opt { width: 44px; height: 44px; border-radius: 10px; background: var(--card); border: 2px solid var(--border); font-size: 22px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.icon-opt.active { border-color: var(--primary); background: rgba(76, 175, 80, 0.1); }
.color-opt { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: all 0.2s; }
.color-opt.active { border-color: var(--text); transform: scale(1.1); }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 9999; display: none;
  align-items: center; justify-content: center; padding: 20px;
}
.modal[style*="display: flex"],
.modal[style*="display:flex"] {
  display: flex !important;
}
.modal-box { background: var(--card); border-radius: 16px; padding: 24px; max-width: 420px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-box h3 { margin: 0 0 16px; font-size: 18px; }
.modal-box label { display: block; margin: 14px 0 6px; font-size: 14px; font-weight: 500; }
.modal-box input, .modal-box select { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); font-size: 15px; }

.edit-tabs { display: flex; background: var(--card); border-radius: 12px; padding: 4px; margin-bottom: 16px; box-shadow: 0 2px 6px rgba(0,0,0,0.05); }
.edit-tab { flex: 1; padding: 12px 14px; background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 600; border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.edit-tab.active { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3); }
.edit-tab:hover:not(.active) { background: rgba(76, 175, 80, 0.08); color: var(--primary); }
.edit-info { background: rgba(52, 152, 219, 0.08); border-left: 4px solid #3498db; padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; color: var(--text); line-height: 1.6; }
.edit-filter-bar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.edit-filter-bar input, .edit-filter-bar select { flex: 1; padding: 10px 12px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--card); color: var(--text); font-size: 14px; min-width: 120px; }
.edit-filter-bar input:focus, .edit-filter-bar select:focus { outline: none; border-color: var(--primary); }
.btn-edit-lg { background: rgba(76, 175, 80, 0.15) !important; color: var(--primary) !important; border-radius: 10px !important; padding: 8px 12px !important; font-size: 15px !important; font-weight: 700 !important; }

.empty-msg.loading::before {
  content: '';
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pwa-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 10000; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(4px); }
.pwa-modal.active { display: flex; }
.pwa-modal-box { background: var(--card); border-radius: 20px; padding: 32px 24px; max-width: 380px; width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: slideUp 0.3s ease-out; }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
.pwa-icon { font-size: 64px; margin-bottom: 16px; animation: bounce 1.5s infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.pwa-modal-box h2 { font-size: 22px; color: var(--text); margin-bottom: 8px; font-weight: 700; }
.pwa-modal-box p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.pwa-features { list-style: none; text-align: left; background: rgba(76, 175, 80, 0.08); border-radius: 12px; padding: 14px 18px; margin-bottom: 24px; }
.pwa-features li { font-size: 13px; color: var(--text); padding: 6px 0; line-height: 1.5; }
.pwa-buttons { display: flex; flex-direction: column; gap: 10px; }
.pwa-btn-install { background: linear-gradient(135deg, #4CAF50, #2ecc71); color: white; border: none; padding: 14px; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4); }
.pwa-btn-cancel { background: transparent; color: var(--muted); border: none; padding: 10px; font-size: 14px; cursor: pointer; border-radius: 8px; }
.ios-hint { background: rgba(52, 152, 219, 0.1); border-left: 4px solid #3498db; padding: 12px; border-radius: 8px; font-size: 13px; color: var(--text); text-align: left; margin-bottom: 16px; line-height: 1.6; }

/* ============================================================
   TRANSACTION DETAIL MODAL
   ============================================================ */
.tx-detail-box {
  max-width: 500px !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.tx-detail-header {
  background: linear-gradient(135deg, #2c3e50, #1a252f);
  color: white;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
}

.tx-detail-icon {
  font-size: 36px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  flex-shrink: 0;
}

.tx-detail-header h3 {
  margin: 0 0 6px !important;
  font-size: 17px !important;
  font-weight: 600;
  color: white !important;
}

.tx-detail-type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tx-detail-type-badge.income { background: #27ae60; color: white; }
.tx-detail-type-badge.expense { background: #e74c3c; color: white; }
.tx-detail-type-badge.transfer { background: #f39c12; color: white; }

.txd-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.txd-close-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

.tx-detail-amount {
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  padding: 24px 20px 12px;
  color: #2c3e50;
}

.tx-detail-amount.income { color: #27ae60; }
.tx-detail-amount.expense { color: #e74c3c; }
.tx-detail-amount.transfer { color: #f39c12; }

.tx-detail-body {
  padding: 8px 24px 20px;
}

.txd-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid #e1e8ed;
  font-size: 14px;
}

.txd-row:last-child {
  border-bottom: none;
}

.txd-label {
  color: #95a5a6;
  font-weight: 500;
  flex-shrink: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.txd-value {
  color: #2c3e50;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.txd-value.txd-id {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  background: #f0f2f5;
  padding: 2px 8px;
  border-radius: 6px;
  color: #3498db;
}

.txd-receipts-section {
  background: #f8f9fa;
  padding: 16px 24px;
  border-top: 1px solid #e1e8ed;
}

.txd-receipts-section h4 {
  margin: 0 0 12px !important;
  font-size: 14px !important;
  color: #2c3e50;
  padding: 0 !important;
  border: none !important;
}

.txd-receipts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.txd-receipt-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: transform 0.2s;
}

.txd-receipt-thumb:hover {
  transform: scale(1.05);
}

.txd-actions {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  background: #f8f9fa;
  border-top: 1px solid #e1e8ed;
}

.txd-actions .small-btn {
  flex: 1;
  padding: 10px 14px;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.txd-actions .small-btn:hover {
  transform: translateY(-1px);
}

/* ============================================================
   BANK STATEMENT (PC ONLY)
   ============================================================ */
.statement-only { display: none !important; }
.statement-page { display: none; }

@media (min-width: 1025px) {
  .statement-only { display: flex !important; }
  .statement-page.active { display: block !important; }
}

.statement-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #1e3a8a, #1e40af);
  color: white;
  padding: 24px 28px;
  border-radius: 14px;
  margin-bottom: 20px;
  box-shadow: 0 6px 20px rgba(30, 58, 138, 0.25);
}

.statement-brand { display: flex; align-items: center; gap: 18px; }
.statement-logo { font-size: 52px; width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.15); border-radius: 16px; }
.statement-brand h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; }
.statement-subtitle { font-size: 13px; opacity: 0.85; }
.statement-actions { display: flex; gap: 10px; }
.statement-actions .small-btn { padding: 10px 18px; background: rgba(255, 255, 255, 0.2); color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; }
.statement-actions .small-btn:hover { background: rgba(255, 255, 255, 0.3); }

.statement-filters {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 14px;
  background: var(--card);
  padding: 18px 22px;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  align-items: end;
}
.sf-group { display: flex; flex-direction: column; }
.sf-group label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.sf-group select, .sf-group input { padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); font-size: 14px; font-family: inherit; }
.sf-group select:focus, .sf-group input:focus { outline: none; border-color: var(--primary); }
.sf-buttons { display: flex; flex-direction: row; gap: 8px; }
.sf-buttons .small-btn { padding: 10px 16px; background: var(--primary); color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap; }
.sf-buttons .small-btn:hover { background: #43a047; }

.statement-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stmt-summary-card { background: var(--card); border-radius: 12px; padding: 16px 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-left: 4px solid var(--primary); }
.stmt-summary-card.income { border-left-color: #2ecc71; }
.stmt-summary-card.expense { border-left-color: #e74c3c; }
.stmt-summary-card.balance { border-left-color: #3498db; }
.stmt-summary-card.count { border-left-color: #9b59b6; }
.stmt-summary-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-bottom: 6px; }
.stmt-summary-value { font-size: 22px; font-weight: 700; color: var(--text); }
.stmt-summary-value.income { color: #2ecc71; }
.stmt-summary-value.expense { color: #e74c3c; }
.stmt-summary-value.balance { color: #3498db; }

.statement-table-wrapper { background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.06); margin-bottom: 20px; }
.statement-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.statement-table thead { background: #1e3a8a; color: white; }
.statement-table thead th { padding: 14px 12px; text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.statement-table thead th.text-right { text-align: right; }
.statement-table tbody td { padding: 12px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.statement-table tbody td.text-right { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.statement-table tbody tr:hover { background: rgba(76, 175, 80, 0.04); }
.statement-table tbody tr:last-child td { border-bottom: none; }
.statement-table .text-center { text-align: center; }
.statement-table .text-muted { color: var(--muted); font-style: italic; }

.stmt-dr { color: #e74c3c; font-weight: 600; }
.stmt-cr { color: #27ae60; font-weight: 600; }
.stmt-balance { font-weight: 700; color: #1e40af; }
.stmt-date { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--muted); }
.stmt-desc { font-weight: 500; }
.stmt-desc small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.stmt-category-tag { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; background: #e0e7ff; color: #3730a3; }
.stmt-account-tag { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; background: rgba(76, 175, 80, 0.12); color: #2e7d32; }

.statement-footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; background: var(--card); border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.statement-footer p { margin: 4px 0; }
.statement-note { font-style: italic; opacity: 0.75; }

@media print {
  body { background: white !important; padding: 0 !important; }
  .app-header, .bottom-nav, .statement-actions, .statement-filters, .statement-footer { display: none !important; }
  main { padding: 0 !important; max-width: 100% !important; margin: 0 !important; }
  .statement-header { background: white !important; color: #1e3a8a !important; box-shadow: none !important; border: 2px solid #1e3a8a !important; padding: 20px !important; }
  .statement-logo { background: #1e3a8a !important; color: white !important; }
  .stmt-summary-card { border: 1px solid #ccc !important; box-shadow: none !important; }
  .statement-table { font-size: 11px !important; }
  .statement-table thead { background: #1e3a8a !important; color: white !important; }
}

/* ============================================================
   MOBILE FIX
   ============================================================ */
@media (max-width: 1024px) {
  body { padding-bottom: 80px !important; padding-left: 0 !important; margin-left: 0 !important; }
  .bottom-nav {
    position: fixed !important; bottom: 0 !important; top: auto !important;
    left: 0 !important; right: 0 !important;
    width: 100% !important; max-width: 100vw !important;
    height: auto !important; flex-direction: row !important;
    justify-content: space-around !important; align-items: center !important;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom)) !important;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08) !important;
    border-right: none !important; border-top: 1px solid var(--border) !important;
    gap: 0 !important; z-index: 9999 !important;
  }
  .bottom-nav::before { display: none !important; content: none !important; }
  .nav-btn { flex: 1 !important; flex-direction: column !important; justify-content: center !important; align-items: center !important; gap: 2px !important; padding: 6px 2px !important; border-radius: 0 !important; border-left: none !important; font-size: 10px !important; }
  .nav-icon { font-size: 18px !important; }
  .nav-label { font-size: 9px !important; font-weight: 500 !important; }
  main { max-width: 100% !important; padding: 16px !important; margin: 0 auto !important; }
  .app-header { padding: 12px 14px !important; margin-left: 0 !important; }
  .app-header h1 { font-size: 16px !important; }
  .user-chip { font-size: 10px !important; padding: 4px 8px !important; }
  .theme-btn { width: 32px !important; height: 32px !important; font-size: 14px !important; }
  .page { display: none !important; }
  .page.active { display: block !important; }
  .edit-tab-content { display: none !important; }
  .edit-tab-content.active { display: block !important; }
}

@media (max-width: 400px) {
  .nav-label { font-size: 8px !important; }
  .nav-icon { font-size: 16px !important; }
  .nav-btn { padding: 4px 1px !important; }
  .meters-grid { gap: 8px !important; }
  .meter-card { padding: 14px 6px !important; }
  .meter-circle { max-width: 90px !important; }
  .meter-percent { font-size: 15px !important; }
  .meter-label { font-size: 9px !important; }
  .meter-amount { font-size: 10px !important; margin-top: 6px !important; }
  .atc-icon { font-size: 28px !important; width: 40px !important; height: 40px !important; margin-right: 10px !important; }
  .atc-value { font-size: 18px !important; }
  .tb-value { font-size: 20px !important; }
  .acc-icon { font-size: 24px !important; width: 36px !important; height: 36px !important; margin-right: 10px !important; }
  .receipt-gallery { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .receipt-item img { height: 110px !important; }
  .edit-tab { font-size: 12px !important; padding: 10px 8px !important; }
}

@media (min-width: 1025px) {
  body { padding-bottom: 0 !important; padding-left: var(--sidebar-width); }
  .app-header { padding: 18px 32px; margin-left: 0; }
  .app-header h1 { font-size: 22px; }
  .user-chip { font-size: 13px; padding: 6px 14px; }
  main { max-width: 1200px; padding: 28px 36px; margin: 0 auto; }
  .section-title { font-size: 20px; margin: 28px 0 18px; }

  .bottom-nav {
    position: fixed; top: 0; left: 0; bottom: 0; right: auto;
    width: var(--sidebar-width); max-width: var(--sidebar-width);
    height: 100vh; flex-direction: column; justify-content: flex-start;
    padding: 0; gap: 0;
    box-shadow: 2px 0 12px rgba(0,0,0,0.08);
    border-right: 1px solid var(--border); border-top: none;
    background: var(--card);
  }
  .bottom-nav::before {
    content: "💰 Income & Expense";
    display: block;
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    text-align: left;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.10), rgba(46, 204, 113, 0.05));
    letter-spacing: -0.3px;
  }
  .nav-btn {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start;
    align-items: center; gap: 14px; padding: 14px 22px; border-radius: 0;
    font-size: 15px; font-weight: 500;
    border-left: 4px solid transparent;
    color: var(--text); width: 100%;
  }
  .nav-btn:hover { background: rgba(76, 175, 80, 0.08); color: var(--primary); }
  .nav-btn.active { background: rgba(76, 175, 80, 0.12); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
  .nav-icon { font-size: 22px; min-width: 26px; text-align: center; }
  .nav-label { font-size: 15px; font-weight: 500; }

  .meters-grid { gap: 24px; }
  .meter-card { padding: 32px 24px; }
  .meter-circle { max-width: 180px; }
  .meter-percent { font-size: 32px; }
  .meter-label { font-size: 15px; }
  .meter-amount { font-size: 16px; margin-top: 16px; }
  .tx-item { padding: 20px 24px; }
  .tx-title { font-size: 16px; }
  .tx-amount { font-size: 17px; }
  .chart-container { height: 420px; padding: 28px; }
  .accounts-total-card { padding: 28px 32px; }
  .atc-icon { font-size: 52px; width: 80px; height: 80px; margin-right: 22px; }
  .atc-value { font-size: 32px; }

  .receipt-mobile-only { display: none !important; }
  .receipt-desktop-only { display: block !important; }
}

@media (min-width: 1440px) {
  :root { --sidebar-width: 260px; }
  main { max-width: 1400px; padding: 36px 52px; }
  .bottom-nav::before { font-size: 19px; padding: 26px 22px; }
}