:root {
  --bg: #07110e;
  --surface: #0c1814;
  --surface-2: #11201b;
  --ink: #eff8ed;
  --muted: #85978f;
  --line: rgba(211, 236, 218, 0.13);
  --line-strong: rgba(211, 236, 218, 0.24);
  --lime: #c9ff4a;
  --mint: #42e8b4;
  --coral: #ff6b59;
  --amber: #ffbf48;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
  --radius: 4px;
}

body.light {
  --bg: #edf0e8;
  --surface: #f8faf4;
  --surface-2: #e4e9df;
  --ink: #101b17;
  --muted: #65716b;
  --line: rgba(15, 31, 24, 0.13);
  --line-strong: rgba(15, 31, 24, 0.25);
  --shadow: 0 30px 80px rgba(52, 69, 60, 0.15);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Bahnschrift", "Aptos", sans-serif;
  font-variant-numeric: tabular-nums;
  transition: background .35s ease, color .35s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 74% 14%, rgba(66, 232, 180, .07), transparent 30%),
    linear-gradient(rgba(201, 255, 74, .018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201, 255, 74, .018) 1px, transparent 1px);
  background-size: auto, 46px 46px, 46px 46px;
}

button, input { font: inherit; }
button { color: inherit; }

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .28;
  z-index: 10;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.06'/%3E%3C/svg%3E");
}

.shell { max-width: 1600px; margin: 0 auto; padding: 0 30px; position: relative; }

.topbar {
  min-height: 82px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; letter-spacing: .08em; font-weight: 700; }
.brand small { color: var(--muted); font-size: 9px; letter-spacing: .18em; margin-left: 3px; align-self: flex-end; margin-bottom: 4px; }
.brand-mark { width: 23px; height: 23px; display: flex; align-items: flex-end; gap: 3px; transform: skew(-12deg); }
.brand-mark i { width: 5px; display: block; background: var(--lime); }
.brand-mark i:nth-child(1) { height: 10px; }
.brand-mark i:nth-child(2) { height: 18px; }
.brand-mark i:nth-child(3) { height: 14px; }

.nav-tabs { display: flex; align-self: stretch; }
.nav-tab {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 24px;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: .06em;
}
.nav-tab::after { content: ""; position: absolute; left: 22px; right: 22px; bottom: -1px; height: 2px; background: var(--lime); transform: scaleX(0); transition: transform .25s ease; }
.nav-tab:hover, .nav-tab.active { color: var(--ink); }
.nav-tab.active::after { transform: scaleX(1); }

.top-actions { justify-self: end; display: flex; align-items: center; gap: 14px; }
.market-state { font-size: 10px; letter-spacing: .14em; color: var(--mint); border: 1px solid var(--line); padding: 9px 11px; }
.market-state span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 10px var(--mint); margin-right: 7px; animation: pulse 1.8s infinite; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); background: transparent; display: grid; place-items: center; cursor: pointer; }
.icon-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.ticker-strip { height: 42px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr auto; align-items: center; overflow: hidden; font-size: 11px; }
.ticker-label { color: var(--bg); background: var(--lime); align-self: stretch; display: grid; place-items: center; padding: 0 14px; font-weight: 800; letter-spacing: .08em; }
.ticker-track { display: flex; gap: 30px; padding: 0 24px; overflow: hidden; mask-image: linear-gradient(90deg, transparent, black 4%, black 96%, transparent); }
.ticker { white-space: nowrap; color: var(--muted); }
.ticker b { color: var(--ink); margin-right: 8px; }
.ticker .up { color: var(--mint); }
.ticker .down { color: var(--coral); }
.data-time { color: var(--muted); padding-left: 16px; border-left: 1px solid var(--line); }

main { padding-top: 62px; }
.intro { display: grid; grid-template-columns: 1.2fr .8fr; align-items: end; gap: 60px; margin-bottom: 52px; }
.eyebrow, .kicker { margin: 0 0 15px; color: var(--muted); font-size: 10px; letter-spacing: .2em; font-weight: 700; }
.eyebrow span { color: var(--lime); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: "Bodoni MT", "Times New Roman", serif; font-size: clamp(56px, 7.2vw, 114px); font-weight: 400; line-height: .77; letter-spacing: -.065em; }
h1 em { font-style: italic; color: var(--lime); }
.intro-copy { justify-self: end; max-width: 570px; }
.intro-copy > p { color: var(--muted); font-size: 15px; line-height: 1.85; max-width: 520px; }
.range-control { display: inline-flex; border: 1px solid var(--line); margin-top: 14px; }
.range { min-width: 54px; height: 36px; border: 0; border-right: 1px solid var(--line); background: transparent; cursor: pointer; color: var(--muted); font-size: 11px; }
.range:last-child { border-right: 0; }
.range.active { color: var(--bg); background: var(--lime); font-weight: 800; }
.data-source-note { display: inline-flex; margin-left: 10px; color: var(--muted); font-size: 9px; letter-spacing: .1em; vertical-align: middle; }
.data-source-note.live { color: var(--mint); }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); margin-bottom: 18px; }
.metric { min-height: 135px; padding: 24px; border-right: 1px solid var(--line); position: relative; overflow: hidden; }
.metric:last-child { border-right: 0; }
.metric-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; letter-spacing: .14em; }
.metric-index { opacity: .55; }
.metric-value { font-family: "Bodoni MT", Georgia, serif; font-size: clamp(32px, 3vw, 48px); line-height: 1; margin: 20px 0 8px; letter-spacing: -.035em; }
.metric-meta { font-size: 11px; color: var(--muted); }
.positive { color: var(--mint) !important; }
.negative { color: var(--coral) !important; }
.metric-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--lime); }

