/* ============================================================
   CashFlow — Material Design 3 Dark Theme
   Reference: https://m3.material.io/
   ============================================================ */

/* ── MD3 Color Tokens ──────────────────────────────────────────
   Palette: #EEFABD · #A0D585 · #6984A9 · #263B6A
   Source:  colorhunt.co/palette/eefabda0d5856984a9263b6a
   ─────────────────────────────────────────────────────────── */
:root {
  /* Primary — Soft Green (#A0D585) */
  --md-primary:                #A0D585;
  --md-on-primary:             #1a3c0e;
  --md-primary-container:      #2d5c1a;
  --md-on-primary-container:   #EEFABD;

  /* Secondary — Steel Blue (#6984A9) */
  --md-secondary:              #9db8d0;
  --md-on-secondary:           #162436;
  --md-secondary-container:    #6984A9;
  --md-on-secondary-container: #EEFABD;

  /* Tertiary — Cream (#EEFABD) used for income highlights */
  --md-tertiary:               #EEFABD;
  --md-on-tertiary:            #263B6A;
  --md-tertiary-container:     #3d5c1e;
  --md-on-tertiary-container:  #d8f5a0;

  /* Error — Red (kept for standard destructive actions) */
  --md-error:                  #FFB4AB;
  --md-on-error:               #690005;
  --md-error-container:        #93000A;
  --md-on-error-container:     #FFDAD6;

  /* Surfaces — built from dark navy (#263B6A) */
  --md-background:                    #131e38;
  --md-on-background:                 #EEFABD;
  --md-surface:                       #131e38;
  --md-on-surface:                    #EEFABD;
  --md-surface-variant:               #3d5580;
  --md-on-surface-variant:            #b8cde0;
  --md-surface-container-lowest:      #0d1628;
  --md-surface-container-low:         #1a2a4a;
  --md-surface-container:             #263B6A;
  --md-surface-container-high:        #2f4880;
  --md-surface-container-highest:     #3a5692;

  /* Outline */
  --md-outline:         #6984A9;
  --md-outline-variant: #3d5580;

  /* Extra semantic aliases used by this app */
  --md-income:   var(--md-primary);
  --md-expense:  var(--md-error);
  --md-transfer: var(--md-secondary);

  /* ── MD3 Shape tokens ── */
  --md-shape-none:        0px;
  --md-shape-extra-small: 4px;
  --md-shape-small:       8px;
  --md-shape-medium:      12px;
  --md-shape-large:       16px;
  --md-shape-extra-large: 28px;
  --md-shape-full:        9999px;

  /* ── MD3 Elevation (tonal — green tint) ── */
  --md-elev-0:  transparent;
  --md-elev-1:  rgba(160, 213, 133, 0.05);
  --md-elev-2:  rgba(160, 213, 133, 0.08);
  --md-elev-3:  rgba(160, 213, 133, 0.11);
  --md-elev-4:  rgba(160, 213, 133, 0.12);
  --md-elev-5:  rgba(160, 213, 133, 0.14);

  /* ── MD3 State layers ── */
  --md-state-hover:   rgba(160, 213, 133, 0.08);
  --md-state-pressed: rgba(160, 213, 133, 0.12);
  --md-state-focused: rgba(160, 213, 133, 0.12);

  /* ── Typography ── */
  --md-font:      'Roboto', sans-serif;
  --md-font-mono: 'Roboto Mono', monospace;

  /* Nav */
  --nav-bar-height: 100px;
  --top-bar-height: 64px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--md-font);
  background: var(--md-background);
  color: var(--md-on-background);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app { height: 100%; }

/* ============================================================
   MD3 Typography Scale
   ============================================================ */
