/* ============================================================
   工具库 · 设计系统 v3 「晨光工作台」(自托管,零外部依赖)
   命名保持与 app.js / 各模板兼容:task-table / status-pill / s-*
   / tool-tag / error-msg / toast / modal-mask / tcard 等
   ============================================================ */

:root {
  color-scheme: dark;
  /* 品牌与语义色 */
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-active: #4f46e5;
  --primary-subtle: rgba(99, 102, 241, 0.18);
  --primary-ring: rgba(99, 102, 241, 0.28);
  --grad-brand: linear-gradient(135deg, #818cf8 0%, #6366f1 55%, #4f46e5 100%);
  --grad-text: linear-gradient(100deg, #a5b4fc 10%, #38bdf8 90%);

  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.16);
  --success-border: rgba(16, 185, 129, 0.32);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.16);
  --warning-border: rgba(245, 158, 11, 0.32);
  --danger: #f43f5e;
  --danger-subtle: rgba(244, 63, 94, 0.16);
  --danger-border: rgba(244, 63, 94, 0.32);
  --info: #38bdf8;
  --info-subtle: rgba(56, 189, 248, 0.16);
  --info-border: rgba(56, 189, 248, 0.32);

  /* 中性色 (深空墨色底) */
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --text-3: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --bg: #080c14;
  --bg-2: #0d1422;
  --surface: rgba(15, 22, 38, 0.8);

  /* 形状与阴影 */
  --radius-sm: 9px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 12px 36px -8px rgba(0, 0, 0, 0.65);
  --shadow-lg: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 20px 48px -12px rgba(0, 0, 0, 0.75);
  --shadow-primary: 0 4px 18px rgba(99, 102, 241, 0.4);

  --font: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --ease: cubic-bezier(.16, 1, .3, 1);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  background-color: var(--bg);
  color: var(--text);
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  position: relative;
}

