/* ===== CSS Variables - Mono Minimalistic Theme ===== */
:root {
  --bg-primary: #000000;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #2d2d2d;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  --border-color: #333333;
  --accent-color: #00d4ff;
  --success-color: #00cc00;
  --error-color: #ff4444;
  --warning-color: #ffaa00;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.6);
  --border-radius: 4px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Base Styles ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Header ===== */
.app-header {
  background: var(--bg-secondary);
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-branding {
  margin-bottom: 0.25rem;
}

.header-left h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.5px;
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.user-greeting {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle-btn,
.settings-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.theme-toggle-btn:hover,
.settings-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.logout-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.logout-btn:hover {
  border-color: var(--error-color);
  color: var(--error-color);
  background: rgba(255, 68, 68, 0.05);
}

/* ===== Dashboard Grid ===== */
.dashboard {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}


/* ===== Cards ===== */
.card {
  background: white;
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  border: 1px solid #f0f0f0;
}

.card:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.card-header {
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.card h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-dark);
  cursor: pointer;
  user-select: none;
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.1);
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  color: var(--text-primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.card h2:hover {
  color: var(--accent-color);
}

.card h2:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
  border-radius: 4px;
}

.card-toggle-icon {
  font-size: 1.2rem;
  color: var(--text-secondary);
  transition: var(--transition);
}

.income-card {
  border-left: 3px solid #27ae60;
}

.income-card:hover {
  border-left-color: #2ecc71;
}

.expenses-card {
  border-left: 3px solid #f39c12;
}

.expenses-card:hover {
  border-left-color: #f1c40f;
}

.loans-card {
  border-left: 3px solid #e74c3c;
}

.loans-card:hover {
  border-left-color: #ec7063;
}

.card-body {
  margin-top: 1rem;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
  }
  to {
    opacity: 1;
    max-height: 1000px;
  }
}

/* ===== Form Elements ===== */
.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-family: inherit;
  transition: var(--transition);
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

.form-input:hover {
  border-color: var(--text-secondary);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.1);
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.add-expense h4,
.add-loan h4 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: var(--text-primary);
  font-weight: 700;
}

.large-text {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-color);
  margin: 0;
}

.income-display {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
}

.btn {
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.btn-primary {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.btn-primary:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-color);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}

.btn-success {
  background: transparent;
  color: #27ae60;
  border-color: #27ae60;
  width: 100%;
}

.btn-success:hover {
  background: rgba(39, 174, 96, 0.1);
  border-color: #2ecc71;
  color: #2ecc71;
}

.btn-info {
  color: var(--accent-color);
  border-color: var(--accent-color);
  width: 100%;
}

.btn-info:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: var(--accent-color);
}

/* ===== Income / Expenses ===== */
#income {
  font-size: 1.5rem;
  font-weight: 700;
  color: #27ae60;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--bg-tertiary);
  font-size: 0.95rem;
  color: var(--text-secondary);
}

li:last-child {
  border-bottom: none;
}

li:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.total {
  margin-top: 1.5rem;
  font-weight: 700;
  text-align: right;
  font-size: 1.2rem;
  color: var(--accent-color);
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

/* ===== Expenses Container ===== */
.expenses-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.expense-item {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  transition: var(--transition);
  background: var(--bg-tertiary);
}

.expense-item:hover {
  border-color: var(--accent-color);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.1);
}

.expense-header {
  display: flex;
  align-items: center;
}

.expense-toggle-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 1rem;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.expense-toggle-btn::after {
  content: "−";
  display: inline-block;
  font-weight: bold;
  font-size: 1.2rem;
  color: var(--accent-color);
  transition: transform 0.3s ease;
}

.expense-toggle-btn.collapsed::after {
  content: "+";
  transform: rotate(0deg);
}

.expense-toggle-btn:hover {
  color: var(--accent-color);
}

.expense-toggle-btn:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: -2px;
}

.expense-body {
  background: var(--bg-secondary);
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  display: none;
  animation: slideDown 0.3s ease;
}

.expense-body.open {
  display: block;
}

