:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-muted: #f8fafc;
  --text: #162033;
  --muted: #667085;
  --line: #dde4ef;
  --blue: #2357d9;
  --cyan: #17a2b8;
  --green: #1f9d55;
  --red: #d64545;
  --amber: #d28a16;
  --shadow: 0 12px 32px rgba(20, 38, 72, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(35, 87, 217, 0.08), rgba(245, 247, 251, 0) 360px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  font-size: 21px;
  box-shadow: var(--shadow);
}

.brand-name {
  font-size: 14px;
}

h1 {
  margin: 10px 0 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.group-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
}

select {
  min-width: 210px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #b8c4d6;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}

.nav-link.active {
  color: var(--blue);
  background: #ffffff;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric,
.panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(221, 228, 239, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 118px;
  padding: 18px;
}

.metric-label,
.metric-note,
.eyebrow,
.generated-at {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 28px;
  line-height: 1;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 14px;
  align-items: start;
}

.side-stack {
  display: grid;
  gap: 14px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

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

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

.view-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.checkbox-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.checkbox-control input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--blue);
}

.checkbox-control:has(input:checked) {
  color: var(--blue);
  border-color: #b9c8f6;
  background: #eef4ff;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: #fbfcfe;
}

.table-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 28px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
}

.table-sort::after {
  min-width: 12px;
  color: var(--blue);
  font-size: 11px;
}

.table-sort.active {
  color: var(--blue);
}

.table-sort.active[data-dir="desc"]::after {
  content: "↓";
}

.table-sort.active[data-dir="asc"]::after {
  content: "↑";
}

.header-filter {
  display: grid;
  gap: 5px;
}

.header-filter select {
  min-width: 0;
  width: 92px;
  height: 26px;
  padding: 0 22px 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background-color: #ffffff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

td strong {
  display: block;
  font-size: 14px;
}

.muted {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 24px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
}

.pill.active {
  color: #0b4a7d;
  background: #e8f3ff;
}

.pill.paused {
  color: #7a4b00;
  background: #fff1d6;
}

.hidden-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  margin-left: 6px;
  padding: 0 7px;
  border: 1px solid #d8e0ec;
  border-radius: 7px;
  color: var(--muted);
  background: #f2f5fa;
  font-size: 11px;
  font-weight: 800;
  vertical-align: middle;
  white-space: nowrap;
}

tr.is-hidden {
  background: #f8fafc;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 320px;
  color: var(--muted);
  font-size: 13px;
}

.chart-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.up {
  color: var(--red);
}

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

.flat {
  color: var(--muted);
}

.spotlight-chart {
  padding: 16px 18px 10px;
}

.chart-row {
  display: grid;
  grid-template-columns: 72px 1fr 58px;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  font-size: 12px;
}

.chart-bar-track {
  height: 12px;
  border-radius: 6px;
  background: #e8edf5;
  overflow: hidden;
}

.chart-bar {
  height: 100%;
  min-width: 2px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
}

.best-worst {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 18px 18px;
}

.best-worst div {
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-muted);
}

.best-worst span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.best-worst strong {
  font-size: 13px;
}

.recommender-list,
.activity-list {
  padding: 8px 18px 18px;
}

.recommender-row {
  display: grid;
  grid-template-columns: minmax(78px, 1fr) 58px 72px 82px;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
}

