:root {
  --bg-primary: linear-gradient(135deg, #ebf0f1, #b4ced4);
  --bg-sidebar: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --bg-secondary: #fff;
  --bg-action: #f5f7fa;
  --bg-account-switch: rgba(102, 126, 234, 0.12);

  --text-primary: #222;
  --text-secondary: #5b6597;
  --text-accent: #667eea;

  --sidebar-width: 242px;
  --border-radius: 17px;
  --box-shadow-card: 0 8px 32px rgba(0,0,0,0.10);
  --box-shadow-hover: 0 16px 40px rgba(34,55,120,0.18);

  --stats-income: #4ecdc4;
  --stats-expense: #ff6b6b;
}

/* Body and App Layout */
body {
  margin: 0;
  background: var(--bg-primary);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  color: var(--text-primary);
}

/* Sidebar */
.sidebar {
  background: var(--bg-sidebar);
  color: #fff;
  width: var(--sidebar-width);
  position: fixed;
  left: 0; top: 0;
  bottom: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 16px 15px 16px;
  box-shadow: 2px 0 16px rgba(0,0,0,0.11);
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 25px;
}

.sidebar-header img {
  width: 54px;
  height: 54px;
  border-radius: 7px;
}

.sidebar-header h2 {
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  margin: 7px 0 0 0;
  background: linear-gradient(90deg,#fff,#dcd6ff 70%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-menu {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 18px;
  color: rgba(255,255,255,0.85);
  border-radius: 8px;
  font-weight: 500;
  font-size: 1.08rem;
  text-decoration: none;
  margin-bottom: 3px;
  transition: background 0.22s, color 0.22s;
}

.nav-link i {
  font-size: 1.25em;
}

.nav-link.active,
.nav-link:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.13);
  padding-top: 18px;
  margin-top: 10px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5eead4, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: bold;
  font-size: 1.28em;
  box-shadow: 0 4px 10px rgba(99,102,241,0.13);
}

/* Sidebar user info */
.user-name {
  font-weight: 600;
  font-size: 15px;
}

.user-settings {
  color: #e7eaff;
  text-decoration: none;
  font-size: 13.3px;
  transition: color 0.18s;
}

.user-settings:hover {
  color: #fff;
}

/* Main Content Scroll */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 0;
  background: transparent;
  min-height: 100vh;
}

/* Top Bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-card);
  padding: 23px 38px 19px 38px;
  margin: 41px 22px 28px 22px;
}

.logo {
  font-size: 2.03rem;
  font-weight: 800;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.account-switcher {
  display: flex;
  background: var(--bg-account-switch);
  border-radius: 13px;
  padding: 5px;
  gap: 7px;
}

.account-btn {
  padding: 13px 24px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-accent);
  font-weight: 600;
  cursor: pointer;
  font-size: 1.06rem;
  transition: background 0.18s, color 0.22s;
}

.account-btn.active {
  background: var(--text-accent);
  color: #fff;
  box-shadow: 0 4px 17px rgba(102,126,234,0.21);
}

.settings-btn {
  margin-left: 337px;
  margin-top: 12px;
  padding: 15px 13px;
  background: var(--bg-account-switch);
  border-radius: 11px;
  color: var(--text-accent);
  font-weight: 650;
  border: none;
  font-size: 1.23rem;
  display: flex;
  align-items: center;
  text-decoration: none;
  justify-content: center;
  transition: background 0.19s;
}

.settings-btn:hover {
  background: rgba(102,126,234,0.22);
}

/* Stats Grid */
.dashboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px 38px 32px;
}
.dashboard-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 34px;
  margin-bottom: 38px;
}
.stats-card {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-card);
  flex: 1 1 225px;
  text-align: center;
  padding: 32px 34px 30px 34px;
  transition: 0.21s box-shadow, 0.13s transform;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stats-card:hover {
  box-shadow: var(--box-shadow-hover);
  transform: translateY(-3px);
}
.stats-title {
  color: var(--text-secondary);
  font-size: 1.06rem;
  text-transform: uppercase;
  margin-bottom: 14px;
  letter-spacing: 1.2px;
}
.stats-amount {
  font-size: 2.7rem;
  font-weight: 800;
  margin-bottom: 6px;
}
.income .stats-amount { color: var(--stats-income);}
.expense .stats-amount { color: var(--stats-expense);}
.balance .stats-amount, .total .stats-amount { color: var(--text-accent);}

/* Quick Actions */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin: 0 0 8px 0;
  padding: 15px 8px;
  background: var(--bg-action);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-card);
  align-items: center;
  justify-content: center;
}

.action-btn {
  padding: 20px 32px;
  border-radius: 13px;
  border: none;
  font-size: 1.08rem;
  font-weight: 600;
  background: linear-gradient(120deg,#e3f0ff 60%,#a2b8e8 100%);
  color: var(--text-accent);
  box-shadow: 0 4px 12px rgba(160, 197, 247, 0.11);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: background 0.19s, color 0.18s, box-shadow 0.2s;
  min-width: 180px;
}

.action-btn:hover {
  background: linear-gradient(120deg,#d1e7ff 60%,#c3d0ea 100%);
  color: #445abb;
  box-shadow: 0 6px 18px rgba(110, 157, 235, 0.17);
}

.action-btn .icon {
  font-size: 1.45em;
  display: flex;
  align-items: center;
}

/* Responsive Layouts */
@media (max-width: 1200px) {
  .dashboard-container { padding-left: 3vw; padding-right: 3vw; }
}
@media (max-width: 900px) {
  .main-content { margin-left: 0; }
  .sidebar {
    position: absolute;
    left: -250px;
    width: 230px;
    transition: 0.26s;
    z-index: 200;
  }
  .sidebar.active { left: 0; }
  .dashboard-container { padding: 9px; }
  .dashboard-grid { flex-direction: column; gap: 17px; }
  .top-bar { margin: 23px 7px 18px 7px; }
}
@media (max-width: 650px) {
  .stats-card { padding: 17px 5vw 16px 5vw; }
  .quick-actions { flex-direction: column; padding: 10px 2vw; gap: 11px;}
  .dashboard-container { padding: 4px; }
}

/* Dark theme overrides */
[data-theme="dark"] {
  --bg-primary: linear-gradient(135deg, #1a2a3a, #273e47);
  --bg-dashboard: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  --bg-settings-primary: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  
  --bg-secondary: rgba(30, 30, 46, 0.95);
  --bg-tertiary: rgba(40, 40, 56, 0.9);
  --bg-quaternary: rgba(35, 35, 51, 0.9);
  --bg-account-switch: rgba(124, 138, 173, 0.2);
  --bg-topbar: rgba(34, 42, 53, 0.8);
  --bg-action-section: rgba(34, 42, 53, 0.8);
  --bg-transaction-form: rgba(45, 58, 75, 0.75);
  --bg-recent-transactions: rgba(34, 42, 53, 0.8);
  --success-bg: rgba(78, 205, 196, 0.2);
  --danger-bg: rgba(255, 107, 107, 0.2);
  --warning-bg: rgba(255, 193, 7, 0.2);


  --text-primary: #e0e0e0;
  --text-secondary: #bbb;
  --text-muted: #999;
  --text-tertiary: #888;
  --text-accent: #7c8aed;
  --text-income: #36b5a9;
  --text-expense: #b84848;
  --text-balance: #7c8aed;
  --success-text: #5ed9ce;
  --danger-text: #ff7979;
  --warning-text: #fdcb6e;


  --border-primary: #404040;
  --border-secondary: #353535;
  --border-input: #404040;


  --box-shadow-card: 0 8px 32px rgba(0, 0, 0, 0.5);
  --box-shadow-hover: 0 15px 45px rgba(0, 0, 0, 0.7);
  --box-shadow-action-btn-income: 0 8px 25px rgba(54, 181, 169, 0.7);
  --box-shadow-action-btn-expense: 0 8px 25px rgba(184, 72, 72, 0.7);
  --box-shadow-action-btn-hover: 0 12px 35px rgba(0,0,0,0.5);
  --shadow-primary: rgba(0, 0, 0, 0.3);
  --shadow-secondary: rgba(0, 0, 0, 0.4);
  --shadow-strong: rgba(0, 0, 0, 0.6);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-primary);
  min-height: 100vh;
  color: var(--text-primary);
}

.settings-container {
  margin: 40px auto 0 auto;
  max-width: 640px;
  padding: 0 16px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.header {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-card);
  padding: 20px 30px;
  margin-bottom: 8px;
  border: 1px solid var(--border-primary);
}

.logo {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.back-btn {
  margin-left: auto;
  padding: 10px 18px;
  background: var(--bg-account-switch);
  border-radius: 12px;
  color: var(--text-accent);
  font-weight: 600;
  border: none;
  text-decoration: none;
  display: flex;
  align-items: center;
}

.settings-section {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-card);
  padding: 30px 28px;
  border: 1px solid var(--border-primary);
  width: 100%;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-control {
  display: flex;
  align-items: center;
  gap: 15px;
}

.theme-toggle {
  position: relative;
  width: 54px;
  height: 29px;
}

.theme-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border-primary);
  border-radius: 30px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.18);
  transition: 0.3s;
}

