:root {
  color-scheme: light;
  --canvas: #f2f4f7;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #121820;
  --muted: #667080;
  --line: #d8dee6;
  --line-strong: #b8c1cc;
  --green: #087b57;
  --green-soft: #e4f3ed;
  --red: #ba3b4a;
  --red-soft: #f9e8eb;
  --amber: #b47a12;
  --blue: #275f87;
  --shadow: 0 12px 32px rgba(18, 24, 32, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(39, 95, 135, 0.3);
  outline-offset: 2px;
}

.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;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand > span:last-child,
.market-status > span:last-child {
  display: grid;
  gap: 2px;
}

.brand strong {
  font-size: 15px;
  line-height: 1.2;
}

.brand small,
.market-status small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 3px;
  padding: 6px;
  border: 2px solid var(--green);
}

.brand-mark span {
  width: 4px;
  background: var(--green);
}

.brand-mark span:nth-child(1) {
  height: 9px;
}

.brand-mark span:nth-child(2) {
  height: 18px;
  background: var(--amber);
}

.brand-mark span:nth-child(3) {
  height: 24px;
}

.market-status {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  text-align: right;
}

.market-status strong {
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px var(--green-soft);
}

.status-stale .status-dot {
  background: var(--amber);
  box-shadow: 0 0 0 5px #f8ebd5;
}

.market-strip {
  border-bottom: 1px solid var(--line);
  background: #e9edf1;
}

.market-strip-inner {
  width: min(1500px, 100%);
  min-height: 82px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 auto;
  padding: 12px clamp(18px, 4vw, 56px);
  gap: 1px;
}

.market-tile {
  min-width: 0;
  min-height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  border-radius: 0;
}

button.market-tile:hover,
button.market-tile.is-active {
  border-color: var(--green);
  background: var(--green-soft);
}

.market-tile-position {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.market-tile-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.market-tile-copy strong,
.market-tile-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-tile-copy strong {
  font-size: 14px;
}

.market-tile-copy small {
  color: var(--muted);
  font-size: 11px;
}

.market-tile-value {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}

.market-tile-loading {
  opacity: 0.45;
}

main {
  width: 100%;
}

.board {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 36px clamp(18px, 4vw, 56px) 48px;
}

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

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

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

h1 {
  margin-bottom: 6px;
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.board-subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
}

.snapshot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.snapshot span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.controls {
  display: grid;
  grid-template-columns: auto minmax(200px, 1fr) 150px 160px;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.position-control {
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, auto));
  gap: 1px;
  border: 1px solid var(--line-strong);
  background: var(--line-strong);
}

.position-control button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  border-radius: 0;
}

.position-control button:hover,
.position-control button.is-active {
  background: var(--ink);
  color: var(--surface);
}

.field {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
}

.field input {
  padding: 0 12px;
}

.field select {
  padding: 0 32px 0 10px;
}

.board-meta {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 12px;
}

.board-meta p {
  margin: 0;
}

.table-frame {
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  height: 42px;
  background: #edf1f4;
  color: #525d6b;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  height: 66px;
  font-size: 13px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #f7faf9;
}

.rank-column {
  width: 72px;
  text-align: center;
}

.role-column {
  width: 122px;
}

.score-column {
  width: 110px;
  text-align: right;
}

.trend-column {
  width: 92px;
  text-align: right;
}

.context-column {
  width: 120px;
}

.confidence-column {
  width: 120px;
}

.action-column {
  width: 72px;
  text-align: right;
}

