/* 要素式文书向导 —— 清爽、克制，像一份排好的表单 */
:root {
  --ink: #15171c; --ink-2: #40454f; --muted: #767d8a; --line: #e4e7ec;
  --bg: #f5f6f8; --surface: #fff; --accent: #1f4fd8; --accent-soft: #eef2fe;
  --ok: #157347; --warn: #9a6700; --bad: #b02a37;
  --radius: 10px;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.6; }
button, input, select, textarea { font: inherit; color: inherit; }

/* 顶栏 */
.top { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
       padding: 12px 20px; display: flex; align-items: center; gap: 14px; }
.top h1 { font-size: 16px; margin: 0; font-weight: 600; letter-spacing: .01em; }
.top .meta { color: var(--muted); font-size: 12.5px; }
.top .spacer { flex: 1; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 13px; cursor: pointer;
       font-size: 13.5px; white-space: nowrap; }
.btn:hover { border-color: #c9cfd8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: .45; cursor: default; }
.btn.ghost { border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: #f0f2f5; }

/* 选文书 */
.pick { max-width: 980px; margin: 0 auto; padding: 26px 20px 60px; }
.pick h2 { font-size: 20px; margin: 4px 0 6px; font-weight: 600; }
.pick p.lead { color: var(--muted); margin: 0 0 20px; font-size: 13.5px; }
.search { display: flex; gap: 10px; margin-bottom: 14px; }
.search input { flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; background: #fff; }
.cats { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.cat { border: 1px solid var(--line); background: #fff; color: var(--ink-2); border-radius: 999px;
       padding: 5px 12px; font-size: 12.5px; cursor: pointer; }
.cat[aria-pressed="true"] { background: var(--accent-soft); border-color: #c6d4fb; color: var(--accent); }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.doc { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
       padding: 13px 15px; cursor: pointer; }
.doc:hover { border-color: #b9c3d4; }
.doc b { display: block; font-weight: 600; font-size: 14.5px; }
.doc span { color: var(--muted); font-size: 12.5px; }

/* 填表 */
.fill { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; max-width: 1120px; margin: 0 auto; padding: 20px; }
@media (max-width: 860px) { .fill { grid-template-columns: 1fr; } .steps { position: static !important; } }
.steps { position: sticky; top: 74px; align-self: start; background: var(--surface); border: 1px solid var(--line);
         border-radius: var(--radius); padding: 10px; }
.steps button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px;
                border-radius: 7px; cursor: pointer; font-size: 13.5px; color: var(--ink-2); }
.steps button[aria-current="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.steps button span { float: right; color: var(--muted); font-weight: 400; font-size: 12px; }
.form { min-width: 0; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.group > h3 { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px;
              font-weight: 600; color: var(--ink-2); }
.fields { padding: 6px 16px 14px; }
.field { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; align-items: start;
         padding: 8px 0; border-bottom: 1px dashed #eef0f3; }
.field:last-child { border-bottom: 0; }
.field > label { padding-top: 8px; color: var(--ink-2); font-size: 13.5px; }
.field .ctl { min-width: 0; }
.field input[type=text], .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.field textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.field input:focus, .field textarea:focus { outline: 2px solid #cdd9fb; border-color: var(--accent); }
.field.invalid input { border-color: var(--bad); }
.date { display: flex; gap: 6px; align-items: center; }
.date input { width: 72px; text-align: center; }
.opts { display: flex; flex-wrap: wrap; gap: 7px; padding-top: 4px; }
.opt { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 13px; cursor: pointer; font-size: 13.5px; }
.opt[aria-pressed="true"] { background: var(--accent-soft); border-color: #c6d4fb; color: var(--accent); font-weight: 600; }
.note { color: var(--muted); font-size: 12px; margin-top: 4px; }
.note.bad { color: var(--bad); }
.note.warn { color: var(--warn); }
.foot { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.foot .spacer { flex: 1; }
.progress { height: 4px; background: #e9ecf1; border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .25s; }

/* 完成 */
.done { max-width: 640px; margin: 60px auto; background: var(--surface); border: 1px solid var(--line);
        border-radius: 14px; padding: 28px; }
.done h2 { margin: 0 0 8px; font-size: 19px; }
.done .log { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted);
             white-space: pre-wrap; margin-top: 14px; }
.hidden { display: none !important; }

/* ---------------- 预览 ---------------- */
.fill { grid-template-columns: 200px minmax(0, 1fr) minmax(430px, 1fr); align-items: start; max-width: 1600px; }
@media (max-width: 1240px) {
  .fill { grid-template-columns: 200px minmax(0, 1fr); }
  .preview { position: fixed; top: 0; right: 0; height: 100vh; width: min(620px, 94vw); z-index: 40;
             border-left: 1px solid var(--line); border-radius: 0; box-shadow: -14px 0 34px rgba(20,24,32,.14); }
  .preview.hidden { display: none; }
}
@media (max-width: 860px) {
  .fill { grid-template-columns: 1fr; }
  .steps { position: static; display: flex; overflow-x: auto; gap: 4px; }
  .steps button { width: auto; white-space: nowrap; }
  .steps button span { float: none; margin-left: 6px; }
}
.preview { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
           border-radius: var(--radius); position: sticky; top: 74px; max-height: calc(100vh - 92px); }
.pv-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line);
          font-size: 12.5px; color: var(--muted); }
.pv-bar .spacer { flex: 1; }
.pv-bar button { padding: 4px 9px; font-size: 12.5px; }
.pv-zoom { min-width: 42px; text-align: center; }
.pv-scroll { overflow: auto; padding: 14px; background: #eef0f3; flex: 1; }
.pv-pages { transform-origin: top left; }
.pv-page { position: relative; background: #fff; margin: 0 auto 14px; box-shadow: 0 1px 3px rgba(20,24,32,.16);
           color: #16181d; font-size: 10.5pt; line-height: 1.5; overflow: hidden; }
.pv-page table { border-collapse: collapse; width: 100%; }
.pv-page td { vertical-align: top; font-size: 10.5pt; }   /* 内边距按模板的 tblCellMar，不自己加 */
.pv-page .pv-no { position: absolute; right: 6px; bottom: 4px; font-size: 9px; color: #b6bcc6; }
.pv-empty { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }
