:root {
  --navy: #1f3a5f;
  --navy-d: #16293f;
  --blue: #2e6fb0;
  --red: #c0392b;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --grey: #6b7280;
  --green: #2e9e5b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: #1f2937;
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}

/* 顶部栏 */
.topbar {
  background: linear-gradient(135deg, var(--navy), var(--navy-d));
  color: #fff;
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.topbar .sub { font-size: 12px; opacity: .8; margin-top: 2px; }
.topbar .me { font-size: 12px; text-align: right; }
.topbar .me button {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; margin-top: 4px;
}

/* 容器 */
.wrap { max-width: 640px; margin: 0 auto; padding: 14px; }
.view { display: none; }
.view.active { display: block; }

/* 卡片 */
.card {
  background: var(--card); border-radius: 12px; padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 12px;
}
.card h3 { margin: 0 0 4px; font-size: 15px; }
.muted { color: var(--grey); font-size: 13px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--blue); color: #fff; border: none; border-radius: 10px;
  padding: 12px 16px; font-size: 15px; font-weight: 500; cursor: pointer;
  width: 100%; transition: opacity .15s;
}
.btn:active { opacity: .8; }
.btn.block { width: 100%; }
.btn.primary { background: var(--navy); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.ghost { background: #eef2f7; color: var(--navy); }
.btn.small { padding: 8px 12px; font-size: 13px; width: auto; border-radius: 8px; }
.btn:disabled { opacity: .5; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* 表单 */
label { display: block; font-size: 13px; color: var(--grey); margin: 12px 0 5px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 12px; font-size: 15px; font-family: inherit; background: #fff;
  color: #1f2937;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); }

/* 星级 */
.stars { display: flex; gap: 6px; font-size: 30px; }
.stars .s { color: #d1d5db; cursor: pointer; line-height: 1; user-select: none; }
.stars .s.on { color: #f5a623; }
.star-hint { font-size: 12px; color: var(--grey); margin-top: 6px; }

/* 列表项 */
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: #fff; border-radius: 12px; margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05); cursor: pointer;
}
.item .thumb {
  width: 54px; height: 54px; border-radius: 8px; object-fit: cover;
  background: #eef2f7; flex: 0 0 auto;
}
.item .info { flex: 1; min-width: 0; }
.item .info .t { font-weight: 600; font-size: 15px; }
.item .info .d { color: var(--grey); font-size: 13px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.item .arrow { color: #cbd5e1; font-size: 20px; }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.badge.draft { background: #fef3c7; color: #92400e; }
.badge.done { background: #dcfce7; color: #166534; }
.badge.cat { background: #e0ecfa; color: #1d4e89; }

/* 隐患条目 */
.finding { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 10px; }
.finding img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.finding .fbody { flex: 1; min-width: 0; }
.finding .fstar { color: #f5a623; font-size: 14px; letter-spacing: 1px; }
.finding .fcat { display: inline-block; font-size: 11px; background: #e0ecfa;
  color: #1d4e89; padding: 1px 7px; border-radius: 10px; margin-left: 6px; }
.finding .fdesc { font-size: 14px; margin-top: 3px; }
.finding .floc { font-size: 12px; color: var(--grey); margin-top: 2px; }
.finding .del { color: var(--red); font-size: 12px; background: none; border: none; cursor: pointer; padding: 4px; }

/* 标题横条 */
.section-title { font-size: 13px; color: var(--grey); font-weight: 600;
  margin: 18px 4px 8px; text-transform: none; }

/* 空态 */
.empty { text-align: center; color: var(--grey); padding: 40px 20px; font-size: 14px; }

/* 拍照预览 */
#photoPreview { width: 100%; max-height: 220px; object-fit: contain;
  border-radius: 10px; margin-top: 8px; display: none; background: #000; }

/* 照片操作：拍照 / 从相册选择 */
.photo-actions { display: flex; gap: 10px; margin: 4px 0 2px; }
.photo-actions label.btn { flex: 1; text-align: center; cursor: pointer; margin: 0; }

/* 签字画板 */
#sigCanvas { width: 100%; height: 160px; border: 2px dashed #cbd5e1;
  border-radius: 10px; background: #fafcff; touch-action: none; }
.sig-actions { display: flex; gap: 10px; margin-top: 10px; }

/* Tabs */
.tabs { display: flex; gap: 8px; margin: 4px 0 14px; }
.tabs .tab { flex: 1; text-align: center; padding: 9px; border-radius: 9px;
  background: #fff; color: var(--grey); font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); }
.tabs .tab.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* 浮动新建按钮 */
.fab { position: fixed; right: 18px; bottom: 22px; z-index: 30;
  width: 56px; height: 56px; border-radius: 50%; background: var(--navy);
  color: #fff; font-size: 28px; border: none; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center; }

/* 模态 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 50; display: none; align-items: flex-end; }
.modal-mask.show { display: flex; }
.modal { background: #fff; width: 100%; max-width: 640px; margin: 0 auto;
  border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto; }
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.modal .close { float: right; font-size: 22px; color: var(--grey);
  background: none; border: none; cursor: pointer; line-height: 1; }

.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%);
  background: rgba(17,24,39,.92); color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: 13px; z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

.login-logo { text-align: center; padding: 30px 0 16px; }
.login-logo .ic { font-size: 46px; }
.login-logo .nm { font-size: 19px; font-weight: 700; color: var(--navy); margin-top: 6px; }
.login-logo .tg { font-size: 13px; color: var(--grey); margin-top: 2px; }

.stat { display: flex; gap: 10px; margin-top: 4px; }
.stat .box { flex: 1; background: #fff; border-radius: 10px; padding: 10px;
  text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.stat .box .n { font-size: 22px; font-weight: 700; color: var(--navy); }
.stat .box .l { font-size: 12px; color: var(--grey); }

/* 检查人员多选 */
.chk-list { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 14px;
  background: #f4f6f9; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; }
.chk input { width: auto; margin: 0; }
.chk .role { font-size: 11px; color: var(--grey); }

/* 隐患条目操作按钮 */
.finding .fops { display: flex; flex-direction: column; gap: 6px; align-items: stretch;
  justify-content: center; flex: 0 0 auto; }
.finding .edit { color: var(--blue); font-size: 12px; background: none; border: none;
  cursor: pointer; padding: 4px; }
.finding .del { color: var(--red); font-size: 12px; background: none; border: none;
  cursor: pointer; padding: 4px; }

/* 编辑隐患照片预览 */
#efPhotoPreview { width: 100%; max-height: 220px; object-fit: contain;
  border-radius: 10px; margin-top: 8px; display: none; background: #000; }

/* 手写签字画布 */
.sig-pad {
  display: block; width: 100%; height: 170px;
  border: 2px dashed var(--line); border-radius: 12px;
  background: #fff; touch-action: none; cursor: crosshair; margin-top: 8px;
}
.sig-pad-wrap { position: relative; }
.sig-pad-ph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #b6bec9; font-size: 13px; pointer-events: none; letter-spacing: 1px;
}
.sig-base {
  position: absolute; left: 14px; right: 14px; bottom: 34px; height: 1px;
  background: #d9dfe8; pointer-events: none;
}

/* ============ v4：AI 智能推荐 ============ */
.ai-box {
  margin-top: 10px; border: 1px solid #cfe0f4; background: #f6faff;
  border-radius: 12px; padding: 12px 12px 10px;
}
.ai-box .ai-hd {
  display: flex; align-items: center; gap: 6px; font-size: 13px;
  font-weight: 600; color: var(--navy); margin-bottom: 8px;
}
.ai-box .ai-hd .ai-tag {
  font-size: 10px; background: var(--navy); color: #fff;
  border-radius: 4px; padding: 1px 5px; font-weight: 600;
}
.ai-box .ai-hd .ai-act {
  margin-left: auto; font-size: 12px; color: var(--blue);
  background: none; border: none; cursor: pointer; padding: 2px 4px;
}
.ai-row { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin-bottom: 6px; }
.ai-row .ai-k { flex: 0 0 46px; color: var(--grey); font-size: 12px; padding-top: 1px; }
.ai-row .ai-v { flex: 1; min-width: 0; }
.ai-row .ai-v .ai-alt {
  color: var(--blue); font-size: 12px; background: none; border: none;
  cursor: pointer; padding: 0 0 0 6px;
}
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip {
  font-size: 12px; padding: 4px 9px; border-radius: 20px; cursor: pointer;
  border: 1px solid #cfe0f4; background: #fff; color: var(--navy);
}
.ai-chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.ai-sec { font-size: 12px; color: var(--grey); margin: 8px 0 6px; }
.basis-card {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 9px 10px; margin-bottom: 7px; cursor: pointer;
  display: flex; gap: 8px; align-items: flex-start;
}
.basis-card.on { border-color: var(--blue); background: #eef5fd; }
.basis-card .dot {
  flex: 0 0 15px; width: 15px; height: 15px; border-radius: 50%;
  border: 1.5px solid #b9c6d6; margin-top: 3px; position: relative;
}
.basis-card.on .dot { border-color: var(--blue); background: var(--blue); }
.basis-card.on .dot::after {
  content: ""; position: absolute; inset: 3.5px; background: #fff; border-radius: 50%;
}
.basis-card .bc { flex: 1; min-width: 0; }
.basis-card .law { font-size: 13px; font-weight: 600; color: var(--navy); }
.basis-card .txt { font-size: 12px; color: #4b5563; margin-top: 2px; word-break: break-all; }
.basis-card .sc { font-size: 11px; color: #9aa4b2; margin-top: 3px; }
.basis-none {
  border: 1px dashed #cbd5e1; background: #fff; border-radius: 10px;
  padding: 8px 10px; font-size: 13px; color: var(--grey); cursor: pointer; text-align: center;
}
.basis-none.on { border-color: var(--navy); color: var(--navy); background: #eef2f7; font-weight: 600; }
.ai-manual { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.ai-manual input {
  flex: 1; margin: 0; font-size: 13px; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 8px;
}
.ai-tip { font-size: 11px; color: #9aa4b2; margin-top: 6px; line-height: 1.45; }
.ai-tip.warn { color: #b45309; background: #fffbeb; border-left: 2px solid #f59e0b; padding: 5px 8px; border-radius: 0 6px 6px 0; }
.ai-row .ai-v .ai-alt.warn { color: #b45309; font-weight: 600; }
.finding .fbasis { font-size: 12px; color: var(--blue); margin-top: 2px; word-break: break-all; }

/* 知识库检索 */
.kb-list { max-height: 52vh; overflow: auto; margin-top: 10px; }
.kb-list .kb-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px;
  margin-bottom: 7px; cursor: pointer; background: #fff;
}
.kb-list .kb-item:active { background: #f1f5f9; }
.kb-list .kb-item .law { font-size: 13px; font-weight: 600; color: var(--navy); }
.kb-list .kb-item .txt { font-size: 12px; color: #4b5563; margin-top: 2px; word-break: break-all; }
.kb-list .kb-item .sc { font-size: 11px; color: #9aa4b2; margin-top: 3px; }
