/* ══════════════════════════════════════════════════════════════
   WealthOS — Modern Dark Financial Dashboard
   Dark navy + indigo/purple accent theme
══════════════════════════════════════════════════════════════ */

/* ─── Variables ─────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base:       #080b14;
  --bg-sidebar:    #0c0f1a;
  --bg-panel:      #111525;
  --bg-panel-alt:  #161b2e;
  --bg-hover:      #1a2035;
  --border:        #1e2640;
  --border-subtle: #171e32;

  /* Accent — Indigo / Purple */
  --accent:        #6366f1;
  --accent-light:  #818cf8;
  --accent-dim:    rgba(99,102,241,0.12);
  --accent-glow:   rgba(99,102,241,0.25);
  --accent-grad:   linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  /* Semantic */
  --up:      #34d399;
  --down:    #f87171;
  --up-dim:   rgba(52,211,153,0.1);
  --down-dim: rgba(248,113,113,0.1);
  --warn:    #fbbf24;

  /* Text */
  --text-primary:   #eef0ff;
  --text-secondary: #8892a4;
  --text-tertiary:  #3d4a63;

  /* Fonts */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;
  --font-body:    'DM Sans', system-ui, sans-serif;

  /* Radii */
  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;

  /* Shadows */
  --shadow-card:  0 4px 24px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.03);
  --shadow-glow:  0 0 24px rgba(99,102,241,0.15);
}

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

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── App Layout ─────────────────────────────────────────────── */
#app-content {
  display: flex;
  min-height: 100vh;
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════ */
.sidebar {
  width: 230px;
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 0 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px 36px;
}

.logo__mark {
  width: 36px;
  height: 36px;
  background: var(--accent-grad);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(99,102,241,0.35);
}

.logo__name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 14px;
  flex: 1;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  transition: all 0.18s ease;
  border: 1px solid transparent;
}

button.nav__item {
  background: none;
  width: 100%;
  font-family: inherit;
  cursor: pointer;
}

.nav__item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav__item--active {
  background: var(--accent-dim);
  color: var(--accent-light);
  border-color: rgba(99,102,241,0.2);
}

.nav__icon { font-size: 14px; }

.sidebar__footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  margin: 0 14px;
}

.user__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.user__info   { display: flex; flex-direction: column; gap: 2px; }
.user__name   { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.user__plan   { font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); }

/* ══════════════════════════════════════════════════════════════
   MAIN
══════════════════════════════════════════════════════════════ */
.main {
  flex: 1;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  min-width: 0;
  background:
    radial-gradient(ellipse 70% 50% at 80% -10%, rgba(99,102,241,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 0% 100%, rgba(139,92,246,0.05) 0%, transparent 50%);
}

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar__left { display: flex; flex-direction: row; align-items: center; gap: 14px; }
.topbar__title-group { display: flex; flex-direction: column; gap: 4px; }

.page__title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.3px;
  line-height: 1;
}

.page__date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.5px;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}


.market__pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 14px;
  border-radius: 99px;
  letter-spacing: 0.5px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.18s ease;
  letter-spacing: 0.3px;
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--accent-dim);
}

.btn--primary {
  background: var(--accent-grad);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(99,102,241,0.35);
}

.btn--primary:hover {
  box-shadow: 0 4px 22px rgba(99,102,241,0.55);
  opacity: 0.92;
}

.btn--large {
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 10px;
}

/* ─── KPI Grid ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 16px;
}

.kpi-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.kpi-card:hover {
  border-color: rgba(99,102,241,0.25);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.kpi-card--primary {
  background: linear-gradient(145deg, #111828 0%, #151d34 100%);
  border-color: rgba(99,102,241,0.3);
}

.kpi-card--primary::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-grad);
}

.kpi-card--primary::after {
  content: '';
  position: absolute;
  top: -50px; right: -50px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.kpi__label {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.kpi__value {
  font-family: var(--font-body);
  font-size: 34px;
  font-weight: 300;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -1px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi__value--sm { font-size: 24px; }

.kpi__change {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kpi__change--up   { color: var(--up); }
.kpi__change--down { color: var(--down); }
.kpi__sub { font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); }

/* ─── Mid Grid ───────────────────────────────────────────────── */
.mid-grid {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 16px;
  /* default align-items: stretch — both cells grow to the same row height */
}

