/* ═══════════════════════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════════════════════ */
:root {
  /* Backgrounds — layered depth */
  --bg-0: #06080f;
  --bg-1: #0b0e1a;
  --bg-2: #111520;
  --bg-3: #181c2e;
  --bg-4: #1e2338;
  --bg-card: #0f1322;
  --bg-hover: #161b2e;
  --bg-input: #0a0d18;

  /* Borders */
  --border-0: rgba(90, 110, 170, 0.07);
  --border: rgba(90, 110, 170, 0.13);
  --border-md: rgba(90, 110, 170, 0.24);
  --border-bright: rgba(90, 110, 170, 0.45);

  /* Text */
  --text-1: #eceef8;
  --text-2: #7d8baf;
  --text-3: #404d6e;
  --text-4: #262e47;

  /* Accent colors */
  --blue: #4d8df5;
  --blue-light: #6ba3f8;
  --blue-dim: rgba(77, 141, 245, 0.14);
  --blue-glow: rgba(77, 141, 245, 0.25);

  --purple: #9568f0;
  --purple-dim: rgba(149, 104, 240, 0.14);

  --green: #2dd4a4;
  --green-dim: rgba(45, 212, 164, 0.12);

  --red: #f06060;
  --red-dim: rgba(240, 96, 96, 0.12);

  --amber: #f5bc3a;
  --amber-dim: rgba(245, 188, 58, 0.12);

  --cyan: #18d4e8;
  --pink: #e84daa;
  --teal: #14b8a6;

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 15px;
  --radius-xl: 20px;
  --radius-2xl: 26px;

  /* Typography */
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --mono: 'DM Mono', 'Fira Code', monospace;

  /* Motion */
  --transition: 160ms ease;
  --transition-slow: 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ═══════════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-0);
  color: var(--text-1);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Atmospheric background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 90% 60% at 15% -5%, rgba(77, 141, 245, 0.055) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 85% 105%, rgba(149, 104, 240, 0.045) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(77, 141, 245, 0.02) 0%, transparent 60%);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px 28px 80px;
}

/* ═══════════════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════════════ */
header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 32px;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 13px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(77, 141, 245, 0.3), 0 4px 16px rgba(77, 141, 245, 0.2);
}

.logo-icon svg { width: 20px; height: 20px; color: #fff; }

.logo-text h1 {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text-1);
  line-height: 1.2;
}

.logo-text span {
  color: var(--text-3);
  font-size: 0.8rem;
  font-weight: 400;
  display: block;
  margin-top: 2px;
  letter-spacing: 0.01em;
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

/* Header status pills */
.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.775rem;
  color: var(--text-3);
}
.status-pill strong { color: var(--text-1); font-weight: 600; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.status-dot.stale { background: var(--amber); }

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.btn-group {
  display: flex;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}
.btn-group .btn {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border);
}
.btn-group .btn:last-child { border-right: none; }
.btn-group .btn:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: -0.01em;
  white-space: nowrap;
  line-height: 1;
}

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 1px 3px rgba(77, 141, 245, 0.4), 0 4px 14px rgba(77, 141, 245, 0.2);
}
.btn-primary:hover {
  background: var(--blue-light);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(77, 141, 245, 0.5), 0 4px 20px rgba(77, 141, 245, 0.25);
}
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  background: var(--bg-2);
  color: var(--text-2);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text-1); border-color: var(--border-md); background: var(--bg-3); }
.btn-ghost:active { transform: scale(0.97); }

.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #e04f4f; transform: translateY(-1px); }

.btn-icon-only {
  width: 36px; height: 36px;
  padding: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-icon-only:hover { color: var(--text-1); border-color: var(--border-md); background: var(--bg-3); }
.btn-icon-only svg { width: 16px; height: 16px; }

.btn.loading { opacity: 0.5; pointer-events: none; }
.btn.loading .spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════
   TABS
═══════════════════════════════════════════════════════════ */
nav.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 4px;
  width: fit-content;
  margin-bottom: 28px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  background: transparent;
  border: none;
  color: var(--text-3);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.tab-btn svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.6; }