.dashboard-grid { display: grid; grid-template-columns: 1.6fr .8fr; gap: 18px; }
.panel { border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: var(--shadow); }
.panel-head { min-height: 84px; padding: 22px 24px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--line); }
.panel-head h2, .section-heading h2 { font-family: "Bodoni MT", Georgia, serif; font-size: 29px; font-weight: 400; margin: 0; letter-spacing: -.025em; }
.panel-head .kicker { margin-bottom: 5px; }
.legend { color: var(--muted); font-size: 10px; display: flex; align-items: center; gap: 7px; }
.legend span { width: 16px; height: 3px; display: inline-block; margin-left: 8px; }
.legend .in { background: var(--mint); }
.legend .out { background: var(--coral); }

.flow-stage { min-height: 426px; position: relative; overflow: hidden; }
.flow-stage svg { width: 100%; height: 426px; display: block; }
.flow-line { fill: none; stroke-linecap: round; opacity: .38; transition: opacity .2s ease, stroke-width .2s ease; }
.flow-line.active { opacity: .9; }
.flow-node { cursor: pointer; }
.flow-node circle { transition: r .2s ease, filter .2s ease; }
.flow-node:hover circle { filter: brightness(1.35); }
.flow-node text { fill: var(--ink); font-family: "Bahnschrift", sans-serif; font-size: 11px; letter-spacing: .03em; }
.flow-node .node-value { fill: var(--muted); font-size: 9px; }
.flow-source-label { fill: var(--muted); font-size: 8px; letter-spacing: .14em; }
.flow-footer { min-height: 46px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; padding: 0 24px; color: var(--muted); font-size: 10px; }
.flow-footer strong { color: var(--ink); font-weight: 500; }

.text-button { border: 0; color: var(--muted); background: transparent; font-size: 10px; cursor: pointer; padding: 6px 0; }
.text-button:hover { color: var(--lime); }
.sector-list { padding: 8px 18px 18px; }
.sector-row { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 14px 6px; border-bottom: 1px solid var(--line); transition: background .2s ease, transform .2s ease; cursor: default; }
.sector-row:last-child { border-bottom: 0; }
.sector-row:hover { background: var(--surface-2); transform: translateX(3px); }
.sector-rank { font-size: 9px; color: var(--muted); }
.sector-name { font-size: 12px; margin-bottom: 7px; display: flex; justify-content: space-between; }
.sector-bar { height: 3px; background: var(--line); position: relative; overflow: hidden; }
.sector-bar i { position: absolute; height: 100%; left: 0; background: var(--mint); }
.sector-row.out .sector-bar i { background: var(--coral); }
.sector-flow { text-align: right; font-size: 12px; min-width: 68px; }
.sector-change { display: block; color: var(--muted); font-size: 9px; margin-top: 5px; }

