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

/* ========================================
   CSS Variables for Light/Dark Mode
   ======================================== */

:root {
  /* Light Mode Colors (Default) */
  --bg-gradient-start: #94a3b8;
  --bg-gradient-end: #64748b;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;

  --text-primary: #333333;
  --text-secondary: #666666;
  --text-tertiary: #64748b;
  --text-muted: #94a3b8;

  --border-color: #e2e8f0;
  --border-color-hover: #cbd5e1;

  --btn-primary-bg: #64748b;
  --btn-primary-hover: #475569;
  --btn-secondary-bg: #94a3b8;
  --btn-secondary-hover: #64748b;

  --success-color: #4ade80;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* Dark Mode Colors */
[data-theme="dark"] {
  --bg-gradient-start: #1e293b;
  --bg-gradient-end: #0f172a;
  --bg-primary: #1e293b;
  --bg-secondary: #334155;
  --bg-tertiary: #475569;

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --text-muted: #64748b;

  --border-color: #475569;
  --border-color-hover: #64748b;

  --btn-primary-bg: #64748b;
  --btn-primary-hover: #94a3b8;
  --btn-secondary-bg: #475569;
  --btn-secondary-hover: #64748b;

  --success-color: #22c55e;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  min-height: 100vh;
  padding: 20px;
  color: var(--text-primary);
  transition: background 0.3s ease, color 0.3s ease;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

/* Header */
header {
  background: var(--bg-primary);
  padding: 24px 30px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  margin-bottom: 24px;
  transition: all 0.3s ease;
  border: 1px solid var(--border-color);
}

header:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

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

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 48px;
  height: 48px;
  color: var(--btn-primary-bg);
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: scale(1.05);
}

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

.brand-text h1 {
  color: var(--text-primary);
  font-size: 1.75rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0;
  font-weight: 500;
}

.header-period {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

h1 {
  color: var(--text-tertiary);
  font-size: 2rem;
  margin-bottom: 10px;
}

.budget-period {
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  display: inline-block;
  margin: 0 auto;
}

.budget-period-notes {
  display: none;
  align-items: center;
  gap: 6px;
  max-width: 300px;
}

.budget-period-notes.visible {
  display: flex;
}

.budget-notes-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.budget-notes-edit-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  opacity: 0.6;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.budget-notes-edit-btn:hover {
  opacity: 1;
  color: var(--text-primary);
}

.budget-notes-input {
  font-size: 0.85rem;
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 240px;
  font-style: italic;
}

.budget-notes-input:focus {
  outline: none;
  border-color: var(--btn-primary-bg);
  box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.15);
}

.btn-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.btn-header svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-header:hover {
  background: var(--bg-tertiary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

.btn-header-primary {
  background: linear-gradient(135deg, var(--btn-primary-bg) 0%, var(--btn-primary-hover) 100%);
  color: white;
  border-color: transparent;
}

.btn-header-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
}

.funds-summary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  border-radius: 12px;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: stretch;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
  transition: all 0.3s ease;
}

.funds-summary:has(.funds-value.zero) {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.funds-arrow {
  font-size: 1.5rem;
  color: rgba(255, 255, 255, 0.5);
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.funds-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  transition: all 0.2s ease;
  text-align: center;
}

.funds-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.15);
}

.funds-remaining {
  background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.funds-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.95);
  margin-bottom: 8px;
  font-weight: 600;
}

.funds-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 5px;
}

.funds-value.positive {
  color: #fde68a;
}

.funds-value.zero {
  color: #a7f3d0;
}

.funds-value.negative {
  color: #fca5a5;
}

.funds-value.neutral {
  color: #ffffff;
}

.funds-status {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  margin-top: 4px;
  font-style: italic;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.btn-primary {
  background: linear-gradient(135deg, var(--btn-primary-bg) 0%, var(--btn-primary-hover) 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(100, 116, 139, 0.3);
}

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

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.9rem;
  min-height: auto;
}

/* Main Content */
main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

section {
  background: var(--bg-primary);
  padding: 28px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  border: 1px solid var(--border-color);
}

section:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}

/* Add Expense Form */
.add-expense-section form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.floating-label {
  position: relative;
  margin-top: 8px;
}

.form-group.floating-label input,
.form-group.floating-label select {
  padding: 18px 12px 8px 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.form-group.floating-label input:focus,
.form-group.floating-label select:focus {
  outline: none;
  border-color: var(--btn-primary-bg);
}

.form-group.floating-label label {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 400;
  pointer-events: none;
  transition: all 0.2s ease;
  background: var(--bg-primary);
  padding: 0 4px;
}

/* Float label when input is focused or has value */
.form-group.floating-label input:focus + label,
.form-group.floating-label input:not(:placeholder-shown) + label,
.form-group.floating-label select:focus + label,
.form-group.floating-label select:valid + label {
  top: 0;
  transform: translateY(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--btn-primary-bg);
}

/* Handle select specifically */
.form-group.floating-label select:not(:invalid) + label {
  top: 0;
  transform: translateY(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--btn-primary-bg);
}

label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

input, select {
  padding: 12px 14px;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.2s, background 0.3s ease, color 0.3s ease;
  min-height: 48px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--text-tertiary);
}

