/* ===== CSS Variables ===== */
:root {
  --primary: #2E7D32;
  --primary-light: #4CAF50;
  --primary-dark: #1B5E20;
  --income: #2E7D32;
  --income-light: #E8F5E9;
  --expense: #C62828;
  --expense-light: #FFEBEE;
  --background: #F5F5F5;
  --surface: #FFFFFF;
  --text-primary: #212121;
  --text-secondary: #757575;
  --border: #E0E0E0;
  --shadow: rgba(0, 0, 0, 0.1);
  --nav-height: 70px;
  --header-height: 60px;
}

[data-theme="dark"] {
  --primary: #4CAF50;
  --primary-light: #81C784;
  --primary-dark: #2E7D32;
  --income: #4CAF50;
  --income-light: #1B5E20;
  --expense: #EF5350;
  --expense-light: #B71C1C;
  --background: #121212;
  --surface: #1E1E1E;
  --text-primary: #FFFFFF;
  --text-secondary: #B0B0B0;
  --border: #333333;
  --shadow: rgba(0, 0, 0, 0.3);
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}

#app.ready {
  display: flex;
}

/* ===== Splash Screen ===== */
.splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--background);
  z-index: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.splash-screen h1 {
  font-size: 1.5rem;
  color: var(--primary);
}

.splash-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Header ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 100;
  box-shadow: 0 2px 4px var(--shadow);
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 0.25rem;
}

