:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --brand: #1f3a2e;
  --brand-hover: #162b22;
  --accent: #d9f07a;
  --accent-hover: #cde762;
  --text: #18211c;
  --muted: #64746b;
  --border: #e3e8e0;
  --soft: #eff3ec;
  --green: #15803d;
  --green-bg: #dcfce7;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--brand);
  color: var(--accent);
  font-weight: 800;
  font-size: 17px;
  display: grid;
  place-items: center;
}

.brand-name { font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--muted); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  background: var(--soft);
  padding: 6px 12px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 15px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-accent { background: var(--accent); color: var(--brand); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-subtle { background: var(--soft); color: var(--brand); border-color: var(--border); }
.btn-subtle:hover { background: #e3eae0; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; }

/* 页面主体 */
.page {
  padding-top: 24px;
  padding-bottom: 52px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hint { font-size: 13px; color: var(--muted); }

/* 城市选择栏 */
.city-selector-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.city-selector-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.toggle-cities-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.toggle-cities-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.city-selector-label > span:first-child {
  font-size: 14px;
  font-weight: 700;
}

.city-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.city-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 7px 13px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.city-tab:hover { border-color: var(--brand); }

.city-tab.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.city-tab .cnt {
  font-size: 12px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--green-bg);
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.city-tab .cnt.zero {
  background: #eceeed;
  color: #85928b;
}

.city-tab.active .cnt {
  background: var(--accent);
  color: var(--brand);
}

.city-tab.active .cnt.zero {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* 城市一眼看清摘要卡 */
.city-summary {
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.summary-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.summary-title-row h1 {
  font-size: 26px;
  line-height: 1.2;
}

.city-en {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.68);
}

.total-badge {
  background: var(--accent);
  color: var(--brand);
  font-size: 14px;
  font-weight: 800;
  padding: 3px 12px;
  border-radius: 999px;
}

.total-badge.zero {
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.85);
}

.summary-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  font-variant-numeric: tabular-nums;
}

.summary-meta .sep { opacity: 0.4; }

/* 精简工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 4px 2px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tb-label {
  font-size: 13px;
  color: var(--muted);
  margin-right: 4px;
}

.pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.pill.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* 楼盘清单 */
.building-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.building-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.building-head {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid #eef1ec;
  background: #fcfdfb;
}

.building-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.building-title h3 {
  font-size: 16px;
  font-weight: 700;
}

.city-tag {
  font-size: 12px;
  background: var(--soft);
  color: var(--brand);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.building-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  background: var(--green-bg);
  padding: 2px 9px;
  border-radius: 999px;
}

.building-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.lease-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.lease-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 18px;
  border-bottom: 1px solid #f0f3ee;
  background: #fafbf9;
}

.lease-table td {
  padding: 12px 18px;
  border-bottom: 1px solid #f2f4f0;
  font-variant-numeric: tabular-nums;
}

.lease-table tr:last-child td {
  border-bottom: none;
}

.lease-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--brand);
}

.lease-badge.short { background: #fef3c7; color: #92400e; }
.lease-badge.long { background: #dbeafe; color: #1e40af; }

.price-cell {
  font-weight: 700;
  color: var(--brand);
}

.summary-row {
  cursor: pointer;
  transition: background 0.12s ease;
}

.summary-row:hover {
  background: #f4f7f2;
}

.summary-row.expanded {
  background: #f1f6ee;
}

.expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 9px;
  cursor: pointer;
}

.expand-arrow {
  display: inline-block;
  transition: transform 0.15s ease;
}

.summary-row.expanded .expand-arrow {
  transform: rotate(90deg);
}

.detail-row td {
  padding: 0;
  background: #fafbf9;
}

.unit-sublist {
  padding: 10px 18px 14px 32px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  border-top: 1px dashed #e5ebe2;
}

.unit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid #e7ece4;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}

.unit-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.unit-name {
  font-weight: 600;
  color: var(--text);
}

.unit-meta {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.unit-item-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.unit-link {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
  padding: 4px 10px;
  border-radius: 6px;
}

.unit-link:hover {
  background: var(--brand-hover);
}

/* 空状态 */
.empty-card {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
}

.empty-card h3 { font-size: 16px; margin-bottom: 6px; }
.empty-card p { font-size: 14px; color: var(--muted); margin-bottom: 16px; }

/* 近期放房记录 */
.history-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.history-head h2 { font-size: 15px; font-weight: 700; }

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--bg);
}

.history-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.history-speed {
  font-size: 12px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
}
.history-speed.live { background: var(--green-bg); color: var(--green); }

/* 底部邮箱订阅条 */
.inline-sub-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inline-sub-text h3 { font-size: 16px; margin-bottom: 3px; }
.inline-sub-text p { font-size: 13px; color: var(--muted); }