.theme-slider:before {
  content: "";
  position: absolute;
  height: 20px; width: 20px;
  left: 4px;
  bottom: 4px;
  background: linear-gradient(135deg,#667eea 0%,#764ba2 100%);
  border-radius: 50%;
  transition: 0.3s;
}

.theme-toggle input:checked + .theme-slider {
  background: #434c5e;
}

.theme-toggle input:checked + .theme-slider:before {
  transform: translateX(24px);
  background: linear-gradient(135deg,#88c999 0%,#5e81ac 100%);
}

#themeLabel {
  font-weight: 600;
  color: var(--text-accent);
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--border-primary);
}

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

.setting-info {
  flex: 1;
}

.setting-name {
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-primary);
}

.setting-desc {
  font-size: 0.97rem;
  color: var(--text-secondary);
}

.current-email {
  font-size: 0.94rem;
  color: var(--text-accent);
  font-weight: 600;
}

.status-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 16px;
  background: var(--success-bg);
  color: var(--success-text);
  padding: 4px 14px;
}

.btn {
  padding: 12px 22px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: 0.2s;
}

.btn-primary {
  background: var(--text-accent);
  color: #fff;
}
.btn-primary:hover { background: #5a6cd8; }

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

.btn-success {
  background: #667eea;
  color: #fff;
}
.btn-success:hover { background: #2ec3a1; }

.btn-danger {
  background: #667eea;
  color: #fff;
}
.btn-danger:hover { background: #ee5a5a; }

.account-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-primary);
  margin-bottom: 12px;
}

.account-card.current {
  border-color: var(--text-accent);
  background: var(--bg-account-switch);
}

/* Danger Zone Card */
.danger-zone {
  border: 2px solid var(--danger-text);
  
}

/* --- Modals --- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(5px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

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

/* Modal base */
.modal {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: 0 10px 44px rgba(0,0,0,0.2);
  padding: 40px 36px 32px 36px;
  max-width: 440px;
  width: 96vw;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border: 1.5px solid var(--border-primary);
  gap: 20px;
}

.modal-title {
  font-size: 1.23rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 7px;
  display: block;
}

.form-input {
  width: 100%;
  padding: 13px 16px;
  border: 1.8px solid var(--border-primary);
  border-radius: 10px;
  font-size: 1rem;
  background: var(--bg-quaternary);
  color: var(--text-primary);
  margin-top: 3px;
}

.form-input:focus {
  outline: none;
  border-color: var(--text-accent);
}

.modal-buttons {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
  margin-top: 18px;
}

.backup-section, .warning-box, .confirmation-section {
  margin-bottom: 18px;
}

.warning-box ul, .backup-section ul {
  margin-top: 7px;
  margin-bottom: 7px;
}

@media (max-width: 600px) {
  .modal {
    padding: 18px 5vw 16px 5vw;
    max-width: 99vw;
    gap: 13px;
  }
  .modal-title {
    margin-bottom: 13px;
  }
  .modal-buttons {
    margin-top: 10px;
  }
}


/* Mobile view adjustments */
@media (max-width: 600px) {

  /* Sidebar adjustments */
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-radius: 0;
    box-shadow: none;
  }
  .sidebar-header {
    flex-direction: row;
    justify-content: flex-start;
    padding: 10px;
  }
  .sidebar-header img {
    width: 40px;
    height: 40px;
    margin-right: 10px;
  }
  .sidebar-header h2 {
    font-size: 1.25rem;
  }
  .nav-menu {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
  }
  .nav-menu li {
    flex: 0 0 auto;
    margin-right: 15px;
  }
  .nav-link span {
    display: none; /* show icon only on mobile in nav */
  }
  .nav-link {
    padding: 10px 5px;
  }

  /* Sidebar footer adjustments */
  .sidebar-footer {
    display: flex;
    justify-content: space-between;
    padding: 10px;
  }
  .user-avatar {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  /* Main content adjustments */
  .main-content {
    margin-left: 0;
    padding: 10px;
  }

  /* Dashboard grid adjustments */
  .dashboard-grid {
    grid-template-columns: 1fr; /* single column layout */
    gap: 15px;
  }

  /* Stats card sizing */
  .stats-card {
    padding: 15px;
  }

  /* Buttons and quick actions */
  .quick-actions {
    flex-wrap: wrap;
    gap: 10px;
  }
  .action-btn {
    flex: 1 1 48%;
    font-size: 14px;
    padding: 10px;
  }
  
  /* Account switcher */
  .account-switcher {
    flex-direction: column;
    gap: 5px;
  }
  .account-btn {
    width: 100%;
    font-size: 14px;
  }
  
  /* User info at top */
  .user-info {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 768px) {
  .settings-container {
    padding: 0 3vw;
    max-width: 100vw;
    gap: 40px;
  }
  .settings-section,
  .header {
    padding: 28px 15px;
    margin-bottom: 22px;
    border-radius: 22px;
  }
  .header {
    flex-direction: column;
    gap: 24px;
    padding-bottom: 22px;
    align-items: flex-start;
  }
  .section-title {
    font-size: 1.13rem;
    margin-bottom: 20px;
    color: var(--text-primary);
  }
  .setting-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
    padding: 32px 0;
  }
  .setting-info {
    margin-bottom: 12px;
    font-size: 16px;
    width: 100%;
  }
  .btn,
  .btn-primary,
  .btn-secondary,
  .btn-danger,
  .btn-success {
    width: 100%;
    font-size: 16px;
    margin-top: 12px;
    padding: 16px 0;
  }
  .modal {
    padding: 32px 9vw 28px 9vw;
    gap: 26px;
    border-radius: 18px;
  }
  .account-card {
    flex-direction: column;
    align-items: flex-start;
    padding: 26px 16px;
    gap: 14px;
    margin-bottom: 22px;
    border-radius: 16px;
  }
}

@media (max-width: 600px) {
  .settings-container {
    padding: 0 1vw;
    gap: 38px;
  }
  .settings-section,
  .header {
    padding: 18px 8px;
    margin-bottom: 14px;
    border-radius: 13px;
  }
  .modal {
    padding: 16px 3vw 14px 3vw;
    gap: 18px;
    border-radius: 13px;
  }
  .section-title {
    font-size: 1.03rem;
    margin-bottom: 14px;
  }
  .setting-item {
    padding: 18px 0;
    gap: 12px;
  }
}

#feedbackForm textarea {
    font-size: 15px;
    background: #f8f9fa;
}
#feedbackMsg {
    color: #2cbb5d;
}

