/* ============================================================
   ROOT VARIABLES
   ============================================================ */
:root {
  --bg:          #f0f2f5;
  --surface:     #ffffff;
  --surface2:    #f8f9fa;
  --border:      #e0e3e8;
  --text:        #1a1d23;
  --text2:       #6b7280;
  --primary:     #2563eb;
  --primary-h:   #1d4ed8;
  --success:     #16a34a;
  --success-h:   #15803d;
  --danger:      #dc2626;
  --danger-h:    #b91c1c;
  --warning:     #d97706;
  --purple:      #7c3aed;
  --teal:        #0891b2;
  --gray:        #6b7280;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow:      0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.14);
  --radius:      12px;
  --radius-sm:   8px;
  --transition:  0.28s cubic-bezier(0.4,0,0.2,1);
}

.dark-mode {
  --bg:          #0f1117;
  --surface:     #1a1d27;
  --surface2:    #242735;
  --border:      #2e3347;
  --text:        #e8eaf0;
  --text2:       #8b92a8;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.3);
  --shadow:      0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.5);
}

/* ============================================================
   BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  line-height: 1.5;
}

/* ============================================================
   DARK MODE SMOOTH TRANSITION — all major surfaces
   ============================================================ */
/* Broad catch-all: anything that uses CSS vars animates with body */
.app-wrapper, .container, .dropdown, .dropdown-content,
.form, .form input, .form select, .form button,
.table-wrapper, table, thead th, tbody tr, td,
.month-nav button, .filter-sort-row select,
.search-input, h1, h2, h3, h4, p,
.expense-total, .summary-card-inner, .summary-share-btn,
#bottomNav, .bnav-item, #networkStatus,
.pinned-section, .pinned-chip, .category-chip,
.trash-note, input, select, textarea,
.export-btn, button, .auth-card {
  transition:
    background var(--transition),
    background-color var(--transition),
    color var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}

/* Toggle button — special spin+scale animation on click */
#toggleDarkMode {
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition),
    transform 0.18s cubic-bezier(0.34,1.56,0.64,1) !important;
}
#toggleDarkMode:active {
  transform: scale(0.88) rotate(-12deg);
}
/* Emoji icon smooth flip */
#toggleDarkMode.toggling {
  animation: toggleSpin 0.36s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes toggleSpin {
  0%   { transform: scale(1) rotate(0deg); }
  40%  { transform: scale(0.82) rotate(-18deg); }
  70%  { transform: scale(1.1) rotate(8deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* Main app content needs padding restored */
#appScreen {
  padding: 20px 16px;
}

.app-wrapper {
  max-width: 960px;
  margin: 20px auto;
  background: var(--surface);
  padding: 28px 28px 36px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

.container {
  max-width: 960px;
  margin: 0 auto;
  background: var(--surface);
  padding: 28px 28px 36px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1 {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0 0 28px;
  color: var(--text);
  letter-spacing: -0.5px;
}

h2 {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 600;
  margin: 32px 0 16px;
  color: var(--text);
  position: relative;
}

h2::after {
  content: '';
  display: block;
  width: 48px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
  margin: 6px auto 0;
}

h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin: 20px 0 8px; }
h4 { font-size: 0.9rem; font-weight: 600; color: var(--text2); margin: 16px 0 8px; }

/* ============================================================
   HEADER BUTTONS — now rendered inside .app-header as .header-icon-btn
   Legacy selectors kept so JS-toggled classes still apply
   ============================================================ */
#toggleDarkMode, .logout-btn, #logoutBtn {
  /* base reset — visual style comes from .header-icon-btn */
  cursor: pointer;
  transition: all var(--transition);
}
.logout-btn, #logoutBtn {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger) !important;
}
.logout-btn:hover, #logoutBtn:hover { background: var(--danger-h); border-color: var(--danger-h) !important; }

/* ============================================================
   FORM
   ============================================================ */
.form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  background: var(--surface2);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.form input,
.form select,
.form button {
  padding: 10px 14px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  flex: 1 1 150px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form input:focus,
.form select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.form button {
  background: var(--success);
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
  flex: 1 1 130px;
}
.form button:hover { background: var(--success-h); transform: translateY(-1px); }
.form button:active { transform: none; }

/* ============================================================
   BUTTONS (general)
   ============================================================ */
button {
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--primary);
  color: #fff;
  padding: 11px 14px;
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

td {
  padding: 10px 14px;
  text-align: center;
  color: var(--text);
  vertical-align: middle;
}

/* Edit / Delete table buttons */
td button {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  margin: 0 2px;
  border-radius: 6px;
  color: #fff;
}
td button:first-of-type { background: var(--primary); }
td button:first-of-type:hover { background: var(--primary-h); }
td button:last-of-type { background: var(--danger); }
td button:last-of-type:hover { background: var(--danger-h); }

/* ============================================================
   DROPDOWN
   ============================================================ */
.dropdown {
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.dropdown-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--primary);
  color: #fff;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 0;
  letter-spacing: 0.2px;
}
.dropdown-btn:hover { background: var(--primary-h); }

.dropdown-btn .caret {
  transition: transform 0.25s ease;
  font-size: 14px;
  opacity: 0.85;
}
.dropdown-btn.active .caret { transform: rotate(180deg); }

.dropdown-content {
  max-height: 0;
  overflow: hidden;
  background: var(--surface);
  border-top: none;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 16px;
}
.dropdown-content.open {
  max-height: 300000px;
  padding: 16px;
}

/* ============================================================
   MONTH NAV CHIPS
   ============================================================ */
.month-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.month-nav button {
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  padding: 5px 13px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 20px;
}
.month-nav button.active,
.month-nav button:hover {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

/* ============================================================
   EXPENSE TOTAL BANNER
   ============================================================ */
.expense-total {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff;
  border-radius: var(--radius-sm);
  letter-spacing: 0.2px;
}

/* ============================================================
   FILTER / SORT ROW
   ============================================================ */
.filter-sort-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-sort-row select {
  flex: 1 1 200px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.filter-sort-row select:focus { border-color: var(--primary); }

/* ============================================================
   SEARCH INPUT
   ============================================================ */
.search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ============================================================
   CHARTS
   ============================================================ */
.chart-wrapper {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
  padding: 8px 0;
}
.chart {
  max-width: 400px;
  max-height: 260px;
}

/* Monthly bar charts */
#monthlyChartWrapper,
#monthlyIncomeChartWrapper {
  height: 320px;
}
/* Monthly-by-Category bar chart */
#monthCatWrapper {
  height: 420px;
}
/* Income vs Expense comparison chart */
#comparisonChartWrapper {
  height: 420px;
}
/* Pie charts — full width on mobile so they're easy to read */
#categoryChartWrapper canvas,
#incomeCategoryChartWrapper canvas {
  max-width: 400px;
  max-height: 340px;
}
@media (max-width: 600px) {
  #monthlyChartWrapper,
  #monthlyIncomeChartWrapper {
    height: 340px;
  }
  #monthCatWrapper {
    height: 400px;
  }
  #comparisonChartWrapper {
    height: 430px;
  }
  #categoryChartWrapper,
  #incomeCategoryChartWrapper {
    justify-content: center;
    padding: 0 8px;
  }
  #categoryChartWrapper canvas,
  #incomeCategoryChartWrapper canvas {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 380px !important;
  }
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.hidden { display: none !important; }



.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 22px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  background: var(--surface2);
  color: var(--text2);
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 0;
  border: none;
}
.auth-tab.active {
  background: var(--primary);
  color: #fff;
}

.auth-form { flex-direction: column; }
.auth-form input, .auth-form button {
  flex: 1 1 auto;
  width: 100%;
}

.auth-error {
  color: var(--danger);
  text-align: center;
  min-height: 20px;
  font-size: 13.5px;
  margin-bottom: 4px;
}

.link-btn {
  background: none;
  color: var(--primary);
  padding: 4px;
  font-size: 13px;
  text-decoration: underline;
  font-weight: normal;
  border: none;
}
.link-btn:hover { opacity: 0.75; }

/* ============================================================
   MIGRATE BUTTON
   ============================================================ */
.migrate-btn {
  display: block;
  width: 100%;
  background: linear-gradient(135deg, var(--warning), #f59e0b);
  color: #fff;
  margin-bottom: 20px;
  padding: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: none;
  cursor: pointer;
}
.migrate-btn:hover { opacity: 0.9; }

/* ============================================================
   EXPORT BUTTONS
   ============================================================ */
.export-btn {
  display: block;
  width: 100%;
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  color: #fff;
}
.export-btn { background: var(--purple); }
.export-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.excel-btn { background: #16a34a; }
.json-btn    { background: #b45309; }
.restore-btn { background: #0e7490; cursor: pointer; text-align: center; }

/* Backup row — two buttons side by side */
.backup-row {
  display: flex;
  gap: 10px;
  margin-bottom: 0;
}
.backup-row .export-btn {
  flex: 1;
  margin-bottom: 10px;
}

/* ============================================================
   PINNED ITEMS
   ============================================================ */
.pinned-section {
  margin-bottom: 20px;
  background: var(--surface2);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.pinned-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.pinned-chip {
  background: #fef3c7;
  color: #92400e;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #fde68a;
  font-weight: 500;
  transition: all var(--transition);
}
.pinned-chip:hover { background: #fde68a; }

.dark-mode .pinned-chip {
  background: #78350f;
  color: #fef3c7;
  border-color: #92400e;
}

.pinned-chip .remove-pin {
  color: var(--danger);
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  font-size: 12px;
}

.pinned-add {
  display: flex;
  gap: 8px;
}
.pinned-add input {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.pinned-add input:focus { border-color: var(--warning); }
.pinned-add button {
  background: #d97706;
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
}
.pinned-add button:hover { background: #b45309; }

/* ============================================================
   CATEGORIES
   ============================================================ */
.category-btn { background: var(--teal); }
.category-btn:hover { background: #0e7490; }

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.category-chip {
  background: #e0f2fe;
  color: #0c4a6e;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #bae6fd;
  font-weight: 500;
}
.dark-mode .category-chip {
  background: #0c4a6e;
  color: #e0f2fe;
  border-color: #0369a1;
}

.category-chip .edit-cat { cursor: pointer; color: inherit; }
.category-chip .remove-cat { cursor: pointer; color: var(--danger); font-weight: 700; font-size: 12px; }

/* ============================================================
   TRASH
   ============================================================ */
.trash-btn { background: var(--gray); }
.trash-btn:hover { background: #4b5563; }

.trash-note {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 14px;
  text-align: center;
  background: var(--surface2);
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
}

.spinner {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(255,255,255,.2);
  border-top: 4px solid #fff;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
  margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 92%;
}

.toast {
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: toastIn 0.22s ease, toastOut 0.22s ease 2.78s forwards;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

@keyframes toastIn  { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .container { padding: 16px 14px 24px; }
  h1 { font-size: 1.4rem; }
  .form input, .form select, .form button { flex: 1 1 100%; }
  .chart { max-width: 100%; }
  .filter-sort-row select { flex: 1 1 100%; }
}

/* ============================================================
   MODERN AUTH SCREEN — LIVE ANIMATED
   ============================================================ */

/* ---- Full-screen container ---- */
.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050d1f;
  padding: 20px;
  overflow: hidden;
  z-index: 100;
}

/* ---- Particle canvas ---- */
.auth-particle-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ---- Morphing gradient orbs ---- */
.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}
.auth-orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #4f46e5 0%, transparent 70%);
  top: -180px; left: -120px;
  opacity: 0.55;
  animation: orbDrift1 12s ease-in-out infinite alternate;
}
.auth-orb-2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, #0ea5e9 0%, transparent 70%);
  bottom: -140px; right: -100px;
  opacity: 0.5;
  animation: orbDrift2 10s ease-in-out infinite alternate;
}
.auth-orb-3 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, #a855f7 0%, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.3;
  animation: orbPulse 6s ease-in-out infinite;
}
@keyframes orbDrift1 {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(60px, 80px) scale(1.18); }
}
@keyframes orbDrift2 {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(-50px, -60px) scale(1.12); }
}
@keyframes orbPulse {
  0%,100% { opacity:0.25; transform:translate(-50%,-50%) scale(1); }
  50%      { opacity:0.45; transform:translate(-50%,-50%) scale(1.3); }
}

/* ---- Floating finance icons ---- */
.auth-float-icons {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.afi {
  position: absolute;
  bottom: -40px;
  left: var(--x, 50%);
  font-size: 22px;
  opacity: 0;
  animation: floatUp 8s ease-in infinite;
  animation-delay: var(--d, 0s);
  transform-origin: center;
  scale: var(--s, 1);
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.3));
}
@keyframes floatUp {
  0%   { opacity:0;   transform: translateY(0) rotate(0deg); }
  10%  { opacity:0.7; }
  80%  { opacity:0.5; }
  100% { opacity:0;   transform: translateY(-110vh) rotate(360deg); }
}

/* ---- Card ---- */
.auth-card {
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(28px) saturate(1.6);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 24px;
  padding: 42px 38px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.07),
    0 32px 80px rgba(0,0,0,0.6),
    0 0 60px rgba(79,70,229,0.15);
  position: relative;
  z-index: 1;
  overflow: hidden;
  animation: cardIn 0.7s cubic-bezier(0.22,1,0.36,1) both;
}
@keyframes cardIn {
  from { opacity:0; transform:translateY(40px) scale(0.94); }
  to   { opacity:1; transform:none; }
}

/* Card shimmer sweep */
.auth-card-shine {
  position: absolute;
  top: -100%;
  left: -60%;
  width: 60%;
  height: 300%;
  background: linear-gradient(105deg, transparent 20%, rgba(255,255,255,0.06) 50%, transparent 80%);
  animation: shineSweep 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes shineSweep {
  0%   { transform: translateX(-20%) skewX(-15deg); opacity:0; }
  30%  { opacity:1; }
  60%  { transform: translateX(200%) skewX(-15deg); opacity:0; }
  100% { transform: translateX(200%) skewX(-15deg); opacity:0; }
}

/* ---- Logo with pulse ring ---- */
.auth-logo-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-logo-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(99,102,241,0.6);
  animation: ringPulse 2.4s ease-in-out infinite;
}
.auth-logo-ring::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(14,165,233,0.4);
  animation: ringPulse 2.4s ease-in-out 0.8s infinite;
}
@keyframes ringPulse {
  0%,100% { transform:scale(1); opacity:0.7; }
  50%     { transform:scale(1.25); opacity:0; }
}
.auth-logo {
  font-size: 2.8rem;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 4px 16px rgba(99,102,241,0.6));
  animation: logoPop 0.7s cubic-bezier(0.34,1.56,0.64,1) 0.2s both;
}
@keyframes logoPop {
  from { transform: scale(0.3) rotate(-25deg); opacity:0; }
  to   { transform: none; opacity:1; }
}