.md-display-large  { font-size: 57px; font-weight: 400; line-height: 64px; letter-spacing: -0.25px; }
.md-display-medium { font-size: 45px; font-weight: 400; line-height: 52px; }
.md-display-small  { font-size: 36px; font-weight: 400; line-height: 44px; }
.md-headline-large  { font-size: 32px; font-weight: 400; line-height: 40px; }
.md-headline-medium { font-size: 28px; font-weight: 400; line-height: 36px; }
.md-headline-small  { font-size: 24px; font-weight: 400; line-height: 32px; }
.md-title-large   { font-size: 22px; font-weight: 500; line-height: 28px; }
.md-title-medium  { font-size: 16px; font-weight: 500; line-height: 24px; letter-spacing: 0.15px; }
.md-title-small   { font-size: 14px; font-weight: 500; line-height: 20px; letter-spacing: 0.1px; }
.md-body-large    { font-size: 16px; font-weight: 400; line-height: 24px; letter-spacing: 0.5px; }
.md-body-medium   { font-size: 14px; font-weight: 400; line-height: 20px; letter-spacing: 0.25px; }
.md-body-small    { font-size: 12px; font-weight: 400; line-height: 16px; letter-spacing: 0.4px; }
.md-label-large   { font-size: 14px; font-weight: 500; line-height: 20px; letter-spacing: 0.1px; }
.md-label-medium  { font-size: 12px; font-weight: 500; line-height: 16px; letter-spacing: 0.5px; }
.md-label-small   { font-size: 11px; font-weight: 500; line-height: 16px; letter-spacing: 0.5px; }

/* ============================================================
   App Shell Layout
   ============================================================ */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.app-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-bar-height) + 16px);
}

/* ============================================================
   MD3 Top App Bar — seamless, no background
   ============================================================ */
.top-app-bar {
  height: var(--top-bar-height);
  background: transparent;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-app-bar-headline {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 600;
  color: var(--md-primary);
  letter-spacing: -0.3px;
}

/* ── Profile menu ── */
.profile-menu-wrap {
  position: relative;
}

.profile-avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--md-shape-full);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.profile-avatar-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

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

.profile-popup {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--md-surface-container-high);
  border-radius: var(--md-shape-large);
  padding: 16px;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  border: 1px solid var(--md-outline-variant);
  animation: popupIn 0.18s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 200;
}

@keyframes popupIn {
  from { opacity: 0; transform: scale(0.88) translateY(-6px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.profile-popup-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--md-on-surface);
  letter-spacing: 0.1px;
}

.profile-popup-username {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  margin-top: 2px;
}

.profile-popup-action {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 4px;
  background: transparent;
  border: none;
  color: var(--md-error);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--md-shape-small);
  transition: background 0.15s;
  text-align: left;
}

.profile-popup-action:hover {
  background: rgba(255, 180, 171, 0.12);
}

/* ============================================================
   MD3 Navigation Bar — floating pill
   ============================================================ */
.nav-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 480px;
  height: 68px;
  background: var(--md-surface-container-high);
  display: flex;
  align-items: center;
  z-index: 100;
  border-radius: var(--md-shape-full);
  padding: 0 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.45), 0 1px 4px rgba(0,0,0,0.2);
  border: 1px solid var(--md-outline-variant);
  animation: navBarIn 0.4s cubic-bezier(0.34,1.3,0.64,1);
}

@keyframes navBarIn {
  from { opacity: 0; transform: translateX(-50%) translateY(24px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  padding: 8px 0;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1);
}

.nav-item:active {
  transform: scale(0.88);
}

.nav-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 30px;
  border-radius: var(--md-shape-full);
  transition: background 0.2s, width 0.25s cubic-bezier(0.34,1.2,0.64,1);
}

.nav-item.active .nav-indicator {
  background: var(--md-secondary-container);
  width: 64px;
}

.nav-item:not(.active):hover .nav-indicator {
  background: var(--md-state-hover);
}

.nav-icon {
  font-size: 1.3rem;
  line-height: 1;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
}

.nav-item.active .nav-icon {
  transform: scale(1.12);
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: var(--md-on-surface-variant);
  transition: color 0.2s, font-weight 0.15s;
}

.nav-item.active .nav-label {
  color: var(--md-on-surface);
  font-weight: 600;
}

/* ============================================================
   Page Container
   ============================================================ */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  animation: pageFadeIn 0.3s cubic-bezier(0.22,1,0.36,1);
}

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

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

.page-title {
  font-size: 28px;
  font-weight: 400;
  color: var(--md-on-surface);
}

/* ============================================================
   MD3 Cards
   ============================================================ */

