/* ===== 全局重置 & 变量 ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --accent: #06b6d4;
  --accent-light: #22d3ee;
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --navbar-height: 68px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border: #334155;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.5);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
  padding-top: var(--navbar-height);
  min-height: 100vh;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

a {
  color: var(--primary);
  text-decoration: none;
}

/* ===== 导航栏 ===== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--navbar-height);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--transition), background var(--transition);
}

[data-theme="dark"] .navbar {
  background: rgba(15, 23, 42, 0.8);
}

.navbar.scrolled {
  box-shadow: var(--shadow-md);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.5px;
}

.logo i {
  font-size: 1.4rem;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-link {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link i {
  font-size: 1rem;
}

.nav-link:hover {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.hamburger span {
  width: 24px;
  height: 2.5px;
  background: var(--text-primary);
  border-radius: 4px;
  transition: all var(--transition);
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

/* ===== 视图 (SPA) ===== */
.view {
  display: none;
  animation: fadeUp 0.4s ease;
}

.view.active {
  display: block;
}

@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ===== 英雄区 + 指标 ===== */
.hero-section {
  padding: 40px 0 20px;
}

.hero-section h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 4px;
  font-size: 1.05rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 28px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all var(--transition);
  cursor: default;
}

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

.stat-card .stat-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  color: var(--primary);
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.stat-card .stat-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.stat-card .stat-change {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
}

.stat-change.up {
  background: #dcfce7;
  color: #16a34a;
}

.stat-change.down {
  background: #fee2e2;
  color: #dc2626;
}

[data-theme="dark"] .stat-change.up {
  background: #14532d;
  color: #4ade80;
}

[data-theme="dark"] .stat-change.down {
  background: #7f1d1d;
  color: #f87171;
}

/* ===== 卡片通用 ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

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

.card-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px 24px;
}

.mt-2 {
  margin-top: 24px;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--border);
  color: var(--text-secondary);
}

.badge-primary {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
}

/* ===== 最近报表列表 ===== */
.report-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.report-item:last-child {
  border-bottom: none;
}

.report-item:hover {
  background: rgba(99, 102, 241, 0.03);
}

.report-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.report-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
}

.report-title {
  font-weight: 600;
}

.report-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.report-actions .btn {
  padding: 4px 12px;
  font-size: 0.8rem;
}

/* ===== 快速操作 ===== */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ===== 报表页面 ===== */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 32px 0 20px;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.search-input {
  padding: 10px 16px 10px 38px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 0.95rem;
  width: 220px;
  transition: all var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 18px;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.filter-select {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 0.95rem;
  cursor: pointer;
}

/* ===== 报表卡片网格 ===== */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  padding-bottom: 40px;
}

.report-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.report-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.report-card .card-category {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  margin-bottom: 10px;
}

.report-card h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.report-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  flex: 1;
}

.report-card .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.report-card .card-footer i {
  margin-right: 4px;
}

/* ===== 图表仪表盘 ===== */
.chart-dashboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 20px 0 40px;
}

.chart-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  min-height: 280px;
  display: flex;
  flex-direction: column;
}

.chart-box h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-canvas-wrapper {
  flex: 1;
  position: relative;
}

.chart-canvas-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
  max-height: 260px;
}

/* ===== 设置页 ===== */
.settings-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 32px;
  max-width: 560px;
  margin-top: 24px;
}

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

.setting-item:last-of-type {
  border-bottom: none;
}

.setting-item label {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-item select {
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
}

#saveSettings {
  margin-top: 24px;
}

/* ===== Toast 消息 ===== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  animation: slideInRight 0.3s ease;
  max-width: 360px;
}

.toast.success {
  border-left: 4px solid #22c55e;
}

.toast.error {
  border-left: 4px solid #ef4444;
}

.toast.info {
  border-left: 4px solid var(--primary);
}

@keyframes slideInRight {
  0% { opacity: 0; transform: translateX(40px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* ===== 底部 ===== */
.footer {
  text-align: center;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.separator {
  margin: 0 12px;
  opacity: 0.4;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 16px;
    gap: 4px;
    box-shadow: var(--shadow-md);
  }

  .nav-links.open {
    display: flex;
  }

  .hamburger {
    display: flex;
  }

  .nav-actions .btn-outline,
  .nav-actions .btn-primary {
    display: none;
  }

  .hero-section h1 {
    font-size: 1.6rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .chart-dashboard {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .search-input {
    width: 100%;
  }

  .filter-select {
    flex: 1;
  }

  .settings-card {
    padding: 20px;
  }

  .setting-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .report-grid {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 0 16px;
  }

  .hero-section {
    padding: 24px 0;
  }
}