/* =========================
   THEME + DESIGN TOKENS
   Added: your new dark palette as CSS variables
========================= */
:root {
  /* Core */
  --bg: #1A1F2E;
  --surface: #242A3D;
  --surface-2: #2C3350;
  --border: rgba(255,255,255,0.08);

  /* Text */
  --text: #FFFFFF;
  --text-2: #B0B5C0;

  /* Semantic */
  --positive: #00D9B8; /* savings / success */
  --pocket: #8B5CF6;   /* available to spend */
  --essential: #3B82F6;/* bills */
  --debt: #F59E0B;     /* debt */
  --negative: #FF3B5C; /* warning */

  /* Buttons */
  --btn-primary: #00D9B8;
  --btn-primary-text: #0B1220;

  /* Effects */
  --shadow: 0 12px 30px rgba(0,0,0,0.35);
  --shadow-soft: 0 8px 20px rgba(0,0,0,0.25);
}

/* =========================
   GLOBAL RESET
========================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* =========================
   PAGE BACKGROUND + BASE TEXT
   Changed: gradient -> solid dark background
   Changed: default text -> white for contrast
========================= */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg); /* changed */
  color: var(--text);    /* changed */
  min-height: 100vh;
  line-height: 1.5;
}

/* =========================
   APP LAYOUT: SIDEBAR + MAIN
   Breakpoints: Mobile <767px | Tablet 768–979px | Desktop 980px+
========================= */

.app-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
}

/* Tablet: narrower sidebar */
@media (min-width: 768px) and (max-width: 979px) {
  .app-shell {
    grid-template-columns: 250px 1fr;
  }
}

/* Mobile: flex column, main content first (sidebar becomes drawer) */
@media (max-width: 767px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-x: hidden;
  }
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 18px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Mobile: off-canvas drawer */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    z-index: 1002;
    transform: translateX(-100%);
    transition: transform 0.3s ease, visibility 0.3s ease;
    visibility: hidden;
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
    visibility: visible;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .sidebar-backdrop.sidebar-backdrop-open {
    opacity: 1;
    visibility: visible;
  }

  body.sidebar-drawer-open {
    overflow: hidden;
    touch-action: none;
  }
}

/* Mobile-only: header row with close button (hidden on desktop) */
.sidebar-header-mobile {
  display: none;
}

@media (max-width: 767px) {
  .sidebar-header-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    flex-shrink: 0;
  }

  .sidebar-header-mobile .sidebar-brand {
    margin-bottom: 0;
  }

  .sidebar-close-btn {
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.menu-toggle-btn {
  display: none;
}

/* Mobile fixed header (hamburger + app title) */
.mobile-header {
  display: none;
}

@media (max-width: 767px) {
  .mobile-header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    z-index: 1200;
  }

  .mobile-header .app-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    white-space: nowrap;
  }

  .mobile-header .header-spacer {
    width: 44px;
    height: 44px;
  }

  .main,
  .container {
    padding-top: 56px;
  }

  .topbar {
    justify-content: center;
    gap: 8px;
    margin: 12px 12px 8px 12px;
    padding: 10px;
    border-radius: 12px;
  }

  .topbar .icon-btn,
  .topbar .month-controls .icon-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 10px;
    padding: 0;
  }

  .topbar .month-pill {
    padding: 8px 10px;
    min-height: 36px;
  }

  .topbar #month-label {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
  }

  .sidebar {
    top: 56px;
    height: calc(100vh - 56px);
  }

  .sidebar-backdrop {
    top: 56px;
    bottom: 56px;
    inset: unset;
    left: 0;
    right: 0;
  }
}

.hamburger-btn {
  background: none;
  border: none;
  width: 44px;
  height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  border-radius: 10px;
}

.hamburger-btn:active {
  transform: scale(0.98);
}

.hamburger-line {
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.hamburger-btn.is-open .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-btn.is-open .hamburger-line:nth-child(2) {
  opacity: 0;
}

.hamburger-btn.is-open .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.brand-icon {
  font-size: 1.6em;
}

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

.brand-title {
  font-size: 1.2em;
  font-weight: 700;
  color: var(--text);
}

.brand-subtitle {
  font-size: 0.85em;
  color: var(--text-2);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.main {
  position: relative;
  height: 100vh;
  overflow: auto;
  padding: 18px 22px;
}

@media (max-width: 767px) {
  .main {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    padding: 12px 16px;
  }
}

.container {
  width: 100%;
  max-width: none;
  margin: 0;
}

@media (max-width: 767px) {
  .container {
    overflow-x: hidden;
  }
}

/* TOPBAR / MONTH CONTROLS */
.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  background: var(--surface);
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.month-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.icon-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  transform: translateY(-1px);
}

.month-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;

  background: var(--surface-2);
  color: var(--text);
  border: 1px solid rgba(139,92,246,0.55);
  box-shadow: 0 0 0 2px rgba(139,92,246,0.20);
  border-radius: 14px;

  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

.month-pill-icon {
  opacity: 0.9;
}

.month-picker {
  position: absolute;
  left: -9999px; /* NEW: keep it available but hidden */
}

/* Stack header on smaller screens */
@media (max-width: 767px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .month-controls {
    width: 100%;
    justify-content: space-between;
  }

  .month-pill {
    width: 100%;
    justify-content: space-between;
  }
}

/* =========================
   TABS
   Changed: tabs -> dark surfaces
   Changed: active state -> subtle purple outline (pocket)
========================= */
.tab-btn {
  padding: 12px 24px;
  background: var(--surface);               /* changed */
  border: 1px solid var(--border);          /* changed */
  border-radius: 25px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  color: var(--text);                        /* changed */
  box-shadow: var(--shadow-soft);            /* changed */
  transition: all 0.2s ease;                 /* changed */
}

/* Sidebar-specific tab styling */
.sidebar .tab-btn {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  border-radius: 10px;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.sidebar-section {
  margin-top: 18px;
}

.sidebar-section-title {
  font-size: 0.78em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-2);
  margin-bottom: 6px;
}

#accounts-sidebar {
  margin-bottom: 8px;
}

.accounts-group-title {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-2);
  padding: 4px 2px 6px;
  margin: 0 0 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.account-row-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.account-row-wrap.selected-account .account-row {
  background: rgba(139,92,246,0.18);
  border-color: rgba(139,92,246,0.7);
  border-left-color: var(--positive);
}

.account-row {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 36px 8px 10px; /* extra right padding for edit button */
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.9em;
  text-align: left;
  color: var(--text);
  border-left: 3px solid transparent;
}

.account-row:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border);
}

.account-edit-btn {
  position: absolute;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.85em;
  opacity: 0.9;
}

.account-edit-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(139,92,246,0.7);
}

.account-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  color: var(--text);
  font-weight: 700;
}

.account-balance {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 650;
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.account-balance-positive {
  color: var(--positive);
}

.account-balance-negative {
  color: var(--negative);
}

.sidebar-empty {
  font-size: 0.8em;
  color: var(--text-2);
}

.sidebar-add-account {
  margin-top: auto;
  width: 100%;
}

.account-badge {
  font-size: 0.7em;
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 6px;
  white-space: nowrap;
}

.account-badge-debt {
  background: rgba(255, 59, 92, 0.15);
  border: 1px solid rgba(255, 59, 92, 0.35);
  color: var(--negative);
}

.tab-btn:hover {
  transform: translateY(-1px);               /* changed */
}

.tab-btn.active {
  background: var(--surface-2);              /* changed */
  border-color: rgba(139,92,246,0.55);       /* changed (pocket purple) */
  box-shadow: 0 0 0 2px rgba(139,92,246,0.25); /* changed */
}

/* =========================
   TAB CONTENT VISIBILITY
========================= */
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* View (e.g. account detail drill-down) */
.view {
  display: none;
}
.view.active {
  display: block;
}

/* ========================================
   BUDGET VIEW (SPENDING TAB) - MOBILE OPTIMIZED
   ======================================== */

.budget-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
}

