:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #61707e;
  --line: #d8e0e7;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --accent: #0f6b5f;
  --accent-dark: #0a4c43;
  --danger: #b42318;
  --amber: #b54708;
  --radius: 8px;
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, .button-link {
  border: 0; border-radius: var(--radius); background: var(--accent); color: #fff;
  padding: .62rem .9rem; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; min-height: 38px;
}
button:hover, .button-link:hover { background: var(--accent-dark); }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.ghost:hover { background: #e8f2f0; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius);
  padding: .58rem .65rem; background: #fff; min-height: 38px;
}
textarea { resize: vertical; }
label { display: block; font-size: .88rem; color: var(--muted); }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; padding: .75rem max(1rem, 4vw);
  background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: .5rem; white-space: nowrap; }
.brand span { color: var(--muted); font-size: .82rem; }
nav { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.nav-link { background: transparent; color: var(--muted); }
.nav-link.active { background: #e8f2f0; color: var(--accent-dark); font-weight: 700; }
main { max-width: 1280px; margin: 0 auto; padding: 1.25rem; }
.view { display: none; }
.view.active { display: block; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: .25rem 0 1rem; }
h1, h2 { margin-top: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.08rem; }
article { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
.split { display: grid; grid-template-columns: minmax(280px, 38%) 1fr; gap: 1rem; align-items: start; }
.split > * { min-width: 0; }
.stack { display: grid; gap: .65rem; }
.stack button { justify-self: start; }
.field-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .65rem; }
.toolbar { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.toolbar select[required], .toolbar input[type="date"] { min-width: 0; }
.checkbox { display: flex; align-items: center; gap: .5rem; }
.checkbox input { width: 18px; height: 18px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1rem; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; }
.metric span { display: block; color: var(--muted); font-size: .85rem; }
.metric strong { display: block; font-size: 1.7rem; margin-top: .3rem; }
.table-wrap { overflow: auto; max-height: 500px; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .65rem .7rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: #edf3f5; z-index: 1; }
td.wrap, th.wrap { white-space: normal; min-width: 180px; }
.empty { padding: 1rem; color: var(--muted); text-align: center; }
.error { color: var(--danger); min-height: 1.2em; }
.success { color: var(--accent-dark); }
.warning { color: var(--amber); }
.hidden { display: none !important; }
.score-badge { display: inline-flex; min-width: 52px; justify-content: center; border-radius: 999px; padding: .2rem .45rem; color: #fff; font-weight: 700; }
.flow { padding-left: 1.2rem; }
.flow li { margin: .45rem 0; }
.fact { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.fact span { display: block; margin-top: .35rem; }
.compact-result { font-size: .88rem; white-space: pre-wrap; }
.report-output { display: grid; gap: 1rem; }
.report-head { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: .6rem; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 72px; gap: .6rem; align-items: center; margin: .45rem 0; }
.bar { height: 10px; background: var(--accent); border-radius: 999px; min-width: 2px; }
.bar-track { background: #e4ebee; border-radius: 999px; padding: 0; height: 10px; }
.login-screen { position: fixed; inset: 0; display: grid; place-items: center; background: #20313b; padding: 1rem; }
.login-screen[hidden] { display: none; }
.login-box { width: min(92vw, 380px); background: #fff; padding: 1.5rem; border-radius: var(--radius); display: grid; gap: .65rem; }
.login-box p { margin: 0; color: var(--muted); }

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .split, .field-grid, .metrics, .report-head { grid-template-columns: 1fr; }
  .table-wrap { max-width: 100%; }
  .toolbar { grid-template-columns: 1fr; }
  .toolbar button, .stack button { width: 100%; }
  .brand { justify-content: space-between; width: 100%; }
  th, td { white-space: normal; min-width: 0; }
}
