/* ============================================================
   LLM-API-Eval 设计系统 V1（2026-11-27）
   浅色苹果风 · SaaS 蓝 · 依据 DESIGN-SPEC.md v1.0
   与原深色版保持同一套变量名/类名，页面无需改结构即可换肤
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  color-scheme: light;

  /* 色板 */
  --bg: #f5f5f7;
  --bg-deep: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f9f9fb;
  --surface-3: #e8e8ed;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);

  --text-1: #1d1d1f;
  --text-2: #515154;
  --text-3: #6e6e73;

  --primary: #0071e3;
  --primary-2: #7d7aff;
  --primary-hover: #0060c9;
  --primary-grad: linear-gradient(135deg, #0a84ff, #42a5f5);
  --primary-soft: rgba(0, 113, 227, 0.09);
  --primary-ring: rgba(0, 113, 227, 0.16);

  --success: #248a3d;
  --success-soft: rgba(52, 199, 89, 0.13);
  --warning: #b45309;
  --warning-soft: rgba(255, 159, 10, 0.14);
  --danger: #d70015;
  --danger-soft: rgba(255, 59, 48, 0.09);
  --info: #0066cc;
  --info-soft: rgba(10, 132, 255, 0.1);

  /* 动效（Emil Kowalski 规则：进入 ease-out、≤300ms、按压即时反馈） */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  /* 字号（基准 16px，页面可通过 html{font-size} 整体缩放） */
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.625rem;
  --fs-3xl: 2.125rem;

  /* 圆角与阴影 */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px -4px rgba(16, 24, 40, 0.07);
  --shadow-2: 0 4px 8px rgba(16, 24, 40, 0.06), 0 20px 44px -12px rgba(16, 24, 40, 0.18);
  --shadow-primary: 0 6px 16px -6px rgba(0, 113, 227, 0.45);

  /* 布局 */
  --sidebar-w: 236px;
  --topbar-h: 60px;
  --sidebar-bg: rgba(255, 255, 255, 0.82);
  --topbar-bg: rgba(245, 245, 247, 0.8);

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* ---------- 暗色模式（html[data-theme="dark"]，苹果暗色规范） ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-deep: #1c1c1e;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.22);
  --text: #f5f5f7;
  --text-1: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #86868b;
  --primary: #0a84ff;
  --primary-hover: #409cff;
  --primary-soft: rgba(10, 132, 255, 0.18);
  --primary-ring: rgba(10, 132, 255, 0.35);
  --success: #30d158;
  --success-text: #30d158;
  --success-soft: rgba(48, 209, 88, 0.16);
  --warning: #ff9f0a;
  --warning-text: #ffb340;
  --warning-soft: rgba(255, 159, 10, 0.16);
  --danger: #ff453a;
  --danger-text: #ff6961;
  --danger-soft: rgba(255, 69, 58, 0.16);
  --info: #64d2ff;
  --info-text: #64d2ff;
  --info-soft: rgba(100, 210, 255, 0.14);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 12px 40px rgba(0, 0, 0, 0.55);
  --shadow-primary: 0 6px 20px rgba(10, 132, 255, 0.4);
  --sidebar-bg: rgba(28, 28, 30, 0.72);
  --topbar-bg: rgba(0, 0, 0, 0.55);
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); border-color: #000000; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.32); }
:root[data-theme="dark"] .sidebar-version { background: rgba(255, 255, 255, 0.08); }
:root[data-theme="dark"] .login-card { background: rgba(28, 28, 30, 0.88); }
:root[data-theme="dark"] .loading-overlay { background: rgba(0, 0, 0, 0.6); }
:root[data-theme="dark"] .toast { background: #2c2c2e; border: 1px solid var(--border); }
:root[data-theme="dark"] input[type="date"] { color-scheme: dark; }
:root[data-theme="dark"] .nav-link:hover { background: rgba(255, 255, 255, 0.06); }
:root[data-theme="dark"] .btn-ghost { background: rgba(255, 255, 255, 0.08); }
:root[data-theme="dark"] .btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.13); }
:root[data-theme="dark"] .table tbody tr:hover { background: rgba(255, 255, 255, 0.04); }
:root[data-theme="dark"] .switch .track { background: #3a3a3c; }
:root[data-theme="dark"] .modal-close { background: rgba(255, 255, 255, 0.08); }
:root[data-theme="dark"] .modal-close:hover { background: rgba(255, 255, 255, 0.14); }
:root[data-theme="dark"] .pagination .pg-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.07); }
:root[data-theme="dark"] .issue.warn { color: #ffb340; }
:root[data-theme="dark"] table.diff td.official { color: #409cff; }
:root[data-theme="dark"] table.diff td.local { color: #ffb340; }

/* 主题切换按钮（顶栏右上） */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s var(--ease-out), color 0.15s var(--ease-out), transform 0.12s var(--ease-out);
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle:active { transform: scale(0.92); }
.theme-toggle svg { width: 18px; height: 18px; }

/* ---------- Reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  font-size: var(--fs-md);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

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

::selection { background: rgba(0, 113, 227, 0.18); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.18); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.28); }

/* 键盘焦点可见（无障碍） */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- 应用骨架 ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-primary);
  flex-shrink: 0;
}
.sidebar-logo .logo-mark svg { width: 20px; height: 20px; }

.sidebar-logo .logo-name {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-1);
  line-height: 1.2;
}
.sidebar-logo .logo-sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.2;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.nav-group-title {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: var(--fs-md);
  cursor: pointer;
  transition: background-color 0.16s var(--ease-out), color 0.16s var(--ease-out);
  text-decoration: none;
}
.nav-link:hover { background: rgba(0, 0, 0, 0.04); color: var(--text-1); text-decoration: none; }
.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  position: relative;
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 3px;
  background: var(--primary);
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link .nav-badge {
  margin-left: auto;
  font-size: var(--fs-xs);
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
}

