/* =========================================================
   隐患排查助手 · 样式表
   设计基调：浅灰底 + 白色卡片 + 深蓝主色，移动端优先
   ========================================================= */

:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #14171f;
  --ink-2: #4b5464;
  --ink-3: #8a92a2;
  --line: #e6e9ef;
  --line-strong: #d5dae3;
  --brand: #1e4fe0;
  --brand-dark: #1739a8;
  --brand-soft: #eef2ff;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --warn: #b45309;
  --warn-soft: #fffaeb;
  --ok: #0e9f6e;
  --ok-soft: #ecfdf5;
  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 23, 31, 0.05);
  --shadow-md: 0 6px 24px rgba(20, 23, 31, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* 统一 hidden 语义：避免 display:flex/grid 覆盖 UA 的 [hidden] 规则 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }

/* ---------------- 顶栏 ---------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.appbar-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 12px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(140deg, #2a5cf0, #1a3fb8);
  color: #fff;
  box-shadow: 0 4px 12px rgba(30, 79, 224, 0.28);
}
.brand-mark svg { width: 21px; height: 21px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 15px; letter-spacing: 0.2px; }
.brand-text small { font-size: 11px; color: var(--ink-3); white-space: nowrap; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: #f0f2f7;
  border-radius: 999px;
  flex: 0 0 auto;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.tab.is-active {
  background: #fff;
  color: var(--brand);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  vertical-align: 1px;
}
.tab-badge[hidden] { display: none; }

/* 分段筛选 */
.seg {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: #f0f2f7;
  border-radius: 10px;
  width: 100%;
}
.seg-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  padding: 7px 6px;
  border-radius: 8px;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.seg-btn.is-active {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* 采纳按钮 */
.adopt-btn {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.adopt-btn:active { transform: scale(0.97); }
.adopt-btn.is-done {
  background: #f1f5f9;
  border-color: var(--line);
  color: var(--ink-3);
}

/* 台账卡片 */
.ledger {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
}
.ledger.sev-high { border-left-color: var(--danger); }
.ledger.sev-mid { border-left-color: #f59e0b; }
.ledger.sev-low { border-left-color: #94a3b8; }

.ledger-head { display: flex; gap: 10px; align-items: flex-start; }
.ledger-thumb {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 10px;
  object-fit: cover;
  background: #eef1f6;
}
.ledger-thumb.is-empty { background: linear-gradient(135deg, #eef1f6, #e3e8f2); }
.ledger-title-wrap { min-width: 0; flex: 1; }
.ledger-tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-bottom: 3px; }
.ledger-tags .sev { margin-top: 0; }
.ledger-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
}
.ledger-sub {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.ledger-desc {
  margin: 9px 0 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
}
.ledger .fields {
  padding: 9px 0 0;
  gap: 7px;
}
.ledger .fields > div { grid-template-columns: 62px 1fr; }
.ledger .fields dt { font-size: 11.5px; }
.ledger .fields dd { font-size: 12.5px; }

.ledger-foot {
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.ledger-foot .meta { font-size: 11px; color: #aab1bf; margin-right: auto; }

.status-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 5px;
  letter-spacing: 0.2px;
}
.status-pill.is-pending { background: var(--warn-soft); color: var(--warn); }
.status-pill.is-done { background: var(--ok-soft); color: var(--ok); }

/* ---------------- 布局 ---------------- */
.main {
  max-width: 780px;
  margin: 0 auto;
  padding: 18px 16px calc(28px + var(--safe-bottom));
}

.view-head { margin: 2px 0 14px; }
.view-head h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.2px; }
.view-head p { margin: 0; font-size: 13px; color: var(--ink-3); line-height: 1.5; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

/* ---------------- 上传区 ---------------- */
.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 208px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fbfcfe;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
  outline: none;
}
.dropzone:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.dropzone.is-drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.has-image { border-style: solid; border-color: var(--line); padding: 0; }

.dz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 18px;
  text-align: center;
  color: var(--ink-2);
}
.dz-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand);
  margin-bottom: 2px;
}
.dz-icon svg { width: 24px; height: 24px; }
.dz-empty strong { font-size: 14.5px; }
.dz-sub { font-size: 12px; color: var(--ink-3); line-height: 1.5; }

.dz-preview { position: relative; width: 100%; }
.dz-preview img {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  background: #0f1115;
  border-radius: calc(var(--radius) - 2px);
}
.dz-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 17, 21, 0.62);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
}

