/* ============================================
   BizReminder — Design System
   ============================================ */

:root {
  /* Colors - Nature Palette */
  --bg-primary: #F2E3BB;
  --bg-secondary: #EADDBC;
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-card-hover: rgba(255, 255, 255, 0.9);
  --bg-glass: rgba(242, 227, 187, 0.95);

  --border: #C0B87A;
  --border-hover: #427A43;

  --text-primary: #005F02;
  --text-secondary: #427A43;
  --text-tertiary: #6B7C60;

  --accent: #005F02;
  --accent-glow: rgba(0, 95, 2, 0.2);

  --success: #005F02;
  --success-bg: rgba(0, 95, 2, 0.1);
  --warning: #C0B87A;
  --warning-bg: rgba(192, 184, 122, 0.2);
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --info: #06b6d4;
  --info-bg: #cffafe;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-xs: 0.7rem;
  --font-sm: 0.8rem;
  --font-base: 0.9rem;
  --font-md: 1rem;
  --font-lg: 1.25rem;
  --font-xl: 1.75rem;
  --font-2xl: 2.25rem;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Override (Nature Palette) */
[data-theme="light"] {
  --bg-primary: #F2E3BB;
  --bg-secondary: #EADDBC;
  /* Slightly darker cream for contrast */
  --bg-card: rgba(255, 255, 255, 0.7);
  /* Glassy white on cream */
  --bg-card-hover: rgba(255, 255, 255, 0.9);
  --bg-glass: rgba(242, 227, 187, 0.95);

  --border: #C0B87A;
  --border-hover: #427A43;

  --text-primary: #005F02;
  --text-secondary: #427A43;
  --text-tertiary: #6B7C60;

  --accent: #005F02;
  --accent-glow: rgba(0, 95, 2, 0.2);

  /* Adjust status colors to harmonize if needed, or keep standard */
  --success: #005F02;
  /* Use the dark green for success too? Or keep standard green? Let's use standard but maybe darker. */
  --success-bg: rgba(0, 95, 2, 0.1);
  --warning: #C0B87A;
  /* Use the Gold for warning */
  --warning-bg: rgba(192, 184, 122, 0.2);
}

/* ============================================
   Reset & Base
   ============================================ */

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ============================================
   App Container
   ============================================ */

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-md);
  padding-bottom: var(--space-2xl);
}

/* ============================================
   Header
   ============================================ */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) 0;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
}

.logo {
  font-size: var(--font-xl);
  font-weight: 800;
  color: #000000;
  letter-spacing: -0.5px;
}

.header-subtitle {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

.btn-add {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: var(--font-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-add:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px var(--accent-glow);
}

.btn-add:active {
  transform: translateY(0);
}

/* ============================================
   Stats
   ============================================ */

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
  transition: var(--transition);
}

.stat-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.stat-label {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.stat-sub {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
}

.stat-total .stat-value {
  color: var(--accent);
}

.stat-upcoming .stat-value {
  color: var(--warning);
}

.stat-overdue .stat-value {
  color: var(--danger);
}

.stat-paid .stat-value {
  color: var(--success);
}

/* ============================================
   Filter Bar
   ============================================ */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--space-md);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-tabs-scroll {
  display: flex;
  gap: 6px;
}

.filter-tab {
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--font-xs);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.filter-tab:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.filter-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ============================================
   Reminder Cards
   ============================================ */

.reminders-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.reminder-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
  cursor: default;
  animation: fadeIn 300ms ease-out;
}

