:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --line: #d8e0ef;
  --text: #162033;
  --muted: #5d6a83;
  --brand: #0b6bcb;
  --brand-strong: #084f9a;
  --accent: #d9ecff;
  --good: #0f8a56;
  --warn: #b86a0b;
  --bad: #d14343;
  --shadow: 0 18px 50px rgba(31, 46, 85, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(11, 107, 203, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 138, 86, 0.1), transparent 24%),
    linear-gradient(180deg, #f7f9fd 0%, #eef3fb 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1800px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 24px 0 40px;
  overflow-x: clip;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  margin-bottom: 20px;
  border: 1px solid rgba(216, 224, 239, 0.8);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(237, 244, 255, 0.96));
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.02;
}

.hero-copy,
.hero-note ol,
.muted {
  color: var(--muted);
  line-height: 1.6;
}

.hero-note {
  min-width: 280px;
  padding: 18px 20px;
  border-radius: 22px;
  background: rgba(11, 107, 203, 0.06);
  border: 1px solid rgba(11, 107, 203, 0.12);
}

.hero-note p {
  margin: 0 0 8px;
  font-weight: 700;
}

.hero-note ol {
  margin: 0;
  padding-left: 20px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.stack > * {
  min-width: 0;
}

.layout > .stack:first-child {
  grid-template-columns: minmax(0, 1fr);
  position: sticky;
  top: 16px;
}

.wide {
  min-width: 0;
}

.analysis-shell {
  display: grid;
  gap: 18px;
}

.subcard {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(216, 224, 239, 0.9);
  background: rgba(255, 255, 255, 0.88);
  min-width: 0;
}

.card {
  padding: 20px;
  border-radius: 24px;
  border: 1px solid rgba(216, 224, 239, 0.9);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  min-width: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.08rem;
}

.section-subtitle {
  margin: 18px 0 10px;
  font-weight: 700;
  font-size: 0.96rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(11, 107, 203, 0.08);
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 700;
}

.tag.neutral {
  background: rgba(93, 106, 131, 0.09);
  color: var(--muted);
}

.sheet-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(11, 107, 203, 0.08);
}

.sheet-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.sheet-tab.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 6px 18px rgba(31, 46, 85, 0.12);
}

.sheet-panel {
  display: none;
  gap: 18px;
}

.sheet-panel.active {
  display: grid;
}

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

.formula-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.formula-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.formula-block {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #d6e4fb;
  background: #f7fbff;
  color: var(--brand-strong);
  font-size: 0.92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-x: auto;
}

.button-row,
.table-actions,
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  transition: 160ms ease;
}

.button:hover,
.button:focus-visible,
.chip:hover,
.chip:focus-visible {
  transform: translateY(-1px);
  border-color: #9eb5db;
  outline: none;
}

.button.primary {
  background: linear-gradient(135deg, var(--brand), #2b8cf0);
  border-color: transparent;
  color: #fff;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 120px;
  margin-top: 14px;
  padding: 18px;
  border-radius: 18px;
  border: 1.5px dashed #b6c8e8;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(232, 240, 252, 0.92));
  text-align: center;
  transition: 160ms ease;
}

.drop-zone.drag {
  border-color: var(--brand);
  background: linear-gradient(180deg, rgba(217, 236, 255, 0.92), rgba(239, 246, 255, 0.98));
}

.drop-zone small {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

.field-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--muted);
}

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

.check-line {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
}

select,
textarea,
input[type="number"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
}

textarea {
  min-height: 170px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, monospace;
}

input[type="range"] {
  width: 100%;
}

.status {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(184, 106, 11, 0.18);
  background: rgba(255, 247, 229, 0.98);
  color: #8f5612;
}

.image-card {
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.image-card img {
  width: 100%;
  min-height: 180px;
  max-height: 280px;
  object-fit: contain;
  margin-top: 8px;
  border-radius: 14px;
  background: #eff4fb;
}

.candidate-list {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  padding: 12px;
}

.candidate {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.candidate:last-child {
  border-bottom: 0;
}

.candidate pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  color: var(--muted);
  font-size: 0.78rem;
  font-family: "SFMono-Regular", Consolas, monospace;
}

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

.metric-card {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(216, 224, 239, 0.9);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(240, 245, 252, 0.97));
  box-shadow: var(--shadow);
}

.metric-card span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.08rem;
  line-height: 1.25;
  word-break: break-word;
}

.diagnosis-card {
  background: linear-gradient(180deg, rgba(247, 250, 255, 0.96), rgba(235, 244, 255, 0.96));
}

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

.diagnosis-value {
  margin-top: 6px;
  color: var(--text);
  font-weight: 700;
  line-height: 1.5;
}

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

.chart-card canvas {
  width: 100%;
  max-width: 100%;
  height: 280px;
  margin-top: 10px;
  border-radius: 18px;
  background: #fff;
  display: block;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
}

.table-wrap.compact {
  max-height: 260px;
}

table {
  width: max-content;
  min-width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #e9eef7;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

tr.anomaly td {
  background: rgba(255, 238, 238, 0.82);
}

.editable {
  width: 100%;
  min-width: 120px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  text-align: right;
  padding: 6px 8px;
  border-radius: 10px;
}

.editable.text {
  text-align: left;
  min-width: 180px;
}

.editable:focus {
  outline: none;
  border-color: #9ec4f2;
  background: #eef6ff;
}

.tooltip {
  position: fixed;
  z-index: 9999;
  display: none;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.96);
  color: #fff;
  font-size: 0.78rem;
  line-height: 1.55;
  pointer-events: none;
  white-space: pre-line;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}

@media (max-width: 1480px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .layout > .stack:first-child {
    position: static;
  }
}

@media (max-width: 1440px) {
  .chart-grid,
  .diagnosis-grid,
  .formula-grid,
  .grid.two,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }

  .hero-note {
    min-width: 0;
  }
}

@media (max-width: 1680px) {
  .metrics-grid {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
  }
}

@media (max-width: 1440px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}
