/* ===== 全局变量 ===== */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #e0e7ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --bg: #f8fafc;
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #4f46e5;
  --white: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== 登录页（樱桃云风格） ===== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  position: relative;
  overflow: hidden;
}

/* 已登录状态：同步隐藏登录页，避免刷新闪现 */
html.is-logged-in .login-wrapper { display: none !important; }
html.is-logged-in #app { display: flex !important; }

/* 视频背景层 */
.login-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

/* 遮罩层 - 视频未加载时的备用渐变（JS加载后会随机替换） */
.login-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(59,130,246,0.50) 0%,
    rgba(99,102,241,0.45) 40%,
    rgba(139,92,246,0.38) 100%
  );
  z-index: 1;
}

/* 居中内容区 */
.login-center {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  width: 100%;
  max-width: 440px;
}

/* Logo + 品牌名 */
.login-logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo-img {
  width: 360px;
  height: auto;
  object-fit: contain;
}

.login-brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.login-brand-name {
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 2px;
}

/* 登录表单卡片 - 全透明，给错误提示和输入框留空间 */
.login-form-card {
  background: transparent;
  backdrop-filter: none;
  border-radius: 12px;
  padding: 24px 20px 12px;
  width: 100%;
  position: relative;
}

/* 顶部 Tab 导航 - 白色文字 */
.login-tabs {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
  font-size: 13px;
  color: rgba(255,255,255,0.6);
}

.login-tab {
  cursor: pointer;
  font-weight: 400;
  transition: color 0.2s;
  user-select: none;
  position: relative;
  padding-bottom: 4px;
}

.login-tab.active {
  color: #fff;
  font-weight: 500;
}

.login-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}

/* 输入区域 */
.login-inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

/* 用户名 + 密码 + 按钮同一行（樱桃云风格） */
.login-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 用户名输入框 - 占约42% */
.login-input-user { flex: 0 0 auto; width: 180px; }

/* 密码输入框 - 占约38% */
.login-input-pwd { flex: 0 0 auto; width: 160px; }

.login-input-flex { flex: 1; }

/* 左侧图标 */
.login-in-icon {
  position: absolute;
  left: 12px;
  display: flex;
  align-items: center;
  pointer-events: none;
  z-index: 2;
}

