* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', system-ui, sans-serif; }
body {
  background: linear-gradient(135deg, #e8dff5 0%, #c3e0fc 50%, #d4f1f4 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh; overflow-y: auto; overflow-x: hidden;
  transition: color 0.3s;
}
[data-theme="dark"] body {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f2027 100%);
}

:root {
  --bg: #f8fafc;
  --card: rgba(255, 255, 255, 0.55);
  --text: #1e293b;
  --text-light: #475569;
  --border: rgba(255, 255, 255, 0.6);
  --hover: rgba(255, 255, 255, 0.8);
  --accent: #667eea;
  --accent-text: #ffffff;
  --danger: #ef4444;
  --success: #10b981;
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --bg: #0b1220;
  --card: rgba(15, 23, 42, 0.6);
  --text: #f1f5f9;
  --text-light: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --hover: rgba(255, 255, 255, 0.08);
  --accent: #818cf8;
  --accent-text: #ffffff;
}

/* Glassmorphism Global Magic */
.tab-bar, .header, .stat-card, .chart-card, .item-card, .health-banner, .modal, .toast, .advisor-input-area, .chat-container, .wish-card, .goal-card, .filter-chip, .emoji-opt, .theme-opt {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
}

/* SIDEBAR LAYOUT */
.tab-bar {
  width: 260px; height: 100vh;
  border-right: 1px solid var(--border);
  background: var(--card);
  padding: 100px 16px 24px;
  display: flex; flex-direction: column; gap: 4px;
  position: fixed; left: 0; top: 0; z-index: 50;
  overflow-y: auto;
}
.header {
  position: fixed; left: 0; top: 0; width: 260px; height: 80px;
  padding: 24px 16px; z-index: 60;
  background: transparent;
  display: flex; justify-content: space-between; align-items: center;
}
.header-left h1 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.5px; display: flex; align-items: center; gap: 8px;}
.header-left p { display: none; }
.settings-btn { background: transparent; border: 1px solid var(--border); border-radius: 6px; width: 32px; height: 32px; cursor: pointer; color: var(--text); display: grid; place-items: center; transition: 0.2s; }
.settings-btn:hover { background: var(--hover); }

/* MAIN SCROLL AREA */
.content {
  margin-left: 260px;
  max-width: 1300px;
  padding-left: 48px; padding-right: 48px;
}
@media (max-width: 768px) {
  .content { margin-left: 0; padding-top: 96px; padding-left: 16px; padding-right: 16px; }
  .tab-bar { width: 100%; height: 60px; bottom: 0; top: auto; flex-direction: row; padding: 8px; border-top: 1px solid var(--border); border-right: none; overflow-x: auto; z-index: 100; }
  .header { width: 100%; border-bottom: 1px solid var(--border); background: var(--card); }
}

/* OVERVIEW STATS BENTO */
.overview {
  padding-top: 0; padding-bottom: 16px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; position: relative; transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03); cursor: default;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 16px rgba(0,0,0,0.04); border-color: var(--text-light); }
.stat-icon { position: absolute; right: 24px; top: 24px; font-size: 1.2rem; filter: grayscale(1); opacity: 0.3; }
.stat-label { font-size: 0.75rem; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }

/* HEALTH BANNER */
.health-banner {
  padding-top: 16px; padding-bottom: 16px;
  display: flex; gap: 32px; align-items: center; justify-content: space-between;
  background: var(--accent); color: var(--accent-text); border-radius: var(--radius); margin: 0 0 16px; padding: 32px 40px;
}
@media (max-width: 768px) { .health-banner { margin: 0 0 16px; } }
.health-title { font-size: 0.8rem; font-weight: 600; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.health-label { font-size: 2.5rem; font-weight: 800; letter-spacing: -1px; margin-bottom: 8px; line-height: 1; }
.health-tip { opacity: 0.8; font-size: 0.95rem; margin-bottom: 16px; max-width: 400px; }
.health-detail-btn { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: inherit; padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 500; cursor: pointer; transition: 0.2s; }
.health-detail-btn:hover { background: rgba(255,255,255,0.2); }
.health-left { flex-shrink: 0; }
.health-right { flex: 1; min-width: 0; }
.health-gauge-wrap { position: relative; width: 120px; height: 120px; display: grid; place-items: center; }
.health-gauge { width: 120px; height: 120px; transform: rotate(-90deg); }
.gauge-bg, .gauge-fill { fill: none; stroke-width: 10; }
.gauge-bg { stroke: rgba(255, 255, 255, 0.25); }
.gauge-fill { stroke: #ffffff; stroke-linecap: round; stroke-dasharray: 314; stroke-dashoffset: 314; transition: stroke-dashoffset 0.8s ease; }
.gauge-text { position: absolute; font-size: 1.4rem; font-weight: 800; color: #fff; }
@media (max-width: 768px) { .health-gauge-wrap { width: 96px; height: 96px; } .health-gauge { width: 96px; height: 96px; } }

/* CHARTS SECTION */
.charts-section { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; padding-bottom: 16px; }
.chart-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.chart-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 24px; color: var(--text); }
.charts-empty { text-align: center; color: var(--text-light); font-size: 0.85rem; padding: 20px 0; }

/* CONTENT & TABS */
.content { padding-top: 24px; padding-bottom: 100px; width: 100%; }
@media (max-width: 768px) {
  .content { padding-top: 96px; }
}
.tab-panel { display: none; animation: fadeIn 0.3s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.tab-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border: none; background: transparent;
  color: var(--text-light); font-weight: 500; font-size: 0.95rem;
  border-radius: var(--radius-sm); cursor: pointer; transition: 0.2s; text-align: left;
}
.tab-btn:hover { background: var(--hover); color: var(--text); }
.tab-btn.active { background: var(--accent); color: var(--accent-text); }
.tab-btn i, .tab-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.stat-icon { position: absolute; right: 24px; top: 24px; opacity: 0.25; color: var(--text-light); }
.stat-icon svg { width: 24px; height: 24px; }
.empty-emoji { margin-bottom: 16px; color: var(--text-light); opacity: 0.4; }
.empty-emoji svg { width: 48px; height: 48px; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.section-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.5px; }
.add-btn { background: var(--accent); color: var(--accent-text); border: none; padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 500; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 8px; }
.add-btn:hover { opacity: 0.8; }
.add-btn.teal { background: #0ea5a3; color: #fff; }
.add-btn.pink { background: #ec4899; color: #fff; }
.add-btn.purple { background: #8b5cf6; color: #fff; }
.add-btn.orange { background: #f97316; color: #fff; }
.add-btn.blue { background: #3b82f6; color: #fff; }

/* LISTS & ITEMS */
.item-list { display: flex; flex-direction: column; gap: 12px; }
.item-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px 24px; display: flex; justify-content: space-between; align-items: center;
  transition: 0.2s;
}
.item-card:hover { border-color: var(--text-light); }
.item-name { font-weight: 600; font-size: 1rem; color: var(--text); display: flex; align-items: center; gap: 8px; }
.item-detail { font-size: 0.85rem; color: var(--text-light); margin-top: 4px; }
.item-amount { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.5px; }
.item-amount.positive { color: var(--success); }
.item-amount.negative { color: var(--text); }
.item-actions { display: flex; gap: 8px; margin-left: 16px; }
.icon-btn { width: 32px; height: 32px; border: 1px solid var(--border); background: var(--card); border-radius: 6px; color: var(--text-light); cursor: pointer; transition: 0.2s; display: grid; place-items: center; }
.icon-btn:hover { border-color: var(--text); color: var(--text); }
.icon-btn.delete:hover { border-color: var(--danger); color: var(--danger); background: rgba(239,68,68,0.05); }

/* BADGES */
.date-badge, .type-badge, .category-badge, .priority-badge {
  padding: 2px 8px; border-radius: 4px; font-size: 0.7rem; font-weight: 600; background: var(--hover); color: var(--text); display: inline-flex; align-items: center; justify-content: center;
}

/* MODALS */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.open { display: flex; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px; width: 440px; max-width: 90%; box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}
.modal-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; }
.modal-close { background: transparent; border: none; font-size: 1.2rem; color: var(--text-light); cursor: pointer; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-light); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; border: 1px solid var(--border); background: transparent; color: var(--text);
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.95rem; outline: none; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--text); }
.submit-btn { width: 100%; padding: 14px; border: none; background: var(--accent); color: var(--accent-text); border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; margin-top: 8px; transition: 0.2s; }
.submit-btn:hover { opacity: 0.9; }
.submit-btn.teal { background: #0ea5a3; color: #fff; }
.submit-btn.pink { background: #ec4899; color: #fff; }
.submit-btn.purple { background: #8b5cf6; color: #fff; }
.submit-btn.orange { background: #f97316; color: #fff; }
.submit-btn.blue { background: #3b82f6; color: #fff; }
.api-status { margin-bottom: 12px; padding: 10px 12px; border-radius: 8px; font-size: 0.85rem; font-weight: 600; border: 1px solid transparent; }
.api-status.connected { background: rgba(16, 185, 129, 0.12); color: #047857; border-color: rgba(16, 185, 129, 0.3); }
.api-status.disconnected { background: rgba(249, 115, 22, 0.12); color: #9a3412; border-color: rgba(249, 115, 22, 0.3); }
[data-theme="dark"] .api-status.connected { color: #6ee7b7; }
[data-theme="dark"] .api-status.disconnected { color: #fdba74; }

/* MISC TWEAKS */
.empty-state { text-align: center; padding: 60px 0; color: var(--text-light); }
.empty-emoji { font-size: 2rem; filter: grayscale(1); opacity: 0.3; margin-bottom: 16px; }
.empty-text { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-sub { font-size: 0.9rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* TOAST */
.toast { position: fixed; bottom: 32px; right: 32px; background: var(--text); color: var(--bg); padding: 12px 24px; border-radius: 8px; font-weight: 500; font-size: 0.9rem; transform: translateY(100px); opacity: 0; transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 9999; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
.toast.show { transform: translateY(0); opacity: 1; }

/* GLOBALS EMOJI MUTE */
.goal-emoji, .wish-icon, .stat-icon { filter: grayscale(1); opacity: 0.4; }
.expense-filters { display: flex; gap: 8px; margin-bottom: 24px; overflow-x: auto; padding-bottom: 4px; }
.filter-chip { padding: 6px 16px; border: 1px solid var(--border); border-radius: 50px; background: var(--card); color: var(--text-light); font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: 0.2s; white-space: nowrap; }
.filter-chip:hover { border-color: var(--text); color: var(--text); }
.filter-chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* WISHLIST */
.wishlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.wish-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; transition: 0.2s; }
.wish-card:hover { transform: translateY(-2px); border-color: var(--text-light); }
.wish-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; display: flex; justify-content: space-between; }
.wish-price { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-bottom: 16px; letter-spacing: -0.5px; }
.wish-meta { font-size: 0.85rem; color: var(--text-light); margin-bottom: 16px; line-height: 1.5; }
.wish-actions { display: flex; gap: 8px; }
.wish-action-btn { background: var(--hover); border: none; padding: 8px 12px; border-radius: 6px; font-size: 0.8rem; font-weight: 500; cursor: pointer; color: var(--text); transition: 0.2s; }
.wish-action-btn:hover { background: var(--border); }
.wish-card.purchased { opacity: 0.6; }

/* GOALS */
.goals-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.goal-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; transition: 0.2s; }
.goal-card:hover { border-color: var(--text-light); }
.goal-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.goal-card-left { display: flex; gap: 12px; align-items: center; }
.goal-name { font-weight: 600; font-size: 1.05rem; }
.goal-deadline { font-size: 0.8rem; color: var(--text-light); margin-top: 4px; }
.goal-progress-wrap { margin-bottom: 24px; }
.goal-progress-bar { height: 8px; background: var(--hover); border-radius: 4px; overflow: hidden; }
.goal-progress-fill { height: 100%; background: var(--text); border-radius: 4px; }
.goal-progress-fill.complete { background: var(--success); }
.goal-progress-text { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 500; margin-top: 8px; color: var(--text-light); }
.goal-progress-text .percentage { color: var(--text); font-weight: 700; }
.goal-contribute-btn { width: 100%; border: 1px dashed var(--border); background: transparent; padding: 12px; color: var(--text); font-weight: 500; border-radius: var(--radius-sm); cursor: pointer; transition: 0.2s; }
.goal-contribute-btn:hover { border-style: solid; }
.goal-complete-banner { background: var(--hover); color: var(--text); padding: 12px; font-weight: 600; font-size: 0.85rem; border-radius: var(--radius-sm); text-align: center; }

/* AI ADVISOR */
.advisor-input-area { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; margin-bottom: 24px; max-width: 600px; margin: 0 auto 24px; }
.advisor-input-area h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 24px; display: flex; align-items: center; gap: 8px; }
.ask-btn {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.ask-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(79, 70, 229, 0.32);
}
.ask-btn:disabled {
  cursor: not-allowed;
  opacity: 0.75;
  transform: none;
  box-shadow: none;
}
.ai-response-area { display: none; background: var(--hover); border-radius: var(--radius); padding: 24px; max-width: 600px; margin: 0 auto; border-left: 4px solid var(--text); }
.ai-response-area.visible { display: block; }
.ai-response-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ai-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--card); border: 1px solid var(--border); }
.ai-name { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.ai-name span { display: block; font-weight: 500; font-size: 0.78rem; color: var(--text-light); }

/* CHAT */
.chat-container { border: 1px solid var(--border); border-radius: var(--radius); height: calc(100vh - 200px); display: flex; flex-direction: column; background: var(--card); max-width: 800px; margin: 0 auto; }
.chat-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; gap: 16px; align-items: center; }
.chat-header-avatar { width: 40px; height: 40px; background: var(--hover); border-radius: 50%; display: grid; place-items: center; font-size: 1.2rem; filter: grayscale(1); }
.chat-messages { flex: 1; padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.chat-bubble { max-width: 80%; display: flex; gap: 12px; }
.chat-bubble.ai { align-self: flex-start; }
.chat-bubble.user { align-self: flex-end; flex-direction: row-reverse; }
.bubble-avatar { display: none; }
.bubble-content { padding: 12px 16px; border-radius: 12px; font-size: 0.95rem; line-height: 1.5; }
.ai .bubble-content { background: var(--hover); color: var(--text); border-top-left-radius: 4px; }
.user .bubble-content { background: var(--text); color: var(--bg); border-top-right-radius: 4px; }
.chat-input-area { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 12px; }
.chat-input-area input { flex: 1; border: 1px solid var(--border); background: transparent; color: var(--text); border-radius: 8px; padding: 12px 16px; outline: none; }
.chat-input-area input:focus { border-color: var(--text); }
.chat-send-btn { width: 48px; border: none; background: var(--text); color: var(--bg); border-radius: 8px; cursor: pointer; display: grid; place-items: center; }

/* CHARTS INTERNAL DETAILS */
.bar-chart { display: flex; align-items: flex-end; justify-content: space-around; height: 160px; padding: 16px 0 0; }
.bar-group { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 40px; }
.bar-fill { width: 100%; background: var(--text); border-radius: 4px 4px 0 0; position: relative; }
.bar-label { font-size: 0.75rem; font-weight: 500; color: var(--text-light); }
.bar-tooltip { display: none; }

.horizontal-bars { display: flex; flex-direction: column; gap: 12px; }
.h-bar-row { display: flex; align-items: center; gap: 12px; }
.h-bar-label { width: 80px; font-size: 0.8rem; font-weight: 500; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-bar-track { flex: 1; height: 8px; background: var(--hover); border-radius: 4px; overflow: hidden; }
.h-bar-fill { height: 100%; background: var(--text); border-radius: 4px; }
.h-bar-amount { width: 60px; text-align: right; font-size: 0.85rem; font-weight: 600; color: var(--text); }
.donut-chart-wrap { position: relative; width: 160px; height: 160px; margin: 0 auto 16px; }
.donut-chart { width: 160px; height: 160px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.donut-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-weight: 700; font-size: 1.25rem; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-light); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

.loading-dots { display: flex; gap: 4px; }
.loading-dots span { width: 6px; height: 6px; background: var(--text-light); border-radius: 50%; animation: blink 1.4s infinite; }
@keyframes blink { 0%, 100% { opacity: 0.2; } 20% { opacity: 1; } }

/* Theming & Confetti fixes */
.theme-toggle { display: flex; gap: 8px; }
.theme-opt { flex: 1; padding: 10px; text-align: center; border: 1px solid var(--border); background: transparent; color: var(--text-light); font-weight: 500; font-size: 0.9rem; border-radius: var(--radius-sm); cursor: pointer; transition: 0.2s; }
.theme-opt:hover { border-color: var(--text); }
.theme-opt.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.emoji-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.emoji-opt { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: transparent; cursor: pointer; font-size: 1.2rem; }
.emoji-opt.active { border-color: var(--text); background: var(--hover); }

/* Confetti */
.confetti-piece {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  animation-name: confetti-fall;
  animation-timing-function: linear;
}

@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
