/* ============================================================
 * 商标代理委托书 · 普推知产 · 界面样式
 * 设计 token：商务蓝 / 中性灰 / 8px 圆角体系
 * 断点：360 / 768 / 1024 / 1440（移动优先）
 * ============================================================ */

:root {
  --brand:        #1557D6;
  --brand-deep:   #0B3F9E;
  --brand-soft:   #EAF1FF;
  --brand-tint:   #F5F8FF;
  --ink:          #1B2333;
  --ink-2:        #4C5870;
  --ink-3:        #8A93A6;
  --line:         #E2E7F0;
  --line-strong:  #CDD6E5;
  --bg:           #F4F6FA;
  --stage:        #E9EDF4;
  --white:        #FFFFFF;
  --danger:       #C8362F;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 2px 12px rgba(24, 48, 92, .06);
  --shadow-paper: 0 6px 28px rgba(24, 40, 76, .14);
  --header-h:     60px;
  --footer-h:     34px;
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-doc: "Songti SC", "SimSun", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------------- 顶栏 ---------------- */
.app-header {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 24px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--brand); color: #fff; flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; font-weight: 700; letter-spacing: .3px; }
.brand-text small { font-size: 11.5px; color: var(--ink-3); }
.header-meta { display: flex; align-items: center; gap: 18px; }
.privacy-pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  background: #EAF6EF; color: #1E7A47; font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.link-btn { border: 0; background: none; color: var(--brand); font-size: 13px; padding: 8px 4px; }
.link-btn:hover { color: var(--brand-deep); text-decoration: underline; }

/* ---------------- 工作台 ---------------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 436px) minmax(0, 1fr);
  gap: 16px;
  height: calc(100dvh - var(--header-h) - var(--footer-h));
  padding: 16px;
}
.panel {
  min-height: 0; min-width: 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ---------------- 左：表单 ---------------- */
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 20px 16px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0 0 3px; font-size: 16px; font-weight: 700; }
.panel-head p { margin: 0; font-size: 12px; color: var(--ink-3); }
.required-note { font-size: 12px; color: var(--ink-3); white-space: nowrap; padding-top: 3px; }
.required-note i, .field label i, .help-list i { color: var(--danger); font-style: normal; }
.form-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px 24px; }
.form-scroll::-webkit-scrollbar, .paper-stage::-webkit-scrollbar { width: 9px; height: 9px; }
.form-scroll::-webkit-scrollbar-thumb, .paper-stage::-webkit-scrollbar-thumb { background: #C9D2E2; border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }

.fsec {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 18px; margin: 0 0 16px; min-width: 0;
}
.fsec:last-child { margin-bottom: 0; }
.fsec legend {
  display: flex; align-items: center; gap: 8px;
  padding: 0 6px; font-size: 13.5px; font-weight: 700; color: var(--ink);
}
.step-no {
  width: 20px; height: 20px; border-radius: 6px;
  display: inline-grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 700;
}
.legend-tip { font-size: 11.5px; font-weight: 400; color: var(--ink-3); }

.field { min-width: 0; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; margin-bottom: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field input[type="text"], .field input[type="tel"], .field input[type="date"],
.field textarea, .search-wrap input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--white); color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea {
  display: block; resize: none; overflow-y: hidden;
  /* 与界面字体统一：JS 会以 14px 为基准，文字多时自动缩小到 11px */
  font-family: inherit; font-size: inherit;
  line-height: 1.55; max-height: 148px;
}
.field input::placeholder, .field textarea::placeholder, .search-wrap input::placeholder { color: #A7AFBE; }
.field input:focus, .field textarea:focus, .search-wrap input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(21, 87, 214, .12);
}
.field input.is-invalid, .field textarea.is-invalid {
  border-color: var(--danger); box-shadow: 0 0 0 3px rgba(200, 54, 47, .10);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row .field { margin-bottom: 14px; }
.opt-tag {
  display: inline-block; margin-left: 5px; padding: 1px 6px;
  border-radius: 4px; background: var(--bg); color: var(--ink-3);
  font-size: 10.5px; font-weight: 500; vertical-align: 1px;
}
.form-note {
  margin: 0 0 16px; padding: 10px 12px;
  border: 1px solid var(--brand-soft); border-radius: var(--radius-sm);
  background: var(--brand-tint);
  font-size: 12px; line-height: 1.65; color: var(--ink-2);
}
.form-note--seal {
  margin: 2px 0 0; background: var(--bg); border-style: dashed;
  border-color: var(--line); color: var(--ink-3); font-size: 11.5px;
}

/* 事项筛选 */
.items-toolbar { margin: 4px 0 12px; }
.search-wrap { position: relative; display: block; }
.search-wrap svg { position: absolute; left: 12px; top: 14px; color: var(--ink-3); pointer-events: none; }
.search-wrap input { padding-left: 34px; }
/* 分组按钮自动换行，全部可见，不再横向裁切 */
.group-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-bottom: 2px; }
.chip {
  flex: 0 0 auto; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--white); color: var(--ink-2); font-size: 12px; white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* 事项复选 */
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.check-item {
  position: relative; display: flex; align-items: flex-start; gap: 8px;
  min-height: 44px; padding: 9px 7px; border-radius: var(--radius-sm);
  font-size: 12px; line-height: 1.45; color: var(--ink-2);
  cursor: pointer; transition: background .18s;
}
.check-item:hover { background: var(--brand-tint); }
.check-item.is-checked { color: var(--ink); font-weight: 600; }
.check-item.is-flash { background: var(--brand-soft); }
.check-item input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box {
  width: 16px; height: 16px; flex: none; margin-top: 1px;
  border: 1.5px solid var(--line-strong); border-radius: 50%; background: #fff;
  display: grid; place-items: center; transition: background .12s, border-color .12s;
}
.check-box::after {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #fff; opacity: 0; transform: scale(.4);
  transition: opacity .12s, transform .12s;
}
.check-item input:checked + .check-box { background: var(--brand); border-color: var(--brand); }
.check-item input:checked + .check-box::after { opacity: 1; transform: scale(1); }
.check-item input:focus-visible + .check-box { outline: 2px solid var(--brand); outline-offset: 2px; }
.check-item .it-label { flex: 1; min-width: 0; }
.no-result { margin: 16px 0; text-align: center; font-size: 12.5px; color: var(--ink-3); }
.items-actions {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line);
}
.mini-btn {
  min-height: 34px; padding: 0 11px; border: 1px solid var(--line-strong);
  border-radius: 7px; background: #fff; color: var(--ink-2); font-size: 12px;
}
.mini-btn:hover { border-color: var(--brand); color: var(--brand); }
/* 受托机构「保存为默认」 */
.default-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 7px;
}
.default-row .mini-btn { min-height: 40px; }
.default-clear {
  min-height: 40px; padding: 0 4px; border: 0; background: none;
  color: var(--ink-3); font-size: 11.5px; text-decoration: underline; cursor: pointer;
}
.default-clear:hover { color: var(--danger); }
.default-clear[hidden] { display: none; }
.default-tip {
  flex: 1 1 120px; min-width: 0; font-size: 11.5px; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.selected-count {
  margin-left: auto; min-width: 0; flex: 1 1 120px; text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; font-weight: 600; color: var(--brand);
}
.other-field { margin-top: 14px; padding: 12px; border-radius: var(--radius-sm); background: var(--brand-tint); }
.other-field label { color: var(--brand-deep); }

.form-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 20px; border-top: 1px solid var(--line); background: #FBFCFE;
}
.text-btn { border: 0; background: none; color: var(--ink-2); font-size: 12.5px; padding: 8px 0; }
.text-btn:hover { color: var(--danger); }
.draft-status { font-size: 11.5px; color: var(--ink-3); }

