/* 租房记录 —— 简洁移动端样式 */
:root {
  --primary: #00a0e8;
  --primary-weak: #e0f3ff;
  --yellow: #f7b500;
  --yellow-weak: #fff4d6;
  --bg: #ffffff;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #8a919c;
  --border: #e9f0f6;
  --red: #e5484d;
  --red-bg: #fdecec;
  --orange: #ef8c00;
  --orange-bg: #fff3e0;
  --green: #2f9e44;
  --green-bg: #e8f5ec;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

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

/* 确保 hidden 属性始终生效（覆盖 display:flex 等） */
[hidden] { display: none !important; }

html { background: var(--bg); }
html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  max-width: 520px;
  margin: 0 auto;
}

/* 顶部栏（三栏网格，标题始终居中，避免与按钮重叠） */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 3px solid var(--yellow);
  border-bottom: 1px solid var(--border);
}
#backBtn { grid-column: 1; grid-row: 1; justify-self: start; }
.topbar-title {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
}
#settingsBtn { grid-column: 3; grid-row: 1; justify-self: end; }

.icon-btn {
  border: none;
  background: none;
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { background: var(--bg); }
#backBtn { font-size: 30px; line-height: 1; }

/* 视图 */
.view { padding: 16px 16px 130px; }
.view[hidden] { display: none; }

/* 统计条（单卡片三栏） */
.stats {
  display: flex;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.stat {
  flex: 1;
  padding: 14px 8px;
  text-align: center;
}
.stat + .stat { border-left: 1px solid var(--border); }
.stat .num { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.overdue .num { color: var(--red); }
.stat.due .num { color: var(--orange); }

/* 搜索 */
.search { margin-bottom: 12px; }
.search input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.search input:focus { border-color: var(--primary); }

/* 列表 */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.list li:active { background: #f6f8fa; }

/* 列表左侧状态色条 */
.list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 28px;
  border-radius: 0 4px 4px 0;
  background: transparent;
}
.list li.red::before    { background: var(--red); }
.list li.orange::before { background: var(--orange); }
.list li.green::before  { background: var(--green); }
.list li.gray::before   { background: var(--muted); }

/* 抄表记录行：强制块级，避免与 .list li 的 flex 冲突导致挤成一行 */
.list li.reading-line {
  display: block;
  cursor: pointer;
}

/* 房间行 */
.room-main { flex: 1; min-width: 0; }
.room-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.room-no { font-size: 17px; font-weight: 700; flex-shrink: 0; }
.room-name {
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 状态标签 */
.tag {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag.red    { background: var(--red-bg); color: var(--red); }
.tag.orange { background: var(--orange-bg); color: var(--orange); }
.tag.green  { background: var(--green-bg); color: var(--green); }
.tag.gray   { background: #f1f3f5; color: var(--muted); }

/* 空状态 */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 56px 20px;
  line-height: 1.8;
}
.empty::before {
  content: '🔔';
  display: block;
  font-size: 40px;
  margin-bottom: 10px;
  opacity: 0.6;
}

/* 底部 Tab */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tabbar[hidden] { display: none; }
.tab-btn {
  flex: 1;
  border: none;
  background: none;
  position: relative;
  padding: 10px 0 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tab-ico { font-size: 20px; line-height: 1; }
.tab-btn.active { color: var(--primary); font-weight: 600; }
.tab-btn.active::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 22px; height: 3px; border-radius: 0 0 3px 3px; background: var(--yellow); }

/* 悬浮新增按钮 */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 160, 232, 0.4);
  z-index: 9;
}
.fab:active { opacity: 0.85; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.form-title { font-size: 16px; margin: 0 0 14px; }

.group { border: none; margin: 0 0 18px; padding: 0; }
.group legend {
  font-size: 13px;
  color: var(--muted);
  padding: 0;
  margin-bottom: 10px;
}
.field { display: block; margin-bottom: 12px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-weak);
}
.field textarea { resize: vertical; }
/* 日期框限宽，避免独占整行显得过长 */
.field input[type="date"] { max-width: 160px; }
.req { color: var(--red); font-style: normal; }

/* 按钮 */
.btn {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 13px;
  font-size: 15px;
  cursor: pointer;
  margin-bottom: 10px;
  transition: opacity 0.15s;
}
.btn:active { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:active { opacity: 0.88; }
.btn-danger { color: var(--red); border-color: #f3c7c9; }
.btn-danger:active { background: var(--red-bg); }

.link-btn {
  border: none;
  background: none;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}
.link-btn.primary { color: var(--primary); font-weight: 600; }

/* 弹层 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-mask[hidden] { display: none; }
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideup 0.22s ease;
}
@keyframes slideup { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
}
.modal-head h2 { font-size: 16px; margin: 0; }
.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

/* 抄表预览 */
.preview {
  background: var(--primary-weak);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 12px;
  line-height: 1.9;
  color: #0b6fa8;
}
.preview b { color: var(--primary); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 4px 2px 10px;
}
.section-head h2 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); font-size: 13px; }

/* 抄表记录行 */
.reading-line .top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.reading-line .date { font-weight: 600; flex-shrink: 0; }
.reading-line .detail { color: var(--muted); font-size: 13px; margin-top: 3px; }
.reading-line .fee { color: var(--primary); font-weight: 600; text-align: right; }

/* 详情页 */
.detail-card { margin-bottom: 14px; }
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.detail-head .room-no { font-size: 20px; }
.detail-rows { display: flex; flex-direction: column; gap: 10px; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.detail-row .k { color: var(--muted); flex-shrink: 0; }
.detail-row .v { text-align: right; word-break: break-all; }
.detail-actions { display: flex; gap: 10px; margin-top: 14px; }
.detail-actions .btn { flex: 1; margin-bottom: 0; }

/* 提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 50;
  max-width: 90%;
  text-align: center;
}
.toast[hidden] { display: none; }

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