:root {
  --market-accent: #315b63;
  --market-soft: #6f9698;
  --market-tint: #e3efed;
  --market-rise: #8c4c36;
  --market-fall: #326052;
}

.market-body {
  --sec-accent: var(--market-accent);
  --sec-soft: var(--market-soft);
  --sec-tint: var(--market-tint);
}

.market-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
}

.market-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 26px 22px 30px;
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.market-brand {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-top: 14px;
}

.market-brand h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.1;
}

.market-brand p {
  margin-top: 4px;
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  color: var(--ink-soft);
}

.market-glyph {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(49, 91, 99, .18);
  background: var(--market-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transform: rotate(90deg);
}

.market-glyph span {
  display: block;
  width: 3px;
  background: var(--market-accent);
  border-radius: 2px;
}

.market-glyph span:nth-child(1) { height: 10px; }
.market-glyph span:nth-child(2) { height: 23px; }
.market-glyph span:nth-child(3) { height: 16px; }
.market-glyph span:nth-child(4) { height: 28px; }

.series-panel { min-height: 130px; }

.market-series-list {
  display: grid;
  gap: 5px;
  max-height: 310px;
  overflow: auto;
  padding-right: 3px;
}

.series-button {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-left: 2px solid transparent;
  border-bottom: 1px solid var(--rule-soft);
}

.series-button:hover,
.series-button.active {
  border-left-color: var(--market-accent);
  background: var(--market-tint);
}

.series-button strong {
  display: block;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 12.5px;
  line-height: 1.3;
}

.series-button span {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-faint);
}

.source-status { display: grid; }

.source-row {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule-soft);
}

.source-row .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--market-soft);
}

.source-row.stale .status-dot,
.source-row.failed .status-dot { background: var(--market-rise); }

.source-row strong {
  display: block;
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 500;
}

.source-row small {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-faint);
}

.market-workspace {
  min-width: 0;
  max-width: 1240px;
  padding: 26px 34px 70px;
}

.market-hero {
  min-height: 170px;
  padding: 24px 26px;
  border: 1px solid var(--rule);
  border-top: 4px solid var(--market-accent);
  border-radius: 8px;
  background:
    repeating-linear-gradient(90deg, transparent 0, transparent 42px, rgba(49, 91, 99, .04) 43px),
    linear-gradient(135deg, var(--market-tint), var(--bg-card) 62%);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 30px;
}

.hero-copy h2 {
  margin-top: 12px;
  font-family: var(--serif);
  font-size: clamp(32px, 5vw, 57px);
  font-weight: 500;
  line-height: .98;
  letter-spacing: -.035em;
}

.hero-copy > p:last-child {
  margin-top: 16px;
  color: var(--ink-soft);
  max-width: 650px;
}

.hero-meta {
  min-width: 130px;
  display: grid;
  justify-items: end;
  gap: 3px;
  font-family: var(--mono);
}

.hero-meta > span { font-size: 9px; color: var(--ink-faint); letter-spacing: .1em; }
.hero-meta > strong { font-size: 18px; font-weight: 500; }
.hero-meta .icon-button { margin-top: 12px; }

.market-tape-wrap {
  margin-top: 18px;
  overflow: hidden;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.market-tape {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(180px, 1fr);
  overflow-x: auto;
}

.tape-cell {
  min-height: 84px;
  padding: 13px 16px;
  border-right: 1px solid var(--rule);
}

.tape-cell .tape-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tape-value {
  margin-top: 5px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.tape-value strong { font-family: var(--serif); font-size: 22px; font-weight: 500; }
.tape-value span { font-family: var(--mono); font-size: 10px; }
.tape-value .up { color: var(--market-rise); }
.tape-value .down { color: var(--market-fall); }
.tape-foot { margin-top: 3px; font-family: var(--mono); font-size: 8.5px; color: var(--ink-faint); }

.market-section {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}

.market-section.compact { margin-top: 0; }

.market-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.market-section h3 {
  margin-top: 4px;
  font-family: var(--serif);
  font-size: 23px;
  line-height: 1.2;
  font-weight: 500;
}

.chart-controls { display: flex; gap: 10px; flex-wrap: wrap; }

.segmented {
  display: flex;
  border: 1px solid var(--rule);
  border-radius: 5px;
  overflow: hidden;
  background: var(--bg-card);
}

.segmented button {
  padding: 6px 10px;
  border-right: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-faint);
}

.segmented button:last-child { border-right: 0; }
.segmented button.active { background: var(--market-tint); color: var(--market-accent); }

.chart-context,
.section-note {
  margin-top: 8px;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 13.5px;
  font-style: italic;
}

.chart-stage {
  position: relative;
  min-height: 390px;
  margin-top: 14px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background:
    linear-gradient(var(--rule-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule-soft) 1px, transparent 1px),
    var(--bg-card);
  background-size: 100% 72px, 90px 100%, auto;
}

#price-chart { width: 100%; height: 390px; display: block; }
.chart-grid { stroke: rgba(44, 42, 38, .13); stroke-width: 1; }
.chart-axis-label { font: 10px var(--mono); fill: rgba(44, 42, 38, .52); }
.chart-range { stroke: rgba(49, 91, 99, .24); stroke-width: 9; stroke-linecap: round; }
.chart-path { fill: none; stroke: var(--market-accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--bg-card); stroke: var(--market-accent); stroke-width: 2.5; }
.chart-dot:hover { fill: var(--market-accent); }

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 40px;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-faint);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 10px 2px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-faint);
}

.chart-legend a { color: var(--market-accent); text-decoration: none; }
.legend-line { display: inline-block; width: 18px; height: 2px; margin-right: 6px; background: var(--market-accent); vertical-align: middle; }
.legend-band { display: inline-block; width: 18px; height: 7px; margin-right: 6px; background: rgba(49, 91, 99, .20); vertical-align: middle; }

.market-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
  gap: 38px;
  margin-top: 46px;
}

.signal-list,
.latest-ledger { margin-top: 16px; border-top: 1px solid var(--rule); }

.signal-item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--rule-soft);
}

.signal-date { font-family: var(--mono); font-size: 9px; color: var(--ink-faint); }
.signal-copy strong { font-family: var(--serif); font-size: 14px; font-weight: 500; }
.signal-copy p { margin-top: 4px; font-size: 12px; color: var(--ink-soft); }
.signal-copy a { display: inline-block; margin-top: 5px; font-family: var(--mono); font-size: 9px; color: var(--market-accent); text-decoration: none; }

.latest-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--rule-soft);
}

.latest-row strong { display: block; font-family: var(--serif); font-size: 13px; font-weight: 500; }
.latest-row small { display: block; font-family: var(--mono); font-size: 8.5px; color: var(--ink-faint); }
.latest-row .latest-price { text-align: right; font-family: var(--mono); font-size: 12px; }
.latest-row .latest-price small { margin-top: 2px; }

.market-footnote {
  margin-top: 55px;
  padding-top: 15px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-faint);
}

@media (max-width: 900px) {
  .market-shell { grid-template-columns: 1fr; }
  .market-sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule); }
  .series-panel { display: none; }
  .market-workspace { padding: 20px 18px 60px; }
  .market-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .market-hero { min-height: 210px; align-items: flex-start; flex-direction: column; }
  .hero-meta { justify-items: start; }
  .market-section-head { align-items: flex-start; flex-direction: column; }
  .chart-stage, #price-chart { min-height: 310px; height: 310px; }
  .signal-item { grid-template-columns: 1fr; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