.tab-btn:hover { color: var(--text-2); background: var(--bg-2); }
.tab-btn:hover svg { opacity: 1; }
.tab-btn.active {
  background: var(--bg-4);
  color: var(--text-1);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.04);
}
.tab-btn.active svg { opacity: 1; color: var(--blue); }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ═══════════════════════════════════════════════════════════
   STAT CARDS
═══════════════════════════════════════════════════════════ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
/* Top shimmer line */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(120, 140, 200, 0.18) 50%, transparent 100%);
}
.stat-card:hover {
  border-color: var(--border-md);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* Colored left border accents */
.stat-card.accent-positive { border-left: 2px solid var(--green); }
.stat-card.accent-negative { border-left: 2px solid var(--red); }
.stat-card.accent-blue     { border-left: 2px solid var(--blue); }
.stat-card.accent-purple   { border-left: 2px solid var(--purple); }
.stat-card.accent-amber    { border-left: 2px solid var(--amber); }

/* Glow dot accent in top-right corner */
.stat-card::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.stat-card.accent-blue::after { background: radial-gradient(circle, var(--blue-dim), transparent); }
.stat-card.accent-positive::after { background: radial-gradient(circle, var(--green-dim), transparent); }
.stat-card.accent-negative::after { background: radial-gradient(circle, var(--red-dim), transparent); }
.stat-card.accent-purple::after { background: radial-gradient(circle, var(--purple-dim), transparent); }
.stat-card:hover::after { opacity: 1; }

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.stat-icon { width: 16px; height: 16px; color: var(--text-4); flex-shrink: 0; }

.stat-value {
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-bottom: 4px;
}
.stat-sub {
  font-size: 0.775rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.stat-sub.positive { color: var(--green); }
.stat-sub.negative { color: var(--red); }

/* ═══════════════════════════════════════════════════════════
   GENERIC CARD
═══════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-md); }
.card-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 16px;
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD SECONDARY GRID
═══════════════════════════════════════════════════════════ */
.dashboard-secondary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

/* Allocation bars */
.allocation-list { display: flex; flex-direction: column; gap: 13px; }
.allocation-item { display: flex; flex-direction: column; gap: 5px; }
.allocation-info { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.allocation-name { font-size: 0.8375rem; font-weight: 500; color: var(--text-1); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.allocation-pct { font-size: 0.775rem; color: var(--text-3); font-variant-numeric: tabular-nums; flex-shrink: 0; }

.alloc-bar { height: 3px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.alloc-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  transition: width 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.alloc-fill.green { background: linear-gradient(90deg, var(--green), var(--teal)); }
.alloc-fill.amber { background: linear-gradient(90deg, var(--amber), #e97d1a); }

.allocation-value { font-size: 0.725rem; color: var(--text-3); font-family: var(--mono); }

/* Performers */
.performers-list { display: flex; flex-direction: column; gap: 6px; }
.performer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 13px;
  background: var(--bg-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-0);
  transition: border-color var(--transition), background var(--transition);
  gap: 8px;
}
.performer-item:hover { border-color: var(--border); background: var(--bg-3); }
.performer-name {
  font-size: 0.8375rem;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.performer-value { font-size: 0.8375rem; font-weight: 600; font-family: var(--mono); flex-shrink: 0; }
.performer-item.pos .performer-value { color: var(--green); }
.performer-item.neg .performer-value { color: var(--red); }

/* Rank badge on performers */
.performer-rank {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--border);
  font-size: 0.65rem; font-weight: 700; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.last-updated {
  text-align: center;
  color: var(--text-4);
  font-size: 0.725rem;
  margin-top: 20px;
  letter-spacing: 0.01em;
}

/* ═══════════════════════════════════════════════════════════
   SECTION HEADER (used in History)
═══════════════════════════════════════════════════════════ */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-1);
}

/* ═══════════════════════════════════════════════════════════
   FILTER BAR
═══════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-3);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 0.8375rem;
  transition: var(--transition);
}
.search-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim);
  background: var(--bg-1);
}
.search-input::placeholder { color: var(--text-4); }

.filter-select {
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: var(--transition);
}
.filter-select:focus { outline: none; border-color: var(--blue); }

.filter-count {
  font-size: 0.75rem;
  color: var(--text-3);
  padding: 0 4px;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════════════════ */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.asset-table { width: 100%; border-collapse: collapse; }
.asset-table thead { position: sticky; top: 0; z-index: 2; }

.asset-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 0.685rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}
.asset-table th:hover { color: var(--text-2); }
.asset-table th.sorted { color: var(--blue); }
.asset-table th:last-child { cursor: default; }

.asset-table td {
  padding: 12px 14px;
  font-size: 0.8375rem;
  border-bottom: 1px solid var(--border-0);
  white-space: nowrap;
  vertical-align: middle;
}
.asset-table tr:last-child td { border-bottom: none; }
.asset-table tbody tr { transition: background var(--transition); }
.asset-table tbody tr:hover { background: var(--bg-hover); }

/* Generic .table for price history */
.table { width: 100%; border-collapse: collapse; font-size: 0.8375rem; }
.table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.685rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border-0); color: var(--text-1); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-hover); }

.cell-name { display: flex; flex-direction: column; gap: 2px; }
.asset-name { font-weight: 500; color: var(--text-1); }
.asset-ticker {
  font-size: 0.7rem;
  color: var(--text-3);
  font-family: var(--mono);
  letter-spacing: 0.05em;
}
.asset-note {
  font-size: 0.695rem;
  color: var(--text-3);
  font-style: italic;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }

/* ═══════════════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.685rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.badge-etf     { background: var(--blue-dim);   color: var(--blue);   }
.badge-stock   { background: var(--purple-dim); color: var(--purple); }
.badge-crypto  { background: var(--amber-dim);  color: var(--amber);  }
.badge-fund    { background: rgba(24,212,232,0.1); color: var(--cyan); }
.badge-bond    { background: var(--green-dim);  color: var(--green);  }
.badge-p2p     { background: rgba(232,77,170,0.1); color: var(--pink); }
.badge-savings { background: rgba(45,212,164,0.1); color: var(--green); }
.badge-manual  { background: rgba(110,120,150,0.1); color: var(--text-2); }

/* FX conversion indicator */
.fx-badge {
  font-size: 0.62rem;
  padding: 1px 5px;
  background: var(--purple-dim);
  color: var(--purple);
  border-radius: var(--radius-xs);
  font-family: var(--mono);
  margin-left: 4px;
  vertical-align: middle;
}

.mono { font-family: var(--mono); }

/* ═══════════════════════════════════════════════════════════
   ACTION BUTTONS (inline icon buttons)
═══════════════════════════════════════════════════════════ */
.actions-cell { display: flex; gap: 3px; }

.btn-icon {
  width: 28px; height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon svg { width: 14px; height: 14px; }

.btn-edit  { color: var(--blue); }
.btn-edit:hover  { background: var(--blue-dim);  border-color: rgba(77,141,245,0.3);  }

.btn-price { color: var(--green); }
.btn-price:hover { background: var(--green-dim); border-color: rgba(45,212,164,0.3); }

.btn-delete { color: var(--red); }
.btn-delete:hover { background: var(--red-dim); border-color: rgba(240,96,96,0.3); }

/* ═══════════════════════════════════════════════════════════
   EMPTY STATES
═══════════════════════════════════════════════════════════ */
.empty-state-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.empty-icon {
  width: 48px; height: 48px;
  color: var(--text-4);
  margin-bottom: 16px;
  opacity: 0.7;
}
.empty-state-wrap p { color: var(--text-2); margin-bottom: 22px; font-size: 0.9rem; line-height: 1.6; }
.empty-list { color: var(--text-3); text-align: center; padding: 20px; font-size: 0.8rem; }

/* ═══════════════════════════════════════════════════════════
   CHARTS
═══════════════════════════════════════════════════════════ */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  transition: border-color var(--transition);
}
.chart-card:hover { border-color: var(--border-md); }
.chart-card-wide { grid-column: 1 / -1; }

.chart-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.chart-card-header h3 {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}
.chart-badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-3);
  font-weight: 500;
}

