/* =====================================================================
 * 小蚂蚁公寓管理平台 · 设计令牌与基础样式
 * 零依赖，无构建。所有页面共用。
 * 深浅两套主题通过 <html data-theme="light|dark"> 切换。
 * ===================================================================== */

:root {
  /* 品牌 */
  --brand: #2f57d6;
  --brand-weak: #eef2ff;
  --brand-strong: #2440a8;

  /* 语义色 */
  --ok: #0e9f6e;
  --ok-weak: #e6f7f1;
  --warn: #d97706;
  --warn-weak: #fdf3e3;
  --bad: #dc2626;
  --bad-weak: #fdecec;
  --info: #0e7490;
  --info-weak: #e6f6fa;

  /* 背景与层次 */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --line: #e5e8ee;
  --line-strong: #d3d8e2;
  --text: #191c22;
  --text-2: #4d5563;
  --muted: #858d9c;

  /* 侧栏 */
  --side-bg: #14181f;
  --side-text: #b9c1cf;
  --side-text-strong: #ffffff;
  --side-active: #2f57d6;

  /* 形状 */
  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 14px;
  --shadow-1: 0 1px 2px rgba(20, 26, 40, 0.06), 0 1px 3px rgba(20, 26, 40, 0.04);
  --shadow-2: 0 6px 20px rgba(20, 26, 40, 0.10), 0 2px 6px rgba(20, 26, 40, 0.06);
  --shadow-3: 0 24px 60px rgba(16, 20, 30, 0.22);

  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 17px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
}

[data-theme='dark'] {
  --brand: #5b7cfa;
  --brand-weak: #1b2440;
  --brand-strong: #7d97ff;

  --ok: #34d399;
  --ok-weak: #12291f;
  --warn: #fbbf24;
  --warn-weak: #2c2312;
  --bad: #f87171;
  --bad-weak: #2e1618;
  --info: #38bdf8;
  --info-weak: #0f2530;

  --bg: #0d1015;
  --surface: #151a22;
  --surface-2: #1a202a;
  --line: #242b36;
  --line-strong: #333c4a;
  --text: #e8ecf3;
  --text-2: #aeb7c6;
  --muted: #7d879a;

  --side-bg: #0a0d12;
  --side-text: #93a0b4;
  --side-text-strong: #eef2f9;
  --side-active: #2f57d6;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Segoe UI', Roboto, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--brand); color: #fff; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* ---------------------------------------------------------------- 布局 */
.app {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.app.is-login { grid-template-columns: 1fr; }
.app.is-login .sidebar,
.app.is-login .topbar { display: none; }
.app.is-login .content { padding: 0; overflow: hidden; }

/* ---------------------------------------------------------------- 侧栏 */
.sidebar {
  background: var(--side-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 作用域必须限定在侧栏内：.brand 同时被 KPI 色条用作修饰类
   （.kpi-accent.brand）。若写成全局 .brand，这里的 padding:18px 会套到
   色条上，把 3px 宽的色条撑成 39px，直接盖住卡片前两个字。 */
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  color: var(--side-text-strong);
}

/* 正式 logo：透明底的绿橙蚂蚁，深浅主题共用一张图。
   原来的「屋」字蓝底方块已移除；容器本身不再带背景色，避免深色侧栏出现色块。 */
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: none;
  overflow: hidden;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-name { font-size: var(--fs-md); font-weight: 600; letter-spacing: 0.2px; }
.brand-sub { font-size: 10px; color: var(--side-text); opacity: 0.72; line-height: 1.2; }

.nav {
  flex: 1;
  overflow-y: auto;
  /* 19 个菜单项 + 7 个分组标题要在一屏内放下，底部留白压到最小；
     窗口再矮就靠滚动，不靠继续压缩行高（行高小于 28px 点击会困难） */
  padding: 4px 10px 8px;
}

.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: #2c3444; border-radius: 3px; }

.nav-group-title {
  font-size: 10px;
  letter-spacing: 1.2px;
  color: var(--side-text);
  opacity: 0.5;
  padding: 10px 10px 4px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--side-text);
  cursor: pointer;
  font-size: var(--fs-base);
  /* 继承 body 的 1.6 会让每项实际 33px 高，19 项就装不下。
     收到 1.25 后单项约 28px，点击区域仍够用 */
  line-height: 1.25;
  user-select: none;
  position: relative;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--side-text-strong); text-decoration: none; }
.nav-item.is-active { background: var(--side-active); color: #fff; font-weight: 500; }
.nav-item.is-active:hover { background: var(--side-active); }

.nav-ico { width: 16px; text-align: center; opacity: 0.9; font-size: 13px; }
.nav-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.16);
  color: var(--side-text-strong);
  font-size: 10px;
  padding: 0 6px;
  border-radius: 8px;
  line-height: 16px;
}
.nav-item.is-active .nav-badge { background: rgba(255, 255, 255, 0.28); }

.sidebar-foot {
  padding: 8px 14px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 10px;
  color: var(--side-text);
  opacity: 0.62;
  line-height: 1.7;
}

/* ---------------------------------------------------------------- 主区 */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  height: 52px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.crumb { font-size: var(--fs-base); color: var(--muted); display: flex; align-items: center; gap: 7px; }
.crumb b { color: var(--text); font-weight: 600; }
.crumb .sep { opacity: 0.5; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.period-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  background: var(--surface-2);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-weak);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
}

.user-box { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); }
.user-box .role { color: var(--muted); font-size: 10px; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px 44px;
  scroll-behavior: smooth;
}

.content::-webkit-scrollbar { width: 9px; height: 9px; }
.content::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; }
.content::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- 页头 */
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}
.page-title { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -0.2px; margin: 0; line-height: 1.3; }
.page-desc { color: var(--muted); font-size: var(--fs-sm); margin-top: 3px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex: none; }

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.card-title { font-size: var(--fs-md); font-weight: 600; }
.card-sub { font-size: var(--fs-sm); color: var(--muted); }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.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)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1, .grid-1-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------------- KPI */
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 15px 16px 14px;
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}

.kpi-label { font-size: var(--fs-sm); color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.6px; margin-top: 6px; line-height: 1.15; }
.kpi-value .unit { font-size: var(--fs-md); font-weight: 500; color: var(--text-2); margin-left: 3px; }
.kpi-foot { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); margin-top: 8px; }
.kpi-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.kpi-accent.ok { background: var(--ok); }
.kpi-accent.warn { background: var(--warn); }
.kpi-accent.bad { background: var(--bad); }
.kpi-accent.brand { background: var(--brand); }

.delta { font-weight: 600; }
.delta.up { color: var(--bad); }   /* 涨用红 */
.delta.down { color: var(--ok); }  /* 跌用绿 */

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-base);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger:hover { background: var(--bad-weak); }
.btn.sm { height: 26px; padding: 0 9px; font-size: var(--fs-sm); }
.btn.icon { width: 32px; padding: 0; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- 表单 */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }

.input, .select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-base);
  min-width: 0;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}
.input.sm, .select.sm { height: 26px; font-size: var(--fs-sm); padding: 0 7px; }
.input::placeholder { color: var(--muted); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.search { position: relative; }
.search .input { width: 210px; padding-left: 28px; }
.search::before {
  content: '⌕';
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
}
.seg button {
  height: 24px;
  padding: 0 10px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  border-radius: 4px;
  cursor: pointer;
}
.seg button.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); font-weight: 500; }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { width: 100%; overflow-x: auto; }
table.tb { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-base); }
table.tb th {
  text-align: left;
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--muted);
  background: var(--surface-2);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.tb td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
table.tb tbody tr:hover td { background: var(--surface-2); }
table.tb tbody tr.is-clickable { cursor: pointer; }
table.tb tbody tr:last-child td { border-bottom: none; }
table.tb .r { text-align: right; }
table.tb .c { text-align: center; }
table.tb .mono { font-variant-numeric: tabular-nums; }
table.tb .strong { font-weight: 600; }
table.tb .sub { color: var(--muted); font-size: var(--fs-sm); }

.cell-title { font-weight: 500; }
.cell-stack { display: flex; flex-direction: column; line-height: 1.4; }
.cell-stack .sub { font-size: var(--fs-xs); color: var(--muted); }

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--muted);
}
.pager .spacer { flex: 1; }
.pager button {
  height: 26px;
  min-width: 26px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--r-sm);
  color: var(--text-2);
  cursor: pointer;
  font-size: var(--fs-sm);
}
.pager button:hover:not([disabled]) { border-color: var(--muted); color: var(--text); }
.pager button.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button[disabled] { opacity: 0.4; cursor: not-allowed; }

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.empty .big { font-size: 26px; opacity: 0.35; display: block; margin-bottom: 8px; }

/* ---------------------------------------------------------------- 徽标 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.bad { background: var(--bad-weak); color: var(--bad); }
.badge.info { background: var(--info-weak); color: var(--info); }
.badge.brand { background: var(--brand-weak); color: var(--brand); }
.badge.mute { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.tag {
  display: inline-block;
  padding: 0 6px;
  height: 19px;
  line-height: 19px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--fs-xs);
  margin-right: 4px;
}

/* ---------------------------------------------------------------- 进度 */
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--brand); }
.bar.ok > i { background: var(--ok); }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }

.stat-row { display: flex; align-items: baseline; gap: 8px; font-size: var(--fs-sm); color: var(--muted); }
.stat-row .v { color: var(--text); font-weight: 600; font-size: var(--fs-md); }

/* ---------------------------------------------------------------- 列表 */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t { font-weight: 500; }
.list-item .s { font-size: var(--fs-sm); color: var(--muted); }
.list-ico {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
  flex: none;
}

/* ---------------------------------------------------------------- 房态矩阵 */
.matrix { display: flex; flex-direction: column; gap: 8px; }
.matrix-floor { display: flex; align-items: flex-start; gap: 10px; }
.floor-label {
  width: 44px;
  flex: none;
  padding-top: 6px;
  font-size: var(--fs-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.floor-rooms { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }

.unit {
  width: 76px;
  padding: 6px 7px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
}
.unit:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); z-index: 2; }
.unit .no { font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.unit .meta { font-size: 10px; color: var(--muted); line-height: 1.5; font-variant-numeric: tabular-nums; }
.unit.st-OCCUPIED { background: var(--ok-weak); border-color: color-mix(in srgb, var(--ok) 32%, var(--line)); }
.unit.st-OCCUPIED .no { color: var(--ok); }
.unit.st-VACANT { background: var(--surface); border-style: dashed; }
.unit.st-PENDING { background: var(--warn-weak); border-color: color-mix(in srgb, var(--warn) 34%, var(--line)); }
.unit.st-PENDING .no { color: var(--warn); }
.unit.st-MAINTENANCE { background: var(--bad-weak); border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }
.unit.st-MAINTENANCE .no { color: var(--bad); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid var(--line-strong); }
.legend .l-OCCUPIED { background: var(--ok-weak); border-color: var(--ok); }
.legend .l-VACANT { background: var(--surface); border-style: dashed; }
.legend .l-PENDING { background: var(--warn-weak); border-color: var(--warn); }
.legend .l-MAINTENANCE { background: var(--bad-weak); border-color: var(--bad); }

/* ---------------------------------------------------------------- 图表 */
.chart { width: 100%; display: block; }
.chart-legend { display: flex; gap: 16px; font-size: var(--fs-sm); color: var(--muted); margin-top: 10px; }
.chart-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 92px 1fr 54px; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.hbar-row .name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.hbar-track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.hbar-track > i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }

/* ---------------------------------------------------------------- 抽屉 */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(12, 16, 24, 0.42);
  z-index: 60;
  opacity: 0;
  animation: fade 0.16s ease forwards;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 92vw;
  background: var(--surface);
  z-index: 61;
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  transform: translateX(18px);
  opacity: 0;
  animation: slidein 0.2s ease forwards;
}
@keyframes fade { to { opacity: 1; } }
@keyframes slidein { to { transform: none; opacity: 1; } }

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.drawer-title { font-size: var(--fs-lg); font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 26px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.close-x { margin-left: auto; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; padding: 4px; }
.close-x:hover { color: var(--text); }

.kv { display: grid; grid-template-columns: 92px 1fr; gap: 9px 12px; font-size: var(--fs-base); }
.kv dt { color: var(--muted); font-size: var(--fs-sm); }
.kv dd { margin: 0; }

.section-label {
  font-size: var(--fs-xs);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 9px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.section-label:first-child { margin-top: 0; }

/* ---------------------------------------------------------------- 提示条 */
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  border: 1px solid;
  margin-bottom: 14px;
  line-height: 1.6;
}
.notice.info { background: var(--brand-weak); border-color: color-mix(in srgb, var(--brand) 26%, transparent); color: var(--text-2); }
.notice.warn { background: var(--warn-weak); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--text-2); }
.notice .ico { flex: none; font-size: 13px; line-height: 1.5; }
.notice b { color: var(--text); }

