/* =========================================================================
   蒸馏平台 · 设计系统
   三层 token：primitive（原始色阶）→ semantic（语义角色）→ component（局部）
   规则：组件只允许使用 semantic 层变量，永不直接写死 hex。
   ========================================================================= */

:root {
  /* ---------- primitive：中性色阶（深色为主，亮度递增即层级升高） ---------- */
  --gray-950: #07080b;
  --gray-925: #0a0c10;
  --gray-900: #0e1015;
  --gray-875: #12151b;
  --gray-850: #161a21;
  --gray-825: #1b1f28;
  --gray-800: #22262f;
  --gray-750: #2b303b;
  --gray-700: #363c49;
  --gray-600: #4a5162;
  --gray-500: #67707f;
  --gray-400: #8d97a7;
  --gray-300: #b6c0cf;
  --gray-200: #d5dce6;
  --gray-100: #eaeef5;
  --gray-50: #f6f9fd;

  /* ---------- primitive：品牌与语义色 ---------- */
  --brand-300: oklch(82% 0.09 268);
  --brand-400: oklch(72% 0.14 268);
  --brand-500: oklch(64% 0.17 268);
  --brand-600: oklch(56% 0.19 268);
  --brand-700: oklch(47% 0.17 268);
  --violet-500: oklch(62% 0.19 300);
  --violet-600: oklch(54% 0.20 300);

  --emerald-400: oklch(76% 0.15 158);
  --emerald-500: oklch(68% 0.16 158);
  --amber-400: oklch(82% 0.14 82);
  --amber-500: oklch(75% 0.15 72);
  --rose-400: oklch(72% 0.17 18);
  --rose-500: oklch(63% 0.20 18);

  /* ---------- semantic：组件唯一可用的名字 ---------- */
  --bg: var(--gray-950);
  --bg-subtle: var(--gray-925);
  --surface: var(--gray-900);
  --surface-raised: var(--gray-875);
  --surface-overlay: var(--gray-850);
  --surface-sunken: #06070a;

  --fg: var(--gray-100);
  --fg-muted: var(--gray-400);
  --fg-subtle: var(--gray-500);
  --fg-on-accent: #ffffff;

  --border: var(--gray-800);
  --border-subtle: var(--gray-850);
  --border-strong: var(--gray-750);
  --ring: var(--brand-500);

  --accent: var(--brand-500);
  --accent-hover: var(--brand-400);
  --accent-fg: var(--fg-on-accent);
  --accent-soft: color-mix(in oklab, var(--brand-500) 16%, transparent);
  --accent-soft-border: color-mix(in oklab, var(--brand-500) 38%, transparent);

  --success: var(--emerald-500);
  --success-soft: color-mix(in oklab, var(--emerald-500) 15%, transparent);
  --warning: var(--amber-500);
  --warning-soft: color-mix(in oklab, var(--amber-500) 15%, transparent);
  --danger: var(--rose-500);
  --danger-soft: color-mix(in oklab, var(--rose-500) 15%, transparent);

  /* ---------- spacing：4px 基准、8px 节奏 ---------- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;

  /* ---------- 字号：1.125 比例（密集控制台） ---------- */
  --fs-xs: 11.5px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: 30px;

  /* ---------- 圆角 / 阴影 / 动效 ---------- */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-full: 999px;

  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.5);
  --shadow-2: 0 4px 16px -4px rgb(0 0 0 / 0.55), 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-3: 0 24px 60px -12px rgb(0 0 0 / 0.7), 0 2px 6px rgb(0 0 0 / 0.4);
  --shadow-accent: 0 6px 20px -6px color-mix(in oklab, var(--brand-500) 55%, transparent);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 320ms;

  --z-sticky: 100;
  --z-modal: 900;
  --z-toast: 1000;

  --nav-w: 232px;
}

/* =========================================================================
   基础
   ========================================================================= */
*,
*::before,
*::after { box-sizing: border-box; }

