* { box-sizing: border-box; }

/* Design tokens — accent reuses the existing validated dataviz blue
   (#2a78d6, already used for the portfolio-value line chart) rather than
   introducing a new hue, so charts and UI stay consistent. Piloted first
   on the Portfolio page alone, now the site-wide default. */
:root {
  --ink: #1f2a44;
  --accent: #2a78d6;
  --accent-glow: rgba(42, 120, 214, 0.20);
  --positive: #1baf7a;
  --positive-glow: rgba(27, 175, 122, 0.22);
  --negative: #e34948;
  --negative-glow: rgba(227, 73, 72, 0.20);
  --gold: #c8912b;
  --gold-glow: rgba(200, 145, 43, 0.24);
  --silver: #8a94a6;
  --silver-glow: rgba(138, 148, 166, 0.22);
  --bronze: #b0703f;
  --bronze-glow: rgba(176, 112, 63, 0.22);
  --radius: 16px;
}

body {
  font-family: 'Public Sans', -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
  /* A soft cool-to-warm drift instead of a flat gray — the base "canvas"
     every card sits on. Cards themselves stay near-white so text contrast
     and readability are unaffected; only the page background changes. */
  background: linear-gradient(180deg, #eef2fb 0%, #f6f7fb 55%, #f1f0e9 100%);
  background-attachment: fixed;
  color: #1a1a1a;
}
.navbar {
  background: var(--ink);
  color: white;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 3px solid var(--accent);
}
.navbar .brand {
  color: white;
  font-weight: 700;
  text-decoration: none;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.brand-mark { flex-shrink: 0; display: block; }
.nav-links a {
  color: #cfd6e4;
  text-decoration: none;
  margin-left: 16px;
  font-size: 0.9rem;
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
}
.nav-links a:hover { color: white; }
/* Current page marker. Uses a underline rather than a background so it reads
   as "you are here" without competing with the accent border under the bar. */
.nav-links a.active {
  color: white;
  font-weight: 600;
  border-bottom-color: var(--accent);
}
.nav-user {
  margin-left: 16px;
  color: #8fa0c4;
  font-size: 0.9rem;
  text-decoration: none;
}
.nav-user:hover { color: white; }
/* Hidden on desktop; the media query below turns it on for narrow screens,
   where eight links would otherwise wrap into an unreadable block. */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid #4a5878;
  color: white;
  font-size: 1.1rem;
  line-height: 1;
  padding: 5px 11px;
  border-radius: 7px;
  cursor: pointer;
  box-shadow: none;
}
.nav-toggle:hover { background: rgba(255, 255, 255, 0.09); }

/* Inline row trend line (views/partials/sparkline.ejs). */
.sparkline { display: block; overflow: visible; }

/* Empty states. A dead-end "nothing here" leaves a new student stuck; these
   are styled to hold a next step, so every one of them points somewhere. */
.empty-state {
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed #c9d0de;
  border-radius: var(--radius);
  padding: 22px 24px;
  text-align: center;
}
.empty-state p { margin: 6px 0; }
.empty-state p:first-child { font-size: 1.02rem; }
.container {
  /* Wide enough that the app's widest tables (10+ columns, e.g. the
     watchlist and holdings tables) fit without horizontal scrolling on a
     typical laptop screen (1366-1920px wide), while still leaving margin
     on very large monitors instead of stretching edge to edge. */
  max-width: 1400px;
  width: 94%;
  margin: 24px auto;
  padding: 0 16px;
}
h1 {
  font-size: 1.5rem;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 1.2rem;
  color: var(--ink);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
h2::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
/* Wrap every <table> in <div class="table-scroll"> rather than putting
   overflow directly on the table element — `table { display: block }`
   looks harmless but silently breaks the browser's column-width
   distribution (confirmed by testing: it left the real Leaderboard table
   only filling ~1/3 of its own box, the rest dead space). The wrapper
   gets the scroll behavior instead, so `table` can stay `display: table`
   and actually fill its container's width the normal way. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 10px 26px -10px rgba(31, 42, 68, 0.16);
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.9rem;
}
th {
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
}
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: rgba(42, 120, 214, 0.06); }
.card {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid rgba(31, 42, 68, 0.06);
  box-shadow: 0 14px 34px -12px var(--accent-glow);
  margin-bottom: 20px;
}
/* Live tick flash (views/partials/live-refresh.ejs). Brief and low-contrast:
   enough to catch the eye when a number moves, not enough to be distracting
   on a page where several values update at once. */
@keyframes live-tick-up-anim {
  0%   { background-color: rgba(31, 157, 85, 0.28); }
  100% { background-color: transparent; }
}
@keyframes live-tick-down-anim {
  0%   { background-color: rgba(214, 69, 69, 0.28); }
  100% { background-color: transparent; }
}
.live-tick-up { animation: live-tick-up-anim 1.1s ease-out; border-radius: 3px; }
.live-tick-down { animation: live-tick-down-anim 1.1s ease-out; border-radius: 3px; }
@media (prefers-reduced-motion: reduce) {
  .live-tick-up, .live-tick-down { animation: none; }
}

/* Glossary hint marker (views/partials/info.ejs). Deliberately quiet — it
   should be findable when a student wants it and invisible when they don't. */
.info-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  border-radius: 50%;
  background: #d8dce4;
  color: #4a5568;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  user-select: none;
}
.info-dot:hover { background: #2a78d6; color: #fff; }
.info-dot:focus-visible { outline: 2px solid #2a78d6; outline-offset: 1px; }

.chart-card { position: relative; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.78rem; color: #666; margin-bottom: 6px; }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.chart-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  background: #23231f;
  color: #f5f4ef;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  z-index: 20;
}
.form-group { margin-bottom: 14px; }
label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 0.9rem; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccd2dd;
  border-radius: 8px;
  font-size: 0.95rem;
}
button, .btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  display: inline-block;
  box-shadow: 0 8px 18px -4px var(--accent-glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
button:hover, .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px -4px var(--accent-glow);
}
.btn-danger {
  background: var(--negative);
  box-shadow: 0 8px 18px -4px var(--negative-glow);
}
.btn-danger:hover { box-shadow: 0 12px 22px -4px var(--negative-glow); }

/* Inactive tab in a range/segment selector (e.g. the research page's
   1D/5D/1M/.../Max price history tabs) — same pill shape, muted so the
   selected one stands out clearly against it. */
.btn-range-inactive {
  background: white;
  color: var(--ink);
  border: 1px solid rgba(31, 42, 68, 0.12);
  box-shadow: none;
}
.btn-range-inactive:hover {
  background: rgba(42, 120, 214, 0.08);
  box-shadow: none;
  transform: none;
}
.error {
  background: #fdecea;
  color: #a33;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.success {
  background: #eaf7ee;
  color: #2a7a3f;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.readonly-price {
  background: #f0f2f5;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
}
.pl-positive { color: #2a7a3f; font-weight: 600; }
.pl-negative { color: #a33; font-weight: 600; }
.summary-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.summary-box {
  background: white;
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid rgba(31, 42, 68, 0.06);
  border-top: 3px solid var(--accent);
  box-shadow: 0 10px 26px -8px var(--accent-glow);
  flex: 1;
  min-width: 160px;
  transition: transform 0.18s ease;
}
.summary-box:has(.pl-positive) {
  border-top-color: var(--positive);
  box-shadow: 0 10px 26px -8px var(--positive-glow);
}
.summary-box:has(.pl-negative) {
  border-top-color: var(--negative);
  box-shadow: 0 10px 26px -8px var(--negative-glow);
}
.summary-box:hover { transform: translateY(-3px); }
.summary-box .label {
  font-size: 0.7rem;
  color: #8b8fa3;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.summary-box .value { font-size: 1.3rem; font-weight: 800; }

/* Small colored pill — used for rank-change arrows, "last active" status,
   price-source tags, etc. across several pages. */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge-positive { background: var(--positive-glow); color: #0e7a52; }
.badge-negative { background: var(--negative-glow); color: #a33; }
.badge-neutral { background: rgba(31, 42, 68, 0.08); color: #666; }

/* Leaderboard podium (top 3) */
.podium {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.podium-card {
  flex: 1;
  min-width: 180px;
  background: white;
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  border-top: 4px solid var(--accent);
  box-shadow: 0 12px 28px -10px var(--accent-glow);
}
.podium-card.rank-1 { border-top-color: var(--gold); box-shadow: 0 12px 28px -10px var(--gold-glow); order: 2; }
.podium-card.rank-2 { border-top-color: var(--silver); box-shadow: 0 12px 28px -10px var(--silver-glow); order: 1; }
.podium-card.rank-3 { border-top-color: var(--bronze); box-shadow: 0 12px 28px -10px var(--bronze-glow); order: 3; }
.podium-card .rank-medal { font-size: 1.6rem; }
.podium-card .rank-name { font-weight: 800; color: var(--ink); margin: 4px 0; }
.podium-card .rank-value { font-size: 1.1rem; font-weight: 700; }

/* Market-movers style ranked list (Dashboard, cohort stats, etc.) */
.mover-list { list-style: none; padding: 0; margin: 0; }
.mover-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid #eef0f4;
  font-size: 0.85rem;
}
.mover-list li:last-child { border-bottom: none; }
.mover-ticker { flex: 1.1; font-weight: 700; color: var(--ink); }
.mover-price { flex: 1; text-align: right; color: #666; }
.mover-change { flex: 1.5; text-align: right; font-weight: 600; }

/* Dashboard: Watchlist as the large primary column, Indices + Movers as a
   narrower sidebar — Watchlist is the personalized, actionable content and
   was previously buried below a full-width Indices/Movers stack. */
.dashboard-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.dashboard-main { flex: 2.2; min-width: 0; }
.dashboard-side { flex: 1; min-width: 280px; max-width: 360px; }
.dashboard-side .summary-row { flex-direction: column; }
@media (max-width: 600px) {
  .dashboard-layout { flex-direction: column; }
  .dashboard-side { max-width: none; }
}

/* Donut charts (flat, not 3D — see docs/CODE_GUIDE.md for why) */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  animation: donutIn 0.6s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
@keyframes donutIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
.donut { filter: drop-shadow(0 10px 18px var(--accent-glow)); flex-shrink: 0; }
.donut-slice { transition: opacity 0.15s ease; }
.donut-slice:hover { opacity: 0.8; }
.donut-total-label {
  font-size: 9px;
  fill: #8b8fa3;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.donut-total-value { font-size: 15px; fill: var(--ink); font-weight: 800; }
.legend { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; }
.legend li { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }

.auth-layout {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
  align-items: center;
  min-height: 55vh;
}
.auth-hero { flex: 1.1; min-width: 280px; }
.auth-hero h1 {
  font-size: 2.1rem;
  color: var(--ink);
  margin-bottom: 12px;
}
.auth-hero p {
  font-size: 1rem;
  color: #52514e;
  line-height: 1.6;
  max-width: 480px;
}
.auth-hero-points {
  list-style: none;
  padding: 0;
  margin-top: 20px;
}
.auth-hero-points li {
  padding-left: 26px;
  position: relative;
  margin-bottom: 10px;
  color: #33333a;
  font-size: 0.92rem;
}
.auth-hero-points li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--positive);
  font-weight: 700;
}
.auth-form-side { flex: 1; min-width: 280px; max-width: 420px; }
.auth-form-side .card { margin-bottom: 0; }

/* Mobile pass — phones and small tablets */
@media (max-width: 600px) {
  .container { padding: 0 10px; margin: 14px auto; }
  h1 { font-size: 1.25rem; }
  h2 { font-size: 1.05rem; }
  .navbar { padding: 10px 14px; }
  /* Collapse the eight nav links behind a toggle. Without this they wrap
     into several dense rows that push the actual page content off screen. */
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    margin-top: 10px;
    border-top: 1px solid #3a4763;
    padding-top: 8px;
  }
  .nav-links.open { display: flex; }
  .nav-links a {
    margin-left: 0;
    font-size: 0.92rem;
    padding: 9px 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .nav-links a.active { border-bottom-color: var(--accent); }
  .nav-user { margin-left: 0; font-size: 0.92rem; }
  th, td { padding: 8px 10px; font-size: 0.82rem; }
  .summary-box { min-width: 130px; padding: 12px 14px; }
  .summary-box .value { font-size: 1.1rem; }
  .summary-box:hover { transform: none; }
  .card { padding: 14px; }
  button, .btn { padding: 9px 14px; font-size: 0.88rem; }
  .auth-hero h1 { font-size: 1.5rem; }
  .auth-layout { min-height: 0; gap: 24px; }
  .podium-card.rank-1, .podium-card.rank-2, .podium-card.rank-3 { order: initial; }
}