.inline-sub-form {
  display: grid;
  grid-template-columns: 140px 150px 1fr auto;
  gap: 8px;
}

.inline-sub-form select,
.inline-sub-form input {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #fff;
}

.inline-sub-form select:focus,
.inline-sub-form input:focus { border-color: var(--brand); }

/* 页脚 */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 0;
  font-size: 13px;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.link-btn {
  background: none;
  border: none;
  color: var(--brand);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

/* 弹窗 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 20, 0.5);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  padding: 20px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.18);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-close {
  border: none;
  background: var(--bg);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}

.modal-tabs {
  display: flex;
  background: var(--bg);
  padding: 4px;
  border-radius: 9px;
  margin-bottom: 14px;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 7px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab-btn.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.form-stack { display: flex; flex-direction: column; gap: 11px; }
.field-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.qr-wrap { display: flex; gap: 14px; align-items: center; }
.qr-box {
  width: 126px;
  height: 126px;
  flex-shrink: 0;
  border: 2px dashed #b9c8be;
  border-radius: 10px;
  background: var(--bg);
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 10px;
}

.qr-desc p { margin-bottom: 6px; font-size: 13px; }
.wx-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 8px; }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand);
  color: #fff;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 200;
}

@media (max-width: 720px) {
  .container { padding: 0 14px; }
  .topbar-inner { height: 56px; }
  .brand-name { font-size: 15px; }
  .brand-sub { font-size: 11px; }
  .sync-status { display: none; }
  .topbar-right .btn { padding: 7px 12px; font-size: 13px; }

  .page { padding-top: 14px; gap: 14px; }
  .city-selector-wrap { padding: 14px; }
  .city-tab { padding: 7px 11px; font-size: 13px; }

  .city-summary { padding: 16px; flex-direction: column; align-items: stretch; }
  .summary-title-row h1 { font-size: 22px; }
  .summary-meta { font-size: 12px; gap: 6px; }
  .summary-meta .sep { display: none; }
  .summary-right .btn { width: 100%; padding: 10px; }

  .toolbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .pill { padding: 6px 12px; font-size: 13px; }

  .building-head { padding: 12px 14px; }
  .building-right { width: 100%; justify-content: space-between; }
  .building-right .hint { display: none; }

  /* 手机端表格转成双行紧凑卡片，保留全部信息不隐藏列 */
  .lease-table thead { display: none; }
  .lease-table, .lease-table tbody { display: block; width: 100%; }
  .lease-table tr.summary-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #eef1ec;
  }
  .lease-table tr.summary-row td {
    display: block;
    padding: 0;
    border: none;
  }
  .lease-table tr.summary-row td:nth-child(1) { grid-column: 1; font-weight: 600; font-size: 14px; }
  .lease-table tr.summary-row td:nth-child(3) { grid-column: 2; text-align: right; font-size: 14px; }
  .lease-table tr.summary-row td:nth-child(2) { grid-column: 1 / -1; }
  .lease-table tr.summary-row td:nth-child(4) { grid-column: 1; font-size: 16px; }
  .lease-table tr.summary-row td:nth-child(5) { grid-column: 1; font-size: 12px; color: var(--muted); }
  .lease-table tr.summary-row td:nth-child(5)::before { content: "入住："; }
  .lease-table tr.summary-row td:nth-child(6) {
    grid-column: 2;
    grid-row: 3 / 5;
    align-self: center;
    text-align: right;
  }

  .lease-table tr.detail-row { display: block; }
  .lease-table tr.detail-row td { display: block; }
  .unit-sublist { padding: 10px 12px 12px 14px; }
  .unit-item { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
  .unit-item-right { justify-content: space-between; padding-top: 6px; border-top: 1px dashed #eef1ec; }
  .unit-link { padding: 7px 14px; font-size: 13px; }

  .history-box { padding: 14px; }
  .history-row { flex-direction: column; align-items: flex-start; gap: 6px; }

  .inline-sub-bar { padding: 16px 14px; }
  .inline-sub-form { grid-template-columns: 1fr; }
  .inline-sub-form select,
  .inline-sub-form input,
  .field input,
  .field select {
    font-size: 16px; /* 防止 iOS Safari 聚焦输入框自动放大 */
    min-height: 42px;
  }
  .inline-sub-form .btn,
  .form-stack .btn { min-height: 44px; font-size: 15px; }

  .field-2col { grid-template-columns: 1fr; }
  .modal-card { padding: 18px 16px; max-height: 90vh; overflow-y: auto; }
  .toast { width: calc(100% - 28px); text-align: center; border-radius: 10px; }
}