.budget-section:last-child {
  padding-bottom: 80px;
}

.budget-section .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 10;
}

.budget-section .section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  min-height: 32px;
}

/* Bills / Fixed Expenses - card layout */
.bills-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
}

.bill-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 68px;
}

.bill-card:active {
  transform: scale(0.98);
  background: var(--surface);
}

.bill-card.overdue {
  background: rgba(255, 59, 92, 0.15);
  border-color: var(--negative);
}

.bill-card.pending {
  background: var(--surface-2);
  border-color: var(--essential);
}

.bill-card.paid {
  background: var(--surface-2);
  border-color: var(--border);
  opacity: 0.7;
}

.bill-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.bill-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.bill-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.bill-amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.bill-status-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.bill-status-badge.overdue {
  background: var(--negative);
  color: white;
}

.bill-status-badge.pending {
  background: var(--essential);
  color: white;
}

.bill-status-badge.paid {
  background: var(--positive);
  color: white;
}

.bill-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bill-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-2);
}

.bill-date { font-weight: 500; }
.bill-frequency { opacity: 0.7; }

/* ========================================
   EXPENSE CATEGORIES - CLEAN CARD LAYOUT
   ======================================== */

.categories-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 80px 16px;
}

.category-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.category-card:active {
  transform: scale(0.98);
  background: var(--surface);
}

/* Header with icon and name side-by-side */
.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.category-icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}

.category-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

/* Stats in a clean 3-column grid */
.category-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.category-card .stat-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-card .stat-label {
  font-size: 10px;
  color: var(--text-secondary, var(--text-2));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.category-card .stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.category-card .stat-value.spent {
  color: var(--text);
}

.category-card .stat-value.remaining {
  color: var(--text);
}

.category-card .stat-value.remaining.positive {
  color: var(--success, var(--positive));
}

.category-card .stat-value.remaining.negative {
  color: var(--danger, var(--negative));
}

/* Progress bar section */
.category-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-progress .progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
}

.category-progress .progress-fill {
  height: 100%;
  background: var(--primary, var(--essential));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.category-progress .progress-fill.warning {
  background: var(--debt);
}

.category-progress .progress-fill.danger {
  background: var(--danger, var(--negative));
}

.category-progress .progress-text {
  font-size: 11px;
  color: var(--text-secondary, var(--text-2));
  text-align: right;
  font-weight: 500;
}

/* Category card mobile adjustments */
@media (max-width: 767px) {
  .category-card {
    padding: 12px;
  }
  .category-icon {
    font-size: 22px;
  }
  .category-name {
    font-size: 15px;
  }
  .category-stats {
    gap: 8px;
  }
  .category-card .stat-value {
    font-size: 15px;
  }
}

@media (max-width: 360px) {
  .category-card .stat-label {
    font-size: 9px;
  }
  .category-card .stat-value {
    font-size: 14px;
  }
  .category-stats {
    gap: 6px;
  }
}

.bills-container .empty-state,
.categories-container .empty-state {
  padding: 40px 20px;
  text-align: center;
}

@media (max-width: 767px) {
  .budget-section .section-header {
    padding: 12px 16px;
  }
  .budget-section .section-title {
    font-size: 15px;
  }
  .bills-container,
  .categories-container {
    padding: 10px 12px;
  }
  .bill-card { padding: 10px; }
  .bill-name { font-size: 14px; }
  .bill-amount { font-size: 16px; }
}

/* ========================================
   CALENDAR VIEW - TIMELINE LAYOUT
   ======================================== */

.calendar-view-wrapper {
  padding-bottom: 80px;
}

#calendar .calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 10;
}

#calendar .calendar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

#calendar .calendar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.toggle-control input[type="checkbox"] {
  display: none;
}

.toggle-slider {
  width: 44px;
  height: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: relative;
  transition: all 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 1px;
  left: 2px;
  transition: all 0.3s;
}

.toggle-control input[type="checkbox"]:checked + .toggle-slider {
  background: var(--primary, var(--essential));
  border-color: var(--primary, var(--essential));
}

.toggle-control input[type="checkbox"]:checked + .toggle-slider::before {
  transform: translateX(20px);
}

#calendar .calendar-nav {
  padding: 12px 16px;
  background: var(--surface);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.calendar-timeline {
  padding: 0 16px 20px 16px;
}

.timeline-group {
  margin-bottom: 24px;
}

.timeline-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 10px 0;
  position: sticky;
  top: 120px;
  background: var(--surface);
  z-index: 5;
}

.timeline-badge {
  font-size: 20px;
  line-height: 1;
}

.timeline-date {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.timeline-relative {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.timeline-relative.overdue {
  color: var(--danger, var(--negative));
}

.timeline-relative.today {
  color: var(--primary, var(--essential));
}

.timeline-absolute {
  font-size: 12px;
  color: var(--text-secondary, var(--text-2));
}

.timeline-count {
  font-size: 11px;
  color: var(--text-secondary, var(--text-2));
  white-space: nowrap;
}

.timeline-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ========== DESKTOP CALENDAR MONTH GRID ========== */

.desktop-only {
  display: none;
}

.mobile-only {
  display: block;
}

@media (min-width: 980px) {
  .desktop-only {
    display: block;
  }

  .mobile-only {
    display: none !important;
  }

  /* Hide floating action button on desktop */
  .calendar-fab {
    display: none;
  }
}

.calendar-body {
  padding: 0 16px 24px 16px;
}

.calendar-grid-wrapper {
  padding: 8px 0 32px;
}

.calendar-grid-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 16px 0;
}

.calendar-grid-month-label {
  font-size: 1.1em;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

/* Make day cells share the same grid as headers */
#calendar-grid-days {
  display: contents;
}

.calendar-day-header {
  background: var(--surface-2);
  text-align: center;
  padding: 10px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary, var(--text-2));
}

.calendar-cell {
  background: var(--surface);
  min-height: 110px;
  padding: 8px 6px 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.calendar-cell:hover {
  background: var(--surface-2);
}

.calendar-cell.today {
  background: rgba(139, 92, 246, 0.08);
  outline: 2px solid rgba(139, 92, 246, 0.45);
  outline-offset: -2px;
}

.calendar-cell.other-month {
  opacity: 0.38;
}

.calendar-cell.has-items {
  background: var(--surface-2);
}

.cell-day-number {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary, var(--text-2));
  line-height: 1;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.calendar-cell.today .cell-day-number {
  color: var(--pocket, var(--primary));
  font-size: 14px;
}

.cell-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}

.cell-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  line-height: 1.4;
  transition: opacity 0.15s;
}

.cell-pill:hover {
  opacity: 0.8;
}