.expense-body p {
  margin: 0.75rem 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.expense-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

.edit-expense-btn {
  background: transparent;
  color: var(--accent-color);
  border: 1px solid var(--accent-color);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.edit-expense-btn:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: var(--accent-color);
}

.edit-expense-btn:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

#editForm-food,
#editForm-utilities,
#editForm-entertainment,
#editForm-transportation,
#editForm-groceries,
#editForm-other {
  background: var(--bg-secondary);
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto auto;
  gap: 0.75rem;
  border: 1px solid var(--border-color);
}

#editForm-food input,
#editForm-utilities input,
#editForm-entertainment input,
#editForm-transportation input,
#editForm-groceries input,
#editForm-other input,
#editForm-food select,
#editForm-utilities select,
#editForm-entertainment select,
#editForm-transportation select,
#editForm-groceries select,
#editForm-other select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  transition: var(--transition);
  margin-bottom: 0;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

#editForm-food input::placeholder,
#editForm-utilities input::placeholder,
#editForm-entertainment input::placeholder,
#editForm-transportation input::placeholder,
#editForm-groceries input::placeholder,
#editForm-other input::placeholder {
  color: var(--text-tertiary);
}

#editForm-food input:focus,
#editForm-utilities input:focus,
#editForm-entertainment input:focus,
#editForm-transportation input:focus,
#editForm-groceries input:focus,
#editForm-other input:focus,
#editForm-food select:focus,
#editForm-utilities select:focus,
#editForm-entertainment select:focus,
#editForm-transportation select:focus,
#editForm-groceries select:focus,
#editForm-other select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.1);
}

#editForm-food button,
#editForm-utilities button,
#editForm-entertainment button,
#editForm-transportation button,
#editForm-groceries button,
#editForm-other button {
  margin: 0;
}

/* ===== Loans Table ===== */
.loans-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1rem 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
}

thead {
  background: var(--bg-tertiary);
  position: sticky;
  top: 0;
}

th {
  padding: 1rem;
  text-align: left;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

tbody tr {
  transition: var(--transition);
}

tbody tr:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

tbody tr:last-child td {
  border-bottom: none;
}

.add-loan {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
  margin: 1.5rem 0;
  border: 1px solid var(--border-color);
}

.add-expense {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  margin: 1.5rem 0;
}

.add-expense input,
.add-expense select {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  transition: var(--transition);
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.add-expense input::placeholder {
  color: var(--text-tertiary);
}

.add-expense input:focus,
.add-expense select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.1);
}

@media (max-width: 1000px) {
  .add-expense {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 800px) {
  .add-loan {
    grid-template-columns: 1fr 1fr;
  }
  
  .add-expense {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .add-loan {
    grid-template-columns: 1fr;
  }
  
  .add-expense {
    grid-template-columns: 1fr;
  }
}

/* ===== Form Inputs ===== */
input {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  font-size: 0.95rem;
  background: var(--bg-tertiary);
  transition: var(--transition);
  font-family: inherit;
  color: var(--text-primary);
}

input::placeholder {
  color: var(--text-tertiary);
}

input:hover {
  border-color: var(--text-secondary);
}

input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.1);
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

/* ===== Buttons ===== */
button {
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-weight: 600;
  background: transparent;
  color: var(--text-secondary);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Save button */
.save-btn {
  background: transparent;
  color: var(--accent-color);
  border-color: var(--accent-color);
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.save-btn:hover:not(:disabled) {
  background: rgba(0, 212, 255, 0.1);
  border-color: var(--accent-color);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}
.save-btn:active {
  transform: translateY(0);
}

/* Close/Delete button */
.close-btn {
  background-color: transparent;
  color: #e74c3c;
  border-color: #e74c3c;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  min-width: auto;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.close-btn:hover:not(:disabled) {
  background: rgba(231, 76, 60, 0.1);
  border-color: #ec7063;
  color: #ec7063;
}

button:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* ===== Balance Card ===== */
.balance {
  position: sticky;
  top: 100px;
  z-index: 20;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.balance h2 {
  margin-bottom: 1rem;
}

#balance {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -1px;
}

.positive {
  color: #27ae60;
}

.negative {
  color: #e74c3c;
}

/* ===== Notifications ===== */
.notification {
  position: fixed;
  top: 100px;
  right: 1rem;
  padding: 1rem 1.5rem;
  border-radius: var(--border-radius);
  color: white;
  font-weight: 600;
  z-index: 1000;
  animation: slideInRight 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  border: 1px solid var(--border-color);
}

.notification-error {
  background: #e74c3c;
  border-color: #ec7063;
}

.notification-success {
  background: #27ae60;
  border-color: #2ecc71;
}

@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .app-header {
    padding: 1rem;
    flex-wrap: wrap;
  }
  
  .app-header h1 {
    font-size: 1.25rem;
    flex-basis: 100%;
  }
  
  .logout-btn {
    flex-basis: auto;
  }
  
  .dashboard {
    margin: 1rem auto;
    padding-bottom: 150px;
  }
  
  .balance {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    border-radius: 1rem 1rem 0 0;
    margin: 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.2);
  }
  
  .notification {
    right: 0.5rem;
    left: 0.5rem;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .app-header h1 {
    font-size: 1.1rem;
  }
  
  .card {
    padding: 1.25rem;
  }
  
  #balance {
    font-size: 2rem;
  }
  
  .add-loan {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
}

/* ===== Financial Health Card ===== */
.financial-health {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.health-metric {
  background: var(--bg-tertiary);
  padding: 1.25rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.health-metric:hover {
  transform: translateY(-4px);
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.1);
}

.metric-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.75rem 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #27ae60, #2ecc71);
  transition: width 0.5s ease;
  border-radius: 4px;
  width: 0%;
}

.progress-bar.danger .progress-fill {
  background: linear-gradient(90deg, #e74c3c, #ec7063);
}

.metric-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}

.metric-large {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-color);
  text-align: center;
  letter-spacing: -0.5px;
}

.health-score {
  font-size: 2rem;
  font-weight: 800;
  text-align: center;
  padding: 1rem;
  border-radius: var(--border-radius);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.health-score.excellent {
  border-color: #27ae60;
  color: #27ae60;
}

.health-score.good {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.health-score.fair {
  border-color: #f39c12;
  color: #f39c12;
}

.health-score.poor {
  border-color: #e74c3c;
  color: #e74c3c;
}

.health-tips {
  background: var(--bg-tertiary);
  padding: 1rem;
  border-left: 3px solid var(--accent-color);
  border-radius: var(--border-radius);
  margin-top: 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.health-tips strong {
  color: var(--accent-color);
}

/* ===== Modal Styles ===== */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
  backdrop-filter: blur(2px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-primary);
}

.close-modal-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  color: var(--text-secondary);
  transition: var(--transition);
}

.close-modal-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.preference-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.preference-section:last-child {
  border-bottom: none;
}

.preference-section h3 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: var(--text-primary);
  font-weight: 700;
}

.preference-section .form-group {
  margin-bottom: 1rem;
}

.preference-section input[type="text"],
.preference-section select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  margin-bottom: 0.5rem;
  transition: var(--transition);
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.preference-section input[type="text"]::placeholder {
  color: var(--text-tertiary);
}

.preference-section input:focus,
.preference-section select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.1);
}

/* Theme Options */
.theme-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

.theme-option {
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-tertiary);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: var(--transition);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.theme-option:hover {
  border-color: var(--accent-color);
  background: var(--bg-secondary);
}

.theme-option.active {
  border-color: var(--accent-color);
  background: transparent;
  color: var(--accent-color);
}

/* Checkbox Labels */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent-color);
}

