:root {
  --bg: #0b0f19;
  --bg-elev: #151b2b;
  --bg-elev-2: #1c2236;
  --text: #e7ecf5;
  --muted: #8b93a7;
  --accent: #7c9cff;
  --green: #3ddc97;
  --red: #ff6b8a;
  --border: #242b41;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bot: env(safe-area-inset-bottom, 0);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bot));
}

h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 15px; color: var(--muted); letter-spacing: 0.02em; text-transform: uppercase; }

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.app-header .sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.spinning { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hero {
  text-align: left;
  padding: 8px 4px 20px;
}
.hero-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.hero-value {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.hero-change { font-size: 15px; margin-top: 6px; font-variant-numeric: tabular-nums; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 17px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-pct { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.range-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.range-tabs button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
}
.range-tabs button.active {
  background: var(--bg-elev-2);
  color: var(--text);
}

.chart-wrap {
  position: relative;
  height: 200px;
}

.holdings { list-style: none; padding: 0; margin: 0; }
.holding {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.holding:last-child { border-bottom: none; }
.holding-sym { font-weight: 600; font-size: 15px; }
.holding-name { font-size: 12px; color: var(--muted); grid-column: 1 / 2; }
.holding-value { font-weight: 600; font-size: 15px; text-align: right; font-variant-numeric: tabular-nums; }
.holding-pl { font-size: 12px; text-align: right; grid-column: 2; font-variant-numeric: tabular-nums; }
.holding-meta { font-size: 11px; color: var(--muted); grid-column: 1 / 2; margin-top: 2px; }

.cash-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
}
.mono { font-variant-numeric: tabular-nums; font-weight: 600; }

.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 11px; }

.foot {
  margin-top: 24px;
  text-align: center;
}

.loading { opacity: 0.5; }
.error {
  background: rgba(255, 107, 138, 0.1);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 12px;
  border-radius: 12px;
  font-size: 13px;
}