/* ---------------- 站点页脚 ---------------- */
.site-footer {
  height: var(--footer-h); flex: none;
  display: flex; align-items: center; justify-content: center;
  padding: 0 16px; background: var(--white);
  border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: 11.5px; letter-spacing: .2px;
  text-align: center;
}
.site-footer small { font-size: inherit; }

/* ---------------- 右：预览 ---------------- */
.preview-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 60px; padding: 10px 16px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.preview-title { font-size: 14px; font-weight: 700; white-space: nowrap; }
.preview-title span { font-weight: 400; font-size: 11.5px; color: var(--ink-3); margin-left: 6px; }
.zoom-ctrl { display: inline-flex; align-items: center; gap: 4px; }
.zoom-btn {
  width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--ink-2); font-size: 15px; line-height: 1;
}
.zoom-btn:hover { border-color: var(--brand); color: var(--brand); }
.zoom-btn.zoom-fit { width: auto; padding: 0 9px; font-size: 12px; }
#zoomLabel { min-width: 42px; text-align: center; font-size: 12px; color: var(--ink-2); }
.export-ctrl { display: inline-flex; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; border: 1px solid transparent;
  transition: background .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(21, 87, 214, .22); }
.btn-primary:hover { background: var(--brand-deep); }
.btn-primary[disabled] { opacity: .65; cursor: wait; }

