/* ========== CSS 变量（亮色 / 暗色主题） ========== */
:root {
  --bg-body: #f0f4f8;
  --bg-card: #ffffff;
  --bg-hover: #f8fafc;
  --bg-upload: #fafbfc;
  --bg-upload-hover: #f0f9ff;
  --bg-progress: #e2e8f0;
  --bg-file-selected: #f8fafc;
  --bg-current-ver: linear-gradient(135deg, #f0f9ff, #eff6ff);
  --bg-upgrade-notes: #fffbeb;
  --bg-modal: #ffffff;
  --bg-nav: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  --bg-nav-right: rgba(255,255,255,0.08);
  --bg-nav-right-hover: rgba(255,255,255,0.15);
  --bg-theme-btn: rgba(255,255,255,0.12);
  --bg-theme-btn-hover: rgba(255,255,255,0.22);
  --bg-metric:#eef5fd;

  --text-primary: #1e293b;
  --text-nav: #ffffff;
  --text-nav-muted: rgba(255,255,255,0.7);
  --text-notes: #92400e;
  --text-notes-title: #d97706;

  --border-upload: #cbd5e1;
  --border-upload-hover: #38bdf8;
  --border-notes: #fde68a;
  --border-history: #e8edf3;
  --border-history-hover: #93c5fd;
  --border-history-current: #38bdf8;

  --accent-blue-light: #38bdf8;
  --accent-blue-bg: #dbeafe;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-yellow: #f59e0b;

  --shadow-nav: 0 2px 12px rgba(30,58,95,0.25);
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.2);
  --shadow-btn: 0 4px 14px rgba(37,99,235,0.35);

  --gradient-progress: linear-gradient(90deg, #38bdf8, #2563eb);
  --gradient-btn: linear-gradient(135deg, #2563eb, #1d4ed8);
  --gradient-btn-hover: linear-gradient(135deg, #1d4ed8, #1e40af);
  --gradient-card-bar: linear-gradient(180deg, #38bdf8, #2563eb);
  --bg-dark: #0d1117;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --text-secondary: #9ca3af;
  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.5);
  --accent-purple: #8b5cf6;
  --status-ok: #22c55e;
  --status-ok-bg: #f0fdf4;
  --status-err: #ef4444;
  --status-err-bg: #fef2f2;
  --status-warn: #f59e0b;
  --status-warn-bg: #fffbeb;
  --status-info: #3b82f6;
  --status-info-bg: #eff6ff;
  --border-color: #e5e7eb;
  --shadow-card: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-card-hover: 0 8px 30px rgba(0,0,0,0.10);
}

/* 暗色主题 */
[data-theme="dark"] {
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #273449;
  --bg-upload: #172033;
  --bg-upload-hover: #1a2f4e;
  --bg-progress: #334155;
  --bg-file-selected: #172033;
  --bg-current-ver: linear-gradient(135deg, #1a2f4e, #1e3a5f);
  --bg-upgrade-notes: #2d2410;
  --bg-modal: #1e293b;
  --bg-nav: linear-gradient(135deg, #0f1e36 0%, #1a3a6e 100%);
  --bg-nav-right: rgba(255,255,255,0.06);
  --bg-nav-right-hover: rgba(255,255,255,0.12);
  --bg-theme-btn: rgba(255,255,255,0.08);
  --bg-theme-btn-hover: rgba(255,255,255,0.18);
  --bg-metric:#1e293b;

  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-nav: #ffffff;
  --text-nav-muted: rgba(255,255,255,0.6);
  --text-notes: #fbbf24;
  --text-notes-title: #f59e0b;

  --border-color: #334155;
  --border-upload: #475569;
  --border-upload-hover: #38bdf8;
  --border-notes: #92400e;
  --border-history: #334155;
  --border-history-hover: #3b82f6;
  --border-history-current: #38bdf8;

  --accent-blue: #3b82f6;
  --accent-blue-light: #38bdf8;
  --accent-blue-bg: #1e3a5f;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-yellow: #f59e0b;

  --shadow-card: 0 1px 4px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
  --shadow-nav: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.5);
  --shadow-btn: 0 4px 14px rgba(59,130,246,0.35);

  --gradient-progress: linear-gradient(90deg, #38bdf8, #3b82f6);
  --gradient-btn: linear-gradient(135deg, #3b82f6, #2563eb);
  --gradient-btn-hover: linear-gradient(135deg, #2563eb, #1d4ed8);
  --gradient-card-bar: linear-gradient(180deg, #38bdf8, #3b82f6);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}
 /* 主题切换按钮 */
 .theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-theme-btn);
  color: var(--text-nav);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.25s ease;
  margin-right: 4px;
}
.theme-toggle:hover {
  background: var(--bg-theme-btn-hover);
  transform: rotate(20deg) scale(1.05);
}
.theme-toggle:active { transform: rotate(60deg) scale(0.95); }
  /* ========== 顶部导航栏 ========== */
  .nav-bar {
    background: var(--bg-dark);
    height: 6vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.4);
    position: relative;
    z-index: 100;
  }

  .nav-left {
    display: flex;
    align-items: center;
    gap: 28px;
  }

  .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 1.5px;
  }

  .logo-icon {
    width: 30px;
    height: 30px;
    background: conic-gradient(from 180deg, var(--accent-blue), var(--accent-purple), var(--accent-blue));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 0 12px var(--accent-blue-glow);
    animation: logoSpin 8s linear infinite;
  }

  @keyframes logoSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
  }

  .nav-links { display: flex; gap: 4px; }
  .nav-link {
    color: #9ca3af;
    text-decoration: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.25s ease;
    position: relative;
  }
  .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
  }
  .nav-link.active {
    color: #fff;
    background: rgba(59,130,246,0.15);
  }
  .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 20%;
    width: 60%;
    height: 2px;
    background: var(--accent-blue);
    border-radius: 2px;
  }
  
  .nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #9ca3af;
    font-size: 13px;
  }
  .nav-right span {
    cursor: pointer;
    transition: color 0.2s;
    user-select: none;
  }
  .nav-right span:hover { color: #fff; }
  .nav-divider {
    width: 1px;
    height: 16px;
    background: #374151;
    cursor: default !important;
  }
  .logout { color: #f87171 !important; }
  .logout:hover { color: #ef4444 !important; }

  /* ========== Loading 遮罩 ========== */
  .loading-overlay {
    position: fixed;
    top: 55px; left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(238, 241, 246, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 18px;
    opacity: 0;
    visibility: hidden;
    transition: opacity .35s ease, visibility .35s ease;
  }
  .loading-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  /* 旋转 Spinner */
  .loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #d8e2f0;
    border-top-color: #2563eb;
    border-right-color: #3b82f6;
    border-radius: 50%;
    animation: spin .8s linear infinite;
  }
  @keyframes spin {
    to { transform: rotate(360deg); }
  }

  /* Loading 文字 */
  .loading-text {
    font-size: 14px;
    color: #5a6c7d;
    font-weight: 500;
    letter-spacing: 0.5px;
  }
  .loading-text .dot {
    display: inline-block;
    animation: dotBounce 1.4s infinite;
  }
  .loading-text .dot:nth-child(2) { animation-delay: .2s; }
  .loading-text .dot:nth-child(3) { animation-delay: .4s; }
  @keyframes dotBounce {
    0%, 80%, 100% { opacity: .3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
  }
  /* ========== Toast ========== */
  .toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .toast {
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    animation: slideIn .3s ease;
    max-width: 360px;
  }
  .toast.success { background: linear-gradient(135deg, #10b981, #34d399); }
  .toast.error   { background: linear-gradient(135deg, #ef4444, #f87171); }
  .toast.info    { background: linear-gradient(135deg, #4f6df5, #6aa9ff); }
  .toast.warning { background: linear-gradient(135deg, #f59e0b, #fbbf24); }

  @keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
  }
  .card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 22px 24px;
    box-shadow: 0 10px 30px rgba(31,42,68,.08);
    border: 1px solid rgba(255,255,255,.6);
    transition: transform .25s ease, box-shadow .25s ease;
  }
  .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px rgba(31,42,68,.12);
  }
  .card-title {
    display: flex;
    align-items: center;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
  }
  .card-title::before {
    content: "";
    width: 4px;
    height: 18px;
    border-radius: 4px;
    background: #4f6df5;
    margin-right: 10px;
  }
  .card-title .tag {
    margin-left: auto;
    font-size: 12px;
    font-weight: 500;
    color: #4f6df5;
    background: #eaf0ff;
    padding: 3px 10px;
    border-radius: 999px;
  }