:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2329;
  --ink-2: #4e5969;
  --ink-3: #86909c;
  --line: #e5e6eb;
  --brand: #c0392b;
  --brand-2: #a93226;
  --brand-soft: #fdf1ef;
  --blue: #1d6fd6;
  --green: #17a673;
  --amber: #d98600;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 20px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.topbar .brand .dot {
  width: 26px; height: 26px; border-radius: 7px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.topbar nav a { margin-left: 18px; color: var(--ink-2); font-size: 13.5px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.narrow { max-width: 820px; margin: 0 auto; padding: 24px 20px 60px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; }
.card h3 { margin: 18px 0 10px; font-size: 14.5px; }

.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.hidden { display: none !important; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; }
label.field > span em { color: var(--brand); font-style: normal; }

input[type=text], input[type=tel], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
textarea { resize: vertical; min-height: 74px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all .15s;
  touch-action: manipulation;
}
a, button, .chip, .tab, label { -webkit-tap-highlight-color: transparent; }
.btn:hover { background: #fafafa; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.blue:hover { filter: brightness(.94); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.tag.gray { background: #f2f3f5; color: var(--ink-2); }
.tag.blue { background: #e8f1fd; color: var(--blue); }
.tag.green { background: #e7f7f0; color: var(--green); }
.tag.amber { background: #fdf3e2; color: var(--amber); }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.alert.info { background: #eef4fd; color: #1a5fb4; }
.alert.warn { background: #fdf3e2; color: #8a5b00; }
.alert.err { background: #fdeceb; color: #b02a1f; }
.alert.ok { background: #e7f7f0; color: #0f7a56; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--ink-2); font-weight: 600; background: #fafbfc; font-size: 13px; }
tr:hover td { background: #fafbfc; }

/* 协议文档排版 */
.doc {
  font-family: "Songti SC", "SimSun", "Noto Serif CJK SC", serif;
  color: #1a1a1a;
  font-size: 14.5px;
  line-height: 2;
}
.doc .doc-title { text-align: center; font-size: 24px; letter-spacing: 8px; margin: 6px 0 26px; font-weight: 700; }
.doc .doc-h { font-size: 15.5px; font-weight: 700; margin: 22px 0 6px; }
.doc .doc-h3 { font-size: 15px; font-weight: 700; margin: 18px 0 6px; }
.doc .doc-p { margin: 6px 0; text-align: justify; }
.doc .doc-p.blur { color: #bbb; }

/* 协议内表格（办理流程、退费标准、送达方式等） */
.doc .doc-table-wrap { margin: 10px 0 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.doc table.doc-table { width: 100%; border-collapse: collapse; font-size: 13.5px; line-height: 1.7; }
.doc table.doc-table th,
.doc table.doc-table td { border: 1px solid #c8ccd4; padding: 7px 9px; text-align: left; vertical-align: top; }
.doc table.doc-table th { background: #f4f6fa; font-weight: 700; white-space: nowrap; }
.doc table.doc-table tbody tr:nth-child(even) td { background: #fbfcfd; }
/* 特别提示框 */
.doc .doc-notice {
  border: 1px solid #a33a3a; border-radius: 6px; background: #fbf3f3;
  padding: 12px 14px; margin: 12px 0 18px; font-size: 13.5px; line-height: 1.9; color: #2b2b2b;
}

/* 签名区 */
.signbox {
  position: relative;
  border: 1px dashed #c9cdd4;
  border-radius: 10px;
  background: #fcfdfe;
  height: 180px;
}
.signbox canvas { width: 100%; height: 100%; display: block; border-radius: 10px; touch-action: none; cursor: crosshair; }
.signbox .ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #c0c4cc; font-size: 15px; pointer-events: none;
}
.signbox.signed .ph { display: none; }

.chip { display: inline-block; padding: 3px 10px; border: 1px solid var(--line); border-radius: 20px; background: #fff; font-size: 13px; cursor: pointer; }
.chip.active { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); font-weight: 600; }

.linkbox { display: flex; gap: 8px; }
.linkbox input { font-size: 12.5px; color: var(--ink-2); }

.kv { display: grid; grid-template-columns: 132px 1fr; gap: 6px 10px; font-size: 13.5px; }
.kv .k { color: var(--ink-3); }

.hashbox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; color: var(--ink-2); background: #f7f8fa; padding: 8px 10px; border-radius: 6px; }

.steps { display: flex; gap: 0; margin: 4px 0 18px; }
.step { flex: 1; text-align: center; font-size: 12.5px; color: var(--ink-3); position: relative; padding-top: 26px; }
.step::before { content: attr(data-n); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 20px; height: 20px; border-radius: 50%; background: #eceef1; color: var(--ink-3); font-size: 12px; display: grid; place-items: center; }
.step.active { color: var(--brand); font-weight: 700; }
.step.active::before { background: var(--brand); color: #fff; }
.step.done { color: var(--green); }
.step.done::before { background: var(--green); color: #fff; content: "✓"; }

@media print {
  body { background: #fff; }
  .topbar, .no-print, .btn { display: none !important; }
  .wrap, .narrow { max-width: none; padding: 0; }
  .card { box-shadow: none; border: none; padding: 0; margin: 0; }
  .doc { font-size: 12.5pt; line-height: 1.9; }
  .page-break { page-break-before: always; }
}

/* ==================== 移动端适配（手机签约） ==================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, canvas, video { max-width: 100%; }

/* 表格横向滚动容器（窄屏关键） */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 620px; }

/* 窄屏下把列表表格转成卡片（列多的列表在手机上横滚体验差） */
@media (max-width: 640px) {
  .table-wrap table.rwd { min-width: 0; width: 100%; }
  .rwd thead { display: none; }
  .rwd tbody { display: block; }
  .rwd tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    background: #fff;
  }
  .rwd tr:hover td { background: transparent; }
  .rwd td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: none;
    padding: 5px 0;
    white-space: normal;
    word-break: break-all;
  }
  .rwd td::before {
    content: attr(data-th);
    flex: 0 0 auto;
    color: var(--ink-3);
    font-weight: 600;
    font-size: 12.5px;
  }
  .rwd td.no-label { justify-content: flex-start; flex-wrap: wrap; gap: 8px; padding-top: 8px; border-top: 1px dashed var(--line); margin-top: 4px; }
  .rwd td.no-label::before { display: none; }
}

/* 窄屏提示条 */
.mobile-hint { display: none; }

/* 提交条（桌面端为普通右对齐按钮组） */
.submit-bar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.submit-bar .bar-tip { display: none; }

@media (max-width: 640px) {
  body { font-size: 15px; }

  /* 顶栏收紧 */
  .topbar { height: 52px; padding: 0 12px; }
  .topbar .brand { font-size: 14.5px; gap: 8px; }
  .topbar .brand .dot { width: 24px; height: 24px; font-size: 13px; border-radius: 6px; }
  .topbar nav a { margin-left: 12px; font-size: 13px; }

  /* 容器与卡片 */
  .wrap, .narrow { padding: 14px 12px 40px; }
  .wrap, .narrow { padding-left: calc(12px + env(safe-area-inset-left, 0px)); padding-right: calc(12px + env(safe-area-inset-right, 0px)); }
  .topbar { padding-left: calc(12px + env(safe-area-inset-left, 0px)); padding-right: calc(12px + env(safe-area-inset-right, 0px)); }
  .card { padding: 15px; border-radius: 12px; margin-bottom: 12px; }
  .card h2 { font-size: 15.5px; }
  .card h3 { font-size: 14.5px; }

  /* 表单竖排 + 16px 字号（iOS 聚焦不放大页面） */
  .row { gap: 0; }
  .row > * { flex: 1 1 100%; min-width: 0; }
  input[type=text], input[type=tel], input[type=password], input[type=date],
  input[type=number], select, textarea { font-size: 16px; padding: 11px 12px; }
  label.field > span { font-size: 13px; }
  .btn { padding: 11px 16px; font-size: 14.5px; }
  .btn.small { padding: 8px 12px; font-size: 13px; }

  /* 步骤条窄屏可横滑 */
  .steps { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .step { flex: 0 0 auto; min-width: 76px; font-size: 11.5px; }

  /* 协议正文：手机上字号略大、行距略松，长文更好读 */
  .doc { font-size: 15.5px; line-height: 1.95; }
  .doc .doc-title { font-size: 20px; letter-spacing: 4px; margin-bottom: 18px; }
  .doc .doc-h, .doc .doc-h3 { font-size: 15.5px; }
  .doc table.doc-table { font-size: 12.5px; }
  .doc table.doc-table th, .doc table.doc-table td { padding: 6px 7px; }

  /* 键值表改成上下两行，避免拥挤 */
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv .k { margin-top: 8px; font-size: 12px; }
  .kv > div:not(.k) { margin-bottom: 2px; }

  /* 签名区更高，手指好写 */
  .signbox { height: 210px; }
  .signbox .ph { font-size: 14px; }
  .mini-sign { height: 170px; }

  /* 链接复制框换行 */
  .linkbox { flex-wrap: wrap; }
  .linkbox input { flex: 1 1 100%; min-width: 0; }

  .hashbox { font-size: 11px; padding: 7px 9px; }
  .seal-preview { max-width: 130px; }
  .mobile-hint { display: block; }
  .mobile-hide { display: none !important; }
}

/* ===== 学员签署页：手机底部常驻提交条 ===== */
@media (max-width: 640px) {
  .submit-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, .97);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 14px rgba(15, 23, 42, .07);
  }
  .submit-bar .bar-tip { display: block; flex: 1 1 auto; font-size: 11.5px; line-height: 1.35; color: var(--ink-3); }
  .submit-bar .btn { flex: 0 0 auto; padding: 12px 18px; font-size: 15px; border-radius: 10px; }
  /* 给固定条让出空间 */
  .narrow { padding-bottom: 96px; }
}