.reminder-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.reminder-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.reminder-status-dot.paid {
  background: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.reminder-status-dot.upcoming {
  background: var(--warning);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.reminder-status-dot.overdue {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
  animation: pulse 2s infinite;
}

.reminder-status-dot.due_today {
  background: var(--info);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.reminder-info {
  flex: 1;
  min-width: 0;
}

.reminder-name {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reminder-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: 2px;
}

.reminder-category {
  font-size: var(--font-xs);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 100px;
  background: rgba(99, 102, 241, 0.1);
  color: #a78bfa;
}

.reminder-due {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
}

.reminder-amount {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.reminder-amount .currency {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  font-weight: 500;
}

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

.btn-action {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-action:hover {
  background: var(--bg-card-hover);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-action.btn-confirm {
  color: var(--success);
}

.btn-action.btn-confirm:hover {
  background: var(--success-bg);
  border-color: rgba(16, 185, 129, 0.2);
}

.btn-action.btn-confirm.confirmed {
  color: var(--text-tertiary);
  opacity: 0.5;
}

.btn-action.btn-undo {
  color: var(--warning);
}

.btn-action.btn-undo:hover {
  background: var(--warning-bg);
  border-color: rgba(245, 158, 11, 0.2);
}

.btn-action.btn-delete:hover {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(239, 68, 68, 0.2);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  color: var(--text-tertiary);
}

.empty-state p {
  font-size: var(--font-md);
  font-weight: 500;
  margin-top: var(--space-md);
  color: var(--text-secondary);
}

.empty-state span {
  font-size: var(--font-sm);
}

/* ============================================
   Modal
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-md);
  animation: fadeOverlay 200ms ease-out;
}

.modal-overlay.open {
  display: flex;
}

@keyframes fadeOverlay {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  width: 100%;
  max-width: 460px;
  animation: slideUp 300ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Mobile Overflow Fix */
  max-height: 85vh;
  overflow-y: auto;
  scrollbar-width: none;
  /* Hide scrollbar for cleaner UI */
}

.modal::-webkit-scrollbar {
  display: none;
}

.modal-sm {
  max-width: 340px;
  text-align: center;
}

.modal-sm h3 {
  margin-bottom: var(--space-sm);
}

.modal-sm p {
  color: var(--text-secondary);
  font-size: var(--font-sm);
  margin-bottom: var(--space-lg);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.modal-header h2 {
  font-size: var(--font-md);
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

/* ============================================
   Form
   ============================================ */

.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-size: var(--font-xs);
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--font-base);
  transition: var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder {
  color: var(--text-tertiary);
}

.form-group select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-row {
  display: flex;
  gap: var(--space-sm);
}

.form-row .form-group {
  flex: 1;
}

.form-group-small {
  max-width: 100px;
}

.category-select-row {
  display: flex;
  gap: var(--space-sm);
}

.category-select-row select {
  flex: 1;
}

.btn-new-cat {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-new-cat:hover {
  background: var(--bg-card-hover);
  color: var(--accent);
  border-color: var(--accent);
}

.new-cat-group .form-row {
  align-items: center;
}

.color-input {
  width: 40px !important;
  height: 40px;
  padding: 2px !important;
  border-radius: var(--radius-sm) !important;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-save-cat {
  padding: 8px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--font-xs);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.btn-save-cat:hover {
  opacity: 0.9;
}

.form-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-lg);
}

.btn-cancel {
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-cancel:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-save {
  padding: 10px 20px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font);
  font-size: var(--font-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-save:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-delete-confirm {
  padding: 10px 20px;
  background: var(--danger);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font);
  font-size: var(--font-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-delete-confirm:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--danger-bg);
}

/* ============================================
   Navigation & Pages
   ============================================ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--bg-glass);
  /* Use theme glass color */
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 12px 0;
  z-index: 100;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
  /* Subtle lift */
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  /* Bit bolder */
  cursor: pointer;
  width: 100%;
  transition: var(--transition);
}

.nav-tab svg {
  opacity: 0.6;
  transition: var(--transition);
}

.nav-tab.active {
  color: var(--accent);
}

.nav-tab.active svg {
  opacity: 1;
  stroke: var(--accent);
}

.app {
  padding-bottom: 90px;
  /* Space for bottom nav */
}

.page {
  display: none;
  animation: fadeIn 300ms ease-out;
}

.page.active {
  display: block;
}

/* ============================================
   Finance Portal
   ============================================ */

/* Month Nav */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  margin-bottom: var(--space-lg);
}

.month-label {
  font-weight: 600;
  font-size: var(--font-base);
}

.month-arrow {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.month-arrow:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* P&L Cards */
.pl-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.pl-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.pl-card.pl-profit {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(167, 139, 250, 0.05));
  border-color: rgba(99, 102, 241, 0.2);
}

.pl-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pl-credit .pl-icon {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.pl-debit .pl-icon {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.pl-profit .pl-icon {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
}

.pl-label {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  margin-bottom: 2px;
}

.pl-value {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.pl-value.positive {
  color: var(--success);
}

.pl-value.negative {
  color: var(--danger);
}

.pl-sub {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
}

/* Trend Chart */
.trend-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.section-title {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.trend-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 120px;
  gap: 8px;
  padding-bottom: 4px;
}

.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.trend-bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 100%;
  width: 100%;
  justify-content: center;
}

.trend-bar {
  width: 8px;
  border-radius: 2px;
  min-height: 2px;
  transition: height 500ms ease-out;
}

.trend-bar-credit {
  background: var(--success);
  opacity: 0.8;
}

.trend-bar-debit {
  background: var(--danger);
  opacity: 0.8;
}

.trend-label {
  font-size: 10px;
  color: var(--text-tertiary);
}

.trend-legend {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-xs);
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Breakdown List */
.breakdown-section {
  margin-bottom: var(--space-lg);
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr 1fr 1fr;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: var(--font-sm);
  gap: 8px;
  text-align: right;
}

.breakdown-cat {
  text-align: left;
  font-weight: 500;
  color: var(--text-primary);
}

.breakdown-currency {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 10px;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 4px;
  border-radius: 4px;
}

.breakdown-credit {
  color: var(--success);
}

.breakdown-debit {
  color: var(--danger);
}

.breakdown-net {
  font-weight: 600;
}

.breakdown-net.positive {
  color: var(--success);
}

.breakdown-net.negative {
  color: var(--danger);
}

.breakdown-empty {
  text-align: center;
  color: var(--text-tertiary);
  padding: var(--space-md);
  font-size: var(--font-sm);
}

/* Transaction List */
.tx-card {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  transition: var(--transition);
  animation: fadeIn 300ms ease-out;
}

.tx-date-header {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-secondary);
  font-size: var(--font-xs);
  font-weight: 600;
  text-transform: uppercase;
  padding: 8px 4px;
  margin-top: 8px;
  display: block;
}

.tx-type-indicator {
  width: 4px;
  height: 40px;
  border-radius: 2px;
}

.tx-type-indicator.credit {
  background: var(--success);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.tx-type-indicator.debit {
  background: var(--danger);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.tx-info {
  min-width: 0;
}

.tx-description {
  font-size: var(--font-base);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.tx-category {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.tx-notes {
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.tx-amount {
  text-align: right;
  font-weight: 600;
  font-size: var(--font-base);
}

.tx-amount-credit {
  color: var(--success);
}

.tx-amount-debit {
  color: var(--text-primary);
}

/* Keep expense white to reduce noise */

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

/* Modal Type Toggle */
.type-toggle {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.type-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.type-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.type-btn[data-type="credit"].active {
  color: var(--success);
}

.type-btn[data-type="debit"].active {
  color: var(--danger);
}

/* Currency Controls */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.currency-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.rate-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-xs);
  color: var(--text-secondary);
}

#exchange-rate {
  width: 50px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--font-sm);
  text-align: center;
  padding: 2px;
}

#exchange-rate:focus {
  outline: none;
  border-color: var(--accent);
}

.currency-label {
  font-weight: 600;
  color: var(--text-tertiary);
}

.currency-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: var(--font-xs);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.currency-toggle:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* Theme Toggle Removed */

/* Scrollable Lists */
.breakdown-list,
.transactions-list {
  max-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
  /* avoid content overlap with scrollbar */
}

/* Custom Scrollbar */
.breakdown-list::-webkit-scrollbar,
.transactions-list::-webkit-scrollbar {
  width: 4px;
}

.breakdown-list::-webkit-scrollbar-track,
.transactions-list::-webkit-scrollbar-track {
  background: transparent;
}

.breakdown-list::-webkit-scrollbar-thumb,
.transactions-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.breakdown-list::-webkit-scrollbar-thumb:hover,
.transactions-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Mobile Optimization */
@media (max-width: 480px) {
  :root {
    --space-md: 12px;
    --space-lg: 16px;
    --font-xl: 1.5rem;
  }

  /* Safer Touch Targets */
  button,
  .btn-action,
  .type-btn,
  .currency-toggle,
  .theme-toggle {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Compact Inputs */
  .currency-controls {
    padding: 2px 4px;
    gap: 4px;
  }

  #exchange-rate {
    width: 40px;
    height: 40px;
  }

  /* Header adjustments */
  .header {
    flex-wrap: wrap;
    /* Allow wrapping */
    gap: 8px;
  }

  .header-left {
    width: 100%;
    /* Full width for logo on tiny screens? No, keep side by side if possible */
    flex: 1;
  }

  .logo {
    font-size: var(--font-lg);
  }

  .header-actions {
    gap: 4px;
    /* justify-content: flex-end; */
    /* Can create issues if wrapping */
  }

  .btn-text {
    display: none;
    /* Hide 'Add' text on mobile, just icon */
  }

  /* Bottom Navigation - Safe Area */
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 16px);
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    z-index: 100;
    /* Ensure above content */
  }

  /* Modal - Full width bottom sheet feel */
  .modal {
    width: 100%;
    bottom: 0;
    top: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    transition: transform var(--transition);
    max-height: 85vh;
    overflow-y: auto;
    padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
  }

  .modal-overlay.open .modal {
    transform: translateY(0);
  }

  /* Stats Grid - 2 columns is fine, but maybe smaller gaps */
  .stats-row,
  .pl-cards {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
  }

  /* Make Profit card full width on mobile */
  .pl-cards .pl-card:last-child {
    grid-column: 1 / -1;
  }

  .stat-card,
  .pl-card,
  .reminder-card {
    padding: var(--space-sm);
  }

  /* Optimize LKR Display in Cards */
  .pl-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .pl-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 2px;
  }

  .pl-value,
  .stat-value {
    word-break: break-word;
  }

  .reminder-amount {
    font-size: var(--font-sm);
  }

  .header-subtitle {
    display: none;
  }

  /* Finance Page Styles */
  .breakdown-row {
    grid-template-columns: 1fr auto;
    /* Name | Amount */
    gap: 4px;
  }

  .breakdown-credit,
  .breakdown-debit,
  .breakdown-pct {
    display: none;
    /* Hide extra details on mobile */
  }

  .tx-card {
    grid-template-columns: auto 1fr auto;
    gap: var(--space-sm);
    padding: var(--space-sm);
  }

  .tx-actions {
    display: none;
    /* Hide actions on mobile list to clean UI */
  }

  .reminder-actions button {
    display: flex;
    /* Keep showing actions in reminder list? Maybe hide edit/delete and use swipe or long press in future, but for now keep */
  }

  /* Transaction List - ensure description doesn't break layout */
  .tx-description {
    max-width: 120px;
    /* Reduced for LKR space */
  }

  /* Fix LKR Display */
  .tx-amount {
    font-size: var(--font-sm);
    /* Smaller font for amounts */
    white-space: nowrap;
    /* Prevent wrapping generally */
  }

  /* If amount is very long, maybe stack? For now, just smaller font and less padding */
  .tx-card {
    gap: 4px;
    /* Tighter gap */
  }

  /* Improve Rate Input for Mobile */
  .rate-input-group {
    flex-wrap: wrap;
    justify-content: center;
  }

  .rate-input-group label {
    display: none;
    /* Hide label "1 USD =" on mobile to save space */
  }

  #exchange-rate {
    width: 60px;
    /* Bit wider for LKR rates */
  }
}