:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --price: #f43f5e;
  --green: #16a34a;
  --orange: #ea580c;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --nav-h: 56px;
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
}

a { color: inherit; text-decoration: none; }
img { display: block; }
button { font-family: inherit; border: none; background: none; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 0.95rem; }

.container { max-width: 640px; margin: 0 auto; padding: 0 12px; }

/* ===== 顶部 ===== */
.header {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: #fff;
}
.header-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 8px;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; }
.logo img { width: 30px; height: 30px; border-radius: 8px; }
.logo small { display: block; font-size: 0.68rem; font-weight: 400; opacity: 0.85; }
.header-link { color: #fff; font-size: 0.85rem; opacity: 0.9; padding: 4px 8px; }

.search-bar {
  display: flex; align-items: center; gap: 8px; padding: 0 12px 10px;
}
.search-bar input {
  flex: 1; height: 36px; border-radius: 18px; border: none; outline: none;
  padding: 0 16px; font-size: 0.9rem; background: rgba(255, 255, 255, 0.95);
}
.search-bar button {
  height: 36px; padding: 0 16px; border-radius: 18px;
  background: rgba(255, 255, 255, 0.22); color: #fff; font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

/* ===== 分类 Tab ===== */
.tabs {
  display: flex; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 49;
}
.tabs .tab {
  flex: 1; padding: 11px 0; text-align: center; font-size: 0.95rem;
  color: var(--text-2); position: relative; font-weight: 500;
}
.tabs .tab.active { color: var(--primary); font-weight: 700; }
.tabs .tab.active::after {
  content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 28px; height: 3px; border-radius: 2px; background: var(--primary);
}

/* ===== 筛选 ===== */
.filters {
  display: flex; gap: 8px; padding: 10px 12px; overflow-x: auto;
  background: var(--card); border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0; padding: 6px 12px; border-radius: 16px; font-size: 0.82rem;
  background: var(--bg); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap;
}
.filter-chip.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); font-weight: 600; }

.filter-panel {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.45);
  display: none; align-items: flex-end; justify-content: center;
}
.filter-panel.show { display: flex; }
.filter-panel .sheet {
  background: #fff; width: 100%; max-width: 640px; border-radius: 16px 16px 0 0;
  padding: 16px; max-height: 70vh; overflow-y: auto;
}
.filter-panel h4 { font-size: 1rem; margin-bottom: 12px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.filter-grid button {
  padding: 8px 0; border-radius: 8px; background: var(--bg); font-size: 0.85rem;
  color: var(--text-2); border: 1px solid transparent;
}
.filter-grid button.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); font-weight: 600; }
.filter-actions { display: flex; gap: 10px; }
.filter-actions button { flex: 1; padding: 11px 0; border-radius: 10px; font-size: 0.95rem; }
.btn-reset { background: var(--bg); color: var(--text-2); }
.btn-apply { background: var(--primary); color: #fff; font-weight: 600; }

/* ===== 房源卡片 ===== */
.listing-list { padding: 10px 12px 0; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px; margin-bottom: 10px; display: flex; gap: 10px; position: relative;
}
.card-img {
  width: 116px; height: 92px; flex-shrink: 0; border-radius: 8px; overflow: hidden;
  position: relative; background: #eef1f5;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-img .placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 0.75rem;
}
.badge-type {
  position: absolute; left: 0; top: 0; padding: 2px 7px; font-size: 0.68rem;
  color: #fff; border-radius: 8px 0 8px 0; font-weight: 600;
}
.badge-type.new { background: var(--green); }
.badge-type.second { background: var(--orange); }
.badge-type.rent { background: var(--primary); }
.badge-featured {
  position: absolute; left: 0; bottom: 0; padding: 2px 7px; font-size: 0.68rem;
  color: #fff; background: #dc2626; border-radius: 0 8px 0 0; font-weight: 600;
}
.card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card-title {
  font-size: 0.93rem; font-weight: 600; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-sub { font-size: 0.78rem; color: var(--text-2); margin-top: 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card-bottom { margin-top: auto; display: flex; align-items: baseline; justify-content: space-between; }
.card-price { color: var(--price); font-weight: 700; font-size: 1.02rem; }
.card-price small { font-size: 0.72rem; font-weight: 400; }
.card-tag { font-size: 0.7rem; color: var(--text-3); flex-shrink: 0; }
.card-tag.agent { color: var(--orange); }

/* ===== 空状态 ===== */
.empty { text-align: center; padding: 60px 0; color: var(--text-3); }
.empty .icon { font-size: 3rem; margin-bottom: 10px; }

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--card); border-top: 1px solid var(--border);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; height: var(--nav-h); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-size: 0.7rem; color: var(--text-2);
}
.bottom-nav a.active { color: var(--primary); font-weight: 600; }
.bottom-nav .nav-icon { font-size: 1.3rem; line-height: 1; }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px);
  z-index: 40; width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, #f43f5e, #e11d48); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.4); font-size: 1.5rem;
}

/* ===== 表单 ===== */
.form-card { background: var(--card); border-radius: var(--radius); padding: 14px; margin: 10px 12px; box-shadow: var(--shadow); }
.form-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.form-title::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--primary); }

.form-item { margin-bottom: 14px; }
.form-item:last-child { margin-bottom: 0; }
.form-label { display: block; font-size: 0.85rem; color: var(--text-2); margin-bottom: 6px; }
.form-label .req { color: #ef4444; margin-left: 2px; }
.form-input {
  width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 10px;
  padding: 0 12px; outline: none; background: #fafbfc; font-size: 0.95rem;
}
.form-input:focus { border-color: var(--primary); background: #fff; }
textarea.form-input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.form-row { display: flex; gap: 10px; }
.form-row .form-item { flex: 1; }

.type-selector { display: flex; gap: 10px; }
.type-selector button {
  flex: 1; padding: 12px 0; border-radius: 10px; border: 2px solid var(--border);
  font-size: 0.95rem; font-weight: 600; color: var(--text-2); background: #fff;
}
.type-selector button.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.type-selector button.active.new { border-color: var(--green); color: var(--green); background: #dcfce7; }
.type-selector button.active.second { border-color: var(--orange); color: var(--orange); background: #ffedd5; }
.type-selector button.active.rent { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.phone-input-row { display: flex; gap: 10px; }
.phone-input-row .form-input { flex: 1; }
.btn-sms {
  flex-shrink: 0; width: 110px; height: 42px; border-radius: 10px;
  background: var(--primary); color: #fff; font-size: 0.85rem; font-weight: 600;
}
.btn-sms:disabled { background: var(--text-3); }

.upload-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.upload-cell {
  aspect-ratio: 1; border-radius: 10px; overflow: hidden; position: relative;
  border: 1px dashed var(--border); background: #fafbfc;
}
.upload-cell img { width: 100%; height: 100%; object-fit: cover; }
.upload-cell .del {
  position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 0.8rem; line-height: 22px; text-align: center;
}
.upload-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 0.72rem; gap: 4px; cursor: pointer;
}
.upload-add .plus { font-size: 1.6rem; line-height: 1; }

.btn-submit {
  width: 100%; height: 48px; border-radius: 12px; margin: 4px 0 20px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff;
  font-size: 1.05rem; font-weight: 700; letter-spacing: 2px;
}
.btn-submit:disabled { opacity: 0.6; }

.checkbox-row { display: flex; align-items: flex-start; gap: 8px; font-size: 0.8rem; color: var(--text-2); margin-top: 10px; }
.checkbox-row input { margin-top: 3px; }

/* ===== 详情页 ===== */
.carousel { position: relative; width: 100%; height: 260px; overflow: hidden; background: #eef1f5; }
.carousel-track { display: flex; height: 100%; transition: transform 0.3s; }
.carousel-track img { width: 100%; height: 100%; object-fit: cover; flex-shrink: 0; }
.carousel-dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 5px; }
.carousel-dots span { width: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.5); }
.carousel-dots span.active { background: #fff; width: 16px; }

.detail-card { background: var(--card); border-radius: var(--radius); padding: 14px; margin: 10px 12px; box-shadow: var(--shadow); }
.detail-price-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.detail-price { color: var(--price); font-size: 1.5rem; font-weight: 800; }
.detail-price small { font-size: 0.85rem; font-weight: 400; }
.detail-title { font-size: 1.1rem; font-weight: 700; line-height: 1.5; margin-bottom: 8px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.8rem; color: var(--text-2); }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 6px; }
.info-cell { text-align: center; padding: 10px 4px; background: var(--bg); border-radius: 8px; }
.info-cell .v { font-size: 0.92rem; font-weight: 700; }
.info-cell .k { font-size: 0.7rem; color: var(--text-3); margin-top: 2px; }

.detail-desc { font-size: 0.9rem; color: #374151; line-height: 1.7; white-space: pre-wrap; word-break: break-all; }

.contact-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.contact-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; background: var(--primary-light);
  color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.contact-name { font-weight: 700; font-size: 0.95rem; }
.contact-type-tag { font-size: 0.68rem; padding: 1px 6px; border-radius: 4px; margin-left: 6px; }
.contact-type-tag.agent { background: #ffedd5; color: var(--orange); }
.contact-type-tag.personal { background: #dcfce7; color: var(--green); }
.contact-phone { font-size: 0.8rem; color: var(--text-2); margin-top: 2px; }
.btn-call {
  flex-shrink: 0; padding: 10px 20px; border-radius: 24px; font-weight: 700; font-size: 0.95rem;
  background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff;
  box-shadow: 0 3px 10px rgba(22, 163, 74, 0.35);
}
.btn-call.reveal { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 3px 10px rgba(217, 119, 6, 0.35); }

.btn-share { flex: 1; height: 44px; border-radius: 10px; background: var(--primary-light); color: var(--primary); font-weight: 700; font-size: 0.95rem; }

/* ===== 分享引导遮罩 ===== */
.share-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, 0.75);
  display: none; align-items: center; justify-content: center; flex-direction: column;
}
.share-overlay.show { display: flex; }
.share-overlay .arrow { font-size: 4.5rem; color: #fff; margin-bottom: 18px; animation: float 1.2s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
.share-overlay .tip { color: #fff; font-size: 1.05rem; font-weight: 600; }
.share-overlay .tip2 { color: rgba(255, 255, 255, 0.75); font-size: 0.85rem; margin-top: 6px; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%); z-index: 300;
  background: rgba(0, 0, 0, 0.78); color: #fff; padding: 12px 22px; border-radius: 10px;
  font-size: 0.9rem; max-width: 80%; text-align: center; display: none;
}
.toast.show { display: block; animation: fadein 0.2s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ===== 管理后台 ===== */
.stat-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 12px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat-card .num { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.stat-card .label { font-size: 0.75rem; color: var(--text-2); margin-top: 2px; }

.admin-table-card { background: var(--card); border-radius: var(--radius); margin: 0 12px 12px; padding: 12px; box-shadow: var(--shadow); overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; min-width: 560px; }
.admin-table th, .admin-table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table th { color: var(--text-2); font-weight: 600; }
.admin-table .title-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.btn-mini { padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; margin-right: 4px; }
.btn-mini.feature { background: #fef3c7; color: #b45309; }
.btn-mini.off { background: #fee2e2; color: #b91c1c; }
.btn-mini.on { background: #dcfce7; color: #15803d; }
.btn-mini.del { background: #f3f4f6; color: #6b7280; }
.status-tag { padding: 1px 6px; border-radius: 4px; font-size: 0.7rem; }
.status-tag.active { background: #dcfce7; color: #15803d; }
.status-tag.off { background: #f3f4f6; color: #6b7280; }
.status-tag.deleted { background: #fee2e2; color: #b91c1c; }

/* ===== 我的发布 ===== */
.my-item { position: relative; }
.my-status { position: absolute; right: 10px; top: 10px; }
.my-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }

/* ===== 通用 ===== */
.text-primary { color: var(--primary); }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.load-more {
  display: block; margin: 6px auto 16px; padding: 10px 40px; border-radius: 20px;
  background: var(--card); color: var(--text-2); font-size: 0.85rem; border: 1px solid var(--border);
}
.load-more:disabled { color: var(--text-3); }
