/* =========================================================
   Personal Finance 2026 — styles.css
   Mobile-first · purple RE-NEO style · bottom nav
   ========================================================= */

:root {
  --c-primary: #6366f1;
  --c-primary-2: #8b5cf6;
  --c-primary-3: #c084fc;
  --c-primary-4: #ec4899;
  --c-primary-soft: #eef2ff;
  --c-primary-soft-2: #f5f3ff;

  --c-income: #10b981;
  --c-income-soft: #d1fae5;
  --c-expense: #ef4444;
  --c-expense-soft: #fee2e2;
  --c-warn: #f59e0b;
  --c-warn-soft: #fef3c7;

  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #e5e7eb;
  --border-2: #f1f5f9;

  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow:    0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 14px 36px rgba(99, 102, 241, 0.22);
  --radius: 22px;
  --radius-sm: 14px;
  --radius-xs: 12px;

  --bn-h: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", "PingFang SC", "Microsoft JhengHei", sans-serif;
  background: linear-gradient(180deg, #f5f3ff 0%, #f7f7fb 240px, #f7f7fb 100%);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }
input, select { font-family: inherit; color: var(--text); }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 18px calc(var(--bn-h) + 36px) 18px;
  min-height: 100vh;
}

/* =========================================================
   HEADER
   ========================================================= */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.user-block { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.15rem;
  box-shadow: 0 6px 14px rgba(99, 102, 241, 0.35);
}

.user-text { line-height: 1.15; }
.greeting {
  font-size: 0.78rem;
  color: var(--text-2);
  font-weight: 500;
}
.username {
  font-size: 1.12rem;
  font-weight: 700;
  margin-top: 2px;
}

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

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  position: relative;
  transition: background 0.15s, transform 0.1s;
  font-size: 1rem;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.96); }

#currency-btn {
  font-weight: 700;
  color: var(--c-primary);
  background: var(--c-primary-soft);
  border-color: transparent;
  font-size: 0.95rem;
}

.icon-btn-bell .dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-warn);
  border: 2px solid var(--surface);
  box-sizing: content-box;
}
.icon-btn-bell .dot.ok { background: var(--c-income); }
.icon-btn-bell .dot.error { background: var(--c-expense); }

/* =========================================================
   WELCOME / HERO CARD
   ========================================================= */
.welcome-card {
  position: relative;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #c084fc 100%);
  padding: 22px 22px 24px 22px;
  color: #fff;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin-bottom: 20px;
  isolation: isolate;
  min-height: 200px;
}