.cell-pill.income {
  background: rgba(0, 217, 184, 0.18);
  color: var(--positive, #00d9b8);
  border-left: 2px solid var(--positive, #00d9b8);
}

.cell-pill.expense {
  background: rgba(255, 59, 92, 0.15);
  color: var(--negative, #ff3b5c);
  border-left: 2px solid var(--negative, #ff3b5c);
}

.cell-pill.bill {
  background: rgba(59, 130, 246, 0.18);
  color: var(--essential, var(--primary));
  border-left: 2px solid var(--essential, var(--primary));
}

.cell-pill.transfer {
  background: rgba(245, 158, 11, 0.15);
  color: var(--debt, #f59e0b);
  border-left: 2px solid var(--debt, #f59e0b);
}

.cell-more {
  font-size: 10px;
  color: var(--text-secondary, var(--text-2));
  padding: 1px 4px;
  font-weight: 600;
}

.cell-day-total {
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: auto;
  padding-top: 3px;
  flex-shrink: 0;
}

.cell-day-total.positive {
  color: var(--positive, #00d9b8);
}

.cell-day-total.negative {
  color: var(--negative, #ff3b5c);
}

.calendar-day-detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 499;
  display: none;
}

.calendar-day-detail-backdrop.open {
  display: block;
}

.calendar-day-detail {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow, 0 18px 45px rgba(0, 0, 0, 0.45));
  z-index: 500;
  width: 380px;
  max-width: 95vw;
  max-height: 70vh;
  overflow-y: auto;
  display: none;
  padding: 20px;
}

.calendar-day-detail.open {
  display: block;
}

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

.detail-header h3 {
  font-size: 1.1em;
  color: var(--text);
  margin: 0;
}

.detail-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary, var(--text-2));
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}

.detail-close-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.detail-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

.detail-item:hover {
  border-color: rgba(139, 92, 246, 0.45);
  background: var(--surface);
}

.detail-item-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.detail-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-item-sub {
  font-size: 11px;
  color: var(--text-secondary, var(--text-2));
}

.detail-item-amount {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  margin-left: 10px;
}

.detail-item-amount.income {
  color: var(--positive, #00d9b8);
}

.detail-item-amount.expense {
  color: var(--negative, #ff3b5c);
}

.detail-item-amount.transfer {
  color: var(--debt, #f59e0b);
}

.detail-add-btn {
  margin-top: 14px;
  width: 100%;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  align-items: flex-start;
}

.timeline-item:active {
  transform: scale(0.98);
  background: var(--surface);
}

.timeline-item .transaction-icon {
  width: 40px;
  height: 40px;
  background: var(--surface);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.timeline-item .transaction-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.timeline-item .transaction-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-item .transaction-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--text-secondary, var(--text-2));
}

.timeline-item .transaction-account,
.timeline-item .transaction-accounts-detail {
  font-size: 11px;
  opacity: 0.9;
}

.timeline-item .transaction-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 11px;
}

.timeline-item .transaction-frequency {
  color: var(--text-secondary, var(--text-2));
}

.timeline-item .transaction-status {
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
}

.timeline-item .transaction-status.posted {
  background: var(--success, var(--positive));
  color: white;
}

.timeline-item .transaction-status.pending {
  background: var(--primary, var(--essential));
  color: white;
}

.timeline-item .transaction-status.overdue {
  background: var(--danger, var(--negative));
  color: white;
}

.timeline-item .transaction-status.skipped {
  background: var(--surface);
  color: var(--text-secondary, var(--text-2));
}

.timeline-item .transaction-amount {
  font-size: 16px;
  font-weight: 700;
  color: var(--success, var(--positive));
  flex-shrink: 0;
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.timeline-item .transaction-amount.negative {
  color: var(--danger, var(--negative));
}

.fab.calendar-fab {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: var(--btn-primary);
  color: var(--btn-primary-text);
  border: none;
  border-radius: 50%;
  font-size: 28px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: all 0.2s;
  z-index: 100;
}

.fab.calendar-fab:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow);
}

.fab.calendar-fab:active {
  transform: scale(0.95);
}

#calendar .calendar-timeline .empty-state {
  padding: 60px 20px;
}

@media (max-width: 767px) {
  #calendar .calendar-header {
    padding: 12px 16px;
  }
  #calendar .calendar-title {
    font-size: 16px;
  }
  .toggle-control .toggle-label {
    font-size: 12px;
  }
  .timeline-header {
    top: 108px;
  }
  .timeline-item {
    padding: 10px;
  }
  .timeline-item .transaction-icon {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
  .timeline-item .transaction-title {
    font-size: 13px;
  }
  .timeline-item .transaction-amount {
    font-size: 15px;
  }
}

/* Desktop calendar improvements */
@media (min-width: 980px) {
  #calendar .calendar-nav,
  #calendar .calendar-timeline {
    max-width: 1100px;
    margin: 0 auto;
  }

  #calendar .calendar-nav {
    padding-left: 0;
    padding-right: 0;
  }

  #calendar .calendar-timeline {
    padding-left: 0;
    padding-right: 0;
  }

  /* Show more scheduled items per row */
  #calendar .timeline-items {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  /* Keep date headers visible while scrolling */
  #calendar .timeline-header {
    top: 0;
    padding-top: 18px;
  }
}

@media (min-width: 1440px) {
  #calendar .calendar-nav,
  #calendar .calendar-timeline {
    max-width: 1300px;
  }

  #calendar .timeline-items {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ========================================
   ALL TRANSACTIONS PAGE
   ======================================== */

#all-transactions {
  padding-bottom: 80px;
}

/* Shared page section header (used by Income/Debt views) */
.section-header-page {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 20;
}

.section-header-page .page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.transactions-page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 20;
}

.transactions-page-header .page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  flex: 1;
}

.transactions-page-header .header-actions {
  display: flex;
  gap: 8px;
}

.filter-drawer {
  max-height: 0;
  overflow: hidden;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: max-height 0.3s ease;
}

.filter-drawer.open {
  max-height: 600px;
}

.filter-content {
  padding: 16px;
}

.filter-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 16px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-group {
  margin-bottom: 16px;
}

.filter-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, var(--text-2));
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-select,
.filter-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

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

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

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

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

/* ========================================
   ALL TRANSACTIONS - TABLE LAYOUT
   ======================================== */

.transactions-timeline {
  padding: 0;
  max-width: 100%;
}

.table-container {
  width: 100%;
  overflow-x: auto;
}

.transactions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.transactions-table th {
  text-align: left;
  padding: 16px 12px;
  color: var(--text-2);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.transactions-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.transactions-table tr {
  transition: background 0.15s ease;
  cursor: pointer;
}

.transactions-table tr:hover {
  background: var(--surface-2);
}

.transactions-table .text-right {
  text-align: right;
}

/* Column Specifics */
.col-date {
  color: var(--text-2);
  white-space: nowrap;
}

.account-badge-table {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.category-pill {
  display: inline-block;
  padding: 4px 10px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.col-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}

.col-amount.positive { color: var(--positive); }
.col-amount.negative { color: var(--negative); }

.btn-icon-sm {
  background: transparent;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 4px;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.2s;
}

.transactions-table tr:hover .btn-icon-sm {
  opacity: 1;
}

.transactions-timeline .empty-state {
  padding: 60px 20px;
  text-align: center;
}

/* ========================================
   MOBILE CARD TRANSFORMATION (< 768px)
   ======================================== */
@media (max-width: 767px) {
  .transactions-timeline {
    padding: 16px;
  }

  .transactions-table thead {
    display: none;
  }

  .transactions-table,
  .transactions-table tbody,
  .transactions-table tr,
  .transactions-table td {
    display: block;
    width: 100%;
  }

  .transactions-table tr {
    display: flex;
    flex-direction: column;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 12px;
    position: relative;
  }

  .transactions-table td {
    border-bottom: none;
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .transactions-table td::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--text-2);
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 12px;
  }

  .transactions-table .col-date {
    order: -2;
    font-size: 12px;
    color: var(--text-2);
    margin-bottom: 4px;
  }
  .transactions-table .col-date::before { content: none; }

  .transactions-table .col-account {
    order: -1;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }
  .transactions-table .col-account::before { content: none; }

  .transactions-table .col-amount {
    order: 999;
    font-size: 18px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  .btn-icon-sm {
    opacity: 1;
    font-size: 18px;
    padding: 8px;
  }

  .col-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    width: auto;
    padding: 0;
  }
  .col-actions::before { content: none; }
}

/* ========================================
   INCOME SOURCES - CARD LAYOUT
   ======================================== */

#income {
  padding-bottom: 80px;
}

.income-cards-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.income-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.income-card:active {
  transform: scale(0.98);
  background: var(--surface);
}

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

.income-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.income-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.income-amount {
  font-size: 20px;
  font-weight: 700;
  color: var(--success);
  font-variant-numeric: tabular-nums;
}

.income-status-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.income-status-badge.pending {
  background: var(--primary);
  color: #fff;
}

