:root {
  --bg: #eef2f0;
  --surface: rgba(255, 255, 255, 0.76);
  --surface-solid: #ffffff;
  --ink: #17202a;
  --muted: #65717d;
  --faint: #8d98a4;
  --line: rgba(34, 46, 58, 0.12);
  --gold: #d6a333;
  --gold-strong: #a87512;
  --green: #0b8f63;
  --green-soft: #e2f6ec;
  --red: #c7443e;
  --red-soft: #fae6e3;
  --orange: #c87322;
  --orange-soft: #fff0df;
  --blue: #2f75b8;
  --violet: #7c5cc4;
  --slate: #263445;
  --shadow: 0 18px 55px rgba(27, 39, 51, 0.12);
  --shadow-soft: 0 10px 26px rgba(27, 39, 51, 0.08);
  --radius: 8px;
  color-scheme: light;
  font-family: Inter, "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 34%),
    radial-gradient(circle at 20% 0%, rgba(214, 163, 51, 0.16), transparent 26%),
    linear-gradient(180deg, #f8f6ef 0%, #eef2f0 44%, #e7ecea 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1520px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 46px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow,
.panel-label {
  color: var(--gold-strong);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 5px;
  font-size: clamp(30px, 3vw, 42px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-top: 5px;
  font-size: 20px;
  line-height: 1.2;
}

h3 {
  font-size: 16px;
  line-height: 1.3;
}

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

.asset-tabs {
  display: inline-flex;
  gap: 4px;
  margin-top: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(14px);
}

.asset-tab {
  min-width: 64px;
  border: 0;
  border-radius: 999px;
  padding: 8px 13px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.asset-tab.active {
  color: #fff;
  background: var(--slate);
}

.status-pill,
.updated-at,
.ma-toggle {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(14px);
  border-radius: 999px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-pill.live {
  color: var(--green);
}

.status-pill.sample,
.status-pill.partial {
  color: var(--orange);
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 16%, transparent);
}

.updated-at {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.updated-at strong {
  color: var(--ink);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--ink);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--gold) 60%, var(--line));
  box-shadow: var(--shadow-soft);
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.learn-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid color-mix(in srgb, var(--gold) 48%, var(--line));
  border-radius: 999px;
  padding: 8px 13px;
  background: linear-gradient(180deg, #fff8e8, #ffffff);
  color: var(--gold-strong);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.learn-button:hover {
  border-color: var(--gold);
}

.learn-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.learn-panel {
  margin: -2px 0 18px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.78)),
    var(--surface-solid);
  box-shadow: var(--shadow);
}

.learn-panel[hidden] {
  display: none;
}

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

.learn-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-height: min(68vh, 760px);
  margin-top: 14px;
  padding-right: 4px;
  overflow: auto;
}

.learn-block {
  min-height: 186px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.learn-block.wide {
  grid-column: span 2;
}

.learn-block h3 {
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.learn-block p,
.learn-block li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.68;
}

.learn-block p {
  margin-top: 9px;
}

.learn-block ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

.learn-block strong {
  color: var(--ink);
  font-weight: 900;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.74fr) minmax(0, 1.9fr);
  gap: 18px;
}

.signal-panel,
.chart-panel,
.module,
.factor-card {
  border: 1px solid rgba(255, 255, 255, 0.74);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.64)),
    var(--surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
}

.signal-panel {
  position: relative;
  overflow: hidden;
  min-height: 540px;
  padding: 22px;
  display: flex;
  flex-direction: column;
}

.signal-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(214, 163, 51, 0.18), transparent 36%),
    linear-gradient(180deg, rgba(23, 32, 42, 0.04), transparent 45%);
  pointer-events: none;
}

.signal-panel > * {
  position: relative;
}

.signal-head,
.panel-heading,
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.market-badge,
.hit-rate {
  white-space: nowrap;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 850;
}

.market-badge.live,
.hit-rate {
  color: var(--green);
  background: var(--green-soft);
}

.market-badge.partial {
  color: var(--orange);
  background: var(--orange-soft);
}

.market-badge.offline {
  color: var(--red);
  background: var(--red-soft);
}

.signal-orb {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 264px);
  aspect-ratio: 1;
  margin: 24px auto 18px;
}

.signal-orb svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 12px 22px rgba(11, 143, 99, 0.14));
}

.orb-track {
  fill: none;
  stroke: rgba(23, 32, 42, 0.08);
  stroke-width: 9;
}

.orb-value {
  fill: none;
  stroke: var(--gold);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  transition: stroke-dashoffset 560ms ease, stroke 200ms ease;
}

.signal-orb > div {
  text-align: center;
  padding-top: 6px;
}

.signal-text {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0;
}

.score-text {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 3px;
  color: var(--muted);
  font-weight: 800;
}

.score-text span:first-child {
  color: var(--ink);
  font-size: 46px;
  line-height: 1;
}

.price-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: auto;
}

.price-stack > div,
.driver-list > div,
.signal-insights > div {
  min-width: 0;
  border: 1px solid rgba(23, 32, 42, 0.08);
  background: rgba(255, 255, 255, 0.56);
  border-radius: 8px;
  padding: 12px;
}

.price-stack span,
.driver-kicker {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.price-stack strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  white-space: nowrap;
}

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

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

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

.driver-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 9px;
}

.driver-list strong {
  display: block;
  margin-top: 6px;
  min-height: 38px;
  line-height: 1.35;
}

.signal-insights {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 9px;
}

.signal-insights strong {
  display: block;
  margin-top: 6px;
  min-height: 20px;
  line-height: 1.3;
}

.module-note,
.section-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.chart-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.kline-tabs {
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  padding: 3px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  scrollbar-width: none;
}

