/* ========= 全局变量与重置 ========= */
:root {
  --primary: #1E3A8A;
  --primary-light: #3B5BDB;
  --primary-dark: #152C6E;
  --accent: #F59E0B;
  --accent-light: #FBBF24;
  --success: #059669;
  --success-light: #10B981;
  --danger: #DC2626;
  --danger-light: #EF4444;
  --text: #0F172A;
  --text-sub: #475569;
  --text-mute: #94A3B8;
  --bg: #F1F5F9;
  --bg-soft: #F8FAFC;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.05);
  --shadow: 0 4px 12px rgba(15,23,42,0.06);
  --shadow-lg: 0 12px 32px rgba(30,58,138,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 260px;
  --tabbar-h: 64px;
  --header-h: 56px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.hidden { display: none !important; }

/* ========= 布局骨架 ========= */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  padding-top: 0;
}
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.mobile-header-title { font-size: 17px; font-weight: 600; }
.menu-toggle {
  width: 40px; height: 40px;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center; gap: 5px;
}
.menu-toggle span {
  display: block; width: 22px; height: 2px;
  background: white; border-radius: 2px;
  transition: .25s;
}

/* 侧边栏 */
.sidebar {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0F2256 0%, var(--primary) 100%);
  color: #C7D2FE;
  padding: 24px 16px 16px;
  display: flex;
  flex-direction: column;
  z-index: 90;
  transition: transform .3s ease;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 24px;
  color: white;
}
.brand-logo {
  width: 40px; height: 40px;
  background: rgba(255,255,255,.15);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.nav-list { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: #C7D2FE;
  font-size: 14px;
  transition: .2s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: white; }
.nav-item.active {
  background: rgba(255,255,255,.16);
  color: white;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-icon { font-size: 18px; width: 22px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #78350F;
  font-size: 11px; font-weight: 700;
  padding: 1px 8px;
  border-radius: 10px;
  min-width: 22px; text-align: center;
}
.sidebar-footer { padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.storage-label { font-size: 11px; color: rgba(255,255,255,.6); margin-bottom: 6px; }
.storage-bar-mini {
  height: 6px; background: rgba(255,255,255,.1);
  border-radius: 3px; overflow: hidden;
}
.storage-fill-mini {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--success-light), var(--accent));
  border-radius: 3px;
  transition: width .4s;
}
.sidebar-mask {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 89;
}
.sidebar-mask.show { display: block; }

/* 主内容 */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px 40px;
  max-width: 100%;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .2px;
}
.page-sub {
  font-size: 13px;
  color: var(--text-sub);
  margin-top: 2px;
}
.page-header {
  margin-bottom: 20px;
}
.page-header.row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

/* 移动端底部 Tab */
.mobile-tabbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--tabbar-h);
  background: white;
  border-top: 1px solid var(--border);
  display: none;
  z-index: 80;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-mute);
  font-size: 11px;
  min-width: 0;
}
.tab span { font-size: 22px; }
.tab.active { color: var(--primary); font-weight: 600; }
.tab.center span {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  margin-top: -18px;
  box-shadow: 0 8px 20px rgba(30,58,138,.3);
}

