:root {
  --green: #0e7a4f;
  --green-dark: #0a5f3d;
  --green-bg: #eef6f1;
  --orange: #d97706;
  --blue: #2563eb;
  --ink: #1c2a24;
  --muted: #66756e;
  --line: #e2e9e5;
  --card: #ffffff;
  --bg: #f6f8f7;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
}

.app { max-width: 560px; margin: 0 auto; padding: 0 16px 40px; }

/* 头部 */
.header { padding: 20px 0 14px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.logo-text h1 { font-size: 22px; line-height: 1.2; }
.logo-text p { font-size: 13px; color: var(--muted); }

/* Tab */
.tabs {
  display: flex; gap: 8px; background: #e8efeb;
  padding: 5px; border-radius: 12px; margin-bottom: 16px;
}
.tab {
  flex: 1; border: 0; background: transparent;
  padding: 11px 0; font-size: 16px; font-weight: 600;
  color: var(--muted); border-radius: 9px; cursor: pointer;
}
.tab.active { background: var(--card); color: var(--green); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.view { display: none; }
.view.active { display: block; }

/* 搜索栏 */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 4px 6px 4px 14px;
  color: var(--muted); margin-bottom: 12px;
}
.search-bar:focus-within { border-color: var(--green); }
.search-bar input {
  flex: 1; border: 0; outline: 0; font-size: 16px;
  background: transparent; padding: 10px 0; color: var(--ink);
}
.search-bar input::placeholder { color: #9aa8a1; }
.search-bar button {
  border: 0; background: var(--green); color: #fff;
  font-size: 15px; font-weight: 600; padding: 9px 18px;
  border-radius: 9px; cursor: pointer;
}
.search-bar button:active { background: var(--green-dark); }

.scan-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--card); border: 1.5px dashed var(--line);
  border-radius: 12px; padding: 13px 0; font-size: 16px; font-weight: 600;
  color: var(--green); cursor: pointer; margin-bottom: 18px;
}

.section-title { font-size: 14px; font-weight: 600; color: var(--muted); margin: 14px 0 10px; }

/* 症状网格 */
.symptom-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.symptom-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 14px;
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  font-size: 17px; font-weight: 600;
}
.symptom-card:active { background: var(--green-bg); border-color: var(--green); }
.symptom-card svg { flex-shrink: 0; color: var(--green); }
.symptom-card span { flex: 1; }
.symptom-card small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }

/* 药品卡片 */
.drug-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.drug-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
}
.drug-card:active { background: var(--green-bg); }
.drug-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.drug-generic { font-size: 17px; font-weight: 700; }
.drug-brand { font-size: 13px; color: var(--muted); }
.drug-meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.drug-advice {
  font-size: 14px; color: var(--ink); margin-top: 8px;
  border-top: 1px dashed var(--line); padding-top: 8px;
}

/* 原研/仿制/贴牌标签 */
.tag {
  font-size: 12px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; white-space: nowrap;
}
.tag-original { background: #e3f4e9; color: #157a3e; }
.tag-generic { background: #e8eefc; color: #2451b0; }
.tag-private_label { background: #fdf0e0; color: #b45f06; }
.tag-chinese { background: #f3ecfa; color: #6b3fa0; }

/* 贴牌高发提示 */
.risk-tip {
  margin-top: 8px; font-size: 13px; color: #b45f06;
  background: #fdf6ec; border: 1px solid #f5e0c0;
  border-radius: 8px; padding: 6px 10px;
}

/* 分类筛选 */
.drug-count { font-size: 13px; font-weight: 400; color: var(--muted); }
.category-bar {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.category-bar::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; border: 1.5px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 6px 14px; font-size: 14px;
  color: var(--muted); cursor: pointer; white-space: nowrap;
}
.chip.active { border-color: var(--green); background: var(--green-bg); color: var(--green); font-weight: 600; }

/* 加载更多 */
.load-more {
  width: 100%; margin-top: 12px; border: 1.5px dashed var(--line);
  background: var(--card); border-radius: 12px; padding: 12px 0;
  font-size: 15px; font-weight: 600; color: var(--green); cursor: pointer;
}
.load-more:active { background: var(--green-bg); }

/* 空结果 */
.empty { text-align: center; color: var(--muted); padding: 36px 0; font-size: 15px; }
.empty strong { color: var(--ink); display: block; font-size: 17px; margin-bottom: 6px; }

/* 页脚 */
.footer { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); }
.footer p { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* 模态 */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 30, 24, .55); }
.modal-body {
  position: relative; background: var(--card); border-radius: 16px;
  width: 100%; max-width: 500px; max-height: 82vh; overflow-y: auto;
  padding: 22px 20px 20px;
}
.modal-close {
  position: absolute; top: 10px; right: 12px; border: 0; background: var(--green-bg);
  width: 30px; height: 30px; border-radius: 50%; font-size: 18px; cursor: pointer; color: var(--muted);
}
.modal-body h2 { font-size: 20px; margin-bottom: 2px; }
.modal-body .brand-line { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.detail-row { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.detail-row:last-child { border-bottom: 0; }
.detail-row .k { flex: 0 0 84px; color: var(--muted); flex-shrink: 0; }
.detail-row .v { flex: 1; }
.red-flag {
  background: #fdf1f1; border: 1px solid #f3caca; color: #a12d2d;
  border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 12px;
}
.red-flag strong { display: block; margin-bottom: 2px; }

/* 查看在售 */
.buy-bar {
  display: flex; gap: 8px; margin: 10px 0 4px;
}
.buy-bar a {
  flex: 1; text-align: center; text-decoration: none;
  background: var(--green); color: #fff; font-size: 14px; font-weight: 600;
  border-radius: 9px; padding: 9px 0;
}
.buy-bar a:last-child { background: var(--ink); }
.buy-bar a:active { opacity: .85; }

/* 药品图片 */
.drug-img { margin: 10px 0 4px; }
.img-wrap {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  padding: 10px; min-height: 140px;
}
.img-wrap img { max-width: 100%; max-height: 180px; object-fit: contain; border-radius: 6px; }
.img-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 8px; }
.img-nav button {
  border: 1px solid var(--line); background: var(--card); border-radius: 8px;
  width: 30px; height: 30px; font-size: 16px; cursor: pointer; color: var(--muted);
}
.img-nav span { font-size: 13px; color: var(--muted); }

/* 扫码面板 */
.scan-panel { position: fixed; inset: 0; z-index: 60; }
.scan-panel[hidden] { display: none; }
.scan-mask { position: absolute; inset: 0; background: rgba(10, 20, 16, .92); }
.scan-body {
  position: relative; z-index: 1; height: 100%;
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 20px 30px; color: #fff;
}
.scan-header {
  width: 100%; max-width: 460px; display: flex; justify-content: space-between; align-items: center;
  font-size: 17px; font-weight: 600; margin-bottom: 20px;
}
.scan-close {
  border: 0; background: rgba(255,255,255,.15); color: #fff;
  width: 32px; height: 32px; border-radius: 50%; font-size: 18px; cursor: pointer;
}
.scan-camera {
  position: relative; width: 100%; max-width: 460px; border-radius: 14px; overflow: hidden;
  background: #000; aspect-ratio: 4/3;
}
.scan-camera video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; inset: 18% 12%; border: 2.5px solid #4ade80;
  border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35);
}
.scan-hint { margin: 14px 0; font-size: 14px; color: rgba(255,255,255,.75); }
.scan-input-row { display: flex; gap: 8px; width: 100%; max-width: 460px; }
.scan-input-row input {
  flex: 1; border: 0; border-radius: 10px; padding: 12px 14px;
  font-size: 16px; background: rgba(255,255,255,.12); color: #fff;
  outline: 0; letter-spacing: 1px;
}
.scan-input-row input::placeholder { color: rgba(255,255,255,.45); }
.scan-input-row button {
  border: 0; background: #4ade80; color: #0a2016; font-weight: 700;
  border-radius: 10px; padding: 0 20px; font-size: 15px; cursor: pointer;
}
.scan-result { margin-top: 14px; font-size: 14px; min-height: 20px; color: #fbbf24; }
