:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #17223b;
  --ink-soft: #45536b;
  --muted: #8291a8;
  --border: #e6eaf3;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --accent-soft: #eef2ff;
  --sky: #0284c7;
  --amber: #d97706;
  --good: #0f766e;
  --good-soft: #ecfdf5;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;
  --shadow:
    0 1px 2px rgba(23, 34, 59, .05),
    0 4px 12px rgba(23, 34, 59, .05),
    0 16px 40px rgba(79, 70, 229, .06);
  --shadow-hover:
    0 2px 4px rgba(23, 34, 59, .06),
    0 10px 24px rgba(23, 34, 59, .08),
    0 20px 48px rgba(79, 70, 229, .1);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1100px 420px at 8% -8%, rgba(79, 70, 229, .08), transparent 60%),
    radial-gradient(900px 380px at 96% -12%, rgba(2, 132, 199, .07), transparent 55%),
    linear-gradient(180deg, #f7f8fd 0%, var(--bg) 340px);
  background-attachment: fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app-shell { max-width: 1560px; margin: 0 auto; padding: 0 28px 28px; }

/* ------------------------------- top bar ------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 6px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
}

.brand { display: flex; align-items: center; gap: 16px; }

.brand-mark {
  width: 50px; height: 50px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, #5b54ee 0%, #4338ca 100%);
  color: #fff;
  font-size: 26px;
  font-weight: 600;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .28),
    0 8px 20px rgba(79, 70, 229, .3);
}

.brand h1 {
  font-size: 23px;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -.3px;
  background: linear-gradient(100deg, #312e81 10%, #4f46e5 55%, #7c6ff0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand h1 span { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.brand p { margin: 3px 0 0; color: var(--ink-soft); font-size: 13px; }
.brand p strong { color: var(--accent); }
.brand-title-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.brand-author {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(120deg, #eef2ff, #f0f9ff);
  border: 1px solid #dbe3f8;
}

.topbar-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, .8);
  color: var(--muted);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  box-shadow: 0 1px 2px rgba(23, 34, 59, .04);
}

/* ------------------------------- layout ------------------------------- */

.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 22px; align-items: start; }
.sidebar { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 18px; }
.content { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.side-card { padding: 20px; }

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 13px;
}

/* -------------------------------- tabs -------------------------------- */

.tabs { display: flex; flex-direction: column; gap: 8px; }
.tab {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: #f6f7fc;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s;
}
.tab:hover { background: var(--accent-soft); transform: translateX(2px); }
.tab.active {
  background: linear-gradient(120deg, var(--accent-soft), #f0f9ff);
  border-color: #c7d2fe;
  color: var(--accent-dark);
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(79, 70, 229, .12);
}
.tab-num {
  width: 23px; height: 23px; flex: none;
  display: grid; place-items: center;
  border-radius: 7px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 11px; font-weight: 700;
  transition: background .15s, border-color .15s, color .15s;
}
.tab.active .tab-num {
  background: linear-gradient(145deg, #5b54ee, #4338ca);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 8px rgba(79, 70, 229, .35);
}

.formula {
  margin-top: 15px;
  padding: 12px 14px;
  background: #f8f9fd;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.8;
  overflow-x: auto;
}

/* ------------------------------ parameters ----------------------------- */

.fields { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field span { font-size: 12.5px; color: var(--ink-soft); }
.field input {
  width: 92px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fbfcff;
  color: var(--ink);
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: right;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }

.preset-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.preset {
  padding: 6px 11px;
  border: 1px dashed #c3cddd;
  border-radius: 8px;
  background: #fff;
  color: var(--ink-soft);
  font-size: 11px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.preset:hover { border-color: var(--accent); border-style: solid; color: var(--accent); background: var(--accent-soft); }

.run-row { display: flex; gap: 9px; margin-top: 17px; }
.btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 15px;
  background: #fff;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  flex: 1;
  background: linear-gradient(145deg, #5b54ee, #4338ca);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .32);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(145deg, #4c46e0, #3730a3);
  box-shadow: 0 8px 20px rgba(79, 70, 229, .4);
}
.btn-ghost { background: #fff; }
.btn-small { padding: 7px 12px; font-size: 11.5px; }
.btn-small:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.progress-wrap {
  height: 6px;
  background: #edf0f6;
  border-radius: 999px;
  margin-top: 15px;
  overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  border-radius: 999px;
  transition: width .12s linear;
}
.progress-text {
  margin-top: 7px;
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ------------------------------ intro card ----------------------------- */

.intro-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(120deg, #eef2ff 0%, #f5f8ff 55%, #eefaf7 100%);
  border: 1px solid #dde4f6;
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}
.intro-card::before {
  content: "";
  position: absolute;
  right: -70px; top: -90px;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 70, 229, .1), transparent 65%);
  pointer-events: none;
}
.intro-card .intro-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  color: var(--accent);
  text-transform: uppercase;
}
.intro-card h2 { margin: 5px 0 7px; font-size: 20px; letter-spacing: -.2px; }
.intro-card p { margin: 0; color: var(--ink-soft); font-size: 13px; position: relative; }
.intro-card .question {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .8);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  font-size: 12.5px;
  position: relative;
}

/* ---------------------------- metric cards ----------------------------- */

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.metric {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 16px 18px 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .18s, box-shadow .18s;
  animation: rise .35s ease both;
}
.metric:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.metric::before {
  content: "";
  position: absolute;
  left: 0; top: 0; right: 0;
  height: 3px;
  background: var(--accent);
  opacity: .85;
}
.metric.sky::before { background: var(--sky); }
.metric.amber::before { background: var(--amber); }
.metric.good::before { background: var(--good); }
.metric-label { font-size: 11.5px; color: var(--muted); }
.metric-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.6px;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.metric-hint { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }
.metric.accent .metric-value { color: var(--accent); }
.metric.sky .metric-value { color: var(--sky); }
.metric.amber .metric-value { color: var(--amber); }
.metric.good .metric-value { color: var(--good); }

.metric:nth-child(2) { animation-delay: .05s; }
.metric:nth-child(3) { animation-delay: .1s; }
.metric:nth-child(4) { animation-delay: .15s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------ card head ------------------------------ */

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.card-head h2 { font-size: 15.5px; margin: 0; letter-spacing: -.1px; }
.card-sub { font-size: 11.5px; color: var(--muted); margin: 3px 0 0; }

/* -------------------------------- table -------------------------------- */

.table-wrap { overflow-x: auto; }
.empty-state { color: var(--muted); font-size: 12.5px; padding: 14px 0; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  background: #f8f9fc;
  letter-spacing: .02em;
}
th:first-child { border-radius: 9px 0 0 0; text-align: left; }
th:last-child { border-radius: 0 9px 0 0; }
td:first-child { text-align: left; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f8faff; }
tbody tr:last-child td { border-bottom: none; }
td.num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
td.bold { font-weight: 700; color: var(--ink); }
.table-title { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin: 16px 0 7px; }
.table-title:first-child { margin-top: 0; }

/* -------------------------- charts & legend ---------------------------- */

.two-col { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
#histogram { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; font-size: 11.5px; color: var(--ink-soft); }
.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-swatch { width: 11px; height: 11px; border-radius: 3.5px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }

/* --------------------------- interpretation ---------------------------- */

.interpretation { font-size: 12.5px; color: var(--ink-soft); }
.interpretation p { margin: 0 0 10px; }
.interpretation strong { color: var(--ink); }
.interpretation .key { color: var(--accent); font-weight: 600; }

.checklist { margin-top: 13px; display: flex; flex-direction: column; gap: 7px; }
.check {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 11.5px;
  background: #f8f9fc;
  color: var(--ink-soft);
  animation: rise .3s ease both;
}
.check-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.check.pass { background: var(--good-soft); color: var(--good); }
.check.pass .check-dot { background: var(--good); box-shadow: 0 0 0 3px rgba(15, 118, 110, .15); }
.check.fail { background: var(--bad-soft); color: var(--bad); }
.check.fail .check-dot { background: var(--bad); box-shadow: 0 0 0 3px rgba(185, 28, 28, .15); }

/* -------------------------------- footer ------------------------------- */

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 6px 0;
  color: var(--muted);
  font-size: 11.5px;
  border-top: 1px solid var(--border);
  margin-top: 26px;
}

/* ------------------------------ responsive ----------------------------- */

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar .card { flex: 1 1 300px; }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .app-shell { padding: 0 14px 20px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .sidebar { flex-direction: column; }
  .sidebar .card { flex: 1 1 auto; }
  .field input { width: 80px; }
  footer { flex-direction: column; }
}
