/* ============================================================
   WealthFlow – Design System
   Aesthetic: Dark Luxury Fintech — obsidian base, gold accents,
   DM Serif Display headlines, surgical spacing
   ============================================================ */

/* ── Tokens ──────────────────────────────────────────────── */
:root {
  --bg:        #0a0b0f;
  --bg2:       #111318;
  --bg3:       #181c24;
  --surface:   #1e2330;
  --surface2:  #252c3a;
  --border:    rgba(255,255,255,.07);
  --border2:   rgba(255,255,255,.12);

  --gold:      #c9a84c;
  --gold-lt:   #e8c97a;
  --gold-dk:   #8a6c2a;
  --green:     #22c55e;
  --red:       #ef4444;
  --blue:      #3b82f6;
  --purple:    #a855f7;
  --cyan:      #06b6d4;

  --text:      #f0f2f8;
  --text2:     #8b93a8;
  --text3:     #4a5370;

  --radius:    14px;
  --radius-sm: 8px;
  --radius-lg: 20px;

  --font-serif: 'DM Serif Display', Georgia, serif;
  --font-sans:  'DM Sans', system-ui, sans-serif;

  --sidebar-w: 240px;
  --topbar-h:  60px;
  --shadow:    0 4px 32px rgba(0,0,0,.45);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.6);
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea {
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .55rem .9rem;
  width: 100%;
  outline: none;
  transition: border-color .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
select option { background: var(--bg3); }
h1,h2,h3 { font-family: var(--font-serif); font-weight: 400; line-height: 1.2; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform .3s;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 1.4rem 1.2rem 1rem;
  border-bottom: 1px solid var(--border);
}
.logo-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--gold-dk), var(--gold));
  border-radius: 10px;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: #fff;
  flex-shrink: 0;
}
.logo-text {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  letter-spacing: .02em;
  color: var(--text);
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: 1rem .75rem;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem .85rem;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(201,168,76,.15), rgba(201,168,76,.05));
  color: var(--gold);
  border-left: 2px solid var(--gold);
  padding-left: calc(.85rem - 2px);
}
.sidebar-footer {
  padding: 1rem .75rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.user-pill { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--gold-dk), var(--gold));
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: .8rem;
  color: #fff;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: .7rem; color: var(--text3); }
.logout-btn {
  color: var(--text3); padding: .4rem;
  border-radius: 6px;
  transition: color .2s;
  display: grid; place-items: center;
}
.logout-btn:hover { color: var(--red); }
.logout-btn svg { width: 16px; height: 16px; }

/* ── Main layout ─────────────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-x: hidden; }
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 50;
}
.menu-toggle {
  display: none;
  color: var(--text2);
  padding: .3rem;
}
.menu-toggle svg { width: 20px; height: 20px; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.currency-badge, .date-badge {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: .2rem .75rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text2);
}
.page-container { padding: 1.75rem 2rem; max-width: 1400px; }

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}
.page-title { font-size: 2rem; color: var(--text); }
.page-subtitle { font-size: .85rem; color: var(--text2); margin-top: .15rem; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}
.card-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text2);
}

/* ── KPI cards ───────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, transform .15s;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent, var(--gold));
  opacity: .7;
}
.kpi-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.kpi-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text2); margin-bottom: .45rem; }
.kpi-value { font-family: var(--font-serif); font-size: 1.7rem; color: var(--text); line-height: 1; }
.kpi-sub { font-size: .75rem; color: var(--text2); margin-top: .3rem; }
.kpi-icon {
  position: absolute; top: 1rem; right: 1rem;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  display: grid; place-items: center;
}
.kpi-icon svg { width: 18px; height: 18px; }

/* ── Grid layouts ────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.grid-col-3-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 1.25rem; }
.grid-col-2-3 { display: grid; grid-template-columns: 2fr 3fr; gap: 1.25rem; }

/* ── Tables ──────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
  text-align: left;
  padding: .6rem 1rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: .8rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--text2);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.data-table .amount { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.data-table .amount.neg { color: var(--red); }
.data-table .amount.pos { color: var(--green); }

/* ── Allocation bars ──────────────────────────────────────── */
.allocation-list { display: flex; flex-direction: column; gap: .85rem; }
.alloc-item { }
.alloc-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .35rem; }
.alloc-name { display: flex; align-items: center; gap: .5rem; font-size: .85rem; font-weight: 500; }
.alloc-dot { width: 8px; height: 8px; border-radius: 50%; }
.alloc-pct { font-size: .75rem; color: var(--text3); }
.alloc-amounts { display: flex; align-items: center; gap: .3rem; font-size: .8rem; }
.alloc-bar { height: 6px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; }
.alloc-bar-fill { height: 100%; border-radius: 3px; transition: width .6s cubic-bezier(.4,0,.2,1); }