/* Categories Grid */
/* Budget sections */
.budget-section {
  margin-bottom: 35px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.budget-section:last-child {
  border-bottom: none;
}

.section-header {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--text-tertiary);
  word-wrap: break-word;
}

.categories-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 15px;
}

.category-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  transition: all 0.25s ease;
  overflow: hidden;
  word-wrap: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: var(--btn-primary-bg);
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.category-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #374151;
  word-wrap: break-word;
  overflow-wrap: break-word;
  flex: 1;
  min-width: 0;
}

.spend-period-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.period-15th {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #78350f;
  box-shadow: 0 2px 4px rgba(251, 191, 36, 0.3);
}

.period-30th {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.category-notes {
  font-size: 0.82rem;
  color: #6b7280;
  font-style: italic;
  margin-bottom: 12px;
  padding: 6px 10px;
  background: #f3f4f6;
  border-radius: 4px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.category-progress {
  margin: 12px 0;
}

.progress-bar {
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.progress-fill.safe {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.progress-fill.warning {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.progress-fill.overspent {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.progress-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: right;
}

.category-amounts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.95rem;
}

.amount-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.amount-label {
  color: #6b7280;
  flex-shrink: 0;
}

.amount-value {
  font-weight: 600;
  text-align: right;
  word-wrap: break-word;
}

.remaining {
  font-size: 1.2rem;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 2px solid #e5e7eb;
}

.remaining.positive {
  color: #84a98c;
}

.remaining.warning {
  color: #f59e0b;
}

.remaining.negative {
  color: #ef4444;
}

/* Section subtotals */
.section-subtotal {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  border: 2px solid #64748b;
  border-radius: 8px;
  padding: 15px 20px;
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.subtotal-label {
  font-weight: 700;
  font-size: 1.1rem;
  color: #ffffff;
  min-width: 100px;
}

.subtotal-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 0.95rem;
}

.subtotal-item {
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
}

.subtotal-item.positive {
  color: #a7f3d0;
}

.subtotal-item.negative {
  color: #fca5a5;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #6b7280;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: var(--bg-primary);
  padding: 30px;
  border-radius: 12px;
  max-width: 900px;
  width: 95%;
  max-height: 95vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease;
}

.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: var(--btn-primary-bg);
  border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: var(--btn-primary-hover);
}

.modal-content h2 {
  margin-bottom: 20px;
}

/* Enhanced Modal Header */
.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-color);
}

.modal-header-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--btn-primary-bg);
  color: white;
  border-radius: 8px;
  flex-shrink: 0;
}

.modal-header-icon svg {
  width: 20px;
  height: 20px;
}

.modal-header-content {
  flex: 1;
}

.modal-header-content h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-primary);
}