.chart-container { position: relative; height: 260px; overflow: hidden; max-width: 100%; }
.chart-container-tall { height: 300px; }
.chart-container canvas { max-width: 100% !important; }
.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 260px;
  color: var(--text-3);
  font-size: 0.8rem;
  text-align: center;
  padding: 24px;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════ */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 14, 0.82);
  backdrop-filter: blur(8px) saturate(0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.18s ease;
  padding: 20px;
}
#modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(90, 110, 170, 0.06);
  animation: slideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 650px; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-0);
}
.modal-header h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.modal-close {
  width: 26px; height: 26px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
  line-height: 1;
}
.modal-close:hover { color: var(--text-1); border-color: var(--border-md); background: var(--bg-4); }

.modal-body { padding: 20px 22px; }
.modal-body p { color: var(--text-2); font-size: 0.875rem; margin-bottom: 14px; line-height: 1.65; }

.modal-form { padding: 20px 22px; display: flex; flex-direction: column; gap: 13px; }

/* FORM ELEMENTS */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 13px; }

.form-group label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 0.875rem;
  transition: var(--transition);
  appearance: auto;
}
.form-group select { -webkit-appearance: auto; }
.form-group textarea { resize: vertical; min-height: 68px; line-height: 1.5; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim);
  background: var(--bg-1);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-4); }
.form-hint { font-size: 0.72rem; color: var(--text-3); margin-top: 3px; }
.form-section-title {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-top: 4px;
}

.file-input {
  padding: 12px;
  background: var(--bg-input);
  border: 1px dashed var(--border-md);
  border-radius: var(--radius-md);
  color: var(--text-2);
  width: 100%;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.875rem;
  transition: var(--transition);
}
.file-input:hover { border-color: var(--blue); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border-0);
}

/* ═══════════════════════════════════════════════════════════
   SETTINGS PANEL
═══════════════════════════════════════════════════════════ */
.settings-section { margin-bottom: 26px; }
.settings-section:last-child { margin-bottom: 0; }
.settings-section h3 {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-0);
  gap: 16px;
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 0.875rem; font-weight: 500; color: var(--text-1); }
.setting-desc { font-size: 0.775rem; color: var(--text-3); margin-top: 2px; }

.platform-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--text-2);
}
.platform-tag button {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  transition: color var(--transition);
}
.platform-tag button:hover { color: var(--red); }
.platforms-wrap { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.add-platform-row { display: flex; gap: 8px; }
.add-platform-row input { flex: 1; }

/* ═══════════════════════════════════════════════════════════
   KEYBOARD SHORTCUT HINTS
═══════════════════════════════════════════════════════════ */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  background: var(--bg-3);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-xs);
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--text-2);
  min-width: 22px;
}

/* ═══════════════════════════════════════════════════════════
   TRANSACTIONS TAB
═══════════════════════════════════════════════════════════ */
.tx-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 0;
}
.tx-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  min-width: 130px;
}
.tx-stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.tx-stat-value {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}