/* Small Button */
.small-btn {
  width: auto;
  padding: 0.75rem 1.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Dark Theme Support */
body.dark-theme {
  background: linear-gradient(180deg, #0a0a0a, #0f0f0f);
  color: var(--text-primary);
}

body.dark-theme .app-header {
  background: var(--bg-secondary);
  border-bottom-color: var(--border-color);
}

body.dark-theme .header-left h1 {
  color: var(--text-primary);
}

body.dark-theme .user-greeting {
  color: var(--text-secondary);
}

body.dark-theme .theme-toggle-btn:hover,
body.dark-theme .settings-btn:hover {
  background: var(--bg-tertiary);
}

body.dark-theme .card {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

body.dark-theme .card h2 {
  color: var(--text-primary);
}

body.dark-theme .modal {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

body.dark-theme .modal-header {
  border-bottom-color: var(--border-color);
}

body.dark-theme .preference-section {
  border-bottom-color: var(--border-color);
}

body.dark-theme .preference-section input[type="text"],
body.dark-theme .preference-section select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

body.dark-theme .theme-option {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

body.dark-theme .theme-option:hover {
  border-color: var(--accent-color);
  background: var(--bg-secondary);
}

/* Light Theme */
body.light-theme {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f0f1f4;
  --text-primary: #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-tertiary: #8a8a8a;
  --border-color: #d8d8d8;
  --accent-color: #0099cc;
  background: linear-gradient(180deg, #f8f9fa, #ffffff);
}

body.light-theme {
  color: var(--text-primary);
}

body.light-theme .app-header {
  background: #ffffff;
  border-bottom-color: var(--border-color);
}

body.light-theme .app-header h1 {
  color: var(--text-primary);
}

body.light-theme .theme-toggle-btn,
body.light-theme .settings-btn {
  border-color: var(--border-color);
  color: var(--text-secondary);
}

body.light-theme .theme-toggle-btn:hover,
body.light-theme .settings-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

body.light-theme .logout-btn {
  border-color: var(--border-color);
  color: var(--text-secondary);
}

body.light-theme .logout-btn:hover {
  border-color: #e74c3c;
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.05);
}

body.light-theme .card {
  background: #ffffff;
  border-color: var(--border-color);
}

body.light-theme .card:hover {
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(0, 153, 204, 0.1);
}

body.light-theme .card h2 {
  color: var(--text-primary);
}

body.light-theme .card h2:hover {
  color: var(--accent-color);
}

body.light-theme .card-toggle-icon {
  color: var(--text-secondary);
}

body.light-theme .income-card,
body.light-theme .expenses-card,
body.light-theme .loans-card {
  background: #ffffff;
}

body.light-theme .expense-item {
  background: #f8f9fa;
  border-color: var(--border-color);
}

body.light-theme .expense-item:hover {
  border-color: var(--accent-color);
}

body.light-theme .expense-toggle-btn {
  color: var(--text-primary);
}

body.light-theme .expense-toggle-btn::after {
  color: var(--accent-color);
}

body.light-theme .expense-body {
  background: #ffffff;
  border-top-color: var(--border-color);
}

body.light-theme .form-input {
  background: #ffffff;
  border-color: var(--border-color);
  color: var(--text-primary);
}

body.light-theme .form-input::placeholder {
  color: var(--text-tertiary);
}

body.light-theme .form-input:hover {
  border-color: var(--text-secondary);
}

body.light-theme .form-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 153, 204, 0.1);
}

body.light-theme .form-label {
  color: var(--text-secondary);
}

body.light-theme .btn {
  border-color: var(--border-color);
  color: var(--text-secondary);
}

body.light-theme .btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-primary);
  color: var(--text-primary);
}

body.light-theme .btn-primary {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

body.light-theme .btn-primary:hover {
  background: rgba(0, 153, 204, 0.05);
  box-shadow: 0 0 12px rgba(0, 153, 204, 0.15);
}

body.light-theme .btn-success {
  border-color: #27ae60;
  color: #27ae60;
}

body.light-theme .btn-success:hover {
  background: rgba(39, 174, 96, 0.05);
  border-color: #2ecc71;
  color: #2ecc71;
}

body.light-theme .btn-info {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

body.light-theme .btn-info:hover {
  background: rgba(0, 153, 204, 0.05);
}

body.light-theme .edit-expense-btn {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

body.light-theme .edit-expense-btn:hover {
  background: rgba(0, 153, 204, 0.05);
}

body.light-theme .loans-table {
  background: #ffffff;
  border-color: var(--border-color);
}

body.light-theme thead {
  background: #f8f9fa;
}

body.light-theme th {
  color: var(--text-primary);
  border-bottom-color: var(--border-color);
}

body.light-theme td {
  color: var(--text-secondary);
  border-bottom-color: var(--border-color);
}

body.light-theme tbody tr:hover {
  background-color: #f0f1f4;
  color: var(--text-primary);
}

body.light-theme .add-loan,
body.light-theme .add-expense {
  background: #f8f9fa;
  border-color: var(--border-color);
}

body.light-theme .add-expense input,
body.light-theme .add-expense select {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border-color);
}

body.light-theme .add-expense input::placeholder {
  color: var(--text-tertiary);
}

body.light-theme .modal {
  background: #ffffff;
  border-color: var(--border-color);
}

body.light-theme .modal-overlay {
  background: rgba(0, 0, 0, 0.4);
}

body.light-theme .modal-header {
  border-bottom-color: var(--border-color);
}

body.light-theme .modal-header h2 {
  color: var(--text-primary);
}

body.light-theme .close-modal-btn {
  color: var(--text-secondary);
}

body.light-theme .close-modal-btn:hover {
  color: var(--text-primary);
}

body.light-theme .preference-section {
  border-bottom-color: var(--border-color);
}

body.light-theme .preference-section h3 {
  color: var(--text-primary);
}

body.light-theme .preference-section input[type="text"],
body.light-theme .preference-section select {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border-color);
}

body.light-theme .preference-section input[type="text"]::placeholder {
  color: var(--text-tertiary);
}

body.light-theme .preference-section input:focus,
body.light-theme .preference-section select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 153, 204, 0.1);
}