.modal-header-content p {
  margin: 4px 0 0 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Template selection */
.template-selection {
  background: var(--bg-secondary);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  border: 2px solid var(--border-color);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.template-selection h3 {
  font-size: 1rem;
  margin: 0 0 10px 0;
  color: #374151;
}

.template-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.template-buttons .btn {
  flex: 1;
  padding: 10px 15px;
  font-size: 0.9rem;
}

.template-dropdown {
  width: 100%;
  padding: 10px;
  border: 2px solid #64748b;
  border-radius: 6px;
  font-size: 0.95rem;
  margin-top: 10px;
  background: white;
}

/* Form sections for reset budget */
.form-section {
  margin-bottom: 25px;
  padding: 15px;
  background: #f9fafb;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
}

.section-label {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  color: #374151;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid #64748b;
  word-wrap: break-word;
}

.categories-input-section {
  margin-bottom: 10px;
}

.category-input-row {
  display: grid;
  grid-template-columns: 2fr 1fr auto 2fr;
  gap: 8px;
  margin-bottom: 10px;
}

.category-input-row input,
.category-input-row select {
  min-width: 0;
  width: 100%;
}

.category-input-row .cat-spend-period {
  min-width: 80px;
  max-width: 100px;
}

.allocation-summary {
  background: #f9fafb;
  padding: 15px;
  border-radius: 8px;
  margin: 15px 0;
  border: 2px solid #e5e7eb;
  overflow: hidden;
}

.allocation-summary.over-budget {
  background: #fef2f2;
  border-color: #ef4444;
}

.allocation-summary.under-budget {
  background: #fef9e7;
  border-color: #f59e0b;
}

.validation-success {
  margin-top: 12px;
  padding: 12px;
  background: #d1fae5;
  border: 2px solid #84a98c;
  border-radius: 6px;
  color: #065f46;
  font-weight: 700;
  text-align: center;
}

.validation-warning {
  margin-top: 12px;
  padding: 12px;
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: 6px;
  color: #92400e;
  font-weight: 700;
  text-align: center;
}

.validation-error {
  margin-top: 12px;
  padding: 12px;
  background: #fee2e2;
  border: 2px solid #ef4444;
  border-radius: 6px;
  color: #991b1b;
  font-weight: 700;
  text-align: center;
}

.allocation-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.95rem;
  flex-wrap: wrap;
}

.allocation-row:last-child {
  margin-bottom: 0;
  padding-top: 8px;
  border-top: 2px solid #e5e7eb;
  font-weight: 700;
  font-size: 1.05rem;
}

.allocation-value.positive {
  color: #84a98c;
}

.allocation-value.zero {
  color: #64748b;
  font-weight: 700;
}

.allocation-value.negative {
  color: #ef4444;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions .btn {
  flex: 1;
}

/* Mobile Responsive */
/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  header {
    padding: 16px;
  }

  .header-top {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 12px;
  }

  .header-brand {
    justify-content: center;
  }

  .header-period {
    margin-bottom: 12px;
  }

  .header-actions {
    justify-content: center;
    flex-wrap: wrap;
  }

  .btn-header {
    flex: 1 1 auto;
    min-width: 110px;
    justify-content: center;
  }

  .brand-text h1 {
    font-size: 1.5rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  section {
    padding: 20px;
  }

  .funds-summary {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .funds-arrow {
    transform: rotate(90deg);
    font-size: 1.2rem;
  }


  .section-subtotal {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .subtotal-amounts {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .category-input-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .modal-content {
    padding: 20px;
    width: 98%;
    max-height: 98vh;
  }

  .template-buttons {
    flex-direction: column;
  }

  .form-section {
    padding: 12px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.3rem;
  }

  .section-header {
    font-size: 1.1rem;
  }

  .category-card {
    padding: 15px;
  }

  .funds-value {
    font-size: 1.3rem;
  }

  .btn {
    padding: 10px 18px;
    font-size: 0.95rem;
  }
}

/* Confirmation dialog */
.confirmation-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 2000;
  max-width: 450px;
  width: 90%;
}

.confirmation-dialog h3 {
  margin: 0 0 15px 0;
  color: #374151;
  font-size: 1.2rem;
}

.confirmation-dialog p {
  margin: 0 0 20px 0;
  color: #6b7280;
  line-height: 1.6;
}

.confirmation-dialog .warning {
  background: #fef2f2;
  border: 2px solid #ef4444;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 20px;
  color: #991b1b;
  font-weight: 600;
}

.confirmation-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.confirmation-actions .btn {
  min-width: 100px;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1999;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.category-card {
  animation: fadeIn 0.3s ease-out;
}

/* Animations */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Edit Allocation Modal */
.edit-allocation-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 2000;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.edit-allocation-modal h3 {
  margin: 0 0 20px 0;
  color: #374151;
  font-size: 1.3rem;
  border-bottom: 2px solid #64748b;
  padding-bottom: 10px;
}

.edit-allocation-info {
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 0.95rem;
}

.info-row:not(:last-child) {
  border-bottom: 1px solid #e5e7eb;
}

.info-value {
  font-weight: 700;
  color: #374151;
}

.info-value.zero {
  color: #84a98c;
}

.info-value.warning {
  color: #f59e0b;
}

.info-value.danger {
  color: #ef4444;
}

.edit-allocation-btn {
  width: 100%;
  margin-top: 12px;
  background: #64748b;
  color: white;
}

.edit-allocation-btn:hover {
  background: #5568d3;
}

#edit-validation-message {
  margin: 15px 0;
  min-height: 45px;
}

/* Mobile Responsive for Edit Modal */
@media (max-width: 768px) {
  .edit-allocation-modal {
    padding: 20px;
    width: 95%;
  }

  .edit-allocation-modal h3 {
    font-size: 1.1rem;
  }
}

/* ========================================
   Settings Modal & Backup Styles
   ======================================== */

.settings-modal-content {
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
}

.settings-section {
  margin-bottom: 30px;
}

.settings-section h3 {
  color: #64748b;
  font-size: 1.2rem;
  margin-bottom: 20px;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 10px;
}

.settings-section h4 {
  color: #64748b;
  font-size: 1rem;
  margin-bottom: 15px;
}

/* Backup Status Card */
.backup-status-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 15px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #e2e8f0;
}

.status-row:last-child {
  border-bottom: none;
}

.status-label {
  font-weight: 600;
  color: #64748b;
  font-size: 0.95rem;
}

.status-value {
  color: #1e293b;
  font-size: 0.95rem;
}

#backup-status-indicator {
  font-weight: 600;
}

/* Backup Browser */
.backup-browser {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
}

.backup-list {
  max-height: 300px;
  overflow-y: auto;
}

.loading-text {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
  margin: 0;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Individual Backup Items */
.backup-item {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 10px;
  background: #f8fafc;
  transition: all 0.2s ease;
  gap: 10px;
}

.backup-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.backup-info {
  flex: 1;
}

.backup-date {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 5px;
}

.backup-details {
  font-size: 0.85rem;
  color: #64748b;
}

/* Backup Browser Header */
.backup-browser-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.backup-browser-header h4 {
  margin: 0;
}

/* Select All Checkbox */
.backup-select-all {
  padding: 10px 15px;
  background: #f1f5f9;
  border-radius: 6px;
  margin-bottom: 10px;
}

.backup-select-all .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #64748b;
}

.backup-select-all input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Backup Item with Checkbox */
.backup-checkbox {
  display: flex;
  align-items: center;
  margin-right: 12px;
}

.backup-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Backup Actions */
.backup-actions {
  display: flex;
  gap: 8px;
}

.btn-delete-backup {
  background: transparent;
  color: #ef4444;
  border: 1px solid #ef4444;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-delete-backup:hover {
  background: #ef4444;
  color: white;
}

/* Delete Selected Button */
#delete-selected-btn {
  font-size: 0.85rem;
  padding: 6px 12px;
}