.welcome-deco { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.welcome-blob {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}
.welcome-blob-1 { width: 180px; height: 180px; top: -80px; right: -50px; }
.welcome-blob-2 { width: 120px; height: 120px; bottom: -60px; left: 30px; background: rgba(255, 255, 255, 0.06); }

.welcome-card-illu {
  position: absolute;
  right: 18px;
  top: 28px;
  width: 110px;
  height: 80px;
  z-index: 1;
}
.illu-card {
  position: absolute;
  border-radius: 10px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}
.illu-card-back {
  width: 70px;
  height: 44px;
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  top: 12px;
  left: 0;
  transform: rotate(-12deg);
}
.illu-card-front {
  width: 80px;
  height: 50px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  top: 4px;
  left: 24px;
  transform: rotate(8deg);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.illu-chip {
  width: 14px;
  height: 10px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  border-radius: 3px;
}
.illu-line {
  height: 3px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 2px;
  width: 100%;
}
.illu-line-short { width: 60%; }

.welcome-content {
  position: relative;
  z-index: 2;
  max-width: 60%;
}

.welcome-title {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.welcome-year {
  background: linear-gradient(90deg, #fbbf24, #f472b6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

.welcome-sub {
  font-size: 0.78rem;
  opacity: 0.88;
  line-height: 1.45;
  max-width: 220px;
}

/* =========================================================
   BALANCE CARD
   ========================================================= */
.balance-card {
  position: relative;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  padding: 22px 22px 20px 22px;
  color: #fff;
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.28);
  overflow: hidden;
  margin-bottom: 18px;
  isolation: isolate;
}

.balance-blob {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
  z-index: 0;
}
.balance-blob-1 { width: 160px; height: 160px; top: -70px; right: -50px; }
.balance-blob-2 { width: 110px; height: 110px; bottom: -50px; left: -30px; background: rgba(255, 255, 255, 0.08); }

.balance-content { position: relative; z-index: 1; }

.balance-label {
  font-size: 0.78rem;
  font-weight: 500;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.balance-amount {
  font-size: 2.2rem;
  font-weight: 700;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.8px;
}

.balance-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 10px;
  font-size: 0.82rem;
}
.balance-sub { opacity: 0.88; font-variant-numeric: tabular-nums; }

.badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
}
.badge.up   { color: #fff; background: rgba(255, 255, 255, 0.22); }
.badge.down { color: #fff; background: rgba(255, 255, 255, 0.12); }
.badge.neutral { color: rgba(255, 255, 255, 0.9); background: rgba(255, 255, 255, 0.1); }

/* =========================================================
   QUICK ACTIONS
   ========================================================= */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.qa-btn {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 14px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, border-color 0.15s;
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
}
.qa-btn:hover { border-color: var(--c-primary); box-shadow: var(--shadow-sm); }
.qa-btn:active { transform: translateY(1px); }

.qa-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 700;
}
.qa-icon-in     { background: var(--c-income-soft);  color: var(--c-income); }
.qa-icon-out    { background: var(--c-expense-soft); color: var(--c-expense); }
.qa-icon-rates  { background: var(--c-primary-soft); color: var(--c-primary); }
.qa-icon-export { background: var(--c-warn-soft);    color: var(--c-warn); }

/* =========================================================
   WALLETS (3 stacked cards)
   ========================================================= */
.wallets {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-2);
}

.wallets-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.wallets-head h2 { font-size: 1rem; font-weight: 700; }
.wallets-tag {
  font-size: 0.7rem;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}

.wallet-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.wallet-card {
  position: relative;
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  color: #fff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
  margin-bottom: -22px;
  transition: transform 0.2s;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  isolation: isolate;
  overflow: hidden;
}
.wallet-card::before {
  content: "";
  position: absolute;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  top: -50px; right: -40px;
  z-index: 0;
}
.wallet-card > * { position: relative; z-index: 1; }

.wallet-card-1 { background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%); z-index: 1; }
.wallet-card-2 { background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%); z-index: 2; margin-left: 8px; margin-right: 8px; }
.wallet-card-3 { background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%); z-index: 3; }

.wallet-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.wallet-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.92;
}
.wallet-mini-icon {
  width: 22px; height: 22px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.wallet-amount {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
  margin-top: 4px;
}
.wallet-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 0.7rem;
  opacity: 0.85;
}
.wallet-foot-icon { opacity: 0.7; }

.wallets-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30px;
  padding: 14px 4px 4px;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
  color: var(--text-2);
}
.wallets-total span:last-child {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   SECTIONS (generic)
   ========================================================= */
.section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-2);
  scroll-margin-top: 20px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}
.section-head h2 { font-size: 1rem; font-weight: 700; }
.section-sub { font-size: 0.78rem; color: var(--text-3); }
.muted { color: var(--text-3); font-weight: 400; }

/* =========================================================
   DONUT
   ========================================================= */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-height: 220px;
  justify-content: center;
}
.donut-wrap svg { width: 100%; max-width: 200px; height: auto; }

.donut-slice {
  transition: transform 0.2s, opacity 0.2s;
  transform-origin: center;
  cursor: pointer;
}
.donut-slice:hover { opacity: 0.85; transform: scale(1.03); }

