/* ============================================================
 * style.css · AML Dossier Builder
 *  · 无外链资源（字体/图标全用系统字体 + 内联 SVG）
 *  · 触控目标 ≥44px；375px 无横向滚动；深色模式；打印样式
 * ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #101418;
  --muted: #4a5568;
  --line: #d7dde8;
  --brand: #123a6b;
  --brand-ink: #ffffff;
  --focus: #0b63d6;
  --ok: #14653a;
  --warn: #7a4b00;
  --bad: #9b1c1c;
  --soft: #eef2f8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --panel: #171d27;
    --ink: #eef2f8;
    --muted: #b9c3d4;
    --line: #2c3543;
    --brand: #8fb4ff;
    --brand-ink: #0c1220;
    --focus: #8fb4ff;
    --ok: #7fd6a1;
    --warn: #ffd48a;
    --bad: #ff9aa2;
    --soft: #131924;
  }
}

html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  overflow-wrap: break-word;
}

img, svg { max-width: 100%; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 8px; }
h2, .h2 { font-size: 1.15rem; margin: 22px 0 8px; }
h3 { font-size: 1.05rem; margin: 0 0 8px; }
h4 { font-size: 1rem; margin: 16px 0 6px; }
p { margin: 0 0 10px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 32px; }
#main:focus { outline: none; }

/* ---------- skip link ---------- */
/* 用 transform 藏起来（不是 -9999px 位移），这样任何视口宽度下都不会产生横向溢出 */
.skip {
  position: absolute; left: 0; top: 0; z-index: 30;
  transform: translateY(-130%);
  display: inline-flex; align-items: center; min-height: 44px;
  padding: 10px 16px; background: var(--brand); color: var(--brand-ink);
  border-radius: 0 0 10px 0; font-weight: 600;
  transition: transform .15s ease-in;
}
.skip:focus { transform: translateY(0); }

/* ---------- header ---------- */
.site-head {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}
.head-inner { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1.05rem; }
.tagline { color: var(--muted); font-size: 0.82rem; }
.head-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.nav { display: flex; flex-wrap: wrap; gap: 6px; }
button, .btn, input, select, textarea { font: inherit; color: inherit; }

.navbtn, .langbtn, .btn {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}
.navbtn.is-active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.langsw { display: flex; align-items: center; gap: 6px; }
.langsw-label { color: var(--muted); font-size: 0.82rem; margin-right: 2px; }
.langbtn { min-width: 56px; padding: 10px 10px; font-weight: 600; }
.langbtn.is-active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.small { min-height: 44px; padding: 8px 12px; font-size: 0.92rem; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
button:hover, .btn:hover { filter: brightness(0.97); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- stepper ---------- */
.stepper {
  list-style: none; display: flex; flex-wrap: wrap; gap: 8px;
  margin: 18px 0 14px; padding: 0;
}
.step {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--muted); font-size: 0.9rem;
}
.step.is-current { border-color: var(--brand); color: var(--ink); font-weight: 600; }
.step.is-done { color: var(--ok); }
.step-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--soft); font-size: 0.8rem; font-weight: 700;
}
.step.is-current .step-no { background: var(--brand); color: var(--brand-ink); }