.upload-card .btn-block { margin-top: 14px; }
.hint {
  margin: 10px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: center;
}

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 600;
  transition: transform 0.06s, background 0.18s, box-shadow 0.18s, opacity 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, #2a5cf0, var(--brand));
  color: #fff;
  box-shadow: 0 6px 16px rgba(30, 79, 224, 0.22);
}
.btn-primary:not(:disabled):hover { background: linear-gradient(180deg, #2f61f5, var(--brand-dark)); }

.btn-ghost {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--ink-2);
}
.btn-ghost:hover { border-color: #c3cad6; color: var(--ink); }

.btn-danger-ghost {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fbd5d1;
}

.btn-block { width: 100%; height: 50px; font-size: 15.5px; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; font-weight: 500; border-radius: 9px; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  border-radius: 9px;
  font-size: 15px;
}
.icon-btn:hover { background: #f2f4f8; color: var(--ink); }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 状态条 ---------------- */
.notice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0 0 14px;
  padding: 11px 13px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid #fde9b8;
  background: var(--warn-soft);
  color: #8a5a00;
}
.notice[hidden] { display: none; }
.notice b { font-weight: 700; }
.notice > span:not(.notice-icon) { flex: 1 1 auto; min-width: 0; }
.notice .notice-icon { flex: 0 0 auto; font-size: 13px; line-height: 1.5; }
.notice.is-error { background: var(--danger-soft); border-color: #fbd5d1; color: #a02a20; }

/* ---------------- 识别记录 ---------------- */
.history { margin-top: 18px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 8px;
}
.section-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-head .count {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 1px 7px;
}
.link-btn {
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 12.5px;
  padding: 4px 6px;
  border-radius: 6px;
}
.link-btn:hover { color: var(--danger); background: var(--danger-soft); }

.history-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.history-list::-webkit-scrollbar { display: none; }

.hist-item {
  position: relative;
  flex: 0 0 auto;
  width: 106px;
  padding: 0;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  scroll-snap-align: start;
  transition: border-color 0.18s, box-shadow 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.hist-item img {
  display: block;
  width: 100%;
  height: 72px;
  object-fit: cover;
  background: #eef1f6;
}
.hist-item.is-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
}
.hist-body { padding: 6px 8px 7px; }
.hist-body b {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-body i {
  font-style: normal;
  font-size: 10.5px;
  color: var(--ink-3);
}
.hist-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 17, 21, 0.55);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  backdrop-filter: blur(3px);
}

.status {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
}
.status.is-error { background: var(--danger-soft); border-color: #fbd5d1; color: #a02a20; }
.status.is-loading { background: var(--brand-soft); border-color: #dbe3ff; color: var(--brand-dark); }

/* ---------------- 历史记录详情头 ---------------- */
.record-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.record-head img {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  background: #eef1f6;
  flex: 0 0 auto;
}
.record-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.record-meta i { font-style: normal; font-size: 11.5px; color: var(--ink-3); }
.record-head .link-btn { margin-left: auto; color: var(--brand); font-size: 12.5px; }

.pill-tag {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 2px 7px;
  border-radius: 6px;
}

/* ---------------- 识别结果 ---------------- */
.result-area {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* 吸顶导航高约 62px，滚动定位时留出避让空间 */
  scroll-margin-top: 76px;
}

.scene-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 13px 15px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.55;
}
.scene-card .tag {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 3px 8px;
  border-radius: 6px;
  margin-top: 1px;
}

.result-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-3);
  padding: 2px 4px;
}
.result-summary strong { color: var(--ink); font-size: 15px; }

.hazard {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}
.hazard.sev-high { border-left-color: var(--danger); }
.hazard.sev-mid { border-left-color: #f59e0b; }
.hazard.sev-low { border-left-color: #94a3b8; }

.hazard-head { display: flex; align-items: flex-start; gap: 8px; }
.hazard-head h3 {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.4;
  flex: 1;
  letter-spacing: -0.1px;
}

.sev {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.3px;
  margin-top: 1px;
}
.sev-high { background: var(--danger-soft); color: var(--danger); }
.sev-mid { background: var(--warn-soft); color: var(--warn); }
.sev-low { background: #f1f5f9; color: #52627a; }

.hazard-desc {
  margin: 9px 0 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-2);
}

.match-box {
  margin-top: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fcfdff;
}
.match-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafd;
  flex-wrap: wrap;
}
.match-label { font-size: 11px; color: var(--ink-3); font-weight: 600; letter-spacing: 0.3px; }
.chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.match-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.conf {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--ok);
  background: var(--ok-soft);
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
}
.conf.is-mid { color: var(--warn); background: var(--warn-soft); }
.conf.is-low { color: var(--danger); background: var(--danger-soft); }
/* 没匹配到库条目不等于出错，用中性灰，红/黄留给风险与待核对 */
.conf.is-none { color: var(--ink-2); background: #eef0f4; font-weight: 500; }

.conf-hint {
  display: block;
  margin: 0 13px 12px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--warn-soft);
  color: #8a5a00;
  font-size: 11.5px;
  line-height: 1.5;
}

.fields { margin: 0; padding: 12px 13px; display: grid; gap: 10px; }
.fields > div { display: grid; grid-template-columns: 74px 1fr; gap: 8px; }
.fields dt {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.6;
  font-weight: 500;
}
.fields dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.62;
  color: var(--ink-2);
  word-break: break-word;
}
.fields dd.strong { color: var(--ink); }

.major-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 13px 12px;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--danger);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
}
/* 风险等级只有四级，界面上只出一个徽标（.risk-badge）。
   「重大」即构成重大事故隐患，不再另挂一个徽标，避免被读成两个等级。 */

.keywords { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 13px 12px; }
.keywords span {
  font-size: 11.5px;
  color: var(--ink-3);
  background: #f4f6fa;
  padding: 3px 7px;
  border-radius: 5px;
}

details.alt {
  margin-top: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}
details.alt summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-3);
  list-style: none;
  user-select: none;
}
details.alt summary::-webkit-details-marker { display: none; }
details.alt summary::before { content: "▸ "; }
details.alt[open] summary::before { content: "▾ "; }
.alt-item {
  margin-top: 9px;
  padding: 10px 12px;
  background: #f8fafd;
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.6;
}
.alt-item b { color: var(--ink); font-weight: 600; }

/* 无知识库依据的推测项：默认折起来，不占正文视线 */
details.speculative {
  margin: 12px 0 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fbfcfe;
  padding: 11px 14px;
}
details.speculative summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin: -4px -6px;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.15s ease;
}
details.speculative summary:hover { background: #f1f4fa; }
details.speculative summary::-webkit-details-marker { display: none; }
details.speculative summary::before {
  content: "▸";
  color: var(--ink-3);
  font-size: 11px;
}
details.speculative[open] summary::before { content: "▾"; }
.spec-title { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.spec-hint { font-size: 12px; color: var(--ink-3); }
.spec-toggle {
  margin-left: auto;
  font-size: 12px;
  color: var(--brand);
  white-space: nowrap;
}
/* 用真实文本节点而不是伪元素：屏幕阅读器和自动化都读得到 */
.spec-toggle .t-closed { display: none; }
details.speculative:not([open]) .spec-toggle .t-open { display: none; }
details.speculative:not([open]) .spec-toggle .t-closed { display: inline; }
.spec-body { margin-top: 12px; display: grid; gap: 12px; }
.spec-body .hazard { background: #fff; }
/* 默认就是展开的，虚线框会显得很重，展开时收淡一点 */
details.speculative[open] { border-color: var(--line); background: #fcfdff; }

.empty-result {
  text-align: center;
  padding: 26px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.6;
}
.empty-result .ok-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 21px;
}

/* ---------------- 知识库 ---------------- */
.kb-toolbar { padding: 13px 14px; display: flex; flex-direction: column; gap: 10px; }

.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--ink-3);
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 12px 0 35px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: #fbfcfe;
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  -webkit-appearance: none;
}
.search-wrap input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: #fff; }

.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-row .toolbar-end { margin-left: auto; }
/* 与「导出」按钮同行时不再整行铺满 */
.filter-row .seg { width: auto; flex: 0 1 300px; }
.btn-icon { width: 15px; height: 15px; flex: 0 0 auto; }
.btn-sm .btn-icon { margin-right: 1px; }
.filter-row select {
  flex: 1;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 0 10px;
  font-size: 13.5px;
  outline: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5 6 8.5l4-4' stroke='%238a92a2' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 28px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.switch input {
  appearance: none;
  -webkit-appearance: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #dfe3ea;
  position: relative;
  transition: background 0.2s;
  flex: 0 0 auto;
  margin: 0;
}
.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s;
}
.switch input:checked { background: var(--danger); }
.switch input:checked::after { transform: translateX(16px); }

.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar-actions .btn-sm { flex: 0 0 auto; }
.toolbar-actions .btn-primary.btn-sm { flex: 0 0 auto; }

.kb-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }

.kb-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  box-shadow: var(--shadow-sm);
}
.kb-item-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  justify-content: space-between;
}
.kb-item-title { font-size: 14.5px; font-weight: 600; line-height: 1.45; margin: 0; flex: 1; }
.kb-item-sub {
  margin: 5px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.dot-sep { color: #cfd5e0; }
.kb-item-content {
  margin: 9px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kb-item-reg {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kb-item-foot {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.kb-item-foot .meta { font-size: 11px; color: #aab1bf; margin-right: auto; }
.mini-btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-2);
  font-size: 12.5px;
  height: 32px;
  padding: 0 11px;
  border-radius: 8px;
}
.mini-btn:hover { border-color: #c3cad6; color: var(--ink); }
.mini-btn.danger { color: var(--danger); border-color: #fbd5d1; background: var(--danger-soft); }

.badge-major {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  background: var(--danger);
  padding: 3px 7px;
  border-radius: 5px;
  letter-spacing: 0.3px;
}

.list-foot { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 0 4px; }
.list-foot .btn { min-width: 160px; }
.list-empty { font-size: 13px; color: var(--ink-3); text-align: center; margin: 6px 0; }

.skeleton {
  height: 92px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, #eef1f6 30%, #f7f9fc 50%, #eef1f6 70%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -40% 0; } }

/* ---------------- 弹层 ---------------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(16, 20, 28, 0.46); backdrop-filter: blur(2px); }

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  background: #fff;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 40px rgba(20, 23, 31, 0.18);
  animation: sheet-up 0.24s cubic-bezier(0.22, 0.9, 0.3, 1);
  padding-bottom: var(--safe-bottom);
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px 11px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 16px; margin: 0; }

.modal-body {
  padding: 14px 16px 6px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 11px;
  -webkit-overflow-scrolling: touch;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13.5px;
  background: #fbfcfe;
  outline: none;
  resize: vertical;
  line-height: 1.55;
  -webkit-appearance: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: #fff; }

.modal-foot {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
}
.modal-foot .btn { flex: 1; }

/* ---------------- 轻提示 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(86vw, 420px);
  padding: 11px 16px;
  border-radius: 10px;
  background: rgba(20, 23, 31, 0.92);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease-out;
}
.toast[hidden] { display: none; }
.toast.is-error { background: #b42318; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* =========================================================
   多来源采集台
   ========================================================= */
.intake-card { padding: 15px 15px 14px; transition: background 0.15s, border-color 0.15s; }
.intake-card.is-drag {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.intake-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.intake-head h2 { margin: 0; font-size: 14.5px; letter-spacing: -0.1px; }
.intake-hint { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }

.source-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.source-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 11px 4px 9px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.source-btn:hover { border-color: #c3cad6; background: #fff; }
.source-btn:active { transform: scale(0.975); }
.src-icon { color: var(--brand); display: flex; }
.src-icon svg { width: 23px; height: 23px; }
.source-btn b { font-size: 12.5px; font-weight: 600; letter-spacing: -0.1px; }
.source-btn i {
  font-style: normal;
  font-size: 10.5px;
  color: var(--ink-3);
  line-height: 1.2;
  text-align: center;
}

.url-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.url-row input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  font-size: 13px;
  outline: none;
}
.url-row input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.url-row .btn { flex: 0 0 auto; height: 38px; }

.drop-tip {
  margin: 10px 0 0;
  padding: 9px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.4;
}
.intake-card.is-drag .drop-tip { border-color: var(--brand); color: var(--brand-dark); }

/* 待识别队列 */
.queue { margin-top: 13px; }
.queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.queue-head b { color: var(--ink); font-size: 13.5px; }
.queue-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.q-item {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: #eef1f6;
  border: 1px solid var(--line);
}
.q-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.q-link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--brand);
  background: linear-gradient(135deg, #eef2ff, #e3e8f2);
}
.q-link-icon svg { width: 26px; height: 26px; }

.q-tag {
  position: absolute;
  left: 5px;
  top: 5px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: rgba(20, 23, 31, 0.62);
  padding: 2px 6px;
  border-radius: 5px;
  backdrop-filter: blur(2px);
}
.q-remove {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: rgba(20, 23, 31, 0.55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.q-remove:hover { background: rgba(217, 45, 32, 0.9); }
.q-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 4px 6px;
  font-size: 10.5px;
  font-weight: 600;
  text-align: center;
  color: #fff;
  background: rgba(20, 23, 31, 0.55);
}
.q-item.is-ready .q-status { background: rgba(20, 23, 31, 0.5); }
.q-item.is-running .q-status { background: rgba(30, 79, 224, 0.92); }
.q-item.is-done .q-status { background: rgba(14, 159, 110, 0.92); }
.q-item.is-error .q-status { background: rgba(217, 45, 32, 0.92); }
.q-item.is-running img { opacity: 0.75; }

/* =========================================================
   结果：概览 + 分图分组 + 四段式隐患卡
   ========================================================= */
.res-head {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.res-kpi {
  display: flex;
  gap: 22px;
}
.res-kpi > div { display: flex; flex-direction: column; gap: 1px; }
.res-kpi b { font-size: 21px; line-height: 1.15; letter-spacing: -0.6px; }
.res-kpi b.is-danger { color: var(--danger); }
.res-kpi i { font-style: normal; font-size: 11px; color: var(--ink-3); }
.risk-dist { display: flex; flex-wrap: wrap; gap: 6px; }
.res-note { display: flex; flex-direction: column; gap: 3px; }
.res-note .warn {
  font-size: 11.5px;
  color: #8a5a00;
  background: var(--warn-soft);
  border-radius: 6px;
  padding: 4px 8px;
  line-height: 1.45;
}

.risk-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.risk-red { background: var(--danger-soft); color: var(--danger); }
.risk-orange { background: #fff4ed; color: #c2410c; }
.risk-yellow { background: var(--warn-soft); color: var(--warn); }
.risk-blue { background: var(--brand-soft); color: var(--brand-dark); }

/* 单张照片分组 */
.shot {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 13px 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.shot-head { display: flex; align-items: center; gap: 10px; }
.shot-thumb {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 9px;
  object-fit: cover;
  background: #eef1f6;
}
.shot-thumb.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand-dark);
  background: linear-gradient(135deg, #eef2ff, #e3e8f2);
}
.shot-meta { min-width: 0; flex: 1; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.shot-label {
  font-size: 12.5px;
  color: var(--ink-2);
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shot-meta i { font-style: normal; font-size: 11px; color: #aab1bf; }
.shot-count {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.shot-count.is-ok { color: var(--ok); background: var(--ok-soft); }
.shot-error {
  font-size: 13px;
  color: #a02a20;
  background: var(--danger-soft);
  border-radius: 9px;
  padding: 10px 12px;
  line-height: 1.55;
}
.empty-result.is-inline { padding: 16px 12px; }
.shot .empty-result.is-inline {
  padding: 13px 10px;
  border: 0;
  background: #f8fafc;
  border-radius: 10px;
  font-size: 12.5px;
}
.shot .empty-result.is-inline .ok-icon {
  width: 30px;
  height: 30px;
  font-size: 14px;
  margin-bottom: 6px;
}

/* 隐患卡（嵌套在分组里，弱化外框） */
.shot .hazard {
  background: #fcfdff;
  box-shadow: none;
  padding: 13px 13px 12px;
}
.shot .hazard + .hazard { margin-top: 0; }
.risk-line-red { border-left-color: var(--danger) !important; }
.risk-line-orange { border-left-color: #ea580c !important; }
.risk-line-yellow { border-left-color: #d99a00 !important; }
.risk-line-blue { border-left-color: #7c96e8 !important; }

.hazard-head .risk-badge { margin-top: 1px; flex: 0 0 auto; }

/* 四段式规格表 */
.spec {
  margin: 11px 0 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.spec-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 9px;
  padding: 9px 11px;
  border-top: 1px solid var(--line);
}
.spec-row:first-child { border-top: 0; }
.spec-row dt {
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 600;
  line-height: 1.6;
}
.spec-row dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.62;
  color: var(--ink-2);
  word-break: break-word;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.spec-row dd > div { width: 100%; }
.spec .major-badge { margin: 0; }
.type-name { color: var(--ink); font-weight: 600; }

.legal-ref {
  width: 100%;
  font-size: 12.5px;
  color: var(--ink);
  font-weight: 600;
  line-height: 1.55;
  white-space: pre-line;
}
.legal-text {
  width: 100%;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.6;
}
.src-tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 5px;
  background: #f1f5f9;
  color: #52627a;
}
.src-tag.is-kb { background: var(--ok-soft); color: #067a55; }
.src-tag.is-ai { background: var(--warn-soft); color: #8a5a00; }
.fix-supp {
  width: 100%;
  margin-top: 4px;
  padding: 7px 9px;
  border-radius: 7px;
  background: #f7f9fc;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.6;
}
.fix-supp b {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-3);
  margin-right: 6px;
  letter-spacing: 0.3px;
}
.fix-foot {
  width: 100%;
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.match-foot {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}
.match-foot .conf { margin-left: 0; }
.muted { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; }
.hazard > .conf-hint { margin: 9px 0 0; }

/* 台账里的四段式表格更紧凑 */
.ledger .spec { margin-top: 10px; }
.ledger .spec-row { grid-template-columns: 58px 1fr; padding: 8px 10px; }
.ledger .spec-row dt { font-size: 11px; }
.ledger .spec-row dd { font-size: 12.5px; }
.ledger .spec .major-badge { margin: 0; }
.ledger-sub .chip { font-size: 11px; padding: 2px 7px; }

/* =========================================================
   图片放大查看
   ========================================================= */
body.lb-locked { overflow: hidden; }

[data-zoom] { cursor: zoom-in; }
.shot-thumb, .ledger-thumb, .record-head img { cursor: zoom-in; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  /* 纯不透明：照片观看时下层页面一丝都不该透出来，也省掉 blur 的渲染开销 */
  background: #080a0f;
  animation: lb-in 0.16s ease-out;
}
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }

.lb-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 10px;
  color: #fff;
}
.lb-caption {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.82);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
}
.lb-close:hover { background: rgba(255, 255, 255, 0.26); }

/* 舞台只是「视口」：裁剪 + 接管手势，图片靠 transform 缩放平移 */
.lb-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 10px 12px;
  touch-action: none;
  overscroll-behavior: contain;
  -webkit-user-select: none;
  user-select: none;
}
/* 绝对定位到舞台中心，transform 里再回退自身一半，缩放原点即舞台中心 */
.lb-stage img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  border-radius: 8px;
  cursor: zoom-in;
  transform-origin: center center;
  will-change: transform;
  -webkit-user-drag: none;
  user-select: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
.lb-stage.is-zoomed img { cursor: grab; border-radius: 2px; box-shadow: none; }
.lb-stage.is-panning img { cursor: grabbing; }

.lb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}
.lb-bar > span { min-width: 0; line-height: 1.45; }
.lb-btn {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.2); }

/* ---------------- 小屏 / 大屏适配 ---------------- */
@media (max-width: 420px) {
  .form-grid { grid-template-columns: 1fr; }
  .brand-text small { display: none; }
  .fields > div { grid-template-columns: 66px 1fr; }
  .toolbar-actions .btn-sm { flex: 1 1 auto; justify-content: center; }
  .spec-row { grid-template-columns: 56px 1fr; gap: 7px; padding: 8px 10px; }
  .res-kpi { gap: 16px; }
  .res-kpi b { font-size: 19px; }
  /* 台账工具栏：分段筛选与导出按钮各占一行，便于点按 */
  .filter-row .seg { flex: 1 1 100%; }
  .filter-row .toolbar-end { flex: 1 1 100%; margin-left: 0; }
}

@media (max-width: 360px) {
  .source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .queue-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 720px) {
  .main { padding-top: 26px; }
  .view-head h1 { font-size: 22px; }
  .dropzone { min-height: 240px; }
  .modal { align-items: center; }
  .modal-sheet { border-radius: 18px; max-height: 88vh; }
  .kb-list { gap: 12px; }
  .queue-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .source-btn { padding: 14px 6px 12px; }
  .source-btn b { font-size: 13px; }
  .source-btn i { font-size: 11px; }
}