.paper-stage {
  flex: 1; min-height: 0; overflow: auto;
  display: flex; flex-direction: column; align-items: center;
  padding: 26px 20px 12px; background: var(--stage);
}
.paper-scaler { position: relative; width: 794px; height: 1123px; flex: none; }
.paper {
  position: absolute; top: 0; left: 0;
  width: 794px; height: 1123px;
  padding: 74px 62px 56px;
  background: #fff; color: #000;
  font-family: var(--font-doc);
  box-shadow: var(--shadow-paper);
  transform-origin: top left;
  overflow: hidden;
}
.stage-tip { flex: none; margin: 18px 0 4px; font-size: 11.5px; color: #7E889C; }

/* ---- A4 纸面：严格复刻空白模板 ---- */
.doc-title {
  margin: 0 0 42px; text-align: center;
  font-size: 27px; font-weight: 700; letter-spacing: 5px; line-height: 1.4;
}
/* 短内容恒为 15px（对标原件印刷字号）；文字多时由 JS 整体自动缩小，下限 11px */
.declare { font-size: 15px; }
/* 整条声明是一条连续内联流：文字依次向右排满，再「横向顺延」折到下一行继续，
 * 不在「现委托」后强制断行；长内容不挤压固定文字、不截断。 */
.declare-line {
  display: block; margin: 0; line-height: 2.15;
  white-space: normal; overflow-wrap: break-word; word-break: normal;
  text-wrap: pretty;   /* 每行尽量排满，同时避免末尾出现孤字 */
}
.declare-line .lbl { white-space: normal; }
/* 固定短语整体不拆：内容多时整块顺延到下一行，不出现破词 */
.declare-line .lbl.lbl-keep { white-space: nowrap; }
/* 填空允许换行，长内容不再被省略号截断；字号由 JS 自适应 */
.fill {
  display: inline-block; min-height: 20px; line-height: 20px;
  padding: 0 5px; border-bottom: 1px solid #000;
  text-align: center; vertical-align: baseline;
  white-space: normal; overflow-wrap: anywhere; word-break: break-word;
  text-wrap: balance;
  font-family: var(--font-doc);
}
/* 声明区填空改为 inline：下划线随文字逐行延伸，横向顺延不截断 */
.declare .fill {
  display: inline; min-height: 0; line-height: inherit;
  padding: 0 4px; text-align: left;
  overflow-wrap: break-word; word-break: normal;
}
/* 未填写时仍保留一段可见横线 */
.declare .fill:empty::before {
  content: "\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0";
}

.items-print {
  display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px;
  margin-top: 32px;
}
.items-col { display: flex; flex-direction: column; gap: 9px; }
.poa-item { display: flex; align-items: flex-start; gap: 5px; font-size: 12.2px; line-height: 1.45; }
.tick {
  width: 11px; height: 11px; flex: none; margin-top: 2px;
  border: 1px solid #111; border-radius: 1px;
  text-align: center; line-height: 9px; font-size: 11px; font-weight: 700;
  font-family: Arial, "Helvetica Neue", sans-serif;
  color: transparent;
}
.poa-item.is-checked .tick { color: #111; }
.it-text { flex: 1; min-width: 0; }
.inline-fill {
  display: inline-block; min-width: 128px; max-width: 100%; min-height: 14px;
  margin-left: 2px; border-bottom: 1px solid #000;
  vertical-align: baseline;
  white-space: normal; overflow-wrap: anywhere; word-break: break-word;
}

.doc-footer { display: flex; justify-content: space-between; gap: 30px; margin-top: 42px; align-items: flex-start; }
.foot-left { flex: 1 1 auto; min-width: 0; max-width: 384px; }
.foot-left p { display: flex; align-items: baseline; gap: 8px; margin: 0 0 15px; font-size: 14px; }
.foot-label { width: 82px; flex: none; white-space: nowrap; }
.fill-foot { flex: 1; min-width: 60px; }
.foot-right { width: 246px; display: flex; flex-direction: column; align-items: center; }
.seal-label { align-self: flex-start; margin: 0 0 4px; font-size: 14px; }
.seal-box { width: 100%; height: 92px; }
.date-line { display: flex; align-items: baseline; gap: 4px; margin: 22px 0 0; font-size: 14px; }
.fill-year { width: 46px; flex: none; }
.fill-md { width: 28px; flex: none; }

/* ---------------- 移动端吸底导航 ---------------- */
.mobile-bar { display: none; }

/* ---------------- 弹窗 / 提示 ---------------- */
.help-dialog {
  width: min(480px, calc(100vw - 32px)); padding: 0 22px 22px;
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 60px rgba(20, 36, 72, .22); color: var(--ink);
}
.help-dialog::backdrop { background: rgba(20, 30, 50, .42); }
.help-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 12px; border-bottom: 1px solid var(--line); }
.help-head h3 { margin: 0; font-size: 16px; }
.close-btn { border: 0; background: none; font-size: 24px; line-height: 1; color: var(--ink-3); padding: 0 4px; }
.help-list { padding-left: 20px; margin: 16px 0; font-size: 13px; line-height: 1.8; color: var(--ink-2); }
.help-list li { margin-bottom: 8px; }
.help-list strong { color: var(--ink); }
.privacy-note { background: #F0F7F2; border-radius: 10px; padding: 12px 14px; font-size: 12.5px; color: #2A6042; }
.privacy-note strong { display: block; margin-bottom: 4px; }
.privacy-note p { margin: 0; line-height: 1.7; }
.help-foot { margin: 14px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--ink-3); }
.toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 60;
  transform: translate(-50%, 14px); opacity: 0; pointer-events: none;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 18px; border-radius: 10px;
  background: #25324A; color: #fff; font-size: 13px; line-height: 1.5;
  box-shadow: 0 8px 26px rgba(20, 30, 50, .25);
  transition: opacity .2s, transform .2s;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #A92D27; }
.noscript { margin: 16px; padding: 14px; border-radius: 10px; background: #FFF4E5; color: #8A5A10; font-size: 13px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1439px) {
  .workspace { grid-template-columns: minmax(360px, 410px) minmax(0, 1fr); gap: 12px; padding: 12px; }
  .check-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1023px) {
  body { overflow: hidden; }
  .app-header { padding: 0 16px; }
  .workspace {
    display: block; height: calc(100dvh - var(--header-h) - 62px - var(--footer-h));
    padding: 12px; overflow: hidden;
  }
  .panel { height: 100%; }
  .panel:not(.is-active) { display: none; }
  .form-scroll { padding: 16px; }
  .check-grid { grid-template-columns: 1fr 1fr; }
  .preview-bar { min-height: 56px; }
  .paper-stage { padding: 18px 12px; }
  .mobile-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(3, 1fr);
    height: 62px; padding-bottom: env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid var(--line);
    box-shadow: 0 -3px 14px rgba(24, 48, 92, .06);
  }
  .mb-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 44px; border: 0; background: none; color: var(--ink-3); font-size: 11px;
  }
  .mb-item.is-active { color: var(--brand); font-weight: 600; }
  .toast { bottom: 80px; }
}