/* ---------------------------------------------------------------- 登录 */
.login-wrap {
  height: 100vh;
  display: grid;
  grid-template-columns: 1fr 460px;
  background: var(--bg);
}
.login-hero {
  background: linear-gradient(150deg, #10151d 0%, #17203a 46%, #1e2f63 100%);
  color: #fff;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-hero::after {
  content: '';
  position: absolute;
  width: 520px;
  height: 520px;
  right: -160px;
  bottom: -220px;
  background: radial-gradient(circle, rgba(91, 134, 255, 0.34), transparent 68%);
  border-radius: 50%;
}
.login-hero h1 { font-size: 34px; line-height: 1.3; margin: 0 0 14px; letter-spacing: -0.6px; font-weight: 650; }
.login-hero p { color: rgba(255, 255, 255, 0.66); margin: 0; font-size: var(--fs-md); max-width: 420px; line-height: 1.8; }
.hero-list { display: flex; flex-direction: column; gap: 12px; font-size: var(--fs-base); color: rgba(255, 255, 255, 0.78); position: relative; z-index: 1; }
.hero-list div { display: flex; gap: 9px; align-items: center; }
.hero-list .n {
  width: 20px; height: 20px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  display: grid; place-items: center; font-size: 10px; flex: none;
}
.login-panel {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 54px;
  border-left: 1px solid var(--line);
}
.login-panel h2 { font-size: var(--fs-xl); margin: 0 0 4px; font-weight: 650; }
/* 标题后的版本号：灰色、比标题小一号，沿用 --muted 保证深浅主题都读得清 */
.login-panel h2 .ver-inline {
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
  margin-left: 8px;
  vertical-align: 2px;
}
.login-panel .sub { color: var(--muted); font-size: var(--fs-sm); margin-bottom: 26px; }
.login-panel .field { margin-bottom: 14px; }
.login-panel .input { height: 38px; }
.login-panel .btn.primary { height: 38px; width: 100%; margin-top: 8px; font-size: var(--fs-md); }
.login-hint {
  margin-top: 20px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--warn-weak);
  border: 1px solid color-mix(in srgb, var(--warn) 26%, transparent);
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.7;
}

/* ---------------------------------------------------------------- 小工具 */
.mt8 { margin-top: 8px; }
.mt14 { margin-top: 14px; }
.mt20 { margin-top: 20px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.right { margin-left: auto; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.nowrap { white-space: nowrap; }
.tr { text-align: right; }
.tc { text-align: center; }
.ok-t { color: var(--ok); }
.warn-t { color: var(--warn); }
.bad-t { color: var(--bad); }
.brand-t { color: var(--brand); }
.b { font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(10px);
  background: #1b2130;
  color: #fff;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: var(--fs-sm);
  z-index: 90;
  opacity: 0;
  box-shadow: var(--shadow-2);
  animation: toastin 0.22s ease forwards;
  pointer-events: none;
}
@keyframes toastin { to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.loading {
  padding: 60px;
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* ==================================================================
 * P1 / P2 增值业务页面
 * 房源卡片、充电端口矩阵、商品卡片、工单时间线
 * ================================================================== */

/* ---------------------------------------------------------------- 房源卡片 */
.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.listing-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}
.listing-card:hover {
  box-shadow: var(--shadow-2);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.listing-cover {
  height: 104px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 25px;
  font-weight: 650;
  letter-spacing: 1.5px;
  font-variant-numeric: tabular-nums;
}
.listing-cover .cover-tag { position: absolute; top: 8px; left: 8px; }
.listing-cover .cover-tag .badge { background: rgba(255, 255, 255, 0.92); border: none; }
.listing-cover .cover-view {
  position: absolute;
  bottom: 7px;
  right: 9px;
  font-size: var(--fs-xs);
  background: rgba(0, 0, 0, 0.34);
  padding: 2px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.listing-body {
  padding: 11px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}
/* 价格与面积同行：面积列可省略号，但不能把价格挤变形 */
.listing-card .listing-area {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.listing-title {
  font-weight: 600;
  font-size: var(--fs-base);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.listing-price {
  font-size: var(--fs-lg);
  font-weight: 650;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  flex: none;
  white-space: nowrap;
}
.listing-price small { font-size: var(--fs-xs); color: var(--muted); font-weight: 400; margin-left: 2px; }
.fac-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.fac-tags .tag { margin-right: 0; }

/* ---------------------------------------------------------------- 充电端口 */
.station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 12px;
}

.station-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.station-head { display: flex; align-items: flex-start; gap: 8px; }
.station-name { font-weight: 600; font-size: var(--fs-base); line-height: 1.3; flex: 1; min-width: 0; }
.station-metrics { display: flex; gap: 20px; }
.station-metrics > div { display: flex; flex-direction: column; gap: 1px; }
.station-metrics .k { font-size: var(--fs-xs); color: var(--muted); }
.station-metrics .v { font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; }

.port-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.port-cell {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: var(--line-strong);
}
.port-cell.IDLE { background: var(--ok); opacity: 0.62; }
.port-cell.CHARGING { background: var(--warn); }
.port-cell.OFFLINE { background: var(--muted); opacity: 0.45; }
.port-cell.FAULT { background: var(--bad); }
.port-cell.DISABLED { background: var(--line-strong); }

.port-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.port-legend span { display: flex; align-items: center; gap: 4px; }
.port-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ---------------------------------------------------------------- 商品卡片 */
.sku-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 12px;
}

.sku-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.sku-card.is-low { border-color: color-mix(in srgb, var(--bad) 42%, var(--line)); }
.sku-name {
  font-weight: 600;
  font-size: var(--fs-base);
  line-height: 1.35;
  min-height: 2.7em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sku-price { display: flex; align-items: baseline; gap: 6px; }
.sku-price .p { font-size: var(--fs-lg); font-weight: 650; color: var(--brand); font-variant-numeric: tabular-nums; }
.sku-price .c { font-size: var(--fs-xs); color: var(--muted); }
.sku-meta { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-xs); color: var(--muted); }

/* ---------------------------------------------------------------- 时间线 */
.timeline { position: relative; padding-left: 19px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 5px;
  bottom: 5px;
  width: 1px;
  background: var(--line-strong);
}
.tl-item { position: relative; padding-bottom: 14px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -17px;
  top: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  border: 2px solid var(--surface);
  box-sizing: content-box;
}
.tl-item.on::before { background: var(--brand); }
.tl-item.done::before { background: var(--ok); }
.tl-t { font-size: var(--fs-base); font-weight: 500; }
.tl-s { font-size: var(--fs-xs); color: var(--muted); margin-top: 1px; }

/* =====================================================================
 * 接后端新增：数据源标识、表单错误、真实数据分支
 * ===================================================================== */

/* 侧栏里标出「本页已接真实接口」。api 模式下没有演示角标，不会和 nav-badge 抢位 */
.nav-live {
  margin-left: auto;
  font-size: 7px;
  line-height: 1;
  color: #34d399;
  opacity: 0.85;
}
.nav-live + .nav-badge { margin-left: 6px; }

.sidebar-foot .src-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: 1px;
}
.sidebar-foot .src-dot.on { background: #34d399; }
.sidebar-foot .src-dot.off { background: #f59e0b; }

/* 每页顶部的数据源说明条 */
.srcbar { margin-bottom: 14px; font-size: var(--fs-sm); line-height: 1.65; }
.srcbar code {
  background: rgba(0, 0, 0, 0.055);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
[data-theme="dark"] .srcbar code { background: rgba(255, 255, 255, 0.1); }

.notice.bad {
  background: var(--bad-weak);
  border-color: color-mix(in srgb, var(--bad) 30%, transparent);
  color: var(--text-2);
}

/* 表单内联报错：紧贴提交按钮下方，比 toast 更容易定位哪一项错了 */
.form-err {
  display: none;
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--bad-weak);
  color: var(--bad);
  font-size: var(--fs-sm);
  line-height: 1.5;
  border: 1px solid color-mix(in srgb, var(--bad) 26%, transparent);
}
.form-err.on { display: block; }
.login-panel .form-err { margin-top: 12px; }