.income-status-badge.received {
  background: var(--success);
  color: #fff;
}

.income-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

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

.detail-label {
  font-size: 10px;
  color: var(--text-secondary, var(--text-2));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.detail-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.income-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

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

@media (max-width: 767px) {
  .income-cards-container {
    padding: 12px;
  }

  .income-card {
    padding: 12px;
  }

  .income-name {
    font-size: 15px;
  }

  .income-amount {
    font-size: 18px;
  }
}

/* Desktop Optimization: Grid Layout for Income Cards */
@media (min-width: 980px) {
  .income-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    align-items: stretch;
  }

  .income-card {
    height: 100%; /* Uniform height */
    display: flex;
    flex-direction: column;
  }

  .income-details {
    flex: 1; /* Pushes actions to bottom */
  }
}

/* ========================================
   DEBT ACCOUNTS - CARD LAYOUT
   ======================================== */

#debt {
  padding-bottom: 80px;
}

.debt-cards-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.debt-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.debt-card:active {
  transform: scale(0.98);
  background: var(--surface);
}

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

.debt-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.debt-balance {
  font-size: 20px;
  font-weight: 700;
  color: var(--danger, var(--negative));
  font-variant-numeric: tabular-nums;
}

.debt-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

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

.detail-value.rate {
  color: var(--danger, var(--negative));
  font-weight: 700;
}

.debt-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

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

@media (max-width: 767px) {
  .debt-cards-container {
    padding: 12px;
  }

  .debt-card {
    padding: 12px;
  }
}

@media (max-width: 767px) {
  .transactions-page-header {
    padding: 12px 16px;
  }
  .transactions-page-header .page-title {
    font-size: 16px;
  }
  .filter-content {
    padding: 12px 16px;
  }
  .transactions-timeline {
    padding: 12px;
  }
  .transaction-card {
    padding: 10px;
  }
  .transaction-status-icon {
    width: 36px;
    height: 36px;
    font-size: 13px;
  }
  .transaction-card .transaction-name {
    font-size: 13px;
  }
  .transaction-card .transaction-amount {
    font-size: 14px;
  }
}

/* =========================
   ACCOUNTS VIEW + ACCOUNT DETAIL
========================= */
.accounts-top { margin: 0 0 12px 0; }
.accounts-footer { padding: 16px; padding-bottom: 88px; }

.search-bar-container { padding: 12px 16px; }
.search-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
}

.btn-link-full {
  width: calc(100% - 32px);
  margin: 0 16px 12px 16px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--btn-primary);
  font-weight: 600;
}

.accounts-container { padding: 0 16px 0 16px; }
/* ========================================
   ACCOUNTS LIST - COMPACT VERSION
   ======================================== */

.accounts-view-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.accounts-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.accounts-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 980px) {
  .accounts-view-grid {
    display: grid;
    grid-template-columns: minmax(0, 2.3fr) minmax(260px, 1fr);
    gap: 20px;
    align-items: flex-start;
  }
}

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

.account-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  margin-bottom: 8px;
  cursor: pointer;
}

.account-group-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, var(--text-2));
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.account-group-total {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.account-group-total.negative {
  color: var(--danger, var(--negative));
}

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

/* Individual Account Card - COMPACT */
.account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 56px;
}

.account-card:active {
  transform: scale(0.98);
  background: var(--surface);
}

.account-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.account-card-icon {
  width: 36px;
  height: 36px;
  background: var(--surface);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

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

.account-card-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-card-subtitle {
  font-size: 11px;
  color: var(--text-secondary, var(--text-2));
}

.account-card-balance {
  font-size: 15px;
  font-weight: 600;
  color: var(--success, var(--positive));
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  margin-left: 10px;
}

.account-card-balance.negative {
  color: var(--danger, var(--negative));
}

/* ========================================
   ACCOUNT CARDS - MOBILE OPTIMIZATIONS
   ======================================== */
@media (max-width: 767px) {
  .account-card {
    padding: 10px;
    min-height: 54px;
  }

  .account-card-icon {
    width: 34px;
    height: 34px;
    font-size: 17px;
  }

  .account-card-name {
    font-size: 13px;
  }

  .account-card-subtitle {
    font-size: 10px;
  }

  .account-card-balance {
    font-size: 14px;
  }
}

.account-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.account-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-back {
  background: none;
  border: none;
  color: var(--primary, var(--btn-primary));
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 10px;
  min-height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-back:hover {
  background: var(--surface);
}

.btn-menu {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text);
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-menu:hover {
  background: var(--surface);
}

.account-title-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.account-icon-large {
  width: 44px;
  height: 44px;
  background: var(--surface);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

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

.account-name-large {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-type-label {
  font-size: 13px;
  color: var(--text-secondary, var(--text-2));
}

.account-balances {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--border);
  gap: 1px;
}
.balance-item { background: var(--surface-2); text-align: center; padding: 14px 10px; }
.balance-label { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.6px; }
.balance-value { margin-top: 6px; font-weight: 900; font-variant-numeric: tabular-nums; }

/* Account Actions - 2 Button Layout */
.account-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
  background: var(--surface);
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.action-btn-primary {
  background: var(--primary, var(--btn-primary));
  color: white;
  border-color: var(--primary, var(--btn-primary));
}

.action-btn-primary .action-icon {
  color: white;
}

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

.action-icon {
  font-size: 24px;
  line-height: 1;
}

/* Transactions header row (account detail) */
.transactions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.transactions-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-secondary, var(--text-2));
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.view-all-btn {
  background: none;
  border: none;
  color: var(--primary, var(--btn-primary));
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 10px;
  min-height: 44px;
  border-radius: 10px;
}

.view-all-btn:hover {
  background: var(--surface-2);
}

/* Empty state centering inside account transactions */
.transactions-list {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  padding-bottom: 88px;
}

.transactions-list .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  flex: 1;
  text-align: center;
}

.transactions-list .empty-icon {
  font-size: 56px;
  margin-bottom: 14px;
  opacity: 0.4;
}

.transactions-list .empty-message {
  font-size: 15px;
  color: var(--text-secondary, var(--text-2));
  margin: 0;
}

/* Mobile tweaks (account detail) */
@media (max-width: 767px) {
  .account-header {
    padding: 12px 16px;
  }

  .account-icon-large {
    width: 40px;
    height: 40px;
    font-size: 22px;
  }

  .account-name-large {
    font-size: 16px;
  }

  .transactions-header {
    padding: 12px 16px;
  }

  .account-actions {
    gap: 8px;
    padding: 12px;
  }

  .account-actions .action-btn {
    padding: 14px 10px;
    font-size: 13px;
  }

  .account-actions .action-icon {
    font-size: 22px;
  }
}

/* =========================
   CARDS
   Changed: white cards -> dark surface cards
========================= */
.card {
  background: var(--surface);               /* changed */
  padding: 25px;
  border-radius: 15px;
  box-shadow: var(--shadow-soft);           /* changed */
  margin-bottom: 20px;
  border: 1px solid var(--border);          /* added */
}

/* Changed: ensure headings are readable on dark */
.card-header h2,
.card h2 {
  color: var(--text);                        /* changed */
}

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

/* Changed: removed old #333 so it doesn't fight the dark theme */
.card-header h2 {
  font-size: 1.8em;
}

/* =========================
   BUTTONS
   Changed: primary -> teal
   Added: secondary -> dark surface
   Changed: danger -> red semantic color
========================= */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  line-height: 1.4;
  transition: all 0.2s ease; /* changed: slightly snappier */
  min-height: 44px;
}

.btn-primary {
  background: var(--btn-primary);          /* changed */
  color: var(--btn-primary-text);          /* changed */
}

.btn-primary:hover {
  transform: translateY(-1px);             /* changed */
  box-shadow: 0 10px 20px rgba(0,217,184,0.25); /* changed */
}

