/* 金家井乡人口核查系统 —— 通用样式（移动优先） */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: #1f2733; background: #f4f6f9;
}
a { color: #1a73e8; text-decoration: none; }
button { font-family: inherit; }

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; background: #fff; border-bottom: 1px solid #e4e8ee;
  position: sticky; top: 0; z-index: 30;
}
.topbar .title { font-weight: 600; font-size: 16px; margin-right: 4px; }
.topbar .grow { flex: 1; }
.topbar .user { font-size: 13px; color: #6b7785; }

input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #d5dbe3; border-radius: 8px;
  background: #fff; color: inherit; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: #1a73e8; box-shadow: 0 0 0 3px rgba(26,115,232,.12); }
textarea { min-height: 72px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 8px 14px; border: 1px solid #d5dbe3; border-radius: 8px;
  background: #fff; color: #1f2733; cursor: pointer; font-size: 14px; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: #1a73e8; border-color: #1a73e8; color: #fff; }
.btn.danger { background: #fff; border-color: #e04b3a; color: #e04b3a; }
.btn.ok { background: #12a05c; border-color: #12a05c; color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.block { width: 100%; }

/* ---------- 布局 ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; background: #fff; border-bottom: 1px solid #e4e8ee; position: sticky; top: 49px; z-index: 25; }
.tabs .tab { padding: 7px 13px; border-radius: 999px; background: #eef1f5; color: #38424f; cursor: pointer; white-space: nowrap; font-size: 14px; }
.tabs .tab.active { background: #1a73e8; color: #fff; }
.panel { display: none; padding: 12px; }
.panel.active { display: block; }
.wrap { max-width: 1200px; margin: 0 auto; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 140px; }
.card { background: #fff; border: 1px solid #e4e8ee; border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.muted { color: #6b7785; font-size: 13px; }
.hint { color: #8b95a3; font-size: 12px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mb8 { margin-bottom: 8px; }
.hidden { display: none !important; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stat { background: #fff; border: 1px solid #e4e8ee; border-radius: 12px; padding: 12px; }
.stat .k { font-size: 12px; color: #6b7785; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat.gray .v { color: #7a8694; }
.stat.green .v { color: #12a05c; }
.stat.red .v { color: #e04b3a; }
.stat.blue .v { color: #1a73e8; }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; border: 1px solid #e4e8ee; border-radius: 12px; background: #fff; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #eef1f5; text-align: left; white-space: nowrap; }
th { background: #f7f9fc; font-weight: 600; position: sticky; top: 0; z-index: 2; }
tbody tr:hover { background: #fafcff; }
td.wrap-cell { white-space: normal; max-width: 260px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 10px; }

/* ---------- 状态标记 ---------- */
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid transparent; }
.tag.gray { background: #eef1f5; color: #5d6b7a; }
.tag.green { background: #e6f6ee; color: #12a05c; border-color: #bfe6d1; }
.tag.red { background: #fdecea; color: #e04b3a; border-color: #f6c8c1; }
.tag.blue { background: #e8f0fe; color: #1a73e8; border-color: #c6dafc; }
.tag.yellow { background: #fff6e5; color: #b7791f; border-color: #f3dca6; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot.gray { background: #9aa4ae; } .dot.green { background: #12a05c; } .dot.red { background: #e04b3a; } .dot.blue { background: #1a73e8; }

/* ---------- 地图 ---------- */
#map { width: 100%; height: 62vh; min-height: 320px; background: #e8edf3; }
#map.full { height: calc(100vh - 100px); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; padding: 8px 10px; background: #fff; border-bottom: 1px solid #e4e8ee; font-size: 13px; }
.filter-bar { display: flex; gap: 8px; padding: 8px 10px; background: #fff; border-bottom: 1px solid #e4e8ee; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select { width: auto; min-width: 120px; }

/* ---------- 列表卡 ---------- */
.house-card { background: #fff; border: 1px solid #e4e8ee; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.house-card.active { border-color: #1a73e8; box-shadow: 0 0 0 3px rgba(26,115,232,.12); }
.house-card .n { font-weight: 600; }
.house-card .m { font-size: 13px; color: #6b7785; margin-top: 3px; }

/* ---------- 底部抽屉 ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(20,30,45,.18);
  max-height: 88vh; overflow: auto; transform: translateY(101%); transition: transform .22s ease;
}
.sheet.show { transform: translateY(0); }
.sheet .hd { position: sticky; top: 0; background: #fff; display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid #eef1f5; z-index: 2; }
.sheet .hd .t { font-weight: 600; flex: 1; }
.sheet .bd { padding: 12px 14px 90px; }
.sheet .ft { position: sticky; bottom: 0; background: #fff; padding: 10px 14px; border-top: 1px solid #eef1f5; display: flex; gap: 8px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: #4a5568; margin-bottom: 5px; }
.field .req { color: #e04b3a; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumb { position: relative; width: 76px; height: 76px; border-radius: 8px; overflow: hidden; border: 1px solid #e4e8ee; background: #f4f6f9; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x { position: absolute; right: 2px; top: 2px; background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 50%; width: 20px; height: 20px; line-height: 18px; padding: 0; font-size: 13px; cursor: pointer; }
.thumb .pg { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; text-align: center; }

/* ---------- 浮层 ---------- */
.mask { position: fixed; inset: 0; background: rgba(15,23,35,.45); z-index: 50; display: none; }
.mask.show { display: block; }
.modal { position: fixed; z-index: 70; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(680px, 94vw); max-height: 90vh; overflow: auto; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(10,20,35,.3); display: none; }
.modal.show { display: block; }
.modal .hd { position: sticky; top: 0; background: #fff; padding: 12px 14px; border-bottom: 1px solid #eef1f5; font-weight: 600; z-index: 2; }
.modal .bd { padding: 12px 14px; }
.modal .ft { position: sticky; bottom: 0; background: #fff; padding: 10px 14px; border-top: 1px solid #eef1f5; display: flex; gap: 8px; justify-content: flex-end; }

#toast { position: fixed; left: 50%; bottom: 88px; transform: translate(-50%, 20px); background: rgba(23,33,46,.92); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 200; max-width: 86vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#loading { position: fixed; inset: 0; background: rgba(255,255,255,.72); z-index: 190; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 10px; }
#loading.show { display: flex; }
#loading .sp { width: 28px; height: 28px; border: 3px solid #d5dbe3; border-top-color: #1a73e8; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 登录门禁 ---------- */
#authGate { position: fixed; inset: 0; background: rgba(244,246,249,.98); z-index: 500; display: none; align-items: center; justify-content: center; padding: 20px; }
#authGate.show { display: flex; }
#authGate .gate-box { width: min(460px, 100%); background: #fff; border: 1px solid #e4e8ee; border-radius: 14px; padding: 22px; text-align: center; box-shadow: 0 16px 44px rgba(15,30,55,.14); }
#authGate .sp { width: 26px; height: 26px; margin: 0 auto 12px; border: 3px solid #d5dbe3; border-top-color: #1a73e8; border-radius: 50%; animation: spin .8s linear infinite; }
#authGate .txt { font-weight: 600; font-size: 16px; margin-bottom: 8px; }
#authGate .tip { font-size: 13px; color: #6b7785; line-height: 1.7; text-align: left; }
#authGate .acts { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #1a73e8 0%, #0b4c8c 100%); }
.login-card { width: min(380px, 100%); background: #fff; border-radius: 16px; padding: 24px; box-shadow: 0 20px 50px rgba(8,25,50,.28); }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { margin: 0 0 18px; color: #6b7785; font-size: 13px; }

/* ---------- 挂图 ---------- */
.map-holder { position: relative; }
.maplist { border-top: 1px solid #e4e8ee; }
.bar { height: 8px; background: #eef1f5; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: #1a73e8; }
.bar > i.green { background: #12a05c; }
.bar > i.red { background: #e04b3a; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 10px; border-radius: 999px; background: #eef1f5; font-size: 13px; cursor: pointer; border: 1px solid transparent; }
.chip.active { background: #e8f0fe; border-color: #1a73e8; color: #1a73e8; }
