* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f4f6f9;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.55;
}

/* —— 顶部标题 —— */
.topbar {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  background: linear-gradient(135deg, #C62828 0%, #D32F2F 100%);
  color: #fff;
  padding: 18px 18px 15px;
  border-bottom: 3px solid #F44336;
}
.topbar-title { font-size: 18px; font-weight: 600; letter-spacing: .4px; }
.topbar-sub { font-size: 11px; opacity: 0.72; margin-top: 4px; }

/* —— 筛选面板 —— */
.filter-panel {
  position: sticky; top: 0; z-index: 15;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
}
.filter-row { display: flex; gap: 12px; }
.filter-item { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.filter-item label { flex-shrink: 0; font-size: 12px; color: #6b7280; font-weight: 500; }
.filter-item select {
  flex: 1; min-width: 0; padding: 8px 9px; border: 1px solid #d1d5db; border-radius: 6px;
  background: #fff; font-size: 13px; color: #1f2937;
  transition: border-color .15s, box-shadow .15s;
}
.filter-item select:focus { outline: none; border-color: #D32F2F; box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.12); }

/* 分段按钮组（项目 / 销售状态 / 房屋类型） */
.filter-segs { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.seg-group { flex: 1; display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.seg-group-full { flex: 1 1 100%; }
.seg-label { flex-shrink: 0; font-size: 11px; color: #6b7280; font-weight: 500; padding-top: 6px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  border: 1px solid #e5e7eb; background: #fff; color: #4b5563;
  font-size: 12px; padding: 5px 14px; border-radius: 6px; cursor: pointer; font-weight: 500;
  transition: all .15s;
}
.seg button:hover { border-color: #c7cdd6; }
.seg button.active { background: #C62828; color: #fff; border-color: #C62828; }

/* —— 项目树形多选下拉 —— */
.tree-select { position: relative; flex: 1; min-width: 0; }
.ts-trigger {
  height: 38px; border: 1px solid #dcdfe6; border-radius: 4px; background: #fff;
  display: flex; align-items: center; justify-content: space-between; padding: 0 12px; cursor: pointer;
  transition: border-color .15s;
}
.ts-trigger:hover { border-color: #c0c4cc; }
.ts-trigger.open { border-color: #D32F2F; }
.ts-text { font-size: 13px; color: #303133; }
.ts-arrow { color: #909399; font-size: 12px; transition: transform .2s; }
.ts-trigger.open .ts-arrow { transform: rotate(180deg); }
.ts-panel {
  position: absolute; top: 44px; left: 0; right: 0; z-index: 60;
  background: #fff; border: 1px solid #ebeef5; border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .12); padding: 10px 12px; max-height: 340px; overflow: auto;
  display: none;
}
.ts-panel.open { display: block; }
.ts-row { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: #303133; padding: 4px 0; }
.ts-row:hover { color: #D32F2F; }
.ts-row input[type=checkbox] { width: 15px; height: 15px; accent-color: #D32F2F; margin: 0; cursor: pointer; flex-shrink: 0; }
.ts-divider { height: 1px; background: #ebeef5; margin: 6px 0 8px; }
.ts-area-head { display: flex; align-items: center; justify-content: space-between; }
.ts-area-head .ts-row { font-weight: 600; color: #303133; }
.ts-fold { color: #909399; font-size: 12px; cursor: pointer; padding: 2px 6px; user-select: none; }
.ts-area-body { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 6px 0 8px 22px; }
.ts-area.collapsed .ts-area-body { display: none; }
.ts-item { font-weight: 400; }

/* —— 内容区 —— */
.content { padding: 10px; max-width: 1400px; margin: 0 auto; }

/* —— 指标卡 —— */
.kpi-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kpi {
  background: #fff; border: 1px solid #eef0f4; border-radius: 8px;
  padding: 13px 15px 12px; box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
  border-left: 3px solid #D32F2F;
}
.kpi.sk { border-left-color: #059669; }
.kpi-label { font-size: 12px; color: #6b7280; margin-bottom: 8px; font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 700; color: #111827; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-prev { font-size: 12px; color: #9aa3b2; margin-top: 8px; }
.kpi-prev span { font-weight: 600; color: #6b7280; }

/* —— 卡片 —— */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid #eef0f4;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; flex-wrap: wrap; gap: 6px;
}
.card-title { font-size: 15px; font-weight: 600; color: #111827; }
.badge {
  font-size: 11px; background: #eff6ff; color: #1d4ed8;
  padding: 2px 8px; border-radius: 4px; font-weight: 500;
}
.p3-sub { font-size: 12px; color: #6b7280; margin-bottom: 6px; }

/* —— 指标切换按钮 —— */
.metric-tabs { display: flex; gap: 4px; }
.metric-tabs button {
  border: 1px solid #e5e7eb; background: #fff; color: #4b5563;
  font-size: 12px; padding: 4px 12px; border-radius: 6px; cursor: pointer; font-weight: 500;
  transition: all .15s;
}
.metric-tabs button:hover { border-color: #c7cdd6; }
.metric-tabs button.active { background: #C62828; color: #fff; border-color: #C62828; }

.chart { width: 100%; }

/* —— 表格 —— */
.tbl { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.tbl th, .tbl td { padding: 8px 7px; text-align: right; border-bottom: 1px solid #f1f3f7; white-space: nowrap; }
.tbl th { background: #f8fafc; color: #4b5563; font-weight: 600; font-size: 12px; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #f9fafb; }
.tbl .up { color: #059669; }
.tbl .down { color: #dc2626; }
.tbl .sum { background: #f0f5ff; font-weight: 700; }

.empty { color: #9aa3b2; text-align: center; padding: 20px; font-size: 13px; }

@media (min-width: 600px) {
  .content { padding: 18px; }
  .card { padding: 20px; }
}

/* —— 下钻明细弹窗 —— */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 640px; max-height: 84vh;
  border-radius: 12px 12px 0 0;
  display: flex; flex-direction: column;
  animation: slideUp 0.22s ease;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid #eef0f4; background: #f8fafc;
}
.modal-title { font-size: 16px; font-weight: 600; color: #111827; }
.modal-close {
  border: none; background: none; font-size: 26px; color: #8a94a6;
  cursor: pointer; line-height: 1; padding: 0 4px;
}
.modal-close:hover { color: #111827; }
.modal-body { padding: 12px 18px 22px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-body .sub { font-size: 12px; color: #6b7280; margin: 2px 0 10px; }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (min-width: 600px) {
  .modal-mask { align-items: center; }
  .modal { border-radius: 12px; }
}

/* —— 图表全屏按钮 & 全屏显示 —— */
.fs-btn {
  flex-shrink: 0;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #6b7280;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.fs-btn:hover { color: #111827; border-color: #6b7280; background: #f3f4f6; }
.chart-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card.fs, .chart-card.fs, .panel.fs {
  position: fixed !important;
  inset: 0;
  z-index: 99990;
  background: #fff;
  border-radius: 0;
  margin: 0 !important;
  padding: 16px 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.card.fs .chart, .chart-card.fs .chart, .panel.fs .chart {
  flex: 1 1 auto;
  height: calc(100vh - 90px) !important;
  min-height: 300px;
}

/* —— 宽屏响应式布局（参考酒店系统） —— */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.charts-grid .card { margin-bottom: 0; }
@media (max-width: 760px) { .charts-grid { grid-template-columns: 1fr; } }

/* —— 移动端：图表 canvas 左右贴边 —— */
@media (max-width: 599px) { .card .chart { margin-left: -14px; margin-right: -14px; } }