html { color-scheme: dark; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background-image:
    radial-gradient(900px 480px at 12% -8%, color-mix(in oklab, var(--brand-600) 22%, transparent), transparent 70%),
    radial-gradient(760px 420px at 96% 0%, color-mix(in oklab, var(--violet-600) 14%, transparent), transparent 68%);
  background-attachment: fixed;
}

a { color: var(--brand-400); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

code, pre, .mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

button, input, select, textarea { font-family: inherit; font-size: var(--fs-base); }

::selection { background: color-mix(in oklab, var(--brand-500) 40%, transparent); }

/* 滚动条：细、低对比 */
* { scrollbar-width: thin; scrollbar-color: var(--gray-750) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--gray-800);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--gray-700); background-clip: content-box; }

/* 键盘焦点：统一可见环，鼠标点击不出现 */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* =========================================================================
   图标（lucide sprite）
   ========================================================================= */
.ico,
svg.ico {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -2px;
}
.ico-lg { width: 20px; height: 20px; }
.ico-sm { width: 14px; height: 14px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* =========================================================================
   按钮
   ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 36px;
  padding: 0 var(--s-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--fg);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
@media (hover: hover) {
  .btn:hover { background: var(--gray-800); border-color: var(--gray-700); }
}
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.primary {
  background: linear-gradient(160deg, var(--brand-500), var(--brand-700) 60%, var(--violet-600));
  border-color: color-mix(in oklab, var(--brand-400) 45%, transparent);
  color: var(--accent-fg);
  font-weight: 600;
  box-shadow: var(--shadow-accent), inset 0 1px 0 rgb(255 255 255 / 0.16);
}
@media (hover: hover) {
  .btn.primary:hover {
    background: linear-gradient(160deg, var(--brand-400), var(--brand-600) 60%, var(--violet-500));
    border-color: color-mix(in oklab, var(--brand-300) 55%, transparent);
  }
}
.btn.primary:active { box-shadow: inset 0 2px 6px rgb(0 0 0 / 0.35); }

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--fg-muted);
}
@media (hover: hover) {
  .btn.ghost:hover { background: var(--surface-overlay); color: var(--fg); border-color: var(--border); }
}

.btn.danger {
  background: color-mix(in oklab, var(--rose-500) 12%, transparent);
  border-color: color-mix(in oklab, var(--rose-500) 40%, transparent);
  color: var(--rose-400);
}
@media (hover: hover) {
  .btn.danger:hover {
    background: color-mix(in oklab, var(--rose-500) 22%, transparent);
    border-color: var(--rose-400);
  }
}

.btn.sm {
  min-height: 28px;
  padding: 0 var(--s-2);
  font-size: var(--fs-sm);
  border-radius: var(--r-xs);
  gap: 6px;
}
.btn.icon { padding: 0; width: 30px; min-height: 30px; }
.btn.wide { width: 100%; }

/* =========================================================================
   表单控件
   ========================================================================= */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px var(--s-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  color: var(--fg);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
input::placeholder, textarea::placeholder { color: var(--fg-subtle); }
@media (hover: hover) {
  input[type="text"]:hover, input[type="password"]:hover, input[type="number"]:hover,
  input[type="url"]:hover, input[type="search"]:hover, select:hover, textarea:hover {
    border-color: var(--border-strong);
  }
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand-500) 22%, transparent);
  background: var(--bg-subtle);
}
input[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--rose-500) 18%, transparent);
}
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--brand-500);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-muted) 50%),
    linear-gradient(135deg, var(--fg-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--s-8);
}

textarea { resize: vertical; min-height: 96px; line-height: 1.65; font-size: var(--fs-sm); }

label.field { display: block; margin-bottom: var(--s-4); }
label.field > span {
  display: block;
  margin-bottom: 7px;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
}
label.field > span em { color: var(--fg-subtle); font-style: normal; font-weight: 400; }
label.check { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; font-size: var(--fs-sm); color: var(--fg-muted); }

.hint { color: var(--fg-subtle); font-size: var(--fs-xs); margin-top: 6px; line-height: 1.6; }
.hint code { color: var(--brand-300); background: var(--accent-soft); padding: 1px 5px; border-radius: var(--r-xs); }

.row { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: flex-start; }
.row > * { flex: 1 1 220px; min-width: 0; }
.row > .fixed { flex: 0 0 auto; }

/* =========================================================================
   登录页
   ========================================================================= */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--s-6);
  position: relative;
  overflow: hidden;
}
#login-view::before {
  content: "";
  position: absolute;
  inset: -30% -10% auto -10%;
  height: 70vh;
  background:
    radial-gradient(46% 60% at 30% 40%, color-mix(in oklab, var(--brand-600) 34%, transparent), transparent 70%),
    radial-gradient(40% 55% at 72% 20%, color-mix(in oklab, var(--violet-600) 26%, transparent), transparent 72%);
  filter: blur(12px);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 404px;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s-8) var(--s-6) var(--s-6);
  box-shadow: var(--shadow-3), inset 0 1px 0 rgb(255 255 255 / 0.05);
  animation: cardIn var(--dur-slow) var(--ease-out);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(0.99); } }

.login-card h1 {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--fs-xl);
  line-height: 1.25;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.login-card h1 .mark {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, var(--brand-500), var(--violet-600));
  box-shadow: var(--shadow-accent), inset 0 1px 0 rgb(255 255 255 / 0.22);
  color: #fff;
}
.login-card .sub {
  color: var(--fg-subtle);
  font-size: var(--fs-sm);
  margin: 0 0 var(--s-6);
  padding-left: 46px;
}
.login-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: var(--s-5);
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  padding: 3px;
  border-radius: var(--r-md);
}
.login-tabs button {
  flex: 1;
  min-height: 32px;
  padding: 0 var(--s-2);
  border: 0;
  background: transparent;
  color: var(--fg-subtle);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
@media (hover: hover) { .login-tabs button:hover { color: var(--fg); background: var(--surface-raised); } }
.login-tabs button.on {
  background: var(--surface-raised);
  color: var(--fg);
  font-weight: 600;
  box-shadow: var(--shadow-1), inset 0 1px 0 rgb(255 255 255 / 0.06);
}
#form-login .btn, #form-register .btn { margin-top: var(--s-2); min-height: 40px; }

/* =========================================================================
   应用骨架
   ========================================================================= */
#app-view { display: none; min-height: 100dvh; grid-template-columns: var(--nav-w) minmax(0, 1fr); }
#app-view.on { display: grid; }

aside.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-4) var(--s-3) var(--s-3);
  border-right: 1px solid var(--border-subtle);
  background: color-mix(in oklab, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px) saturate(130%);
  overflow-y: auto;
  z-index: var(--z-sticky);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-1) var(--s-2) var(--s-5);
}
.brand .logo {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: linear-gradient(150deg, var(--brand-500), var(--violet-600));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: var(--shadow-accent), inset 0 1px 0 rgb(255 255 255 / 0.22);
}
.brand b { font-size: var(--fs-md); letter-spacing: 0.01em; }

.nav-group {
  color: var(--fg-subtle);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--s-4) var(--s-3) var(--s-1);
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: 36px;
  padding: 0 var(--s-3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-muted);
  text-align: left;
  cursor: pointer;
  font-size: var(--fs-base);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav-item .ico { color: currentColor; opacity: 0.85; }
@media (hover: hover) {
  .nav-item:hover { background: var(--surface-raised); color: var(--fg); }
  .nav-item:hover .ico { opacity: 1; }
}
.nav-item.on {
  background: linear-gradient(90deg, var(--accent-soft), transparent 90%);
  color: var(--fg);
  font-weight: 600;
}
.nav-item.on .ico { color: var(--brand-400); opacity: 1; }
.nav-item.on::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, var(--brand-400), var(--violet-500));
}

.sidebar-foot {
  margin-top: auto;
  padding: var(--s-3) var(--s-2) 0;
  border-top: 1px solid var(--border-subtle);
}
.sidebar-foot .who {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  margin-bottom: var(--s-2);
  min-width: 0;
}
.sidebar-foot .who #who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  color: var(--brand-300);
}

main.content {
  min-width: 0;
  padding: var(--s-6) var(--s-8) 72px;
  max-width: 1320px;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
}
.page-head h2 {
  margin: 0;
  font-size: var(--fs-2xl);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 650;
}
.page-head .desc { color: var(--fg-muted); font-size: var(--fs-sm); margin-top: 6px; max-width: 68ch; }

/* =========================================================================
   卡片
   ========================================================================= */
.card {
  background: linear-gradient(180deg, color-mix(in oklab, var(--surface-raised) 96%, transparent), var(--surface));
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-bottom: var(--s-4);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
@media (hover: hover) {
  .card:hover { border-color: var(--border); box-shadow: var(--shadow-2); }
}
.card h3 {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: 0 0 var(--s-4);
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: -0.01em;
}
.card h3 .n { color: var(--fg-subtle); font-weight: 400; font-size: var(--fs-sm); }

/* =========================================================================
   表格
   ========================================================================= */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
th, td {
  text-align: left;
  padding: 10px var(--s-3);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
th {
  color: var(--fg-subtle);
  font-weight: 600;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
tbody tr { transition: background var(--dur-fast) var(--ease-out); }
@media (hover: hover) { tbody tr:hover { background: color-mix(in oklab, var(--brand-500) 6%, transparent); } }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .mono, td.mono { font-size: var(--fs-sm); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  color: var(--fg-subtle);
  text-align: center;
  padding: var(--s-10) var(--s-4);
  font-size: var(--fs-sm);
}
.empty .ico { width: 26px; height: 26px; opacity: 0.35; stroke-width: 1.5; }

/* =========================================================================
   状态标记
   ========================================================================= */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 1px solid transparent;
  line-height: 1.7;
  white-space: nowrap;
}
.pill.ok { background: var(--success-soft); color: var(--emerald-400); border-color: color-mix(in oklab, var(--emerald-500) 34%, transparent); }
.pill.run { background: var(--accent-soft); color: var(--brand-300); border-color: var(--accent-soft-border); }
.pill.warn { background: var(--warning-soft); color: var(--amber-400); border-color: color-mix(in oklab, var(--amber-500) 34%, transparent); }
.pill.err { background: var(--danger-soft); color: var(--rose-400); border-color: color-mix(in oklab, var(--rose-500) 34%, transparent); }
.pill.mute { background: var(--surface-overlay); color: var(--fg-muted); border-color: var(--border); }

/* 颜色不是唯一信号：状态点 + 文字标签同时存在 */
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.spin {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--r-xs);
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
   进度条
   ========================================================================= */
.bar {
  position: relative;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand-600), var(--brand-400) 60%, var(--violet-500));
  transition: width var(--dur-slow) var(--ease-out);
  position: relative;
}
.bar > i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgb(255 255 255 / 0.28) 50%, transparent 80%);
  background-size: 220% 100%;
  animation: shimmer 2.2s linear infinite;
}
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -80% 0; } }
.bar.ok > i { background: linear-gradient(90deg, var(--emerald-500), var(--emerald-400)); }
.bar.err > i { background: linear-gradient(90deg, var(--rose-500), var(--rose-400)); }

/* =========================================================================
   统计卡
   ========================================================================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.stat {
  position: relative;
  overflow: hidden;
  background: linear-gradient(165deg, var(--surface-raised), var(--surface));
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
  box-shadow: var(--shadow-1);
  transition: transform var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}
.stat::after {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--brand-400) 55%, transparent), transparent);
  opacity: 0.7;
}
@media (hover: hover) {
  .stat:hover { transform: translateY(-2px); border-color: var(--border); box-shadow: var(--shadow-2); }
}
.stat .k {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-subtle);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: var(--s-2);
}
.stat .k .ico { width: 13px; height: 13px; opacity: 0.7; }
.stat .v {
  font-size: var(--fs-3xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, var(--gray-50), var(--gray-300));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat .v small {
  -webkit-text-fill-color: var(--fg-subtle);
  color: var(--fg-subtle);
  font-size: var(--fs-sm);
  font-weight: 400;
  letter-spacing: 0;
  margin-left: 4px;
}

/* =========================================================================
   Toast
   ========================================================================= */
#toasts {
  position: fixed;
  right: var(--s-5);
  top: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  z-index: var(--z-toast);
  max-width: 380px;
  pointer-events: none;
}
.toast {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  padding: 11px var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-400);
  background: color-mix(in oklab, var(--surface-overlay) 92%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-3);
  font-size: var(--fs-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  pointer-events: auto;
  animation: toastIn var(--dur) var(--ease-out);
}
.toast .ico { margin-top: 2px; }
.toast.ok { border-left-color: var(--emerald-500); }
.toast.err { border-left-color: var(--rose-500); }
.toast.warn { border-left-color: var(--amber-500); }
@keyframes toastIn { from { opacity: 0; transform: translateX(14px) scale(0.98); } }

/* =========================================================================
   弹窗
   ========================================================================= */
#modal-mask {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 64px var(--s-4);
  overflow-y: auto;
  background: rgb(4 5 8 / 0.66);
  backdrop-filter: blur(6px);
  z-index: var(--z-modal);
}
#modal-mask.on { display: flex; animation: fadeIn var(--dur) var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; } }

.modal {
  width: 100%;
  max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: modalIn var(--dur) var(--ease-out);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-8px) scale(0.985); } }
.modal .mh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border-subtle);
}
.modal .mh h3 { margin: 0; font-size: var(--fs-md); font-weight: 650; }
.modal .mb { padding: var(--s-5); }
.modal .mf {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border-subtle);
  background: color-mix(in oklab, var(--surface-sunken) 60%, transparent);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.modal.wide { max-width: 880px; }

/* =========================================================================
   代码块 / 键值 / 分栏
   ========================================================================= */
pre.code {
  margin: 0;
  padding: var(--s-3) var(--s-4);
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  overflow: auto;
  max-height: 320px;
  font-size: var(--fs-sm);
  line-height: 1.7;
  color: var(--gray-300);
  white-space: pre-wrap;
  word-break: break-word;
}

.kv { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px var(--s-4); font-size: var(--fs-sm); }
.kv dt { color: var(--fg-subtle); }
.kv dd { margin: 0; word-break: break-word; color: var(--fg); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }

/* =========================================================================
   响应式：移动优先地退化（表格横向滚动、侧栏变顶栏）
   ========================================================================= */
@media (max-width: 1024px) {
  main.content { padding: var(--s-5) var(--s-5) 64px; }
}

@media (max-width: 900px) {
  #app-view.on { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  aside.sidebar {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: var(--s-1);
    padding: var(--s-2) var(--s-3);
    border-right: 0;
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    overflow-y: hidden;
  }
  .brand, .nav-group, .sidebar-foot { display: none; }
  .nav-item { width: auto; flex: 0 0 auto; min-height: 34px; font-size: var(--fs-sm); }
  .nav-item.on::before { display: none; }
  main.content { padding: var(--s-4) var(--s-4) 56px; }
  .split { grid-template-columns: 1fr; }
  .page-head h2 { font-size: var(--fs-xl); }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .stat .v { font-size: var(--fs-2xl); }
  #modal-mask { padding: var(--s-4) var(--s-2); }
  table { font-size: var(--fs-sm); }
  th, td { padding: 9px var(--s-2); }
}

/* 表格在窄屏允许横向滚动而不是挤压变形 */
@media (max-width: 700px) {
  .card > table, .card > .table-wrap { display: block; overflow-x: auto; white-space: nowrap; }
}

/* =========================================================================
   无障碍：尊重减少动效
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .bar > i::after { display: none; }
}

/* =========================================================================
   v2 视觉升级：在既有 token 之上叠加层次、光泽与动效
   ========================================================================= */

/* ---------- 全局氛围：极淡网格，避免大留白死板 ---------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(to right, color-mix(in oklab, var(--gray-700) 16%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in oklab, var(--gray-700) 16%, transparent) 1px, transparent 1px);
  background-size: 56px 56px, 56px 56px;
  -webkit-mask-image: radial-gradient(115% 85% at 50% -15%, #000 0%, transparent 70%);
  mask-image: radial-gradient(115% 85% at 50% -15%, #000 0%, transparent 70%);
  opacity: 0.45;
}
#login-view, #app-view { position: relative; z-index: 1; }

/* ---------- 页面头：渐变标题 + 发光竖条 ---------- */
.page-head h2 {
  position: relative;
  padding-left: var(--s-4);
  padding-block: 2px;
  background: linear-gradient(118deg, var(--gray-50), var(--gray-300) 58%, var(--brand-300));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.page-head h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.24em;
  bottom: 0.24em;
  width: 3px;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, var(--brand-400), var(--violet-500));
  box-shadow: 0 0 12px color-mix(in oklab, var(--brand-500) 65%, transparent);
}
.page-head .desc { padding-left: var(--s-4); }

/* ---------- 内容入场：顶层块依次浮入 ---------- */
#page > * { animation: pageUp var(--dur-slow) var(--ease-out) both; }
#page > *:nth-child(2) { animation-delay: 40ms; }
#page > *:nth-child(3) { animation-delay: 80ms; }
#page > *:nth-child(4) { animation-delay: 120ms; }
#page > *:nth-child(n + 5) { animation-delay: 150ms; }
@keyframes pageUp { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 卡片：顶部一线光 + 轻微抬升 ---------- */
.card {
  position: relative;
  transition:
    border-color var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    transform var(--dur) var(--ease-out);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--brand-400) 45%, transparent), transparent);
  opacity: 0.55;
  transition: opacity var(--dur) var(--ease-out);
}
@media (hover: hover) {
  .card:hover { transform: translateY(-1px); }
  .card:hover::before { opacity: 1; }
}

/* ---------- 统计卡：图标按位着色 + 右上光斑 ---------- */
.stat .k .ico { opacity: 0.9; }
.stat:nth-child(1) .k .ico { color: var(--brand-400); }
.stat:nth-child(2) .k .ico { color: var(--emerald-400); }
.stat:nth-child(3) .k .ico { color: var(--amber-400); }
.stat:nth-child(4) .k .ico { color: var(--violet-500); }
.stat::before {
  content: "";
  position: absolute;
  right: -34px;
  top: -46px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, color-mix(in oklab, var(--brand-500) 26%, transparent), transparent 70%);
  opacity: 0.5;
}

/* ---------- 按钮：hover 抬升 + 主按钮扫光 ---------- */
.btn.primary { position: relative; overflow: hidden; }
.btn.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 32%, rgb(255 255 255 / 0.22) 48%, transparent 64%);
  transform: translateX(-120%);
  transition: transform 520ms var(--ease-out);
}
@media (hover: hover) {
  .btn:hover:not(:active) { transform: translateY(-1px); }
  .btn.primary:hover::after { transform: translateX(120%); }
  .btn.primary:hover {
    box-shadow:
      0 10px 26px -8px color-mix(in oklab, var(--brand-500) 78%, transparent),
      inset 0 1px 0 rgb(255 255 255 / 0.2);
  }
}

/* ---------- 侧栏 ---------- */
.brand { border-bottom: 1px solid var(--border-subtle); margin-bottom: var(--s-1); }
.brand .logo svg { width: 17px; height: 17px; stroke-width: 2.1; }
.nav-item {
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.nav-item .ico { transition: transform var(--dur) var(--ease-out), color var(--dur) var(--ease-out); }
.nav-item.on { box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--brand-500) 18%, transparent); }
@media (hover: hover) {
  .nav-item:hover:not(.on) { transform: translateX(1px); }
  .nav-item:hover .ico { transform: scale(1.07); }
}

/* ---------- 表格：表头渐变 + 斑马纹 ---------- */
thead th { background: linear-gradient(180deg, var(--surface-raised), var(--surface)); }
tbody tr:nth-child(even) td { background: color-mix(in oklab, var(--gray-900) 50%, transparent); }

/* ---------- 空态：虚线框 ---------- */
.empty {
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
  background: color-mix(in oklab, var(--surface-sunken) 55%, transparent);
}
.empty .ico { color: var(--brand-300); opacity: 0.5; }

/* ---------- 进度条：内阴影 + 发光 ---------- */
.bar { height: 9px; box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.5); }
.bar > i { box-shadow: 0 0 14px -2px color-mix(in oklab, var(--brand-400) 70%, transparent); }

/* ---------- Toast：纯 CSS mask 图标，无需 JS ---------- */
.toast {
  --tone: var(--brand-400);
  --t-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E");
  border-left-color: var(--tone);
}
.toast::before {
  content: "";
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  background: var(--tone);
  -webkit-mask: var(--t-ico) center / contain no-repeat;
  mask: var(--t-ico) center / contain no-repeat;
}
.toast.ok {
  --tone: var(--emerald-500);
  --t-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.801 10A10 10 0 1 1 17 3.335'/%3E%3Cpath d='m9 11 3 3L22 4'/%3E%3C/svg%3E");
}
.toast.err {
  --tone: var(--rose-500);
  --t-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m15 9-6 6'/%3E%3Cpath d='m9 9 6 6'/%3E%3C/svg%3E");
}
.toast.warn {
  --tone: var(--amber-500);
  --t-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
}

/* ---------- 弹窗 ---------- */
.modal { position: relative; overflow: hidden; }
.modal::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--brand-400) 58%, transparent), transparent);
}
.modal .mh { background: linear-gradient(180deg, color-mix(in oklab, var(--brand-600) 12%, transparent), transparent); }

/* ---------- 登录卡：渐变描边 ---------- */
.login-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  padding: 1px;
  background: linear-gradient(150deg,
    color-mix(in oklab, var(--brand-400) 62%, transparent),
    transparent 42%,
    color-mix(in oklab, var(--violet-500) 52%, transparent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.75;
}
.login-tabs button.on { background: linear-gradient(180deg, var(--surface-overlay), var(--surface-raised)); }

/* ---------- 骨架屏 ---------- */
.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-overlay) 25%, var(--gray-825) 37%, var(--surface-overlay) 63%);
  background-size: 400% 100%;
  animation: sk 1.4s ease-in-out infinite;
}
@keyframes sk { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- 响应式补充 ---------- */
@media (max-width: 900px) {
  .page-head h2 { padding-left: var(--s-3); }
  .page-head .desc { padding-left: var(--s-3); }
  /* 移动端保留品牌标识 */
  .brand { display: flex; padding: 0 var(--s-1); border: 0; margin: 0; }
  .brand b { display: none; }
  .brand .logo { width: 26px; height: 26px; }
}

/* ---------- 空态：统一图标（CSS mask，无需 JS） ---------- */
.empty::before {
  content: "";
  width: 30px;
  height: 30px;
  background: currentColor;
  color: var(--brand-300);
  opacity: 0.45;
  -webkit-mask: var(--e-ico) center / contain no-repeat;
  mask: var(--e-ico) center / contain no-repeat;
  --e-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 12h-6l-2 3h-4l-2-3H2'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E");
}

/* ---------- 使用流程：圆角序号 ---------- */
.flow {
  counter-reset: flow;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.flow li {
  counter-increment: flow;
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  line-height: 1.65;
}
.flow li::before {
  content: counter(flow);
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--brand-300);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
}