/* 弥散多焦点极光环境光晕 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1200px 650px at 15% -8%, rgba(99, 102, 241, 0.18), transparent 62%),
    radial-gradient(1000px 600px at 85% -5%, rgba(56, 189, 248, 0.15), transparent 60%),
    radial-gradient(900px 500px at 50% 50%, rgba(16, 185, 129, 0.08), transparent 70%),
    radial-gradient(850px 550px at 90% 105%, rgba(244, 63, 94, 0.1), transparent 65%);
}

/* 细腻微噪点 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app-header, .main-content, .app-footer {
  position: relative;
  z-index: 1;
}

h1, h2, h3, h4 { line-height: 1.35; margin: 0 0 8px; font-weight: 700; letter-spacing: -.02em; color: #fff; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
a { color: #818cf8; text-decoration: none; transition: color .15s ease; }
a:hover { color: #a5b4fc; text-decoration: none; }
small { font-size: 12px; }
.muted { color: var(--text-3); font-size: 13px; }
.num, .badge, .status-pill { font-variant-numeric: tabular-nums; }

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

/* ---------- 顶部导航 ---------- */
.app-header {
  background: rgba(8, 12, 20, 0.82);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav { display: flex; align-items: center; gap: 28px; height: 58px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 15.5px; color: #fff; letter-spacing: -.01em;
  text-decoration: none; flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center; font-size: 16px;
  background: var(--grad-brand);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), var(--shadow-primary);
}
.nav-links { display: flex; gap: 4px; flex: 1; min-width: 0; }
.nav-links a {
  color: var(--text-2); font-size: 14px; font-weight: 500;
  padding: 6px 13px; border-radius: 999px; white-space: nowrap;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.nav-links a:hover { color: #fff; background: rgba(255, 255, 255, .06); text-decoration: none; }
.nav-links a.active {
  color: #fff; background: var(--primary-subtle); font-weight: 600;
  border: 1px solid rgba(99, 102, 241, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2);
}
.nav-sep { width: 1px; height: 20px; background: var(--border); margin: 0 8px; align-self: center; }
.nav-user { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.uname { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.uname .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--grad-brand); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(99, 102, 241, .4);
}
.uname .avatar-img { object-fit: cover; background: var(--surface); }
.uname em { font-style: normal; }

.main-content { padding: 30px 0 60px; min-height: calc(100vh - 160px); }
.app-footer { padding: 22px 0 38px; color: var(--text-3); text-align: center; font-size: 12px; letter-spacing: .02em; }

/* ---------- Hero / 页头区 ---------- */
.page-hero { padding: 14px 0 8px; }
.page-hero .hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--primary);
  background: var(--primary-subtle);
  border: 1px solid rgba(83, 71, 232, .14);
  border-radius: 999px; padding: 3px 12px; margin-bottom: 14px;
}
.page-hero h1, .page-hero .hero-title {
  font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.25;
  margin: 0 0 8px;
}
.page-hero h1 em, .page-hero .hero-title em {
  font-style: normal;
  background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.page-hero .hero-sub { color: var(--text-2); font-size: 14.5px; max-width: 640px; margin: 0; }

.page-header { margin-bottom: 20px; }
.page-header h2 { margin-bottom: 2px; }
.page-header .muted { margin: 0; }
.page-actions { margin: 14px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- 表单控件 ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 6px; }
label small { font-weight: 400; color: var(--text-3); }
input[type="text"], input[type="password"], input[type="number"], input[type="email"],
input:not([type]), select, textarea {
  width: 100%;
  font: inherit; font-size: 14px; color: var(--text);
  background: rgba(10, 15, 26, 0.85);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  outline: none;
}
input:hover, select:hover, textarea:hover { border-color: rgba(255, 255, 255, 0.28); }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 0 3px var(--primary-ring);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); vertical-align: -2px; margin-right: 4px; }
input[type="file"] {
  width: 100%; font-size: 13px; color: var(--text-2);
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 12px 14px; background: rgba(10, 15, 26, 0.6);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
input[type="file"]:hover { border-color: var(--primary); background: var(--primary-subtle); }
input[type="file"]::file-selector-button {
  font: inherit; font-size: 13px; font-weight: 500;
  color: var(--text); background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-strong); border-radius: 7px;
  padding: 4px 11px; margin-right: 10px; cursor: pointer;
}
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b90a7' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  padding-right: 34px;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.65; }
.form-row { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }
.input-group { display: flex; gap: 8px; }
.input-group > :first-child { flex: 1; }
.field-hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }

/* ---------- 按钮 ---------- */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  color: #fff; background: var(--grad-brand);
  border: 1px solid rgba(255, 255, 255, 0.25); border-radius: var(--radius-sm);
  padding: 8px 17px; cursor: pointer; white-space: nowrap;
  transition: box-shadow .15s var(--ease), transform .12s var(--ease), filter .15s var(--ease), background .15s var(--ease);
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, .35);
}
button:hover, .btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 24px rgba(99, 102, 241, .45), inset 0 1px 0 rgba(255,255,255,.45); }
button:active, .btn:active { transform: translateY(1px); filter: brightness(.96); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3); }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-ring); }
button:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; filter: none; }
button.secondary, .btn-secondary, button.outline {
  color: var(--text); background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-strong);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
button.secondary:hover, .btn-secondary:hover, button.outline:hover {
  background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.28); filter: none; transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 14px rgba(0, 0, 0, 0.4);
}
button.secondary:active, .btn-secondary:active { background: rgba(255, 255, 255, 0.08); transform: translateY(0); }
button.danger, .btn-danger { background: linear-gradient(135deg, #f43f5e, #e11d48); box-shadow: 0 4px 14px rgba(244, 63, 94, .35), inset 0 1px 0 rgba(255,255,255,.3); }
button.danger:hover, .btn-danger:hover { filter: brightness(1.08); }
button.ghost, .btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; box-shadow: none; }
button.ghost:hover, .btn-ghost:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); filter: none; transform: none; box-shadow: none; }
.btn-sm { padding: 4px 12px; font-size: 13px; border-radius: 8px; font-weight: 550; }

