/* 业主房源开发工作台 — 移动优先，宽屏切换为侧栏 + 表格布局 */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #101828;
  --ink-2: #475467;
  --muted: #667085;
  --line: #e4e7ec;
  --line-2: #d0d5dd;
  --brand: #0f766e;
  --brand-2: #0b544e;
  --brand-soft: #d3efe9;
  --sell: #c2410c;
  --sell-soft: #ffedd5;
  --rent: #1d4ed8;
  --rent-soft: #dbe4ff;
  --won: #047857;
  --won-soft: #d1fae5;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --warn: #a15c07;
  --warn-soft: #fef0c7;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
  --tab-h: 56px;
  --top-h: 52px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }

/* ---------------------------------------------------------------- 框架 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--top-h);
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  height: calc(var(--top-h) + env(safe-area-inset-top));
  background: var(--brand);
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(255, 255, 255, .18);
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700; flex: none;
}
.brand strong { display: block; font-size: 15px; line-height: 1.15; }
.brand small { display: block; font-size: 11px; opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topnav { display: none; gap: 2px; }
.topnav a {
  color: rgba(255, 255, 255, .85); text-decoration: none;
  padding: 7px 12px; border-radius: 9px; font-size: 14px; white-space: nowrap;
}
.topnav a[aria-current="page"] { background: rgba(255, 255, 255, .2); color: #fff; font-weight: 600; }

.ghost {
  border: 1px solid rgba(255, 255, 255, .45);
  background: transparent; color: #fff;
  padding: 6px 10px; border-radius: 9px; font-size: 13px; cursor: pointer;
}
.ghost:active { background: rgba(255, 255, 255, .16); }
.ghost .badge-dot { color: #ffe08a; font-weight: 700; }

.conn {
  background: var(--warn-soft); color: var(--warn);
  font-size: 13px; padding: 7px 12px; text-align: center;
  border-bottom: 1px solid #fddcb0;
}
.conn[data-kind="online"] { background: var(--won-soft); color: var(--won); border-color: #a7f3d0; }
.conn[data-kind="danger"] { background: var(--danger-soft); color: var(--danger); border-color: #fbcfc9; }

.view {
  padding: 12px 12px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom));
  max-width: 1440px;
  margin: 0 auto;
}
.view:focus { outline: none; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 11px; position: relative;
}
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a[aria-current="page"] { color: var(--brand); font-weight: 600; }
.tabbar a .dot {
  position: absolute; top: 7px; right: 26%;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 10px; line-height: 16px; font-weight: 700;
}

@media (min-width: 900px) {
  .topbar { padding-left: 16px; padding-right: 16px; }
  .brand { flex: none; width: 190px; }
  .topnav { display: flex; flex: 1; }
  .topnav a {
    display: flex; align-items: center; padding: 0 14px; height: 100%;
    color: var(--muted); text-decoration: none; font-size: 14px;
  }
  .topnav a[aria-current="page"] { color: var(--brand); font-weight: 700; box-shadow: inset 0 -2px 0 var(--brand); }
  .tabbar { display: none; }
  .view { padding: 20px 20px 40px; }
}

/* ---------------------------------------------------------------- 通用块 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-head .spacer, .spacer { flex: 1; }
.card-body { padding: 12px 14px; }
.card-body.pad0 { padding: 0; }

.section-title { margin: 18px 2px 8px; font-size: 13px; font-weight: 700; color: var(--ink-2); letter-spacing: .02em; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.wrap { flex-wrap: wrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mb8 { margin-bottom: 8px; }
.hide { display: none !important; }

/* ---------------------------------------------------------------- 指标 */
.metrics {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
@media (min-width: 560px) { .metrics { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .metrics { grid-template-columns: repeat(6, 1fr); } }

.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; text-align: left; cursor: pointer; box-shadow: var(--shadow);
  display: block; width: 100%;
}
.metric:active { background: var(--surface-2); }
.metric b { display: block; font-size: 23px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.metric[data-tone="sell"] b { color: var(--sell); }
.metric[data-tone="rent"] b { color: var(--rent); }
.metric[data-tone="won"] b { color: var(--won); }
.metric[data-tone="warn"] b { color: var(--danger); }
.metric[data-plain="1"] { cursor: default; }

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.count-pill {
  flex: 1 1 auto; min-width: 74px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 8px; text-align: center; cursor: pointer;
}
.count-pill b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.count-pill span { font-size: 11px; color: var(--muted); }
.count-pill[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-2); }

/* ---------------------------------------------------------------- 条 / 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  padding: 9px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
  min-height: 40px; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.dial { background: var(--won); border-color: var(--won); color: #fff; }
.btn.danger { background: #fff; border-color: #f4a9a3; color: var(--danger); }
.btn.soft { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-2); }
.btn.sm { padding: 6px 10px; font-size: 13px; min-height: 32px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 auto; }
.linkbtn { background: none; border: 0; color: var(--brand-2); font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 13px; }
.linkbtn:active { background: var(--brand-soft); }

/* ---------------------------------------------------------------- 标签 */
.tag {
  display: inline-block; padding: 2px 7px; border-radius: 999px;
  font-size: 11.5px; line-height: 17px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap;
}
.tag.state-to_call { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }
.tag.state-to_follow { background: var(--warn-soft); border-color: #fddcb0; color: var(--warn); }
.tag.state-contacted { background: var(--brand-soft); border-color: #99dccf; color: var(--brand-2); }
.tag.state-developed { background: var(--won-soft); border-color: #a7f3d0; color: var(--won); }
.tag.state-do_not_contact, .tag.state-archived { background: var(--danger-soft); border-color: #fbcfc9; color: var(--danger); }
.tag.intent-sell { background: var(--sell-soft); border-color: #fed7aa; color: var(--sell); }
.tag.intent-rent { background: var(--rent-soft); border-color: #c7d7fe; color: var(--rent); }
.tag.intent-both { background: #f3e8ff; border-color: #e9d5ff; color: #7e22ce; }
.tag.entrusted { background: var(--won-soft); border-color: #a7f3d0; color: var(--won); font-weight: 700; }
.tag.key { background: #fff8e1; border-color: #fde68a; color: #92400e; font-weight: 700; }
.tag.overdue { background: var(--danger-soft); border-color: #fbcfc9; color: var(--danger); font-weight: 700; }
.tag.eff { background: var(--won-soft); border-color: #a7f3d0; color: var(--won); }
.tag.none { background: var(--surface-2); color: var(--muted); }

/* ---------------------------------------------------------------- 列表 */
.list { display: flex; flex-direction: column; }
.item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface);
  cursor: pointer; text-align: left; border-left: 0; border-right: 0; border-top: 0; width: 100%;
}
.item:last-child { border-bottom: 0; }
.item:active { background: var(--surface-2); }
.item-main { flex: 1; min-width: 0; }
.item-title { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; }
.item-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; }
.item-sub .sep { color: var(--line-2); }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.item-rail { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.phone { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

.empty { padding: 26px 14px; text-align: center; color: var(--muted); font-size: 13.5px; }
.empty b { display: block; color: var(--ink-2); font-size: 14px; margin-bottom: 4px; }

/* ---------------------------------------------------------------- 表格（宽屏） */
@media (max-width: 899px) { .table-wrap { display: none; } }
@media (min-width: 900px) {
  .list.mobile-only-on-narrow { display: none; }
  .table-wrap { display: block; overflow-x: auto; }
}
table.grid { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.grid th, table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.grid th { background: var(--surface-2); color: var(--ink-2); font-weight: 600; position: sticky; top: 0; font-size: 12.5px; }
table.grid tbody tr:active td { background: var(--surface-2); }
table.grid td.wrapcell { white-space: normal; min-width: 180px; }

/* ---------------------------------------------------------------- 表单 */
.field { display: block; margin-bottom: 10px; }
.field > label { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
.input, .field select, .field textarea {
  width: 100%; padding: 10px 11px; border: 1px solid var(--line-2); border-radius: 10px;
  background: #fff; min-height: 42px;
}
.field textarea { min-height: 68px; resize: vertical; }
.input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.input[type="search"] { background: var(--surface-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 10px; }
.check { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; font-size: 13.5px; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.err { font-size: 12.5px; color: var(--danger); margin-top: 4px; }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.filters .input, .filters select { min-height: 36px; padding: 6px 9px; border-radius: 8px; width: auto; font-size: 13px; }
.filters input[type="search"] { flex: 1 1 150px; min-width: 130px; }

/* 快速选择 chips */
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-2); background: #fff; border-radius: 999px;
  padding: 7px 12px; font-size: 13.5px; cursor: pointer; min-height: 36px;
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip[data-tone="sell"][aria-pressed="true"] { background: var(--sell); border-color: var(--sell); }
.chip[data-tone="rent"][aria-pressed="true"] { background: var(--rent); border-color: var(--rent); }
.chip[data-tone="won"][aria-pressed="true"] { background: var(--won); border-color: var(--won); }
.chip[data-tone="danger"][aria-pressed="true"] { background: var(--danger); border-color: var(--danger); }
.chip .eff { font-size: 10px; opacity: .75; margin-left: 3px; }
.chip-group { margin-bottom: 12px; }
.chip-group > .lab { font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.chip-group > .lab i { font-style: normal; font-weight: 400; color: var(--muted); font-size: 11.5px; }

/* segment */
.segment { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; overflow-x: auto; }
.segment button {
  flex: 1 1 auto; border: 0; background: transparent; padding: 7px 11px; border-radius: 8px;
  font-size: 13px; cursor: pointer; white-space: nowrap; color: var(--ink-2);
}
.segment button[aria-pressed="true"] { background: #fff; color: var(--brand-2); font-weight: 700; box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }

/* ---------------------------------------------------------------- sheet / dialog */
.sheet-root { position: fixed; inset: 0; z-index: 60; }
.sheet-root[hidden] { display: none; }
/* 每个面板自带一层，后开的盖在先开的上面；关掉上层，下层还在原位。 */
.sheet-layer { position: absolute; inset: 0; display: flex; }
.scrim { position: absolute; inset: 0; background: rgba(16, 24, 40, .45); }
.sheet {
  position: relative; margin: auto; width: 100%; max-width: 520px; max-height: 92vh;
  background: var(--surface); border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column; overflow: hidden;
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); flex: none;
}
.sheet-head h3 { margin: 0; font-size: 16px; flex: 1; }
.sheet-body { padding: 14px; overflow: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex: none; background: var(--surface); }
.sheet-close { border: 0; background: var(--surface-2); width: 32px; height: 32px; border-radius: 8px; font-size: 17px; cursor: pointer; color: var(--ink-2); }
@media (min-width: 900px) {
  .sheet { border-radius: 16px; box-shadow: 0 24px 60px rgba(16, 24, 40, .3); margin: auto; }
  .sheet-layer { align-items: center; justify-content: center; }
}
.sheet-narrow { max-width: 420px; }

/* ---------------------------------------------------------------- toast */
.toast-root {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom));
  z-index: 80; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 460px);
  pointer-events: none;
}
@media (min-width: 900px) { .toast-root { bottom: 24px; } }
.toast {
  background: #1d2939; color: #fff; padding: 10px 14px; border-radius: 10px;
  font-size: 13.5px; box-shadow: var(--shadow); animation: rise .16s ease-out; pointer-events: auto;
}
.toast[data-kind="ok"] { background: #047857; }
.toast[data-kind="err"] { background: #b42318; }
.toast[data-kind="warn"] { background: #a15c07; }

/* ---------------------------------------------------------------- 进度 */
.bar { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width .3s; }
.bar[data-tone="danger"] > i { background: var(--danger); }
.bar[data-tone="won"] > i { background: var(--won); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }

.spinner {
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  animation: spin .7s linear infinite; display: inline-block;
}
.spinner[data-dark="1"] { border-color: rgba(15, 118, 110, .25); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.skeleton i { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--line) 25%, #eef1f5 37%, var(--line) 63%); background-size: 400% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------------------------------------------------------- 拨号卡 */
.dial-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.dial-card .top { padding: 14px; background: linear-gradient(180deg, var(--brand-soft), #fff); }
.dial-card .name { font-size: 20px; font-weight: 800; }
.dial-card .num { font-size: 22px; font-weight: 700; letter-spacing: .04em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.dial-card .meta { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.dial-card .ops { padding: 12px 14px 14px; }
.progress-inline { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); padding: 8px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.flagline { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.notice {
  border-left: 3px solid var(--brand); background: var(--surface-2);
  padding: 9px 11px; border-radius: 0 8px 8px 0; font-size: 12.5px; color: var(--ink-2); margin-bottom: 10px;
}
.notice[data-tone="danger"] { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.notice[data-tone="warn"] { border-color: #f79009; background: var(--warn-soft); color: var(--warn); }
.notice[data-tone="won"] { border-color: var(--won); background: var(--won-soft); color: var(--won); }

.kv { display: grid; grid-template-columns: 92px 1fr; gap: 4px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

.timeline { display: flex; flex-direction: column; gap: 0; }
.tl { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.tl:last-child { border-bottom: 0; }
.tl .when { flex: none; width: 92px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.tl .body { flex: 1; min-width: 0; }

/* 导入向导的字段映射：窄屏也要能看清，因此不用 .table-wrap */
.maphead, .maprow {
  display: grid; grid-template-columns: 34px minmax(80px, 1.1fr) minmax(70px, 1fr) minmax(120px, 1.2fr);
  gap: 8px; align-items: center;
}
.maphead { font-size: 11.5px; color: var(--muted); font-weight: 700; padding: 2px 0 6px; }
.maprow { padding: 4px 0; border-top: 1px solid var(--line); font-size: 13px; }
.maprow select { width: 100%; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 8px; background: #fff; min-height: 38px; font-size: 13px; }
.maprow .col-letter { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; }

details { font-size: 13px; }
details > summary { cursor: pointer; color: var(--brand-2); font-weight: 600; padding: 4px 0; }

.queue-item { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.queue-item .kind { flex: none; font-size: 11px; background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: 2px 6px; font-weight: 700; }
