:root {
  color-scheme: dark;
  --bg: #05070d;
  --bg-deep: #02030a;
  --panel: rgba(11, 18, 32, 0.78);
  --panel-strong: rgba(16, 26, 46, 0.92);
  --line: rgba(116, 240, 255, 0.18);
  --line-strong: rgba(116, 240, 255, 0.4);
  --text: #eef9ff;
  --muted: #8ea1b6;
  --soft: #c7d5e5;
  --cyan: #3ee8ff;
  --green: #39ff9d;
  --magenta: #da5cff;
  --danger: #ff5f7e;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
  --glow: 0 0 28px rgba(62, 232, 255, 0.26);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at 18% 16%, rgba(62, 232, 255, 0.13), transparent 28rem),
    radial-gradient(circle at 86% 2%, rgba(218, 92, 255, 0.1), transparent 25rem),
    linear-gradient(135deg, var(--bg-deep), #08111f 46%, #03040a);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background-image:
    linear-gradient(rgba(116, 240, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(116, 240, 255, 0.045) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 82%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 36px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(4, 8, 16, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(62, 232, 255, 0.65);
  border-radius: var(--radius);
  color: var(--bg-deep);
  font-weight: 900;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: var(--glow);
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 850;
}

.search {
  position: relative;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 16px;
  color: var(--cyan);
  transform: translateY(-50%);
}

.search input {
  width: 100%;
  height: 48px;
  padding: 0 18px 0 44px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: rgba(255, 255, 255, 0.045);
}

.search input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(62, 232, 255, 0.1);
}

.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  display: none;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(8, 14, 27, 0.98);
  box-shadow: var(--shadow);
}

.suggestions.is-open {
  display: block;
}

.suggestion {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 13px 16px;
  color: var(--text);
  text-align: left;
  border: 0;
  border-bottom: 1px solid rgba(116, 240, 255, 0.1);
  background: transparent;
}

.suggestion:hover,
.suggestion:focus {
  color: var(--bg-deep);
  background: linear-gradient(135deg, var(--cyan), var(--green));
}

.portfolio-link,
.primary-action,
.ghost-action,
.range-button,
.icon-button {
  min-height: 42px;
  border-radius: var(--radius);
}

.portfolio-link {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: rgba(62, 232, 255, 0.08);
}

.portfolio-link strong {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: var(--bg-deep);
  border-radius: 999px;
  background: var(--green);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.62fr);
  gap: 18px;
  margin-top: 18px;
}

.panel,
.hero-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.stock-hero {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  padding: 22px;
  background:
    linear-gradient(120deg, rgba(62, 232, 255, 0.14), transparent 38%),
    linear-gradient(270deg, rgba(57, 255, 157, 0.13), transparent 34%),
    var(--panel-strong);
}

.stock-copy {
  display: flex;
  gap: 18px;
  align-items: center;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 4.7rem);
  line-height: 0.92;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  line-height: 1.1;
}

.ticker-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 0;
  padding: 0 11px;
  color: var(--green);
  border: 1px solid rgba(57, 255, 157, 0.42);
  border-radius: 999px;
  background: rgba(57, 255, 157, 0.08);
}

.price-stack {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.price {
  font-size: clamp(2rem, 4.6vw, 4.8rem);
  font-weight: 900;
  line-height: 0.9;
}

.change {
  font-weight: 850;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--danger);
}

.primary-action {
  padding: 0 18px;
  color: #001116;
  font-weight: 900;
  border: 0;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: var(--glow);
}

.primary-action.is-added {
  color: var(--green);
  border: 1px solid rgba(57, 255, 157, 0.55);
  background: rgba(57, 255, 157, 0.08);
}

.chart-panel {
  min-width: 0;
  padding: 20px;
}

.metrics-panel,
.watchlist-panel {
  padding: 18px;
}

.news-panel {
  grid-column: 1 / 2;
  padding: 20px;
}

.watchlist-panel {
  grid-column: 2 / 3;
}

.panel-header {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-header.compact {
  margin-bottom: 14px;
}

.range-selector {
  display: grid;
  grid-template-columns: repeat(4, minmax(46px, 1fr));
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.range-button {
  min-width: 46px;
  color: var(--muted);
  font-weight: 850;
  border: 0;
  background: transparent;
}

.range-button.is-active {
  color: var(--bg-deep);
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(62, 232, 255, 0.35);
}

.chart-stage {
  position: relative;
  min-height: 390px;
  overflow: hidden;
  border: 1px solid rgba(116, 240, 255, 0.14);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(116, 240, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(116, 240, 255, 0.055) 1px, transparent 1px),
    radial-gradient(circle at 55% 30%, rgba(62, 232, 255, 0.1), transparent 23rem),
    rgba(2, 6, 15, 0.78);
  background-size: 44px 44px, 44px 44px, auto, auto;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 390px;
}

.chart-readout {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  gap: 5px;
  min-width: 118px;
  padding: 12px;
  border: 1px solid rgba(57, 255, 157, 0.35);
  border-radius: var(--radius);
  background: rgba(5, 12, 22, 0.82);
}

.chart-readout span {
  color: var(--muted);
  font-size: 0.78rem;
}

.chart-readout strong {
  color: var(--green);
  font-size: 1.25rem;
}

.metrics-grid {
  display: grid;
  gap: 10px;
}

.metric-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  min-height: 70px;
  padding: 13px;
  border: 1px solid rgba(116, 240, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.metric-card span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.metric-card strong {
  font-size: 1.18rem;
}

.metric-card small {
  color: var(--green);
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.news-card {
  overflow: hidden;
  border: 1px solid rgba(116, 240, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.news-thumb {
  height: 116px;
  background:
    linear-gradient(135deg, rgba(62, 232, 255, 0.24), rgba(57, 255, 157, 0.1)),
    var(--thumb-pattern);
  background-size: cover;
  border-bottom: 1px solid rgba(116, 240, 255, 0.14);
}

.news-body {
  padding: 13px;
}

.news-body h3 {
  margin: 0 0 10px;
  font-size: 0.98rem;
  line-height: 1.2;
}

.news-body p {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.news-meta {
  display: flex;
  justify-content: space-between;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ghost-action {
  padding: 0 14px;
  color: var(--cyan);
  border: 1px solid var(--line-strong);
  background: rgba(62, 232, 255, 0.06);
}

.watchlist {
  display: grid;
  gap: 10px;
}

.watch-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(116, 240, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.watch-symbol {
  color: var(--cyan);
  font-weight: 900;
}

.watch-name {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watch-price {
  display: grid;
  justify-items: end;
  gap: 2px;
  font-weight: 850;
}

.portfolio-modal {
  width: min(520px, calc(100% - 28px));
  padding: 0;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(62, 232, 255, 0.12), transparent 45%),
    rgba(6, 12, 23, 0.98);
  box-shadow: var(--shadow);
}

.portfolio-modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

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

.icon-button {
  width: 42px;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.portfolio-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.portfolio-item,
.empty-state {
  padding: 14px;
  border: 1px solid rgba(116, 240, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.portfolio-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.remove-button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--danger);
  border: 1px solid rgba(255, 95, 126, 0.36);
  border-radius: var(--radius);
  background: rgba(255, 95, 126, 0.08);
}

@media (max-width: 1100px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .metrics-panel,
  .watchlist-panel,
  .news-panel {
    grid-column: 1;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 10px;
  }

  .topbar {
    position: static;
    grid-template-columns: 1fr;
  }

  .portfolio-link {
    width: 100%;
  }

  .stock-hero {
    grid-template-columns: 1fr;
  }

  .stock-copy {
    display: grid;
  }

  .price-stack {
    justify-items: start;
  }

  .primary-action {
    width: 100%;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .news-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .chart-stage,
  canvas {
    min-height: 320px;
  }
}

@media (max-width: 460px) {
  .range-selector {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .watch-row {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .watch-price {
    grid-column: 1 / -1;
    justify-items: start;
  }
}
