/* =============================================
   网站统计系统 - 主样式 v3
   管理员登录 + 左侧站点列表 + 右侧仪表盘
   ============================================= */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e5e7eb;
  --border-light: #f0f1f3;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --accent-dark: #1d4ed8;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --purple: #7c3aed;
  --purple-light: #f5f3ff;
  --site-panel-w: 280px;
  --topbar-h: 56px;
  --subnav-h: 44px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);
  --transition: 0.18s cubic-bezier(0.16,1,0.3,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Outfit', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg); color: var(--text-primary);
  min-height: 100vh; overflow-x: hidden;
}

/* =============================================
   登录页
   ============================================= */
.auth-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8ecf4 50%, #f4f0ff 100%);
  padding: 20px;
}
.auth-container { width: 100%; max-width: 400px; }
.auth-card {
  background: var(--surface); border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.08); overflow: hidden;
}
.auth-header { text-align: center; padding: 36px 32px 24px; }
.auth-logo {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--accent), #60a5fa);
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  color: white; margin: 0 auto 16px; box-shadow: 0 4px 16px rgba(37,99,235,0.3);
}
.auth-logo svg { width: 24px; height: 24px; }
.auth-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.auth-subtitle { font-size: 13.5px; color: var(--text-secondary); }
.auth-form { padding: 0 32px 28px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-icon { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--text-tertiary); pointer-events: none; }
.input-wrap input {
  width: 100%; padding: 10px 12px 10px 38px;
  font-family: inherit; font-size: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-primary);
  transition: all var(--transition); outline: none;
}
.input-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.input-wrap input::placeholder { color: var(--text-tertiary); }
.auth-btn {
  width: 100%; padding: 11px; font-family: inherit; font-size: 14px; font-weight: 600;
  color: white; background: linear-gradient(135deg, var(--accent), #3b82f6);
  border: none; border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition);
}
.auth-btn:hover { box-shadow: 0 4px 14px rgba(37,99,235,0.35); transform: translateY(-1px); }
.auth-btn:active { transform: translateY(0); }
.auth-error { margin-top: 12px; font-size: 13px; color: var(--danger); text-align: center; min-height: 20px; }
.auth-footer { padding: 0 32px 28px; text-align: center; }
.auth-footer p { font-size: 12.5px; color: var(--text-tertiary); }

/* =============================================
   App Shell
   ============================================= */
.app-shell { display: flex; min-height: 100vh; }

/* ====== 左侧站点面板 ====== */
.site-panel {
  width: var(--site-panel-w); min-height: 100vh;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 100; transition: transform var(--transition);
}
.site-panel-header { padding: 18px 16px 14px; border-bottom: 1px solid var(--border-light); }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), #60a5fa);
  border-radius: 9px; display: flex; align-items: center; justify-content: center; color: white;
}
.logo-icon svg { width: 17px; height: 17px; }
.logo-text { display: flex; flex-direction: column; }
.logo-name { font-size: 14px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.logo-sub { font-size: 11px; color: var(--text-tertiary); font-weight: 400; }

.site-list-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 8px;
}
.site-list-title { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; }
.btn-add-site {
  width: 26px; height: 26px; background: var(--accent); color: white;
  border: none; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition);
}
.btn-add-site svg { width: 14px; height: 14px; }
.btn-add-site:hover { background: var(--accent-dark); transform: scale(1.05); }

.site-list { flex: 1; overflow-y: auto; padding: 0 8px; }
.site-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 2px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition); position: relative;
}
.site-item:hover { background: var(--surface-2); }
.site-item.active { background: var(--accent-light); }
.site-item-avatar {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: white; flex-shrink: 0;
}
.site-item-info { flex: 1; min-width: 0; }
.site-item-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-item-domain {
  font-size: 11px; color: var(--text-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px;
}
.site-item-actions {
  display: flex; gap: 2px; opacity: 0;
  transition: opacity var(--transition); flex-shrink: 0;
}
.site-item:hover .site-item-actions { opacity: 1; }
.site-item-actions button {
  width: 26px; height: 26px; background: none; border: none; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-tertiary); transition: all var(--transition);
}
.site-item-actions button svg { width: 14px; height: 14px; }
.site-item-actions button:hover { background: var(--bg); color: var(--text-primary); }
.site-item-actions button.del:hover { background: var(--danger-light); color: var(--danger); }

