/* ================= 房租水电管理系统 ================= */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e4e9f2;
  --text: #0f172a;
  --muted: #64748b;
  --muted2: #94a3b8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
a { color: var(--primary); }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 700;
}
.brand small { font-weight: 400; color: var(--muted2); font-size: 12px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 236px; flex: 0 0 236px; background: #fff; border-right: 1px solid var(--border);
  padding: 14px 10px; overflow-y: auto;
}
.side-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted2); font-weight: 600; letter-spacing: .5px;
  padding: 8px 8px 6px; text-transform: uppercase;
}
.side-title button {
  border: none; background: var(--primary-light); color: var(--primary);
  width: 22px; height: 22px; border-radius: 6px; cursor: pointer; font-size: 15px; line-height: 1;
}
.side-title button:hover { background: var(--primary); color: #fff; }
.house-list { list-style: none; margin: 0 0 14px; padding: 0; }
.house-list li {
  padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex;
  align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 2px;
}
.house-list li:hover { background: #f1f5f9; }
.house-list li.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.house-list li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.house-list li .tag {
  font-size: 11px; padding: 1px 6px; border-radius: 20px; background: #e2e8f0; color: var(--muted);
}
.house-list li .tag.on { background: #dcfce7; color: var(--success); }
.nav { list-style: none; margin: 0; padding: 0; }
.nav li {
  padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--muted);
}
.nav li:hover { background: #f1f5f9; }
.nav li.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }

main { flex: 1; padding: 20px; overflow-x: hidden; min-width: 0; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.page-head h2 { font-size: 20px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-head .acts { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 卡片 / 网格 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.card > h3 {
  font-size: 15px; margin-bottom: 12px; display: flex; align-items: center;
  justify-content: space-between; gap: 8px;
}
.card > h3 .hint { font-size: 12px; font-weight: 400; color: var(--muted2); }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .sidebar { width: 64px; flex-basis: 64px; }
  .sidebar .nm, .nav li, .side-title span { font-size: 0; }
  .nav li { text-align: center; }
}

/* ---------- KPI ---------- */
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.kpi .extra { font-size: 12px; color: var(--muted2); margin-top: 2px; }
.kpi.primary .value { color: var(--primary); }
.kpi.success .value { color: var(--success); }
.kpi.warning .value { color: var(--warning); }
.kpi.danger .value { color: var(--danger); }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font-size: 13px;
  font-family: inherit; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td {
  padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap;
}
table.tbl th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; }
table.tbl td:first-child, table.tbl th:first-child,
table.tbl td.l, table.tbl th.l { text-align: left; }
table.tbl tbody tr:hover { background: #f8fafc; }
table.tbl tfoot td { font-weight: 700; background: #f8fafc; border-top: 2px solid var(--border); }
.num { font-variant-numeric: tabular-nums; }
tr.detail-row td { background: #fbfdff; text-align: left; font-size: 12px; color: var(--muted); white-space: normal; }
tr.detail-row .tier { display: inline-block; margin-right: 14px; }
.muted { color: var(--muted2); }
.strong { font-weight: 600; }
.link { color: var(--primary); cursor: pointer; text-decoration: none; border-bottom: 1px dashed #bfdbfe; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px;
  background: #e2e8f0; color: var(--muted);
}
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.wait { background: #fef3c7; color: #b45309; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.red { background: #fee2e2; color: #b91c1c; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.field .tip { font-size: 11px; color: var(--muted2); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 10050;   /* 必须高于 .gate(9999)，否则登录页上的注册/充值弹窗会被盖住 */
}
.modal-mask.hidden { display: none; }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 620px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25); animation: pop .18s ease;
}
.modal.wide { max-width: 860px; }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }
.modal-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-size: 16px; }
.modal-head .x { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 18px; }
.modal-foot {
  padding: 12px 18px; border-top: 1px solid var(--border); display: flex;
  justify-content: flex-end; gap: 8px; background: #fafbfc; border-radius: 0 0 12px 12px;
}

/* 预览框 */
.preview {
  background: var(--primary-light); border: 1px solid #bfdbfe; border-radius: 8px;
  padding: 10px 12px; font-size: 13px; margin-top: 4px;
}
.preview .pv-row { display: flex; justify-content: space-between; gap: 10px; }
.preview b { color: var(--primary-dark); }
.preview .tiers { margin-top: 6px; padding-top: 6px; border-top: 1px dashed #bfdbfe; font-size: 12px; color: #334155; }

/* ---------- 图表 ---------- */
.chart-box { width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-legend b { color: var(--text); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs .tab {
  padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent;
  font-size: 14px; margin-bottom: -1px;
}
.tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted2); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ---------- 说明 ---------- */
.doc h4 { margin: 18px 0 6px; font-size: 14px; }
.doc p, .doc li { color: #334155; font-size: 13px; }
.doc code {
  background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px;
  font-family: Consolas, monospace;
}
.doc table.tbl td, .doc table.tbl th { text-align: left; }

/* ---------- 租金计划 ---------- */
tr.rp-paid td { color: var(--muted); }
tr.rp-unpaid td { background: #fff7f7; }
tr.rp-unpaid td.strong { color: var(--danger); }
tr.rp-overdue td { background: #fff1f1; }
.pay-state {
  display: inline-block; padding: 2px 10px; border-radius: 6px; font-size: 12px;
  font-weight: 600; border: 1px solid transparent;
}
.pay-state.paid { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.pay-state.unpaid { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.pay-state.overdue { background: #dc2626; color: #fff; border-color: #b91c1c; }
.pay-state.soon { background: #fef3c7; color: #b45309; border-color: #fde68a; }

/* ---------- 催收提醒 ---------- */
.remind-card {
  background: #fff; border: 1px solid #fecaca; border-left: 4px solid var(--danger);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 16px;
}
.remind-card.ok { border-color: #bbf7d0; border-left-color: var(--success); }
.rc-head { font-size: 15px; font-weight: 700; color: var(--danger); }
.remind-card.ok .rc-head { color: var(--success); }
.rc-sub { font-size: 12px; font-weight: 400; color: var(--muted2); margin-left: 8px; }
.rc-kpi { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--muted); }
.rc-kpi span { background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; padding: 3px 9px; }
.rc-kpi b { font-size: 14px; color: var(--text); }
.rc-kpi span.r { border-color: #fecaca; background: #fff7f7; }
.rc-kpi span.o { border-color: #fed7aa; background: #fffbeb; }
.rc-block { margin-top: 14px; }
.rc-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.rc-block .tbl { font-size: 13px; }
.rc-block .tbl th, .rc-block .tbl td { padding: 6px 8px; }
tr.rm-overdue td { background: #fff1f1; }
tr.rm-today td { background: #fff7f7; }
tr.rm-soon td { background: #fffbeb; }
tr.rm-warn td { background: #fff7ed; }
tr.rm-new td { background: #f8fafc; }
.rc-tip {
  margin-top: 12px; font-size: 12px; color: #b45309; background: #fffbeb;
  border: 1px solid #fde68a; border-radius: 6px; padding: 7px 10px;
}

/* ---------- 导入向导 ---------- */
.imp-steps { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted2); margin-bottom: 12px; }
.imp-steps b {
  width: 20px; height: 20px; border-radius: 50%; background: #e2e8f0; color: var(--muted);
  display: inline-grid; place-items: center; font-size: 11px; margin-right: 4px;
}
.imp-steps .on b { background: var(--primary); color: #fff; }
.imp-steps .on { color: var(--primary); font-weight: 600; }
.imp-grid {
  display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  margin-bottom: 10px;
}
.imp-grid .field { gap: 2px; }
.imp-grid select { font-size: 12px; padding: 5px 6px; }
.imp-preview { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.imp-preview table.tbl { font-size: 12px; }
.imp-preview table.tbl th { position: sticky; top: 0; z-index: 1; }
.imp-preview table.tbl td { padding: 5px 8px; }
.imp-preview td.col-date { background: #eff6ff; font-weight: 600; }
.imp-preview th.col-date { background: #dbeafe; color: #1d4ed8; }
.block-tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.block-tag.b0 { background: #dbeafe; color: #1d4ed8; }
.block-tag.b1 { background: #dcfce7; color: #15803d; }
.block-tag.b2 { background: #fef3c7; color: #b45309; }
.block-tag.b3 { background: #fae8ff; color: #a21caf; }
.block-tag.b4 { background: #ffe4e6; color: #be123c; }

/* ---------- 租户水电账单（清晰表格） ---------- */
.tbill {
  background: #fff; border: 1px solid #dbeafe; border-radius: 14px; overflow: hidden;
  max-width: 760px; margin: 0 auto; box-shadow: 0 8px 24px rgba(37, 99, 235, .12);
}
.tbill-head {
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 55%, #7c3aed 100%);
  color: #fff; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.tbill-head .hb-l { min-width: 0; }
.tbill-head .t1 { font-size: 19px; font-weight: 700; letter-spacing: .5px; text-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.tbill-head .t2 { font-size: 12px; color: #e0e7ff; margin-top: 5px; line-height: 1.5; }
.tbill-head .hb-r {
  flex: none; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 12px; padding: 8px 16px; text-align: center; min-width: 132px;
}
.tbill-head .amt-label { display: block; font-size: 11px; color: #e0e7ff; letter-spacing: 1px; }
.tbill-head .amt {
  display: block; font-size: 24px; font-weight: 800; margin-top: 2px; letter-spacing: -.5px;
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
.tbill table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbill th, .tbill td { border-bottom: 1px solid #eef2f7; padding: 11px 12px; text-align: center; }
.tbill th {
  background: #eef4ff; font-weight: 700; font-size: 13px; color: #1e3a8a;
  border-bottom: 2px solid #c7d9ff; letter-spacing: .5px;
}
.tbill td.l { text-align: left; }
.tbill td.r { text-align: right; font-variant-numeric: tabular-nums; }
.tbill tbody tr:nth-child(even) td { background: #fbfdff; }
.tbill tbody td.amt { font-weight: 700; font-size: 15px; color: #0f172a; }
.tbill .calc-expr { font-size: 12.5px; color: #475569; line-height: 1.5; }
.tbill .tier-line { font-size: 11.5px; color: #b45309; margin-top: 3px; }
.tbill tr.sum td { background: #f5f8ff !important; font-weight: 700; border-top: 2px solid #c7d9ff; }
.tbill tr.grand td {
  background: linear-gradient(90deg, #eff6ff 0%, #dbeafe 100%) !important;
  font-weight: 800; font-size: 16px; color: #1e40af; border-top: 2px solid #93c5fd;
}
.tbill tr.grand td.amt { font-size: 20px; color: #1d4ed8; }
.tbill-foot {
  padding: 12px 20px; font-size: 12px; color: #475569; background: #f8fafc;
  border-top: 1px solid #eef2f7; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
/* 项目色标 */
.pill {
  display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: 12.5px; font-weight: 700;
  letter-spacing: .5px; white-space: nowrap;
}
.pill.elec { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.pill.water { background: #ecfeff; color: #0e7490; border: 1px solid #a5f3fc; }
.pill.rent { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.pill.other { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.pill.total { background: #1d4ed8; color: #fff; border: 1px solid #1e40af; }

/* ---------- 财务统计 ---------- */
.fin-year-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.fin-year-bar .y {
  padding: 5px 14px; border: 1px solid var(--border); border-radius: 20px; cursor: pointer;
  font-size: 13px; background: #fff;
}
.fin-year-bar .y.on { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.fin-net-pos { color: var(--success); }
.fin-net-neg { color: var(--danger); }
table.tbl td.cat-cell { text-align: left; font-weight: 600; }

/* ---------- 登录 / 授权锁屏 ---------- */
.gate {
  position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 45%, #ecfeff 100%);
}
.gate.lock { background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px); }
.gate-box {
  width: 420px; max-width: 92vw; background: #fff; border-radius: 14px; padding: 26px 26px 20px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .18); border: 1px solid #e2e8f0;
}
.gate-head { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.gate-head .logo {
  width: 42px; height: 42px; border-radius: 10px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700;
}
.gate-head .logo.warn { background: #dc2626; }
.gate-head h2 { font-size: 18px; margin: 0; }
.gate-head .sub { font-size: 12.5px; color: #64748b; margin-top: 3px; }
.gate-err {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px;
}
.gate-flags {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  padding: 7px 12px; border-radius: 8px; font-size: 12px; margin-bottom: 12px;
}
.gate-foot { margin-top: 14px; font-size: 11.5px; color: #94a3b8; text-align: center; line-height: 1.6; }

/* 登录页 · 安卓安装包下载 */
.gate-dl { margin-top: 16px; padding-top: 14px; border-top: 1px dashed #e2e8f0; text-align: center; }
.gate-dl .dl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 10px 12px; border-radius: 10px; text-decoration: none;
  border: 1px solid #bfdbfe; background: #f0f7ff; color: #1d4ed8;
  font-size: 13.5px; font-weight: 600; transition: background .15s, border-color .15s;
}
.gate-dl .dl-btn:hover { background: #e0efff; border-color: #93c5fd; }
.gate-dl .dl-btn:active { background: #d6e8ff; }
.gate-dl .dl-ico { font-size: 14px; line-height: 1; }
.gate-dl .dl-note { margin-top: 7px; font-size: 11.5px; color: #94a3b8; }
@media (max-width: 420px) {
  .gate-dl .dl-btn { font-size: 13px; padding: 9px 10px; }
}
.gate-tip {
  margin-top: 12px; padding: 9px 12px; border-radius: 8px; font-size: 12px; line-height: 1.7;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
}
.gate-tip b { color: #b45309; font-family: ui-monospace, Consolas, monospace; }
.gate-tip .link { margin-left: 6px; }
.gate .field { margin-bottom: 12px; }
.gate .btn-row input { flex: 1; }

/* 登录页 / 锁屏页 · 广告位（内容后台远程下发；.sponsor = 招商位，视觉上更显眼） */
.gate-ad {
  display: none;   /* 空占位时不占空间，等 Ads.mount 填了内容再显示 */
  position: relative; align-items: center; gap: 10px;
  margin-top: 14px; padding: 11px 12px 11px 13px; border-radius: 10px;
  border: 1px solid #dbeafe; background: linear-gradient(180deg, #f8fbff, #f1f7ff);
  text-align: left; transition: border-color .15s, box-shadow .15s;
}
.gate-ad.sponsor { border-color: #fed7aa; background: linear-gradient(180deg, #fffdf8, #fff7ed); }
.gate-ad:not(:empty) { display: flex; }
.gate-ad:hover { border-color: #93c5fd; box-shadow: 0 2px 10px rgba(37, 99, 235, .08); }
.gate-ad.sponsor:hover { border-color: #fdba74; box-shadow: 0 2px 10px rgba(234, 88, 12, .10); }
.gate-ad .ga-tag {
  flex: 0 0 auto; font-size: 10px; line-height: 1; padding: 4px 6px; border-radius: 4px;
  color: #1d4ed8; background: #dbeafe; letter-spacing: .5px;
}
.gate-ad.sponsor .ga-tag { color: #c2410c; background: #ffedd5; }
.gate-ad .ga-body { flex: 1; min-width: 0; }
.gate-ad .ga-title { font-size: 13px; font-weight: 600; color: #0f172a; line-height: 1.4; }
.gate-ad .ga-text { margin-top: 3px; font-size: 11.5px; color: #64748b; line-height: 1.55; }
.gate-ad .ga-btn {
  flex: 0 0 auto; padding: 6px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid #2563eb; background: #2563eb; color: #fff;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.gate-ad.sponsor .ga-btn { border-color: #ea580c; background: #ea580c; }
@media (max-width: 420px) {
  .gate-ad { padding: 10px; gap: 8px; }
  .gate-ad .ga-title { font-size: 12.5px; }
  .gate-ad .ga-text { font-size: 11px; }
  .gate-ad .ga-btn { padding: 5px 8px; font-size: 11.5px; }
}

/* 邀请有奖 / 代理招募 */
.inv-code-box {
  text-align: center; padding: 14px 12px; border-radius: 10px;
  background: #f8fafc; border: 1px dashed #cbd5e1;
}
.inv-code-label { font-size: 11.5px; color: #64748b; letter-spacing: 2px; }
.inv-code {
  font-family: ui-monospace, Consolas, monospace; font-size: 26px; font-weight: 700;
  letter-spacing: 5px; color: #1d4ed8; margin: 6px 0 10px;
}
.inv-stats { display: flex; gap: 8px; margin-top: 12px; }
.inv-stats > div { flex: 1; text-align: center; padding: 10px 4px; border-radius: 8px; background: #f1f5f9; }
.inv-stats b { display: block; font-size: 19px; color: #0f172a; line-height: 1.3; }
.inv-stats span { font-size: 11px; color: #64748b; }
.inv-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.inv-tbl th {
  text-align: left; font-weight: 600; color: #64748b; font-size: 11.5px;
  border-bottom: 1px solid #e2e8f0; padding: 7px 6px;
}
.inv-tbl td { padding: 7px 6px; border-bottom: 1px solid #f1f5f9; }

/* ---------- 顶栏用户条 ---------- */
.user-chip {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: #475569;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px;
  /* 顶栏按钮多，窄屏下这里必须不换行，否则「邀请/充值/改密/退出」会竖着叠起来 */
  white-space: nowrap; flex-wrap: nowrap; flex: 0 0 auto;
}
.user-chip .who { font-weight: 600; color: #0f172a; }
.user-chip .role { font-size: 11px; background: #ede9fe; color: #6d28d9; border-radius: 4px; padding: 1px 6px; margin-left: 6px; }
.user-chip .role.user { background: #e0f2fe; color: #0369a1; }
.user-chip .lic { padding: 1px 8px; border-radius: 10px; font-size: 11.5px; }
.user-chip .lic.ok { background: #dcfce7; color: #15803d; }
.user-chip .lic.warn { background: #fef3c7; color: #b45309; }
.user-chip .lic.bad { background: #fee2e2; color: #b91c1c; }
.user-chip .exp { font-size: 11.5px; color: #64748b; }
.user-chip .link { color: var(--primary); cursor: pointer; }

/* ---------- 侧栏房屋分组 / 房间 ---------- */
.house-list li.grp {
  background: #f1f5f9; color: #475569; font-size: 12px; font-weight: 600; cursor: default;
  display: flex; align-items: center; justify-content: space-between;
}
.house-list li.grp .add { cursor: pointer; color: var(--primary); font-size: 15px; padding: 0 6px; }
.house-list li.sub { padding-left: 22px; font-size: 13px; }
.house-list li.sub .nm::before { content: '└ '; color: #cbd5e1; }

/* ---------- 后台管理 ---------- */
.code { font-family: Consolas, 'Courier New', monospace; font-size: 12px; letter-spacing: .5px; }
.fp {
  display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 4px; margin: 1px 2px 1px 0;
  background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; font-family: Consolas, monospace;
}
.fp.trial { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.fp.authorized { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.fp.blocked { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.chk-box { max-height: 150px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.chk { display: inline-flex; align-items: center; gap: 5px; width: 46%; font-size: 13px; padding: 3px 0; }
.card .acts { float: right; display: flex; gap: 6px; align-items: center; font-weight: 400; }
.card h3 .acts select, .card h3 .acts .btn { font-size: 12px; }

@media print {
  body { background: #fff; }
  .gate, .gate.lock { display: none !important; }
  body.printing .topbar, body.printing .layout, body.printing .modal-mask { display: none !important; }
  body.printing .print-sheet { display: block; }
  .print-sheet {
    width: 100%; max-width: 720px; margin: 0 auto; padding: 8mm; font-size: 13px; color: #000;
  }
  .print-sheet h2 { text-align: center; font-size: 20px; margin-bottom: 4px; }
  .print-sheet .ps-sub { text-align: center; color: #555; font-size: 12px; margin-bottom: 12px; }
  .print-sheet table { width: 100%; border-collapse: collapse; }
  .print-sheet th, .print-sheet td { border: 1px solid #999; padding: 6px 8px; text-align: left; }
  .print-sheet .ps-total { font-weight: 700; }
  .print-sheet .ps-foot { margin-top: 18px; display: flex; justify-content: space-between; color: #333; }
}

/* ===================== 一键初始化 / 清空数据 ===================== */
.ipt { padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; }
.reset-box { font-size: 14px; line-height: 1.7; }
.reset-box .warn-line {
  color: var(--danger); background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 6px; padding: 8px 10px; margin: 0 0 10px;
}
.reset-box .ipt { width: 100%; box-sizing: border-box; margin-top: 4px; }
.reset-opt {
  display: flex; gap: 8px; align-items: flex-start; padding: 8px 0;
  border-bottom: 1px dashed #e2e8f0; cursor: pointer;
}
.reset-opt small { color: #64748b; }
.reset-box .code-word { color: var(--danger); }

/* ===================== 登录：记住登录状态 / 自动登录 ===================== */
.gate-remember {
  display: flex; align-items: center; gap: 6px; margin-top: 10px;
  font-size: 13px; color: #475569; cursor: pointer; user-select: none;
}
.gate-remember input { width: 15px; height: 15px; cursor: pointer; }
.auto-login-tip {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%);
  z-index: 10060; background: rgba(15, 23, 42, .88); color: #fff;
  padding: 12px 20px; border-radius: 8px; font-size: 14px;
  display: flex; align-items: center; gap: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
.auto-login-tip .spin {
  width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff; border-radius: 50%; display: inline-block;
  animation: rm-spin .8s linear infinite;
}
@keyframes rm-spin { to { transform: rotate(360deg); } }

/* ===================== 移动端适配（手机 / PWA 安装后） ===================== */
/* 桌面端隐藏汉堡按钮；640px 以下侧边栏变抽屉，顶部操作按钮横向滑动收纳 */
.nav-toggle { display: none; }

@media (max-width: 640px) {
  /* 顶栏两行：品牌行 + 可横向滑动的操作行（保留全部功能入口，不删按钮） */
  .topbar {
    height: auto; flex-wrap: wrap; gap: 6px;
    padding: 8px 10px;
    padding-top: calc(8px + env(safe-area-inset-top));
  }
  .brand { font-size: 15px; flex: 1; min-width: 0; }
  .brand .logo { width: 26px; height: 26px; font-size: 13px; }
  .brand small { display: none; }
  .top-actions {
    width: 100%;
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 6px; padding-bottom: 2px;
  }
  .top-actions .btn { flex: 0 0 auto; font-size: 12px; padding: 6px 10px; }

  /* 汉堡按钮 */
  .nav-toggle {
    display: grid; place-items: center;
    width: 34px; height: 34px; margin-right: 2px; flex: 0 0 auto;
    border: 1px solid var(--border); background: #fff; border-radius: 8px;
    font-size: 17px; cursor: pointer; color: var(--text); padding: 0;
  }

  /* 侧边栏 → 抽屉（覆盖 720px 断点的 64px 图标条样式） */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 272px; flex: 0 0 auto;
    z-index: 100;
    padding-top: calc(14px + env(safe-area-inset-top));
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(15, 23, 42, .18);
  }
  body.nav-open .sidebar { transform: none; }
  .sidebar .nm { font-size: 14px; }
  .side-title span { font-size: 12px; }
  .nav li { text-align: left; font-size: 14px; }
  .house-list li, .nav li { padding: 11px 12px; }

  /* 抽屉遮罩（层级低于登录遮罩 9999 / 弹窗 10050） */
  .nav-mask {
    position: fixed; inset: 0; z-index: 99;
    background: rgba(15, 23, 42, .45);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.nav-open .nav-mask { opacity: 1; pointer-events: auto; }

  main { padding: 12px 10px calc(16px + env(safe-area-inset-bottom)); }
}

/* ===================== 手机端专用（≤640px） =====================
   电脑端完全不加载下面这些规则：全部包裹在 media query 内。
   目标：底部 Tab + 更多抽屉 + 表格转卡片 + 底部弹窗 + 触控友好。 */

/* 桌面端隐藏所有手机端组件 */
.fab, .bottom-nav, .more-sheet, .sheet-mask { display: none; }

@media (max-width: 640px) {
  /* ---- 顶栏瘦身：只留品牌 + 用户条，操作全部进「更多」 ---- */
  .topbar {
    height: 52px; flex-wrap: nowrap; gap: 8px;
    padding: 6px 12px;
    padding-top: calc(6px + env(safe-area-inset-top));
  }
  .brand { font-size: 15px; min-width: 0; overflow: hidden; }
  .brand > span:not(.logo) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .brand small { display: none; }
  .top-actions { display: none; }          /* 原 7 个按钮移入「更多」抽屉 */
  .nav-toggle { display: none; }           /* 由底部「房屋」Tab 取代 */

  .user-chip { display: none; }            /* 账号/有效期移入「更多」抽屉顶部，顶栏保持清爽 */
  .user-chip .exp, .user-chip .link { display: none; }   /* 有效期/邀请/充值/改密/退出 → 更多 */

  /* ---- 侧栏抽屉（由「房屋」Tab 打开） ---- */
  .sidebar { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }

  /* ---- 底部 Tab ---- */
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
    background: #fff; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -1px 10px rgba(15, 23, 42, .06);
  }
  .bottom-nav button {
    flex: 1; border: 0; background: none; cursor: pointer; font-family: inherit;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 7px 0 6px; min-height: 54px;
    font-size: 11px; color: var(--muted); -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav button i { font-style: normal; font-size: 19px; line-height: 1.15; }
  .bottom-nav button.active { color: var(--primary); font-weight: 600; }
  .bottom-nav button:active { background: #f1f5f9; }

  /* 主区域给底部 Tab 让位 */
  main { padding: 12px 10px calc(78px + env(safe-area-inset-bottom)); }

  /* ---- 悬浮「添加房屋」按钮 ---- */
  .fab {
    display: grid; place-items: center;
    position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 201;
    width: 52px; height: 52px; border-radius: 50%; border: 0;
    background: var(--primary); color: #fff; font-size: 26px; line-height: 1;
    box-shadow: 0 6px 18px rgba(37, 99, 235, .38); cursor: pointer;
  }
  .fab:active { background: var(--primary-dark); transform: scale(.96); }

  /* ---- 「更多」底部抽屉 ---- */
  .sheet-mask {
    display: block; position: fixed; inset: 0; z-index: 300;
    background: rgba(15, 23, 42, .45);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.sheet-open .sheet-mask { opacity: 1; pointer-events: auto; }
  .more-sheet {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 301;
    background: #fff; border-radius: 16px 16px 0 0;
    padding: 6px 12px calc(14px + env(safe-area-inset-bottom));
    max-height: 82vh; overflow-y: auto;
    transform: translateY(105%); transition: transform .22s ease;
    box-shadow: 0 -10px 36px rgba(15, 23, 42, .22);
  }
  body.sheet-open .more-sheet { transform: none; }
  .ms-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 10px; }
  .ms-head b { font-size: 15px; }
  .ms-user {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    margin: 0 4px 10px; padding: 10px 12px; border-radius: 10px;
    background: #f8fafc; border: 1px solid var(--border); font-size: 12.5px; color: var(--muted);
  }
  .ms-user b { font-size: 14px; color: var(--text); }
  .ms-user .ms-exp { width: 100%; font-size: 11.5px; color: var(--muted2); }
  .ms-x {
    border: 0; background: none; cursor: pointer; padding: 0 6px;
    font-size: 24px; line-height: 1; color: var(--muted);
  }
  .ms-group { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
  .ms-group button {
    border: 1px solid var(--border); background: #f8fafc; color: var(--text);
    border-radius: 10px; padding: 13px 10px; min-height: 46px;
    font-size: 13.5px; font-family: inherit; text-align: left; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .ms-group button:active { background: #eef2f7; }
  .ms-group button.danger { color: var(--danger); border-color: #fecaca; background: #fff7f7; }
  .ms-group button.danger:active { background: #fee2e2; }

  /* ---- 弹窗 → 底部抽屉 ---- */
  .modal-mask { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 16px 16px 0 0; animation: sheet-up .2s ease; }
  .modal.wide { max-width: none; }
  .modal-head { border-radius: 16px 16px 0 0; }
  .modal-body { max-height: 68vh; overflow-y: auto; }
  .modal-foot { border-radius: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; min-height: 44px; }
  @keyframes sheet-up { from { transform: translateY(24%); opacity: .55; } }

  /* ---- 卡片 & 版式收紧 ---- */
  .card { padding: 12px; margin-bottom: 12px; border-radius: 12px; }
  .page-head { margin-bottom: 12px; }
  .page-head h2 { font-size: 18px; }
  .grid { gap: 12px; }
  .kpi { padding: 12px 14px; }
  /* KPI 两列，避免竖向过长 */
  .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 19px; }
  /* 卡片标题里的下拉/按钮换行，标题不竖排 */
  .card > h3 { flex-wrap: wrap; row-gap: 8px; white-space: nowrap; }
  .card > h3 select { flex: 1 1 120px; min-width: 0; max-width: 100%; }
  .card > h3 .btn { flex: 0 0 auto; }

  /* ---- 表格 → 卡片 ---- */
  table.tbl.tbl-cards { display: block; width: 100%; }
  table.tbl.tbl-cards thead { display: none; }
  table.tbl.tbl-cards tbody, table.tbl.tbl-cards tfoot { display: block; }
  table.tbl.tbl-cards tr {
    display: block; background: #fff; border: 1px solid var(--border);
    border-radius: 10px; padding: 8px 12px; margin-bottom: 10px;
  }
  table.tbl.tbl-cards td {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding: 5px 0; border: 0; text-align: right;
    white-space: normal; overflow-wrap: anywhere; font-size: 13px;
  }
  table.tbl.tbl-cards td::before {
    content: attr(data-label);
    flex: 0 0 auto; text-align: left;
    color: var(--muted); font-weight: 600; font-size: 12px;
  }
  /* 第一列当卡片标题：整行加粗、去掉标签 */
  table.tbl.tbl-cards td:first-child {
    display: block; font-size: 14.5px; font-weight: 700; text-align: left;
    padding-bottom: 7px; margin-bottom: 3px; border-bottom: 1px dashed var(--border);
  }
  table.tbl.tbl-cards td:first-child::before { display: none; }
  /* 空单元格不占行 */
  table.tbl.tbl-cards td:empty { display: none; }
  /* 合计行 */
  table.tbl.tbl-cards tfoot tr { background: #f8fafc; border-color: #cbd5e1; }
  table.tbl.tbl-cards tfoot td { font-weight: 700; }
  /* 明细展开行：整块左对齐，不显示标签 */
  table.tbl.tbl-cards tr.detail-row { background: #fbfdff; border-style: dashed; }
  table.tbl.tbl-cards tr.detail-row td { display: block; text-align: left; }
  table.tbl.tbl-cards tr.detail-row td::before { display: none; }

  /* ---- 触控友好 ---- */
  .btn { min-height: 40px; }
  .tabs .tab { padding: 11px 12px; }
  .fin-year-bar .y { padding: 9px 14px; min-height: 40px; }
  .house-list li, .nav li { min-height: 44px; }
  .field input, .field select, .field textarea { padding: 10px 12px; font-size: 16px; } /* 16px 防 iOS 聚焦缩放 */
}

/* ===================== 多端同步状态 / 轻提示 ===================== */
/* 顶栏小标签：显示「已同步 20:31」「同步中…」「离线，待同步」，点击立即同步 */
.user-chip .lic.sync { cursor: pointer; background: #eef2f7; color: #475569; }
.user-chip .lic.sync.ok { background: #ecfdf5; color: #15803d; }
.user-chip .lic.sync.busy { background: #eff6ff; color: #1d4ed8; }
.user-chip .lic.sync.warn { background: #fef3c7; color: #b45309; }

.rm-toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 10080;
  transform: translate(-50%, 12px);
  background: rgba(15, 23, 42, .94); color: #fff;
  padding: 10px 16px; border-radius: 10px;
  font-size: 13px; line-height: 1.5; max-width: 86vw; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .25);
}
.rm-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  /* 手机端顶栏只保留同步状态小标签（品牌后面），其余仍在「更多」里 */
  .user-chip { display: inline-flex; padding: 0; background: none; border: 0; gap: 0; }
  .user-chip > * { display: none !important; }
  .user-chip > .lic.sync { display: inline-flex !important; }
  .user-chip .lic.sync { font-size: 11.5px; padding: 3px 9px; }

  .rm-toast { bottom: calc(84px + env(safe-area-inset-bottom)); font-size: 13.5px; }

  /* 「更多」抽屉里的同步行 */
  .ms-sync { display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin: 0 0 10px; padding: 9px 12px; border-radius: 10px;
    background: #f8fafc; border: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
  .ms-sync b { color: var(--text); font-weight: 600; }
  .ms-sync button {
    border: 1px solid var(--primary); background: #fff; color: var(--primary);
    border-radius: 8px; padding: 7px 12px; font-size: 12.5px; min-height: 34px;
  }
  .ms-sync button:active { background: #eff6ff; }
}

/* ===================== 手机端排版打磨（APK / 手机浏览器，2026-10-29） =====================
   用户反馈「看着挤」。统一放大留白与字号、压缩次要信息：
   - 卡片内外边距 12 → 14，卡片间距 12 → 14，圆角 14
   - 表格卡片化后每行 5px → 7px，标签定宽 70px，右侧数值整齐对齐不再糊成一片
   - 列数 > 6 的表格由 mobile.js 打上 .m-hide 隐藏「累计/备注/编号」等次要列
   - 底部 Tab 56px、悬浮按钮上移，避免压住列表最后一行
   全部包在 ≤640px 内，电脑端零影响。 */
@media (max-width: 640px) {
  main { padding: 14px 12px calc(88px + env(safe-area-inset-bottom)); }

  /* 页面标题区 */
  .page-head { gap: 10px; margin-bottom: 14px; }
  .page-head h2 { font-size: 19px; line-height: 1.3; }
  .page-head .sub { font-size: 12.5px; margin-top: 3px; }
  .page-head .acts { width: 100%; gap: 10px; }
  .page-head .acts .btn { flex: 1 1 auto; }

  /* 卡片 */
  .card { padding: 14px 13px; margin-bottom: 14px; border-radius: 14px; }
  .card > h3 { font-size: 14.5px; line-height: 1.4; row-gap: 10px; margin-bottom: 10px; }
  .card > h3 .hint { font-size: 11.5px; }
  .grid { gap: 12px; }
  .grid-4, .grid-3 { gap: 10px; }

  /* KPI */
  .kpi { padding: 13px 14px; border-radius: 14px; }
  .kpi .label { font-size: 12px; line-height: 1.35; }
  .kpi .value { font-size: 20px; margin-top: 6px; }
  .kpi .extra { font-size: 11.5px; margin-top: 3px; }

  /* 标签页：横向滚动，不再换行挤压 */
  .tabs { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; gap: 2px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab { flex: 0 0 auto; white-space: nowrap; font-size: 13.5px; padding: 10px 13px; }

  /* 表格 → 卡片：更松的行距 + 标签定宽对齐 */
  table.tbl.tbl-cards tr { padding: 12px 13px; margin-bottom: 12px; border-radius: 12px; }
  table.tbl.tbl-cards td { padding: 7px 0; font-size: 14px; line-height: 1.45; gap: 10px; }
  table.tbl.tbl-cards td::before { flex: 0 0 70px; font-size: 12.5px; line-height: 1.45; }
  table.tbl.tbl-cards td:first-child { font-size: 15.5px; padding-bottom: 10px; margin-bottom: 6px; }
  table.tbl.tbl-cards td.m-hide { display: none; }
  table.tbl.tbl-cards tfoot tr { padding: 10px 13px; }
  .table-wrap > table.tbl:not(.tbl-cards) { min-width: 520px; }

  /* 底部 Tab 与悬浮按钮 */
  .bottom-nav button { min-height: 56px; padding: 8px 0 7px; gap: 3px; font-size: 11.5px; }
  .bottom-nav button i { font-size: 20px; }
  .fab { width: 50px; height: 50px; right: 14px; bottom: calc(86px + env(safe-area-inset-bottom)); font-size: 24px; }

  /* 「更多」抽屉 */
  .more-sheet { padding: 8px 14px calc(16px + env(safe-area-inset-bottom)); }
  .ms-group { gap: 10px; margin-bottom: 10px; }
  .ms-group button { padding: 14px 12px; min-height: 50px; font-size: 13.5px; }

  /* 底部抽屉弹窗 / 表单 */
  .modal-head { padding: 15px 16px; }
  .modal-head h3 { font-size: 16.5px; }
  .modal-body { padding: 16px 14px; max-height: 70vh; }
  .modal-foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); gap: 10px; }
  .form-grid { gap: 14px; }
  .field { gap: 6px; }
  .field label { font-size: 12.5px; }
  .field .tip { font-size: 11.5px; line-height: 1.5; }

  /* 正文行距 */
  p, .sub, .muted { line-height: 1.65; }
  .empty { padding: 44px 20px; }
}

/* 超窄屏（≤360px）：KPI 单列，标签收窄 */
@media (max-width: 360px) {
  .grid-4, .grid-3 { grid-template-columns: 1fr; }
  .kpi .value { font-size: 19px; }
  table.tbl.tbl-cards td::before { flex: 0 0 62px; }
}

/* ===================== 手机端排版打磨 · 第二轮（2026-10-29） ===================== */
@media (max-width: 640px) {
  /* 原规则把 .top-actions 整块 display:none，连带把「同步状态」也藏了。
     改为：容器保留，只隐藏里面的按钮（按钮都已在「更多」抽屉里）。 */
  .top-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
  .top-actions > .btn { display: none; }
  .topbar { justify-content: space-between; }

  /* 卡片里的表格不再套一层卡片边框（卡片套卡片最显挤）：改成分隔线列表 */
  .card table.tbl.tbl-cards tr {
    border: 0; border-bottom: 1px solid var(--border);
    border-radius: 0; background: transparent;
    padding: 11px 0; margin: 0;
  }
  .card table.tbl.tbl-cards tr:last-child { border-bottom: 0; }
  .card table.tbl.tbl-cards td:first-child {
    border-bottom: 0; padding-bottom: 6px; margin-bottom: 2px;
  }
  .card table.tbl.tbl-cards td { padding: 6px 0; }

  /* 表格卡片化后，卡片底部的操作按钮单独一行、右对齐，避免挤在字段里 */
  table.tbl.tbl-cards td .link, table.tbl.tbl-cards td a { display: inline-block; padding: 2px 0; }
}

/* ===================== 手机端排版打磨 · 第三轮：催收提醒卡片 ===================== */
@media (max-width: 640px) {
  .remind-card { padding: 13px; border-radius: 14px; margin-bottom: 14px; }
  /* 一行长说明在手机上占三四行，收进小字并在窄屏隐藏（信息在标题里已表达） */
  .rc-head { font-size: 14.5px; line-height: 1.45; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  .rc-sub { display: none; }
  .rc-kpi { gap: 8px; margin-top: 10px; font-size: 11.5px; }
  .rc-kpi span { padding: 4px 9px; border-radius: 8px; }
  .rc-kpi b { font-size: 13.5px; }
  .rc-tip { font-size: 12px; line-height: 1.6; }
  /* 催收卡片里的表格同样用分隔线列表，不再套卡片 */
  .remind-card table.tbl.tbl-cards tr { padding: 10px 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; margin: 0; }
  .remind-card table.tbl.tbl-cards tr:last-child { border-bottom: 0; }
  .remind-card table.tbl.tbl-cards td:first-child { font-size: 15px; }
  /* 操作链接（标记已收 / 复制催缴 / 发账单）单独一行铺开，不挤在字段行里 */
  .remind-card table.tbl.tbl-cards td:last-child { justify-content: flex-start; gap: 16px; padding-top: 8px; }
  .remind-card table.tbl.tbl-cards td:last-child::before { display: none; }
}

@media (max-width: 640px) {
  /* 顶栏：品牌占满剩余宽度、同步标签靠右（上一轮 justify-content:space-between 把品牌挤没了） */
  .topbar { display: flex; align-items: center; }
  .brand { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
  .top-actions { flex: 0 0 auto; margin-left: auto; }
  .user-chip .lic.sync { white-space: nowrap; }
  /* 悬浮按钮再抬高一点，别压住卡片底部的操作链接 */
  .fab { bottom: calc(96px + env(safe-area-inset-bottom)); width: 48px; height: 48px; font-size: 23px; }
}

@media (max-width: 640px) {
  /* 顶栏改绝对定位放同步标签：品牌不再被 flex 挤压消失 */
  .topbar { position: relative; padding-right: 96px; }
  .brand { flex: 1 1 100%; width: 100%; }
  .top-actions { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); margin: 0; }
}

/* ===================== 手机端顶栏 · 最终方案 =====================
   试过「品牌 + 同步标签同行」，459px 及更窄屏下品牌会被挤没。
   定稿：顶栏只留品牌（干净、不打架），同步状态与「立即同步」放进「更多」抽屉。
   同步失败/其他设备有更新时用轻提示告知，不占用顶栏。 */
@media (max-width: 640px) {
  .topbar { position: static; padding-right: 12px; justify-content: flex-start; display: flex; align-items: center; }
  .topbar .brand { flex: 1 1 auto; width: auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
  .top-actions { display: none !important; }
  .user-chip { display: none !important; }
}

/* ===================== 手机端排版打磨 · 第四轮 ===================== */
@media (max-width: 640px) {
  /* 阶梯额度三档：手机上单列，避免「元/度」「已用 x / 已发 y 度」在两列里折成三行 */
  .quota-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
  .quota-grid > div > div:first-child { flex-wrap: wrap; gap: 4px 10px; }

  /* 悬浮「+」在手机上会压住卡片底部的「编辑/打印/删除」：移除，
     添加房间的入口已在「房屋」抽屉顶部与「更多」抽屉里。 */
  .fab { display: none !important; }
  main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* ===================== ICP 备案页脚（工信部合规要求） ===================== */
.icp-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 6px 16px; padding: 18px 16px 22px; margin-top: 10px;
  font-size: 12px; color: var(--muted, #94a3b8);
  border-top: 1px solid var(--border, #e2e8f0);
  background: #fff;
}
.icp-bar a, .gate-icp a { color: var(--muted, #94a3b8); text-decoration: none; }
.icp-bar a:hover, .gate-icp a:hover { color: var(--primary, #2563eb); text-decoration: underline; }
.gate-icp {
  margin-top: 14px; padding-top: 12px; text-align: center;
  border-top: 1px dashed var(--border, #e2e8f0);
  font-size: 11.5px; color: var(--muted, #94a3b8);
}
@media (max-width: 640px) {
  /* 手机底部有固定 Tab 栏，页脚留出避让空间 */
  .icp-bar { padding: 14px 14px calc(80px + env(safe-area-inset-bottom)); font-size: 11.5px; gap: 4px 12px; }
  .gate-icp { font-size: 11px; margin-top: 12px; }
}