/* ---- Title ---- */
.auth-title {
  text-align: center;
  font-size: 1.65rem;
  font-weight: 800;
  background: linear-gradient(135deg, #e0e7ff 0%, #a5b4fc 50%, #67e8f9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 6px;
  letter-spacing: -0.5px;
  animation: titleSlide 0.6s cubic-bezier(0.22,1,0.36,1) 0.3s both;
}
@keyframes titleSlide {
  from { opacity:0; transform:translateY(12px); }
  to   { opacity:1; transform:none; }
}

/* Typewriter subtitle */
.auth-subtitle {
  text-align: center;
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  margin: 0 0 22px;
  min-height: 18px;
  letter-spacing: 0.2px;
}
.auth-subtitle::after {
  content: '|';
  opacity: 1;
  animation: blink 0.7s step-end infinite;
}
@keyframes blink {
  0%,100% { opacity:1; }
  50%     { opacity:0; }
}

/* ---- Tabs with sliding pill ---- */
.auth-tabs {
  position: relative;
  display: flex;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 22px;
  gap: 0;
}
.auth-tab-slider {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: linear-gradient(135deg, rgba(99,102,241,0.6), rgba(14,165,233,0.5));
  border-radius: 9px;
  transition: transform 0.3s cubic-bezier(0.34,1.4,0.64,1);
  box-shadow: 0 2px 12px rgba(99,102,241,0.35);
  pointer-events: none;
}
.auth-tabs.signup-active .auth-tab-slider {
  transform: translateX(100%);
}
.auth-tab {
  flex: 1;
  background: transparent;
  color: rgba(255,255,255,0.5);
  border: none;
  border-radius: 9px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.25s ease;
  position: relative;
  z-index: 1;
  letter-spacing: 0.2px;
}
.auth-tab.active { color: #fff; }

/* ---- Form fields ---- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: formIn 0.35s ease both;
}
@keyframes formIn {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:none; }
}
.auth-field {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 0 14px;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
  position: relative;
}
.auth-field:focus-within {
  border-color: rgba(99,102,241,0.7);
  background: rgba(99,102,241,0.1);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15), 0 4px 16px rgba(99,102,241,0.15);
}
/* animated bottom line */
.auth-field-line {
  position: absolute;
  bottom: 0; left: 14px; right: 14px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, #6366f1, #0ea5e9);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
  pointer-events: none;
}
.auth-field:focus-within .auth-field-line { transform: scaleX(1); }

.auth-icon { font-size: 16px; margin-right: 10px; flex-shrink: 0; }
.auth-field input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 14px 0;
  font-size: 14px;
  color: #fff;
  font-family: inherit;
}
.auth-field input::placeholder { color: rgba(255,255,255,0.4); }

/* ---- Submit button ---- */
.auth-submit-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%);
  background-size: 200% 200%;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.22s, box-shadow 0.22s, background-position 0.4s;
  box-shadow: 0 4px 20px rgba(79,70,229,0.5);
  margin-top: 4px;
  letter-spacing: 0.4px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.auth-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(79,70,229,0.6);
  background-position: right center;
}
.auth-submit-btn:active { transform: scale(0.98); }
.auth-btn-text { position: relative; z-index: 1; }
.auth-btn-icon {
  position: relative;
  z-index: 1;
  font-size: 18px;
  transition: transform 0.25s;
}
.auth-submit-btn:hover .auth-btn-icon { transform: translateX(4px); }
/* ripple on click */
.auth-btn-ripple {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.15);
  border-radius: inherit;
  transform: scale(0);
  pointer-events: none;
}
.auth-submit-btn:active .auth-btn-ripple {
  animation: btnRipple 0.4s ease-out;
}
@keyframes btnRipple {
  to { transform: scale(2.5); opacity: 0; }
}