.btn-secondary {
  background: var(--surface-2);           /* changed */
  color: var(--text);                     /* changed */
  border: 1px solid var(--border);        /* added */
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.06);     /* changed */
}

.btn-positive {
  background: var(--positive);
  color: var(--btn-primary-text);
}

.btn-positive:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(0,217,184,0.25);
}

.btn-danger {
  background: var(--negative);            /* changed */
  color: var(--text);
  padding: 6px 12px;
  font-size: 0.9em;
}

.btn-danger:hover {
  filter: brightness(0.95);
}

.btn-success {
  background: var(--positive);
  color: var(--btn-primary-text);
  border: none;
}
.btn-success:hover {
  background: #00b894;
  transform: translateY(-1px);
}
.btn-success:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* NEW: header action buttons on the right side */
.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* =========================
   STATS
   Changed: gradient stat cards -> dark surface
========================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--surface-2);           /* changed */
  color: var(--text);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);        /* added */
  box-shadow: var(--shadow-soft);         /* changed */
}

.stat-label {
  font-size: 0.9em;
  color: var(--text-2);                   /* changed */
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2em;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

/* Optional: semantic coloring on totals (safe even if you remove later) */
#total-income { color: var(--positive); } /* added */
#total-spending { color: var(--negative); } /* added */
#total-savings { color: var(--positive); } /* added */
#total-debt { color: var(--debt); } /* added */

/* =========================
   SAVINGS PROGRESS
   Changed: progress bar -> teal + dark background
========================= */
.progress-bar {
  width: 100%;
  height: 25px;
  background: rgba(255,255,255,0.08);      /* changed */
  border-radius: 12px;
  overflow: hidden;
  margin: 10px 0;
}

.progress-fill {
  height: 100%;
  background: var(--positive);             /* changed */
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--btn-primary-text);          /* changed */
  font-weight: 700;                        /* changed */
  font-size: 0.85em;
  transition: width 0.3s ease;
}

/* Make tables + modals match dark theme */
table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: rgba(255,255,255,0.04);
  font-weight: 700;
  color: var(--text-2);
}

tr:hover {
  background: rgba(255,255,255,0.03);
}

/* All Transactions screen */
.card-header-row {
  margin-bottom: 16px;
}
.card-header-row h2 {
  margin: 0;
  font-size: 1.35em;
  color: var(--text);
}
.filters-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}
.filter-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}
.table-wrap .table {
  margin: 0;
  min-width: 700px;
}

/* Money/numbers align in columns */
.amount-positive,
.amount-negative,
.amount-transfer,
.break-row strong,
td .amount-positive,
td .amount-negative {
  font-variant-numeric: tabular-nums;
}

/* Long labels / payee names: prevent awkward wrapping */
.stat-label,
.transaction-info,
.card-header-row h2 {
  overflow-wrap: anywhere;
  max-width: 100%;
}
.payee-name,
.transaction-info .category,
.savings-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

@media (max-width: 767px) {
  .table-wrap thead th:first-child,
  .table-wrap tbody td:first-child {
    position: sticky;
    left: 0;
    background: var(--surface-2);
    z-index: 1;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.15);
  }
}
.tx-summary {
  margin-top: 10px;
  color: var(--text-2);
  font-size: 0.9em;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  padding: 30px;
  border-radius: 15px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.modal-header {
  margin-bottom: 20px;
}

.modal-header h3 {
  color: var(--text);
  font-size: 1.5em;
}

/* ========================================
   MODAL Z-INDEX STACKING
   ======================================== */

.modal.modal-layer-1 {
  z-index: 1000;
}

.modal.modal-layer-2 {
  z-index: 1100;
  background: rgba(0, 0, 0, 0.7);
}

.modal.modal-layer-3 {
  z-index: 1200;
  background: rgba(0, 0, 0, 0.8);
}

/* =========================
   FORMS
========================= */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-2);                    /* changed */
  font-weight: 700;                        /* changed */
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1em;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* ========================================
   MODALS - MOBILE OPTIMIZATION
   ======================================== */