/* ── Progress bars ───────────────────────────────────────── */
.progress-bar { height: 8px; background: rgba(255,255,255,.08); border-radius: 4px; overflow: hidden; margin-top: .5rem; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .6s; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  transition: opacity .15s, transform .12s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: linear-gradient(135deg, var(--gold-dk), var(--gold));
  color: #0a0b0f;
}
.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text2);
}
.btn-danger { background: rgba(239,68,68,.15); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-icon { padding: .45rem; border-radius: 6px; }

/* ── Badge / tag ─────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.badge-green { background: rgba(34,197,94,.15); color: var(--green); }
.badge-red   { background: rgba(239,68,68,.15); color: var(--red); }
.badge-gold  { background: rgba(201,168,76,.15); color: var(--gold); }
.badge-blue  { background: rgba(59,130,246,.15); color: var(--blue); }

/* ── Forms ───────────────────────────────────────────────── */
.form-grid { display: grid; gap: 1rem; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-label { font-size: .78rem; font-weight: 600; color: var(--text2); }
.form-row { display: flex; gap: .75rem; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: grid; place-items: center;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  position: relative;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  color: var(--text3); padding: .3rem;
  border-radius: 6px; transition: color .2s;
}
.modal-close:hover { color: var(--text); }
.modal-close svg { width: 18px; height: 18px; }
.modal-title { font-family: var(--font-serif); font-size: 1.4rem; margin-bottom: 1.25rem; }

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 300;
  display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  font-size: .85rem;
  min-width: 240px;
  animation: toastIn .25s ease;
  display: flex; align-items: center; gap: .6rem;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }

/* ── Goal cards ──────────────────────────────────────────── */
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.goal-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}
.goal-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--goal-color, var(--gold));
}
.goal-name { font-family: var(--font-serif); font-size: 1.05rem; margin-bottom: .25rem; }
.goal-amounts { font-size: .8rem; color: var(--text2); margin-bottom: .6rem; }
.goal-pct { font-size: .78rem; font-weight: 700; color: var(--text); margin-top: .4rem; }

/* ── Asset grid ──────────────────────────────────────────── */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.asset-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex; align-items: flex-start; justify-content: space-between;
}
.asset-type-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--surface);
  display: grid; place-items: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.asset-info { flex: 1; margin-left: .85rem; }
.asset-name { font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
.asset-type { font-size: .72rem; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; }
.asset-value { font-family: var(--font-serif); font-size: 1.2rem; margin-top: .3rem; }

/* ── Auth pages ──────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 1.5rem;
}
.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%; max-width: 420px;
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo .logo-mark { margin: 0 auto .75rem; width: 48px; height: 48px; font-size: 1.6rem; }
.auth-logo h1 { font-family: var(--font-serif); font-size: 1.8rem; }
.auth-logo p { font-size: .85rem; color: var(--text2); margin-top: .3rem; }
.auth-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  font-size: .85rem;
  color: var(--red);
  margin-bottom: 1rem;
}
.auth-link { text-align: center; font-size: .85rem; color: var(--text2); margin-top: 1.25rem; }
.auth-link a { color: var(--gold); }

/* ── Chart containers ────────────────────────────────────── */
.chart-wrap { position: relative; }

/* ── Divider ─────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 1rem 0; }

/* ── Helpers ─────────────────────────────────────────────── */
.text-gold   { color: var(--gold); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-muted  { color: var(--text2); }
.text-sm     { font-size: .8rem; }
.text-right  { text-align: right; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.flex { display: flex; } .items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ── Month picker ────────────────────────────────────────── */
.month-picker {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: .4rem .8rem;
  color: var(--text);
  font-size: .85rem;
  cursor: pointer;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-col-3-2, .grid-col-2-3 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh;
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: grid; }
  .page-container { padding: 1.25rem 1rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ── V2: tabs, wallets, streams ─────────────────────────── */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); }
.tab {
  padding: .6rem 1.1rem; font-size: .88rem; color: var(--text2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.wallet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .75rem;
}
.wallet-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--w-color, var(--gold));
  border-radius: var(--radius-sm);
  padding: .75rem .9rem;
}
.wallet-chip-name { font-size: .82rem; color: var(--text2); }
.wallet-chip-balance { font-family: var(--font-serif); font-size: 1.1rem; color: var(--gold); }
.wallet-chip-lg { border-left-width: 4px; }
.stream-list { display: flex; flex-direction: column; gap: .65rem; }
.stream-card {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  padding: .85rem 1rem; background: var(--bg3); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.v2-hint {
  background: rgba(201,168,76,.08); border: 1px solid rgba(201,168,76,.2);
  border-radius: 8px; padding: .75rem; font-size: .8rem; color: var(--gold);
}
.v2-warn {
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25);
  border-radius: 8px; padding: .5rem .75rem; font-size: .78rem; color: var(--red); margin-top: .35rem;
}
.badge-cyan { background: rgba(6,182,212,.15); color: var(--cyan); }
.badge-green { background: rgba(34,197,94,.15); color: var(--green); }
.wallet-available {
  margin-top: .5rem;
  padding: .7rem .9rem;
  background: rgba(201,168,76,.1);
  border: 1px solid rgba(201,168,76,.28);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  line-height: 1.4;
}
.wallet-available.hidden { display: none; }
.wallet-available.low {
  border-color: rgba(239,68,68,.45);
  background: rgba(239,68,68,.1);
  color: var(--text);
}
.wallet-available .wallet-available-amt {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--gold);
  display: block;
  margin-top: .2rem;
}
.wallet-available.low .wallet-available-amt { color: var(--red); }
