:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --gray: #9ca3af;
  --blue: #2563eb;
  --amber: #f59e0b;
  --red: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
}
.topbar nav a.active { background: #eff6ff; color: var(--primary); }
.topbar nav a:hover { text-decoration: none; background: #f3f4f6; }
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }

/* ---------- 通用 ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 20px; }
.page-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--red); border-color: #fecaca; background: #fef2f2; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn-ghost { border: 0; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 统计 ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}
.stat:hover { border-color: #bfdbfe; }
.stat.active { border-color: var(--primary); background: #f8fbff; }
.stat .num { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat .label { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- 筛选 ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.filters .grow { flex: 1; }
.filter-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.tabs { display: flex; gap: 2px; background: #f3f4f6; padding: 2px; border-radius: 8px; }
.tabs button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.tabs button.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
input, select, textarea {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
input[type="number"] { width: 82px; }
.filters input[type="search"] { width: 200px; }
textarea { height: auto; padding: 8px 10px; resize: vertical; }

/* ---------- 表格 ---------- */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f1f3f5; white-space: nowrap; }
th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: 12px; }
tbody tr:hover { background: #fafcff; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.stale { background: #fffbeb; }
tbody tr.stale:hover { background: #fef3c7; }
td.num, th.num { text-align: right; }
.actions { display: flex; gap: 6px; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--green); }
.dot.off { background: var(--gray); }
.dot.rented { background: var(--blue); }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 2px 0; color: var(--muted); font-size: 13px; }
.pager .btns { display: flex; gap: 6px; }

/* ---------- 列表 / 卡片视图 ---------- */
.view-seg { flex: none; }
.view-seg button { padding: 6px 10px; }
body.view-cards .table-wrap { display: none; }
body.view-cards .mobile-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
body.view-cards .card { margin-bottom: 0; }
body.view-list .mobile-list { display: none; }
body.view-list .table-wrap { display: block; }

.mobile-list { display: none; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.card .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .title { font-weight: 600; }
.card .rent { color: var(--red); font-weight: 700; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card .ops { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.login-card input { width: 100%; height: 38px; }
.login-card .btn { width: 100%; height: 38px; margin-top: 18px; }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------- 编辑表单 ---------- */
.form-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  max-width: 760px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field label b { color: var(--red); margin-left: 2px; }
.field input, .field select, .field textarea { width: 100%; }
.field .row { display: flex; gap: 8px; align-items: center; }
.field .row input { flex: 1; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.form-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.section-title { grid-column: 1 / -1; font-size: 13px; color: var(--muted); border-bottom: 1px dashed var(--line); padding-bottom: 6px; margin-top: 6px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.45);
  display: none; align-items: center; justify-content: center; z-index: 200; padding: 16px;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--card); border-radius: 14px; padding: 20px;
  width: 100%; max-width: 560px; box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.modal h3 { margin: 0 0 12px; font-size: 16px; }
.modal .picker { height: 300px; border-radius: 10px; overflow: hidden; margin: 10px 0; }
.modal .footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------- 地图页 ---------- */
.map-page { height: calc(100vh - 56px); display: flex; flex-direction: column; }
.map-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.seg { display: flex; background: #f3f4f6; padding: 2px; border-radius: 8px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.map-body { flex: 1; display: flex; min-height: 0; position: relative; }
#map { flex: 1; min-width: 0; background: #e8eef5; }
.map-panel {
  width: 340px; background: var(--card); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 12px;
}
.map-panel .panel-title { font-weight: 600; margin-bottom: 8px; display: flex; justify-content: space-between; }
.map-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
}
.map-item:hover { border-color: #bfdbfe; background: #f8fbff; }
.map-item .t { font-weight: 600; }
.map-item .m { color: var(--muted); font-size: 12px; margin-top: 2px; }
.map-footer {
  padding: 8px 16px; background: var(--card); border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px; display: flex; gap: 16px; flex-wrap: wrap;
}
.map-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(246,247,249,0.8); z-index: 5; color: var(--muted); }

/* 地图上的自定义元素 */
.price-pill {
  transform: translateY(-100%);
  background: var(--green); color: #fff; font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2); cursor: pointer;
  border: 2px solid #fff;
}
.price-pill.off { background: var(--gray); }
.price-pill.rented { background: var(--blue); }
.community-label {
  background: rgba(255,255,255,0.92); border: 1px solid var(--line);
  border-radius: 6px; padding: 2px 6px; font-size: 12px; color: #374151;
  white-space: nowrap; cursor: pointer; box-shadow: var(--shadow);
}
.community-label b { font-weight: 600; }
.community-label span { color: var(--green); margin-left: 3px; }
.metro-marker {
  background: #fff; border: 2px solid #0ea5e9; color: #0369a1;
  border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 600;
  white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.info-card { padding: 12px 14px; min-width: 220px; font-size: 13px; }
.info-card .t { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.info-card .line { color: var(--muted); margin: 2px 0; }
.info-card .price { color: var(--red); font-weight: 700; }
.info-card .ops { margin-top: 10px; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 500;
}
.toast.show { opacity: 1; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .map-panel { width: 280px; }
}

@media (max-width: 768px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .brand { font-size: 15px; }
  .topbar nav a { padding: 6px 10px; }
  .container { padding: 12px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .num { font-size: 20px; }
  .filters { padding: 8px; }
  .filters input[type="search"] { width: 100%; }
  .tabs { width: 100%; overflow-x: auto; }
  .form-grid { grid-template-columns: 1fr; }
  body.view-cards .mobile-list { grid-template-columns: 1fr; }
  body.view-list .table-wrap { display: block; overflow-x: auto; }
  body.view-list .table-wrap table { min-width: 760px; }
  .map-page { height: auto; }
  .map-body { flex-direction: column; }
  #map { height: 55vh; flex: none; }
  .map-panel { width: auto; border-left: 0; border-top: 1px solid var(--line); max-height: 40vh; }
  .form-footer { position: sticky; bottom: 0; background: var(--card); padding: 12px 0; }
}