.rank {
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.player-cell {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-image,
.player-fallback {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid var(--line);
  background: #e9edf1;
}

.player-image {
  object-fit: cover;
  object-position: center top;
}

.player-fallback {
  display: none;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.player-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.player-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-name-button {
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.player-name-button:hover {
  text-decoration: underline;
}

.player-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-badge {
  display: inline-flex;
  min-width: 30px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  margin-right: 7px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
}

.role-copy,
.context-copy {
  display: grid;
  gap: 3px;
}

.role-copy strong,
.context-copy strong {
  font-size: 12px;
}

.role-copy small,
.context-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-score {
  display: block;
  color: var(--ink);
  font-size: 22px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.trend {
  display: inline-flex;
  min-width: 58px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.trend-up {
  background: var(--green-soft);
  color: var(--green);
}

.trend-down {
  background: var(--red-soft);
  color: var(--red);
}

.trend-flat {
  background: #eef1f4;
  color: var(--muted);
}

.confidence {
  display: grid;
  grid-template-columns: minmax(40px, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.confidence-track,
.component-track {
  overflow: hidden;
  background: #e4e8ed;
}

.confidence-track {
  height: 5px;
}

.confidence-track span,
.component-track span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.detail-button,
.secondary-button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.detail-button {
  padding: 0 10px;
}

.detail-button:hover,
.secondary-button:hover {
  border-color: var(--ink);
}

.loading-row td,
.empty-row td {
  height: 160px;
  color: var(--muted);
  text-align: center;
}

.board-actions {
  display: flex;
  justify-content: center;
  padding-top: 18px;
}

.secondary-button {
  padding: 0 16px;
}

.methodology {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(440px, 1.4fr);
  gap: 24px 48px;
  padding: 42px clamp(18px, 4vw, 56px);
  border-top: 1px solid var(--line);
  background: var(--ink);
  color: var(--surface);
}

.methodology > div:first-child,
.methodology dl,
.methodology-note {
  width: 100%;
  max-width: 720px;
}

.methodology .eyebrow {
  color: #6dd4ad;
}

.methodology dl {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: #3b424d;
}

.methodology dl div {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 14px;
  background: #202732;
}

.methodology dt {
  color: #6dd4ad;
  font-size: 22px;
  font-weight: 850;
}

.methodology dd {
  margin: 0;
  color: #c8d0da;
  font-size: 11px;
}

.methodology-note {
  grid-column: 2;
  margin: 0;
  color: #aeb8c4;
  font-size: 12px;
  line-height: 1.6;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(18, 24, 32, 0.62);
}

.dialog-shell {
  position: relative;
  padding: 26px;
}

.dialog-close-form {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
}

.dialog-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.dialog-header {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding-right: 42px;
}

.dialog-player-image,
.dialog-player-fallback {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  background: #e9edf1;
}

.dialog-player-image {
  object-fit: cover;
  object-position: center top;
}

.dialog-player-fallback {
  display: none;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.dialog-title-copy {
  min-width: 0;
}

.dialog-title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
}

.dialog-title-copy h2 {
  overflow: hidden;
  margin-bottom: 0;
  font-size: clamp(22px, 4vw, 32px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-trend-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
}

.player-trend-icon svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.player-trend-icon.is-up {
  background: var(--green-soft);
  color: var(--green);
}

.player-trend-icon.is-down {
  background: var(--red-soft);
  color: var(--red);
}

.dialog-title-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.dialog-score {
  min-width: 100px;
  text-align: right;
}

.dialog-score strong {
  display: block;
  font-size: 38px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.dialog-score small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.dialog-section {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.dialog-section h3 {
  margin: 0 0 14px;
  font-size: 13px;
}

.news-brief {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
}

.news-brief h3 {
  margin-bottom: 8px;
}

.news-brief p {
  max-width: 72ch;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.news-brief a {
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.news-brief a:hover,
.source-list a:hover {
  border-color: var(--blue);
}

.news-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.news-meta span {
  padding: 5px 7px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.component-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}

.component {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
  align-items: center;
}

.component span,
.component strong {
  font-size: 11px;
}

.component strong {
  font-variant-numeric: tabular-nums;
}

.component-track {
  grid-column: 1 / -1;
  height: 7px;
}

.component-track span {
  background: var(--green);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.stat-grid div {
  min-height: 70px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px;
  background: var(--surface-soft);
}

.stat-grid dt {
  color: var(--muted);
  font-size: 10px;
}

.stat-grid dd {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ledger {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ledger li {
  display: grid;
  grid-template-columns: minmax(140px, 0.45fr) minmax(0, 1fr) auto;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.ledger li:last-child {
  border-bottom: 0;
}

.ledger strong {
  font-size: 12px;
}

.ledger p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.ledger-delta {
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-list a {
  padding: 7px 9px;
  border: 1px solid var(--line);
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.noscript {
  margin: 0;
  padding: 20px;
  background: var(--red-soft);
  color: var(--red);
  text-align: center;
}

@media (max-width: 1040px) {
  .market-strip-inner {
    grid-template-columns: 1fr 1fr;
  }

  .controls {
    grid-template-columns: auto minmax(180px, 1fr) 140px;
  }

  .controls .field:last-child {
    grid-column: 3;
  }

  .search-field {
    grid-column: 2;
  }

  .confidence-column,
  .confidence-cell {
    display: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 64px;
  }

  .brand small {
    display: none;
  }

  .market-status small {
    max-width: 190px;
    display: block;
    text-wrap: pretty;
  }

  .market-strip-inner {
    padding: 10px 14px;
  }

  .market-tile {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    padding: 9px 11px;
  }

  .market-tile-value {
    grid-column: 2;
    font-size: 15px;
  }

  .market-tile-copy small {
    display: none;
  }

  .board {
    padding: 28px 14px 38px;
  }

  .board-heading {
    align-items: start;
  }

  .snapshot {
    max-width: 120px;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .position-control {
    grid-column: 1 / -1;
    grid-template-columns: repeat(5, 1fr);
  }

  .position-control button {
    padding: 0 8px;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .controls .field:last-child {
    grid-column: auto;
  }

  .board-meta p:last-child {
    display: none;
  }

  th,
  td {
    padding-right: 8px;
    padding-left: 8px;
  }

  .rank-column {
    width: 44px;
  }

  .score-column {
    width: 72px;
  }

  .trend-column {
    width: 68px;
  }

  .action-column {
    display: none;
  }

  .role-column,
  .role-cell,
  .context-column,
  .context-cell {
    display: none;
  }

  .player-image,
  .player-fallback {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .player-cell {
    gap: 8px;
  }

  .player-name {
    font-size: 13px;
  }

  .stock-score {
    font-size: 18px;
  }

  .trend {
    min-width: 48px;
    font-size: 11px;
  }

  .detail-button {
    width: 34px;
    padding: 0;
    font-size: 0;
  }

  .detail-button::after {
    content: "View";
    font-size: 9px;
  }

  .methodology {
    grid-template-columns: 1fr;
  }

  .methodology dl {
    grid-template-columns: 1fr 1fr;
  }

  .methodology-note {
    grid-column: 1;
  }

  .dialog-shell {
    padding: 22px 18px;
  }

  .dialog-header {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .dialog-player-image,
  .dialog-player-fallback {
    width: 58px;
    height: 58px;
  }

  .dialog-score {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    gap: 8px;
    text-align: left;
  }

  .component-list {
    grid-template-columns: 1fr;
  }

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

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .ledger li {
    grid-template-columns: 1fr auto;
  }

  .ledger p {
    grid-column: 1 / -1;
  }
}

@media (max-width: 420px) {
  .topbar {
    padding-right: 14px;
    padding-left: 14px;
  }

  .brand strong {
    max-width: 170px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .market-status strong {
    font-size: 11px;
  }

  .board-heading {
    display: grid;
  }

  .snapshot {
    max-width: none;
    justify-content: flex-start;
  }

  .player-meta {
    max-width: 132px;
  }
}