/* ---------- 面板 / 卡片 ---------- */
.panel {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 24px 26px;
  margin-bottom: 18px;
  position: relative;
}
.panel::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 1px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: linear-gradient(90deg, transparent, rgba(124, 108, 255, .45), rgba(14, 165, 233, .4), transparent);
  opacity: .85;
}
.panel > h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: #fff; }
.panel > h3 + .muted { margin-bottom: 16px; }
.panel-plain {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* ---------- 首页工具卡片 ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 18px;
  margin-top: 20px;
}
.tcard {
  position: relative;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 40%, rgba(255, 255, 255, 0.01) 100%),
    var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex; flex-direction: column; gap: 11px;
  text-decoration: none; color: inherit;
  transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s var(--ease);
  overflow: hidden;
}
.tcard::after {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, #7c6cff, #0ea5e9);
  opacity: 0;
  transition: opacity .2s var(--ease);
}
.tcard:hover {
  box-shadow: 0 12px 32px rgba(83, 71, 232, .14), var(--shadow);
  transform: translateY(-3px);
  border-color: rgba(124, 108, 255, .4);
  text-decoration: none;
}
.tcard:hover::after { opacity: 1; }
.tcard .ic {
  width: 50px; height: 50px; border-radius: 14px;
  display: grid; place-items: center; font-size: 24px;
  background: var(--primary-subtle);
  border: 1px solid rgba(83, 71, 232, .12);
  overflow: hidden;
  transition: transform .2s var(--ease);
}
.tcard:hover .ic { transform: scale(1.06) rotate(-2deg); }
.tcard .ic.g0 { background: linear-gradient(135deg, #6366f1, #8b5cf6); border: none; box-shadow: 0 4px 14px rgba(99, 102, 241, .35), inset 0 1px 0 rgba(255,255,255,.25); }
.tcard .ic.g1 { background: linear-gradient(135deg, #06b6d4, #3b82f6); border: none; box-shadow: 0 4px 14px rgba(6, 182, 212, .35), inset 0 1px 0 rgba(255,255,255,.25); }
.tcard .ic.g2 { background: linear-gradient(135deg, #f59e0b, #f97316); border: none; box-shadow: 0 4px 14px rgba(245, 158, 11, .35), inset 0 1px 0 rgba(255,255,255,.25); }
.tcard .ic.g3 { background: linear-gradient(135deg, #10b981, #14b8a6); border: none; box-shadow: 0 4px 14px rgba(16, 185, 129, .35), inset 0 1px 0 rgba(255,255,255,.25); }
.tcard .ic.g4 { background: linear-gradient(135deg, #f43f5e, #ec4899); border: none; box-shadow: 0 4px 14px rgba(244, 63, 94, .35), inset 0 1px 0 rgba(255,255,255,.25); }
.tcard .ic-img {
  width: 30px; height: 30px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .15));
}
.tcard .nm { font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; }
.tcard .ds { color: var(--text-2); font-size: 13px; line-height: 1.6; min-height: 42px; }
.tcard .badge {
  align-self: flex-start;
  font-size: 12px; font-weight: 550;
  background: var(--primary-subtle); color: var(--primary);
  border: 1px solid rgba(83, 71, 232, .14);
  border-radius: 999px; padding: 3px 11px;
}
.tcard .go {
  position: absolute; top: 20px; right: 18px;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-3); font-size: 15px;
  background: var(--bg);
  transition: transform .2s var(--ease), color .2s var(--ease), background .2s var(--ease);
}
.tcard:hover .go { transform: translateX(3px); color: #fff; background: var(--grad-brand); box-shadow: var(--shadow-primary); }
.tcard.disabled { opacity: .6; filter: saturate(.3); }
.tcard.disabled:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--border); }
.tcard.disabled:hover::after { opacity: 0; }
.tcard.disabled:hover .go { transform: none; color: var(--text-3); background: var(--bg); box-shadow: none; }
.tcard.disabled .badge { background: var(--bg-2); color: var(--text-3); border-color: var(--border); }

/* ---------- 表格 ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.task-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.task-table th {
  text-align: left; font-size: 12px; font-weight: 650;
  color: var(--text-2); letter-spacing: .03em;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 11px 15px; white-space: nowrap;
}
.task-table td {
  border-bottom: 1px solid var(--bg-2);
  padding: 12px 15px; vertical-align: middle;
}
.task-table tbody tr:last-child td { border-bottom: none; }
.task-table tbody tr { transition: background .12s var(--ease); }
.task-table tbody tr:hover td { background: #fafbff; }
.task-table td input, .task-table td select { padding: 5px 9px; font-size: 13px; }

/* 表格不在 .table-wrap 内时的兜底(JS 直接注入容器) */
div > .task-table { background: var(--surface); }
#tasks-container .task-table, #recent .task-table, #tools-container .task-table,
#users-container .task-table, #usage-container .task-table {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
/* 圆角容器内的表格首尾行修正 */
#tasks-container, #recent, #tools-container, #users-container, #usage-container { overflow-x: auto; }

/* ---------- 状态徽标 ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  border: 1px solid transparent;
}
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-queued { background: var(--warning-subtle); color: var(--warning); border-color: var(--warning-border); }
.s-running { background: var(--info-subtle); color: var(--info); border-color: var(--info-border); }
.s-running::before { animation: pulse 1.2s ease-in-out infinite; }
.s-succeeded { background: var(--success-subtle); color: var(--success); border-color: var(--success-border); }
.s-failed { background: var(--danger-subtle); color: var(--danger); border-color: var(--danger-border); }
@keyframes pulse { 50% { opacity: .35; } }

.tool-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-2);
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 7px; padding: 2px 9px; white-space: nowrap;
}
.error-msg {
  color: var(--danger); background: var(--danger-subtle);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm); padding: 9px 13px; font-size: 13px;
}
.download-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 500; margin-right: 10px;
  color: var(--primary);
}
button.link-btn, .link-btn {
  appearance: none; -webkit-appearance: none;
  display: inline-flex; align-items: center; justify-content: flex-start;
  width: auto; min-width: 0; height: auto; min-height: 0;
  margin: 0 10px 0 0; padding: 0;
  border: 0; border-radius: 0; box-shadow: none;
  background: transparent; color: var(--text-2);
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1.6;
  cursor: pointer; white-space: nowrap; vertical-align: baseline;
  transition: color .12s, text-decoration-color .12s;
}
button.link-btn:hover, .link-btn:hover {
  background: transparent; color: var(--danger); text-decoration: underline;
  transform: none; filter: none; box-shadow: none;
}
button.link-btn:active, .link-btn:active {
  background: transparent; transform: none;
}
button.link-btn:focus-visible, .link-btn:focus-visible {
  outline: none; box-shadow: 0 0 0 4px var(--primary-ring);
  border-radius: 4px;
}
button.link-btn:disabled, .link-btn:disabled {
  opacity: .5; cursor: default; text-decoration: none;
}

/* ---------- 工具页头 ---------- */
.tool-header { display: flex; align-items: center; gap: 15px; margin-bottom: 22px; }
.tool-header .ic {
  width: 54px; height: 54px; border-radius: 15px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 26px;
  background: var(--grad-brand);
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.tool-header h2 { margin: 0; }

/* ---------- Tabs ---------- */
.tabs {
  display: inline-flex; gap: 3px; padding: 3px;
  background: var(--bg-2); border-radius: 10px; margin-bottom: 10px;
}
.tab-btn {
  font-size: 13px; font-weight: 550; color: var(--text-2);
  background: transparent; border: none; box-shadow: none;
  border-radius: 8px; padding: 5px 15px; cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.tab-btn:hover { background: rgba(255, 255, 255, .65); color: var(--text); transform: none; box-shadow: none; }
.tab-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 650; }

/* ---------- 认证页(登录/改密/解锁) ---------- */
.auth-wrap {
  display: flex; flex-direction: column; align-items: center;
  padding-top: 8vh;
  position: relative;
}
.auth-wrap::before {
  content: "";
  position: absolute; top: -40px; left: 50%; transform: translateX(-50%);
  width: 560px; height: 320px;
  background: radial-gradient(closest-side, rgba(124, 108, 255, .16), transparent);
  pointer-events: none;
}
.auth-card {
  position: relative;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(231, 233, 242, .9);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 36px 32px;
  width: 410px; max-width: calc(100vw - 40px);
}
.auth-card::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 3px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: linear-gradient(90deg, #7c6cff, #0ea5e9);
}
.auth-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 8px; }
.auth-brand .logo {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center; font-size: 23px;
  background: var(--grad-brand);
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, .28);
}
.auth-card h2 { margin: 0; font-size: 20px; }
.auth-card .muted { margin-bottom: 22px; }
.auth-card form button[type="submit"] { width: 100%; margin-top: 8px; padding: 10px 16px; font-size: 14.5px; }
.auth-card .form-row { margin-bottom: 15px; }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(19, 21, 39, .48);
  backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-mask.show { display: flex; animation: fadeIn .14s ease-out; }
.modal {
  background: var(--surface); border-radius: var(--radius-xl);
  padding: 26px 28px; max-width: 480px; width: 100%;
  box-shadow: var(--shadow-lg);
  animation: slideUp .18s var(--ease);
}
.modal h3 { margin-bottom: 6px; }
.modal .form-row { margin-bottom: 12px; }
.modal-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } }

.pw-box {
  font-family: var(--mono); font-size: 19px; letter-spacing: 1.5px;
  background: var(--bg); border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm); padding: 15px; text-align: center;
  user-select: all;
}
.kbd {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 6px; padding: 1px 7px;
}

/* ---------- 设置页状态与 Key 控件 ---------- */
.key-status {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600;
  border-radius: 999px; padding: 3px 12px;
  border: 1px solid transparent;
}
.key-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.key-status.on { background: var(--success-subtle); color: var(--success); border-color: var(--success-border); }
.key-status.off { background: var(--bg-2); color: var(--text-3); border-color: var(--border); }
.key-chip {
  font-family: var(--mono); font-size: 12px; color: var(--text-2);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 7px; padding: 3px 9px;
}
.pw-toggle {
  flex-shrink: 0;
  width: 40px;
  padding: 0 !important;
  font-size: 15px !important;
}

/* ---------- 筛选栏 ---------- */
.filter-bar {
  display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 16px 18px; margin-bottom: 16px;
}
.filter-bar label { margin-bottom: 4px; font-size: 12px; color: var(--text-2); }
.filter-bar input, .filter-bar select { width: auto; min-width: 120px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%) translateY(-6px);
  background: var(--text); color: #fff;
  padding: 10px 19px; border-radius: 10px; z-index: 200;
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .2s var(--ease), transform .2s var(--ease); pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: linear-gradient(135deg, #f04438, #d92d20); }
.toast.ok { background: linear-gradient(135deg, #12b76a, #0e9f5c); }

/* ---------- 空态 ---------- */
.empty-hint { color: var(--text-3); text-align: center; padding: 36px 0; font-size: 13px; }

/* ---------- 限额展开行 ---------- */
.limits-row td { background: var(--bg) !important; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .nav { gap: 12px; height: auto; padding: 10px 0; flex-wrap: wrap; }
  .nav-links { order: 3; width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .form-grid { grid-template-columns: 1fr; }
  .main-content { padding-top: 18px; }
  .panel { padding: 18px 16px; }
  .page-hero h1, .page-hero .hero-title { font-size: 24px; }
}

/* SSO 统一登录入口 */
.sso-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: var(--text-2, #8a8fa3); font-size: 13px; }
.sso-divider::before, .sso-divider::after { content: ""; flex: 1; height: 1px; background: var(--border, #2a2e3a); }
.sso-btn { display: block; text-align: center; padding: 11px 12px; background: linear-gradient(135deg, #16a34a, #15803d); box-shadow: 0 4px 14px rgba(22,163,74,.3), inset 0 1px 0 rgba(255,255,255,.2); }
.sso-btn:hover { filter: brightness(1.06); }

/* ---------- 公共错误中心（app.js 切面 UI） ---------- */
#tb-errcenter { position: fixed; right: 18px; bottom: 18px; z-index: 9999; font-size: 13px; }
.tb-err-badge {
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 44px; height: 44px; padding: 0 12px; border: none; border-radius: 999px;
  background: linear-gradient(135deg, #f04438, #d92d20); color: #fff; font-size: 16px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(217, 45, 32, .35), inset 0 1px 0 rgba(255, 255, 255, .2);
  cursor: pointer;
}
.tb-err-badge:hover { filter: brightness(1.07); }
.tb-err-badge.pulse { animation: tb-err-pulse 1.6s ease-out 3; }
@keyframes tb-err-pulse {
  0% { box-shadow: 0 0 0 0 rgba(240, 68, 56, .5); }
  70% { box-shadow: 0 0 0 14px rgba(240, 68, 56, 0); }
  100% { box-shadow: 0 0 0 0 rgba(240, 68, 56, 0); }
}
.tb-err-panel {
  position: absolute; right: 0; bottom: 56px; width: min(560px, calc(100vw - 36px));
  max-height: min(70vh, 560px); display: none; flex-direction: column; overflow: hidden;
  background: #fff; border: 1px solid var(--border-strong, #d3d7e6); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(19, 21, 39, .22);
}
.tb-err-panel.open { display: flex; }
.tb-err-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border, #e7e9f2);
  background: linear-gradient(180deg, #fff, #fdf5f5); font-size: 14px;
}
.tb-err-actions { display: flex; gap: 6px; }
.tb-err-actions button {
  border: 1px solid var(--border-strong, #d3d7e6); background: #fff; color: var(--text-2, #4b5069);
  border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.tb-err-actions button:hover { background: var(--bg, #f6f7fb); }
.tb-err-actions .tb-btn-danger { color: var(--danger, #dc2626); border-color: var(--danger-border, #fecaca); }
.tb-err-actions .tb-btn-danger:hover { background: var(--danger-subtle, #fef2f2); }
.tb-err-actions .tb-btn-plain { border: none; font-size: 16px; line-height: 1; padding: 4px 8px; }
.tb-err-hint { padding: 6px 14px; color: var(--text-3, #8b90a7); font-size: 12px; background: var(--bg, #f6f7fb); }
#tb-err-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.tb-err-empty { padding: 22px; text-align: center; color: var(--text-3, #8b90a7); }
.tb-err-item { border-bottom: 1px solid var(--border, #e7e9f2); padding: 10px 14px; }
.tb-err-item:last-child { border-bottom: none; }
.tb-err-row { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.tb-err-time { color: var(--text-3, #8b90a7); font-size: 12px; flex: none; }
.tb-err-kind {
  flex: none; font-size: 11px; padding: 1px 7px; border-radius: 999px; font-weight: 600;
  background: var(--danger-subtle, #fef2f2); color: var(--danger, #dc2626); border: 1px solid var(--danger-border, #fecaca);
}
.tb-err-kind.k-js { background: var(--warning-subtle, #fffbeb); color: var(--warning, #b45309); border-color: var(--warning-border, #fde68a); }
.tb-err-kind.k-promise { background: var(--info-subtle, #f0f9ff); color: var(--info, #0284c7); border-color: var(--info-border, #bae6fd); }
.tb-err-kind.k-console { background: var(--bg, #f6f7fb); color: var(--text-2, #4b5069); border-color: var(--border, #e7e9f2); }
.tb-err-msg { flex: 1 1 200px; color: var(--text, #131527); word-break: break-all; }
.tb-err-rowbtns button {
  flex: none; border: 1px solid var(--primary, #5347e8); background: var(--primary-subtle, #eef0fe);
  color: var(--primary, #5347e8); border-radius: 8px; padding: 3px 10px; font-size: 12px; cursor: pointer; font-weight: 500;
}
.tb-err-rowbtns button:hover { background: var(--primary, #5347e8); color: #fff; }
.tb-err-detail {
  display: none; margin: 8px 0 0; padding: 8px 10px; border-radius: 8px;
  background: #101322; color: #d8ddff; font-size: 11.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow-y: auto;
}
.tb-err-item.expanded .tb-err-detail { display: block; }