/* Treat form footers inside modals as modal footers */
.modal .form-actions {
  padding-top: 16px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.modal .form-actions .btn {
  flex: 1;
  min-width: 0;
  padding: 10px 16px;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Smaller utility buttons (like Adjust / Add contribution) should size to content */
.modal .form-actions .btn.goal-adjust-saved-btn,
.modal .form-actions .btn.goal-add-contribution-btn {
  flex: 0 1 auto;
  white-space: nowrap;
}

/* Date input calendar icon */
input[type="date"]::-webkit-calendar-picker-indicator {
  background: transparent;
  color: var(--text);
  cursor: pointer;
  opacity: 0.7;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

@media (max-width: 767px) {
  .modal {
    padding: 12px;
    box-sizing: border-box;
    align-items: flex-start;
    padding-top: 40px;
  }

  .modal-content {
    width: 100%;
    max-width: 500px;
    max-height: calc(100vh - 60px);
    border-radius: 10px;
  }

  .modal-header {
    margin-bottom: 14px;
  }

  .modal-header h3 {
    font-size: 1.1em;
  }

  .modal .form-group {
    margin-bottom: 16px;
  }

  .modal .form-actions {
    padding-top: 12px;
    flex-direction: column;
    gap: 8px;
  }

  .modal .form-actions .btn {
    width: 100%;
    flex: 1;
    min-width: 0;
  }
}

/* ========================================
   MODAL FOOTER - MINIMALIST DESIGN
   ======================================== */

.modal-footer-compact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  gap: 12px;
}

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

.modal-actions-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn-icon-modal {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 20px;
  font-weight: 600;
  flex-shrink: 0;
}

.btn-icon-modal:hover {
  background: var(--surface-2);
  border-color: var(--primary, var(--essential));
  color: var(--primary, var(--essential));
  transform: scale(1.05);
}

.btn-icon-modal:active {
  transform: scale(0.95);
}

.btn-icon-modal .icon {
  display: block;
  line-height: 1;
}

.btn-compact {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  white-space: nowrap;
  min-width: 80px;
}

@media (max-width: 767px) {
  .modal-footer-compact {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .modal-actions-left {
    order: 2;
    width: 100%;
    justify-content: center;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
  }

  .modal-actions-right {
    order: 1;
    width: 100%;
    margin-left: 0;
  }

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

  .btn-icon-modal {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }
}

@media (max-width: 360px) {
  .modal-footer-compact {
    padding: 10px 12px;
  }

  .btn-compact {
    padding: 10px 16px;
    font-size: 13px;
    min-width: 70px;
  }
}

/* Tooltip for icon buttons (desktop only) */
.btn-icon-modal::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1001;
}

.btn-icon-modal::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.btn-icon-modal:hover::after,
.btn-icon-modal:hover::before {
  opacity: 1;
}

@media (max-width: 767px) {
  .btn-icon-modal::after,
  .btn-icon-modal::before {
    display: none;
  }
}

/* iOS zoom prevention: 16px on mobile only (<767px) */
@media (max-width: 767px) {
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  input[type="month"],
  select,
  textarea {
    font-size: 16px;
  }
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: rgba(0,217,184,0.65);      /* changed: teal focus */
  box-shadow: 0 0 0 2px rgba(0,217,184,0.18); /* added */
}

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

/* =========================
   TRANSACTIONS LIST
   Changed: light tiles -> dark tiles, essential blue accent
========================= */
.recent-transactions {
  max-height: 400px;
  overflow-y: auto;
}

.transaction-item {
  padding: 15px;
  border-left: 4px solid var(--essential); /* changed */
  background: rgba(255,255,255,0.03);      /* changed */
  margin-bottom: 10px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);         /* added */
}

.transaction-info {
  flex: 1;
}

.transaction-category {
  color: var(--text);                      /* changed */
  font-weight: 700;                        /* changed */
  margin-bottom: 5px;
}

.transaction-date {
  color: var(--text-2);                    /* changed */
  font-size: 0.85em;
}

.transaction-account {
  color: var(--text-2);
  font-size: 0.85em;
  margin-top: 4px;
}

.form-hint {
  color: var(--text-2);
  font-size: 0.85em;
  margin-top: 6px;
}

.account-warning {
  font-size: 0.85em;
  color: var(--negative);
  margin: 8px 0;
  padding: 8px;
  background: rgba(255, 59, 92, 0.1);
  border-radius: 6px;
  border: 1px solid rgba(255, 59, 92, 0.2);
}

.transaction-amount {
  font-size: 1.3em;
  font-weight: 800;                        /* changed */
  color: var(--text);                      /* changed */
}

.amount-positive {
  color: var(--positive);                  /* changed */
}

.amount-negative {
  color: var(--negative);                  /* changed */
}

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

/* helps the chart keep a nice height when responsive */
.chart-wrap {
  height: 320px;
}

@media (max-width: 767px) {
  .chart-wrap {
    height: 260px;
  }
}

/* =========================
   RESPONSIVE (Breakpoints: 767 / 768–979 / 980+)
========================= */
@media (max-width: 979px) {
  .overview-shell {
    grid-template-columns: 1fr;
  }
  .overview-rail {
    position: static;
  }
  .overview-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  h1 {
    font-size: 1.8em;
  }
  table {
    font-size: 0.9em;
  }
  th, td {
    padding: 8px;
  }
}

/* Stats grid: 4 cols desktop, 2 tablet (600–767), 1 mobile (<600) */
@media (max-width: 767px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
}

@media (max-width: 599px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Filters row: 2 cols tablet, 1 col mobile */
@media (min-width: 768px) and (max-width: 979px) {
  .filters-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 767px) {
  .filters-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .filter-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

/* =========================
   PYF Dashboard Layout (NEW)
   ========================= */

.month-switch {
  display: flex;
  gap: 8px;
  align-items: center;
}

#month-picker {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
}

.stat-meta {
  margin-top: 8px;
  font-size: 0.85em;
  color: var(--text-2);
  white-space: normal;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* Savings tab (sinking funds) */
.savings-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1100px) {
  .savings-shell {
    grid-template-columns: 1fr;
  }
}

.savings-totals-card {
  padding: 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15,23,42,0.95);
}
.savings-totals-card .stat-value {
  font-size: 1.4em;
  font-weight: 700;
  color: var(--text);
}
.savings-totals-card .stat-label {
  font-size: 0.85em;
  color: var(--text-2);
  margin-bottom: 2px;
}

.savings-chart-card {
  padding: 18px;
}
.savings-chart-title {
  margin: 0 0 12px;
  font-size: 1em;
  color: var(--text-2);
}
.savings-bar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.savings-bar-empty {
  margin: 0;
  font-size: 0.9em;
  color: var(--text-2);
}
.savings-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.savings-bar-label {
  flex: 0 0 120px;
  font-size: 0.9em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.savings-bar-track {
  flex: 1;
  display: flex;
  height: 20px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.savings-bar-fill.saved {
  background: var(--positive);
  opacity: 0.85;
}
.savings-bar-fill.left {
  background: rgba(255,255,255,0.06);
}
.savings-bar-meta {
  color: var(--text-2);
  font-size: 0.85em;
  margin-left: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.savings-goal-missing-account {
  background: rgba(255, 180, 0, 0.08);
}
.missing-account-label {
  color: var(--negative);
  font-weight: 600;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 0.82em;
  margin-right: 4px;
}
.text-muted {
  color: var(--text-2);
  text-align: center;
  padding: 12px;
}

.cell-muted {
  color: var(--text-2);
}
.cell-past-due,
.cell-warn {
  color: var(--negative);
  font-weight: 700;
}

/* ========================================
   SAVINGS GOALS - ENHANCED LAYOUT
   ======================================== */

#savings {
  padding-bottom: 80px;
}

/* Summary Stats */
.savings-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
}

.summary-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.summary-label {
  font-size: 11px;
  color: var(--text-secondary, var(--text-2));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 8px;
}

.summary-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}

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

.summary-subtitle {
  font-size: 11px;
  color: var(--text-secondary, var(--text-2));
}

/* Section Subtitle */
.section-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Quick Overview Section */
.savings-overview-section {
  padding: 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

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

.savings-quick-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

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

.quick-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.quick-item-progress {
  font-size: 11px;
  color: var(--text-secondary, var(--text-2));
  white-space: nowrap;
}

.quick-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
}

.quick-progress-fill {
  height: 100%;
  background: var(--primary, var(--essential));
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Detailed Funds Section */
.funds-section {
  padding: 16px;
}

.funds-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fund-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.fund-card:active {
  transform: scale(0.98);
  background: var(--surface);
}

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

.fund-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.fund-goal {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary, var(--text-2));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Fund Stats Grid */
.fund-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.fund-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.fund-stat .stat-label {
  font-size: 10px;
  color: var(--text-secondary, var(--text-2));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.fund-stat .stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

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

/* Fund Progress */
.fund-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fund-progress .progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
}

.fund-progress .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary, var(--essential)), #0066cc);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.fund-progress .progress-fill.warning {
  background: linear-gradient(90deg, orange, #ff8c00);
}

.fund-progress .progress-fill.complete {
  background: linear-gradient(90deg, var(--success, var(--positive)), #00cc66);
}

.progress-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.progress-percentage {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary, var(--essential));
}

.progress-percentage.warning {
  color: orange;
}

.progress-percentage.complete {
  color: var(--success, var(--positive));
}

.progress-remaining {
  font-size: 11px;
  color: var(--text-secondary, var(--text-2));
}

/* Empty State */
.funds-container .empty-state {
  padding: 40px 20px;
  text-align: center;
}

/* ========================================
   SAVINGS - MOBILE ADJUSTMENTS
   ======================================== */

@media (max-width: 767px) {
  .savings-summary {
    padding: 12px;
    gap: 10px;
  }

  .summary-card {
    padding: 14px;
  }

  .summary-value {
    font-size: 24px;
  }

  .savings-overview-section,
  .funds-section {
    padding: 12px;
  }

  .section-subtitle {
    font-size: 13px;
  }

  .fund-card {
    padding: 12px;
  }

  .fund-name {
    font-size: 15px;
  }

  .fund-goal {
    font-size: 13px;
  }

  .fund-stats {
    gap: 8px;
  }

  .fund-stat .stat-value {
    font-size: 13px;
  }
}

@media (max-width: 360px) {
  .summary-value {
    font-size: 22px;
  }

  .fund-stats {
    gap: 6px;
  }

  .fund-stat .stat-label {
    font-size: 9px;
  }

  .fund-stat .stat-value {
    font-size: 12px;
  }
}

.goal-autofill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.goal-autofill-row .btn-sm {
  margin-right: 0;
}
.goal-autofill-row .form-hint {
  color: var(--text-2);
  font-size: 0.8em;
}

#adjust-saved-hint {
  margin: 6px 0 12px;
  color: var(--text-2);
  font-size: 0.9em;
}
.form-actions .goal-adjust-saved-btn,
.form-actions .goal-add-contribution-btn {
  margin-right: 8px;
  opacity: 0.9;
}

/* Top row summary */
.pyf-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* Main overview layout */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 16px;
}

/* Overview shell: main + right rail */
.overview-shell {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}

.overview-main {
  min-width: 0;
}

.overview-rail {
  position: sticky;
  top: 18px;
  height: fit-content;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.overview-rail .stat-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--pocket);
  background: rgba(15,23,42,0.95);
}

.overview-rail .stat-label {
  font-size: 0.8em;
  color: var(--text-2);
  margin-bottom: 2px;
}

.overview-rail .stat-value {
  font-size: 1.3em;
  font-weight: 700;
}

/* PYF card compaction */
.pyf-card {
  padding: 18px;
}

