/* ============ 主题变量 ============ */
:root {
  --primary: #3477d6;
  --primary-dark: #2456a8;
  --primary-light: #eaf2fd;
  --success: #34c38f;
  --warning: #f0a24b;
  --danger: #ef5f5f;
  --text: #2c3340;
  --text-2: #5f6b7d;
  --text-3: #98a2b3;
  --border: #e8ecf2;
  --bg: #f3f5f9;
  --card: #ffffff;
  --shadow-sm: 0 1px 3px rgba(23, 43, 77, .06);
  --shadow: 0 4px 16px rgba(23, 43, 77, .08);
  --shadow-lg: 0 12px 32px rgba(23, 43, 77, .14);
  --radius: 12px;
  --sidebar-w: 224px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c9d2de; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aab6c6; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 登录页 ============ */
.login-wrap {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(103, 194, 143, .25), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(59, 130, 246, .35), transparent 55%),
    linear-gradient(135deg, #16294f 0%, #24518f 50%, #3477d6 100%);
}
.login-card {
  width: 420px; max-width: 100%; padding: 44px 40px 32px;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px);
  border-radius: 18px; box-shadow: var(--shadow-lg);
}
.login-logo {
  width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), #5ea1f0);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; box-shadow: 0 8px 20px rgba(52, 119, 214, .35);
}
.login-title { text-align: center; font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: 1px; }
.login-sub { text-align: center; font-size: 13px; color: var(--text-3); margin: 6px 0 26px; }
.login-tip {
  margin-top: 18px; font-size: 12px; color: var(--text-2); line-height: 1.9;
  background: var(--primary-light); border: 1px solid #d8e6fb;
  border-radius: 10px; padding: 10px 14px;
}

/* ============ 主布局 ============ */
.layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; z-index: 30;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #1b2740 0%, #223455 60%, #1f2f4d 100%);
  transition: transform .25s ease;
}
.sidebar .logo {
  height: 64px; display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; font-weight: 700; color: #fff; letter-spacing: 1px;
  background: rgba(255, 255, 255, .05); border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.menu { flex: 1; padding: 10px 12px; overflow-y: auto; }
.menu-item {
  padding: 12px 16px; margin-bottom: 4px; cursor: pointer; font-size: 14px;
  color: #b9c5d8; display: flex; align-items: center; gap: 10px;
  border-radius: 9px; transition: all .18s ease;
}
.menu-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.menu-item.active {
  background: linear-gradient(90deg, var(--primary), #4a8ce0);
  color: #fff; font-weight: 600;
  box-shadow: 0 4px 12px rgba(52, 119, 214, .4);
}
.menu-item span:first-child { font-size: 16px; width: 20px; text-align: center; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.header {
  height: 60px; background: var(--card); display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px;
  box-shadow: var(--shadow-sm); z-index: 10; gap: 12px;
}
.header .page-title {
  font-size: 17px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.header-user { cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.hamburger {
  display: none; width: 38px; height: 38px; border: none; border-radius: 9px;
  background: var(--primary-light); color: var(--primary); font-size: 18px;
  cursor: pointer; align-items: center; justify-content: center; flex-shrink: 0;
}
.hamburger:hover { background: #d8e6fb; }
.sidebar-mask { display: none; }
.content { flex: 1; overflow-y: auto; padding: 20px 24px 32px; scroll-behavior: smooth; }

/* ============ KPI 卡片 ============ */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi-card {
  background: var(--card); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  border: 1px solid var(--border); transition: transform .2s ease, box-shadow .2s ease;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--kc, var(--primary));
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.kpi-label { font-size: 13px; color: var(--text-3); margin-bottom: 8px; }
.kpi-value { font-size: 27px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 13px; font-weight: 400; color: var(--text-3); margin-left: 4px; }

/* ============ 面板 ============ */
.panel {
  background: var(--card); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  margin-bottom: 16px;
}
.panel-title {
  font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.panel-title .muted { font-weight: 400; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .panel { margin-bottom: 0; }

/* ============ 工具栏 / 标签 ============ */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.el-tag { border-radius: 6px; }

/* ============ 时间线 ============ */
.fu-item { border-left: 2px solid var(--border); margin-left: 8px; padding: 0 0 16px 16px; position: relative; }
.fu-item::before {
  content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.fu-meta { font-size: 12px; color: var(--text-3); margin-bottom: 4px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fu-content { font-size: 13px; color: var(--text); line-height: 1.65; background: #f7f9fc; padding: 9px 12px; border-radius: 8px; }

.table-pager { margin-top: 12px; display: flex; justify-content: flex-end; }
.muted { color: var(--text-3); font-size: 12px; }
.danger-text { color: var(--danger); font-weight: 600; }

/* ============ 地图页面 ============ */
.map-layout { display: flex; gap: 16px; align-items: stretch; }
#crm-map, #poi-map, .map-box {
  flex: 1; height: 660px; min-width: 0; border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.map-side { width: 360px; flex-shrink: 0; margin-bottom: 0; max-height: 660px; overflow-y: auto; }
.side-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 0; border-bottom: 1px solid #f0f2f5; font-size: 13px;
}
.side-item:last-child { border-bottom: none; }

/* ============ 表格微调 ============ */
.el-table { border-radius: 10px; }
.el-table th.el-table__cell { background: #f7f9fc !important; color: var(--text-2); font-weight: 600; }
.el-button { border-radius: 8px; }
.el-dialog { border-radius: 14px; }
.el-card { border-radius: 12px; }

/* ============================================================
   响应式适配
   ============================================================ */

/* ---- 平板 / 小屏笔记本 ---- */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .map-side { width: 300px; }
}

/* ---- 手机端 ---- */
@media (max-width: 768px) {
  /* 布局：侧边栏改抽屉 */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: none;
  }
  .layout.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .sidebar-mask {
    display: none; position: fixed; inset: 0; z-index: 25;
    background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px);
  }
  .layout.sidebar-open .sidebar-mask { display: block; }

  .hamburger { display: flex; }
  .header { height: 54px; padding: 0 14px; }
  .header .page-title { font-size: 16px; }
  .header-user .user-name { display: none; }   /* 手机端只显示头像 */
  .content { padding: 12px 12px 28px; }

  /* 卡片与栅格单列 */
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-card { padding: 14px 14px; }
  .kpi-value { font-size: 22px; }
  .grid-2 { grid-template-columns: 1fr; gap: 12px; }
  .panel { padding: 14px 14px; border-radius: 10px; }

  /* 地图纵排 */
  .map-layout { flex-direction: column; }
  #crm-map, #poi-map, .map-box { height: 52vh; min-height: 320px; }
  .map-side { width: 100%; max-height: none; }

  /* 弹窗与表单占满屏 */
  .el-dialog { width: 94% !important; max-width: 94vw; margin-top: 6vh !important; }
  .el-message-box { width: 92% !important; max-width: 92vw; }

  /* 抽屉全宽 */
  .el-drawer { width: 100% !important; }

  /* 表格：允许横向滚动，字号略减 */
  .el-table { font-size: 12px; }
  .el-table .cell { padding: 0 8px; }
  .toolbar .el-button { padding: 8px 12px; }
  .toolbar .el-input, .toolbar .el-select, .toolbar .el-date-editor {
    width: auto !important; min-width: 130px; flex: 1 1 140px; max-width: 100%;
  }
}

/* ---- 超小屏 ---- */
@media (max-width: 420px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 32px 22px 24px; }
  .content { padding: 10px 10px 24px; }
}

/* 手机端 Element 消息提示位置避让 */
@media (max-width: 768px) {
  .el-message { min-width: auto; max-width: 88vw; }
}