/* Transaction type badges */
.tx-type-buy  { color: var(--green) !important; }
.tx-type-sell { color: var(--red) !important; }
.badge-tx-buy  { background: var(--green-dim); color: var(--green); }
.badge-tx-sell { background: var(--red-dim);   color: var(--red);   }

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  padding: 12px 18px;
  background: var(--bg-3);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.6);
  font-size: 0.8375rem;
  font-weight: 500;
  z-index: 2000;
  transform: translateY(130px);
  opacity: 0;
  transition: all 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.toast-success::before { background: var(--green); }
.toast-error::before   { background: var(--red); }
.toast-info::before    { background: var(--blue); }
.toast-show { transform: translateY(0); opacity: 1; }

/* ═══════════════════════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Complete mobile-first overhaul
═══════════════════════════════════════════════════════════ */

/* ── 1200px: hide center status bar, shrink to 2-col header ── */
@media (max-width: 1200px) {
  header { grid-template-columns: 1fr 1fr; }
  .header-center { display: none; }
}

/* ── 1024px: single-col charts, smaller padding ── */
@media (max-width: 1024px) {
  .app { padding: 18px 18px 60px; }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .chart-card-wide { grid-column: 1; }
  .table-wrapper { border-radius: var(--radius-md); }
}

/* ── 768px: full mobile layout ── */
@media (max-width: 768px) {
  /* Header: stack to single column */
  header {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .header-center { display: none; }
  .header-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Primary button stays prominent, group buttons share row */
  #btn-add-asset {
    flex: 1;
    justify-content: center;
    min-width: 0;
  }
  .btn-group {
    flex: 2;
    display: flex;
    min-width: 0;
  }
  .btn-group .btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
  }
  #btn-settings {
    flex-shrink: 0;
  }

  /* Tabs: scrollable pill row, hide SVG icons to save space */
  nav.tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    scrollbar-width: none;
  }
  nav.tabs::-webkit-scrollbar { display: none; }
  .tab-btn {
    padding: 8px 16px;
    font-size: 0.8rem;
    white-space: nowrap;
  }
  .tab-btn svg { display: none; }

  /* Dashboard: single column everywhere */
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-secondary { grid-template-columns: 1fr; }

  /* Forms collapse to single column */
  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  /* Modal: reduce margin */
  .modal { margin: 12px; }

  /* Filter bar: stack vertically */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search-wrap { min-width: 0; }
  .filter-count { text-align: right; }

  /* Transactions summary: grid 2-col instead of column */
  .tx-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .tx-stat { min-width: 0; width: 100%; }
  .tx-stat-value { font-size: 0.9rem; }

  /* Charts */
  .chart-card { padding: 16px; }
  .chart-container { height: 220px; }
  .chart-container-tall { height: 250px; }

  /* Chart card header with select: stack vertically on mobile */
  .chart-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .chart-card-header select {
    width: 100%;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* Tables: smaller padding */
  .asset-table th,
  .asset-table td { padding: 10px 10px; font-size: 0.8rem; }

  /* Section header: stack */
  .section-header { flex-direction: column; align-items: stretch; }
  .section-header .form-group { min-width: 0; }

  /* Empty states: reduce padding */
  .empty-state-wrap { padding: 50px 20px; }

  /* Settings */
  .setting-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .setting-row select, .setting-row button { align-self: flex-start; }
}

/* ── 600px: compact everything further ── */
@media (max-width: 600px) {
  /* Stat cards: tighter */
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 1.3rem; }
  .stat-label { font-size: 0.65rem; }

  /* Hide all btn labels except Add Asset — icon-only mode */
  .header-actions .btn-label { display: none; }
  .btn-group .btn { padding: 8px 10px; }

  /* Keep Add Asset labelled */
  #btn-add-asset { padding: 8px 14px; }
  #btn-add-asset .btn-label { display: inline; }

  /* Toast: full-width from bottom */
  .toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
    justify-content: flex-start;
  }

  /* Performer items: ensure name doesn't overflow */
  .performer-name { max-width: 140px; }

  /* Allocation: tighter */
  .allocation-name { font-size: 0.8rem; }

  /* Transactions summary: reduce to 2 visible cards */
  .tx-summary { grid-template-columns: 1fr 1fr; }
  .tx-stat { padding: 10px 12px; }
  .tx-stat-label { font-size: 0.65rem; }
  .tx-stat-value { font-size: 0.875rem; }

  /* Settings rows */
  .setting-row select,
  .setting-row input { width: 100%; }

  /* Modal actions: full-width buttons on tiny screens */
  .modal-actions { flex-direction: row; flex-wrap: wrap; }
  .modal-actions .btn { flex: 1; justify-content: center; min-width: 80px; }
}

