/* ============================================================
   申报资格查询系统 · 手机版样式
   移动优先，触控目标 ≥44px，浅色主题
   ============================================================ */
:root {
  --blue: #0f4c81;
  --blue-light: #e8f1f8;
  --blue-mid: #d3e3f0;
  --text: #1f2933;
  --text-2: #52606d;
  --text-3: #7b8794;
  --bg: #f3f5f7;
  --card: #ffffff;
  --line: #e4e7eb;
  --green: #1b7f4d;
  --green-light: #e6f4ec;
  --orange: #b05c0a;
  --orange-light: #fdf1e2;
  --purple: #6b4fa0;
  --purple-light: #f0eafa;
  --radius: 12px;
  --header-h: auto;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

/* ---------------- 吸顶头部 ---------------- */
.m-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #ffffff;
  padding: calc(10px + var(--safe-top)) 12px 8px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 6px rgba(15, 76, 129, 0.06);
}

.m-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.m-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 0.5px;
}

.m-count-badge {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--blue);
  background: var(--blue-light);
  border-radius: 999px;
  padding: 2px 10px;
  font-weight: 600;
}

/* 搜索框（输入字号 16px，防 iOS 聚焦缩放） */
.m-search-row { margin-top: 8px; }

.m-search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  height: 42px;
}

.m-search-box:focus-within {
  border-color: var(--blue);
  background: #ffffff;
}

.m-search-icon { color: var(--text-3); display: flex; }

.m-search-box input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
  height: 100%;
}

.m-search-box input::placeholder { color: var(--text-3); font-size: 15px; }

.m-search-clear {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border: none;
  border-radius: 50%;
  background: #d9dde2;
  color: #ffffff;
  font-size: 16px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* 分类 / 层级 chips：横向滚动 */
.m-chips-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 8px 0 2px;
}
.m-chips-scroll::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text-2);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chip .n {
  font-size: 12px;
  color: var(--text-3);
  background: var(--bg);
  border-radius: 999px;
  padding: 0 6px;
}

.chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}
.chip.active .n { background: rgba(255,255,255,0.22); color: #ffffff; }

/* 筛选行：层级 chips + 机构按钮 */
.m-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.m-filter-row .m-levels { flex: 1; padding: 6px 0 2px; }

.m-org-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

.m-org-btn.filtered {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-light);
}

.m-caret { font-size: 10px; color: var(--text-3); }

/* 隐藏原生 select（点击按钮触发） */
.m-hidden-select {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------------- 主体列表 ---------------- */
.m-main { padding: 10px 12px 20px; }

.m-result-count {
  margin: 2px 2px 8px;
  font-size: 12.5px;
  color: var(--text-3);
}

.m-list { display: flex; flex-direction: column; gap: 10px; }

.m-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.m-card:active { transform: scale(0.985); }

.m-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.m-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  padding: 1px 8px;
}
.m-badge.资质 { background: var(--blue-light); color: var(--blue); }
.m-badge.荣誉 { background: var(--orange-light); color: var(--orange); }
.m-badge.奖补 { background: var(--green-light); color: var(--green); }

.m-level-tag {
  font-size: 12px;
  color: var(--text-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 6px;
  flex-shrink: 0;
}

.m-card-title {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text);
}

.m-card-org {
  font-size: 12.5px;
  color: var(--text-3);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.m-card-summary {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.m-card-more {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--blue);
  font-weight: 600;
}

.m-empty {
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
  padding: 48px 20px;
  margin: 0;
  line-height: 2;
}
.m-empty-icon { font-size: 30px; }

.m-footer {
  padding: 16px 16px calc(20px + var(--safe-bottom));
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.8;
  border-top: 1px solid var(--line);
  background: #ffffff;
}
.m-footer p { margin: 0; }
.m-footer .warn { color: var(--orange); }

/* ---------------- 全屏面板（详情 / 原文） ---------------- */
.m-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  visibility: hidden;
}
.m-panel.open { transform: translateY(0); visibility: visible; }

.m-panel-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--blue);
  color: #ffffff;
  padding: calc(8px + var(--safe-top)) 10px 8px;
  min-height: 48px;
}

.m-back {
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  min-height: 36px;
  padding: 0 8px;
  cursor: pointer;
}

.m-panel-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.m-btn-ghost {
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.55);
  background: transparent;
  color: #ffffff;
  border-radius: 8px;
  font-size: 13.5px;
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
}

.m-panel-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px calc(24px + var(--safe-bottom));
}

.m-panel-action {
  flex-shrink: 0;
  padding: 10px 14px calc(12px + var(--safe-bottom));
  background: #ffffff;
  border-top: 1px solid var(--line);
}

.m-btn-primary {
  width: 100%;
  border: none;
  background: var(--blue);
  color: #ffffff;
  border-radius: 10px;
  font-size: 15.5px;
  font-weight: 600;
  min-height: 46px;
  cursor: pointer;
}
.m-btn-primary:active { opacity: 0.88; }

/* 详情内容 */
.m-detail-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.m-detail-title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.5;
}

.m-detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.m-sec { margin-top: 16px; }

.m-sec h4 {
  margin: 0 0 8px;
  font-size: 14.5px;
  color: var(--blue);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.m-sec h4::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--blue);
  border-radius: 2px;
}

.m-sec p {
  margin: 0;
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.75;
}

.m-sec ul {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.75;
}
.m-sec li { margin-bottom: 6px; }
.m-sec li:last-child { margin-bottom: 0; }

.m-muted { color: var(--text-3) !important; }

/* 原文 markdown 渲染 */
.md-body { background: #ffffff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.md-body p { margin: 0 0 10px; font-size: 14.5px; line-height: 1.85; color: var(--text); }
.md-body .md-h1 { font-size: 16.5px; margin: 16px 0 8px; color: var(--blue); }
.md-body .md-h2 { font-size: 15px; margin: 12px 0 6px; color: var(--text); }
.md-body ul, .md-body ol { margin: 0 0 10px; padding-left: 22px; font-size: 14.5px; line-height: 1.85; }
.md-body li { margin-bottom: 4px; }
.md-body h2.md-h1:first-child, .md-body h3.md-h2:first-child { margin-top: 0; }

/* 小屏适配 */
@media (max-width: 360px) {
  .m-card-title { font-size: 15px; }
  .m-sec p, .m-sec li { font-size: 13.5px; }
}

/* 桌面浏览器打开时的居中窄屏容器 */
@media (min-width: 700px) {
  body { background: #e6eaee; }
  .m-header, .m-main, .m-footer, .m-panel > .m-panel-bar, .m-panel-body, .m-panel-action {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
  }
  .m-header { border-radius: 0 0 14px 14px; }
  .m-footer { border-radius: 14px 14px 0 0; }
}