.btn-icon {
  background: none;
  border: none;
  color: white;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-icon svg {
  width: 24px;
  height: 24px;
  pointer-events: none;
}

.icon-moon {
  display: none;
}

[data-theme="dark"] .icon-sun {
  display: none;
}

[data-theme="dark"] .icon-moon {
  display: block;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  padding: calc(var(--header-height) + 1rem) 1rem calc(var(--nav-height) + 1rem);
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* ===== Screens ===== */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Balance Card ===== */
.balance-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 1.5rem;
  border-radius: 16px;
  text-align: center;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px var(--shadow);
}

.balance-label {
  display: block;
  font-size: 0.875rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.balance-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
}

/* ===== Due Expenses Alert ===== */
.due-expenses-alert {
  background: linear-gradient(135deg, #FFF3E0, #FFE0B2);
  border: 1px solid #FFB74D;
  border-radius: 12px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.due-expenses-alert.has-today {
  background: linear-gradient(135deg, #FFF8E1, #FFECB3);
  border-color: #FFC107;
}

.due-expenses-alert.has-overdue {
  background: linear-gradient(135deg, #FFEBEE, #FFCDD2);
  border-color: #EF5350;
}

.due-alert-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  color: #E65100;
  font-weight: 600;
  font-size: 0.875rem;
}

.due-expenses-alert.has-today .due-alert-header {
  color: #F57F17;
}

.due-expenses-alert.has-overdue .due-alert-header {
  color: #C62828;
}

.due-expenses-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.due-expense-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
}

.due-expense-info {
  flex: 1;
  min-width: 0;
}

.due-expense-desc {
  display: block;
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.due-expense-status {
  font-size: 0.7rem;
  color: #E65100;
}

.due-expense-item.today .due-expense-status {
  color: #F57F17;
  font-weight: 600;
}

.due-expense-item.overdue .due-expense-status {
  color: #C62828;
  font-weight: 600;
}

.due-expense-value {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--expense);
  white-space: nowrap;
}

.due-expense-pay {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--income);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, opacity 0.2s;
}

.due-expense-pay:hover {
  opacity: 0.9;
}

.due-expense-pay:active {
  transform: scale(0.95);
}

/* Dark theme adjustments */
[data-theme="dark"] .due-expenses-alert {
  background: linear-gradient(135deg, #3E2723, #4E342E);
  border-color: #8D6E63;
}

[data-theme="dark"] .due-expenses-alert.has-today {
  background: linear-gradient(135deg, #3E2723, #5D4037);
  border-color: #FFB300;
}

[data-theme="dark"] .due-expenses-alert.has-overdue {
  background: linear-gradient(135deg, #3E2723, #4E342E);
  border-color: #EF5350;
}

[data-theme="dark"] .due-alert-header {
  color: #FFB74D;
}

[data-theme="dark"] .due-expenses-alert.has-today .due-alert-header {
  color: #FFC107;
}

[data-theme="dark"] .due-expenses-alert.has-overdue .due-alert-header {
  color: #EF5350;
}

[data-theme="dark"] .due-expense-item {
  background: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .due-expense-status {
  color: #FFB74D;
}

[data-theme="dark"] .due-expense-item.today .due-expense-status {
  color: #FFC107;
}

[data-theme="dark"] .due-expense-item.overdue .due-expense-status {
  color: #EF5350;
}

/* ===== Dashboard Month Selector ===== */
.dashboard-month-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 2px 8px var(--shadow);
}

.month-nav-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--background);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  transition: background 0.2s, transform 0.1s;
}

.month-nav-btn:hover {
  background: var(--primary);
  color: white;
}

.month-nav-btn:active {
  transform: scale(0.95);
}

.month-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 140px;
  text-align: center;
  text-transform: capitalize;
}

/* ===== Summary Cards ===== */
.summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.summary-card {
  background: var(--surface);
  padding: 0.75rem 0.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.summary-card.savings {
  border-left: 4px solid #3F51B5;
}

.summary-card.savings .summary-value {
  color: #3F51B5;
}

.summary-card.income {
  border-left: 4px solid var(--income);
}

.summary-card.expense {
  border-left: 4px solid var(--expense);
}

.summary-card.remaining {
  border-left: 4px solid #FF9800;
}

.summary-card.remaining .summary-value {
  color: #FF9800;
}

.summary-card.remaining .summary-value.negative {
  color: var(--expense);
}

.summary-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  white-space: nowrap;
}

.summary-value {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-card.income .summary-value {
  color: var(--income);
}

.summary-card.expense .summary-value {
  color: var(--expense);
}

/* ===== Chart Container ===== */
.chart-container {
  background: var(--surface);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.chart-container h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.chart-container canvas {
  max-height: 250px;
}

.empty-message {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem 1rem;
  font-size: 0.875rem;
}

/* ===== Goal Preview ===== */
.goal-preview {
  background: var(--surface);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.goal-preview h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.goal-progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.goal-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
}

.goal-info span:first-child {
  font-weight: 600;
  color: var(--primary);
}

.goal-info span:last-child {
  color: var(--text-secondary);
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar.large {
  height: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 4px;
  transition: width 0.5s ease;
  width: 0%;
}

.goal-percentage {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ===== Transaction List ===== */
.recent-transactions h3,
.transactions-list-container h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.transaction-list {
  list-style: none;
}

.transaction-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 4px var(--shadow);
}

.transaction-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
  font-size: 1.25rem;
}

.transaction-icon.income {
  background: var(--income-light);
  color: var(--income);
}

.transaction-icon.expense {
  background: var(--expense-light);
  color: var(--expense);
}

.transaction-details {
  flex: 1;
  min-width: 0;
}

.transaction-description {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transaction-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.transaction-value {
  font-weight: 600;
  margin-left: 0.5rem;
}

.transaction-value.income {
  color: var(--income);
}

.transaction-value.expense {
  color: var(--expense);
}

.transaction-actions {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

.transaction-actions button {
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: all 0.2s;
}

.transaction-actions button:hover {
  background: var(--border);
  color: var(--text-primary);
}

.transaction-actions button.delete:hover {
  color: var(--expense);
}

/* ===== Forms ===== */
.transaction-form,
.goal-form,
.category-form {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.transaction-form h3,
.goal-form h3 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.type-toggle {
  display: flex;
  gap: 0.5rem;
}

.type-btn {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.type-btn.active[data-type="income"] {
  border-color: var(--income);
  background: var(--income-light);
  color: var(--income);
}

.type-btn.active[data-type="expense"] {
  border-color: var(--expense);
  background: var(--expense-light);
  color: var(--expense);
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.form-row {
  display: flex;
  gap: 0.5rem;
}

.form-row input[type="text"] {
  flex: 1;
}

.form-row input[type="color"] {
  width: 50px;
  padding: 0.25rem;
  cursor: pointer;
}

/* ===== Buttons ===== */
.btn {
  flex: 1;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--text-secondary);
  color: white;
}

.btn-danger {
  background: var(--expense);
  color: white;
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  flex: none;
}

.btn-income {
  background: var(--income);
  color: white;
}

.btn-income:hover {
  opacity: 0.9;
}

.btn-expense {
  background: var(--expense);
  color: white;
}

.btn-expense:hover {
  opacity: 0.9;
}

/* ===== Savings Form ===== */
.savings-buttons {
  display: flex;
  gap: 0.5rem;
}

.savings-buttons .btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* ===== Savings History ===== */
.savings-history-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.savings-history-section h4 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.savings-history-list {
  max-height: 300px;
  overflow-y: auto;
}

.savings-history-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: var(--background);
  gap: 0.75rem;
}

.savings-history-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}

.savings-history-icon.deposit {
  background: rgba(76, 175, 80, 0.15);
  color: var(--income);
}

.savings-history-icon.withdraw {
  background: rgba(244, 67, 54, 0.15);
  color: var(--expense);
}

.savings-history-details {
  flex: 1;
  min-width: 0;
}

.savings-history-reason {
  display: block;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.savings-history-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.savings-history-values {
  text-align: right;
  flex-shrink: 0;
}

.savings-history-value {
  display: block;
  font-weight: 600;
}

.savings-history-value.deposit {
  color: var(--income);
}

.savings-history-value.withdraw {
  color: var(--expense);
}

.savings-history-balance {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* ===== Filter Group ===== */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.filter-group select,
.report-filters select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.report-filters {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.report-actions {
  display: flex;
  justify-content: flex-end;
  flex: 1;
}

.report-actions .btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ===== Export Modal ===== */
.export-format-toggle {
  display: flex;
  gap: 0.5rem;
}

.format-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.format-btn:hover {
  border-color: var(--primary-light);
}

.format-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.format-btn.active svg {
  stroke: #fff;
}

.export-custom-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* ===== Report Summary ===== */
.report-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.report-card {
  background: var(--surface);
  padding: 1rem 0.5rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 2px 8px var(--shadow);
}

.report-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.report-value {
  display: block;
  font-size: 1rem;
  font-weight: 600;
}

.report-value.income {
  color: var(--income);
}

.report-value.expense {
  color: var(--expense);
}

/* ===== Category List ===== */
.category-breakdown h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.category-list {
  list-style: none;
}

.category-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 4px var(--shadow);
}

.category-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 0.75rem;
}

.category-name {
  flex: 1;
  font-weight: 500;
}

.category-amount {
  font-weight: 600;
  color: var(--expense);
}

.category-percent {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: 0.5rem;
  min-width: 45px;
  text-align: right;
}

/* ===== Goal Screen ===== */
.goals-list-container {
  margin-top: 1.5rem;
}

.goals-list-container h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.goals-list {
  list-style: none;
}

.goal-item {
  background: var(--surface);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.goal-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.goal-item-info h4 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.goal-item-info .goal-details {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.goal-item-actions {
  display: flex;
  gap: 0.25rem;
}

.goal-item-actions button {
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: all 0.2s;
}

.goal-item-actions button:hover {
  background: var(--border);
  color: var(--text-primary);
}

.goal-item-actions button.delete:hover {
  color: var(--expense);
}

.goal-item-progress {
  margin-bottom: 0.5rem;
}

.goal-item-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.goal-item-numbers .saved {
  color: var(--primary);
  font-weight: 600;
}

.goal-item-numbers .target {
  color: var(--text-secondary);
}

.goal-item-numbers .remaining {
  width: 100%;
  color: var(--expense);
  font-weight: 500;
  font-size: 0.95rem;
}

.goal-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.goal-item-footer .monthly {
  color: var(--primary);
  font-weight: 500;
}

.goal-item.completed {
  border: 2px solid var(--income);
}

.goal-item.completed .goal-badge {
  background: var(--income-light);
  color: var(--income);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

.goal-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 4px var(--shadow);
}

.goal-history-month {
  font-weight: 500;
}

.goal-history-status {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.goal-history-status.achieved {
  background: var(--income-light);
  color: var(--income);
}

.goal-history-status.not-achieved {
  background: var(--expense-light);
  color: var(--expense);
}

/* ===== Settings Screen ===== */
.settings-section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.settings-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.settings-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.savings-form {
  margin-bottom: 0.75rem;
}

.current-savings {
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 0.75rem;
  background: var(--background);
  border-radius: 8px;
  margin-top: 0.5rem;
}

.current-savings strong {
  color: var(--primary);
}

/* Sync Styles */
.sync-config .form-group {
  margin-bottom: 0.5rem;
}

.sync-config .settings-description a {
  color: var(--primary);
  text-decoration: underline;
}

.sync-actions .sync-status {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--income-light);
  border-radius: 8px;
}

.sync-actions .sync-status #sync-status-text {
  color: var(--income);
  font-weight: 500;
}

.sync-actions .last-sync {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.sync-buttons {
  display: flex;
  gap: 0.5rem;
}

.sync-buttons .btn {
  flex: 1;
}

/* ===== Devices List ===== */
.devices-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.devices-section h4 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.devices-list {
  list-style: none;
}

.device-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--background);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.device-item.current-device {
  background: var(--income-light);
  border: 1px solid var(--income);
}

.device-icon {
  font-size: 1.5rem;
}

.device-info {
  flex: 1;
  min-width: 0;
}

.device-name {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
}

.device-badge {
  display: inline-block;
  background: var(--income);
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.device-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.device-actions {
  flex-shrink: 0;
}

.device-action-btn {
  background: none;
  border: none;
  padding: 0.4rem;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: all 0.2s;
}

.device-action-btn:hover {
  background: var(--border);
  color: var(--text-primary);
}

.device-action-btn.delete:hover {
  background: var(--expense-light);
  color: var(--expense);
}

.categories-list {
  list-style: none;
}

.categories-list li {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.categories-list li:last-child {
  border-bottom: none;
}

.categories-list .category-color {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  margin-right: 0.75rem;
}

.categories-list .category-name {
  flex: 1;
}

.categories-list .delete-category {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
}

.categories-list .delete-category:hover {
  color: var(--expense);
  background: var(--expense-light);
}

.categories-list .default-badge {
  font-size: 0.7rem;
  background: var(--border);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  color: var(--text-secondary);
}

/* ===== Goal Add Savings ===== */
.goal-add-savings {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.goal-add-savings .btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.savings-modal-info {
  background: var(--background);
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.data-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.about-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--surface);
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 10px var(--shadow);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0.5rem;
  cursor: pointer;
  transition: color 0.2s;
  min-width: 60px;
}

.nav-btn svg {
  width: 24px;
  height: 24px;
  margin-bottom: 0.25rem;
}

.nav-btn span {
  font-size: 0.625rem;
  font-weight: 500;
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn:hover {
  color: var(--primary);
}

/* ===== Modal ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  max-width: 400px;
  width: 100%;
}

.modal-content h3 {
  margin-bottom: 0.5rem;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
}

.modal-large {
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* ===== Replicate Button ===== */
.btn-replicate {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
  padding: 0.6rem;
  font-size: 0.8rem;
  opacity: 0.75;
}

.btn-replicate svg {
  flex-shrink: 0;
}

/* ===== Replicate Modal ===== */
.replicate-actions-top {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.replicate-actions-top .btn {
  flex: 1;
}

.replicate-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.replicate-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}

.replicate-item:last-child {
  border-bottom: none;
}

.replicate-item:hover {
  background: var(--background);
}

.replicate-item.selected {
  background: var(--income-light);
}

.replicate-checkbox {
  width: 20px;
  height: 20px;
  margin-right: 0.75rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.replicate-info {
  flex: 1;
  min-width: 0;
}

.replicate-description {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.replicate-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.replicate-value {
  font-weight: 600;
  margin-left: 0.5rem;
  white-space: nowrap;
}

.replicate-value.income {
  color: var(--income);
}

.replicate-value.expense {
  color: var(--expense);
}

.replicate-empty {
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.replicate-item.last-installment {
  opacity: 0.5;
  background: var(--expense-light);
}

.replicate-item.last-installment:hover {
  background: var(--expense-light);
  cursor: not-allowed;
}

.replicate-card-info {
  display: block;
  font-size: 0.7rem;
  color: #7B1FA2;
  margin-top: 0.25rem;
  font-weight: 500;
}

.replicate-card-info.last {
  color: var(--expense);
}

.replicate-card-info.already {
  color: var(--income);
}

.replicate-item.already-replicated {
  opacity: 0.5;
  background: var(--income-light);
}

.replicate-item.already-replicated:hover {
  background: var(--income-light);
  cursor: not-allowed;
}

[data-theme="dark"] .replicate-card-info {
  color: #BA68C8;
}

[data-theme="dark"] .replicate-card-info.last {
  color: var(--expense);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 1rem);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: var(--surface);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.875rem;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 300;
  max-width: calc(100% - 2rem);
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  background: var(--income);
}

.toast.error {
  background: var(--expense);
}

/* ===== Responsive ===== */
@media (min-width: 768px) {
  .main-content {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .summary-cards {
    grid-template-columns: 1fr 1fr;
  }

  .report-summary {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* ===== Animations ===== */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.goal-message.success {
  animation: pulse 2s infinite;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--background);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ===== Hide Values ===== */
.values-hidden .balance-value,
.values-hidden .summary-value,
.values-hidden #total-remaining,
.values-hidden .transaction-value,
.values-hidden .report-value,
.values-hidden .goal-item-numbers .saved,
.values-hidden .goal-item-numbers .target,
.values-hidden .goal-item-numbers .remaining,
.values-hidden .goal-item-footer .monthly,
.values-hidden .category-amount,
.values-hidden .current-savings strong,
.values-hidden .savings-modal-info,
.values-hidden .due-expense-value,
.values-hidden .savings-history-value,
.values-hidden .savings-history-balance,
.values-hidden .budget-exceeded-text {
  color: transparent !important;
  text-shadow: none !important;
  background: var(--border);
  border-radius: 4px;
  user-select: none;
  min-width: 60px;
  display: inline-block;
}

#toggle-values .icon-eye-open,
#toggle-values .icon-eye-closed {
  width: 24px;
  height: 24px;
}

#toggle-values .icon-eye-closed {
  display: none !important;
}

#toggle-values .icon-eye-open {
  display: block !important;
}

.values-hidden #toggle-values .icon-eye-open {
  display: none !important;
}

.values-hidden #toggle-values .icon-eye-closed {
  display: block !important;
}

/* Ocultar gráficos quando valores estão ocultos */
.values-hidden canvas {
  filter: blur(15px) !important;
  pointer-events: none !important;
}

/* ===== Paid Status ===== */
.transaction-item.is-paid {
  opacity: 0.7;
}

.transaction-item.is-paid .transaction-description {
  text-decoration: line-through;
}

.transaction-item.unpaid {
  border-left: 3px solid var(--expense);
}

.paid-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.paid-btn:hover {
  background: var(--background);
}

.paid-btn.paid {
  color: var(--income);
}

.paid-btn.paid svg {
  fill: var(--income);
}

/* ===== Card Badge ===== */
.card-badge {
  display: inline-block;
  background: linear-gradient(135deg, #7B1FA2, #9C27B0);
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

[data-theme="dark"] .card-badge {
  background: linear-gradient(135deg, #9C27B0, #BA68C8);
}

/* ===== Checkbox Label ===== */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.5rem 0;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-label span {
  user-select: none;
}

/* Card field group */
.card-field {
  border-top: 1px dashed var(--border);
  padding-top: 1rem;
  margin-top: 0.5rem;
}

/* ===== Auth Overlay ===== */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--background);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-container {
  background: var(--surface);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 32px var(--shadow);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header h1 {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.auth-header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.auth-form-group {
  margin-bottom: 1rem;
}

.auth-form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.auth-form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.auth-form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.auth-btn {
  width: 100%;
  margin-top: 0.5rem;
}

.auth-back-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
}

.auth-back-btn:hover {
  opacity: 0.8;
}

.auth-form-title {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
}

.auth-links a {
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: none;
}

.auth-links a:hover {
  text-decoration: underline;
}


/* ===== Account Section in Settings ===== */
.account-info {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.account-email {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--background);
  border-radius: 8px;
}

.account-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.account-value {
  font-weight: 600;
  color: var(--primary);
}

/* ===== Offline Banner ===== */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #FF9800;
  color: #fff;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 600;
}

[data-theme="dark"] .offline-banner {
  background: #E65100;
}

.offline-banner + #app .header {
  top: 32px;
}

/* ===== Update Banner ===== */
.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  color: #fff;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 600;
}

.update-dismiss {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.25rem;
  opacity: 0.8;
}

.update-dismiss:hover {
  opacity: 1;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-content {
  background: var(--surface);
  padding: 2rem;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.loading-text {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* ===== Search Input ===== */
.search-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.search-input::placeholder {
  color: var(--text-secondary);
}

/* ===== Transactions Filters ===== */
.transactions-filters {
  margin-bottom: 1rem;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-row select {
  flex: 1 1 calc(50% - 0.2rem);
  min-width: 0;
  padding: 0.45rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.75rem;
  box-sizing: border-box;
}

/* Em mobile, mês ocupa linha inteira, categoria e conta dividem a segunda linha */
@media (max-width: 480px) {
  .filter-row select:first-child {
    flex: 1 1 100%;
  }
  .filter-row select {
    flex: 1 1 calc(50% - 0.2rem);
  }
}

/* ===== Campos extras do formulário (Conta + Recorrência) lado a lado ===== */
.form-row-inline {
  display: flex;
  gap: 0.75rem;
}

.form-row-inline .form-group {
  flex: 1;
  min-width: 0;
}

/* ===== Load More Button ===== */
.btn-load-more {
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  text-align: center;
}

/* ===== Comparison Badge ===== */
.comparison-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 0.25rem;
}

.comparison-badge.positive {
  background: rgba(76, 175, 80, 0.15);
  color: var(--income);
}

.comparison-badge.negative {
  background: rgba(244, 67, 54, 0.15);
  color: var(--expense);
}

/* ===== Recurring Badge ===== */
.recurring-badge {
  display: inline-block;
  background: linear-gradient(135deg, #0277BD, #0288D1);
  color: white;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.35rem;
  vertical-align: middle;
}

[data-theme="dark"] .recurring-badge {
  background: linear-gradient(135deg, #0288D1, #039BE5);
}

/* ===== Emoji Picker ===== */
.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  padding: 0.5rem 0;
  margin-bottom: 0.75rem;
}

.emoji-picker-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-right: 0.25rem;
}

.emoji-option {
  width: 32px;
  height: 32px;
  border: 2px solid transparent;
  background: var(--background);
  border-radius: 6px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.emoji-option:hover {
  border-color: var(--border);
  transform: scale(1.1);
}

.emoji-option.selected {
  border-color: var(--primary);
  background: var(--income-light);
}

/* ===== Budget Alerts ===== */
.budget-alerts {
  background: var(--surface);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.budget-bar {
  margin-bottom: 0.75rem;
}

.budget-bar:last-child {
  margin-bottom: 0;
}

.budget-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.budget-bar.ok .budget-bar-header {
  color: var(--text-primary);
}

.budget-bar.warning .budget-bar-header {
  color: #FF9800;
}

.budget-bar.exceeded .budget-bar-header {
  color: var(--expense);
  font-weight: 600;
}

.budget-fill-ok {
  background: var(--primary) !important;
}

.budget-fill-warning {
  background: #FF9800 !important;
}

.budget-fill-exceeded {
  background: var(--expense) !important;
}

.budget-exceeded-text {
  font-size: 0.7rem;
  color: var(--expense);
  font-weight: 500;
}

/* ===== Budget Settings ===== */
.budget-categories-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.budget-category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.budget-category-item:last-child {
  border-bottom: none;
}

.budget-category-item span {
  font-size: 0.875rem;
  flex: 1;
}

.budget-limit-input {
  width: 100px;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text-primary);
  text-align: right;
}

.budget-limit-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== App Version Footer ===== */
.app-version-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ===== Account icon display ===== */
.account-icon-display {
  font-size: 1.25rem;
  margin-right: 0.5rem;
}
