:root {
  --bg: #f5f2eb;
  --paper: #fffdf8;
  --ink: #17191c;
  --muted: #6a6f76;
  --line: #ded8cc;
  --buy: #176a4b;
  --buy-soft: #e2f0e9;
  --sell: #a33f3b;
  --sell-soft: #f2dfdc;
  --panel-head: #f0ede6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.page-header,
main {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
}

.page-header {
  padding: 38px 0 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(36px, 5vw, 66px);
  line-height: 1.02;
  letter-spacing: 0;
}

.summary {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
}

main {
  padding-bottom: 34px;
}

.boards-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.boards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(460px, 1fr));
  gap: 14px;
  min-width: 940px;
}

.board {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.board-head {
  display: flex;
  min-height: 86px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-head);
  padding: 16px;
}

.board h2 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.12;
}

.count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.rank-list {
  display: grid;
  max-height: 680px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.rank-row {
  display: grid;
  grid-template-columns: 36px minmax(120px, 1.25fr) minmax(116px, 0.72fr);
  gap: 12px;
  align-items: start;
  border-bottom: 1px solid #ebe6dc;
  padding: 14px 16px;
  cursor: pointer;
}

.rank-row:last-child {
  border-bottom: 0;
}

.rank-row:hover,
.rank-row:focus {
  background: #f8f4ec;
  outline: none;
}

.rank-row:focus {
  box-shadow: inset 0 0 0 2px #8c806d;
}

.rank {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e6e0d4;
  color: #50545a;
  font-size: 12px;
  font-weight: 850;
}

.identity {
  min-width: 0;
}

.ticker {
  font-size: 17px;
  font-weight: 850;
  line-height: 1.15;
}

.name {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.net {
  display: grid;
  justify-items: end;
  gap: 3px;
}

.net span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.net strong {
  font-size: 18px;
  line-height: 1.1;
}

.net.buy strong {
  color: var(--buy);
}

.net.sell strong {
  color: var(--sell);
}

.facts {
  grid-column: 2 / 4;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 0;
}

.facts div {
  min-width: 0;
  border-radius: 6px;
  background: #f7f4ee;
  padding: 8px;
}

.facts dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.facts dd {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 800;
}

.board-buy .board-head {
  box-shadow: inset 4px 0 0 var(--buy);
}

.board-sell .board-head {
  box-shadow: inset 4px 0 0 var(--sell);
}

.holdings-section {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  overflow: hidden;
}

.holdings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-head);
  padding: 16px;
}

.holdings-head h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.12;
}

.holdings-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.holdings-note {
  margin: 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 16px;
}

.holdings-table-wrap {
  max-height: 760px;
  overflow: auto;
}

.holdings-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
}

.holdings-table th,
.holdings-table td {
  border-bottom: 1px solid #ebe6dc;
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
}

.holdings-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbf8f1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

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

.holding-row {
  cursor: pointer;
}

.holding-row:hover,
.holding-row:focus {
  background: #f8f4ec;
  outline: none;
}

.holding-row:focus {
  box-shadow: inset 0 0 0 2px #8c806d;
}

.holdings-table .identity {
  max-width: 320px;
}

.holdings-table .ticker {
  font-size: 16px;
}

.holding-mobile-metrics {
  display: none;
}

.holdings-table .numeric {
  text-align: right;
  font-weight: 800;
  white-space: nowrap;
}

.price-cell {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.price-cell span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.return-cell {
  font-size: 16px;
}

.gain {
  color: var(--buy);
}

.loss {
  color: var(--sell);
}

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

.error-state {
  padding: 40px 0;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(23, 25, 28, 0.38);
  padding: 22px;
}

.detail-overlay[hidden] {
  display: none;
}

.detail-panel {
  width: min(980px, 100%);
  max-height: min(860px, calc(100vh - 44px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(23, 25, 28, 0.3);
  padding: 24px;
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  transition: transform 160ms ease, opacity 160ms ease;
}

.detail-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.detail-close {
  position: sticky;
  top: 0;
  z-index: 1;
  float: right;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.detail-head {
  padding-right: 48px;
}

.detail-head h2 {
  margin: 0 0 6px;
  font-size: 44px;
}

.detail-head p {
  color: var(--muted);
  font-size: 15px;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 10px;
}

.detail-summary div,
.trade-grid div {
  border-radius: 6px;
  background: #f7f4ee;
  padding: 10px;
}

.detail-summary span,
.trade-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.detail-summary strong,
.trade-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.detail-summary strong.buy {
  color: var(--buy);
}

.detail-summary strong.sell {
  color: var(--sell);
}

.detail-meta {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.trade-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.trade-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.trade-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.trade-date {
  font-size: 17px;
  font-weight: 850;
}

.trade-type {
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 850;
}

.trade-type.buy {
  background: var(--buy-soft);
  color: var(--buy);
}

.trade-type.sell {
  background: var(--sell-soft);
  color: var(--sell);
}

.trade-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.trade-range {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 720px) {
  .page-header,
  main {
    width: min(100% - 20px, 1280px);
  }

  .page-header {
    padding-top: 28px;
  }

  .boards-grid {
    grid-template-columns: repeat(2, minmax(330px, 1fr));
    min-width: 680px;
  }

  .rank-row {
    grid-template-columns: 32px minmax(100px, 1fr);
  }

  .net {
    grid-column: 2;
    justify-items: start;
  }

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

  .holdings-section {
    margin-top: 14px;
  }

  .holdings-head {
    display: block;
  }

  .holdings-meta {
    margin-top: 8px;
    text-align: left;
    white-space: normal;
  }

  .holdings-table {
    min-width: 820px;
  }

  .holding-mobile-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
  }

  .holding-mobile-metrics span,
  .holding-mobile-metrics strong {
    border-radius: 999px;
    background: #f0ede6;
    font-size: 11px;
    font-weight: 850;
    line-height: 1.2;
    padding: 4px 7px;
    white-space: nowrap;
  }

  .detail-panel {
    max-height: calc(100vh - 24px);
    padding: 16px;
  }

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

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