:root {
  --primary: #1a9c7a;
  --primary-dark: #147a60;
  --danger: #e05656;
  --clean: #1a9c7a;
  --bg: #f2f5f4;
  --card: #ffffff;
  --text: #1f2d2a;
  --muted: #7a8a86;
  --border: #e3e9e7;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.6;
}
.hidden { display: none !important; }

.app { max-width: 520px; margin: 0 auto; min-height: 100%; padding-bottom: 72px; }
.view { padding: 20px 16px; }

/* 品牌区 */
.brand { text-align: center; padding: 40px 0 24px; }
.brand .logo { font-size: 52px; }
.brand h1 { font-size: 24px; margin-top: 8px; }
.brand .sub { color: var(--muted); margin-top: 4px; }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1; padding: 10px; border: none; background: var(--bg);
  border-radius: 10px; font-size: 15px; color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--primary); color: #fff; font-weight: 600; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }

.btn {
  width: 100%; padding: 13px; border: none; border-radius: 10px;
  font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:disabled { background: #b7d5cc; cursor: not-allowed; }
.btn.primary:active { background: var(--primary-dark); }
.link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 14px; }
.msg { text-align: center; margin-top: 10px; font-size: 14px; min-height: 20px; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--primary); }

/* 顶栏 & 底栏 */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: #fff; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 5;
}
.topbar #hello { font-weight: 600; }
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 520px; margin: 0 auto;
  display: flex; background: #fff; border-top: 1px solid var(--border); z-index: 5;
}
.navbtn { flex: 1; padding: 12px; border: none; background: none; font-size: 14px; color: var(--muted); cursor: pointer; }
.navbtn.active { color: var(--primary); font-weight: 600; }
.tabpane { padding: 16px; }

/* 上传器 */
.uploader {
  display: block; border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 28px 12px; text-align: center; color: var(--muted); cursor: pointer; margin-bottom: 14px;
}
.uploader .cam { font-size: 40px; }
.uploader .preview { max-width: 100%; border-radius: 10px; }

/* 结果区 */
.result { margin-top: 4px; }
.verdict {
  border-radius: var(--radius); padding: 22px 16px; text-align: center;
  color: #fff; margin-bottom: 14px; box-shadow: var(--shadow);
}
.verdict.clean { background: linear-gradient(135deg, #1fae86, #159c78); }
.verdict.dirty { background: linear-gradient(135deg, #ef6a6a, #d64b4b); }
.verdict .big { font-size: 30px; font-weight: 700; }
.verdict .sum { margin-top: 8px; font-size: 14px; opacity: .95; }

.note { background: #fff7e6; border: 1px solid #ffe1a8; color: #a86a00; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }

.problem {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px; border-left: 4px solid var(--danger);
}
.problem .phead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.problem .ptype { background: #ffe9e9; color: var(--danger); padding: 2px 10px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.problem .ploc { color: var(--muted); font-size: 13px; }
.problem .pdesc { font-size: 14px; color: var(--text); margin-bottom: 12px; }

.seg { margin-top: 12px; }
.seg h4 { font-size: 14px; display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.seg .num { background: var(--primary); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.seg p { font-size: 14px; color: #33413d; white-space: pre-line; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.chip { background: #eef6f3; color: var(--primary-dark); padding: 3px 10px; border-radius: 20px; font-size: 12px; }
.chip.chem { background: #eef1fb; color: #4a5bb0; }

/* 记录列表 */
.record-list { display: flex; flex-direction: column; gap: 10px; }
.record {
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
  padding: 12px; display: flex; gap: 12px; align-items: center; cursor: pointer;
}
.record img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #eee; }
.record .rinfo { flex: 1; min-width: 0; }
.record .rtitle { font-weight: 600; }
.record .rtime { color: var(--muted); font-size: 12px; }
.badge { padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.clean { background: #e4f6ef; color: var(--clean); }
.badge.dirty { background: #ffe9e9; color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* 弹层 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; z-index: 20; }
.modal-body { background: var(--bg); width: 100%; max-width: 520px; margin: 0 auto; max-height: 88vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px 16px 40px; position: relative; }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: none; font-size: 28px; color: var(--muted); cursor: pointer; }

/* loading */
.loading { position: fixed; inset: 0; background: rgba(255,255,255,.85); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 50; }
.spinner { width: 40px; height: 40px; border: 4px solid #d7e6e1; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
.loading p { margin-top: 12px; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