/* ========= 卡片与通用组件 ========= */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 18px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 18px 20px; }

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: .2s;
  min-height: 40px;
  border: 1px solid transparent;
  background: var(--bg-soft);
  color: var(--text);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  box-shadow: 0 4px 12px rgba(30,58,138,.25);
}
.btn.primary:hover { box-shadow: 0 6px 16px rgba(30,58,138,.35); }
.btn.secondary {
  border: 1px solid var(--primary);
  color: var(--primary);
  background: white;
}
.btn.danger {
  background: white;
  color: var(--danger);
  border: 1px solid var(--danger-light);
  margin-top: 14px;
  width: 100%;
  justify-content: center;
}
.btn.danger:hover { background: #FEF2F2; }
.btn.small { padding: 6px 12px; font-size: 13px; min-height: 34px; }
.btn.large { padding: 14px 22px; font-size: 15px; }

/* ========= 首页看板 ========= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-grid.small { grid-template-columns: repeat(3, 1fr); }
.stat-card {
  padding: 20px;
  border-radius: var(--radius);
  color: white;
  position: relative;
  overflow: hidden;
  min-height: 120px;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow);
  transition: transform .25s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card::after {
  content: "";
  position: absolute;
  right: -20px; bottom: -20px;
  width: 100px; height: 100px;
  background: rgba(255,255,255,.1);
  border-radius: 50%;
}
.stat-card.a { background: linear-gradient(135deg, #1E3A8A, #3B5BDB); }
.stat-card.b { background: linear-gradient(135deg, #059669, #10B981); }
.stat-card.c { background: linear-gradient(135deg, #D97706, #F59E0B); }
.stat-card.d { background: linear-gradient(135deg, #7C3AED, #A78BFA); }
.stat-card.e { background: linear-gradient(135deg, #0891B2, #22D3EE); }
.stat-label { font-size: 13px; opacity: .9; font-weight: 500; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: .5px; }
.stat-trend { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 4px; }

.quick-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.quick-btn {
  flex: 1;
  min-width: 160px;
  padding: 14px 18px;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: .2s;
  box-shadow: var(--shadow-sm);
}
.quick-btn:hover { border-color: var(--primary-light); box-shadow: var(--shadow); transform: translateY(-2px); }
.quick-btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; border-color: transparent;
}
.quick-btn span:first-child {
  font-size: 22px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.12);
  border-radius: 10px;
}
.quick-btn:not(.primary) span:first-child { background: var(--bg); }

.activity-list {
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
}
.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  position: relative;
  padding-left: 20px;
}
.activity-item:last-child { border-bottom: none; }
.activity-item::before {
  content: "";
  position: absolute;
  left: 4px; top: 18px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,91,219,.15);
}
.activity-ico { font-size: 18px; }
.activity-content { flex: 1; min-width: 0; }
.activity-text { font-size: 13px; color: var(--text); }
.activity-text strong { color: var(--primary); font-weight: 600; }
.activity-time { font-size: 11px; color: var(--text-mute); margin-top: 2px; }

/* ========= 租户管理 ========= */
.filter-row {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  flex-wrap: wrap;
  align-items: center;
}
.search-wrap {
  flex: 1;
  min-width: 240px;
  position: relative;
}
.search-ico {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-mute);
  font-size: 14px;
}
.search-wrap input, .select {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  outline: none;
  transition: .2s;
  min-height: 40px;
}
.search-wrap input:focus, .select:focus {
  border-color: var(--primary-light);
  background: white;
  box-shadow: 0 0 0 3px rgba(59,91,219,.12);
}
.select {
  padding: 10px 12px;
  min-width: 150px;
  width: auto;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%2394A3B8' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

/* 卡片视图 */
.tenant-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.tenant-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: .2s;
  position: relative;
  overflow: hidden;
}
.tenant-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: transparent; }
.tenant-card.need-update::before {
  content: "需更新";
  position: absolute;
  top: 12px; right: -32px;
  background: var(--danger);
  color: white;
  padding: 3px 34px;
  font-size: 11px;
  transform: rotate(35deg);
  font-weight: 600;
}
.tenant-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.tenant-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
  background-size: cover; background-position: center;
}
.tenant-meta { flex: 1; min-width: 0; }
.tenant-name {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tenant-room { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.status-tag.active { background: #D1FAE5; color: #065F46; }
.status-tag.ended { background: #F1F5F9; color: #475569; }
.status-tag.pending { background: #FEF3C7; color: #92400E; }

.tenant-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 12.5px;
  color: var(--text-sub);
  margin-bottom: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.tenant-info span b { color: var(--text); font-weight: 500; }

.tenant-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.tag {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  background: #EFF6FF;
  color: #1D4ED8;
  font-weight: 500;
}
.tag.discount { background: #FEF3C7; color: #92400E; }
.tag.invited { background: #F3E8FF; color: #6D28D9; }
.tag.warning { background: #FEF2F2; color: #991B1B; }

.tenant-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.tenant-actions .btn { flex: 1; padding: 7px 10px; font-size: 13px; min-height: 34px; justify-content: center; }

/* 表格视图 */
.tenant-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.tenant-table th, .tenant-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.tenant-table th {
  background: var(--bg-soft);
  color: var(--text-sub);
  font-weight: 600;
  font-size: 12.5px;
  position: sticky;
  top: 0;
}
.tenant-table tr:nth-child(even) td { background: #FAFBFC; }
.tenant-table tr:hover td { background: #EFF6FF; }

/* ========= 优惠规则 ========= */
.promo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.promo-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  transition: .2s;
  position: relative;
}
.promo-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.promo-card.disabled { opacity: .55; }
.promo-card.type-new { border-left-color: var(--success); }
.promo-card.type-inviter { border-left-color: #8B5CF6; }
.promo-card.type-long { border-left-color: var(--accent); }
.promo-card.type-festival { border-left-color: #EC4899; }
.promo-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.promo-name { font-size: 16px; font-weight: 600; }
.promo-type-tag {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-sub);
}
.promo-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  margin: 10px 0;
}
.promo-meta {
  font-size: 12.5px;
  color: var(--text-sub);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.promo-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px dashed var(--border);
}
.switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: .2s;
  flex-shrink: 0;
}
.switch.on { background: var(--success); }
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: white;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch.on::after { left: 22px; }

/* ========= 租赁记录 ========= */
.records-list {
  max-height: 500px;
  overflow-y: auto;
}
.record-row {
  display: grid;
  grid-template-columns: 80px 1fr auto auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px dashed var(--border);
}
.record-row:last-child { border-bottom: none; }
.record-delete-btn {
  width: 24px; height: 24px; border-radius: 50%; border: none;
  background: transparent; color: var(--text-mute); font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: all .2s;
}
.record-row:hover .record-delete-btn { opacity: 1; }
.record-delete-btn:hover { background: #fee2e2; color: #ef4444; }
.record-date { text-align: center; }
.record-date .day { font-size: 20px; font-weight: 700; color: var(--primary); }
.record-date .ym { font-size: 11px; color: var(--text-mute); }
.record-info .title { font-size: 14px; font-weight: 500; }
.record-info .sub { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.record-amount { font-size: 16px; font-weight: 700; text-align: right; }
.record-amount.discount { color: var(--accent); }
.record-type-tag {
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  background: #EFF6FF;
  color: #1D4ED8;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
  align-items: center;
}
.summary-item:last-child { border-bottom: none; }
.summary-label { font-size: 13px; color: var(--text-sub); display: flex; align-items: center; gap: 8px; }
.summary-value { font-size: 18px; font-weight: 700; color: var(--primary); }
.summary-value.green { color: var(--success); }
.summary-value.orange { color: var(--accent); }

/* ========= 邀请关系 ========= */
.invite-rank-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}
.invite-rank-item:last-child { border-bottom: none; }
.rank-no {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--text-sub);
}
.rank-no.top1 { background: linear-gradient(135deg, #F59E0B, #FBBF24); color: white; }
.rank-no.top2 { background: linear-gradient(135deg, #94A3B8, #CBD5E1); color: white; }
.rank-no.top3 { background: linear-gradient(135deg, #B45309, #D97706); color: white; }
.rank-info { flex: 1; }
.rank-name { font-size: 14px; font-weight: 600; }
.rank-room { font-size: 11px; color: var(--text-mute); }
.rank-count { font-size: 13px; color: var(--text-sub); display: flex; gap: 10px; }
.rank-count strong { color: var(--primary); font-size: 16px; }

.reward-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}
.reward-info .name { font-size: 14px; font-weight: 600; }
.reward-info .cnt { font-size: 12px; color: var(--text-sub); }
.reward-amount {
  font-size: 18px; font-weight: 700; color: var(--accent);
}

/* ========= 数据管理 ========= */
.hint-text {
  color: var(--text-sub);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.7;
}
.hint-text.small { font-size: 12px; margin-top: 14px; }

.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.data-counter {
  margin-top: 20px;
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  text-align: center;
}
.data-counter .count-num {
  font-size: 22px; font-weight: 700; color: var(--primary);
}
.data-counter .count-label {
  font-size: 11px; color: var(--text-sub); margin-top: 2px;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  transition: .2s;
}
.drop-zone.drag { border-color: var(--primary-light); background: #EFF6FF; }
.drop-ico { font-size: 40px; margin-bottom: 8px; }
.drop-text { font-size: 13px; color: var(--text-sub); margin-bottom: 12px; }

.import-mode {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.import-mode label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
}

.storage-chart-wrap {
  display: flex;
  gap: 30px;
  align-items: center;
  flex-wrap: wrap;
}
.storage-detail { flex: 1; min-width: 260px; }
.storage-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  align-items: center;
  font-size: 13.5px;
}
.storage-row:last-of-type { border-bottom: none; }
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
}
.dot.blue { background: var(--primary-light); }
.dot.green { background: var(--success-light); }
.dot.orange { background: var(--accent); }

/* ========= 弹窗 ========= */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .2s;
}
.modal {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: scaleIn .25s;
}
.modal.large { max-width: 720px; }
.modal-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: white;
  font-size: 22px;
  line-height: 1;
}
.modal-close:hover { background: rgba(255,255,255,.15); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-soft);
}

.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.form-group label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  outline: none;
  transition: .2s;
  min-height: 40px;
}
.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,91,219,.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  padding: 4px 10px;
  background: #EFF6FF;
  border-left: 3px solid var(--primary);
  margin: 18px 0 12px;
  border-radius: 0 4px 4px 0;
}
.checkbox-wrap {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text);
  padding: 8px 0;
}
.checkbox-wrap input { width: 16px; height: 16px; }

/* ========= Toast ========= */
.toast-root {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: rgba(15,23,42,.92);
  color: white;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.success { background: rgba(5,150,105,.95); }
.toast.error { background: rgba(220,38,38,.95); }
.toast.warning { background: rgba(217,119,6,.95); }

/* ========= 动画 ========= */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

/* ========= 响应式适配 ========= */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  /* 移动端底部tabbar高度 + 安全区 + 额外余量（防被遮挡） */
  :root { --tabbar-h-safe: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 30px); }
  .app-wrapper { padding-top: var(--header-h); padding-bottom: var(--tabbar-h-safe); }
  /* 确保每个页面自己的最后一个元素也不会被底栏切 */
  .page { padding-bottom: 8px; }
  .page[id="page-records"],
  .page[id="page-data"] { padding-bottom: 16px; }
  /* 所有 canvas 不允许被父容器挤压变形，保持声明的最小高度 */
  canvas { display: block; max-width: 100%; }
  #trend-chart { min-height: 220px; }
  #records-chart { min-height: 260px; height: 260px; width: 100%; }
  #storage-chart { min-height: 240px; min-width: 240px; }
  /* 卡片内的canvas不被overflow:hidden裁剪 */
  .card-body { overflow: visible; }
  .sidebar {
    transform: translateX(-100%);
    width: 84%;
    max-width: 320px;
    /* 修复：侧边栏要在顶部mobile-header上方，且第一行品牌字从header下方开始显示不被挡住 */
    z-index: 150;
    padding-top: calc(var(--header-h) + 16px);
  }
  .sidebar.show { transform: translateX(0); }
  .main-content {
    margin-left: 0;
    padding: 16px 14px 4px; /* 底部多余量由 app-wrapper 的 padding-bottom 承担，避免重复 */
    padding-bottom: 8px;
  }
  .page-title { font-size: 20px; }
  .mobile-tabbar { display: flex; }
  /* 统计卡片：手机上字体略小，容纳长数字 */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px; min-height: 92px; }
  .stat-value { font-size: 22px; letter-spacing: -.5px; }
  .stat-trend { font-size: 12px; line-height: 1.4; word-break: break-all; }
  .stat-label { font-size: 12.5px; }
  /* 快捷按钮：手机端改成每行一个（共3行），防止被文字挤压+与底部tabbar重叠 */
  .quick-actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 16px; }
  .quick-btn { min-width: 0; padding: 12px 14px; }
  .two-col-grid { grid-template-columns: 1fr; gap: 14px; }
  .page-header.row { flex-direction: column; align-items: stretch; }
  .page-header.row .btn { width: 100%; justify-content: center; }
  .filter-row { padding: 12px 14px; gap: 10px; }
  .search-wrap { min-width: 0; width: 100%; flex: 1 1 100%; }
  .search-wrap input { min-height: 44px; font-size: 15px; padding-left: 38px; }
  .search-ico { left: 14px; font-size: 16px; }
  /* 手机端下拉框/按钮：宽度撑满 + 高度增大避免文字被挤压看不清 */
  .filter-row .select { flex: 1 1 calc(50% - 5px); width: auto; min-width: 0; min-height: 44px; font-size: 14px; padding: 10px 34px 10px 12px; }
  .filter-row .btn.small { flex: 1 1 100%; width: 100%; min-width: 0; min-height: 44px; padding: 10px 14px; font-size: 14px; }
  .tenant-list { grid-template-columns: 1fr; gap: 12px; }
  .promo-grid { grid-template-columns: 1fr; gap: 12px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .record-row { grid-template-columns: 60px 1fr auto; }
  .record-row .record-amount { grid-column: 2; text-align: left; font-size: 15px; }
  .record-row .record-type-tag { grid-column: 2; justify-self: start; }
  .record-row .record-delete-btn { grid-column: 3; opacity: 1; }
  .storage-chart-wrap { flex-direction: column; text-align: center; }
  .data-counter { grid-template-columns: repeat(2, 1fr); }
  .card-header, .card-body { padding-left: 14px; padding-right: 14px; }
  .tenant-table th:nth-child(n+5), .tenant-table td:nth-child(n+5) { display: none; }
  .tenant-table th, .tenant-table td { padding: 10px 8px; font-size: 12.5px; }
  /* 移动端Dialog：顶部对齐 + 满宽 + 圆角只在顶 + 避免被手机键盘顶出可视区 + 边距12 */
  .modal-mask { padding: 12px; align-items: flex-start; }
  .modal { max-width: 100%; border-radius: 14px 14px 12px 12px; max-height: calc(100vh - 24px); }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; gap: 8px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; justify-content: center; min-width: 0; }
  /* 表单移动端优化：控件加大点击面积，手指好点 */
  .form-control { min-height: 44px; font-size: 15px; }
  .form-group label { font-size: 13px; margin-bottom: 4px; }
  .form-section-title { margin-top: 16px; font-size: 13px; }
  .checkbox-wrap { padding: 10px 0; font-size: 14px; }
  .checkbox-wrap input { width: 20px; height: 20px; }
  /* Toast 位置：避开顶部mobile-header + 安全区 */
  .toast-root { top: calc(var(--header-h) + 8px); max-width: 92%; width: calc(100% - 32px); }
  .toast { padding: 10px 14px; font-size: 14px; }
  /* PWA 安装按钮不被底栏遮挡 */
  .pwa-install { bottom: calc(var(--tabbar-h-safe) + 10px); max-width: 92vw; }
}

/* ========= PWA 安装按钮 ========= */
.pwa-install {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(99,102,241,.4);
  animation: slideUp .3s;
  max-width: 92vw;
}
.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: white;
}
.pwa-icon {
  font-size: 32px;
  background: rgba(255,255,255,.2);
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.pwa-text { display: flex; flex-direction: column; gap: 2px; }
.pwa-text strong { font-size: 15px; }
.pwa-text span { font-size: 12px; opacity: .85; }
#pwa-install-btn {
  background: white;
  color: #6366f1;
  border: none;
  padding: 8px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
#pwa-install-btn:hover { background: #f0f0ff; }
.pwa-skip {
  background: transparent;
  color: rgba(255,255,255,.7);
  border: none;
  font-size: 12px;
  cursor: pointer;
  padding: 6px 8px;
  flex-shrink: 0;
}
.pwa-skip:hover { color: white; }

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ========= 云端同步状态 ========= */
.sync-status {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #E2E8F0;
  color: #64748B;
  font-weight: 500;
  margin-left: 6px;
  white-space: nowrap;
}
.sync-status.ok { background: #DCFCE7; color: #166534; }
.sync-status.error { background: #FEE2E2; color: #991B1B; }
.sync-status.syncing { background: #DBEAFE; color: #1E40AF; }

.brand .sync-status { margin-left: 8px; }
.mobile-header .sync-status { font-size: 10px; padding: 1px 6px; }