.kline-tabs::-webkit-scrollbar {
  display: none;
}

.kline-tab {
  position: relative;
  flex: 0 0 auto;
  min-width: 38px;
  border: 0;
  border-radius: 4px;
  padding: 8px 8px 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.kline-tab:hover {
  color: var(--ink);
  background: rgba(27, 31, 36, 0.05);
}

.kline-tab.active {
  color: var(--ink);
  background: rgba(201, 154, 46, 0.12);
  box-shadow: none;
}

.kline-tab.active::after {
  position: absolute;
  right: 8px;
  bottom: 3px;
  left: 8px;
  height: 2px;
  border-radius: 99px;
  background: var(--gold);
  content: '';
}

.ma-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 8px;
}

.ma-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.ma-toggle.active {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(23, 32, 42, 0.18);
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 11px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.legend-row span,
.ma-toggle {
  align-items: center;
}

.legend {
  display: inline-block;
  width: 22px;
  height: 3px;
  border-radius: 99px;
}

.legend.gold { background: var(--gold); }
.legend.rate { background: var(--red); }
.legend.dxy { background: var(--blue); }
.legend.ma5y { background: #6b7280; }
.legend.ma3y { background: var(--violet); }
.legend.ma1y { background: var(--green); }
.legend.ma6m { background: #e26d2d; }
.legend.ma1m { background: #111827; }

.chart-wrap,
.mini-chart-wrap {
  position: relative;
  width: 100%;
  min-height: 342px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.6), rgba(255,255,255,0.3)),
    rgba(255,255,255,0.38);
  border: 1px solid rgba(23, 32, 42, 0.08);
  overflow: hidden;
}

.chart-wrap canvas,
.mini-chart-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  pointer-events: none;
}

.chart-empty.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.comparison-section,
.factor-section,
.lower-grid {
  margin-top: 18px;
}

.section-heading {
  margin: 0 2px 12px;
}

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

.comparison-card {
  min-height: 168px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius);
  padding: 15px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.64)),
    var(--surface);
  box-shadow: var(--shadow-soft);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.comparison-card.active {
  border-color: color-mix(in srgb, var(--gold) 70%, var(--line));
  box-shadow: 0 0 0 3px rgba(214, 163, 51, 0.16), var(--shadow-soft);
}

.comparison-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.comparison-top span {
  font-size: 18px;
  font-weight: 900;
}

.comparison-top strong {
  font-size: 22px;
  font-weight: 950;
}

.comparison-top strong.bullish {
  color: var(--green);
}

.comparison-top strong.bearish {
  color: var(--red);
}

.comparison-signal {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.comparison-bar {
  height: 8px;
  margin-top: 13px;
  border-radius: 999px;
  background: rgba(23, 32, 42, 0.08);
  overflow: hidden;
}

.comparison-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.comparison-detail {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.factor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.factor-card {
  min-height: 212px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.factor-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.factor-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(23, 32, 42, 0.06);
  color: var(--slate);
  flex: 0 0 auto;
}

.factor-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.factor-score {
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(23, 32, 42, 0.06);
  font-size: 13px;
  font-weight: 900;
}

.factor-score.bullish {
  color: var(--green);
  background: var(--green-soft);
}

.factor-score.bearish {
  color: var(--red);
  background: var(--red-soft);
}

.factor-body {
  margin-top: 16px;
}

.factor-name {
  font-size: 17px;
  font-weight: 900;
}

.factor-current {
  margin-top: 10px;
  font-size: 24px;
  line-height: 1.05;
  font-weight: 900;
}

.factor-meta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.factor-drivers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.factor-chip {
  max-width: 100%;
  padding: 5px 7px;
  border-radius: 8px;
  background: rgba(23, 32, 42, 0.06);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;
  font-weight: 800;
}

.factor-chip.bullish {
  color: var(--green);
  background: var(--green-soft);
}

.factor-chip.bearish {
  color: var(--red);
  background: var(--red-soft);
}

.progress-track {
  height: 9px;
  margin-top: auto;
  background: rgba(23, 32, 42, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.progress-value {
  height: 100%;
  width: 50%;
  border-radius: inherit;
  background: var(--gold);
}

.factor-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
}

.module {
  padding: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.metric-card {
  min-height: 116px;
  border: 1px solid rgba(23, 32, 42, 0.08);
  background: rgba(255, 255, 255, 0.52);
  border-radius: 8px;
  padding: 13px;
}

.metric-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
}

.metric-value {
  margin-top: 12px;
  font-size: 21px;
  line-height: 1.1;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.metric-change {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
}

.mini-chart-wrap {
  min-height: 230px;
  margin-top: 12px;
}

.loading .chart-panel,
.loading .signal-panel,
.loading .module,
.loading .comparison-card,
.loading .factor-card {
  opacity: 0.72;
}

@media (max-width: 1260px) {
  .hero-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }

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

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

  .signal-panel {
    min-height: auto;
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 24px, 1520px);
    padding-top: 18px;
  }

  .topbar,
  .panel-heading,
  .section-heading,
  .chart-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .learn-head {
    align-items: center;
  }

  .learn-grid {
    grid-template-columns: 1fr;
    max-height: 70vh;
  }

  .learn-block,
  .learn-block.wide {
    grid-column: auto;
    min-height: auto;
  }

  .kline-tabs {
    overflow-x: auto;
    width: 100%;
    justify-content: flex-start;
  }

  .kline-tab {
    min-width: 50px;
  }

  .price-stack,
  .driver-list,
  .signal-insights,
  .comparison-grid,
  .factor-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .signal-orb {
    width: min(100%, 220px);
  }

  .chart-wrap {
    min-height: 320px;
  }
}