.recommender-head {
  min-height: 30px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.recommender-row:last-child,
.activity-item:last-child {
  border-bottom: 0;
}

.activity-panel {
  margin-top: 14px;
}

.activity-item {
  display: grid;
  grid-template-columns: 138px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.empty {
  padding: 24px;
  color: var(--muted);
}

.watchlist-shell {
  width: min(1760px, calc(100% - 40px));
}

.watchlist-main {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.watchlist-list-panel {
  min-height: calc(100vh - 116px);
}

.watchlist-view-filters {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  overflow-x: auto;
}

.watch-view {
  width: auto;
  height: 30px;
  flex: 0 0 auto;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-muted);
  font-size: 12px;
  font-weight: 800;
}

.watch-view.active {
  color: var(--blue);
  border-color: #b9c9ee;
  background: #eef4ff;
}

.watch-member-filter {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.watch-member-filter select {
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.watchlist-list-head {
  display: grid;
  grid-template-columns: 68px minmax(80px, 1fr) 62px 74px 42px;
  gap: 3px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.watch-sort {
  height: 30px;
  border: 0;
  padding: 0 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.watch-sort.active {
  color: #ffffff;
  background: #df493d;
}

.watchlist-rows {
  max-height: calc(100vh - 215px);
  overflow: auto;
  padding: 6px 0;
}

.watch-row {
  display: grid;
  grid-template-columns: 68px minmax(80px, 1fr) 62px 74px 42px;
  gap: 3px;
  align-items: center;
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 0;
  padding: 0 10px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
}

.watch-row:hover,
.watch-row.active {
  background: #eef3f4;
}

.watch-row strong,
.watch-code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watch-code {
  color: #2f3b4c;
  font-weight: 800;
}

.watch-row span:nth-child(3),
.watch-row span:nth-child(4) {
  text-align: right;
}

.watch-volume {
  color: var(--muted);
  text-align: right;
}

.quote-panel {
  min-height: calc(100vh - 116px);
}

.quote-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.quote-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.quote-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(88px, 1fr));
  gap: 10px;
  min-width: min(580px, 100%);
}

.quote-metrics div {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-muted);
}

.quote-metrics span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.quote-metrics strong {
  font-size: 18px;
}

.quote-tabs {
  display: flex;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.quote-tab {
  width: 92px;
  height: 42px;
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
  color: var(--text);
  background: #ffffff;
  font-weight: 800;
}

.quote-tab:first-child {
  border-left: 1px solid var(--line);
}

.quote-tab.active {
  color: #ffffff;
  background: #3087bd;
}

.signal-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.signal-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.signal-toggles {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.signal-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  height: 32px;
  flex: 0 0 auto;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--muted);
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.signal-chip strong {
  color: var(--text);
}

.signal-chip.active {
  color: var(--blue);
  border-color: #b9c9ee;
  background: #eef4ff;
}

.signal-chip.active strong {
  color: var(--blue);
}

.signal-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.quote-chart-wrap {
  padding: 14px 18px 12px;
}

#quoteChart {
  width: 100%;
  height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.quote-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 14px;
  padding: 0 18px 18px;
  align-items: stretch;
}

.quote-detail-section {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  max-height: min(360px, 42vh);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  color: var(--muted);
  background: #fbfcfe;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

.section-action {
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--muted);
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.section-action.active {
  color: var(--blue);
  border-color: #c9d7f2;
  background: #eef4ff;
}

.position-rows,
.event-rows {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.position-row {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) 76px 72px 72px 78px 84px;
  gap: 10px;
  align-items: center;
  min-width: 580px;
  min-height: 42px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.position-row-button {
  width: 100%;
  height: auto;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.position-row-button:hover,
.position-row-button.selected {
  background: #eef3ff;
}

.position-row-button.selected {
  box-shadow: inset 3px 0 0 var(--blue);
}

.position-head {
  min-height: 34px;
  color: var(--muted);
  background: #fbfcfe;
  font-size: 11px;
  font-weight: 800;
}

.position-row:last-child,
.event-row:last-child {
  border-bottom: 0;
}

.event-row {
  display: grid;
  grid-template-columns: 96px 88px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  min-height: 38px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.event-action {
  display: inline-flex;
  min-width: 0;
  align-items: baseline;
  gap: 8px;
}

.event-meta {
  min-width: 0;
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 1080px) {
  .summary-grid,
  .main-grid {
    grid-template-columns: 1fr 1fr;
  }

  .leaderboard-panel,
  .activity-panel {
    grid-column: 1 / -1;
  }

  .watchlist-main,
  .quote-detail-grid {
    grid-template-columns: 1fr;
  }

  .watchlist-list-panel,
  .quote-panel {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 24px, 1440px);
    padding-top: 18px;
  }

  .topbar,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .group-picker,
  select,
  button,
  .nav-link {
    width: 100%;
  }

  .chart-meta {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .activity-item {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .watchlist-shell {
    width: min(100% - 24px, 1760px);
  }

  .watchlist-list-head {
    display: none;
  }

  .watch-row {
    grid-template-columns: 72px 1fr 74px;
    height: auto;
    min-height: 58px;
    row-gap: 4px;
  }

  .watch-row span:nth-child(4),
  .watch-row span:nth-child(5),
  .watch-volume {
    grid-column: span 1;
  }

  .quote-head,
  .quote-metrics,
  .position-row,
  .event-row {
    grid-template-columns: 1fr;
  }

  .quote-tabs {
    overflow: auto;
  }
}
