/* SweetLedger Main Stylesheet - Premium Mobile iOS / Candy Design System */

:root {
  /* Common Shared Colors */
  --color-white: #FFFFFF;
  --color-expense: #FF5A70; /* Soft coral red */
  --color-income: #34C759;  /* iOS system green */
  --border-radius-lg: 24px;
  --border-radius-md: 16px;
  --border-radius-sm: 12px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.1);
  
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-body: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- Theme Definitions --- */

/* 1. Peach Pink Theme (Default) */
.theme-pink {
  --primary: #FF8A98;
  --primary-dark: #E26E7C;
  --primary-light: #FFEAEB;
  --bg-app: #FFF5F6;
  --bg-card: #FFFFFF;
  --bg-card-alt: #FFFBFB;
  --text-main: #4A2E32;
  --text-muted: #9E8589;
  --border-color: #FFE1E4;
  --gradient-card: linear-gradient(135deg, #FF9EAA 0%, #FF8A98 100%);
  --shadow-primary: 0 8px 20px rgba(255, 138, 152, 0.25);
}

/* 2. Mint Green Theme */
.theme-green {
  --primary: #66A380;
  --primary-dark: #4C8263;
  --primary-light: #E8F5EE;
  --bg-app: #F4FAF7;
  --bg-card: #FFFFFF;
  --bg-card-alt: #F9FDFB;
  --text-main: #2A3D32;
  --text-muted: #809687;
  --border-color: #E2F2E9;
  --gradient-card: linear-gradient(135deg, #82BFA0 0%, #66A380 100%);
  --shadow-primary: 0 8px 20px rgba(102, 163, 128, 0.25);
}

/* 3. Oatmeal Cream Theme */
.theme-cream {
  --primary: #C59D7F;
  --primary-dark: #A98163;
  --primary-light: #F5EEE6;
  --bg-app: #FAF7F2;
  --bg-card: #FFFFFF;
  --bg-card-alt: #FAF8F5;
  --text-main: #4D3C2E;
  --text-muted: #A08E80;
  --border-color: #EFE6DC;
  --gradient-card: linear-gradient(135deg, #D4AF94 0%, #C59D7F 100%);
  --shadow-primary: 0 8px 20px rgba(197, 157, 127, 0.25);
}

/* 4. Midnight Dark Theme */
.theme-dark {
  --primary: #FFA8B6;
  --primary-dark: #FFCCD4;
  --primary-light: #2C1E20;
  --bg-app: #151112;
  --bg-card: #1E1719;
  --bg-card-alt: #241D1F;
  --text-main: #FFF0F2;
  --text-muted: #857073;
  --border-color: #2F2426;
  --gradient-card: linear-gradient(135deg, #FF8A98 0%, #D85566 100%);
  --shadow-primary: 0 8px 24px rgba(255, 138, 152, 0.15);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* --- Base & Reset --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  transition: background-color 0.4s ease;
}

/* App Container for iOS layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px; /* Centered mobile frame on desktop */
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-app);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
  padding-bottom: calc(65px + env(safe-area-inset-bottom)); /* Dynamic bottom padding for nav */
  transition: background-color 0.4s ease;
}

/* --- Header & Summary Card --- */
.app-header {
  padding: calc(20px + env(safe-area-inset-top)) 20px 16px 20px;
  background-color: var(--bg-app);
  z-index: 10;
  transition: background-color 0.4s ease;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.welcome-box {
  display: flex;
  flex-direction: column;
}

.greeting {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  animation: fadeIn 0.8s ease;
}

.month-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  background-color: var(--bg-card);
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-display);
  box-shadow: var(--shadow-sm);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.month-selector:active {
  transform: scale(0.95);
  background-color: var(--primary-light);
}

.chevron-icon {
  color: var(--text-muted);
}

/* Budget Card */
.budget-card {
  background: var(--gradient-card);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  color: var(--color-white);
  box-shadow: var(--shadow-primary);
  position: relative;
  overflow: hidden;
}

.budget-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.budget-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.budget-item {
  display: flex;
  flex-direction: column;
}

.budget-divider {
  width: 1px;
  height: 36px;
  background-color: rgba(255, 255, 255, 0.2);
}

.budget-item .label {
  font-size: 12px;
  opacity: 0.85;
  font-weight: 500;
  margin-bottom: 4px;
}

.budget-item .amount {
  font-size: 24px;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: -0.5px;
}

.budget-progress-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.budget-progress-bar {
  height: 6px;
  background-color: rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--color-white);
  border-radius: 10px;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.175, 0.885, 0.32, 1);
}

.progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  opacity: 0.9;
  font-weight: 500;
}

/* --- Content Navigation Sections --- */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px;
  /* Hide scrollbar */
  scrollbar-width: none;
}
.app-content::-webkit-scrollbar {
  display: none;
}

.tab-section {
  display: none;
  flex-direction: column;
  animation: tabFadeIn 0.35s cubic-bezier(0.1, 0.8, 0.25, 1);
  padding-bottom: 24px;
}

.tab-section.active {
  display: flex;
}

@keyframes tabFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0 16px 0;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.subsection-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
}

/* Filter Pills */
.filter-pills {
  display: flex;
  gap: 6px;
}

.filter-pill {
  border: none;
  background-color: var(--bg-card);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  transition: var(--transition-smooth);
}

.filter-pill.active {
  background-color: var(--primary);
  color: var(--color-white);
  border-color: var(--primary);
  font-weight: 700;
  box-shadow: var(--shadow-primary);
}

/* --- Transactions List (Tab 1) --- */
.transactions-list-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.day-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.day-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0 4px;
}

.day-list {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.transaction-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  transition: background-color 0.2s ease;
  touch-action: pan-y;
  user-select: none;
}

.transaction-item:last-child {
  border-bottom: none;
}

.transaction-item:active {
  background-color: var(--primary-light);
}

.item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.item-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background-color: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.item-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.item-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}

.payer-tag {
  background-color: rgba(0, 0, 0, 0.04);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: bold;
}

.theme-dark .payer-tag {
  background-color: rgba(255, 255, 255, 0.08);
}

.item-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-amount {
  font-size: 16px;
  font-weight: 800;
  font-family: var(--font-display);
}

.amount-out {
  color: var(--text-main);
}

.amount-in {
  color: var(--color-income);
}

/* iOS-style Swipe-delete (Simulated with simple hold-delete or left-swipe delete buttons) */
.delete-btn-reveal {
  position: absolute;
  top: 0;
  right: -80px;
  width: 80px;
  height: 100%;
  background-color: var(--color-expense);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.25s ease;
}

.transaction-item.swipe-left .delete-btn-reveal {
  transform: translateX(-80px);
}

.transaction-item.swipe-left {
  transform: translateX(-80px);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.empty-state p {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

/* --- Stats Section (Tab 2) --- */
.stats-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.chart-container {
  position: relative;
  width: 160px;
  height: 160px;
}

.donut-chart {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg); /* Start from top */
}

.chart-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.center-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.center-val {
  font-size: 18px;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--text-main);
  margin-top: 2px;
}

.chart-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

/* Leaderboard */
.leaderboard-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.leaderboard-item {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leader-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
}

.leader-label-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.leader-amount {
  font-family: var(--font-display);
  font-weight: 800;
}

.leader-bar-bg {
  height: 8px;
  background-color: var(--primary-light);
  border-radius: 100px;
  overflow: hidden;
}

.leader-bar-fill {
  height: 100%;
  background-color: var(--primary);
  border-radius: 100px;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.175, 0.885, 0.32, 1);
}

/* --- Wishes Section (Tab 3) --- */
.add-wish-btn {
  border: none;
  background-color: var(--primary);
  color: var(--color-white);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-primary);
  transition: var(--transition-smooth);
}

.add-wish-btn:active {
  transform: scale(0.95);
}

.piggy-bank-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  background-image: linear-gradient(to right, var(--bg-card) 60%, var(--primary-light) 100%);
}

.piggy-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.piggy-icon {
  font-size: 28px;
}

.piggy-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.piggy-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.piggy-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.piggy-balance {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--primary-dark);
}

/* Wishes List */
.wishes-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wish-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.wish-card.completed {
  opacity: 0.65;
}

.wish-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wish-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wish-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background-color: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.wish-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wish-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.wish-budget {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.wish-check-btn {
  border: none;
  background-color: var(--bg-app);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-spring);
  border: 2px solid var(--border-color);
}

.wish-card.completed .wish-check-btn {
  background-color: var(--color-income);
  color: var(--color-white);
  border-color: var(--color-income);
}

.wish-card.completed .wish-title {
  text-decoration: line-through;
}

.wish-delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.wish-card:hover .wish-delete-btn,
.wish-card:active .wish-delete-btn {
  opacity: 1;
}

/* --- Settings Section (Tab 4) --- */
.settings-group {
  margin-bottom: 20px;
}