.pyf-card .pyf-controls .form-group {
  margin-bottom: 10px;
}

.pyf-card .pyf-breakdown {
  margin-top: 10px;
  padding: 10px 12px;
}

.pyf-card .pyf-actions {
  margin-top: 10px;
  gap: 8px;
  flex-wrap: wrap;
}

.pyf-card input[type="range"] {
  height: 4px;
}

.pyf-card input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
}

.pyf-card input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
}

.pyf-card .pill {
  padding: 4px 8px;
  font-size: 0.85em;
}

.rail-header {
  padding: 6px 2px 2px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 8px;
}

.rail-title {
  font-weight: 800;
  font-size: 0.95em;
  color: var(--text);
  letter-spacing: 0.2px;
}

.rail-subtitle {
  font-size: 0.8em;
  color: var(--text-2);
  margin-top: 2px;
}

/* Controls */
.pyf-controls .help-text {
  margin-top: 6px;
  font-size: 0.9em;
  color: var(--text-2);
}

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

.range-row input[type="range"] {
  width: 100%;
}

.pill {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  padding: 6px 10px;
  border-radius: 999px;
  min-width: 64px;
  text-align: center;
  color: var(--text);
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.pyf-breakdown {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
}

.break-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  color: var(--text);
}

.break-row strong.pos { color: var(--positive); }
.break-row strong.debt { color: var(--debt); }

.pyf-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}


/* Tablet/mobile: stack PYF and overview */
@media (max-width: 979px) {
  .pyf-top {
    grid-template-columns: 1fr 1fr;
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 599px) {
  .pyf-top {
    grid-template-columns: 1fr;
  }
}

/* Category spending heatmap */
.heatmap-grid {
  display: grid;
  grid-template-columns: 150px repeat(12, 1fr);
  gap: 4px;
  font-size: 0.85em;
}

.heatmap-cell {
  padding: 8px;
  text-align: center;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.heatmap-header {
  font-weight: 700;
  color: var(--text-2);
}

.heatmap-value {
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8em;
}

@media print {
  .bottom-nav,
  .nav-tabs,
  .mobile-header,
  .menu-toggle-btn,
  .hamburger-btn,
  .btn,
  .header-actions,
  .month-controls {
    display: none !important;
  }

  .card {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #000;
  }

  body {
    background: white;
    color: black;
  }
}

/* Touch-friendly: full-width buttons and table actions on mobile */
@media (max-width: 599px) {
  .btn,
  .btn-primary,
  .btn-secondary {
    width: 100%;
  }

  td button,
  .transaction-item div:last-child button {
    display: block;
    width: 100%;
    margin-bottom: 4px;
    min-height: 44px;
  }
  td button:last-child,
  .transaction-item div:last-child button:last-child {
    margin-bottom: 0;
  }
}

table .btn, .transaction-item .btn {
  white-space: nowrap;
}


.btn-primary.small { padding: 6px 12px; font-size: 0.85em; }

.calendar-container {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border);
}

.calendar-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--text-2);
  font-size: 0.85em;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  min-height: 400px;
}

.calendar-day {
  border-radius: 10px;
  padding: 8px;
  min-height: 88px;
  background: rgba(15,23,42,0.95);
  border: 1px solid rgba(148,163,184,0.35);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.calendar-day:hover {
  background: rgba(139,92,246,0.1);
  border-color: var(--pocket);
}

.calendar-day.today {
  border-color: var(--pocket);
  background: rgba(139,92,246,0.2);
}

.calendar-day.other-month {
  opacity: 0.3;
  background: transparent;
}

.calendar-day-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.calendar-day-number {
  font-weight: 700;
  color: var(--text);
  font-size: 0.9em;
}

.calendar-day-events {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bill-event {
  margin: 2px 0;
}

.calendar-event {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 4px;
  font-size: 0.7em;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
}

.event-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-amount {
  flex-shrink: 0;
  margin-left: 4px;
}

.calendar-more {
  margin-top: 2px;
  background: transparent;
  border: none;
  color: var(--essential);
  font-size: 0.7em;
  cursor: pointer;
  text-align: left;
  padding: 0;
}

.bill-pending { background: rgba(59,130,246,0.3); color: var(--essential); }
.bill-paid { background: rgba(0,217,184,0.3); color: var(--positive); }
.bill-overdue { background: rgba(255,59,92,0.4); color: var(--negative); animation: pulse 2s infinite; }
.bill-estimate { background: rgba(255,255,255,0.1); color: var(--text-2); font-style: italic; }
.income-event {
  background: rgba(0,217,184,0.3) !important;
  color: var(--positive) !important;
  border-left: 2px solid var(--positive);
}
.income-received { background: rgba(0,217,184,0.4) !important; color: var(--positive); border-left: 2px solid var(--positive); }
.income-scheduled { background: rgba(59,130,246,0.2) !important; color: var(--essential); font-style: italic; }

.flash-success {
  animation: flashSuccess 0.45s ease;
}

@keyframes flashSuccess {
  0% { box-shadow: 0 0 0 rgba(0, 217, 184, 0); }
  30% { box-shadow: 0 0 0 3px rgba(0, 217, 184, 0.35); }
  100% { box-shadow: 0 0 0 rgba(0, 217, 184, 0); }
}

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

@media (prefers-reduced-motion: reduce) {
  .bill-overdue {
    animation: none;
  }
}

@media (max-width: 767px) {
  .calendar-grid { gap: 2px; }
  .calendar-day { padding: 4px; font-size: 0.75em; }
  .bill-event { font-size: 0.65em; }
}

/* =========================
   BOTTOM NAVIGATION (Mobile only)
========================= */
.bottom-nav {
  display: none;
}

@media (max-width: 767px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    min-height: 56px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 1000;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
  }

  .bottom-nav .nav-tabs {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    width: 100%;
    padding: 8px 4px;
    gap: 4px;
  }

  .bottom-nav .nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    flex: 1;
    padding: 6px 4px;
    background: transparent;
    border: none;
    color: var(--text-2);
    font-size: 0.7em;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.2s ease, background 0.2s ease;
  }

  .bottom-nav .nav-tab .nav-tab-icon {
    font-size: 1.3em;
    margin-bottom: 2px;
  }

  .bottom-nav .nav-tab .nav-tab-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .bottom-nav .nav-tab:hover,
  .bottom-nav .nav-tab:focus {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
  }

  .bottom-nav .nav-tab.active {
    color: var(--btn-primary);
  }

  /* Container padding so content isn't hidden behind bottom nav */
  .container {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0));
  }
}

/* Pull-to-refresh indicator (mobile) */
.pull-refresh-indicator {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.9em;
  color: var(--text-2);
  transition: top 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
}

.pull-refresh-indicator.visible {
  top: 12px;
  opacity: 1;
}

/* =========================
   DASHBOARD - COMPACT HERO METRIC
========================= */

.dashboard-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dashboard-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 980px) {
  .dashboard-view {
    display: grid;
    grid-template-columns: minmax(0, 2.1fr) minmax(260px, 1fr);
    gap: 20px;
    align-items: flex-start;
  }
}

.hero-metric {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  text-align: center;
  margin: 12px 0;
}

.hero-metric .metric-label {
  font-size: 11px;
  color: var(--text-secondary, var(--text-2));
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.hero-metric .metric-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary, var(--pocket));
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.hero-metric .metric-value.negative {
  color: var(--danger, var(--negative));
}

.hero-metric .metric-subtitle {
  font-size: 11px;
  color: var(--text-secondary, var(--text-2));
}

/* ========================================
   QUICK ACTIONS - COMPACT
======================================== */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.quick-actions .btn {
  padding: 10px 16px;
  font-size: 13px;
  min-height: 42px;
  font-weight: 500;
}

.quick-actions .icon {
  margin-right: 6px;
}

@media (min-width: 980px) {
  .quick-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 10px 0 8px;
  }

  .quick-actions .btn {
    min-height: 40px;
  }
}