.site-panel-footer { padding: 10px 12px; border-top: 1px solid var(--border-light); }
.footer-info { margin-bottom: 6px; }
.btn-footer-link {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 6px 10px;
  font-family: inherit; font-size: 12px; font-weight: 500;
  color: var(--text-tertiary); background: none; border: none;
  border-radius: 6px; cursor: pointer; transition: all var(--transition);
  text-align: left;
}
.btn-footer-link svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-footer-link:hover { background: var(--surface-2); color: var(--text-secondary); }
.btn-logout {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 7px 10px;
  font-family: inherit; font-size: 12px; font-weight: 500;
  color: var(--text-tertiary); background: none; border: none;
  border-radius: 6px; cursor: pointer; transition: all var(--transition);
  text-align: left;
}
.btn-logout svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-logout:hover { background: var(--danger-light); color: var(--danger); }

/* ====== 右侧主区域 ====== */
.main-area {
  flex: 1; margin-left: var(--site-panel-w);
  min-height: 100vh; display: flex; flex-direction: column;
  transition: margin var(--transition);
}

.empty-welcome {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 40px;
}
.welcome-icon {
  width: 80px; height: 80px;
  background: var(--surface-2); border: 2px dashed var(--border);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 20px;
}
.welcome-icon svg { width: 36px; height: 36px; color: var(--text-tertiary); }
.empty-welcome h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.empty-welcome p { font-size: 14px; color: var(--text-tertiary); max-width: 300px; }

.dashboard-area { display: flex; flex-direction: column; flex: 1; }

/* ====== 顶栏 ====== */
.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.menu-toggle {
  display: none; padding: 6px; background: none; border: none;
  cursor: pointer; color: var(--text-secondary); border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.menu-toggle svg { width: 20px; height: 20px; }
.menu-toggle:hover { background: var(--bg); }
.breadcrumb { font-size: 15px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.site-info-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; background: var(--accent-light); border-radius: 99px;
  font-size: 12px; font-weight: 600; color: var(--accent);
  white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis;
}
.site-info-chip .site-dot { width: 6px; height: 6px; background: var(--success); border-radius: 50%; flex-shrink: 0; }

.date-picker {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-secondary);
}
.date-picker svg { width: 14px; height: 14px; flex-shrink: 0; }
.date-picker select {
  border: none; background: transparent;
  font-family: inherit; font-size: 13px;
  color: var(--text-primary); cursor: pointer; outline: none;
  min-width: 68px;
}

.btn-refresh {
  width: 34px; height: 34px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary); transition: all var(--transition);
  flex-shrink: 0;
}
.btn-refresh svg { width: 15px; height: 15px; }
.btn-refresh:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.btn-refresh.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== 数据库模式标识 ====== */
.db-mode-chip {
  font-size: 11px; font-weight: 500; padding: 3px 8px;
  border-radius: 20px; white-space: nowrap; flex-shrink: 0;
  border: 1px solid transparent; letter-spacing: 0.02em;
  transition: all var(--transition);
}
.db-mode-chip.db-online {
  background: var(--success-light); color: var(--success);
  border-color: #a7f3d0;
}
.db-mode-chip.db-offline {
  background: var(--surface-2); color: var(--text-tertiary);
  border-color: var(--border);
}

/* ====== 子导航 ====== */
.sub-nav {
  height: var(--subnav-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 2px;
  padding: 0 16px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; -ms-overflow-style: none;
}
.sub-nav::-webkit-scrollbar { display: none; }
.sub-nav-item {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px; white-space: nowrap;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary); text-decoration: none;
  border-radius: 6px; transition: all var(--transition);
  cursor: pointer; flex-shrink: 0;
}
.sub-nav-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.sub-nav-item:hover { background: var(--bg); color: var(--text-primary); }
.sub-nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.badge { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 99px; }
.badge.live { background: rgba(239,68,68,0.12); color: var(--danger); animation: blink 2s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.5} }