/* ---- Error & links ---- */
.auth-error {
  color: #fca5a5;
  text-align: center;
  min-height: 18px;
  font-size: 13px;
  margin-bottom: 4px;
}
.link-btn {
  background: none;
  color: rgba(255,255,255,0.5);
  border: none;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
  transition: color 0.2s;
}
.link-btn:hover { color: #c7d2fe; }

/* ---- Trust badges ---- */
.auth-badges {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}
.auth-badge {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 3px 10px;
  letter-spacing: 0.3px;
  animation: badgeFade 0.5s ease both;
}
.auth-badge:nth-child(1) { animation-delay: 0.9s; }
.auth-badge:nth-child(2) { animation-delay: 1.1s; }
.auth-badge:nth-child(3) { animation-delay: 1.3s; }
@keyframes badgeFade {
  from { opacity:0; transform:translateY(6px); }
  to   { opacity:1; transform:none; }
}

/* Dark-mode: auth screen stays vivid (it has its own bg) */
body:has(#authScreen:not(.hidden)) {
  padding: 0;
  overflow: hidden;
}

/* ============================================================
   SUMMARY CARD — top-of-page monthly overview
   ============================================================ */
.summary-card { margin: 12px 0 18px; }

.summary-card-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px 16px;
  box-shadow: var(--shadow);
}

