:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef3f2;
  --text: #17202a;
  --muted: #607080;
  --line: #d8e0e6;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --warn: #c97912;
  --danger: #c2413f;
  --good: #15803d;
  --shadow: 0 14px 34px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  min-width: 0;
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.top-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 24px 0 18px;
}

.top-band > * {
  min-width: 0;
}

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

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

h1 {
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 18px;
}

.lead {
  width: 100%;
  max-width: 880px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.asof,
.notice-band,
.metric,
.pipeline-band article,
.control-band,
.candidate-list,
.detail-panel,
.model-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.asof {
  display: grid;
  gap: 4px;
  min-width: 150px;
  padding: 12px 14px;
}

.asof span,
.metric span,
.field span {
  color: var(--muted);
  font-size: 12px;
}

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

.notice-band {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  color: var(--muted);
  line-height: 1.5;
}

.notice-band strong {
  color: var(--accent);
  white-space: nowrap;
}

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

.metric {
  display: grid;
  gap: 8px;
  min-height: 86px;
  padding: 16px;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.pipeline-band {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.pipeline-band article {
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding: 14px;
}

.pipeline-band b {
  font-size: 14px;
}

.pipeline-band span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.control-band {
  display: grid;
  grid-template-columns: minmax(220px, 1.7fr) minmax(150px, 0.8fr) minmax(180px, 1fr) minmax(180px, 0.8fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.field input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(420px, 0.9fr);
  gap: 14px;
  margin-top: 14px;
}

.candidate-list,
.detail-panel {
  min-height: 720px;
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.section-heading span,
.section-heading button {
  color: var(--muted);
  font-size: 13px;
}

.section-heading button {
  min-width: 38px;
  padding: 0 10px;
  background: transparent;
}

.stock-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.stock-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(94px, auto);
  gap: 14px;
  overflow: hidden;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
}

.stock-card.is-selected {
  border-color: var(--accent);
  background: #f2fbf8;
}

.stock-main {
  min-width: 0;
}

.stock-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.stock-title strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.code {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pill.good,
.decision-box.good {
  background: #e8f6ee;
  color: var(--good);
}

.pill.warn,
.decision-box.warn {
  background: #fff2df;
  color: var(--warn);
}

.pill.danger,
.decision-box.danger {
  background: #fdecec;
  color: var(--danger);
}

.pill.info,
.decision-box.info {
  background: #eaf1ff;
  color: var(--accent-2);
}

.stock-meta {
  display: grid;
  grid-template-columns: repeat(8, minmax(82px, 1fr));
  gap: 8px;
}

.meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

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

.meta strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag-line span {
  padding: 3px 7px;
  border-radius: 99px;
  background: #eef3f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-box {
  display: grid;
  justify-items: end;
  align-content: center;
  gap: 8px;
}

.score-ring {
  display: grid;
  place-items: center;
  width: 72px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fff 58%, transparent 59%),
    conic-gradient(var(--score-color) calc(var(--score) * 1%), #e4eaf0 0);
  color: var(--text);
  font-size: 19px;
  font-weight: 900;
}

.detail-content {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  color: var(--muted);
  text-align: center;
}

.detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.detail-header h3 {
  font-size: 26px;
  line-height: 1.1;
}

.detail-header h3 span,
.detail-header p {
  color: var(--muted);
  font-size: 13px;
}

.detail-score {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 88px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-score strong {
  font-size: 32px;
  line-height: 1;
}

.detail-score span {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.decision-box {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 8px;
  line-height: 1.5;
}

.decision-box span {
  color: var(--text);
}

.score-breakdown {
  display: grid;
  gap: 8px;
}

.score-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 54px;
  gap: 10px;
  align-items: center;
}

.score-row span {
  color: var(--muted);
  font-size: 13px;
}

.score-line {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e6edf2;
}

.score-line > i {
  display: block;
  width: var(--width);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.section-block {
  display: grid;
  gap: 8px;
}

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

.edit-form {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

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

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

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.check-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 8px;
}

.form-actions button:first-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.model-band {
  margin-top: 14px;
  box-shadow: none;
}

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

.rule-grid article {
  display: grid;
  gap: 8px;
  min-height: 108px;
  padding: 14px;
  background: var(--surface);
}

.rule-grid span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

dialog {
  width: min(860px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(23, 32, 42, 0.24);
}

dialog::backdrop {
  background: rgba(23, 32, 42, 0.34);
}

dialog textarea {
  width: 100%;
  min-height: 460px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  resize: vertical;
}

@media (max-width: 1180px) {
  .metric-strip,
  .pipeline-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .button-row {
    grid-column: 1 / -1;
  }

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

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

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

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .top-band,
  .metric-strip,
  .pipeline-band,
  .control-band,
  .stock-card,
  .stock-meta,
  .detail-header,
  .form-grid,
  .rule-grid {
    grid-template-columns: 1fr;
  }

  .notice-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .asof {
    width: 100%;
  }

  .score-box {
    justify-items: start;
  }

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