#delete-selected-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Dark mode for backup delete UI */
.dark-mode .backup-select-all {
  background: #1e293b;
}

.dark-mode .backup-select-all .checkbox-label {
  color: #94a3b8;
}

.dark-mode .btn-delete-backup {
  color: #f87171;
  border-color: #f87171;
}

.dark-mode .btn-delete-backup:hover {
  background: #f87171;
  color: #0f172a;
}

.btn-restore {
  background: #64748b;
  color: white;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease;
  white-space: nowrap;
  margin-left: 15px;
}

.btn-restore:hover {
  background: #475569;
}

.btn-restore:active {
  background: #334155;
}

/* Theme Toggle */
.theme-toggle-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
}

.theme-toggle-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

/* ========================================
   History Modal & Period Cards
   ======================================== */

.history-modal-content {
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
}

.compare-modal-content {
  max-width: 1000px;
  max-height: 90vh;
  overflow-y: auto;
}

.comparison-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 30px;
  margin-top: 20px;
  align-items: start;
}

.comparison-period {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.comparison-period h3 {
  margin: 0 0 10px 0;
  font-size: 1.2rem;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 10px;
}

.comparison-period .period-dates {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.comparison-divider {
  width: 2px;
  background: var(--border-color);
  align-self: stretch;
}

.comparison-stats {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.comparison-stats .stat-item {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  transition: background 0.3s ease;
}

.comparison-details-toggle {
  margin-top: 30px;
  text-align: center;
  padding: 20px 0;
  border-top: 2px solid var(--border-color);
}

.comparison-details-toggle .btn {
  padding: 12px 24px;
  font-size: 1rem;
}

.category-comparison-container {
  margin-top: 20px;
  animation: slideDown 0.3s ease-out;
}

.comparison-section {
  margin-bottom: 30px;
}

.comparison-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 15px;
  padding: 10px 15px;
  background: var(--bg-secondary);
  border-left: 4px solid var(--btn-primary-bg);
  border-radius: 4px;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-secondary);
  border-radius: 8px;
  overflow: hidden;
}

.comparison-table thead {
  background: var(--bg-tertiary);
}

.comparison-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
}

.comparison-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.comparison-table tbody tr:last-child td {
  border-bottom: none;
}

.comparison-table tbody tr:hover {
  background: var(--bg-tertiary);
}

.comparison-table .cat-name {
  font-weight: 600;
  color: var(--text-primary);
}

.comparison-table .diff-increase {
  color: var(--danger-color);
  font-weight: 600;
}

.comparison-table .diff-decrease {
  color: var(--success-color);
  font-weight: 600;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 20px;
}

.period-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.period-card:hover {
  border-color: var(--border-color-hover);
  box-shadow: var(--shadow-md);
}

.period-summary {
  outline: none;
}

.period-summary:focus {
  outline: 2px solid var(--btn-primary-bg);
  outline-offset: 2px;
  border-radius: 8px;
}

.period-card.current {
  border-color: var(--success-color);
  background: var(--bg-tertiary);
}

