:root {
  color-scheme: dark;
  --bg: #101216;
  --surface: #171a20;
  --surface-2: #1d2128;
  --surface-3: #252a33;
  --line: #2b313b;
  --text: #f1f3f5;
  --muted: #8f98a6;
  --yellow: #f4c430;
  --green: #16c784;
  --red: #ea586f;
  --blue: #5b8cff;
  --cyan: #3fb9c2;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button {
  font: inherit;
}

input,
select,
textarea {
  font: inherit;
}

button:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 18, 22, 0.94);
  backdrop-filter: blur(14px);
}

.header-inner,
.workspace {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  background: var(--yellow);
  color: #111318;
  font-size: 12px;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand div > span {
  color: var(--muted);
  font-size: 11px;
}

.header-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.source-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.source-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.source-state.is-live i {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 199, 132, 0.12);
}

.source-state.is-warn i {
  background: var(--yellow);
}

.source-state.is-error i {
  background: var(--red);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  border-color: #3b4350;
  background: var(--surface-3);
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-icon-button {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
}

.mini-icon-button:hover {
  color: var(--text);
  background: var(--surface-3);
}

.mini-icon-button svg {
  width: 15px;
  height: 15px;
}

.icon-button.is-loading svg {
  animation: spin 900ms linear infinite;
}

.workspace {
  padding: 34px 0 64px;
}

.section-block + .section-block {
  margin-top: 42px;
  padding-top: 38px;
  border-top: 1px solid var(--line);
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--yellow);
  font-size: 11px;
  font-weight: 800;
}

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

h1,
h2 {
  margin-bottom: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 24px;
}

.updated-at,
.data-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.price-item {
  min-width: 0;
  padding: 18px 20px 18px 0;
}

.price-item + .price-item {
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.price-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.asset-name {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.asset-icon {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--yellow);
  font-size: 11px;
  font-weight: 900;
}

.asset-name strong,
.asset-name small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-name small {
  color: var(--muted);
  font-size: 11px;
}

.quote-age {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.price-value {
  display: block;
  margin-top: 17px;
  overflow-wrap: anywhere;
  font-size: 25px;
  line-height: 1.15;
}

.price-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.price-meta span:last-child {
  flex: 0 0 auto;
  text-align: right;
  white-space: nowrap;
}

.position-meta {
  min-height: 16px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

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

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

.asset-tabs {
  display: flex;
  max-width: 100%;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.asset-tab {
  flex: 0 0 auto;
  min-width: 54px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.asset-tab:hover {
  color: var(--text);
}

.asset-tab.is-active {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--yellow);
}

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

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sentiment-panel,
.provenance-panel {
  grid-column: span 6;
}

.score-panel {
  grid-column: span 7;
}

.factor-panel {
  grid-column: span 5;
}

.thesis-panel,
.research-panel {
  grid-column: span 12;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head strong,
.panel-label {
  display: block;
}

.panel-head strong {
  margin-top: 3px;
  font-size: 17px;
}

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

.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.is-positive {
  background: rgba(22, 199, 132, 0.1);
  color: var(--green);
}

.status-pill.is-negative {
  background: rgba(234, 88, 111, 0.1);
  color: var(--red);
}

.status-pill.is-neutral {
  background: rgba(244, 196, 48, 0.1);
  color: var(--yellow);
}

.score-layout {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  min-height: 142px;
}

.score-gauge {
  --score: 0%;
  position: relative;
  display: grid;
  width: 118px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--yellow) 0 var(--score), var(--surface-3) var(--score) 100%);
}

.score-gauge::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: var(--surface);
}

.score-gauge strong,
.score-gauge span {
  position: relative;
  z-index: 1;
}

.score-gauge strong {
  transform: translateY(-7px);
  font-size: 32px;
  line-height: 1;
}

.score-gauge span {
  position: absolute;
  right: 0;
  bottom: 27px;
  left: 0;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.score-copy {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.score-stat,
.score-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.score-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 10px 12px;
}

.score-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.score-stat strong {
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  white-space: nowrap;
}

.score-summary {
  margin: 0;
  padding: 12px;
  color: #b8bec8;
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.factor-list {
  display: grid;
  gap: 15px;
}

.factor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
}

.factor-row span {
  color: #c3c8d0;
  font-size: 12px;
  font-weight: 700;
}

.factor-row strong {
  justify-self: end;
}

.factor-track {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-3);
}

.factor-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

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

.thesis-columns > div + div {
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.thesis-columns h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  font-size: 13px;
}

.thesis-columns h3 svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.evidence-list,
.report-list,
.source-list {
  display: grid;
  gap: 8px;
}

.evidence-item,
.empty-state {
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: #c0c6cf;
  font-size: 12px;
}

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

.report-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 70px;
  gap: 14px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

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

.report-title,
.report-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-title {
  font-weight: 800;
}

.report-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.report-score {
  text-align: right;
  font-weight: 800;
}

.evidence-score {
  color: var(--muted);
  text-align: right;
  font-size: 11px;
}

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

.sentiment-metrics div {
  min-height: 76px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.sentiment-metrics span,
.sentiment-metrics strong {
  display: block;
}

.sentiment-metrics span {
  color: var(--muted);
  font-size: 11px;
}

.sentiment-metrics strong {
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 17px;
}

.source-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(0, 1.3fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

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

.source-row span {
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 11px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 40px));
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-3);
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.modal {
  width: min(620px, calc(100% - 28px));
  max-height: min(760px, calc(100vh - 40px));
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.modal::backdrop {
  background: rgba(5, 7, 10, 0.76);
  backdrop-filter: blur(3px);
}

.modal-form {
  padding: 20px;
}

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

.modal-head strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.form-grid label > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.form-wide {
  grid-column: 1 / -1;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  background: var(--surface-2);
  color: var(--text);
}

.form-grid input,
.form-grid select {
  height: 40px;
  padding: 0 10px;
}

.form-grid textarea {
  min-height: 150px;
  padding: 10px;
  resize: vertical;
  line-height: 1.55;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  border-color: var(--yellow);
}

.modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
  padding: 16px 0 2px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.primary-button,
.secondary-button {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 7px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--yellow);
  background: var(--yellow);
  color: #111318;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.is-hidden {
  display: none !important;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 920px) {
  .price-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .price-item:nth-child(odd) {
    padding-left: 0;
    border-left: 0;
  }

  .price-item:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .score-panel,
  .factor-panel,
  .sentiment-panel,
  .provenance-panel {
    grid-column: span 12;
  }

}

@media (max-width: 680px) {
  .header-inner,
  .workspace {
    width: min(1160px, calc(100% - 28px));
  }

  .header-inner {
    min-height: 62px;
  }

  .brand {
    flex: 1 1 auto;
  }

  .header-status {
    flex: 0 0 auto;
    gap: 8px;
  }

  .header-status .source-state {
    font-size: 11px;
  }

  .header-status .icon-button {
    width: 34px;
    height: 34px;
  }

  .header-status .source-state {
    display: none;
  }

  .workspace {
    padding-top: 25px;
  }

  .section-head,
  .quant-heading {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 22px;
  }

  .asset-tabs {
    width: 100%;
  }

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

  .price-item,
  .price-item + .price-item,
  .price-item:nth-child(odd) {
    padding: 16px 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .price-item:first-child {
    border-top: 0;
  }

  .score-layout,
  .thesis-columns {
    grid-template-columns: 1fr;
  }

  .score-gauge {
    justify-self: center;
  }

  .thesis-columns > div + div {
    padding: 16px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .report-row {
    grid-template-columns: minmax(0, 1fr) 64px;
  }

  .evidence-score {
    grid-column: 1 / -1;
    text-align: left;
  }

  .sentiment-metrics {
    grid-template-columns: 1fr;
  }

  .source-row {
    grid-template-columns: 1fr auto;
  }

  .source-row span {
    grid-column: 1 / -1;
  }

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

  .form-wide {
    grid-column: span 1;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