@media (max-width: 767px) {
  .brand-text small { display: none; }
  .header-meta { gap: 10px; }
  .privacy-pill { font-size: 11px; padding: 0 8px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .check-grid { grid-template-columns: 1fr; }
  .form-note { font-size: 11.5px; padding: 9px 10px; }
  .preview-title span { display: none; }
  .zoom-ctrl { display: inline-flex; }
  .zoom-btn.zoom-fit { padding: 0 7px; }
  #zoomLabel { min-width: 34px; font-size: 11px; }
  .export-ctrl { width: 100%; }
  .export-ctrl .btn { flex: 1; }
  .paper-stage { padding: 14px 10px; }
  .stage-tip { display: none; }
  .form-footer { padding: 10px 16px; }
  .default-row .mini-btn, .default-clear { min-height: 44px; }
}

/* ---------------- 打印 / 另存为 PDF 兜底 ---------------- */
@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { width: 210mm; height: 297mm; background: #fff !important; overflow: visible !important; }
  body > *:not(main) { display: none !important; }
  .site-footer { display: none !important; }  /* 版权仅属于工具界面，不打印进委托书 */
  .workspace { display: block !important; height: auto !important; padding: 0 !important; margin: 0 !important; }
  .panel { border: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
  .form-panel, .preview-bar, .stage-tip { display: none !important; }
  .preview-panel { display: block !important; background: #fff !important; }
  .paper-stage { display: block !important; overflow: visible !important; padding: 0 !important; background: #fff !important; }
  .paper-scaler { position: static !important; width: 794px !important; height: 1123px !important; }
  .paper {
    position: static !important; transform: none !important;
    width: 794px !important; height: 1123px !important;
    box-shadow: none !important; margin: 0 !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