.sidebar-user {
  border-top: 1px solid var(--border);
  padding: 12px;
}

.sidebar-version {
  align-self: flex-start;
  margin: 2px 0 14px 16px;
  padding: 3px 10px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 999px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* 通用头像（侧边栏迷你用户条等） */
.avatar {
  border-radius: 50%;
  background: var(--primary-grad);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

/* 主区域 */
.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-title { font-size: var(--fs-lg); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { color: var(--text-3); font-size: var(--fs-sm); margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.main {
  padding: 26px 28px 60px;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
}

/* 移动端遮罩 */
.sidebar-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-out);
}
.sidebar-mask.show { opacity: 1; pointer-events: auto; }

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    width: min(280px, 84vw);
    transform: translateX(-105%);
    transition: transform 0.32s var(--ease-drawer);
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-2); }
  .main { padding: 20px 16px 50px; }
  .topbar { padding: 0 16px; }
  .menu-toggle { display: inline-flex !important; }
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
}
.menu-toggle:active { transform: scale(0.94); }

/* ---------- 用户菜单 ---------- */
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.16s var(--ease-out);
  position: relative;
}
.user-chip:hover { border-color: var(--border-strong); }

.user-chip .avatar {
  width: 30px;
  height: 30px;
  font-size: var(--fs-sm);
}

.user-chip .user-name { font-size: var(--fs-sm); color: var(--text-1); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .role-tag {
  font-size: var(--fs-xs);
  padding: 0 7px;
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--info);
  line-height: 1.7;
}
.user-chip .role-tag.admin { background: var(--warning-soft); color: var(--warning); }

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  padding: 6px;
  display: none;
  z-index: 100;
}
.dropdown.open { display: block; animation: dropIn 0.18s var(--ease-out); }
@keyframes dropIn { from { opacity: 0; transform: scale(0.97) translateY(-3px); } to { opacity: 1; transform: none; } }
.dropdown .dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-size: var(--fs-sm);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}
.dropdown .dd-item:hover { background: var(--surface-2); }
.dropdown .dd-item.danger { color: var(--danger); }
.dropdown .dd-divider { height: 1px; background: var(--border); margin: 6px 4px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-1);
}

