:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #fff;
  --ink: #172b48;
  --muted: #506581;
  --line: #dfe7f1;
  --control: #c7d4e5;
  --accent: #1554be;
  --accent-hover: #10449a;
  --soft: #edf4ff;
  --ok: #147254;
  --bad: #ad3039;
  --warn: #845609;
  --radius: 14px;
  --shadow: 0 2px 4px #24457107, 0 8px 22px #24457108;
  font: 16px/1.55 "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
[inert] { cursor: default; }
body { margin: 0; background: var(--bg); color: var(--ink); }
h1, h2, h3, h4 { margin: 0; line-height: 1.32; }
h1 { font-size: clamp(1.75rem, 2.7vw, 2.25rem); letter-spacing: -.035em; }
h2 { font-size: 1.13rem; }
h3 { font-size: 1rem; }
h4 { font-size: .94rem; }
p { margin: .3rem 0 0; }
small { font-size: .81rem; }
button, input, select, textarea { font: inherit; }
button {
  min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid var(--control); border-radius: 8px; padding: .45rem .78rem;
  color: #234062; background: white; cursor: pointer; font-size: .9rem; font-weight: 650;
}
button:hover:not(:disabled) { border-color: #8faedb; background: #f3f8ff; color: var(--accent); }
button:disabled { background: #f4f6f9; color: #657893; border-color: var(--line); cursor: default; }
:where(button, input, select, textarea, summary, a, .drop):focus-visible { outline: 3px solid #77a7fc; outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); color: #fff; }
button.primary:disabled { background: #e5ebf4; color: #526880; border-color: #d5dfed; }
button.quiet { color: var(--accent); border-color: transparent; background: transparent; }
button.danger { color: var(--bad); }
input:not([type=checkbox],[type=radio]), select, textarea {
  width: 100%; min-width: 0; min-height: 40px; padding: .5rem .66rem;
  border: 1px solid var(--control); border-radius: 8px; color: var(--ink); background: #fff;
}
:where(input, textarea)::placeholder { color: #62758f; }
input[type=file]::file-selector-button {
  padding: .35rem .6rem; margin-right: .6rem; border: 1px solid var(--control);
  border-radius: 6px; background: var(--soft); color: var(--accent); font: inherit; cursor: pointer;
}
select {
  appearance: none; padding-right: 1.9rem;
  background: linear-gradient(45deg,transparent 50%,#557395 50%) calc(100% - 16px) 53%/5px 5px no-repeat,
    linear-gradient(135deg,#557395 50%,transparent 50%) calc(100% - 11px) 53%/5px 5px no-repeat,#fff;
}
textarea { resize: vertical; display: block; }
input[type=checkbox], input[type=radio] { width: 1rem; height: 1rem; margin: 0; flex: 0 0 auto; accent-color: var(--accent); }
label { display: block; color: #294362; font-size: .9rem; font-weight: 650; }
label > :is(input, textarea, select) { margin-top: .24rem; }
label.check { display: flex; align-items: center; gap: .45rem; font-weight: 500; }
label.check input { margin: 0; }
.full { width: 100%; }

.frame { width: min(calc(100% - 4rem), 1432px); margin-inline: auto; }
.skip { position: absolute; left: .8rem; top: -8rem; z-index: 6; padding: .5rem; background: white; color: var(--accent); }
.skip:focus { top: .5rem; }
.jump { color: var(--accent); font-size: .9rem; font-weight: 650; padding: .35rem .5rem; text-decoration: none; }
.jump:hover { text-decoration: underline; }
.top {
  position: sticky; top: 0; z-index: 4; background: #fff; border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 7px #24457108;
}
.top-inner { display: flex; align-items: center; gap: clamp(1rem, 4vw, 3.5rem); min-height: 69px; }
.brand { display: flex; align-items: center; gap: .64rem; flex: 0 0 auto; line-height: 1.2; }
.brand strong { display: block; font-size: 1.04rem; letter-spacing: .10em; }
.brand span:not(.brand-mark) { color: var(--muted); font-size: .8rem; }
.brand-mark {
  display: grid; place-items: center; width: 41px; height: 41px; border-radius: 11px;
  background: linear-gradient(145deg,#246ad5,#123b81); color: #fff; font-size: .83rem; font-weight: 750; letter-spacing: .08em;
}
nav { display: flex; align-self: stretch; gap: .32rem; }
nav button {
  position: relative; border: 0; border-radius: 0; background: transparent;
  color: var(--muted); padding-inline: clamp(.55rem,1.25vw,1.15rem);
}
nav button.active { color: var(--accent); background: #f5f9ff; }
nav button.active::after { content:""; position: absolute; height: 3px; inset: auto .55rem 0; background: var(--accent); border-radius: 3px 3px 0 0; }
.model-status {
  margin-left: auto; display: grid; justify-items: start; gap: 0; min-width: 0; max-width: 290px;
  padding: .32rem .7rem; text-align: left; line-height: 1.35; background: #f8faff;
}
.model-line { display: flex; align-items: center; gap: .42rem; min-width: 0; max-width: 100%; }
.model-line strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-status small { color: var(--muted); white-space: normal; }
.dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: #7c8da6; }
.dot.ready { background: #168658; }
.dot.exhausted { background: #be3546; }

.page { padding: 1.8rem 0 3rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .8rem; margin-bottom: 1.3rem; }
.page-head p, .muted { color: var(--muted); }
.page-head .eyebrow { margin: 0 0 .28rem; color: var(--accent); font-size: .83rem; font-weight: 700; }
.page-head h1 + p { margin-top: .38rem; }
.muted { font-size: .875rem; }
.workspace { display: grid; grid-template-columns: minmax(350px, 5fr) minmax(445px, 7fr); align-items: start; gap: 1.25rem; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow); }
.panel > * + * { margin-top: .72rem; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; margin-bottom: .8rem; }
.panel-head + * { margin-top: 0; }
.panel-head p { margin-top: .2rem; }
.panel-actions { border-top: 1px solid #edf1f7; padding-top: .72rem; }
.panel-actions button { margin-left: auto; }
.work-panel { scroll-margin-top: 85px; }
.identity-fields { grid-template-columns: repeat(3,minmax(0,1fr)); }
.stack { display: grid; align-content: start; gap: .86rem; min-width: 0; }
.compact { gap: .55rem; }
.grid { display: grid; gap: .66rem; }
.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.three { grid-template-columns: repeat(3,minmax(0,1fr)); }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: .48rem; }
.row input:not([type=checkbox],[type=radio]), .row select { flex: 1; min-width: 115px; }
.split { justify-content: space-between; }
.split .message { flex: 1; min-width: min(100%, 155px); }
.message { font-size: .875rem; color: var(--muted); margin-top: .35rem; overflow-wrap: anywhere; }
.message:empty { display: none; }
.message.bad, .bad { color: var(--bad); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }

.drop {
  position: relative; display: flex; align-items: center; justify-content: center; gap: .82rem; padding: .95rem;
  min-height: 77px; border: 1.5px dashed #a2b9da; border-radius: 10px; background: #f7faff;
  cursor: pointer; color: var(--accent);
}
.drop:hover, .drop.drag { background: #eaf3ff; border-color: #6393d7; }
.drop input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
.drop small { display: block; color: var(--muted); font-weight: 400; }
.drop-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 9px; background: #e7f0ff; font-size: 1.25rem; }
.thumbs { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .45rem; }
.thumbs:empty { display: none; }
.thumb { min-width: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #f8faff; }
.thumb img { display: block; width: 100%; aspect-ratio: 1.23; object-fit: contain; background: #fff; }
.thumb.fault { border-color: #d9868e; }
.thumb .row { padding: .22rem; justify-content: space-evenly; gap: .15rem; }
.thumb button { min-height: 28px; padding: .1rem .24rem; font-size: .875rem; }
.thumb small { display: block; padding: .25rem; color: var(--bad); overflow-wrap: anywhere; }
.image-preview { display: block; width: 100%; max-height: 68vh; object-fit: contain; background: #f4f7fb; border-radius: 9px; }
.image-evidence { padding-inline-start: 1.3rem; margin-block: .35rem 0; }
.evidence-grid label { min-width: 0; }
fieldset { border: 1px solid var(--line); border-radius: 9px; padding: .42rem .65rem .62rem; margin: 0; min-width: 0; }
legend { font-size: .875rem; font-weight: 650; padding: 0 .25rem; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem .83rem; }
.module-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .4rem; padding: .2rem 0 0; border: 0; }
.module-options legend { padding: 0; }
.module-option {
  display: flex; align-items: center; gap: .37rem; padding: .47rem .44rem; border: 1px solid var(--line);
  border-radius: 8px; background: #fafcff; font-weight: 550; cursor: pointer;
}
.module-option:has(input:checked) { color: var(--accent); border-color: #b7cef2; background: var(--soft); }
.module-option input { margin: 0; }
details { min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: #fcfdff; padding: .5rem .66rem; }
summary { cursor: pointer; font-size: .9rem; font-weight: 650; }
summary small { margin-left: .35rem; color: var(--muted); font-weight: 400; }
details[open] > summary { margin-bottom: .62rem; }
.question { display: grid; gap: .27rem; }
.hint, .callout { background: var(--soft); color: #264d80; border-radius: 9px; padding: .65rem .74rem; font-size: .89rem; overflow-wrap: anywhere; }
.hint strong { display: block; }
.startup { margin-top: .8rem; border: 1px solid #bbcff0; }
.startup button { margin-top: .45rem; }
.chips { display: flex; flex-wrap: wrap; gap: .37rem; }
.chip, .counter, .tag {
  display: inline-flex; align-items: center; gap: .24rem; width: fit-content; flex: 0 0 auto;
  border-radius: 99px; padding: .17rem .51rem; color: #395575; background: #edf3fb; font-size: .81rem;
}
.chip button { min-height: 22px; border: 0; padding: 0 .25rem; margin: 0; background: transparent; }
.counter { font-variant-numeric: tabular-nums; }
.counter.bad, .tag.bad { background: #fbecee; color: var(--bad); }
.tag.ok { background: #e7f5ee; color: var(--ok); }
.tag.warn { background: #fff3db; color: var(--warn); }

.result-top { border-top: 3px solid var(--accent); padding-top: .91rem; }
progress { width: 100%; height: 7px; display: block; border: 0; border-radius: 99px; overflow: hidden; background: #e7eef8; }
progress::-webkit-progress-bar { background: #e7eef8; }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
.downloads button, .result-tools button { min-height: 34px; font-size: .875rem; padding: .34rem .62rem; }
.downloads > span { margin-right: .2rem; }
.result-stack { gap: .62rem; }
.result-card { padding: .78rem 1rem; }
.result-card .panel-head { align-items: center; margin-bottom: 0; }
.result-card .module-label { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .55rem; }
.result-card .module-label p { margin: 0; }
.result-card:not(.pending) .panel-head { margin-bottom: .72rem; }
.result-card.pending .module-status { background: #f1f4f9; }
.result-text { line-height: 1.55; background: #fbfdff; }
.result-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .48rem; }
.coverage-panel { padding-block: .87rem; }
.empty { padding: 1.45rem .85rem; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); }
.stat { border: 1px solid var(--line); border-radius: 9px; background: #f7faff; padding: .66rem .72rem; min-width: 0; overflow-wrap: anywhere; }
.stat b { display: block; margin-top: .15rem; color: #164eaa; font-size: 1.09rem; }
.stat small { color: var(--muted); }

.table-wrap { overflow: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 9px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
td, th { border-bottom: 1px solid var(--line); padding: .51rem .62rem; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
th { background: #eff4fb; color: #385571; font-weight: 650; white-space: nowrap; }
tbody > tr:last-child > td { border-bottom: 0; }
tbody tr:hover { background: #f7faff; }
.cards { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,238px),1fr)); gap: .69rem; }
.cards > article { min-width: 0; padding: .85rem; border: 1px solid var(--line); border-radius: 10px; background: #fcfdff; }
.cards article > * + * { margin-top: .43rem; }
.filters { display: grid; grid-template-columns: minmax(180px,2fr) repeat(3,minmax(135px,1fr)); gap: .6rem; }
.filter-ranges { display: grid; grid-template-columns: repeat(auto-fit,minmax(134px,1fr)); gap: .62rem; }
.pagination { justify-content: flex-end; }
.subnav { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .78rem; padding: .36rem; border: 1px solid var(--line); border-radius: 10px; background: #eaf0f8; }
.subnav button { border-color: transparent; background: transparent; }
.subnav button.active { border-color: #c4d7f3; color: var(--accent); background: white; box-shadow: 0 2px 5px #18365d12; }
.rules-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem; align-items: start; }
.rule-body { white-space: pre-wrap; overflow-wrap: anywhere; color: #2a4566; }
.scroller { max-height: 370px; overflow: auto; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,144px),1fr)); gap: .58rem; }
.trend-graph { height: 105px; width: 100%; display: block; }
dialog {
  width: min(760px,calc(100% - 1.5rem)); max-height: min(85vh,900px); overscroll-behavior: contain;
  padding: 1.12rem; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); box-shadow: 0 18px 70px #15243e46;
}
dialog::backdrop { background: #10203973; }
.toast { position: fixed; bottom: 1.1rem; right: 1.1rem; z-index: 5; max-width: min(510px,90vw); padding: .7rem .9rem; background: #15376c; color: #fff; border-radius: 9px; box-shadow: 0 6px 20px #182b4e38; }

@media (max-width: 1080px) {
  .frame { width: calc(100% - 2rem); }
  .workspace { grid-template-columns: minmax(325px,5fr) minmax(365px,6fr); gap: .85rem; }
  .top-inner { gap: 1rem; }
}
@media (max-width: 840px) {
  .frame { width: calc(100% - 1.4rem); }
  .top { position: static; }
  .top-inner { flex-wrap: wrap; gap: .45rem .62rem; padding-top: .55rem; }
  nav { order: 2; width: 100%; flex: 1 0 100%; overflow: auto; }
  nav button { flex: 1 0 auto; }
  .model-status { max-width: min(59%, 290px); }
  .workspace, .rules-list { grid-template-columns: minmax(0,1fr); }
  .filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .page { padding-top: 1.18rem; }
}
@media (max-width: 440px) {
  .panel { padding: .8rem; }
  .three, .module-options { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .thumbs { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .brand { gap: .35rem; }
  .brand-mark { width: 34px; height: 34px; }
}