/* 输入框 - 微微透明的白色背景 */
.login-fld {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 34px;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 6px;
  font-size: 13px;
  color: rgba(30,41,59,0.85);
  background: rgba(255,255,255,0.88);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.login-fld::placeholder { color: rgba(100,116,139,0.6); }

.login-fld:focus {
  border-color: rgba(79,70,229,0.6);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

/* 密码显示/隐藏按钮 */
.login-pwd-toggle {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}

.login-pwd-toggle:hover { background: rgba(0,0,0,0.06); }

/* 错误提示 - 固定在页面顶部居中，不撑开页面，红色 */
.login-err {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  text-align: center;
  padding: 8px 22px;
  background: rgba(254,242,242,0.97);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 8px;
  font-size: 12px;
  color: #dc2626;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  pointer-events: none;
}

/* 登录按钮 - 紫色底色（樱桃云风格） */
.login-submit {
  height: 40px;
  min-width: 68px;
  padding: 0 20px;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.login-submit:hover:not(:disabled) { background: #4338ca; }
.login-submit:active:not(:disabled) { transform: scale(0.97); }
.login-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.login-submit-loading {
  display: flex;
  align-items: center;
  gap: 5px;
}

.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* 版权信息 - 右下角 */
.login-copyright {
  position: absolute;
  bottom: 18px;
  right: 24px;
  z-index: 3;
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.03em;
}

/* 响应式 */
@media (max-width: 520px) {
  .login-center { padding: 24px 16px; }
  .login-form-card { padding: 20px 14px 12px; }
  .login-row { flex-direction: column; gap: 10px; }
  .login-input-user, .login-input-pwd { width: 100%; flex: none; }
  .login-submit { width: 100%; min-width: unset; }
}

/* ===== 布局 ===== */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
}

.sidebar-header {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo { font-size: 24px; }

.sidebar-title {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-group {
  margin-bottom: 16px;
}

/* 需要权限的菜单项默认隐藏，JS 验证通过后显示，避免刷新时闪烁 */
#sidebar-nav .admin-only,
#nav-group-admin {
  display: none;
}

.nav-group-title {
  color: var(--sidebar-text);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  transition: var(--transition);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
}

.nav-icon { font-size: 16px; flex-shrink: 0; }

/* ===== 子菜单 ===== */
.nav-sub {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

.nav-sub.open {
  max-height: 500px;
}

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 36px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  transition: var(--transition);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0.8;
}

.nav-sub-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  opacity: 1;
}

.nav-sub-item.active {
  background: rgba(99,102,241,0.3);
  color: #fff;
  opacity: 1;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 56px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  color: var(--text-secondary);
}

.sidebar-toggle:hover { background: var(--bg); }

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.topbar-date {
  font-size: 12px;
  color: var(--text-secondary);
}

/* 顶部右侧用户区 */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.3;
}

.topbar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.topbar-user-role {
  font-size: 11px;
  color: var(--text-secondary);
}

.topbar-logout {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: 1px solid #fee2e2;
  border-radius: var(--radius);
  background: #fef2f2;
  color: #dc2626;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}

.topbar-logout:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ===== 通用卡片 ===== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card-compact {
  padding: 10px 14px;
  margin-bottom: 12px;
}

/* ===== 数据概览双栏布局 ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.dashboard-grid-4 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 14px;
}

.dashboard-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

@media (max-width: 768px) {
  .dashboard-grid, .dashboard-grid-3, .dashboard-grid-4 { grid-template-columns: 1fr; }
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* ===== 统计卡片 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

/* 数据查询汇总卡片：无图标、纵向居中、更紧凑 */
.entry-stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
}
.entry-stats-grid .stat-card {
  flex-direction: column;
  justify-content: center;
  padding: 10px 8px;
  text-align: center;
  gap: 0;
}
.entry-stats-grid .stat-value {
  font-size: 14px;
  word-break: break-all;
}
.entry-stats-grid .stat-label {
  font-size: 11px;
}

/* 汇总卡片浅色底色 - 放在 .stat-card 之后确保优先级 */

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* 周期数据汇总卡片网格 */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-cards .stat-card {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  text-align: center;
  gap: 2px;
}

.stat-cards .stat-label {
  font-size: 10px;
  color: var(--text-secondary);
}

.stat-cards .stat-value {
  font-size: 13px;
  font-weight: 700;
  word-break: break-all;
}

.stat-cards .stat-compare {
  margin-top: 2px;
}

/* 汇总卡片浅色底色（放在 .stat-card 之后确保覆盖白色背景） */
.stat-blue   { background: #eff6ff; }
.stat-green  { background: #f0fdf4; }
.stat-gold   { background: #fefce8; }
.stat-teal   { background: #f0fdfa; }
.stat-purple { background: #faf5ff; }
.stat-red    { background: #fef2f2; }
.stat-orange { background: #fff7ed; }
.stat-lime   { background: #f7fee7; }
.stat-pink   { background: #fdf2f8; }
.stat-cyan   { background: #ecfeff; }
.stat-indigo { background: #eef2ff; }
.stat-rose   { background: #fff1f2; }

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #d1fae5; }
.stat-icon.purple { background: var(--primary-light); }
.stat-icon.orange { background: #fef3c7; }
.stat-icon.red { background: #fee2e2; }
.stat-icon.cyan { background: #cffafe; }
.stat-icon.teal { background: #ccfbf1; }
.stat-icon.gold { background: #fef9c3; }
.stat-icon.pink { background: #fce7f3; }
.stat-icon.lime { background: #ecfccb; }

.stat-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* ===== 周月对比标签 ===== */
.stat-compare {
  display: flex;
  gap: 6px;
  margin-top: 3px;
  font-size: 11px;
  line-height: 1;
}

.cmp-tag {
  display: inline-block;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
  white-space: nowrap;
}

.cmp-up {
  color: #dc2626;
  background: #fef2f2;
}

.cmp-down {
  color: #16a34a;
  background: #f0fdf4;
}

.cmp-flat {
  color: var(--text-secondary);
  background: #f1f5f9;
}

.cmp-new {
  color: #9333ea;
  background: #faf5ff;
}

/* ===== 表格 ===== */
.table-wrapper,
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #fafbfc;
  border-top: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.page-size-bar {
  display: flex;
  align-items: center;
}

.page-size-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
  cursor: pointer;
}

.pagination-bar {
  display: flex;
  align-items: center;
  gap: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: #f8fafc;
  padding: 6px 10px;
  text-align: center;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ===== 概览汇总表格：固定列宽，三表一致 ===== */
.summary-table { table-layout: fixed; }

.table-actions {
  display: flex;
  gap: 6px;
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: var(--transition);
  background: var(--white);
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-control[disabled],
.form-control:disabled,
select.form-control:disabled,
input.form-control[readonly] {
  background: #fff;
  color: #374151;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.form-row-4 {
  grid-template-columns: repeat(4, 1fr);
}

.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}

.form-hint {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== 徽章 ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-default { background: #f1f5f9; color: #64748b; }

/* 表格列宽辅助 */
.col-xs { width: 50px; min-width: 50px; }

/* 判定结果下拉 */
.judgment-select {
  max-width: 100px;
  padding: 2px 4px !important;
  font-size: 12px !important;
  height: auto !important;
}

/* ===== 过滤栏 ===== */
.filter-bar {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  margin-right: 8px;
}

.filter-item label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 4px;
}

.modal-close:hover { background: var(--bg); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ===== Toast ===== */
#toast-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 14px 24px;
  border-radius: var(--radius);
  background: #1e293b;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  animation: toastCenterIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 380px;
  text-align: center;
  pointer-events: auto;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }

@keyframes toastCenterIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ===== 分页 ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 16px 0;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== 数据录入表格 ===== */
.entry-table th, .entry-table td {
  padding: 5px 8px;
  white-space: nowrap;
}

.entry-table input[type="number"],
.entry-table input[type="text"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}

.entry-table input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== 搜索框 ===== */
.search-box {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.search-box input {
  padding-left: 32px;
}

.search-box::before {
  content: '🔍';
  position: absolute;
  left: 8px;
  font-size: 13px;
  pointer-events: none;
}

/* ===== 错误信息 ===== */
.error-msg {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ===== 加载状态 ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-secondary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 数字颜色 ===== */
.num-positive { color: #c0392b; font-weight: 600; }
.num-negative { color: #27ae60; font-weight: 600; }
.num-neutral { color: var(--text-secondary); }

/* ===== 页面标题区 ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* ===== Flatpickr 日期选择器定制样式 ===== */
/* 输入框：让整个框可点，去掉原生日期图标 */
input[type="date"].form-control,
.flatpickr-input.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
.flatpickr-input:read-only {
  background-color: var(--white);
  cursor: pointer;
}

/* 日历弹窗 */
.flatpickr-calendar {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
  font-size: 13px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

/* 月份/年份头部 */
.flatpickr-months .flatpickr-month {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.flatpickr-current-month { color: #fff; font-size: 14px; font-weight: 600; }
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month { color: #fff !important; fill: #fff !important; }
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg { fill: rgba(255,255,255,0.7) !important; }

/* 星期标题行 */
.flatpickr-weekdays { background: var(--primary-light); }
span.flatpickr-weekday { color: var(--primary-dark); font-weight: 600; font-size: 12px; }

/* 日期格子 */
.flatpickr-day {
  border-radius: var(--radius);
  font-size: 13px;
}
.flatpickr-day:hover { background: var(--primary-light); border-color: var(--primary-light); }
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.flatpickr-day.today {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}
.flatpickr-day.today.selected { color: #fff; }

/* 输入框内年月选择 */
.numInputWrapper span.arrowUp:after { border-bottom-color: var(--primary); }
.numInputWrapper span.arrowDown:after { border-top-color: var(--primary); }

.page-header h2 {
  font-size: 20px;
  font-weight: 700;
}

/* ===== 移动端底部导航栏 ===== */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 900;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 8px;
  min-width: 48px;
  min-height: 44px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item .mnav-icon { font-size: 20px; line-height: 1; }
.mobile-nav-item.active { color: var(--primary); font-weight: 600; }

/* 移动端子菜单弹窗 */
.mobile-submenu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 950;
  align-items: flex-end;
  justify-content: center;
}

.mobile-submenu-overlay.show { display: flex; }

.mobile-submenu {
  background: var(--white);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 500px;
  padding: 8px 0 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.mobile-submenu-title {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding: 12px 16px 8px;
}

.mobile-submenu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  font-size: 15px;
  color: var(--text);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}

.mobile-submenu-item:hover, .mobile-submenu-item:active { background: var(--bg); }
.mobile-submenu-item .msub-icon { font-size: 18px; }
.mobile-submenu-cancel {
  display: block;
  width: 100%;
  padding: 14px 24px;
  font-size: 15px;
  color: var(--text-secondary);
  border: none;
  border-top: 1px solid var(--border);
  background: none;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

/* ===== 响应式：手机端 (≤768px) ===== */
@media (max-width: 768px) {
  /* 隐藏侧边栏，显示底部导航 */
  .sidebar { display: none !important; }
  .sidebar-toggle { display: none; }
  .mobile-nav { display: flex; }

  /* 主内容区避开底部导航 */
  .main-content { padding-bottom: 56px; }

  /* Topbar 简化 */
  .topbar {
    padding: 0 12px;
    height: 48px;
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .topbar-title { font-size: 15px; }
  .topbar-date { display: none; }
  .topbar-user-info { display: none; }
  .topbar-logout { font-size: 12px; padding: 4px 10px; }

  /* 内容区 */
  .content-area { padding: 12px; }

  /* 卡片 */
  .card { padding: 14px; margin-bottom: 12px; }
  .card-compact { padding: 8px 10px; margin-bottom: 8px; }

  /* 统计卡片：2列 */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .entry-stats-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stat-card { padding: 10px 12px; }
  .stat-value { font-size: 15px; }
  .stat-label { font-size: 10px; }

  /* 网销分析移动端 */
  .wsa-table thead th { padding: 6px 8px; font-size: 11px; }
  .wsa-table tbody td { padding: 6px 8px; }
  .num-cell { padding: 1px 5px; font-size: 12px; min-width: 20px; }
  .rate-cell { padding: 2px 6px; font-size: 11px; min-width: 44px; }
  .empty-hint { padding: 24px 12px !important; }
  .empty-icon { font-size: 28px; }

  /* 网销分析：移动端统计卡片改为3-4列 */
  .wsa-page .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  .wsa-page .stat-card { padding: 6px 4px; }
  .wsa-page .stat-icon { width: 24px; height: 24px; font-size: 12px; line-height: 24px; }
  .wsa-page .stat-value { font-size: 13px; }
  .wsa-page .stat-label { font-size: 9px; }

  /* Dashboard 网格全部单列 */
  .dashboard-grid,
  .dashboard-grid-3,
  .dashboard-grid-4 { grid-template-columns: 1fr; gap: 10px; }

  /* 表格：可横向滚动，缩小字体 */
  .table-wrapper, .table-wrap {
    border-radius: 6px;
    -webkit-overflow-scrolling: touch;
  }
  table { font-size: 12px; }
  thead th { padding: 5px 6px; font-size: 11px; }
  tbody td { padding: 4px 6px; font-size: 12px; }

  /* 筛选栏垂直排列 */
  .filter-bar {
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    margin-bottom: 10px;
  }
  .filter-item { min-width: 100%; }
  .filter-item label { font-size: 11px; }

  /* 表单单列 */
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }
  .form-group { margin-bottom: 12px; }
  .form-control { font-size: 16px; padding: 10px 12px; } /* iOS 不缩放 */

  /* 按钮 */
  .btn { padding: 10px 16px; font-size: 14px; min-height: 44px; }
  .btn-sm { padding: 6px 10px; font-size: 13px; min-height: 36px; }
  .btn-block { padding: 14px; }

  /* 模态框全屏 */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    animation: slideUp 0.3s ease;
  }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 10px 16px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 0; }

  /* 分页按钮更大 */
  .page-btn {
    min-width: 36px;
    height: 36px;
    font-size: 14px;
  }

  /* 空状态 */
  .empty-state { padding: 36px 16px; }
  .empty-state .empty-icon { font-size: 40px; }

  /* 搜索框全宽 */
  .search-box { display: flex; width: 100%; }
  .search-box input { width: 100%; }

  /* 数据录入表格 */
  .entry-table th, .entry-table td { padding: 4px 5px; }

  /* Toast 靠下显示，避开底部导航 */
  #toast-container {
    top: auto;
    bottom: 80px;
    transform: translate(-50%, 0);
  }

  /* 数字颜色保持 */
  .num-positive { color: #c0392b; font-weight: 600; }
  .num-negative { color: #27ae60; font-weight: 600; }

  /* 侧边栏折叠按钮隐藏 */
  .sidebar.collapsed { display: none !important; }

  /* 顶部操作按钮区 */
  .page-header { flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

  /* 登录页手机适配 */
  .login-logo-img { width: 240px !important; }
  .login-center { padding: 20px 16px; padding-top: 6vh; }
  .login-form-card { padding: 16px 12px 8px; }
  .login-row { flex-direction: column; gap: 8px; }
  .login-input-user, .login-input-pwd { width: 100% !important; flex: none !important; }
  .login-submit { width: 100%; min-width: unset; }
  .login-copyright { bottom: 10px; right: 12px; font-size: 10px; }
}

/* ===== 平板端 (769px-1024px) ===== */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar { width: 200px; min-width: 200px; }
  .content-area { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  /* 网销分析平板端：确保一行显示 */
  .wsa-page .stats-grid { grid-template-columns: repeat(11, 1fr); gap: 6px; }
  .dashboard-grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ========== 网销分析页面专用样式 ========== */
.wsa-page { animation: fadeIn 0.3s ease; }

/* 网销分析：统计卡片紧凑布局，确保11个卡片在一行 */
.wsa-page .stats-grid {
  grid-template-columns: repeat(11, 1fr);
  gap: 8px;
}
.wsa-page .stat-card {
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
}
.wsa-page .stat-icon {
  width: 28px; height: 28px;
  font-size: 14px;
  line-height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wsa-page .stat-value { font-size: 15px; text-align: center; }
.wsa-page .stat-label { font-size: 10px; text-align: center; }
.wsa-page .stat-info { align-items: center; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 空状态提示 */
.empty-hint {
  text-align: center;
  padding: 40px 16px !important;
  color: var(--text-secondary);
}
.empty-icon {
  font-size: 36px;
  margin-bottom: 8px;
}
.empty-text {
  font-size: 13px;
  margin-top: 4px;
}
.error-text { color: var(--danger); }

/* 加载动画 */
.loading-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 空状态占位卡片 */
.wsa-empty-card {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px !important;
  background: #fafbfc;
  border: 1px dashed var(--border);
}

/* stat-info 布局（图标+文字左右排列） */
.stat-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* 彩色数值 */
.val-gold { color: #d97706 !important; font-weight: 700; }
.val-blue { color: #2563eb !important; font-weight: 700; }
.val-purple { color: #7c3aed !important; font-weight: 700; }
.val-red { color: #dc2626 !important; font-weight: 700; }
.val-green { color: #059669 !important; font-weight: 700; }
.val-teal { color: #0d9488 !important; font-weight: 700; }
.val-orange { color: #ea580c !important; font-weight: 700; }

.stat-gold { background: #fef3c7 !important; }

/* 表格增强 */
.wsa-table {
  border-collapse: separate;
  border-spacing: 0;
}
.wsa-table thead th {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 10px 12px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.wsa-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  transition: background 0.15s;
}
.wsa-table tbody tr:hover td { background: #f8faff; }
.wsa-table tbody tr.alt-row td { background: #fafbfc; }
.wsa-table tbody tr.alt-row:hover td { background: #f8faff; }

/* 单元格内数字样式 */
.num-cell {
  display: inline-block;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 24px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 5px;
}
.num-primary { background: #eef2ff; color: #4338ca; }
.num-type-a { background: #fef3c7; color: #b45309; }
.num-type-b { background: #dbeafe; color: #2563eb; }
.num-type-c { background: #ede9fe; color: #7c3aed; }
.num-invalid { background: #fee2e2; color: #dc2626; }
.num-visited { background: #d1fae5; color: #059669; }
.num-converted { background: #ccfbf1; color: #0d9488; }

.date-cell {
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.user-cell {
  font-weight: 500;
  color: var(--text);
}

/* 进店率单元格 */
.rate-cell {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: center;
}
.rate-eff {
  background: #cffafe;
  color: #0e7490;
}
.rate-good { background: #d1fae5; color: #047857; }
.rate-normal { background: #fef3c7; color: #b45309; }
.rate-poor { background: #fee2e2; color: #dc2626; }
/* 有效进店率：统一青色，无左边框 */
.rate-cell.rate-eff {
  background: #cffafe !important;
  color: #0e7490 !important;
  border: none !important;
}

/* 按钮图标间距 */
.btn-icon { margin-right: 4px; }

/* 筛选按钮组 */
.filter-btn-group {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.filter-btn-group .btn { white-space: nowrap; }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  background: var(--bg);
  color: var(--primary);
  border-color: var(--primary-light);
}

/* ===== 渠道折线图指标按钮 ===== */
.ch-metric-btn {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.ch-metric-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary);
  background: var(--primary-light);
}
.ch-metric-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}