.summary-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text2);
  text-align: center;
  letter-spacing: .3px;
}

.summary-stats {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 10px;
}

.summary-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 120px;
}

/* top row: expense & income পাশাপাশি */
.summary-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

/* Net Balance সবসময় নিচে পূর্ণ-প্রস্থে */
.summary-stat.net-balance-stat {
  width: 100%;
  justify-content: center;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 10px;
}

@media (max-width: 640px) {
  .summary-stats     { flex-direction: column; gap: 0; }
  .summary-top-row   { justify-content: space-between; }
  .summary-stat.expense { justify-content: flex-start; }
  .summary-stat.income  { justify-content: flex-end; }
  .summary-divider      { display: none; }
}

.summary-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}

.summary-label {
  font-size: 11px;
  color: var(--text2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 2px;
}

.summary-amount {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.summary-stat.expense .summary-amount { color: var(--danger); }
.summary-stat.income  .summary-amount { color: var(--success); }

.summary-divider {
  width: 1px;
  height: 44px;
  background: var(--border);
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .summary-amount { font-size: 16px; }
}

/* ============================================================
   SKELETON / SHIMMER — shown before first data load
   ============================================================ */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

.summary-skeleton {
  display: flex;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.skel-block {
  flex: 1;
  height: 52px;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--surface2) 25%,
    var(--border)   50%,
    var(--surface2) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  will-change: background-position;
}

/* ============================================================
   SKELETON / SHIMMER — expense & income card placeholders
   ============================================================ */
.skeleton-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.skel-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
}

.skel-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skel-line {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  will-change: background-position;
}
.skel-line.tall  { height: 14px; width: 60%; }
.skel-line.short { height: 10px; width: 40%; }

.skel-btn-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.skel-btn {
  width: 52px;
  height: 26px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
}

/* ============================================================
   PERFORMANCE: hint the browser about animated / scrolling layers
   ============================================================ */
.chart { will-change: auto; }          /* reset after Chart.js renders */
.loading-overlay { will-change: opacity; }
.toast { will-change: opacity, transform; }

/* ============================================================
   FEATURE 12: OFFLINE / ONLINE STATUS INDICATOR
   ============================================================ */
#networkStatus {
  display: none;
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}
#networkStatus.offline {
  display: block;
  background: #dc2626;
  color: #fff;
}
#networkStatus.back-online {
  display: block;
  background: #16a34a;
  color: #fff;
}

/* ============================================================
   FEATURE 3: BOTTOM NAVIGATION BAR (mobile only)
   ============================================================ */
/* Hide bottom nav and FAB on auth screen */
.auth-screen-active #bottomNav,
.auth-screen-active #fabAdd {
  display: none !important;
}

/* FAB hidden on all screen sizes by default; shown only in mobile media query */
#fabAdd {
  display: none;
}

#bottomNav {
  display: none;
}

@media (max-width: 640px) {
  #bottomNav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 8000;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0,0,0,.12);
    justify-content: space-around;
    align-items: center;
    height: 60px;
    padding: 0 4px;
  }
  .bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    padding: 6px 0;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
    color: var(--text2);
    font-size: 11px;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  .bnav-item .bnav-icon { font-size: 22px; line-height: 1; }
  .bnav-item.active { color: var(--primary); }
  .bnav-item:active { background: var(--surface2); }

  /* Push app content above bottom nav */
  .app-wrapper { padding-bottom: 72px !important; }

  /* FAB: floating add button — shown only on mobile */
  #fabAdd {
    display: flex;
    position: fixed;
    bottom: 72px;
    right: 18px;
    z-index: 8100;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 28px;
    line-height: 54px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(37,99,235,.5);
    cursor: pointer;
    border: none;
    outline: none;
    transition: background var(--transition), transform 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    align-items: center;
    justify-content: center;
  }
  #fabAdd:active {
    background: var(--primary-h);
    transform: scale(0.94);
    box-shadow: 0 2px 10px rgba(37,99,235,.4);
  }

  /* networkStatus sits above nav */
  #networkStatus {
    bottom: 70px;
  }
}

/* ============================================================
   FEATURE 3: TOUCH-FRIENDLY IMPROVEMENTS
   ============================================================ */
/* Bigger tap targets on mobile */
@media (max-width: 640px) {
  button, .auth-tab, select, input[type="date"],
  input[type="text"], input[type="email"], input[type="password"], input[type="number"] {
    min-height: 44px;
  }
  .dropdown-btn { min-height: 48px; font-size: 15px; }
  #expenseTable td, #eidFlatTable td { padding: 10px 8px; font-size: 13px; }
  #expenseTable th, #eidFlatTable th { padding: 8px 6px; font-size: 12px; }
}

/* ============================================================
   FEATURE 14: SHARE BUTTON on Summary Card
   ============================================================ */
.summary-share-btn {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border: none;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .3px;
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
}
.summary-share-btn:hover {
  opacity: 0.92;
  transform: translateY(-2px);
  box-shadow: 0 7px 20px rgba(37,99,235,.45);
}
.summary-share-btn:active { transform: none; }