/* ─── Panels ─────────────────────────────────────────────────── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.panel__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.3px;
  color: var(--text-primary);
}

.panel__badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  background: var(--bg-base);
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  letter-spacing: 0.5px;
}

/* ─── Donut ──────────────────────────────────────────────────── */
.donut-wrapper {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 0 auto 20px;
  filter: drop-shadow(0 0 16px rgba(99,102,241,0.12));
}

.donut-svg { width: 100%; height: 100%; }

.donut-slice {
  transition: opacity 0.18s, filter 0.18s;
  cursor: pointer;
}

.donut-slice:hover {
  opacity: 0.85;
  filter: brightness(1.15);
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.donut__pct {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--text-primary);
  line-height: 1;
}

.donut__label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  letter-spacing: 0.5px;
  margin-top: 4px;
  max-width: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  max-height: 168px;
  width: 100%;
  max-width: 240px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding-right: 4px;
}

.legend::-webkit-scrollbar { width: 4px; }
.legend::-webkit-scrollbar-track { background: transparent; }
.legend::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.legend__item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}

.legend__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend__name { flex: 1; color: var(--text-secondary); font-family: var(--font-mono); font-size: 11px; }
.legend__pct  { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 11px; min-width: 38px; text-align: right; }

/* ─── Performance Chart ──────────────────────────────────────── */
.panel--allocation { display: flex; flex-direction: column; align-items: center; }
.panel--allocation .panel__header { width: 100%; }
.panel--performance { display: flex; flex-direction: column; }

