/* 监理工作助手 - 移动端优先样式 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --primary: #1e88e5;
  --primary-dark: #1565c0;
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1f2937;
  --text-2: #6b7280;
  --border: #e5e7eb;
  --danger: #e53935;
  --success: #43a047;
  --radius: 10px;
  --header-h: 52px;
  --tabbar-h: 58px;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* 顶部栏 */
.app-header {
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.app-title { font-size: 17px; font-weight: 600; }
.btn-back {
  position: absolute; left: 6px; top: 0; bottom: 0;
  background: none; border: none; color: #fff; font-size: 28px;
  width: 44px; cursor: pointer; line-height: 1;
}
.btn-add {
  position: absolute; right: 10px; top: 0; bottom: 0;
  background: none; border: none; color: #fff; font-size: 26px;
  width: 44px; cursor: pointer; font-weight: 300;
}

/* 主内容 */
.app-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  padding-bottom: calc(var(--tabbar-h) + 16px);
}

/* 表式选择（首页） */
.form-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.form-type-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  cursor: pointer;
  transition: transform .15s;
}
.form-type-card:active { transform: scale(.96); }
.form-type-card .ft-icon { font-size: 30px; margin-bottom: 6px; }
.form-type-card .ft-name { font-size: 14px; font-weight: 600; }
.form-type-card .ft-count { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* 列表 */
.section-title { font-size: 14px; color: var(--text-2); margin: 6px 2px 10px; font-weight: 600; }
.record-list { display: flex; flex-direction: column; gap: 10px; }
.record-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  cursor: pointer;
}
.record-card:active { background: #f0f4ff; }
.rc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.rc-type { font-size: 12px; color: var(--primary); font-weight: 600; }
.rc-date { font-size: 12px; color: var(--text-2); }
.rc-title { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.rc-sub { font-size: 13px; color: var(--text-2); }

/* 搜索 */
.search-bar { margin-bottom: 12px; }
.search-bar input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 22px; font-size: 14px; background: #fff;
}
.search-bar input:focus { outline: none; border-color: var(--primary); }

/* 空状态 */
.empty { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty-icon { font-size: 52px; margin-bottom: 12px; }
.empty p { font-size: 15px; margin-bottom: 4px; }
.empty-tip { font-size: 13px !important; color: #9ca3af; }

/* 项目目录 */
.project-list { display: flex; flex-direction: column; gap: 10px; }
.project-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}
.project-card:active { background: #f0f4ff; }
.pj-icon { font-size: 28px; }
.pj-info { flex: 1; min-width: 0; }
.pj-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-meta { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.pj-arrow { font-size: 22px; color: var(--text-2); }
.project-actions { margin-bottom: 10px; }
.project-actions .btn { width: 100%; }
.project-tip { font-size: 12px; color: var(--text-2); margin: 0 2px 12px; line-height: 1.6; }

/* 表单 */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row { display: flex; flex-direction: column; gap: 5px; grid-column: span 2; }
.form-row[style*="grid-column: span 1"] { grid-column: span 1; }
.form-row label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.form-row label .req { color: var(--danger); }
.form-row input, .form-row select, .form-row textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; background: #fff; font-family: inherit;
}
.form-row textarea { resize: vertical; min-height: 70px; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--primary);
}

/* 快捷填写区 */
.quick-bar {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px;
}
.quick-chip {
  font-size: 12px; padding: 4px 10px; background: #e3f2fd; color: var(--primary-dark);
  border-radius: 14px; cursor: pointer; border: none;
}
.quick-chip:active { background: #bbdefb; }
.phrases-panel {
  background: #f9fafb; border-radius: 8px; padding: 10px;
  margin-top: 6px;
}
.phrases-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.phrases-panel-head span { font-size: 12px; color: var(--text-2); }
.phrases-add { font-size: 12px; color: var(--primary); border: none; background: none; cursor: pointer; }
.phrases-list { display: flex; flex-wrap: wrap; gap: 6px; }
.phrase-chip {
  font-size: 12px; padding: 5px 10px; background: #fff; border: 1px solid var(--border);
  border-radius: 14px; cursor: pointer;
}
.phrase-chip:active { background: #eef2ff; }

/* 按钮 */
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.btn {
  flex: 1; padding: 12px; border: none; border-radius: 8px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-default { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }

/* 详情 */
.detail { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.detail-row { display: flex; padding: 8px 0; border-bottom: 1px solid #f0f0f0; }
.detail-row:last-child { border-bottom: none; }
.detail-label { width: 90px; color: var(--text-2); font-size: 14px; flex-shrink: 0; }
.detail-value { flex: 1; font-size: 14px; }
.detail-block { padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
.detail-block:last-child { border-bottom: none; }
.detail-block .detail-label { margin-bottom: 4px; }
.detail-text { font-size: 14px; white-space: pre-wrap; word-break: break-all; }

/* 底部导出操作条 */
.detail-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.detail-actions .btn { flex: 1; min-width: 100px; }

/* 模板选择弹层 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: flex-end; z-index: 100;
}
.modal {
  background: #fff; width: 100%; border-radius: 14px 14px 0 0;
  padding: 16px; max-height: 70vh; overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-2); cursor: pointer; }
.template-item {
  padding: 12px; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 8px; cursor: pointer;
}
.template-item:active { background: #f0f4ff; }
.template-item .t-name { font-weight: 600; font-size: 14px; }
.template-item .t-meta { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* 底部标签栏 */
.tab-bar {
  height: var(--tabbar-h);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
}
.tab-btn {
  flex: 1; background: none; border: none; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-2); font-size: 11px; cursor: pointer; gap: 2px;
}
.tab-btn.active { color: var(--primary); }
.tab-icon { font-size: 20px; }

/* 我的页 */
.mine-stats { display: flex; gap: 12px; margin-bottom: 16px; }
.stat-item { flex: 1; background: var(--card); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.mine-list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.mine-item {
  padding: 14px 16px; border-bottom: 1px solid #f0f0f0;
  display: flex; justify-content: space-between; cursor: pointer;
}
.mine-item:last-child { border-bottom: none; }
.mine-item.danger { color: var(--danger); }
.mine-item:active { background: #f9fafb; }
.mine-tip { font-size: 12px; color: var(--text-2); text-align: center; margin-top: 16px; padding: 0 20px; }

/* 浮动添加按钮 */
.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + 16px);
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  font-size: 28px; font-weight: 300; cursor: pointer;
  box-shadow: 0 4px 12px rgba(30,136,229,.4);
  display: flex; align-items: center; justify-content: center;
}
.fab:active { background: var(--primary-dark); }

/* toast */
.toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 12px 22px;
  border-radius: 8px; font-size: 14px; z-index: 200;
}

/* ========== 新增：首页 ========== */
.home-actions { margin-bottom: 16px; }
.home-action-btn {
  width: 100%; background: linear-gradient(135deg,#1e88e5,#1565c0); color: #fff;
  border: none; border-radius: var(--radius); padding: 14px;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(30,136,229,.25);
}
.home-action-btn:active { transform: scale(.98); }
.ha-icon { font-size: 24px; }
.ha-count { margin-left: auto; font-size: 12px; opacity: .85; }

/* 表单工具栏 */
.form-tools { display: flex; gap: 8px; margin-bottom: 12px; }
.tool-btn {
  padding: 8px 12px; border: 1px solid var(--border); background: #fff;
  border-radius: 8px; font-size: 13px; cursor: pointer; color: var(--text);
}
.tool-btn:active { background: #f0f4ff; }

/* 签字板 */
.sig-field { display: flex; flex-direction: column; }
.sig-pad { border: 1px dashed var(--border); border-radius: 8px; padding: 8px; background: #fafafa; }
.sig-pad canvas {
  width: 100%; height: 120px; background: #fff; border-radius: 6px;
  touch-action: none; display: block;
}
.sig-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.sig-actions .btn { flex: 1; min-width: 80px; padding: 8px; font-size: 13px; }
.sig-upload { display: flex; align-items: center; justify-content: center; }
.sig-tip { font-size: 11px; color: var(--text-2); text-align: center; margin-top: 6px; }
.sig-preview { position: relative; text-align: center; padding: 8px; }
.sig-preview img { max-width: 200px; max-height: 80px; }
.sig-clear {
  position: absolute; top: 4px; right: 4px; background: var(--danger); color: #fff;
  border: none; border-radius: 4px; padding: 2px 8px; font-size: 12px; cursor: pointer;
}

/* 印章选择 */
.seal-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.seal-item {
  width: 72px; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px; text-align: center; cursor: pointer; background: #fff;
}
.seal-item:active { background: #f0f4ff; }
.seal-item img { width: 60px; height: 60px; object-fit: contain; }
.seal-name { font-size: 11px; margin-top: 4px; color: var(--text-2); }
.seal-add { display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 13px; }

/* 检查清单 */
.checklist { display: flex; flex-direction: column; gap: 8px; }
.check-item {
  background: #f9fafb; border-radius: 8px; padding: 10px; border: 1px solid #f0f0f0;
}
.check-item-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.check-id { font-weight: 700; color: var(--primary); font-size: 13px; }
.check-cat { font-size: 12px; color: var(--text-2); background: #e3f2fd; padding: 1px 8px; border-radius: 10px; }
.check-std { font-size: 13px; margin-bottom: 6px; line-height: 1.4; }
.check-result { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.radio-label { font-size: 13px; display: flex; align-items: center; gap: 4px; }
.check-result input[type="text"] { flex: 1; min-width: 150px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.check-result textarea { flex: 1; min-width: 200px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; resize: vertical; }
.personnel-actions { display: flex; gap: 6px; width: 100%; margin-top: 6px; }
.btn-mini { padding: 4px 10px; font-size: 12px; border: 1px solid var(--primary); background: #fff; color: var(--primary); border-radius: 6px; cursor: pointer; }
.btn-mini:active { background: var(--primary); color: #fff; }

/* 签章库管理 */
.lib-section { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.lib-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.lib-head h3 { font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; flex: none; }
.lib-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.lib-item {
  width: 90px; text-align: center; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; background: #fafafa; position: relative;
}
.lib-item img { width: 74px; height: 74px; object-fit: contain; }
.lib-name { font-size: 12px; margin-top: 4px; color: var(--text); word-break: break-all; }
.lib-del {
  margin-top: 4px; background: none; border: 1px solid var(--danger);
  color: var(--danger); border-radius: 4px; padding: 2px 6px; font-size: 11px; cursor: pointer;
}

/* 详情中的签字图片 */
.sig-img { max-width: 120px; max-height: 50px; vertical-align: middle; }

/* 检查清单表格(详情) */
.check-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.check-table th, .check-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.check-table th { background: #f3f4f6; }

/* 弹层中的短语删除 */
.phrase-chip { position: relative; padding-right: 18px; }
.phrase-del {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-2); cursor: pointer; font-size: 14px; line-height: 1;
}

/* 表式卡片 grid */
.form-type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ========== 预览弹层 ========== */
.preview-mask { z-index: 150; align-items: stretch; }
.preview-modal {
  max-height: 92vh; border-radius: 14px 14px 0 0;
  display: flex; flex-direction: column;
}
.preview-content {
  flex: 1; overflow-y: auto; padding: 14px;
  background: #fff; border-top: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
.preview-content table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.5; }
.preview-content table td, .preview-content table th { border: 1px solid #000; padding: 6px 8px; vertical-align: top; }
.preview-content table th { background: #d9e2f3; text-align: center; }
.preview-content img { max-height: 60px; max-width: 180px; vertical-align: middle; }
.preview-content h2 { text-align: center; margin-bottom: 12px; font-size: 17px; }
.preview-actions {
  display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border);
  background: #fff; flex-shrink: 0;
}
.preview-actions .btn { padding: 10px; font-size: 14px; }

/* ========== 照片上传 ========== */
.photos-area { margin-top: 4px; }
.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.photo-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  background: #e5e7eb;
  display: block;
  text-decoration: none;
}
.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(229, 57, 53, 0.9);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 2;
}
.photo-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  background: #e8f0fe;
  color: var(--primary);
  border: 1px dashed var(--primary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}
.photo-upload:active { background: #d2e1fb; }
.photo-tip { font-size: 12px; color: var(--text-2); margin-top: 6px; }