.donut-legend {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.donut-legend-item {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  gap: 8px;
  align-items: center;
  font-size: 0.82rem;
  padding: 4px 0;
}
.donut-swatch { width: 10px; height: 10px; border-radius: 3px; }
.donut-cat { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.donut-amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.donut-pct { color: var(--text-3); font-size: 0.76rem; font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }
.donut-empty { text-align: center; color: var(--text-3); font-size: 0.88rem; padding: 18px; }

/* =========================================================
   BAR CHART
   ========================================================= */
.bar-chart {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  align-items: end;
  height: 130px;
  padding: 6px 0;
}
.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}
.bar-pair {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  flex: 1;
  width: 100%;
  justify-content: center;
  min-height: 4px;
}
.bar {
  width: 8px;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: opacity 0.15s;
}
.bar:hover { opacity: 0.8; }
.bar-income  { background: var(--c-income); }
.bar-expense { background: var(--c-expense); }
.bar-label {
  font-size: 0.65rem;
  color: var(--text-3);
  text-align: center;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.bar-label.current { color: var(--c-primary); font-weight: 700; }

.bar-legend {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 0.78rem;
  color: var(--text-2);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-2);
}
.dot-legend {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

/* =========================================================
   TRANSACTIONS
   ========================================================= */
.filter-pills {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 999px;
}
.pill {
  background: transparent;
  border: none;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.pill.active {
  background: var(--c-primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

.tx-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 380px;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}
.tx {
  display: grid;
  grid-template-columns: 38px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: var(--radius-xs);
  transition: background 0.15s;
}
.tx:hover { background: var(--surface-2); }

.tx-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}
.tx.income  .tx-icon { background: var(--c-income-soft);  color: var(--c-income); }
.tx.expense .tx-icon { background: var(--c-expense-soft); color: var(--c-expense); }

.tx-info { min-width: 0; }
.tx-cat {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-meta {
  font-size: 0.74rem;
  color: var(--text-3);
  display: flex;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-amounts { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.tx-amount {
  font-weight: 700;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tx.income  .tx-amount { color: var(--c-income); }
.tx.expense .tx-amount { color: var(--c-expense); }
.tx-converted { font-size: 0.7rem; color: var(--text-3); font-variant-numeric: tabular-nums; }

.tx-del {
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  color: var(--text-3);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tx-del:hover { background: var(--c-expense-soft); color: var(--c-expense); }

.empty {
  text-align: center;
  color: var(--text-3);
  padding: 22px 0;
  font-size: 0.88rem;
}

/* =========================================================
   ADD FORM
   ========================================================= */
.add-section { background: var(--surface); }

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }

.form-group { display: flex; flex-direction: column; }
.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}

.form-group input,
.form-group select {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.seg-control {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: var(--radius-xs);
  padding: 3px;
  gap: 3px;
}
.seg-control input { display: none; }
.seg-control label {
  padding: 9px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-2);
  margin: 0;
  transition: all 0.15s;
  user-select: none;
}
.seg-control input:checked + label {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
#type-expense:checked + label { color: var(--c-expense); }
#type-income:checked  + label { color: var(--c-income); }

.amount-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.amount-group:focus-within {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.amount-prefix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 700;
  border-right: 1px solid var(--border);
  min-width: 36px;
  justify-content: center;
}
.amount-group input {
  flex: 1;
  border: none;
  border-radius: 0;
  padding: 11px 10px;
  min-width: 0;
}
.amount-group input:focus { outline: none; box-shadow: none; }

.tx-currency-select {
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface-2);
  padding: 0 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 76px;
  max-width: 100px;
}
.tx-currency-select:focus { outline: none; background: var(--c-primary-soft); }

.conversion-preview {
  font-size: 0.8rem;
  color: var(--text-2);
  min-height: 1.2em;
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
}
.conversion-preview strong { color: var(--c-primary); }

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
  color: #fff;
  border: none;
  padding: 13px 20px;
  border-radius: var(--radius-xs);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
  margin-top: 4px;
}
.btn-primary:hover { opacity: 0.95; }
.btn-primary:active { transform: translateY(1px); }

.error {
  color: var(--c-expense);
  font-size: 0.82rem;
  margin-top: 8px;
  min-height: 1em;
}

/* =========================================================
   FOOTER
   ========================================================= */
.app-footer {
  text-align: center;
  color: var(--text-3);
  font-size: 0.72rem;
  padding: 20px 0 10px;
}

/* =========================================================
   BOTTOM NAV
   ========================================================= */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--bn-h);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-2);
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr 1fr 1fr;
  align-items: center;
  z-index: 50;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bn-btn, .bn-fab {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-3);
  font-size: 0.66rem;
  font-weight: 500;
  padding: 6px 4px;
  height: 100%;
  transition: color 0.15s, transform 0.1s;
}
.bn-btn svg { display: block; }
.bn-btn:hover, .bn-btn.active { color: var(--c-primary); }

.bn-fab {
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
  color: #fff;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  margin: 0 auto;
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}
.bn-fab:hover { transform: translateY(-1px); }
.bn-fab:active { transform: translateY(1px); }

/* =========================================================
   CURRENCY MODAL
   ========================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}
.modal-card {
  position: relative;
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0)) 18px;
  animation: slideUp 0.25s ease;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.modal-head h3 { font-size: 1.05rem; font-weight: 700; }
.modal-sub { font-size: 0.82rem; color: var(--text-2); margin-bottom: 14px; }

.modal-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px;
  font-size: 0.92rem;
  background: var(--surface);
  color: var(--text);
}
.modal-select option { padding: 8px; font-size: 0.92rem; }

/* =========================================================
   DESKTOP
   ========================================================= */
@media (min-width: 900px) {
  body { background: linear-gradient(135deg, #f5f3ff 0%, #eef2ff 100%); }
  .app {
    max-width: 1000px;
    padding: 28px 28px 60px;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    grid-template-areas:
      "header   header"
      "welcome  balance"
      "quick    quick"
      "wallets  wallets"
      "stats    list"
      "add      add"
      "footer   footer";
    gap: 20px 22px;
  }
  .app-header { grid-area: header; margin-bottom: 0; }
  .welcome-card { grid-area: welcome; margin-bottom: 0; }
  .balance-card { grid-area: balance; margin-bottom: 0; }
  .quick-actions { grid-area: quick; margin-bottom: 0; }
  .wallets { grid-area: wallets; margin-bottom: 0; }
  #section-stats { grid-area: stats; }
  #section-list  { grid-area: list; }
  .add-section { grid-area: add; }
  .app-footer { grid-area: footer; }

  .bottom-nav { display: none; }

  .form-row-2 { grid-template-columns: 1fr 1fr 1fr; }
  .form-row-2:first-of-type { grid-template-columns: 1fr 1fr 1fr; }

  .wallet-stack { flex-direction: row; gap: 14px; }
  .wallet-card { margin-bottom: 0; margin-left: 0 !important; margin-right: 0 !important; flex: 1; }
  .wallet-card::before { width: 100px; height: 100px; }
}

/* =========================================================
   AUTH GATE
   ========================================================= */
.app[hidden] { display: none; }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #c084fc 100%);
  overflow: hidden;
  isolation: isolate;
}

.auth-blob {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
  z-index: 0;
}
.auth-blob-1 { width: 280px; height: 280px; top: -100px; right: -80px; }
.auth-blob-2 { width: 220px; height: 220px; bottom: -100px; left: -60px; background: rgba(255, 255, 255, 0.06); }

.auth-card {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 24px;
  padding: 28px 24px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  max-height: 92vh;
  overflow-y: auto;
}

.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-logo {
  font-size: 2.2rem;
  margin-bottom: 4px;
}
.auth-brand h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}
.auth-brand p {
  font-size: 0.85rem;
  color: var(--text-2);
}

.auth-pane h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
  text-align: center;
}
.auth-hint {
  font-size: 0.85rem;
  color: var(--text-2);
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.45;
}

.auth-pane .btn-primary {
  width: 100%;
  margin-top: 4px;
}

.auth-pane[hidden] { display: none; }

.auth-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.95rem;
  font-family: "SF Mono", "Consolas", "Monaco", monospace;
  margin-bottom: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.auth-token-block {
  margin-top: 14px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}
.auth-warning {
  font-size: 0.8rem;
  color: #b45309;
  background: #fef3c7;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
  line-height: 1.4;
}
.auth-token-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.auth-token-row code {
  flex: 1;
  font-family: "SF Mono", "Consolas", "Monaco", monospace;
  font-size: 0.85rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  word-break: break-all;
  letter-spacing: 0.5px;
  user-select: all;
}
.auth-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-2);
  margin-bottom: 12px;
  cursor: pointer;
}
.auth-check input { width: 16px; height: 16px; cursor: pointer; }
.auth-check input:disabled { cursor: not-allowed; }

.btn-primary[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--c-primary-soft);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   SETTINGS MODAL
   ========================================================= */
.settings-section {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-2);
}
.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.settings-section h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-bottom: 10px;
}
.settings-hint {
  font-size: 0.82rem;
  color: var(--text-2);
  margin-bottom: 10px;
  line-height: 1.4;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.88rem;
}
.settings-label { color: var(--text-2); }
.settings-value { color: var(--text); font-weight: 600; }
.settings-value.mono {
  font-family: "SF Mono", "Consolas", "Monaco", monospace;
  font-size: 0.82rem;
  letter-spacing: 1px;
}
.dot-ok {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-income);
  margin-right: 6px;
  vertical-align: middle;
}
.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.settings-actions .btn-secondary {
  width: 100%;
  padding: 10px;
  font-size: 0.85rem;
}