/* Share confirmation modal */
.share-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  z-index: 10001;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.share-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px 24px 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.28s cubic-bezier(0.22,1,0.36,1);
}
@keyframes slideUp {
  from { transform: translateY(100%); opacity:0; }
  to   { transform: none; opacity:1; }
}

.share-modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 16px;
  text-align: center;
}

.share-modal-preview {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.share-modal-preview img { width: 100%; display: block; }

.share-modal-actions {
  display: flex;
  gap: 10px;
}
.share-modal-actions button {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity var(--transition), transform 0.15s;
}
.share-modal-actions button:hover { opacity: 0.88; transform: translateY(-1px); }
.share-modal-btn-share  { background: linear-gradient(135deg, var(--primary), var(--purple)); color:#fff; }
.share-modal-btn-dl     { background: var(--success); color:#fff; }
.share-modal-btn-cancel { background: var(--surface2); color: var(--text); border: 1px solid var(--border) !important; }

/* ============================================================
   FEATURE 15: THEME PICKER
   ============================================================ */
.theme-picker-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: nowrap;
  margin: 10px 0 6px;
  padding: 4px 0;
}
.theme-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.theme-swatch:hover, .theme-swatch.active {
  border-color: var(--text);
  transform: scale(1.22);
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
@media (max-width: 640px) {
  .theme-picker-row {
    gap: 16px;
  }
  .theme-swatch {
    width: 38px;
    height: 38px;
  }
}
.theme-swatch[data-theme="blue"]   { background: #2563eb; }
.theme-swatch[data-theme="purple"] { background: #7c3aed; }
.theme-swatch[data-theme="green"]  { background: #16a34a; }
.theme-swatch[data-theme="rose"]   { background: #e11d48; }
.theme-swatch[data-theme="orange"] { background: #ea580c; }

/* Theme overrides — applied on :root when data-theme attr set */
:root[data-theme="purple"] {
  --primary:   #7c3aed;
  --primary-h: #6d28d9;
}
:root[data-theme="green"] {
  --primary:   #16a34a;
  --primary-h: #15803d;
}
:root[data-theme="rose"] {
  --primary:   #e11d48;
  --primary-h: #be123c;
}
:root[data-theme="orange"] {
  --primary:   #ea580c;
  --primary-h: #c2410c;
}
/* blue is the default — no override needed */

/* ============================================================
   EXPENSE CARDS (replaces plain table rows)
   ============================================================ */
.expense-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.expense-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), background var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.expense-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--danger);
  border-radius: 4px 0 0 4px;
  transition: background var(--transition);
}
.expense-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.exp-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  transition: background var(--transition);
}
.dark-mode .exp-card-icon {
  background: linear-gradient(135deg, #450a0a, #7f1d1d);
}

.exp-card-body {
  flex: 1;
  min-width: 0;
}

.exp-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.exp-card-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.exp-card-amount {
  font-size: 15px;
  font-weight: 800;
  color: var(--danger);
  white-space: nowrap;
  flex-shrink: 0;
}

.exp-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.exp-card-date {
  font-size: 12px;
  color: var(--text2);
}

.exp-card-cat {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
}
.dark-mode .exp-card-cat {
  background: #1e3a5f;
  color: #93c5fd;
  border-color: #1d4ed8;
}

.exp-card-note {
  font-size: 12px;
  color: var(--text2);
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.exp-card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.exp-card-actions button {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  color: #fff;
  min-height: unset;
  line-height: 1.4;
}
.exp-card-actions .btn-edit  { background: var(--primary); }
.exp-card-actions .btn-edit:hover  { background: var(--primary-h); }
.exp-card-actions .btn-del   { background: var(--danger); }
.exp-card-actions .btn-del:hover   { background: var(--danger-h); }

/* Card appear animation */
@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.expense-card {
  animation: cardFadeIn 0.22s ease both;
}

/* ============================================================
   PWA INSTALL BANNER
   ============================================================ */
#pwaInstallBanner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9500;
  padding: 0 0 env(safe-area-inset-bottom);
  animation: pwaSlideUp 0.38s cubic-bezier(0.22,1,0.36,1);
}
@keyframes pwaSlideUp {
  from { transform: translateY(110%); opacity:0; }
  to   { transform: none; opacity:1; }
}

.pwa-banner-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 16px 20px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 -8px 32px rgba(0,0,0,.18);
  backdrop-filter: blur(8px);
}

.pwa-banner-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.pwa-banner-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 14px rgba(37,99,235,.4);
  flex-shrink: 0;
}

.pwa-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pwa-banner-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-banner-sub {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pwa-btn-install {
  padding: 10px 18px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff;
  border: none;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37,99,235,.4);
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}
.pwa-btn-install:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37,99,235,.5);
}

.pwa-btn-dismiss {
  padding: 8px 10px;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pwa-btn-dismiss:hover { background: var(--border); color: var(--text); }

@media (max-width: 640px) {
  /* Push app content above install banner when visible */
  .pwa-install-active .app-wrapper { padding-bottom: 120px !important; }
}

/* ============================================================
   SW UPDATE BANNER
   ============================================================ */
#swUpdateBanner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10002;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  animation: slideDown 0.35s cubic-bezier(0.22,1,0.36,1);
}
@keyframes slideDown {
  from { transform: translateY(-100%); opacity:0; }
  to   { transform: none; opacity:1; }
}

#swUpdateBanner button {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid rgba(255,255,255,.5);
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  min-height: unset;
}
#swUpdateBanner button:first-of-type {
  background: #fff;
  color: #1d4ed8;
  border-color: #fff;
}
#swUpdateBanner button:hover { opacity: 0.88; }