/* Elevated card */
.md-card {
  background: var(--md-surface-container-low);
  border-radius: var(--md-shape-medium);
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.md-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--md-elev-1);
  border-radius: inherit;
  pointer-events: none;
}

.md-card-elevated {
  background: var(--md-surface-container-low);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15);
}

/* Filled card */
.md-card-filled {
  background: var(--md-surface-container-highest);
}

/* Outlined card */
.md-card-outlined {
  background: var(--md-surface);
  border: 1px solid var(--md-outline-variant);
}

.md-card + .md-card { margin-top: 12px; }

/* Clickable card state layer */
.md-card-clickable {
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.md-card-clickable::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  transition: background 0.15s;
}

.md-card-clickable:hover::after {
  background: var(--md-state-hover);
}

.md-card-clickable:active::after {
  background: var(--md-state-pressed);
}

/* ============================================================
   MD3 Buttons
   ============================================================ */

/* Base button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 24px;
  border-radius: var(--md-shape-full);
  font-family: var(--md-font);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.15s cubic-bezier(0.34,1.56,0.64,1);
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.95);
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 0.15s;
}

.btn:hover::after { background: rgba(255,255,255,0.08); }
.btn:active::after { background: rgba(255,255,255,0.12); }

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

/* Filled */
.btn-filled {
  background: var(--md-primary);
  color: var(--md-on-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.15);
}
.btn-filled:hover { box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.15); }

/* Tonal (secondary) */
.btn-tonal {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}

/* Outlined */
.btn-outlined {
  background: transparent;
  color: var(--md-primary);
  border: 1px solid var(--md-outline);
}

/* Text */
.btn-text {
  background: transparent;
  color: var(--md-primary);
  padding: 0 12px;
}

/* Danger (error) */
.btn-danger {
  background: var(--md-error);
  color: var(--md-on-error);
}

/* Size variants */
.btn-sm {
  height: 32px;
  padding: 0 16px;
  font-size: 12px;
}

.btn-lg {
  height: 48px;
  padding: 0 32px;
  font-size: 16px;
}

.btn-full { width: 100%; }

/* Icon button */
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--md-shape-full);
  background: transparent;
  color: var(--md-on-surface-variant);
  font-size: 1.1rem;
}

.btn-icon:hover::after { background: var(--md-state-hover); }

/* Small icon-only action button (delete etc.) */
.icon-btn-sm {
  width: 34px;
  height: 34px;
  border-radius: var(--md-shape-full);
  background: var(--md-surface-container-highest);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn-sm:hover { background: rgba(255,180,171,0.18); }
.icon-btn-sm:active { transform: scale(0.9); }

/* Goal icon picker button */
.goal-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--md-shape-medium);
  background: var(--md-surface-container-high);
  border: 1.5px solid var(--md-outline-variant);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.goal-icon-btn:hover { background: var(--md-surface-container-highest); }
.goal-icon-btn:active { transform: scale(0.92); }
.goal-icon-btn.selected {
  background: var(--md-primary-container);
  border-color: var(--md-primary);
}

/* ── FAB (Floating Action Button) ── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-bar-height) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: var(--md-shape-large);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 300;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4);
  z-index: 90;
  transition: box-shadow 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  position: relative;
}

.fab::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  transition: background 0.15s;
}

.fab:hover { box-shadow: 0 6px 12px rgba(0,0,0,0.4); }
.fab:hover::after { background: var(--md-elev-2); }
.fab:active::after { background: var(--md-elev-3); }

/* Fixed FAB positioning wrapper */
.fab-fixed {
  position: fixed;
  bottom: calc(var(--nav-bar-height) + 16px);
  right: 16px;
  z-index: 90;
}

/* ============================================================
   MD3 Text Fields (Outlined)
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: var(--md-on-surface-variant);
  padding: 0 4px;
}

.field-input {
  height: 56px;
  padding: 0 16px;
  background: transparent;
  border: 1px solid var(--md-outline);
  border-radius: var(--md-shape-extra-small);
  color: var(--md-on-surface);
  font-family: var(--md-font);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.field-input:hover {
  border-color: var(--md-on-surface);
}

.field-input:focus {
  border-color: var(--md-primary);
  border-width: 2px;
  box-shadow: none;
}

.field-input::placeholder {
  color: var(--md-on-surface-variant);
  opacity: 0.6;
}

select.field-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23C9C5D0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}

select.field-input option {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
}

textarea.field-input {
  height: auto;
  min-height: 80px;
  padding: 12px 16px;
  resize: vertical;
}

.field-hint {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  padding: 0 4px;
}

.field-error {
  font-size: 12px;
  color: var(--md-error);
  padding: 0 4px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Legacy aliases for compatibility */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 12px; font-weight: 500; letter-spacing: 0.4px; color: var(--md-on-surface-variant); padding: 0 8px; }
.form-control {
  height: 52px; padding: 0 20px;
  background: var(--md-surface-container-low); border: 1.5px solid var(--md-outline);
  border-radius: var(--md-shape-full); color: var(--md-on-surface);
  font-family: var(--md-font); font-size: 16px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s; width: 100%;
}
.form-control:hover { border-color: var(--md-on-surface); background: var(--md-surface-container); }
.form-control:focus {
  border-color: var(--md-primary); border-width: 2px;
  background: var(--md-surface-container);
  box-shadow: 0 0 0 3px rgba(160, 213, 133, 0.15);
}
.form-control::placeholder { color: var(--md-on-surface-variant); opacity: 0.6; }
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23C9C5D0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
  padding-right: 40px; cursor: pointer;
}
select.form-control option { background: var(--md-surface-container-high); }
.form-hint { font-size: 12px; color: var(--md-on-surface-variant); padding: 0 4px; }
.form-error { font-size: 12px; color: var(--md-error); padding: 0 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ============================================================
   MD3 Dialog (Modal)
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  animation: overlayIn 0.2s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: var(--md-surface-container-high);
  border-radius: var(--md-shape-extra-large) var(--md-shape-extra-large) 0 0;
  padding: 28px 24px 24px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideUp 0.35s cubic-bezier(0.22,1,0.36,1);
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (min-width: 640px) {
  .modal {
    border-radius: var(--md-shape-extra-large);
    animation: modalScaleIn 0.3s cubic-bezier(0.22,1,0.36,1);
  }
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

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

.modal-title {
  font-size: 24px;
  font-weight: 400;
  color: var(--md-on-surface);
}

.modal-close {
  width: 40px;
  height: 40px;
  border-radius: var(--md-shape-full);
  background: transparent;
  border: none;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background 0.15s;
  position: relative;
  overflow: hidden;
}
.modal-close::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: transparent; transition: background 0.15s;
}
.modal-close:hover::after { background: var(--md-state-hover); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ============================================================
   MD3 Snackbar (Toast)
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-bar-height) + 16px);
  left: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
  max-width: 420px;
  margin: 0 auto;
}

.toast {
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface);
  border-radius: var(--md-shape-full);
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
  animation: snackbar-in 0.35s cubic-bezier(0.22,1,0.36,1);
}

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

.toast.success .toast-icon { color: var(--md-tertiary); }
.toast.error   .toast-icon { color: var(--md-error); }
.toast.info    .toast-icon { color: var(--md-primary); }

@keyframes snackbar-in {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* ============================================================
   Account Card — MD3 Elevated Card
   ============================================================ */
.account-card {
  background: var(--md-surface-container-low);
  border-radius: var(--md-shape-medium);
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.15);
  transition: box-shadow 0.25s, transform 0.2s cubic-bezier(0.22,1,0.36,1);
  margin-bottom: 12px;
  animation: cardIn 0.35s cubic-bezier(0.22,1,0.36,1) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.account-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--md-elev-1);
  pointer-events: none;
}

.account-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 0.15s;
}

.account-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}
.account-card:hover::after { background: var(--md-state-hover); }
.account-card:active { transform: translateY(0) scale(0.98); }

.account-card-color-bar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
}

.account-card-body {
  padding-left: 12px;
}

.account-card-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--md-on-surface);
  letter-spacing: 0.15px;
}

.account-card-type {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  letter-spacing: 0.4px;
  text-transform: capitalize;
  margin-top: 2px;
  margin-bottom: 12px;
}

.account-card-balance {
  font-size: 28px;
  font-weight: 400;
  color: var(--md-on-surface);
  font-family: var(--md-font-mono);
  letter-spacing: -0.5px;
}

.account-card-currency {
  font-size: 13px;
  color: var(--md-on-surface-variant);
  margin-left: 4px;
}

/* ============================================================
   Transaction List — MD3 List
   ============================================================ */
.transaction-list {
  display: flex;
  flex-direction: column;
}

.transaction-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: var(--md-shape-extra-small);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.1s;
}

.transaction-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 0.15s;
}

.transaction-item:hover::after { background: var(--md-state-hover); }

.transaction-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--md-shape-full);
  background: var(--md-surface-container-highest);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.transaction-info {
  flex: 1;
  min-width: 0;
}

.transaction-desc {
  font-size: 16px;
  font-weight: 400;
  color: var(--md-on-surface);
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transaction-meta {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  letter-spacing: 0.4px;
  margin-top: 2px;
}

.transaction-amount {
  font-size: 16px;
  font-weight: 500;
  font-family: var(--md-font-mono);
  white-space: nowrap;
  letter-spacing: 0.15px;
}

.transaction-amount.income   { color: var(--md-tertiary); }
.transaction-amount.expense  { color: var(--md-error); }
.transaction-amount.transfer { color: var(--md-primary); }

/* ============================================================
   Budget Bar — MD3 Linear Progress
   ============================================================ */
.budget-item {
  background: var(--md-surface-container-low);
  border-radius: var(--md-shape-medium);
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

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

.budget-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--md-on-surface);
  letter-spacing: 0.1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.budget-amounts {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  font-family: var(--md-font-mono);
  letter-spacing: 0.4px;
}

/* MD3 Linear progress indicator */
.budget-bar-track {
  height: 4px;
  background: var(--md-surface-variant);
  border-radius: var(--md-shape-full);
  overflow: hidden;
}

.budget-bar-fill {
  height: 100%;
  border-radius: var(--md-shape-full);
  transition: width 0.4s ease;
  background: var(--md-primary);
}

.budget-bar-fill.warning { background: #FFB4AB; }
.budget-bar-fill.danger  { background: var(--md-error); }

.budget-remaining {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  margin-top: 8px;
  text-align: right;
  letter-spacing: 0.4px;
}

/* ============================================================
   Goal Card — MD3 Card + circular progress
   ============================================================ */
.goal-card {
  background: var(--md-surface-container-low);
  border-radius: var(--md-shape-medium);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  margin-bottom: 12px;
  transition: box-shadow 0.25s, transform 0.2s cubic-bezier(0.22,1,0.36,1);
  animation: cardIn 0.35s cubic-bezier(0.22,1,0.36,1) both;
}

.goal-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 0.15s;
}
.goal-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.3); transform: translateY(-2px); }
.goal-card:hover::after { background: var(--md-state-hover); }
.goal-card:active { transform: translateY(0) scale(0.98); }

.goal-ring-container {
  flex-shrink: 0;
  position: relative;
  width: 64px;
  height: 64px;
}

.goal-ring-svg { transform: rotate(-90deg); }

.goal-ring-bg {
  fill: none;
  stroke: var(--md-surface-variant);
  stroke-width: 5;
}

.goal-ring-fill {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
}

.goal-ring-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.goal-info { flex: 1; min-width: 0; }

.goal-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--md-on-surface);
  letter-spacing: 0.15px;
}

.goal-progress {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  font-family: var(--md-font-mono);
  margin-top: 4px;
}

.goal-deadline {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  margin-top: 2px;
}

.goal-percent {
  font-size: 20px;
  font-weight: 500;
  color: var(--md-on-surface);
  font-family: var(--md-font-mono);
  text-align: right;
  white-space: nowrap;
}

/* ============================================================
   Dashboard
   ============================================================ */
.net-worth-card {
  background: var(--md-primary-container);
  border-radius: var(--md-shape-extra-large);
  padding: 28px 24px;
  text-align: center;
  margin-bottom: 16px;
}