/* ── 480px: most compact mode ── */
@media (max-width: 480px) {
  .app { padding: 10px 10px 60px; }
  .charts-grid { grid-template-columns: minmax(0, 1fr); }

  /* Logo: compact */
  .logo-icon { width: 30px; height: 30px; border-radius: 8px; }
  .logo-icon svg { width: 16px; height: 16px; }
  .logo-text h1 { font-size: 0.9rem; }
  .logo-text span { font-size: 0.68rem; }

  /* Stats: even tighter */
  .stat-value { font-size: 1.15rem; letter-spacing: -0.03em; }
  .stat-card { padding: 12px 14px; }
  .dashboard-grid { gap: 8px; }

  /* Tabs: smaller pills */
  .tab-btn { padding: 7px 12px; font-size: 0.75rem; }

  /* Modal: edge-to-edge almost */
  .modal { margin: 6px; border-radius: var(--radius-lg); }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 14px 16px; }
  .modal-form { padding: 14px 16px; gap: 12px; }
  .modal-actions { padding: 12px 16px; }

  /* Charts: short height */
  .chart-card { padding: 12px; }
  .chart-container { height: 180px; }
  .chart-container-tall { height: 220px; }

  /* Empty states */
  .empty-state-wrap { padding: 36px 16px; }
  .empty-icon { width: 40px; height: 40px; }

  /* Card padding */
  .card { padding: 14px 16px; }
  .card-title { margin-bottom: 12px; }
  .allocation-list { gap: 10px; }
  .performers-list { gap: 5px; }
  .performer-item { padding: 8px 10px; }
  .performer-name { font-size: 0.8rem; max-width: 120px; }
  .performer-value { font-size: 0.8rem; }

  /* btn-group on header: show icons only */
  .btn-group .btn svg { width: 14px; height: 14px; }
  .btn-icon-only { width: 34px; height: 34px; }
  .btn-icon-only svg { width: 15px; height: 15px; }

  /* Transactions */
  .tx-summary { grid-template-columns: 1fr 1fr; gap: 6px; }

  /* Settings */
  .platforms-wrap { gap: 5px; }
  .platform-tag { font-size: 0.72rem; padding: 3px 8px; }

  /* Filter */
  .search-input { font-size: 0.8rem; }
  .filter-select { font-size: 0.775rem; }
}

/* ── Touch: ensure tap targets are at least 44px ── */
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: 40px; }
  .btn-icon { width: 36px; height: 36px; }
  .tab-btn { min-height: 38px; }
  .form-group input,
  .form-group select,
  .form-group textarea { min-height: 42px; }
  .asset-table td { padding: 12px 10px; }
  .performer-item { padding: 12px 14px; }
  .platform-tag button { min-width: 24px; min-height: 24px; display: flex; align-items: center; justify-content: center; }
}

/* ═══════════════════════════════════════════════════════════
   MICRO ANIMATIONS
═══════════════════════════════════════════════════════════ */
@keyframes flashGreen {
  0%, 100% { background: transparent; }
  50% { background: rgba(45, 212, 164, 0.07); }
}
@keyframes flashRed {
  0%, 100% { background: transparent; }
  50% { background: rgba(240, 96, 96, 0.07); }
}
.price-up   { animation: flashGreen 0.6s ease; }
.price-down { animation: flashRed 0.6s ease; }

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}