/* ============================================================
   CHART DOWNLOAD BUTTON
   ============================================================ */
.chart-download-btn {
  display: block;
  margin: 8px auto 4px;
  padding: 7px 20px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform 0.15s;
  letter-spacing: .3px;
}
.chart-download-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-1px);
}
.chart-download-btn:active { transform: none; }

/* ============================================================
   DEVELOPER FOOTER
   ============================================================ */
.dev-footer {
  margin-top: 56px;
  padding: 0 16px 40px;
}

.dev-footer-inner {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 32px 28px;
  background: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 60%, #9333ea 100%);
  box-shadow: 0 8px 40px rgba(99,60,200,0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

/* animated shimmer orbs */
.dev-footer-inner::before,
.dev-footer-inner::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.dev-footer-inner::before {
  width: 220px; height: 220px;
  background: rgba(255,255,255,0.07);
  top: -60px; right: -40px;
}
.dev-footer-inner::after {
  width: 140px; height: 140px;
  background: rgba(255,255,255,0.05);
  bottom: -50px; left: 30px;
}

.dev-footer-left {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.dev-footer-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 2px solid rgba(255,255,255,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.dev-footer-texts { display: flex; flex-direction: column; gap: 3px; }

.dev-footer-label {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.dev-footer-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.70);
  font-weight: 500;
}

.dev-footer-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.dev-footer-chip {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50px;
  padding: 3px 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dev-footer-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  padding: 12px 22px;
  border-radius: 50px;
  border: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

.dev-footer-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 28px rgba(0,0,0,0.24);
  background: #f0f4ff;
}

.dev-footer-btn svg {
  transition: transform 0.2s ease;
}
.dev-footer-btn:hover svg {
  transform: translateX(3px);
}

@media (max-width: 520px) {
  .dev-footer-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 24px 20px;
    gap: 18px;
  }
  .dev-footer-btn {
    width: 100%;
    justify-content: center;
    font-size: 14px;
    padding: 14px 20px;
  }
}

/* ─── App Header ─────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,.08);
}
.app-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.app-header-icon { font-size: 22px; flex-shrink: 0; }
.app-header-title h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  white-space: nowrap;
}
.app-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.header-control-group {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 4px 10px;
}
.header-theme-group { gap: 6px; padding: 4px 8px; }
.header-control-label { font-size: 14px; }
.header-select {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  padding: 0 2px;
}
.header-rate {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-rate.loading { opacity: 0.5; }
.header-icon-btn {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.header-icon-btn:hover { background: var(--surface); border-color: var(--primary); transform: scale(1.08); }
.header-logout-btn { font-size: 15px; }

/* Legacy currency bar — hidden, kept for JS compat */
#currencyBar { display: none !important; }

/* ─── Professional Header Picker (Currency & Theme) ─────────── */
.hdr-picker-wrap {
  position: relative;
}
.hdr-pill-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.hdr-pill-btn:hover {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}
.hdr-pill-btn[aria-expanded="true"] {
  border-color: var(--primary);
  background: var(--surface);
}
.hdr-pill-icon { font-size: 14px; }
.hdr-pill-caret { font-size: 10px; color: var(--text-muted); transition: transform 0.2s; }
.hdr-pill-btn[aria-expanded="true"] .hdr-pill-caret { transform: rotate(180deg); }

.hdr-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  z-index: 500;
  overflow: hidden;
  animation: hdrDropIn 0.15s ease;
}
.hdr-dropdown.open { display: block; }
@keyframes hdrDropIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.hdr-dropdown-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 10px 14px 6px;
}
.hdr-drop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.hdr-drop-item:hover { background: var(--bg); }
.hdr-drop-item.active {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  font-weight: 700;
}
.hdr-drop-sym {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.hdr-drop-name { flex: 1; }
.hdr-drop-rate {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 14px 10px;
  border-top: 1px solid var(--border);
}

/* Theme items */
.hdr-theme-dropdown { min-width: 160px; }
.hdr-theme-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.hdr-theme-item:hover { background: var(--bg); }
.hdr-theme-item.active {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  font-weight: 700;
}
.hdr-theme-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(0,0,0,.12);
}

/* ─── Keyboard Shortcut Toast ─────────────────────────────── */