.content { flex: 1; padding: 24px; }

/* =============================================
   统计卡片
   ============================================= */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative; overflow: hidden;
}
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: var(--radius) var(--radius) 0 0; }
.kpi-card.blue::before { background: linear-gradient(90deg, var(--accent), #60a5fa); }
.kpi-card.green::before { background: linear-gradient(90deg, var(--success), #34d399); }
.kpi-card.orange::before { background: linear-gradient(90deg, var(--warning), #fcd34d); }
.kpi-card.purple::before { background: linear-gradient(90deg, var(--purple), #a78bfa); }
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.kpi-label { font-size: 12.5px; font-weight: 500; color: var(--text-secondary); }
.kpi-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-icon svg { width: 17px; height: 17px; }
.kpi-icon.blue { background: var(--accent-light); color: var(--accent); }
.kpi-icon.green { background: var(--success-light); color: var(--success); }
.kpi-icon.orange { background: var(--warning-light); color: var(--warning); }
.kpi-icon.purple { background: var(--purple-light); color: var(--purple); }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.5px; line-height: 1; margin-bottom: 8px; }
.kpi-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; flex-wrap: wrap; }
.kpi-change { display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px; border-radius: 99px; font-weight: 600; }
.kpi-change.up { background: var(--success-light); color: var(--success); }
.kpi-change.down { background: var(--danger-light); color: var(--danger); }
.kpi-change svg { width: 11px; height: 11px; }
.kpi-compare { color: var(--text-tertiary); }

/* =============================================
   图表卡片
   ============================================= */
.chart-grid { display: grid; gap: 16px; margin-bottom: 24px; }
.chart-grid.two-col { grid-template-columns: 1fr 1fr; }
.chart-grid.main-side { grid-template-columns: 2fr 1fr; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border-light); gap: 8px; flex-wrap: wrap; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.card-title svg { width: 16px; height: 16px; color: var(--text-tertiary); flex-shrink: 0; }
.card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.tab-group { display: flex; gap: 2px; background: var(--bg); padding: 3px; border-radius: var(--radius-sm); }
.tab-btn { padding: 4px 10px; font-size: 12px; font-weight: 500; color: var(--text-secondary); background: transparent; border: none; border-radius: 6px; cursor: pointer; transition: all var(--transition); white-space: nowrap; }
.tab-btn.active { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow); }
.tab-btn:hover:not(.active) { color: var(--text-primary); }
.card-body { padding: 18px; }
.chart-wrap { position: relative; }
.chart-wrap canvas { max-height: 280px; }

/* 实时 */
.realtime-header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border-light); }
.realtime-count { font-size: 36px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.realtime-label { font-size: 12px; color: var(--text-secondary); }
.realtime-dot { width: 10px; height: 10px; background: var(--success); border-radius: 50%; margin-left: auto; animation: pulse-dot 1.5s infinite; flex-shrink: 0; }
@keyframes pulse-dot { 0%,100%{box-shadow:0 0 0 2px rgba(16,185,129,0.2)} 50%{box-shadow:0 0 0 4px rgba(16,185,129,0.1)} }
.realtime-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.pulse-ring { position: relative; width: 120px; height: 120px; margin: 0 auto 16px; }
.pulse-number { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.pulse-number .num { font-size: 36px; font-weight: 700; color: var(--text-primary); }
.pulse-number .lbl { font-size: 11px; color: var(--text-secondary); }
.pulse-ring svg { width: 120px; height: 120px; }

/* 数据表格 */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 10px 16px; font-size: 11.5px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; text-align: left; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 11px 16px; font-size: 13.5px; color: var(--text-primary); border-bottom: 1px solid var(--border-light); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table td.num { font-weight: 600; font-variant-numeric: tabular-nums; }
.data-table td.secondary { color: var(--text-secondary); }
.rank-badge { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.rank-1 { background: #fef3c7; color: #d97706; }
.rank-2 { background: #f1f5f9; color: #64748b; }
.rank-3 { background: #fef2f2; color: #dc2626; }
.rank-n { background: var(--bg); color: var(--text-tertiary); }

/* 进度条 */
.progress-bar { height: 5px; background: var(--border-light); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1); }
.progress-fill.blue { background: var(--accent); }
.progress-fill.green { background: var(--success); }
.progress-fill.orange { background: var(--warning); }
.progress-fill.purple { background: var(--purple); }

/* 来源标签 */
.source-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.source-tag.search { background: var(--accent-light); color: var(--accent); }
.source-tag.direct { background: var(--success-light); color: var(--success); }
.source-tag.referral { background: var(--purple-light); color: var(--purple); }
.source-tag.social { background: var(--warning-light); color: var(--warning); }
.source-tag.email { background: #fef3c7; color: #92400e; }

/* 设备图表 */
.device-legend { display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 10px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-label { flex: 1; font-size: 13px; color: var(--text-secondary); }
.legend-value { font-size: 13px; font-weight: 600; }
.stat-bar-list { display: flex; flex-direction: column; gap: 14px; }
.stat-bar-item {}
.stat-bar-top { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 13px; }
.stat-bar-name { color: var(--text-primary); font-weight: 500; }
.stat-bar-val { color: var(--text-secondary); }

/* 代码片段 */
.code-card { background: #1e2433; border-radius: var(--radius); overflow: hidden; }
.code-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: #252d3d; border-bottom: 1px solid #2f3a50; gap: 8px; }
.code-dots { display: flex; gap: 6px; flex-shrink: 0; }
.code-dots span { width: 12px; height: 12px; border-radius: 50%; }
.code-dots span:nth-child(1) { background: #ff5f57; }
.code-dots span:nth-child(2) { background: #ffbd2e; }
.code-dots span:nth-child(3) { background: #28c840; }
.code-label { font-size: 12px; color: #6b7a99; font-family: monospace; }
.btn-copy { padding: 4px 10px; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; color: #8b9ab5; font-size: 12px; cursor: pointer; transition: all var(--transition); display: flex; align-items: center; gap: 5px; white-space: nowrap; flex-shrink: 0; }
.btn-copy svg { width: 13px; height: 13px; }
.btn-copy:hover { background: rgba(255,255,255,0.12); color: #fff; }
.btn-copy.copied { color: #28c840; border-color: #28c840; }
.code-body { padding: 20px; font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace; font-size: 13px; line-height: 1.7; overflow-x: auto; }
.code-body pre { color: #cdd6f4; margin: 0; }
.tok-comment { color: #6c7a9c; font-style: italic; }
.tok-string { color: #a6e3a1; }
.tok-key { color: #89b4fa; }
.tok-tag { color: #f38ba8; }
.tok-attr { color: #fab387; }
.tok-num { color: #f9e2af; }

/* =============================================
   模态框
   ============================================= */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); animation: modalIn 0.2s cubic-bezier(0.16,1,0.3,1); max-height: 90vh; overflow-y: auto; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border-light); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { width: 28px; height: 28px; background: none; border: none; font-size: 20px; color: var(--text-tertiary); cursor: pointer; border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; line-height: 1; }
.modal-close:hover { background: var(--bg); color: var(--text-primary); }
.modal-body { padding: 22px; }
.modal-body .form-group { margin-bottom: 16px; }
.modal-body .form-group:last-of-type { margin-bottom: 0; }
.modal-body .form-group input { width: 100%; padding: 10px 12px; font-family: inherit; font-size: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-primary); transition: all var(--transition); outline: none; }
.modal-body .form-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-hint { font-size: 11.5px; color: var(--text-tertiary); margin-top: 4px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.btn-primary { padding: 8px 18px; font-family: inherit; font-size: 13px; font-weight: 600; color: white; background: var(--accent); border: none; border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition); white-space: nowrap; }
.btn-primary:hover { background: var(--accent-dark); box-shadow: 0 2px 8px rgba(37,99,235,0.3); }
.btn-secondary { padding: 8px 18px; font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text-secondary); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition); white-space: nowrap; }
.btn-secondary:hover { color: var(--text-primary); background: var(--bg); }

/* 站点详情模态框 */
.site-detail-section { margin-bottom: 16px; }
.site-detail-section:last-child { margin-bottom: 0; }
.site-detail-label { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.site-detail-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-light); gap: 12px; }
.site-detail-row:last-child { border-bottom: none; }
.site-detail-key { font-size: 13px; color: var(--text-secondary); flex-shrink: 0; }
.site-detail-val { font-size: 13px; font-weight: 600; color: var(--text-primary); font-family: monospace; text-align: right; word-break: break-all; }
.site-detail-val.accent { color: var(--accent); }
.site-detail-actions { display: flex; gap: 8px; margin-top: 16px; }
.pwd-display { display: flex; align-items: center; gap: 8px; }
.pwd-text { font-family: monospace; font-size: 14px; font-weight: 600; color: var(--text-primary); letter-spacing: 1px; }
.pwd-hidden { font-family: monospace; font-size: 14px; color: var(--text-tertiary); }
.btn-icon-sm { width: 28px; height: 28px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-tertiary); transition: all var(--transition); flex-shrink: 0; }
.btn-icon-sm svg { width: 14px; height: 14px; }
.btn-icon-sm:hover { background: var(--bg); color: var(--text-primary); }

/* 空状态 / Toast / 动画 */
.empty-state { text-align: center; padding: 60px 40px; color: var(--text-tertiary); }
.empty-state svg { width: 40px; height: 40px; opacity: 0.3; margin-bottom: 10px; }
.empty-state p { font-size: 13px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 20px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); padding: 12px 20px; background: var(--text-primary); color: white; border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow-lg); opacity: 0; transition: all 0.3s cubic-bezier(0.16,1,0.3,1); z-index: 9999; white-space: nowrap; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.page-enter { animation: fadeInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.skeleton { background: linear-gradient(90deg, var(--border-light) 25%, var(--bg) 50%, var(--border-light) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 4px; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 99; }
.overlay.show { display: block; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* =============================================
   新增页面样式
   ============================================= */

/* 留存卡片 */
.retention-summary { display: flex; gap: 16px; margin-bottom: 8px; }
.retention-item { flex: 1; text-align: center; padding: 12px 8px; background: var(--surface-2); border-radius: var(--radius-sm); }
.retention-label { font-size: 11px; color: var(--text-tertiary); margin-bottom: 4px; }
.retention-value { font-size: 22px; font-weight: 700; }

/* 漏斗总转化率 */
.funnel-total-rate { font-size: 13px; color: var(--text-secondary); background: var(--accent-light); padding: 4px 12px; border-radius: 20px; font-weight: 500; white-space: nowrap; }
.funnel-total-rate strong { color: var(--accent); font-size: 15px; margin-left: 4px; }
.funnel-table-wrap { margin-top: 16px; }

/* 访客标签 */
.visitor-tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.visitor-tag.new { background: var(--accent-light); color: var(--accent); }
.visitor-tag.old { background: var(--success-light); color: var(--success); }

/* =============================================
   响应式
   ============================================= */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid.main-side { grid-template-columns: 1fr; }
  .chart-grid:not(.two-col):not(.main-side) { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 900px) {
  .site-panel { transform: translateX(-100%); }
  .site-panel.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .menu-toggle { display: flex; }
  .chart-grid.two-col { grid-template-columns: 1fr; }
  .realtime-grid { grid-template-columns: 1fr; }
  .chart-grid:not(.two-col):not(.main-side) { grid-template-columns: 1fr !important; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; }
  .kpi-value { font-size: 22px; }
  .sub-nav { padding: 0 12px; }
  .topbar { padding: 0 12px; }
  .topbar-right { gap: 6px; }
  .site-info-chip { max-width: 100px; padding: 5px 8px; font-size: 11px; }
  .date-picker { padding: 5px 8px; }
  .date-picker select { min-width: 56px; font-size: 12px; }
}
@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