.tab-group {
  display: flex;
  gap: 3px;
  background: var(--bg-base);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.tab {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.5px;
}

.tab:hover { color: var(--text-secondary); }

.tab--active {
  background: var(--bg-panel-alt);
  color: var(--accent-light);
}

.date-range-row {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.date-range-row--visible { display: flex; }

.date-input {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
  color-scheme: dark;
}
.date-input:focus { border-color: var(--accent); }

.date-range-sep {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 12px;
}

.date-range-apply {
  font-size: 11px;
  padding: 5px 12px;
}

.chart-area {
  flex: 1;          /* fills remaining height inside the performance panel */
  position: relative;
  min-height: 280px; /* floor so the chart is never too short when panels stack */
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.chart-area canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  letter-spacing: 0.3px;
}

/* ─── Holdings Table ─────────────────────────────────────────── */
.panel--table {
  padding: 0;
  overflow: hidden;
}

.panel--table .panel__header {
  padding: 18px 24px 0;
  margin-bottom: 16px;
}

.search-input {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 7px 12px;
  outline: none;
  width: 180px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input::placeholder { color: var(--text-tertiary); }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.table-wrapper { overflow-x: auto; }

.holdings-table {
  width: 100%;
  border-collapse: collapse;
}

.holdings-table thead tr {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.holdings-table th {
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  color: var(--text-tertiary);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
  background: var(--bg-base);
}

.holdings-table td {
  padding: 13px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.table-row { transition: background 0.15s; }
.table-row:hover { background: var(--bg-hover); }
.table-row:last-child td { border-bottom: none; }

.td--name {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary) !important;
  font-weight: 500;
}

.asset__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.td--link {
  color: inherit;
  text-decoration: none;
}
.td--link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.td--ticker { color: var(--text-tertiary) !important; letter-spacing: 1px; }
.td--price  { color: var(--text-primary) !important; }
.td--up     { color: var(--up) !important; }
.td--down   { color: var(--down) !important; }
.td--muted  { color: var(--text-tertiary) !important; }

.table__empty {
  text-align: center;
  padding: 40px 16px !important;
  color: var(--text-tertiary) !important;
  font-family: var(--font-display) !important;
  font-size: 16px !important;
  letter-spacing: 0.5px;
}

.btn-remove {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
}

.btn-remove:hover {
  border-color: var(--down);
  color: var(--down);
  background: var(--down-dim);
}

/* ══════════════════════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay--visible {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7), 0 0 40px rgba(99,102,241,0.08);
  transform: translateY(-12px);
  transition: transform 0.25s ease;
}
.modal--wide { width: 680px; }

.modal-overlay--visible .modal { transform: translateY(0); }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--border);
}

.modal__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.5px;
}

.modal__close {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s;
}

.modal__close:hover { color: var(--text-primary); }

.modal__body { padding: 22px 26px 26px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; flex: 1; min-height: 0; }
.modal__body--scrollable { overflow-y: auto; }

.modal__section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 0 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.asset-fields { display: flex; flex-direction: column; gap: 16px; }

.form-group  { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.form-row    { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }

/* Aligned multi-column row: labels share row 1, inputs share row 2 via subgrid.
   Works for any number of form-group children (2, 3, 4…). */
.form-row--aligned {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  row-gap: 0;
}
.form-row--aligned .form-group {
  display: grid;
  grid-row: span 2;
  grid-template-rows: subgrid;
  gap: 6px;
}

.form-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* Ticker input + inline lookup button */
.input-lookup-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.input-lookup-row .form-input { flex: 1; min-width: 0; }
.btn--lookup {
  flex-shrink: 0;
  padding: 0 14px;
  font-size: 11px;
  white-space: nowrap;
}
.btn--lookup:disabled { opacity: 0.5; cursor: default; }
.form-hint { display: block; margin-top: 4px; font-size: 11px; color: var(--text-muted, #8892a4); }

.form-input {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 13px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.form-input::placeholder { color: var(--text-tertiary); }
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* ── Datepicker ────────────────────────────────────────────────────────────── */
.datepicker { position: relative; }
.datepicker__input { cursor: pointer; user-select: none; caret-color: transparent; }
.datepicker__popup {
  position: fixed;
  z-index: 9999;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  width: 252px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.dp__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.dp__title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dp__nav {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
  padding: 0;
}
.dp__nav:hover { background: var(--bg-hover); color: var(--text-primary); }
.dp__nav--year { font-size: 13px; }
.dp__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.dp__dow {
  text-align: center;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  padding: 4px 0 6px;
  text-transform: uppercase;
}
.dp__day {
  text-align: center;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  padding: 6px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}
.dp__day:not(.dp__day--future):hover { background: var(--bg-hover); color: var(--text-primary); }
.dp__day--today {
  background: #fff;
  color: #111;
  font-weight: 600;
  border-radius: 6px;
}
.dp__day--today:hover { background: #fff; color: #111; }
.dp__day--selected { background: var(--accent-grad); color: #fff; font-weight: 500; }
.dp__day--selected:hover { background: var(--accent-grad); }
.dp__day--future { color: var(--text-tertiary); opacity: 0.4; cursor: default; pointer-events: none; }

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

/* ══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
  max-width: 300px;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.toast--success { border-color: var(--up);   background: var(--up-dim);   color: var(--up); }
.toast--error   { border-color: var(--down);  background: var(--down-dim); color: var(--down); }
.toast--warning { border-color: rgba(251,191,36,0.35); background: rgba(251,191,36,0.07); color: var(--warn); }
.toast--info    { border-color: var(--border); background: var(--bg-panel-alt); color: var(--text-secondary); }

/* ─── Button Loading State ───────────────────────────────────── */
.btn--loading {
  position: relative;
  color: transparent;
}

.btn--loading::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  top: 50%;
  left: 50%;
  margin: -6px 0 0 -6px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ══════════════════════════════════════════════════════════════
   HAMBURGER BUTTON
══════════════════════════════════════════════════════════════ */
.btn-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: all 0.15s;
}
.btn-hamburger:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--accent-dim);
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR BACKDROP (mobile overlay)
══════════════════════════════════════════════════════════════ */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 299;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.sidebar-backdrop--visible {
  opacity: 1;
  pointer-events: all;
}

/* ══════════════════════════════════════════════════════════════
   MOBILE BOTTOM NAV
══════════════════════════════════════════════════════════════ */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 62px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding: 0 4px;
  align-items: stretch;
}

.mobile-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  transition: color 0.15s;
}

.mobile-nav__item--active { color: var(--accent-light); }

.mobile-nav__icon  { font-size: 17px; line-height: 1; }
.mobile-nav__label {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .mid-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* ── Sidebar: slide-in drawer ──────────────────────────────── */
  .sidebar {
    position: fixed;
    top: 0;
    left: -240px;
    z-index: 300;
    height: 100vh;
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar--open {
    left: 0;
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.6);
  }
  .sidebar-backdrop { display: block; }

  /* ── Hamburger & mobile nav visible ───────────────────────── */
  .btn-hamburger { display: flex; }
  .mobile-nav    { display: flex; }

  /* ── Main: extra bottom padding for mobile nav ────────────── */
  .main { padding: 20px 16px 80px; width: 100%; }

  /* ── Topbar ────────────────────────────────────────────────── */
  .market__pill { display: none; }
  .topbar__right { gap: 8px; }
  .topbar__right .btn--large { padding: 8px 14px; font-size: 12px; }

  /* ── KPI grid: 2 columns on tablet/mobile ─────────────────── */
  .kpi-grid { grid-template-columns: 1fr 1fr; }

  /* ── Panel header: allow wrapping when title + tabs don't fit */
  .panel__header { flex-wrap: wrap; gap: 10px; }

  /* ── Forms ─────────────────────────────────────────────────── */
  .form-row { flex-direction: column; }

  /* ── Modal → bottom sheet ──────────────────────────────────── */
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%); /* slide up from below */
  }
  .modal-overlay--visible .modal { transform: translateY(0); }

  /* Ensure header stays visible while body scrolls */
  .modal__header { flex-shrink: 0; }
  .modal__body { -webkit-overflow-scrolling: touch; }

  /* Reset aligned grid rows to a simple column stack on mobile */
  .form-row--aligned {
    display: flex;
    flex-direction: column;
  }
  .form-row--aligned .form-group {
    display: flex;
    grid-row: unset;
    grid-template-rows: unset;
  }

  /* ── Page title ────────────────────────────────────────────── */
  .page__title { font-size: 24px; }

  /* ── Touch targets: all interactive elements ≥ 44px ───────── */
  .btn-hamburger {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
  .modal__close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  /* Sidebar nav items (in the drawer) */
  .nav__item { min-height: 44px; padding: 12px 14px; }

  /* Chart period tab buttons — increase vertical padding */
  .tab { min-height: 36px; padding: 8px 10px; }

  /* Remove buttons in table rows */
  .btn-remove {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Toast: lift above mobile nav (62px tall) ──────────────── */
  .toast-container { bottom: 80px; }
}

@media (max-width: 480px) {
  /* ── KPI grid: single column on phones ────────────────────── */
  .kpi-grid { grid-template-columns: 1fr; }

  /* ── KPI values: tighter font so numbers fit in 2-col grids
        (holdings page keeps 2 cols at this width)            ── */
  .kpi__value    { font-size: 26px; }
  .kpi__value--sm { font-size: 19px; letter-spacing: -0.3px; }

  /* ── Topbar: stack on very small screens ──────────────────── */
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .topbar__right { width: 100%; justify-content: flex-end; }

  /* ── Donut: cap size so it never wider than available area ── */
  .donut-wrapper { width: min(200px, 100%); height: min(200px, 100%); }

  /* ── Date range row: wrap inputs onto separate lines ────────── */
  .date-range-row--visible { flex-wrap: wrap; }
  .date-input { flex: 1; min-width: 120px; }

  /* ── Tab group: allow wrapping if too many tabs ────────────── */
  .tab-group { flex-wrap: wrap; }

  /* ── Mobile nav labels: ensure readable text size ────────────── */
  .mobile-nav__label { font-size: 10px; }

  /* ── Modal body padding: tighter on smallest screens ─────────── */
  .modal__body { padding: 16px 18px 18px; }
  .modal__header { padding: 16px 18px 14px; }
}