/* ─── Keyboard Shortcut Toast ───────────────────────────── */
#kbShortcutPanel {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,30,40,0.96);
  color: #fff;
  border-radius: 16px;
  padding: 18px 26px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  min-width: 260px;
  backdrop-filter: blur(8px);
}
#kbShortcutPanel.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
#kbShortcutPanel h4 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  opacity: 0.7;
  text-transform: uppercase;
}
.kb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.kb-row:last-child { border-bottom: none; }
.kb-key {
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 2px 8px;
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ─── Haptic ripple visual feedback ────────────────────── */
@keyframes hapticRipple {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(var(--primary-rgb, 99,102,241), 0.4); }
  70%  { transform: scale(1.03); box-shadow: 0 0 0 8px rgba(var(--primary-rgb, 99,102,241), 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(var(--primary-rgb, 99,102,241), 0); }
}
.haptic-pulse { animation: hapticRipple 0.35s ease; }

/* ─── Savings Rate (circular progress) ─────────────────── */
.savings-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.savings-ring-wrap {
  position: relative;
  width: 70px;
  height: 70px;
  flex-shrink: 0;
}
.savings-ring-wrap svg { transform: rotate(-90deg); }
.savings-ring-bg  { fill: none; stroke: var(--border); stroke-width: 7; }
.savings-ring-fg  { fill: none; stroke-width: 7; stroke-linecap: round;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.4,0,0.2,1); }
.savings-ring-pct {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: var(--text);
}
.savings-details { flex: 1; min-width: 140px; }
.savings-details h4 { margin: 0 0 4px; font-size: 13px; color: var(--text-muted); }
.savings-amount  { font-size: 18px; font-weight: 800; }
.savings-amount.positive { color: var(--success); }
.savings-amount.negative { color: var(--danger); }
.mom-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
  margin-top: 5px;
}
.mom-badge.up   { background: rgba(239,68,68,0.13); color: #ef4444; }
.mom-badge.down { background: rgba(34,197,94,0.13); color: #22c55e; }
.mom-badge.flat { background: rgba(148,163,184,0.13); color: var(--text-muted); }

/* ─── Analytics Section ─────────────────────────────────── */
.analytics-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 18px 0;
}
.analytics-section h3 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Top 5 items */
.top5-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.top5-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
}
.top5-rank {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; flex-shrink: 0;
}
.top5-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top5-bar-wrap { width: 90px; height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; }
.top5-bar      { height: 100%; background: var(--primary); border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }
.top5-amt { font-weight: 700; min-width: 70px; text-align: right; font-size: 12px; }

/* Day-of-week heatmap */
.heatmap-grid {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 4px;
}
.heatmap-day {
  flex: 1; min-width: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
  transition: background 0.3s;
}
.heatmap-day .hd-label { font-size: 11px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.heatmap-day .hd-bar-wrap { height: 48px; display: flex; align-items: flex-end; justify-content: center; }
.heatmap-day .hd-bar {
  width: 14px; border-radius: 4px 4px 0 0;
  background: var(--primary); opacity: 0.85;
  transition: height 0.6s cubic-bezier(0.4,0,0.2,1);
}
.heatmap-day .hd-amt { font-size: 10px; margin-top: 5px; color: var(--text-muted); }

/* ─── Drag to reorder categories ───────────────────────── */
.category-item {
  cursor: grab;
  user-select: none;
}
.category-item:active { cursor: grabbing; }
.category-item.drag-over {
  border: 2px dashed var(--primary) !important;
  opacity: 0.7;
}
.drag-handle {
  display: inline-block;
  margin-right: 6px;
  font-size: 13px;
  opacity: 0.4;
  cursor: grab;
}

/* ─── Share Card (beautiful image export) ──────────────── */
.share-card-preview {
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
}
.share-modal-actions {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
}
.share-btn-wa  { background: #25D366; color: #fff; border: none; border-radius: 10px; padding: 10px 18px; font-weight: 700; cursor: pointer; font-size: 14px; }
.share-btn-tg  { background: #229ED9; color: #fff; border: none; border-radius: 10px; padding: 10px 18px; font-weight: 700; cursor: pointer; font-size: 14px; }
.share-btn-dl  { background: var(--primary); color: #fff; border: none; border-radius: 10px; padding: 10px 18px; font-weight: 700; cursor: pointer; font-size: 14px; }
.share-btn-cls { background: var(--border); color: var(--text); border: none; border-radius: 10px; padding: 10px 18px; font-weight: 600; cursor: pointer; font-size: 14px; }

/* ─── Bill Splitter ─────────────────────────────────────── */
.split-form { padding: 14px 0 8px; }
.split-form input { margin-bottom: 8px; }
#splitPeopleList { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; min-height: 36px; }
.split-person-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px;
  font-size: 13px; font-weight: 600;
}
.split-person-chip button {
  background: none; border: none; color: var(--danger);
  cursor: pointer; padding: 0; font-size: 14px; line-height: 1;
}
#splitResult { margin-top: 12px; }
.split-result-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 8px;
}
.split-result-card h4 { margin: 0 0 10px; font-size: 14px; }
.split-row {
  display: flex; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.split-row:last-child { border-bottom: none; }
.split-row .split-name { font-weight: 600; }
.split-row .split-share { color: var(--primary); font-weight: 700; }