body.light-theme .theme-option {
  background: #f8f9fa;
  border-color: var(--border-color);
  color: var(--text-secondary);
}

body.light-theme .theme-option:hover {
  background: #f0f1f4;
  border-color: var(--accent-color);
}

body.light-theme .theme-option.active {
  color: var(--accent-color);
  border-color: var(--accent-color);
  background: transparent;
}

body.light-theme .checkbox-label {
  color: var(--text-secondary);
}

body.light-theme .notification {
  border-color: var(--border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.light-theme .balance {
  background: #ffffff;
  border-color: var(--border-color);
}

body.light-theme .balance h2 {
  color: var(--text-primary);
}

body.light-theme #balance {
  color: var(--accent-color);
}

body.light-theme .positive {
  color: #27ae60;
}

body.light-theme .negative {
  color: #e74c3c;
}

body.light-theme .financial-health {
  background: #ffffff;
  border-color: var(--border-color);
}

body.light-theme .health-metric {
  background: #f8f9fa;
  border-color: var(--border-color);
}

body.light-theme .health-metric:hover {
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(0, 153, 204, 0.1);
}

body.light-theme .metric-label {
  color: var(--text-secondary);
}

body.light-theme .metric-value,
body.light-theme .metric-large {
  color: var(--accent-color);
}

body.light-theme .progress-bar {
  background: var(--border-color);
}

body.light-theme .health-score {
  background: #f8f9fa;
  color: var(--text-primary);
  border-color: var(--border-color);
}

body.light-theme .health-tips {
  background: #f8f9fa;
  border-left-color: var(--accent-color);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

body.light-theme .health-tips strong {
  color: var(--accent-color);
}

body.light-theme .total {
  background: #f8f9fa;
  border-color: var(--border-color);
  color: var(--accent-color);
}

/* ===== Print Styles ===== */
@media print {
  .app-header,
  .logout-btn,
  .add-loan button,
  .close-btn {
    display: none;
  }
  
  body {
    background: white;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid var(--border-color);
    page-break-inside: avoid;
  }
}

/* ===== Utility Classes ===== */
.closed {
  color: var(--text-light);
  text-decoration: line-through;
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }