:root {
  --red: #c8102e;
  --red-d: #9e0c24;
  --blue: #1a4d8f;
  --blue-d: #143a6b;
  --ink: #1f2329;
  --sub: #6b7280;
  --line: #e8eaef;
  --bg: #f4f6f9;
  --card: #ffffff;
  --ok: #1a9e57;
  --warn: #d98a00;
  --safe: #2f7d4f;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 40, 80, 0.06);
}

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

/* 顶栏 */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  height: 50px; padding: 0 12px;
  background: linear-gradient(90deg, var(--red), var(--red-d));
  color: #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,.12);
}
.top-title { font-size: 16px; font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-back, .top-home {
  background: rgba(255,255,255,.18); color: #fff; border: 0;
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.top-back:active, .top-home:active { background: rgba(255,255,255,.32); }

/* 主体 */
#app { padding: 14px 14px 24px; max-width: 720px; margin: 0 auto; }

/* 底部 tab */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(0,0,0,.05);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; text-align: center; padding: 8px 4px 6px; font-size: 12px;
  color: var(--sub); cursor: pointer; border: 0; background: none;
}
.tab .ico { font-size: 20px; display: block; line-height: 1.1; }
.tab.active { color: var(--red); font-weight: 700; }

/* 通用卡片 */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}
.card h3 { margin: 0 0 10px; font-size: 15px; }
.muted { color: var(--sub); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row + .row { margin-top: 8px; }
.spread { display: flex; justify-content: space-between; align-items: center; }
.divider { height: 1px; background: var(--line); margin: 10px 0; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 11px 16px; font-size: 15px; font-weight: 600;
  cursor: pointer; width: 100%;
}
.btn:active { transform: translateY(1px); }
.btn-red { background: var(--red); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-ghost { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn-line { background: #fff; color: var(--blue); border: 1px solid var(--line); }
.btn-sm { padding: 7px 12px; font-size: 13px; width: auto; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; }

/* 角色选择 */
.hero {
  background: linear-gradient(135deg, var(--red), var(--blue));
  color: #fff; border-radius: var(--radius); padding: 22px 18px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 6px; font-size: 20px; }
.hero p { margin: 0; opacity: .92; font-size: 13px; }
.role-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.role {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; cursor: pointer; box-shadow: var(--shadow);
}
.role:active { border-color: var(--red); }
.role .emoji { font-size: 34px; width: 48px; text-align: center; }
.role .t { font-size: 17px; font-weight: 700; }
.role .d { font-size: 12px; color: var(--sub); margin-top: 2px; }

/* 统计卡 */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: #fff; border-radius: var(--radius); padding: 14px; text-align: center; box-shadow: var(--shadow); }
.stat .n { font-size: 26px; font-weight: 800; color: var(--red); }
.stat .l { font-size: 12px; color: var(--sub); margin-top: 2px; }

/* 列表项 */
.item { background: #fff; border-radius: var(--radius); padding: 13px 14px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer; }
.item:active { background: #fafbfc; }
.item .t { font-weight: 700; font-size: 15px; }
.item .s { font-size: 12px; color: var(--sub); margin-top: 4px; }
.item .tag { float: right; }

/* 标签 */
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.tag-red { background: #fde8ec; color: var(--red); }
.tag-blue { background: #e7eefb; color: var(--blue); }
.tag-green { background: #e4f5ec; color: var(--safe); }
.tag-orange { background: #fdf0db; color: var(--warn); }
.tag-gray { background: #eef0f3; color: var(--sub); }

/* 表单 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--sub); margin-bottom: 5px; font-weight: 600; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font-size: 15px; background: #fff; color: var(--ink);
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--blue); }

/* 器材勾选 */
.equip { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.equip label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); font-weight: 500;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.equip input { width: auto; }

/* 房屋详情只读 */
.kv { display: flex; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { width: 92px; color: var(--sub); flex: none; }
.kv .v { flex: 1; word-break: break-all; }
.call-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--ok); color: #fff;
  border-radius: 8px; padding: 6px 12px; font-size: 13px; text-decoration: none; font-weight: 700; }

/* 二维码 */
.qr-wrap { text-align: center; padding: 8px 0; }
.qr-wrap canvas { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.qr-tip { font-size: 12px; color: var(--sub); margin-top: 8px; }

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

/* toast */
.toast {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%);
  background: rgba(20,20,25,.9); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; z-index: 200; max-width: 80%; text-align: center;
}

/* 段落标题 */
.section-title { font-size: 14px; font-weight: 700; margin: 16px 2px 8px; color: var(--ink); }
.section-title .count { color: var(--sub); font-weight: 500; font-size: 12px; }

@media (min-width: 560px) {
  .role-grid { grid-template-columns: 1fr 1fr; }
}
