/* 和平里街道检查系统 · 样式
   设计目标：政务风格、信息密度高、手机可直接单手操作。 */

:root {
  --brand: #b91c1c;
  --brand-dark: #7f1d1d;
  --brand-soft: #fef2f2;
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --info: #1d4ed8;
  --info-soft: #eff6ff;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 32px rgba(15, 23, 42, .16);
  --r: 10px;
  --r-sm: 7px;
  --hdr: 56px;
}

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

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  font-size: 15px; line-height: 1.6; color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--info); }

/* ------------------------------------------------------------ 顶栏 */
header.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--hdr);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff;
  box-shadow: 0 2px 12px rgba(127, 29, 29, .28);
}
.topbar .logo {
  width: 30px; height: 30px; flex: 0 0 30px;
  display: grid; place-items: center;
  border-radius: 8px; background: rgba(255, 255, 255, .18);
  font-weight: 800; font-size: 15px; letter-spacing: -0.5px;
}
.topbar h1 { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: .3px; white-space: nowrap; }
.topbar .sub { font-size: 11px; opacity: .8; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar .conn {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, .16); white-space: nowrap;
  display: flex; align-items: center; gap: 5px;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: #86efac; box-shadow: 0 0 0 3px rgba(134, 239, 172, .25); }
.conn.off .dot { background: #fca5a5; box-shadow: 0 0 0 3px rgba(252, 165, 165, .25); }

/* ------------------------------------------------------------ 标签页 */
nav.tabs {
  position: sticky; top: var(--hdr); z-index: 35;
  display: flex; gap: 2px; overflow-x: auto;
  padding: 0 8px; background: var(--card);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  flex: 0 0 auto; border: 0; background: none;
  padding: 12px 13px 10px;
  font-size: 14px; font-weight: 600; color: var(--ink-3);
  border-bottom: 3px solid transparent; transition: .15s;
}
nav.tabs button:hover { color: var(--ink-2); }
nav.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

main { padding: 14px; max-width: 1180px; margin: 0 auto; }
.view { display: none; }
.view.on { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ 卡片 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  margin-bottom: 14px; overflow: hidden;
}
.card > h2, .card > .card-hd {
  margin: 0; padding: 12px 14px;
  font-size: 15px; font-weight: 700;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: #fbfdff;
}
.card-hd .spacer { flex: 1; }
.card-bd { padding: 14px; }
.card-bd.tight { padding: 10px; }

.sec-title {
  display: flex; align-items: center; gap: 8px;
  margin: 18px 0 10px; font-size: 15px; font-weight: 700;
}
.sec-title::before {
  content: ''; width: 3px; height: 15px; border-radius: 2px; background: var(--brand);
}

/* ------------------------------------------------------------ 表单 */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 4px; }
.field > label .req { color: var(--danger); font-weight: 700; }
.field .hint { font-size: 11.5px; color: var(--ink-3); }

input[type=text], input[type=date], input[type=datetime-local], input[type=number],
input[type=tel], input[type=search], input[type=password], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: #fff; outline: none; transition: .15s;
  color: var(--ink); min-height: 40px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(185, 28, 28, .1);
}
textarea { min-height: 74px; resize: vertical; line-height: 1.6; }
input.err, select.err, textarea.err { border-color: var(--danger); background: var(--danger-soft); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2364748b' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 12px; padding-right: 30px; }

/* ------------------------------------------------------------ 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: #fff; color: var(--ink-2); font-size: 14px; font-weight: 600;
  transition: .15s; white-space: nowrap; min-height: 40px;
}
.btn:hover { background: #f8fafc; border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { filter: brightness(.93); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-3); }
.btn.ghost:hover { background: #f1f5f9; color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; min-height: 32px; border-radius: 6px; }
.btn.danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------ 徽标 */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  background: #f1f5f9; color: var(--ink-2); border: 1px solid transparent;
}
.tag.重大 { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.tag.较大 { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.tag.一般 { background: var(--info-soft); color: var(--info); border-color: #bfdbfe; }
.tag.无隐患 { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.tag.已整改, .tag.已验收 { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.tag.待整改 { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.tag.整改中 { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.tag.无法整改 { background: #f1f5f9; color: var(--ink-3); border-color: var(--line-2); }
.tag.type { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.tag.plain { background: #f8fafc; color: var(--ink-3); border-color: var(--line); font-weight: 600; }

/* ------------------------------------------------------------ 判定标准查询 */
.std-layout { display: grid; gap: 14px; grid-template-columns: 220px 1fr; align-items: start; }
@media (max-width: 820px) { .std-layout { grid-template-columns: 1fr; } }

.ind-list { display: flex; flex-direction: column; gap: 3px; }
@media (max-width: 820px) { .ind-list { flex-direction: row; overflow-x: auto; padding-bottom: 4px; } }
.ind-list button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 11px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: #fff; text-align: left; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  transition: .15s; white-space: nowrap;
}
.ind-list button:hover { background: #f8fafc; }
.ind-list button.on { background: var(--brand-soft); color: var(--brand); border-color: #fecaca; }
.ind-list .cnt {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: #f1f5f9; color: var(--ink-3); border-radius: 999px; padding: 1px 7px;
}
.ind-list button.on .cnt { background: #fee2e2; color: var(--brand); }
.ind-list .swatch { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }

.searchbar { display: flex; gap: 8px; flex-wrap: wrap; }
.searchbar input[type=search] { flex: 1; min-width: 190px; }

.std-item {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 11px 13px; margin-bottom: 9px; background: #fff; transition: .15s;
}
.std-item:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.std-item .no {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 6px; background: var(--brand-soft); color: var(--brand);
  font-size: 12px; font-weight: 800; margin-right: 7px;
}
.std-item .t { font-weight: 700; font-size: 14.5px; }
.std-item .d { margin-top: 5px; color: var(--ink-2); font-size: 13.5px; }
.std-item .meta { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.std-item mark { background: #fef08a; padding: 0 2px; border-radius: 3px; color: inherit; }

/* ------------------------------------------------------------ 地图 */
.map-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #e8eef5; }
#map { width: 100%; height: 62vh; min-height: 380px; }
.map-toolbar {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 5;
  display: flex; gap: 7px; align-items: center; flex-wrap: wrap; pointer-events: none;
}
.map-toolbar > * { pointer-events: auto; }
.map-toolbar .pill {
  background: rgba(255, 255, 255, .96); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 600;
  color: var(--ink-2); box-shadow: var(--shadow); backdrop-filter: blur(6px);
}
.map-fallback {
  height: 62vh; min-height: 380px; position: relative; overflow: hidden;
  background: linear-gradient(#dbeafe, #eff6ff); cursor: crosshair;
}
.map-fallback .grid-line { position: absolute; background: rgba(100, 116, 139, .18); }
.fb-pin {
  position: absolute; width: 24px; height: 24px; margin: -24px 0 0 -12px;
  display: grid; place-items: center; cursor: pointer; z-index: 3;
}
.fb-pin i {
  width: 15px; height: 15px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3); display: block;
}
.fb-pin span {
  position: absolute; top: -19px; left: 50%; transform: translateX(-50%);
  background: rgba(15, 23, 42, .85); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 1px 6px; border-radius: 4px; white-space: nowrap;
}
.fb-note {
  position: absolute; bottom: 10px; left: 10px; right: 10px;
  background: rgba(255, 251, 235, .97); border: 1px solid #fde68a;
  border-radius: var(--r-sm); padding: 8px 11px; font-size: 12.5px; color: #78350f;
}
.map-key { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); padding: 8px 2px 0; }
.map-key b { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }

/* 地图信息窗 */
.iw { min-width: 240px; max-width: 320px; font-size: 13px; }
.iw h4 { margin: 0 0 6px; font-size: 14px; }
.iw .row { display: flex; gap: 6px; margin: 4px 0; color: var(--ink-2); }
.iw .row b { color: var(--ink-3); font-weight: 600; flex: 0 0 52px; }
.iw .acts { margin-top: 9px; display: flex; gap: 6px; }

/* “我的位置”脉冲动画（高德自定义标记内联样式引用） */
@keyframes mypulse {
  0%   { transform: scale(.7); opacity: .85; }
  70%  { transform: scale(2.1); opacity: 0; }
  100% { transform: scale(2.1); opacity: 0; }
}

/* 离线点位图中的“我的位置”标记 */
.fb-my {
  position: absolute; z-index: 6; pointer-events: none;
  transform: translate(-50%, -50%);
}
.fb-my i {
  display: block; width: 18px; height: 18px; border-radius: 50%;
  background: #2563eb; border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
  position: relative;
}
.fb-my i::after {
  content: ''; position: absolute; inset: -9px; border-radius: 50%;
  background: rgba(59, 130, 246, .3); animation: mypulse 1.8s ease-out infinite;
}
.fb-my span {
  position: absolute; left: 18px; top: -4px; white-space: nowrap;
  background: #2563eb; color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px; border: 1.5px solid #fff;
}

/* ------------------------------------------------------------ 记录列表 */
.rec-list { display: flex; flex-direction: column; gap: 9px; }
.rec {
  border: 1px solid var(--line); border-left: 4px solid var(--line-2);
  border-radius: var(--r-sm); padding: 11px 13px; background: #fff;
  cursor: pointer; transition: .15s;
}
.rec:hover { box-shadow: var(--shadow); border-color: var(--line-2); }
.rec.sev-重大 { border-left-color: var(--danger); }
.rec.sev-较大 { border-left-color: var(--warn); }
.rec.sev-一般 { border-left-color: var(--info); }
.rec.sev-无隐患 { border-left-color: var(--ok); }
.rec .hd { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec .hd .name { font-weight: 700; font-size: 14.5px; }
.rec .sub { margin-top: 5px; font-size: 12.5px; color: var(--ink-3); display: flex; gap: 12px; flex-wrap: wrap; }
.rec .tags { margin-top: 7px; display: flex; gap: 5px; flex-wrap: wrap; }

/* ------------------------------------------------------------ 台账批量管理 */
/* 批量操作条：只在"批量管理"模式下出现，红边提示当前处于可删除状态 */
.batch-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 9px 14px; font-size: 13px;
  background: var(--danger-soft); border-top: 1px solid #fecaca; border-bottom: 1px solid #fecaca;
}
.batch-bar .batch-all { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
.batch-bar .spacer { flex: 1; }
.batch-bar input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* 记录卡片上的勾选框 */
.rec .pick { display: inline-flex; align-items: center; margin-right: 2px; cursor: pointer; }
.rec .pick input { width: 16px; height: 16px; cursor: pointer; }
.rec .pick input:disabled { cursor: not-allowed; opacity: .45; }
.rec.picked { border-color: var(--danger); background: #fff7f7; box-shadow: 0 0 0 1px var(--danger) inset; }

.empty { text-align: center; padding: 36px 16px; color: var(--ink-3); }
.empty .ico { font-size: 34px; opacity: .35; }
.empty p { margin: 8px 0 0; font-size: 13.5px; }

/* ------------------------------------------------------------ 统计 */
.stat-grid { display: grid; gap: 11px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 13px; text-align: center;
}
.stat .v { font-size: 25px; font-weight: 800; line-height: 1.15; letter-spacing: -0.5px; }
.stat .k { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.stat.a .v { color: var(--brand); }
.stat.b .v { color: var(--warn); }
.stat.c .v { color: var(--ok); }
.stat.d .v { color: var(--info); }

.bar-row { display: flex; align-items: center; gap: 9px; margin: 7px 0; font-size: 13px; }
.bar-row .lb { flex: 0 0 92px; color: var(--ink-2); text-align: right; font-weight: 600; }
.bar-row .bar { flex: 1; height: 15px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: linear-gradient(90deg, #ef4444, #b91c1c); border-radius: 999px; transition: width .4s; }
.bar-row .vl { flex: 0 0 40px; color: var(--ink-3); font-size: 12px; font-weight: 700; }

/* ------------------------------------------------------------ 隐患编辑块 */
.hz { border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 11px; margin-bottom: 10px; background: #fbfdff; }
.hz .hz-hd { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.hz .hz-hd .idx {
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 800;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px;
  display: inline-grid; place-items: center;
}
.hz .hz-hd .spacer { flex: 1; }
.hz .grid { gap: 9px; }

/* ------------------------------------------------------------ 弹窗 */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-back.on { display: flex; }
.modal {
  background: #fff; border-radius: var(--r); width: 100%; max-width: 760px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-hd {
  padding: 13px 15px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; background: #fbfdff;
  border-radius: var(--r) var(--r) 0 0;
}
.modal-hd h3 { margin: 0; font-size: 15.5px; flex: 1; }
.modal-bd { padding: 15px; overflow: auto; flex: 1; }
.modal-ft { padding: 11px 15px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ------------------------------------------------------------ 提示条 */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #0f172a; color: #fff; padding: 9px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); max-width: 88vw;
  animation: pop .2s ease;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
.toast.warn { background: var(--warn); }

/* ------------------------------------------------------------ 杂项 */
.note {
  background: var(--info-soft); border: 1px solid #bfdbfe; color: #1e3a8a;
  border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 12px;
}
.note.warn { background: var(--warn-soft); border-color: #fde68a; color: #78350f; }
.note.err { background: var(--danger-soft); border-color: #fecaca; color: #7f1d1d; }
.note.ok { background: var(--ok-soft); border-color: #bbf7d0; color: #14532d; }
.note b { font-weight: 700; }
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 5px 10px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 0; word-break: break-all; }
.hr { height: 1px; background: var(--line); margin: 13px 0; }
.thumb-row { display: flex; gap: 7px; flex-wrap: wrap; }
.thumb-row img { width: 76px; height: 76px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line-2); }
.muted { color: var(--ink-3); font-size: 12.5px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.right { text-align: right; }
.hidden { display: none !important; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  main { padding: 11px; }
  .topbar h1 { font-size: 14.5px; }
  .topbar .sub { display: none; }
  #map { height: 52vh; min-height: 320px; }
  .kv { grid-template-columns: 72px 1fr; }
  .modal { max-height: 94vh; }
}

@media print {
  header.topbar, nav.tabs, .btn, .map-toolbar { display: none !important; }
  .view:not(.on) { display: none; }
  .card { box-shadow: none; break-inside: avoid; }
}