.settings-group-title {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.settings-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

/* Theme Selector List */
.theme-selector-card {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 8px;
  gap: 8px;
}

.theme-option {
  border: none;
  background: none;
  padding: 14px 10px;
  border-radius: var(--border-radius-md);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-main);
  transition: var(--transition-smooth);
}

.theme-option:active {
  transform: scale(0.95);
}

.theme-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.theme-btn-pink .theme-dot { background-color: #FF8A98; }
.theme-btn-green .theme-dot { background-color: #66A380; }
.theme-btn-cream .theme-dot { background-color: #C59D7F; }
.theme-btn-dark .theme-dot { background-color: #FFA8B6; }

.theme-btn-pink.active { background-color: #FFEAEB; }
.theme-btn-green.active { background-color: #E8F5EE; }
.theme-btn-cream.active { background-color: #F5EEE6; }
.theme-btn-dark.active { background-color: #2C1E20; }

/* Budget Input Card */
.single-input-card {
  padding: 16px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-row span {
  font-size: 14px;
  font-weight: 700;
}

.budget-input-wrapper {
  display: flex;
  align-items: center;
  background-color: var(--bg-app);
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  max-width: 140px;
}

.currency-symbol {
  font-size: 14px;
  font-weight: bold;
  color: var(--primary-dark);
  margin-right: 4px;
}

.budget-input-wrapper input {
  border: none;
  background: none;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: bold;
  color: var(--text-main);
  width: 100%;
  outline: none;
}

/* Actions Card */
.actions-card {
  display: flex;
  flex-direction: column;
}

.setting-action-btn {
  border: none;
  background: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: background-color 0.2s ease;
}

.setting-action-btn:last-child {
  border-bottom: none;
}

.setting-action-btn:active {
  background-color: var(--primary-light);
}

.setting-action-btn svg {
  color: var(--text-muted);
}

.setting-action-btn.danger {
  color: var(--color-expense);
}
.setting-action-btn.danger svg {
  color: var(--color-expense);
}

.app-info {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 10px 0 30px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 500;
}

/* --- Bottom Navigation Bar --- */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: calc(65px + env(safe-area-inset-bottom));
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding-top: 10px;
  z-index: 100;
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.theme-dark .bottom-nav {
  background-color: rgba(30, 23, 25, 0.85);
}

.nav-item {
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  cursor: pointer;
  width: 50px;
  transition: var(--transition-smooth);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-spring);
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  transition: var(--transition-smooth);
}

.nav-item.active {
  color: var(--primary-dark);
}

.nav-item.active .nav-icon {
  transform: translateY(-2px) scale(1.1);
  color: var(--primary);
}

/* Nav Add (+) Button */
.nav-add-btn {
  border: none;
  background: none;
  position: relative;
  top: -24px;
  width: 56px;
  height: 56px;
  cursor: pointer;
  z-index: 110;
}

.add-btn-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--gradient-card);
  box-shadow: var(--shadow-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-white);
  transition: var(--transition-spring);
}

.nav-add-btn:active .add-btn-inner {
  transform: scale(0.9) rotate(45deg);
}

/* --- Slide-Up Bottom Sheet (Quick Add Form) --- */
.bottom-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: flex;
  justify-content: center;
}

.bottom-sheet-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: absolute;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background-color: var(--bg-app);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  max-height: 90%;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.15, 0.85, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-sheet-overlay.active .bottom-sheet {
  transform: translateY(0);
}

.sheet-header {
  background-color: var(--bg-card);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  padding: 10px 20px 20px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sheet-drag-handle {
  width: 36px;
  height: 5px;
  background-color: var(--border-color);
  border-radius: 100px;
  margin-bottom: 16px;
}

.sheet-title-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.sheet-cancel-btn {
  border: none;
  background: none;
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
}

.sheet-title {
  font-size: 16px;
  font-weight: 800;
}

.sheet-save-btn {
  border: none;
  background: none;
  font-size: 15px;
  color: var(--primary-dark);
  font-weight: 700;
  cursor: pointer;
}

/* Type Segmented Control (Expense / Income) */
.type-segmented-control {
  display: flex;
  background-color: var(--bg-app);
  padding: 3px;
  border-radius: 12px;
  width: 100%;
  margin-bottom: 16px;
}

.control-segment {
  flex: 1;
  border: none;
  background: none;
  padding: 8px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.control-segment.active {
  background-color: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

/* Amount Panel */
.amount-display-panel {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
}

.selected-category-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--primary-light);
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
}

.amount-number-wrapper {
  display: flex;
  align-items: baseline;
  color: var(--text-main);
}

.amount-number-wrapper .currency-symbol {
  font-size: 20px;
  margin-right: 4px;
}

.amount-val-display {
  font-size: 36px;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: -1px;
}

/* Sheet Body */
.sheet-body {
  overflow-y: auto;
  padding: 16px 20px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* Hide scrollbar */
  scrollbar-width: none;
}
.sheet-body::-webkit-scrollbar {
  display: none;
}

/* Category Grid */
.category-grid-container {
  min-height: 140px;
}

.category-grid {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.category-grid.active {
  display: grid;
  animation: fadeIn 0.3s ease;
}

.category-item {
  border: none;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-spring);
}

.category-item .cat-icon {
  font-size: 20px;
  transition: var(--transition-spring);
}

.category-item .cat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.category-item:active {
  transform: scale(0.92);
}

.category-item.active {
  background-color: var(--primary-light);
  border-color: var(--primary);
}

.category-item.active .cat-icon {
  transform: scale(1.15);
}

.category-item.active .cat-label {
  color: var(--primary-dark);
}

/* Form Row for Payer & Text */
.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

.row-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

/* Payer Segment Control */
.payer-segments {
  display: flex;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 3px;
  border-radius: 12px;
}

.payer-btn {
  border: none;
  background: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.payer-btn.active {
  background-color: var(--primary-light);
  color: var(--primary-dark);
}

/* Form inputs styling */
.form-row-group {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 0 16px;
}

.form-row.text-row {
  border-bottom: 1px solid var(--border-color);
}
.form-row.text-row:last-child {
  border-bottom: none;
}

.form-row input[type="text"],
.form-row input[type="date"] {
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  text-align: right;
  outline: none;
  padding: 8px 0;
  font-family: inherit;
  width: 60%;
}

.form-row input::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

/* Numeric Keypad */
.custom-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: var(--border-radius-lg);
  margin-top: 10px;
}

.key-btn {
  border: none;
  background-color: var(--bg-app);
  color: var(--text-main);
  border-radius: 14px;
  padding: 14px 0;
  font-size: 18px;
  font-weight: bold;
  font-family: var(--font-display);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.key-btn:active {
  transform: scale(0.92);
  background-color: var(--primary-light);
  color: var(--primary-dark);
}

.action-key {
  font-size: 13px;
  background-color: rgba(0, 0, 0, 0.03);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-dark .action-key {
  background-color: rgba(255, 255, 255, 0.04);
}

.confirm-key {
  grid-row: span 2;
  background: var(--gradient-card);
  color: var(--color-white);
  box-shadow: var(--shadow-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border-radius: 14px;
}

.confirm-key:active {
  background: var(--primary-dark);
}

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.25s ease;
}

.select-modal {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  padding: 24px;
  width: 100%;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: modalSlideUp 0.3s cubic-bezier(0.15, 0.85, 0.3, 1);
}

@keyframes modalSlideUp {
  from {
    transform: translateY(30px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-title {
  font-size: 16px;
  font-weight: 800;
  text-align: center;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.month-modal-btn {
  border: none;
  background-color: var(--bg-app);
  color: var(--text-main);
  padding: 10px 0;
  border-radius: 10px;
  font-size: 12px;
  font-weight: bold;
  font-family: var(--font-display);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.month-modal-btn:active {
  transform: scale(0.92);
}

.month-modal-btn.active {
  background-color: var(--primary);
  color: var(--color-white);
}

.modal-close-btn {
  border: none;
  background-color: rgba(0, 0, 0, 0.04);
  color: var(--text-muted);
  padding: 12px 0;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.theme-dark .modal-close-btn {
  background-color: rgba(255, 255, 255, 0.06);
}

/* Data backup modal styling */
.data-modal {
  max-width: 400px;
}
.data-modal-tip {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}
.data-modal-textarea {
  width: 100%;
  height: 120px;
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px;
  font-family: monospace;
  font-size: 11px;
  color: var(--text-main);
  resize: none;
  outline: none;
}
.modal-actions-row {
  display: flex;
  gap: 10px;
}
.modal-btn {
  flex: 1;
  border: none;
  background-color: var(--primary);
  color: white;
  padding: 12px 0;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.modal-btn.cancel-btn {
  background-color: rgba(0, 0, 0, 0.04);
  color: var(--text-muted);
}
.theme-dark .modal-btn.cancel-btn {
  background-color: rgba(255, 255, 255, 0.06);
}

/* --- Common Keyframes --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