.trend-panel { grid-column: 1 / -1; }
.trend-value { font-family: "Bodoni MT", Georgia, serif; font-size: 24px; color: var(--mint); }
.trend-value span { font-family: "Bahnschrift", sans-serif; color: var(--muted); font-size: 9px; letter-spacing: .13em; margin-right: 8px; }
.chart-wrap { height: 260px; position: relative; overflow: hidden; }
.chart-wrap svg { display: block; width: 100%; height: 100%; }
.grid-line { stroke: var(--line); stroke-width: 1; }
.axis-label { fill: var(--muted); font-size: 9px; font-family: "Bahnschrift", sans-serif; }
.trend-line { fill: none; stroke: var(--lime); stroke-width: 2.4; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 6px rgba(201,255,74,.25)); }
.trend-area { fill: url(#areaGradient); }
.trend-point { fill: var(--bg); stroke: var(--lime); stroke-width: 2; }
.chart-tooltip { position: absolute; pointer-events: none; padding: 9px 11px; background: var(--ink); color: var(--bg); font-size: 10px; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .12s ease; white-space: nowrap; }

.stock-section { margin: 86px 0 60px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 24px; }
.section-heading h2 { font-size: 42px; }
.stock-tools { display: flex; align-items: center; gap: 8px; }
.search-box { height: 38px; border: 1px solid var(--line); display: flex; align-items: center; padding: 0 11px; width: 240px; }
.search-box svg { width: 15px; fill: none; stroke: var(--muted); stroke-width: 1.5; margin-right: 8px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.search-box input::placeholder { color: var(--muted); }
.filter-button { height: 38px; padding: 0 14px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.filter-button.active { border-color: var(--lime); color: var(--lime); }
.stock-table-wrap { border: 1px solid var(--line); overflow-x: auto; background: color-mix(in srgb, var(--surface) 82%, transparent); }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th { height: 45px; text-align: left; font-size: 9px; color: var(--muted); letter-spacing: .13em; font-weight: 500; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { padding-left: 22px; }
th:last-child, td:last-child { padding-right: 22px; }
td { height: 70px; border-bottom: 1px solid var(--line); font-size: 12px; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .2s ease; }
tbody tr:hover { background: var(--surface-2); }
.stock-name { display: flex; align-items: center; gap: 12px; }
.stock-logo { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line-strong); font-size: 9px; font-weight: 800; color: var(--lime); }
.stock-name strong { display: block; font-size: 13px; margin-bottom: 4px; }
.stock-name small { color: var(--muted); font-size: 9px; }
.flow-pill { display: inline-block; min-width: 78px; padding: 7px 9px; background: rgba(66,232,180,.08); color: var(--mint); }
.flow-pill.out { background: rgba(255,107,89,.08); color: var(--coral); }
.strength { width: 92px; display: flex; gap: 3px; }
.strength i { height: 5px; flex: 1; background: var(--line); }
.strength i.on { background: var(--amber); }
.spark { width: 110px; height: 30px; }
.spark polyline { fill: none; stroke: var(--mint); stroke-width: 1.5; }
.spark.out polyline { stroke: var(--coral); }
.row-action { width: 29px; height: 29px; border: 1px solid var(--line); background: transparent; cursor: pointer; color: var(--muted); }
.row-action:hover { color: var(--lime); border-color: var(--lime); }
.empty-state { padding: 50px; color: var(--muted); text-align: center; }

footer { min-height: 84px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.brand-mini { color: var(--lime); font-weight: 800; margin-right: 8px; }
.footer-dot { display: inline-block; width: 4px; height: 4px; background: var(--lime); border-radius: 50%; margin: 0 8px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; background: var(--lime); color: #07110e; padding: 12px 16px; font-size: 11px; font-weight: 700; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

.reveal { opacity: 0; transform: translateY(18px); animation: reveal .7s cubic-bezier(.2,.8,.2,1) forwards; }
.delay-1 { animation-delay: .1s; }
.delay-2 { animation-delay: .2s; }
.delay-3 { animation-delay: .3s; }

@keyframes reveal { to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 50% { opacity: .35; box-shadow: 0 0 2px var(--mint); } }

@media (max-width: 1020px) {
  .topbar { grid-template-columns: 1fr auto; }
  .nav-tabs { grid-row: 2; grid-column: 1 / -1; order: 3; height: 48px; border-top: 1px solid var(--line); }
  .topbar { padding-top: 18px; }
  .intro { grid-template-columns: 1fr; gap: 35px; }
  .intro-copy { justify-self: start; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .trend-panel { grid-column: auto; }
}

@media (max-width: 680px) {
  .shell { padding: 0 15px; }
  .topbar { min-height: 70px; }
  .brand small, .market-state { display: none; }
  .nav-tabs { overflow-x: auto; }
  .nav-tab { flex: 1; min-width: 110px; padding: 0 10px; }
  .ticker-strip { grid-template-columns: auto 1fr; }
  .data-time { display: none; }
  .ticker-track { padding: 0 14px; gap: 20px; }
  main { padding-top: 42px; }
  h1 { font-size: clamp(54px, 18vw, 78px); line-height: .84; }
  .intro { margin-bottom: 38px; gap: 28px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { padding: 17px; min-height: 120px; }
  .metric-value { font-size: 29px; }
  .panel-head { padding: 18px; min-height: 76px; }
  .panel-head h2 { font-size: 25px; }
  .legend { display: none; }
  .flow-stage, .flow-stage svg { min-height: 360px; height: 360px; }
  .flow-footer span { display: none; }
  .flow-footer { justify-content: flex-end; }
  .section-heading { align-items: start; flex-direction: column; gap: 22px; }
  .section-heading h2 { font-size: 36px; }
  .stock-tools { width: 100%; flex-wrap: wrap; }
  .search-box { width: 100%; }
  .stock-section { margin-top: 58px; }
  footer { gap: 20px; }
  footer > div:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