.period-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.period-dates-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.period-dates {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.period-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-icon-export,
.btn-icon-compare {
  background: var(--btn-primary-bg);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-icon-compare {
  background: var(--btn-secondary-bg);
}

.btn-icon-export:hover,
.btn-icon-compare:hover {
  background: var(--btn-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-icon-compare:hover {
  background: var(--btn-secondary-hover);
}

.btn-icon-export:active,
.btn-icon-compare:active {
  transform: translateY(0);
}

.period-badge {
  background: var(--success-color);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.period-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

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

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

.expand-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 10px;
  font-style: italic;
}

.period-details {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid var(--border-color);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.period-breakdown {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-breakdown {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.section-summary {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: 6px;
}

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

.category-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  padding: 10px;
  background: var(--bg-primary);
  border-radius: 6px;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.category-row:hover {
  border-color: var(--border-color-hover);
  box-shadow: var(--shadow-sm);
}

.category-row .category-name {
  font-weight: 600;
  color: var(--text-primary);
}

.category-row .category-value {
  text-align: right;
  color: var(--text-secondary);
}

.category-row .category-value.allocated {
  color: var(--text-primary);
}

.category-row .category-value.spent {
  color: var(--warning-color);
}

.category-row .category-value.remaining {
  font-weight: 600;
}

.category-row .category-value.remaining.positive {
  color: var(--success-color);
}

.category-row .category-value.remaining.negative {
  color: var(--danger-color);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 400px;
  pointer-events: auto;
  animation: slideInRight 0.3s ease-out;
  transition: all 0.3s ease;
}

.toast.success {
  border-left: 4px solid var(--success-color);
}

.toast.error {
  border-left: 4px solid var(--danger-color);
}

.toast.info {
  border-left: 4px solid var(--btn-primary-bg);
}

.toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toast-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.toast-message {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.toast.removing {
  animation: slideOutRight 0.3s ease-out forwards;
}

@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;
  }
}

/* ========================================
   Email Configuration Styles
   ======================================== */

.email-status-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 15px 20px;
  margin-bottom: 20px;
}

.email-status-card .status-value.configured {
  color: #10b981;
  font-weight: 600;
}

.email-status-card .status-value.not-configured {
  color: #f59e0b;
  font-weight: 600;
}

.email-instructions {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.email-instructions h4 {
  color: #1d4ed8;
  margin-top: 0;
  margin-bottom: 15px;
}

.email-instructions ol {
  margin: 0;
  padding-left: 20px;
  color: #1e40af;
}

.email-instructions li {
  margin-bottom: 10px;
  line-height: 1.5;
}

.email-instructions a {
  color: #2563eb;
  text-decoration: underline;
}

.email-instructions a:hover {
  color: #1d4ed8;
}

.email-config-form {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
}

.email-config-form .form-group {
  margin-bottom: 15px;
}

.email-config-form .form-group:last-of-type {
  margin-bottom: 20px;
}

.email-config-actions {
  display: flex;
  gap: 10px;
}

.email-config-actions .btn {
  flex: 1;
}

/* Dark mode email config */
.dark-mode .email-status-card {
  background: #1e293b;
  border-color: #334155;
}

.dark-mode .email-instructions {
  background: #1e3a5f;
  border-color: #2563eb;
}

.dark-mode .email-instructions h4 {
  color: #60a5fa;
}

.dark-mode .email-instructions ol {
  color: #93c5fd;
}

.dark-mode .email-instructions a {
  color: #93c5fd;
}

.dark-mode .email-config-form {
  background: #1e293b;
  border-color: #334155;
}

/* ========================================
   Email Template Editor Styles
   ======================================== */

.section-description {
  color: #64748b;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.template-selector {
  margin-bottom: 20px;
}

.template-editor {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
}

.template-info {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e2e8f0;
}

.template-info h4 {
  color: #1e293b;
  margin-bottom: 5px;
  font-size: 1.1rem;
}

.template-description {
  color: #64748b;
  font-size: 0.9rem;
  margin: 0;
}

.placeholders-section {
  margin-bottom: 20px;
}

.placeholders-section h5 {
  color: #64748b;
  font-size: 0.85rem;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.placeholders-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.placeholder-tag {
  background: #e2e8f0;
  color: #334155;
  padding: 4px 10px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.placeholder-tag:hover {
  background: #64748b;
  color: white;
  border-color: #64748b;
}

.template-editor .form-group {
  margin-bottom: 15px;
}

.template-editor .form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}

.template-editor input[type="text"],
.template-editor textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  color: #1e293b;
  font-size: 0.95rem;
  box-sizing: border-box;
}

.template-editor textarea {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.85rem;
  resize: vertical;
  min-height: 200px;
}

.template-editor input[type="text"]:focus,
.template-editor textarea:focus {
  outline: none;
  border-color: #64748b;
}

.template-preview-section {
  margin: 20px 0;
  padding: 15px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.template-preview-section h5 {
  color: #64748b;
  font-size: 0.85rem;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-subject {
  font-weight: 600;
  color: #1e293b;
  padding: 10px;
  background: #f1f5f9;
  border-radius: 4px;
  margin-bottom: 10px;
  min-height: 20px;
}

.preview-subject:empty::before {
  content: 'Subject preview will appear here';
  color: #94a3b8;
  font-weight: normal;
  font-style: italic;
}

.preview-body {
  padding: 15px;
  background: #fafafa;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  min-height: 100px;
  max-height: 300px;
  overflow-y: auto;
  color: #1e293b;
}

.preview-body:empty::before {
  content: 'Click "Preview" to see rendered template';
  color: #94a3b8;
  font-style: italic;
}

.template-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.template-actions .btn {
  flex: 1;
  min-width: 100px;
}

.btn-danger-outline {
  background: transparent;
  color: #ef4444;
  border: 2px solid #ef4444;
}

.btn-danger-outline:hover {
  background: #ef4444;
  color: white;
}

/* Dark mode for template editor */
.dark-mode .section-description {
  color: #94a3b8;
}

.dark-mode .template-editor {
  background: #1e293b;
  border-color: #334155;
}

.dark-mode .template-info {
  border-color: #334155;
}

.dark-mode .template-info h4 {
  color: #f1f5f9;
}

.dark-mode .template-description {
  color: #94a3b8;
}

.dark-mode .placeholders-section h5 {
  color: #94a3b8;
}

.dark-mode .placeholder-tag {
  background: #334155;
  color: #e2e8f0;
}

.dark-mode .placeholder-tag:hover {
  background: #64748b;
  color: white;
}

.dark-mode .template-editor .form-group label {
  color: #e2e8f0;
}

.dark-mode .template-editor input[type="text"],
.dark-mode .template-editor textarea {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

.dark-mode .template-editor input[type="text"]:focus,
.dark-mode .template-editor textarea:focus {
  border-color: #64748b;
}

.dark-mode .template-preview-section {
  background: #0f172a;
  border-color: #334155;
}

.dark-mode .template-preview-section h5 {
  color: #94a3b8;
}

.dark-mode .preview-subject {
  background: #1e293b;
  color: #f1f5f9;
}

.dark-mode .preview-subject:empty::before {
  color: #64748b;
}

.dark-mode .preview-body {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

.dark-mode .preview-body:empty::before {
  color: #64748b;
}

.dark-mode .btn-danger-outline {
  color: #f87171;
  border-color: #f87171;
}

.dark-mode .btn-danger-outline:hover {
  background: #f87171;
  color: #0f172a;
}

/* Responsive Settings Modal */
@media (max-width: 768px) {
  .settings-modal-content {
    width: 95%;
    max-height: 95vh;
    padding: 20px;
  }

  .settings-section h3 {
    font-size: 1.1rem;
  }

  .backup-status-card {
    padding: 15px;
  }

  .status-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .backup-item {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .btn-restore {
    margin-left: 0;
    width: 100%;
  }

  .backup-list {
    max-height: 250px;
  }

  /* Template editor responsive */
  .template-actions {
    flex-direction: column;
  }

  .template-actions .btn {
    width: 100%;
  }

  .placeholders-list {
    gap: 5px;
  }

  .placeholder-tag {
    font-size: 0.8rem;
    padding: 3px 8px;
  }

  .template-editor textarea {
    min-height: 150px;
  }

  /* History modal responsive */
  .history-modal-content {
    padding: 20px;
  }

  .period-card {
    padding: 15px;
  }

  .period-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .period-dates {
    font-size: 1rem;
  }

  .period-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .period-dates-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .period-actions {
    width: 100%;
    flex-direction: column;
  }

  .btn-icon-export,
  .btn-icon-compare {
    width: 100%;
    justify-content: center;
  }

  .compare-modal-content {
    padding: 20px;
  }

  .comparison-container {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .comparison-divider {
    display: none;
  }

  .comparison-details-toggle .btn {
    width: 100%;
  }

  .category-comparison-container {
    overflow-x: auto;
  }

  .comparison-table {
    font-size: 0.85rem;
  }

  .comparison-table th,
  .comparison-table td {
    padding: 8px;
    white-space: nowrap;
  }

  .category-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
  }

  .category-row .category-name {
    font-size: 1rem;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
  }

  .category-row .category-value {
    display: flex;
    justify-content: space-between;
    text-align: left;
  }

  .category-row .category-value::before {
    font-weight: 600;
    color: var(--text-secondary);
  }

  .category-row .category-value.allocated::before {
    content: 'Allocated: ';
  }

  .category-row .category-value.spent::before {
    content: 'Spent: ';
  }

  .category-row .category-value.remaining::before {
    content: 'Remaining: ';
  }

  .section-summary {
    flex-direction: column;
    gap: 6px;
  }
}

/* ========================================
   Search Modal Styles
   ======================================== */

.search-modal-content {
  max-width: 900px;
}

.search-filters {
  margin-bottom: 20px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 15px;
}

.filter-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.filter-group input,
.filter-group select {
  padding: 10px 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--btn-primary-bg);
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 15px;
}

.filter-actions {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.filter-actions button {
  flex: 1;
  padding: 10px;
  margin-bottom: 0;
}

/* Search Summary */
.search-summary {
  display: flex;
  gap: 30px;
  padding: 15px 20px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 10px;
  margin-bottom: 20px;
}

.summary-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.summary-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Search Results */
.search-results {
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.search-results::-webkit-scrollbar {
  width: 8px;
}

.search-results::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb {
  background: var(--btn-primary-bg);
  border-radius: 4px;
}

.placeholder-text {
  text-align: center;
  color: var(--text-secondary);
  padding: 60px 20px;
  font-size: 1rem;
}

.error-text {
  text-align: center;
  color: var(--danger-color);
  padding: 60px 20px;
  font-size: 1rem;
}

/* Search Results List */
.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.search-date-group {
  background: var(--bg-primary);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.search-date-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.search-date {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.search-date-total {
  font-weight: 700;
  color: var(--btn-primary-bg);
  font-size: 1.05rem;
}

.search-transactions {
  display: flex;
  flex-direction: column;
}

.search-transaction {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s ease;
}

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

.search-transaction:hover {
  background: var(--bg-secondary);
}

.search-txn-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.search-txn-category {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.search-txn-description {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-style: italic;
}

.search-txn-amount {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 1.05rem;
  margin-left: 15px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .search-modal-content {
    max-width: 95%;
    padding: 20px;
  }

  .filter-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .filter-actions {
    flex-direction: column;
  }

  .filter-actions button {
    width: 100%;
  }

  .search-summary {
    flex-direction: column;
    gap: 15px;
  }

  .search-results {
    max-height: 400px;
  }

  .search-transaction {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .search-txn-amount {
    align-self: flex-end;
    margin-left: 0;
  }
}

/* Recurring Transactions Styles */
.recurring-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-height: 400px;
  overflow-y: auto;
}

.recurring-item {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  transition: all 0.2s ease;
}

.recurring-item:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.recurring-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.recurring-description {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1.05rem;
}

.recurring-details {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.recurring-detail {
  display: flex;
  align-items: center;
  gap: 5px;
}

.recurring-detail strong {
  color: var(--text-primary);
}

.recurring-amount {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-color);
  white-space: nowrap;
}

.recurring-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.recurring-actions button {
  padding: 6px 12px;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Mobile Responsive for Recurring */
@media (max-width: 768px) {
  .recurring-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .recurring-amount {
    align-self: flex-end;
    margin-top: -10px;
  }

  .recurring-actions {
    width: 100%;
    justify-content: stretch;
  }

  .recurring-actions button {
    flex: 1;
  }
}

/* ==================
   User Menu Styles
   ================== */

.btn-user {
  position: relative;
}

.user-menu-dropdown {
  position: fixed;
  top: 60px;
  right: 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  z-index: 1000;
  overflow: hidden;
}

.user-menu-header {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-menu-header span:first-child {
  font-weight: 600;
  color: #1e293b;
}

.user-role-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: #e0e7ff;
  color: #4338ca;
  border-radius: 9999px;
  text-transform: capitalize;
}

.user-role-badge.admin {
  background: #fef3c7;
  color: #b45309;
}

.user-menu-divider {
  height: 1px;
  background: #e5e7eb;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: #374151;
  text-align: left;
  transition: background 0.15s;
}

.user-menu-item:hover {
  background: #f3f4f6;
}

.user-menu-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.user-menu-logout {
  color: #dc2626;
}

.user-menu-logout:hover {
  background: #fef2f2;
}

/* Loading overlay for auth check */
.auth-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.auth-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e5e7eb;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==================
   User Management Styles
   ================== */

.user-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  gap: 15px;
}

.user-item:hover {
  background: #f1f5f9;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  color: #1e293b;
}

.user-email {
  font-size: 0.85rem;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: #e0e7ff;
  color: #4338ca;
  border-radius: 9999px;
  text-transform: capitalize;
  display: inline-block;
  margin-top: 4px;
}

.user-role.admin {
  background: #fef3c7;
  color: #b45309;
}

.user-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.user-actions button {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.user-actions .btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.user-actions .btn-danger:hover {
  background: #fee2e2;
}

.form-help {
  display: block;
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 4px;
}

/* Mobile responsive for user management */
@media (max-width: 600px) {
  .user-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .user-actions {
    width: 100%;
    margin-top: 10px;
  }

  .user-actions button {
    flex: 1;
  }
}

/* ==================
   Notifications Styles
   ================== */

.btn-notifications {
  position: relative;
}

.notifications-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ef4444;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.notifications-panel {
  position: fixed;
  top: 60px;
  right: 80px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  width: 380px;
  max-width: calc(100vw - 40px);
  max-height: 500px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notifications-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.notifications-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.btn-text {
  background: none;
  border: none;
  color: #667eea;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.btn-text:hover {
  background: #f3f4f6;
}

.notifications-list {
  flex: 1;
  overflow-y: auto;
  max-height: 380px;
}

.notifications-loading,
.notifications-empty {
  padding: 40px 20px;
  text-align: center;
  color: #64748b;
}

.notification-item {
  padding: 15px 20px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s;
}

.notification-item:hover {
  background: #f8fafc;
}

.notification-item.unread {
  background: #eff6ff;
  border-left: 3px solid #667eea;
}

.notification-item.unread:hover {
  background: #dbeafe;
}

.notification-title {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.notification-message {
  color: #64748b;
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 6px;
}

.notification-time {
  font-size: 0.75rem;
  color: #94a3b8;
}

.notifications-footer {
  padding: 10px 15px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
}

/* Mobile responsive for notifications */
@media (max-width: 480px) {
  .notifications-panel {
    right: 10px;
    width: calc(100vw - 20px);
  }
}

/* ========================================
   Notification Preferences
   ======================================== */

.notification-prefs-list {
  max-height: 400px;
  overflow-y: auto;
}

.notification-pref-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border-bottom: 1px solid #e5e7eb;
}

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

.notification-pref-info {
  flex: 1;
  margin-right: 20px;
}

.notification-pref-name {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

.notification-pref-description {
  font-size: 0.85rem;
  color: #64748b;
}

.notification-pref-toggles {
  display: flex;
  gap: 20px;
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-group label {
  font-size: 0.8rem;
  color: #64748b;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.3s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #667eea;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* ========================================
   Reminders
   ======================================== */

.reminders-toolbar {
  margin-bottom: 20px;
  display: flex;
  justify-content: flex-end;
}

.reminders-list {
  max-height: 350px;
  overflow-y: auto;
}

.reminder-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 15px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 10px;
  background: white;
}

.reminder-item:hover {
  border-color: #667eea;
}

.reminder-info {
  flex: 1;
}

.reminder-title {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

.reminder-message {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 8px;
}

.reminder-meta {
  display: flex;
  gap: 15px;
  font-size: 0.8rem;
  color: #94a3b8;
}

.reminder-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.reminder-actions {
  display: flex;
  gap: 8px;
}

.reminder-actions button {
  padding: 6px 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.btn-edit {
  background: #e0e7ff;
  color: #4338ca;
}

.btn-edit:hover {
  background: #c7d2fe;
}

.btn-delete {
  background: #fee2e2;
  color: #dc2626;
}

.btn-delete:hover {
  background: #fecaca;
}

.reminder-form {
  background: #f8fafc;
  padding: 20px;
  border-radius: 8px;
  margin-top: 20px;
  border: 1px solid #e5e7eb;
}

.reminder-form h3 {
  margin: 0 0 15px 0;
  color: #1e293b;
}

.reminders-empty {
  text-align: center;
  padding: 40px 20px;
  color: #64748b;
}

.reminders-empty svg {
  width: 48px;
  height: 48px;
  stroke: #cbd5e1;
  margin-bottom: 15px;
}

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

.modal-medium .modal-content {
  max-width: 500px;
}

.modal-large .modal-content {
  max-width: 700px;
}

.modal-description {
  color: #64748b;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
}

.form-divider {
  height: 1px;
  background: var(--border-color);
  margin: 24px 0;
}

.form-message {
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 16px;
  font-size: 0.9rem;
}

.form-message.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.form-message.success {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.dark-mode .form-message.error {
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(220, 38, 38, 0.3);
}

.dark-mode .form-message.success {
  background: rgba(22, 163, 74, 0.1);
  border-color: rgba(22, 163, 74, 0.3);
}

.form-row {
  display: flex;
  gap: 15px;
}

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

.checkbox-group {
  display: flex;
  align-items: center;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #475569;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #667eea;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #e5e7eb;
}

.btn-small {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn-small svg {
  margin-right: 6px;
  vertical-align: middle;
}

/* ========================================
   Tab Bar
   ======================================== */

.tab-bar {
  display: flex;
  gap: 0;
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}

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

.tab-btn.active {
  background: var(--btn-primary-bg);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.tab-btn svg {
  flex-shrink: 0;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ========================================
   Debt Summary Cards
   ======================================== */

.debt-summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.debt-summary-card {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 16px 20px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.debt-summary-label {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.debt-summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

/* ========================================
   Debt Chart
   ======================================== */

.debt-chart-container {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 20px 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.debt-chart-container h3 {
  margin-bottom: 16px;
  color: var(--text-primary);
  font-size: 1.1rem;
}

.chart-wrapper {
  position: relative;
  height: 280px;
}

.chart-wrapper-small {
  height: 200px;
}

.chart-empty-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ========================================
   Debt List
   ======================================== */

.debt-list-section {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 20px 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

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

.debt-list-header h3 {
  color: var(--text-primary);
  font-size: 1.1rem;
}

.debt-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.debt-card {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 16px 20px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.debt-card:hover {
  border-color: var(--border-color-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.debt-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.debt-card-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.debt-card-balance {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.debt-card-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.debt-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.debt-linked-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Debt Progress Bar */
.debt-progress-bar-container {
  margin-bottom: 8px;
}

.debt-progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.debt-progress-fill {
  height: 100%;
  background: var(--success-color);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.debt-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.debt-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.debt-card-actions button {
  padding: 4px 10px;
  font-size: 0.78rem;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.debt-card-actions button:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.debt-card-actions .btn-delete:hover {
  background: var(--danger-color);
  color: white;
  border-color: var(--danger-color);
}

/* ========================================
   Debt Detail Modal
   ======================================== */

.debt-detail-progress {
  margin-bottom: 20px;
}

.debt-detail-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.debt-detail-stat {
  text-align: center;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.debt-detail-stat .stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.debt-detail-stat .stat-value {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.debt-detail-chart {
  margin-bottom: 20px;
}

.debt-detail-chart h4,
.debt-payment-history h4,
.debt-record-payment h4 {
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.debt-payment-list {
  max-height: 200px;
  overflow-y: auto;
}

.debt-payment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

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

.debt-payment-date {
  color: var(--text-tertiary);
  min-width: 100px;
}

.debt-payment-amount {
  font-weight: 600;
  color: var(--success-color);
}

.debt-payment-balance {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.debt-record-payment {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* Budget category debt link badge */
.category-debt-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-left: 8px;
}

/* ========================================
   Debt Responsive
   ======================================== */

@media (max-width: 768px) {
  .tab-btn span {
    display: none;
  }

  .tab-btn {
    padding: 10px 16px;
  }

  .debt-summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .debt-detail-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-wrapper {
    height: 200px;
  }
}