/* ---------- panels & forms ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin: 0 0 16px;
}
.lead { color: var(--muted); }
.muted { color: var(--muted); }
.lead, .muted, .note { overflow-wrap: anywhere; }

fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 6px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 4px; }
.field input[type="text"], .field input[type="search"], .field select, #reg-search, .ci-note input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink);
}
.field.is-invalid input, .field.is-invalid select { border-color: var(--bad); }
.err { color: var(--bad); font-size: 0.85rem; margin: 4px 0 0; min-height: 0; }
.form-err { font-weight: 600; }

/* ---------- risk ---------- */
.risk-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.risk-score { color: var(--muted); }
.badge {
  display: inline-flex; align-items: center; min-height: 28px;
  padding: 2px 10px; border-radius: 999px; font-size: 0.84rem; font-weight: 600;
  border: 1px solid var(--line); background: var(--soft);
}
.badge.risk-low { background: #e6f6ec; color: #14653a; border-color: #b7e3c6; }
.badge.risk-medium { background: #fff5e0; color: #7a4b00; border-color: #f0d9a8; }
.badge.risk-high { background: #fdecec; color: #9b1c1c; border-color: #f2c3c3; }
.badge.st-ok { background: #e6f6ec; color: #14653a; border-color: #b7e3c6; }
.badge.st-gap { background: #fdecec; color: #9b1c1c; border-color: #f2c3c3; }
.badge.due-overdue { background: #fdecec; color: #9b1c1c; border-color: #f2c3c3; }
.badge.due-soon { background: #fff5e0; color: #7a4b00; border-color: #f0d9a8; }
.badge.due-ok { background: #e6f6ec; color: #14653a; border-color: #b7e3c6; }

@media (prefers-color-scheme: dark) {
  .badge.risk-low, .badge.st-ok, .badge.due-ok { background: #12301f; color: #9fe6bb; border-color: #24513a; }
  .badge.risk-medium, .badge.due-soon { background: #33270c; color: #ffd48a; border-color: #5a4318; }
  .badge.risk-high, .badge.st-gap, .badge.due-overdue { background: #361618; color: #ffb3b8; border-color: #5c2528; }
}

.note.warn { color: var(--warn); }
.ok-line { color: var(--ok); font-weight: 600; margin: 6px 0 0; }
.gap-line { color: var(--bad); margin: 6px 0 0; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; max-width: 100%; }
.tbl { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.tbl th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.tbl .num { text-align: right; white-space: nowrap; }

/* ---------- checklist ---------- */
.ci-list { list-style: none; margin: 0 0 16px; padding: 0; }
.ci { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.ci.is-done { border-color: #b7e3c6; }
.ci.is-na { opacity: 0.75; }
.ci-main { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.ci-main input[type="checkbox"] { flex: 0 0 auto; width: 24px; height: 24px; min-height: 24px; margin-top: 2px; }
.ci-text { flex: 1 1 220px; min-width: 0; }
.ci-text label { cursor: pointer; }
.ci-h { color: var(--muted); font-size: 0.9rem; margin: 2px 0 0; }
.ci-badge { flex: 0 0 auto; }
.ci-note { margin-top: 10px; }
.ci-note label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.gap-head { margin: 0 0 6px; }
.bar { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; margin: 0 0 10px; }
.bar > span { display: block; height: 100%; background: var(--brand); }

/* ---------- actions ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0; }
.chain-msg.ok { color: var(--ok); }
.chain-msg.bad { color: var(--bad); }

/* ---------- preview / dossier ---------- */
.preview h3, .print-doc h3 { margin-top: 0; }
dl.meta { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 4px 12px; margin: 0 0 12px; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; }
.checkview { padding-left: 20px; }
.checkview li { margin-bottom: 4px; }

/* ---------- audit ---------- */
.audit-list { list-style: none; margin: 0; padding: 0; }
.audit-list li {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 0.9rem;
}
.audit-list li:last-child { border-bottom: 0; }
.a-ts { color: var(--muted); white-space: nowrap; }
.a-action { font-weight: 600; }
.a-actor { color: var(--muted); }
.a-detail { color: var(--muted); overflow-wrap: anywhere; }
.a-hash { margin-left: auto; font-size: 0.78rem; color: var(--muted); }

/* ---------- register ---------- */
.reg-tools label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 4px; }
.count { margin: 8px 0 0; }
.reg-scroll { max-height: 60vh; overflow-y: auto; overflow-x: hidden; padding-right: 2px; }
.reg-list { list-style: none; margin: 0; padding: 0; }
.reg-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.rc-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; }
.rc-name { font-weight: 600; overflow-wrap: anywhere; }
.rc-ref { color: var(--muted); font-size: 0.85rem; }
.rc-meta { display: grid; grid-template-columns: minmax(90px, 140px) 1fr; gap: 6px 10px; margin: 10px 0; font-size: 0.9rem; }
.rc-meta dt { color: var(--muted); }
.rc-meta dd { margin: 0; }
.rc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.empty { text-align: center; }

/* ---------- help ---------- */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.probe-fig { margin: 0 0 16px; }
.probe-fig img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 12px; }
.probe-fig figcaption { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
.src { padding-left: 20px; }
.src li { margin-bottom: 6px; }
.src-links { list-style: none; padding: 0; margin: 8px 0 0; }
.src-links a {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--brand); overflow-wrap: anywhere;
}

/* ---------- footer ---------- */
.site-foot { border-top: 1px solid var(--line); margin-top: 24px; padding: 16px 0; color: var(--muted); font-size: 0.88rem; }
.site-foot p { margin: 0; }

/* ---------- probe slot ---------- */
#intent-slot { margin-top: 8px; }

/* ---------- print ---------- */
.print-area { display: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media print {
  body { background: #fff; color: #000; }
  .site-head, .site-foot, .no-print, #intent-slot, .stepper { display: none !important; }
  .print-area { display: block !important; padding: 0; }
  .panel, .ci { border-color: #999; box-shadow: none; }
  .wrap { max-width: none; padding: 0; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; }
}

/* ---------- narrow screens ---------- */
@media (max-width: 640px) {
  .head-inner { flex-direction: column; align-items: stretch; }
  .head-tools { flex-direction: column; align-items: stretch; }
  .nav { flex-direction: column; }
  .navbtn { width: 100%; }
  .langsw { justify-content: flex-start; }
  dl.meta, .rc-meta { grid-template-columns: 1fr; gap: 2px; }
  dl.meta dt, .rc-meta dt { margin-top: 6px; }
  h1 { font-size: 1.3rem; }
  .a-hash { margin-left: 0; width: 100%; }
}

@media (max-width: 400px) {
  .actions .btn { width: 100%; }
  .rc-actions .btn { width: 100%; }
}