.net-worth-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--md-on-primary-container);
  opacity: 0.8;
  margin-bottom: 8px;
}

.net-worth-value {
  font-size: 40px;
  font-weight: 300;
  color: var(--md-on-primary-container);
  font-family: var(--md-font-mono);
  letter-spacing: -1px;
}

.net-worth-currency {
  font-size: 16px;
  opacity: 0.7;
  margin-left: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--md-surface-container);
  border-radius: var(--md-shape-medium);
  padding: 16px;
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--md-on-surface-variant);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 20px;
  font-weight: 500;
  color: var(--md-on-surface);
  font-family: var(--md-font-mono);
}

.stat-value.positive { color: var(--md-tertiary); }
.stat-value.negative { color: var(--md-error); }

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--md-background);
}

.login-card {
  background: var(--md-surface-container);
  border-radius: var(--md-shape-extra-large);
  padding: 36px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border: 1px solid var(--md-outline-variant);
  animation: loginCardIn 0.45s cubic-bezier(0.22,1,0.36,1);
}

@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(32px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  font-size: 36px;
  font-weight: 300;
  color: var(--md-primary);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
  animation: logoIn 0.55s cubic-bezier(0.22,1,0.36,1) 0.1s both;
}

@keyframes logoIn {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

.login-subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--md-on-surface-variant);
  margin-bottom: 32px;
  letter-spacing: 0.25px;
}

/* ============================================================
   Section headers
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  margin-top: 4px;
}

.section-title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--md-on-surface-variant);
}

/* ============================================================
   MD3 Chips
   ============================================================ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--md-shape-small);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  border: 1px solid var(--md-outline);
  background: transparent;
  color: var(--md-on-surface-variant);
  transition: background 0.15s;
  position: relative;
  overflow: hidden;
}

.chip.selected {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  border-color: transparent;
}

.chip:hover { background: var(--md-state-hover); }
.chip.selected:hover { background: var(--md-secondary-container); }

/* ============================================================
   Type badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--md-shape-full);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.badge-income   { background: rgba(103, 219, 187, 0.15); color: var(--md-tertiary); }
.badge-expense  { background: rgba(255, 180, 171, 0.15); color: var(--md-error); }
.badge-transfer { background: rgba(197, 192, 255, 0.15); color: var(--md-primary); }

/* ============================================================
   Empty states
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--md-on-surface-variant);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0.7;
}
.empty-state-title { font-size: 22px; font-weight: 400; color: var(--md-on-surface); margin-bottom: 8px; }
.empty-state-body  { font-size: 14px; color: var(--md-on-surface-variant); margin-bottom: 24px; }

/* ============================================================
   Loading / Progress
   ============================================================ */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--md-surface-variant);
  border-top-color: var(--md-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.loading-center {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px;
}

/* ============================================================
   Divider
   ============================================================ */
.divider {
  border: none;
  border-top: 1px solid var(--md-outline-variant);
  margin: 16px 0;
}

/* ============================================================
   Utility classes
   ============================================================ */
.text-primary   { color: var(--md-primary); }
.text-secondary { color: var(--md-secondary); }
.text-muted     { color: var(--md-on-surface-variant); }
.text-error     { color: var(--md-error); }
.text-income    { color: var(--md-tertiary); }

.font-mono { font-family: var(--md-font-mono); }
.font-medium { font-weight: 500; }

.flex             { display: flex; }
.flex-col         { flex-direction: column; }
.flex-1           { flex: 1; }
.items-center     { align-items: center; }
.justify-between  { justify-content: space-between; }
.justify-end      { justify-content: flex-end; }
.justify-center   { justify-content: center; }
.gap-1  { gap: 4px; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-2   { margin-top: 8px; }
.mt-3   { margin-top: 12px; }
.mt-4   { margin-top: 16px; }
.mt-6   { margin-top: 24px; }
.mb-2   { margin-bottom: 8px; }
.mb-3   { margin-bottom: 12px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.w-full  { width: 100%; }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.wrap { flex-wrap: wrap; }

/* ============================================================
   Responsive
   ============================================================ */
@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .fab-fixed { right: 24px; bottom: calc(var(--nav-bar-height) + 24px); }
}