/* Overview sidebar summary cards (desktop) */
.overview-summary-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
}

.overview-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.overview-summary-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.overview-summary-month {
  font-size: 11px;
  color: var(--text-secondary, var(--text-2));
}

.overview-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-bottom: 4px;
}

.overview-summary-row .label {
  color: var(--text-secondary, var(--text-2));
}

.overview-summary-row .value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Reports header + sections */
.report-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}

.report-month {
  color: var(--text-2);
}

.report-section {
  margin-bottom: 32px;
}

.report-section h2 {
  margin-bottom: 16px;
  color: var(--text);
  font-size: 1.25em;
}

.pyf-metrics,
.health-metrics {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

@media (min-width: 980px) {
  .pyf-metrics {
    grid-template-columns: repeat(3, 1fr);
  }
  .health-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) and (max-width: 979px) {
  .pyf-metrics,
  .health-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767px) {
  .pyf-metrics,
  .health-metrics {
    grid-template-columns: 1fr;
  }
  .report-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

.metric-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.metric-card .metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.metric-card .metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.metric-card .metric-value.negative {
  color: var(--negative);
}

.metric-card .metric-subtitle {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.4;
}

.progress-bar-thin {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
  margin: 8px 0;
}

.progress-bar-thin .progress-fill {
  height: 100%;
  width: 0%;
  background: var(--btn-primary);
  transition: width 200ms ease;
}

.report-breakdown.pyf-breakdown h3 {
  margin-bottom: 12px;
  font-size: 1em;
  color: var(--text-2);
}

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

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

.breakdown-item .label {
  color: var(--text-2);
}

.breakdown-item .value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Tooltip popup */
.tooltip-popup {
  position: fixed;
  z-index: 10000;
  max-width: 300px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: none;
}

.tooltip-popup p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.info-icon {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}

.info-icon:active {
  transform: scale(0.98);
}

/* ========================================
   RECENT TRANSACTIONS - COMPACT
======================================== */

.recent-transactions-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  margin: 16px 0;
  overflow: hidden;
}

.recent-transactions-section .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.recent-transactions-section .section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.recent-transactions-section .btn-link {
  background: none;
  border: none;
  color: var(--primary, var(--pocket));
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.recent-transactions-section .btn-link:hover {
  background: var(--surface);
}

.recent-transactions-section .transactions-container {
  padding: 0;
  min-height: 120px;
}

.recent-transactions-section .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  text-align: center;
}

.recent-transactions-section .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.recent-transactions-section .empty-message {
  font-size: 13px;
  color: var(--text-secondary, var(--text-2));
  margin: 0 0 12px 0;
}

.recent-transactions-section .transaction-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
  cursor: pointer;
  min-height: 54px;
}

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

.recent-transactions-section .transaction-item:hover {
  background: var(--surface);
}

.recent-transactions-section .transaction-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.recent-transactions-section .transaction-icon {
  width: 36px;
  height: 36px;
  background: var(--surface);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.recent-transactions-section .transaction-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.recent-transactions-section .transaction-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-transactions-section .transaction-date {
  font-size: 11px;
  color: var(--text-secondary, var(--text-2));
}

.recent-transactions-section .transaction-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
  margin-left: 10px;
}

.recent-transactions-section .transaction-amount {
  font-size: 14px;
  font-weight: 600;
  color: var(--success, var(--positive));
  font-variant-numeric: tabular-nums;
}

.recent-transactions-section .transaction-amount.negative {
  color: var(--danger, var(--negative));
}

.recent-transactions-section .transaction-category {
  font-size: 10px;
  color: var(--text-secondary, var(--text-2));
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
}

.recent-transactions-section .section-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.recent-transactions-section .btn-text-danger {
  background: none;
  border: none;
  color: var(--danger, var(--negative));
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
  transition: background 0.2s;
  opacity: 0.7;
}

.recent-transactions-section .btn-text-danger:hover {
  background: rgba(255, 59, 92, 0.1);
  opacity: 1;
}

/* ========================================
   DASHBOARD - MOBILE ADJUSTMENTS
======================================== */

@media (max-width: 767px) {
  .hero-metric {
    padding: 14px 16px;
    margin: 10px 0;
  }

  .hero-metric .metric-value {
    font-size: 28px;
  }

  .hero-metric .metric-label,
  .hero-metric .metric-subtitle {
    font-size: 10px;
  }

  .quick-actions {
    grid-template-columns: 1fr;
    gap: 6px;
    margin: 10px 0;
  }

  .quick-actions .btn {
    padding: 10px 14px;
    font-size: 13px;
  }

  .recent-transactions-section .section-header {
    padding: 10px 14px;
  }

  .recent-transactions-section .section-title {
    font-size: 14px;
  }

  .recent-transactions-section .transaction-item {
    padding: 10px 14px;
    min-height: 52px;
  }

  .recent-transactions-section .transaction-icon {
    width: 34px;
    height: 34px;
    font-size: 17px;
  }

  .recent-transactions-section .transaction-name {
    font-size: 13px;
  }

  .recent-transactions-section .transaction-amount {
    font-size: 13px;
  }

  .recent-transactions-section .empty-icon {
    font-size: 36px;
  }
}

/* ========================================
   DESKTOP OPTIMIZATIONS (Min-width: 980px)
   ======================================== */

@media (min-width: 980px) {

  /* 1. Dashboard: Wider Income Cards */
  /* Replaces the narrow mobile grid with a spacious layout */
  .income-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: 24px;
  }

  .income-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  /* 2. All Transactions: Centered Table View */
  /* Constrains width so it reads like a document, not a ticker tape */
  .transactions-timeline {
    max-width: 1000px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
  }

  /* 3. Table Visual Polish */
  .transactions-table th {
    background: var(--surface-2);
    font-size: 12px;
    letter-spacing: 0.5px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
  }

  .transactions-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
  }

  .transactions-table tr:hover {
    background-color: rgba(255,255,255,0.02);
  }

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

/* TOAST NOTIFICATIONS */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10000;
  pointer-events: none; /* Let clicks pass through */
}

.toast {
  background: var(--surface-2);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  font-size: 14px;
  border-left: 4px solid var(--primary, var(--btn-primary));
  opacity: 0;
  transform: translateY(20px);
  animation: slideUpFade 0.3s forwards;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-color: var(--positive); }
.toast.error { border-color: var(--negative); }
.toast.info { border-color: var(--essential); }

@keyframes slideUpFade {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  to { opacity: 0; transform: scale(0.9); }
}

/* ========================================
   UI POLISH: DASHBOARD & VISUALS
   ======================================== */

/* 1. Hero Cards "Glow Up" */
.hero-metric {
  position: relative;
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.hero-metric:first-child {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(36, 42, 61, 0.6));
  border-color: rgba(139, 92, 246, 0.3);
}

.hero-metric:nth-child(2) {
  background: linear-gradient(135deg, rgba(0, 217, 184, 0.1), rgba(36, 42, 61, 0.6));
  border-color: rgba(0, 217, 184, 0.2);
}

.hero-metric .metric-value {
  font-weight: 800;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 2. Quick Action Buttons (Pill Shape + Icons) */
.quick-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  margin-bottom: 24px;
}

.quick-actions .btn {
  flex: 1;
  border-radius: 50px;
  justify-content: center;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  padding: 12px;
}

.quick-actions .btn:active {
  transform: scale(0.96);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* 3. Sidebar User Profile (Pinned to Bottom) */
#auth-user-view {
  margin-top: auto;
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  border: 1px solid var(--border);
  text-align: center;
}

#auth-user-email {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 12px;
  font-family: monospace;
  opacity: 0.9;
}

#auth-user-view .btn {
  width: 100%;
  font-size: 13px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 59, 92, 0.1);
  color: var(--negative);
  border: 1px solid rgba(255, 59, 92, 0.2);
}