/* ============ 共用基础 ============ */
:root {
  --seal: #b8352c;
  --seal-dark: #8f241a;
  --seal-soft: #fdf2f1;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --line: #e5e6eb;
  --ok: #18a058;
  --warn: #d97706;
  --info: #2563eb;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 14px 14px 110px;
}

/* ============ 顶部 ============ */
.header {
  background: linear-gradient(135deg, #c0392b 0%, #8f241a 100%);
  color: #fff;
  padding: 22px 16px 26px;
  border-radius: 0 0 22px 22px;
}

.header-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0;
}

.header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .5px;
}

.header p {
  margin: 2px 0 0;
  font-size: 12.5px;
  opacity: .82;
}

/* ============ 卡片 ============ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(31, 35, 41, .05);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
}

.step {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 50%;
  background: var(--seal);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.req { color: var(--seal); font-weight: 700; }

.hint {
  font-size: 12.5px;
  color: var(--text-3);
  margin: -6px 0 10px;
}

.hint-inline {
  font-size: 13px;
  color: var(--text-3);
  padding: 6px 0;
}

/* ============ 选择项 ============ */
.org-list { display: flex; flex-direction: column; gap: 10px; }

.org-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 14.5px;
  text-align: left;
  transition: .15s;
  width: 100%;
}

.org-item .dot {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  border: 1.5px solid #c9cdd4;
  position: relative;
}

.org-item.active {
  border-color: var(--seal);
  background: var(--seal-soft);
  color: var(--seal);
  font-weight: 600;
}

.org-item.active .dot {
  border-color: var(--seal);
  border-width: 5px;
  background: #fff;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.chip {
  padding: 11px 10px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: #fff;
  font-size: 14px;
  color: var(--text);
  text-align: center;
  transition: .15s;
}

.chip.active {
  border-color: var(--seal);
  background: var(--seal-soft);
  color: var(--seal);
  font-weight: 600;
}

.chip.disabled {
  opacity: .45;
  background: #f7f8fa;
}

/* ============ 表单 ============ */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}

.input, .textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: .15s;
}

.input:focus, .textarea:focus { border-color: var(--seal); }

.textarea { min-height: 62px; resize: vertical; }

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* 份数 */
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.stepper button {
  width: 42px;
  height: 40px;
  border: none;
  background: #fff;
  font-size: 19px;
  color: var(--seal);
  font-weight: 600;
}

.stepper button:active { background: var(--seal-soft); }

.stepper input {
  width: 52px;
  height: 40px;
  border: none;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  outline: none;
}

.unit { margin-left: 8px; color: var(--text-3); font-size: 13px; }

/* 承诺勾选 */
.pledge {
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fafbfc;
  align-items: flex-start;
}

.pledge.checked { border-color: var(--seal); background: var(--seal-soft); }

.pledge input {
  width: 19px;
  height: 19px;
  margin: 2px 0 0;
  flex: 0 0 19px;
  accent-color: var(--seal);
}

.pledge span { font-size: 13px; color: var(--text-2); line-height: 1.55; }

/* ============ 拍照 ============ */
.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.photo-item { text-align: center; }

.photo-label {
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.photo-box {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1.5px dashed #c9cdd4;
  border-radius: 12px;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-3);
  overflow: hidden;
  padding: 0;
}

.photo-box.filled {
  border-style: solid;
  border-color: var(--ok);
}

.photo-box .icon { font-size: 24px; line-height: 1; }
.photo-box .txt { font-size: 12.5px; }
.photo-box img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.redo {
  margin-top: 6px;
  font-size: 12px;
  color: var(--seal);
  background: none;
  border: none;
  padding: 0;
}

/* ============ 提交条 ============ */
.submit-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  z-index: 20;
}

.submit-inner { max-width: 600px; margin: 0 auto; }

.btn {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--seal);
  color: #fff;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 1px;
  transition: .15s;
}

.btn:active { background: var(--seal-dark); }
.btn:disabled { opacity: .45; }

.btn-ghost {
  background: #fff;
  color: var(--seal);
  border: 1.5px solid var(--seal);
}

/* ============ 状态 ============ */
.loading, .empty {
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
  padding: 40px 20px;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--line);
  border-top-color: var(--seal);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  top: 24%;
  transform: translateX(-50%);
  background: rgba(31, 35, 41, .9);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 100;
  max-width: 78%;
  text-align: center;
  animation: fade .2s;
}

@keyframes fade { from { opacity: 0; transform: translate(-50%, -6px); } }

.warn-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 12.5px;
  line-height: 1.5;
}

/* ============ 成功页 ============ */
.success {
  background: #fff;
  border-radius: var(--radius);
  padding: 36px 22px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(31, 35, 41, .05);
}

.success-mark {
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #e8f5ee;
  color: var(--ok);
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.success h2 { margin: 0 0 6px; font-size: 19px; font-weight: 600; }
.success p { margin: 0; color: var(--text-2); font-size: 14px; }

.success-detail {
  margin: 20px 0 0;
  text-align: left;
  background: #fafbfc;
  border-radius: 12px;
  padding: 14px;
  font-size: 13.5px;
}

.success-detail div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
}

.success-detail span:first-child { color: var(--text-3); flex: 0 0 auto; }
.success-detail span:last-child { text-align: right; font-weight: 500; }

/* ============ 三列标签 ============ */
.chip-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.chip-grid-3 .chip { padding: 10px 6px; font-size: 13.5px; }

.chip.add {
  border-style: dashed;
  color: var(--seal);
  background: var(--seal-soft);
  font-size: 13.5px;
}

.org-item.local::after {
  content: "本机";
  margin-left: auto;
  font-size: 11px;
  color: var(--warn);
  border: 1px solid #fcd34d;
  background: #fffbeb;
  padding: 1px 5px;
  border-radius: 5px;
  font-weight: 400;
}

.org-item .name { flex: 1; min-width: 0; word-break: break-all; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(31, 35, 41, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  z-index: 200;
  animation: fade .18s;
}

/* 必须保留：display:flex 会覆盖 HTML 的 [hidden]，否则遮罩始终挡住整页 */
.modal-mask[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 20px 18px 16px;
}

.modal h3 {
  margin: 0 0 6px;
  font-size: 16.5px;
  font-weight: 600;
}

.modal-tip {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.55;
}

.modal-btns {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-btn {
  flex: 1;
  height: 42px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
}

.modal-btn.primary {
  background: var(--seal);
  border-color: var(--seal);
  color: #fff;
}

/* ============ 手写签字 ============ */
.sign-wrap {
  position: relative;
  border: 1.5px dashed #c9cdd4;
  border-radius: 12px;
  background: #fafbfc;
  overflow: hidden;
}

.sign-wrap.signed { border-style: solid; border-color: var(--ok); }

#signCanvas {
  display: block;
  width: 100%;
  height: 172px;
  touch-action: none;
  cursor: crosshair;
}

.sign-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 14px;
  pointer-events: none;
}

.sign-placeholder[hidden] { display: none; }

.sign-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.sign-bar .tip { font-size: 12.5px; color: var(--text-3); }

.link-btn {
  border: none;
  background: none;
  color: var(--seal);
  font-size: 13.5px;
  padding: 0;
}