.card + .card { margin-top: 18px; }

.card-title {
  font-size: var(--fs-lg);
  font-weight: 650;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}

.card-desc { color: var(--text-3); font-size: var(--fs-sm); margin-bottom: 16px; line-height: 1.65; max-width: 68ch; }
.card-head-row { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; row-gap: 10px; }
.card-head-row .head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* 统计卡片 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}
.stat-card .stat-label { font-size: var(--fs-xs); color: var(--text-3); letter-spacing: 0.5px; display: flex; align-items: center; gap: 6px; }
.stat-card .stat-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.stat-card .stat-unit { font-size: var(--fs-sm); color: var(--text-3); font-weight: 400; margin-left: 3px; }
.stat-card .stat-foot { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.stat-card.good .stat-value { color: var(--success); }
.stat-card.bad .stat-value { color: var(--danger); }
.stat-card.warn .stat-value { color: var(--warning); }
.stat-card.accent .stat-value { color: var(--primary); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: var(--fs-md);
  font-weight: 550;
  font-family: var(--font);
  cursor: pointer;
  transition: background-color 0.16s var(--ease-out), border-color 0.16s var(--ease-out), transform 0.12s var(--ease-out), box-shadow 0.16s var(--ease-out);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-ghost {
  background: rgba(0, 0, 0, 0.04);
  border-color: transparent;
  color: var(--text-1);
}
.btn-ghost:hover:not(:disabled) { background: rgba(0, 0, 0, 0.07); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(255, 59, 48, 0.25);
}
.btn-danger:hover:not(:disabled) { background: rgba(255, 59, 48, 0.16); }

.btn-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(52, 199, 89, 0.3);
}
.btn-success:hover:not(:disabled) { background: rgba(52, 199, 89, 0.22); }

.btn-sm { padding: 5px 12px; font-size: var(--fs-sm); }
.btn-lg { padding: 12px 26px; font-size: var(--fs-lg); }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* ---------- 表单 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px 16px;
}
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid .span-2 { grid-column: span 1; } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label {
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }
.field .req::after { content: '*'; color: var(--danger); margin-left: 2px; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 13px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-size: var(--fs-md);
  font-family: var(--font);
  transition: border-color 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out);
}
.textarea { resize: vertical; min-height: 88px; font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: #aeaeb2; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.55; cursor: not-allowed; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.input-mono { font-family: var(--mono); font-size: var(--fs-sm); }

/* 开关（iOS 式） */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 44px;
  height: 26px;
  background: #e9e9ee;
  border: none;
  border-radius: 999px;
  position: relative;
  transition: background-color 0.2s var(--ease-out);
  flex-shrink: 0;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s var(--ease-out);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* 复选/单选组 */
.check-row { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: var(--fs-sm); color: var(--text-1); }
.check-row input { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }

/* 分段选择（iOS 分段控件式） */
.seg {
  display: inline-flex;
  background: var(--surface-3);
  border: none;
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
  flex-wrap: wrap;
}
.seg .seg-item {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: var(--font);
  transition: background-color 0.16s var(--ease-out), color 0.16s var(--ease-out);
}
.seg .seg-item:hover { color: var(--text-1); }
.seg .seg-item.active { background: var(--surface); color: var(--text-1); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14); }

/* ---------- 标签/徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 550;
  line-height: 1.8;
  white-space: nowrap;
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--surface-3); color: var(--text-2); }
.badge.accent { background: var(--primary-soft); color: var(--primary); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.success { background: #34c759; }
.dot.danger { background: #ff3b30; }
.dot.warning { background: #ff9f0a; }
.dot.muted { background: var(--text-3); }
.dot.pulse { animation: dotPulse 1.6s ease infinite; }
@keyframes dotPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); -webkit-overflow-scrolling: touch; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  min-width: 640px;
}
.table th {
  text-align: left;
  padding: 11px 14px;
  color: var(--text-3);
  font-weight: 550;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color 0.12s var(--ease-out); }
.table tbody tr:hover { background: rgba(0, 0, 0, 0.025); }
.table .num { text-align: right; }
.table th.num { text-align: right; }

/* ---------- 进度条 ---------- */
.progress {
  height: 8px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.progress .bar {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.4s ease;
  min-width: 0;
}
.progress.thin { height: 5px; }

/* ---------- Toast（底部深色胶囊） ---------- */
.toast-container {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 24px);
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 240px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(29, 29, 31, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: none;
  box-shadow: var(--shadow-2);
  font-size: var(--fs-sm);
  color: #fff;
  animation: toastIn 0.25s var(--ease-out);
}
.toast.out { animation: toastOut 0.25s var(--ease-out) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(0.97); } }
.toast .t-icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.toast.success .t-icon { color: #30d158; }
.toast.error .t-icon { color: #ff6961; }
.toast.warning .t-icon { color: #ffd60a; }
.toast.info .t-icon { color: #64d2ff; }

/* ---------- Modal ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-mask.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2);
  animation: modalIn 0.2s var(--ease-out);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
.modal.modal-lg { max-width: 780px; }

.modal-head {
  display: flex;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head .m-title { font-size: var(--fs-lg); font-weight: 650; }
.modal-close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-3);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: rgba(0, 0, 0, 0.09); color: var(--text-1); }
.modal-close:active { transform: scale(0.92); }

.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 22px;
  border-top: 1px solid var(--border);
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 16px;
  color: var(--text-2);
  font-size: var(--fs-md);
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.16s var(--ease-out);
}
.tab:hover { color: var(--text-1); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 空状态 / 加载 ---------- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-3);
}
.empty-state svg { width: 44px; height: 44px; opacity: 0.4; margin-bottom: 12px; }
.empty-state .e-title { color: var(--text-2); font-size: var(--fs-md); margin-bottom: 4px; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}

/* ---------- 分页 ---------- */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 16px; justify-content: flex-end; flex-wrap: wrap; }
.pagination .page-info { color: var(--text-3); font-size: var(--fs-sm); margin-right: auto; }
.pagination .pg-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-family: var(--font);
  transition: background-color 0.16s var(--ease-out), color 0.16s var(--ease-out);
}
.pagination .pg-btn:hover:not(:disabled) { background: rgba(0, 0, 0, 0.04); color: var(--text-1); }
.pagination .pg-btn.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.pagination .pg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- 杂项 ---------- */
.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--text-3); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-accent { color: var(--primary); }

.flex { display: flex; }
.flex-1 { flex: 1; min-width: 0; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kbd {
  font-family: var(--mono);
  font-size: 0.85em;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
}

.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* 提示条 */
.note {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  background: var(--info-soft);
  border: 1px solid rgba(10, 132, 255, 0.22);
  color: var(--text-2);
}
.note.warning { background: var(--warning-soft); border-color: rgba(255, 159, 10, 0.3); }
.note.danger { background: var(--danger-soft); border-color: rgba(255, 59, 48, 0.22); }
.note svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 3px; }

/* ---------- 手机端（≤640px） ---------- */
@media (max-width: 640px) {
  .main { padding: 16px 14px calc(40px + env(safe-area-inset-bottom)); }
  .topbar { height: auto; min-height: 54px; padding: 8px 14px; gap: 10px; }
  .topbar-sub { display: none; }
  .topbar-actions { gap: 6px; }
  .user-chip .user-name { max-width: 64px; }
  .user-chip .role-tag { display: none; }

  .card { padding: 17px 16px; border-radius: 16px; }
  .card + .card { margin-top: 14px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 13px 14px; }
  .stat-card .stat-value { font-size: 1.375rem; }

  /* 输入框 ≥16px：防 iOS 聚焦自动放大 */
  .input, .select, .textarea { font-size: 16px; padding: 11px 13px; }

  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .btn-lg { width: 100%; }

  .table { min-width: 600px; }

  .toast-container { width: calc(100vw - 24px); }
  .toast { min-width: 0; width: 100%; }

  .modal-mask { padding: 12px; }
  .modal { border-radius: 18px; }
  .modal-head { padding: 15px 17px; }
  .modal-body { padding: 16px 17px; }
  .modal-foot { padding: 12px 17px; }

  .pagination { justify-content: center; }
  .pagination .page-info { margin-right: 0; width: 100%; text-align: center; }

  .tabs { margin-bottom: 14px; }
  .tab { padding: 8px 12px; }
}

/* ---------- V1.1 精修（2026-11-27 真机反馈） ---------- */
/* 图标尺寸兜底：layout.js 注入的 SVG 无自带宽高，必须由 CSS 定尺寸，否则渲染成空白 */
.menu-toggle svg { width: 20px; height: 20px; }
.modal-close svg { width: 15px; height: 15px; display: block; }
.dropdown .dd-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast .t-icon svg { width: 18px; height: 18px; display: block; }

/* 顶栏品牌标（手机/平板显示，桌面端侧边栏已有品牌区） */
.topbar-logo {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--primary-grad);
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 4px 10px rgba(10, 132, 255, 0.35);
  flex-shrink: 0;
}
.topbar-logo svg { width: 18px; height: 18px; }
@media (max-width: 1024px) { .topbar-logo { display: inline-flex; } }

/* 导航彩色图标瓷砖（iOS 设置风） */
.nav-link { padding: 8px 10px; }
.nav-link .nav-ic {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  background: #8e8e93;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 2px 6px rgba(0, 0, 0, 0.12);
}
.nav-link .nav-ic svg { width: 17px; height: 17px; }
.nav-link[data-id="dashboard"] .nav-ic { background: linear-gradient(135deg, #0a84ff, #0071e3); }
.nav-link[data-id="parallel"] .nav-ic { background: linear-gradient(135deg, #7d7aff, #5e5ce6); }
.nav-link[data-id="scorecard"] .nav-ic { background: linear-gradient(135deg, #ff6482, #ff375f); }
.nav-link[data-id="benchmark"] .nav-ic { background: linear-gradient(135deg, #ff9f0a, #ff8a00); }
.nav-link[data-id="quality"] .nav-ic { background: linear-gradient(135deg, #34c759, #30b350); }
.nav-link[data-id="schedule"] .nav-ic { background: linear-gradient(135deg, #bf5af2, #af52de); }
.nav-link[data-id="history"] .nav-ic { background: linear-gradient(135deg, #64d2ff, #5ac8fa); }
.nav-link[data-id="admin"] .nav-ic { background: linear-gradient(135deg, #636366, #48484a); }
.nav-link[data-id="admin-users"] .nav-ic { background: linear-gradient(135deg, #0071e3, #42a5f5); }
.nav-link[data-id="admin-activity"] .nav-ic { background: linear-gradient(135deg, #30b0c7, #32ade6); }
.nav-link[data-id="admin-stations"] .nav-ic { background: linear-gradient(135deg, #ff6482, #ff375f); }

/* Logo 瓷砖加一层高光，更苹果 */
.sidebar-logo .logo-mark { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 4px 12px rgba(10, 132, 255, 0.35); }

/* 侧边栏底部用户条卡片化 */
.sidebar-user .flex {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 9px 12px;
  box-shadow: var(--shadow-1);
}

/* 手机端卡片头：标题与操作区上下排，操作区占满整行 */
@media (max-width: 640px) {
  .card-head-row { flex-wrap: wrap; }
  .card-head-row .head-actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .card-head-row .head-actions .select { flex: 1; min-width: 0; }
}

/* ---------- V1.4 细节打磨（2026-11-27 逐页检阅） ---------- */
/* 分组标题统一加品牌蓝点（quality / schedule 页的 .group-title） */
.group-title::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-grad);
  flex-shrink: 0;
}

/* 大数字收紧字距，更苹果 */
.stat-card .stat-value { letter-spacing: -0.02em; }

/* 表格呼吸感 */
.table td { line-height: 1.55; }

/* 登录页网格底纹：暗色下换浅色线 */
:root[data-theme="dark"] .grid-bg {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
}

/* ---------- 减少动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
