/*!
 * SteamForge Panel — 设计系统
 * 深色机房/控制台风：高信息密度、低饱和背景、克制的强调色。
 * 全部自研，无任何外部资源（字体、图标一律用系统字体与内联 SVG）。
 *
 * ============================================================
 * 完整类名清单（实例详情页等后续模块请直接复用，勿另起炉灶）
 * ============================================================
 * 布局
 *   .app-shell .app-body .sidebar .sidebar-brand .brand-mark .brand-text .brand-name .brand-version
 *   .sidebar-nav .nav-section .nav-section-title .nav-group .nav-item .nav-item.active .nav-item-icon
 *   .nav-item-label .nav-item-badge
 *   .topbar .topbar-left .topbar-right .topbar-title .topbar-subtitle .ws-indicator .ws-indicator.on
 *   .topbar-user .user-trigger .user-meta .user-name .user-role .menu-backdrop .dropdown
 *   .dropdown-item .dropdown-item.danger .dropdown-divider .view
 *   .page .page-header .page-heading .page-title .page-subtitle .page-actions .page-content
 * 容器
 *   .card .card-header .card-title .card-actions .card-body .card-body.no-padding .panel
 *   .grid .grid-2 .grid-3 .grid-4 .grid-auto .row .col .spacer .section-title .stat-grid
 * 表格
 *   .table-wrap .table .table-compact .table th .table td .table tr.selected .table .clickable
 *   .th-sort .th-sort.active .sort-mark .col-select .empty-cell .ta-left .ta-right .ta-center
 *   .cell-main .cell-sub .cell-actions
 * 表单
 *   .field .field-label .field-hint .field-error .required .input .textarea .select .checkbox
 *   .checkbox-label .switch .switch-track .switch-thumb .switch-field .switch-label
 *   .form-grid .form-grid-2 .field-grid .field-span .form-row .input-group .input-suffix .password-field
 * 按钮
 *   .btn .btn-primary .btn-secondary .btn-danger .btn-ghost .btn-sm .btn-lg .btn-icon
 *   .btn:disabled .btn.active .btn-block .btn-group
 * 徽章与状态
 *   .badge .badge-default .badge-success .badge-warn .badge-danger .badge-info .badge-muted
 *   .state-badge .tag .dot .dot-success .dot-danger .dot-warn .dot-muted .dot-label
 *   .tone-success .tone-warn .tone-danger .tone-info .text-success .text-warn .text-danger .text-info
 * 反馈
 *   .toast-wrap .toast .toast-success .toast-error .toast-warn .toast-text .toast-close .leaving
 *   .spinner .loading-block .empty-state .empty-icon .empty-title .empty-message .empty-action
 *   .error-state .error-icon .error-message .error-action
 *   .progress .progress-bar .progress-label .progress-info .progress-warn .progress-danger
 * 控制台
 *   .log-viewer .log-toolbar .log-lines .log-line .log-line.err .log-time .log-text .log-count
 *   .log-search .log-wrap .log-line.level-warn .log-line.level-error .log-line.level-info .log-line.level-debug
 * 弹窗
 *   .modal-backdrop[data-width] .modal .modal-header .modal-title .modal-body .modal-footer .confirm-dialog
 *   .confirm-message .modal-sm .modal-md .modal-lg .modal-xl .modal-open
 *   .modal-resize-handle .modal-resizing .modal-resize-active
 * 主题
 *   html[data-theme="light"] .theme-control .theme-segmented
 * 其他
 *   .stat-card .stat-head .stat-label .stat-value .stat-hint .stat-icon
 *   .tabs .tab .tab.active .tab-badge .segmented .segment .segment.active .segment-label
 *   .kv-list .kv-compact .kv-list dt .kv-list dd .mono .muted .small .strong .nowrap .break-all
 *   .file-row .file-row.selected .file-name .file-meta .file-size .tree .tree-item
 *   .code .code-block .diff .diff-add .diff-del .template-card .template-head .template-body
 *   .template-foot .template-tags .wizard .wizard-steps .wizard-step .wizard-step.active
 *   .wizard-step.done .wizard-step-index .wizard-body .wizard-footer .notice .notice-warn
 *   .notice-danger .notice-info .drawer-section .fieldset .fieldset-title .toolbar .toolbar-group
 *   .mono-input .card-grid .user-cell .role-cell .host-meter .auth-avatar .login-page .login-card
 *   .login-brand .login-form .login-error .login-footer .login-version .skeleton
 * ============================================================
 */

/* ---------------------------------------------------------- 变量 */
/*
 * ★★ 主题口径（深色 / 浅色）唯一一份 ★★
 *
 * 切换方式：`html[data-theme="light"]`（见 js/core/theme.js 的 applyTheme）。
 * 用属性而不是给 body 挂 class，是因为：
 *   · 变量本来就定义在 `:root` 上，`html[data-theme]` 与它是同一个作用域；
 *   · `index.html` 的 <head> 里那段**同步**早期脚本能在解析 body 之前就设好它
 *     —— 这是"渲染前应用、不出现先深后闪"的前提；
 *   · `color-scheme` 也随之切换，滚动条 / 原生下拉这类浏览器自绘控件才会跟着亮暗。
 *
 * ★ 深浅两套**变量名完全一一对应**（tests/theme.test.js 会逐个比对名字集合）。
 *   任何"只写在深色里"的颜色都会在浅色主题下变成看不见的浅灰 —— 所以本轮把
 *   散落各处的写死颜色（#86efac / rgba(255,255,255,.022) / #0b0d11 …）全部收敛到
 *   下面这些变量里；确实收不了的只有三类，见本文件末尾的主题小节。
 */
:root {
  --bg-0: #0f1115;
  --bg-1: #151922;
  --bg-2: #1b2029;
  --bg-3: #222836;
  --bg-hover: #1f2532;
  --border: #272d3a;
  --border-strong: #333b4d;

  --text: #e6e9ef;
  --text-dim: #98a2b3;
  --text-faint: #6b7688;

  --primary: #3b82f6;
  --primary-dim: #2563eb;
  --primary-soft: rgba(59, 130, 246, 0.14);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.14);
  --muted-soft: rgba(152, 162, 179, 0.12);
  /* 状态点外发光（深色底上才需要"点亮"效果；浅色主题里降到几乎无） */
  --dot-glow-success: rgba(34, 197, 94, 0.55);
  --dot-glow-danger: rgba(239, 68, 68, 0.55);
  --dot-glow-warn: rgba(245, 158, 11, 0.5);

  /* 语义色的"文字版"：带色底上的文字与纯文字提示（深色下是浅色调，浅色下必须换成深色调） */
  --danger-text: #fca5a5;
  --success-text: #86efac;
  --warn-text: #fcd34d;
  --info-text: #7dd3fc;
  --on-accent: #fff;
  --danger-strong: #dc2626;

  /*
   * 渐变里的色标（品牌标记、进度条）。
   *
   * 为什么这些也要做成变量：它们是**实心色块**，浅色主题下沿用深色那一套会出现
   * "亮蓝条压在亮白底上、边界糊掉"与"深蓝进度条在白底上过重"。
   * 浅色主题里把它们整体压深一档（对比度不变，视觉重量降下来）。
   */
  --brand-grad-a: #3b82f6;
  --brand-grad-b: #1d4ed8;
  --progress-grad-a: #2563eb;
  --progress-grad-b: #3b82f6;
  --progress-warn-a: #b45309;
  --progress-warn-b: #f59e0b;
  --progress-danger-a: #b91c1c;
  --progress-danger-b: #ef4444;

  /* 强调色底上的文字：ghost 按钮激活态、激活的 Tab、套餐价格、向导步骤 */
  --accent-text: #cfe2ff;
  --accent-text-strong: #dbeafe;

  /* 表面与分隔的细节（原先散落在各条规则里的写死值） */
  --surface-tint: rgba(255, 255, 255, 0.015); /* 卡片头部的极淡渐变 */
  --row-hover: rgba(255, 255, 255, 0.022); /* 表格行悬停 */
  --row-line: rgba(39, 45, 58, 0.7); /* 表格行分隔线 */
  --input-hover-border: #3d4759; /* 输入框悬停边框 */
  --placeholder: #5c6675; /* placeholder 文字 */
  --dot-idle: #48505f; /* 灰色状态点 */
  --scrollbar-thumb: #2c3444;
  --scrollbar-thumb-hover: #3a4457;
  --avatar-from: #334155; /* 头像/品牌标记的渐变起点 */
  --avatar-to: #1e293b;
  --overlay: rgba(6, 8, 12, 0.72); /* 弹窗遮罩 */
  --topbar-bg: rgba(21, 25, 34, 0.92); /* 顶栏半透明底（毛玻璃） */
  --login-glow: rgba(59, 130, 246, 0.16); /* 登录页的径向光晕 */
  --success-border: rgba(34, 197, 94, 0.35);
  --success-tint: rgba(34, 197, 94, 0.1); /* 绿色浅底（diff 新增行） */
  --warn-border: rgba(245, 158, 11, 0.35);
  --danger-border: rgba(239, 68, 68, 0.35);
  --danger-tint: rgba(239, 68, 68, 0.1); /* 红色浅底（diff 删除行） */
  --danger-border-soft: rgba(239, 68, 68, 0.3);
  --info-border: rgba(56, 189, 248, 0.35);
  --primary-border: rgba(59, 130, 246, 0.35);

  /*
   * 日志 / 控制台区：**两个主题下都是深底浅字**（刻意保留）。
   * 理由：日志的价值在于"终端里长什么样"，浅底白字会把用户从终端/文档里得来的肌肉记忆打断；
   * 而且 ANSI 风格的红黄绿在深底上对比度最好。浅色主题下它只是"一块深色玻璃"，
   * 边框与页面背景仍然跟着主题走（见浅色主题里的 --log-bg）。
   */
  --log-bg: #0b0d11;
  --log-text: #cbd5e1;
  --log-time: #4b5563;
  --log-debug: #7c8798;

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

  --radius: 7px;
  --radius-sm: 5px;
  --radius-lg: 11px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, 0.45);
  --sidebar-w: 218px;
  --sidebar-w-compact: 60px;
  --topbar-h: 54px;
}

/*
 * 白天（浅色）主题。
 *
 * 设计口径：不是"把深色反相"，而是白天的办公室/窗边环境 ——
 * 底用冷白（#f5f7fa）而不是纯白（纯白在亮环境里刺眼、也没有层次），
 * 卡片比页面**更白**（与深色主题"卡片比底更亮"的方向一致），
 * 描边比深色主题更实（浅底上淡描边会完全看不见）。
 */
:root[data-theme="light"] {
  --bg-0: #f3f5f9;
  --bg-1: #ffffff;
  --bg-2: #f7f9fc;
  --bg-3: #e9edf4;
  --bg-hover: #eef1f7;
  --border: #dbe1ea;
  --border-strong: #c3cbd8;

  --text: #1c2430;
  --text-dim: #55617a;
  --text-faint: #7b869c;

  --primary: #2563eb;
  --primary-dim: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.12);
  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.12);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --info: #0369a1;
  --info-soft: rgba(3, 105, 161, 0.1);
  --muted-soft: rgba(85, 97, 122, 0.1);
  --dot-glow-success: rgba(21, 128, 61, 0.25);
  --dot-glow-danger: rgba(220, 38, 38, 0.25);
  --dot-glow-warn: rgba(180, 83, 9, 0.25);

  --danger-text: #b91c1c;
  --success-text: #15803d;
  --warn-text: #92400e;
  --info-text: #0369a1;
  --on-accent: #ffffff;
  --danger-strong: #b91c1c;

  /* 渐变整体压深一档：亮色底上不要出现"发光的蓝"与"过重的深蓝" */
  --brand-grad-a: #2563eb;
  --brand-grad-b: #1e40af;
  --progress-grad-a: #1d4ed8;
  --progress-grad-b: #3b82f6;
  --progress-warn-a: #a16207;
  --progress-warn-b: #d97706;
  --progress-danger-a: #b91c1c;
  --progress-danger-b: #dc2626;

  --accent-text: #1d4ed8;
  --accent-text-strong: #1e40af;

  --surface-tint: rgba(15, 23, 42, 0.02);
  --row-hover: rgba(15, 23, 42, 0.035);
  --row-line: rgba(219, 225, 234, 0.9);
  --input-hover-border: #9aa6b8;
  --placeholder: #8b95a8;
  --dot-idle: #a8b0bf;
  --scrollbar-thumb: #c3cbd8;
  --scrollbar-thumb-hover: #a8b0bf;
  --avatar-from: #cbd5e1;
  --avatar-to: #94a3b8;
  --overlay: rgba(15, 23, 42, 0.42);
  --topbar-bg: rgba(255, 255, 255, 0.9);
  --login-glow: rgba(37, 99, 235, 0.1);
  --success-border: rgba(21, 128, 61, 0.4);
  --success-tint: rgba(21, 128, 61, 0.1);
  --warn-border: rgba(180, 83, 9, 0.4);
  --danger-border: rgba(220, 38, 38, 0.4);
  --danger-tint: rgba(220, 38, 38, 0.08);
  --danger-border-soft: rgba(220, 38, 38, 0.3);
  --info-border: rgba(3, 105, 161, 0.35);
  --primary-border: rgba(37, 99, 235, 0.4);

  /* 日志区保持深底（理由见上面 --log-bg 的注释），只把底色略微调暖一点点 */
  --log-bg: #10141a;
  --log-text: #cbd5e1;
  --log-time: #64748b;
  --log-debug: #8b98ac;

  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-2: 0 10px 30px rgba(15, 23, 42, 0.16);
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

h1, h2, h3, h4, h5, h6, p, dl, dd, figure {
  margin: 0;
}

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

a:hover {
  text-decoration: underline;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
}

input, select, textarea {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 6px;
  border: 2px solid var(--bg-0);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.icon {
  flex: none;
  display: block;
}

.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

.muted {
  color: var(--text-dim);
}

.small {
  font-size: 12px;
}

.strong {
  font-weight: 600;
}

.nowrap {
  white-space: nowrap;
}

.break-all {
  word-break: break-all;
}

.spacer {
  flex: 1 1 auto;
}

.text-success { color: var(--success); }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }
.text-dim { color: var(--text-dim); }

/* ---------------------------------------------------------- 应用外壳 */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

/* 侧边栏固定在视口上，长页面滚动时导航不跟着跑 */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: linear-gradient(150deg, var(--brand-grad-a), var(--brand-grad-b));
  color: var(--on-accent);
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-weight: 650;
  letter-spacing: 0.3px;
  font-size: 14.5px;
}

.brand-version {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
}

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 8px 20px;
}

.nav-section {
  margin-bottom: 6px;
}

.nav-section-title {
  padding: 10px 10px 4px;
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-size: 13.5px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--accent-text-strong);
}

.nav-item-icon {
  display: grid;
  place-items: center;
  width: 18px;
  flex: none;
}

.nav-item-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item-badge {
  flex: none;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bg-3);
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
  font-family: var(--mono);
}

/* ---------------------------------------------------------- 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 16px;
  background: var(--topbar-bg);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--text-faint);
}

.ws-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--bg-2);
  color: var(--text-dim);
  font-size: 12px;
}

.ws-indicator.on {
  color: var(--success-text);
  border-color: var(--success-border);
  background: var(--success-soft);
}

.topbar-user {
  position: relative;
}

.user-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-2);
  cursor: pointer;
}

.user-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg-3);
}

.auth-avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--avatar-from), var(--avatar-to));
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
}

.user-role {
  font-size: 11px;
  color: var(--text-faint);
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 41;
  min-width: 186px;
  padding: 5px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}

.dropdown-item:hover {
  background: var(--bg-hover);
}

.dropdown-item.danger {
  color: var(--danger-text);
}

.dropdown-divider {
  height: 1px;
  margin: 5px 4px;
  background: var(--border);
}

.view {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: var(--sidebar-w);
  padding: 18px 20px 40px;
}

/* ---------------------------------------------------------- 页面骨架 */
.page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.page-heading {
  min-width: 0;
}

.page-title {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.page-subtitle {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.page-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.4px;
}

/* ---------------------------------------------------------- 卡片与栅格 */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-tint), transparent);
}

.card-title {
  font-size: 13.5px;
  font-weight: 620;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.card-body {
  padding: 14px;
}

.card-body.no-padding {
  padding: 0;
}

.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.stat-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.card-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ---------------------------------------------------------- 统计卡 */
.stat-card {
  position: relative;
  min-width: 0;
  padding: 12px 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 2px;
  background: var(--border-strong);
}

.stat-card[data-tone="success"]::before { background: var(--success); }
.stat-card[data-tone="warn"]::before { background: var(--warn); }
.stat-card[data-tone="danger"]::before { background: var(--danger); }
.stat-card[data-tone="info"]::before { background: var(--info); }
.stat-card[data-tone="primary"]::before { background: var(--primary); }

.stat-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
}

.stat-icon {
  margin-left: auto;
  color: var(--text-faint);
}

.stat-value {
  margin-top: 3px;
  font-size: 22px;
  font-weight: 650;
  font-family: var(--mono);
  letter-spacing: -0.4px;
}

.stat-hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 2px;
}

/* ---------------------------------------------------------- 表格 */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 12px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--row-line);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: var(--row-hover);
}

.table tbody tr.clickable {
  cursor: pointer;
}

.table tr.selected {
  background: var(--primary-soft);
}

.table-compact th,
.table-compact td {
  padding: 6px 9px;
}

.ta-right { text-align: right; }
.ta-center { text-align: center; }

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.th-sort:hover,
.th-sort.active {
  color: var(--text);
}

.sort-mark {
  font-size: 9px;
}

.col-select {
  width: 34px;
  text-align: center;
}

.empty-cell {
  padding: 22px 12px !important;
  text-align: center;
  color: var(--text-faint);
}

.cell-main {
  font-weight: 550;
}

.cell-sub {
  font-size: 11.5px;
  color: var(--text-faint);
}

.cell-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}

/* ---------------------------------------------------------- 表单 */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field-label {
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 550;
}

.required {
  color: var(--danger);
}

.field-hint {
  font-size: 11.5px;
  color: var(--text-faint);
}

.field-error {
  font-size: 11.5px;
  color: var(--danger-text);
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 7px 10px;
  color: var(--text);
  background: var(--bg-0);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--input-hover-border);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--placeholder);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.textarea {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
}

.select {
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.select option {
  background: var(--bg-2);
  color: var(--text);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-label {
  font-size: 13px;
}

.switch {
  position: relative;
  display: inline-flex;
  flex: none;
  width: 38px;
  height: 21px;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 11px;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  transition: background 0.15s ease, border-color 0.15s ease;
  pointer-events: none;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform 0.15s ease, background 0.15s ease;
}

.switch input:checked + .switch-track {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(17px);
  background: var(--primary);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.switch-field {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.switch-label {
  font-size: 13px;
}

/*
 * ---------------------------------------------------------- 字段网格
 *
 * 两套网格，用途不同：
 *   .form-grid   小组 / 通用表单网格：**能放几列放几列**（2 个字段就两列、3 个就三列）；
 *   .field-grid  **长表单**：字段数多、要占满弹窗宽度的那种（配置文件字段、
 *                模板的插件 / 变量 / 端口 / 字段编辑）—— 由 core/field-render.js 的
 *                variableFieldGrid() 与模板页各编辑器共用，**上限两列**。
 *
 * ★ 为什么"每列至少 320px"（改动前是 240px / 硬两列）：
 *   用户反馈的截图里每列只有 ~270px，`server.description` 的说明被折成五行、
 *   输入框窄得不好点。320px 是"一列里能写下一句 15~20 字的说明"的下限。
 *   一律写成 `min(100%, 320px)` 是因为**网格的列最小宽度不可压缩**：
 *   写死 320px 时，容器窄于 320px 就会撑出横向滚动条；`min(100%, …)`
 *   让极窄容器把列宽回落到 100%（单列），永远不会横向溢出。
 *
 * ★ 为什么长表单（.field-grid）还要额外压一个"最多两列"（46%）：
 *   只写 `minmax(320px, 1fr)` 的话，1400px 的 xl 弹窗会被 auto-fit 摊成 4 列
 *   （1400 / 320），每个字段又变回 320px 的窄条 —— 那就是"弹窗变宽了、字段还是挤"
 *   的假优化。46% × 2 + 间距 ≈ 100%，正好把列数封在两列，每列拿到 600px 以上。
 *
 * ★ 为什么两块网格都要 `min-width: 0` + `max-width: 100%`：
 *   它们现在住在 `width: fit-content` 的弹窗里。fit-content 向**内容**要宽度，
 *   而网格列的 `minmax(…, 1fr)` 在"被问最大宽度"时会按 max-content 回答，
 *   于是一个 27 字段的表单会报出"我要 1400px"。`max-width: 100%` 是给这一步的闸：
 *   网格永远不超过弹窗内容盒（弹窗自己再由 max-width 夹到 96vw），
 *   `min-width: 0` 则保证列能被压到 320px 以下而不是把容器顶开。
 */
.form-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}

.form-grid-2 {
  display: grid;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.field-grid {
  display: grid;
  gap: 12px 14px;
  align-items: start;
  min-width: 0;
  max-width: 100%;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, max(320px, 46%)), 1fr));
}

/*
 * 跨整行的两种字段（core/ui.js 的 field() 会自动打上 .field-span）：
 *   · 控件里带 textarea 的（多行文本挤在半列里只能看到两三个字）；
 *   · 说明文字很长的（说明折成五六行 = 一堵字墙）。
 * 另外"不是字段的东西"（提示条、按钮行、错误框、表格……）也一律整行：
 * 它们本来就是整块的，塞进半列会看不出是提示还是输入项。
 */
.field-grid > .field-span,
.form-grid > .field-span,
.field-grid > :not(.field) {
  grid-column: 1 / -1;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.input-group {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.input-group .input {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.input-group .btn {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: none;
}

.input-suffix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg-2);
  color: var(--text-faint);
  font-size: 12px;
}

.password-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

/*
 * 密码框 + 「显示 / 隐藏」切换按钮（core/ui.js 的 passwordInput）。
 * 外层是 flex 行，输入框本体必须自己撑满剩余宽度 —— .input 的 width:100% 在 flex 行里
 * 会把按钮挤到下一行（"按钮跑到底下去了"），所以这里显式 flex: 1 + min-width: 0
 * （min-width:0 是为了窄屏下能被压缩，否则长 placeholder 会把按钮顶出去）。
 */
.password-field .password-input {
  flex: 1 1 auto;
  min-width: 0;
}

.password-field .password-toggle {
  flex: 0 0 auto;
}

/* ---------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6.5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 520;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}

.btn:hover {
  background: var(--bg-3);
  border-color: var(--input-hover-border);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--primary-dim);
  border-color: var(--primary-dim);
}

.btn-secondary {
  background: var(--bg-2);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-accent);
}

.btn-danger:hover {
  background: var(--danger-strong);
  border-color: var(--danger-strong);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: transparent;
  color: var(--text);
}

.btn-ghost.active {
  background: var(--primary-soft);
  color: var(--accent-text);
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
  gap: 4px;
}

.btn-lg {
  padding: 9px 16px;
  font-size: 14px;
}

.btn-icon {
  padding: 5px;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}

.btn-icon:hover {
  background: var(--bg-hover);
  border-color: transparent;
  color: var(--text);
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: inline-flex;
  gap: 0;
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.btn-group .btn:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.btn-group .btn + .btn {
  border-left: none;
}

/* ---------------------------------------------------------- 徽章/状态 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1.5px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-3);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
  line-height: 1.7;
}

.badge-default { background: var(--bg-3); color: var(--text-dim); }
.badge-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }
.badge-warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-text); }
.badge-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
.badge-info { background: var(--info-soft); border-color: var(--info-border); color: var(--info-text); }
.badge-muted { background: var(--muted-soft); border-color: var(--border); color: var(--text-faint); }

/*
 * 工单分类徽章（8 类，颜色按 `category` key 区分）。
 *
 * 口径：
 *   · **只用上面定义好的主题变量**（--info-soft / --success-text / --danger-border …），
 *     所以深色与浅色主题下都自动可读，不需要在每个分类里再写一遍浅色特例；
 *   · 语义色只有 5 个色系（中性 / 蓝 / 青 / 绿 / 琥珀 / 红），而分类有 8 个 ——
 *     所以"账单"与"故障"、"服务态度(投诉)"与"缺陷"各自共用色系、用**深浅**（soft vs tint、
 *     -text vs 纯色）区分。两个同类色在列表里相邻时仍然能看出不是同一类；
 *   · 类名由前端按服务端下发的 key 拼出（见 views/tickets.js 的 categoryBadge）。
 *     将来服务端新增第 9 类而这里还没有对应类，徽章会退回 .badge 的默认底色，
 *     内容（中文标签）依然正确 —— 这只是"少一种颜色"，不是功能缺失。
 */
.badge.cat-general { background: var(--muted-soft); border-color: var(--border); color: var(--text-dim); }
.badge.cat-technical { background: var(--info-soft); border-color: var(--info-border); color: var(--info-text); }
.badge.cat-presale { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }
.badge.cat-aftersale { background: var(--primary-soft); border-color: var(--primary-border); color: var(--accent-text); }
.badge.cat-billing { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-text); }
.badge.cat-abuse { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
/* 故障与缺陷：比"举报与投诉"更重的纯色文字 + 更浅的底色，两者同属红色系但深浅不同 */
.badge.cat-bug { background: var(--danger-tint); border-color: var(--danger-border-soft); color: var(--danger); }
.badge.cat-other { background: var(--bg-3); border-color: var(--border-strong); color: var(--text-faint); }

/**
 * 工单处理等级徽章（普通 / 中等 / 高级，三色）。
 *
 * 与分类徽章同一套纪律：**只用主题变量**，所以深浅主题都可读；
 * 颜色本身**不是**前端定的 —— 服务端在元数据里给每一档一个 `tone`（muted / warn / danger），
 * 前端把它拼成既有的 `.badge-<tone>` 类（见 views/tickets.js 的 priorityBadge）。
 * 于是这里不需要（也不该）再写一份"high → 红"的映射：改了服务端色档，
 * 界面自动跟着变，不会出现"通知里说高级、列表里是黄的"这种漂移。
 *
 * 这一组选择器只为两件事而存在：
 *   1. 让等级徽章与分类徽章在视觉上可区分（等宽字体 + 更紧凑的字距，读起来像一个"档位"）；
 *   2. 给测试与样式定位一个稳定的类名（`.priority-badge`）。
 * 注意不要在这里覆盖 background/color —— 那会把上面 `.badge-<tone>` 的配色盖掉，
 * 也就是把"颜色由服务端口径决定"这条规则重新变成两份实现。
 */
.badge.priority-badge {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
}

/* 等级徽章在深浅主题下都要有足够对比：只调边框粗细（颜色仍来自 .badge-<tone>） */
.badge.priority-badge.badge-danger { border-width: 1px; }

/* 详情页标题旁的「关联实例」摘要（可点时可点，没有权限时是不可点的徽章） */
a.badge.instance-link:hover { text-decoration: underline; }
a.badge.instance-link { text-decoration: none; cursor: pointer; }

.state-badge {
  font-family: var(--mono);
  font-size: 11px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}

.dot-success { background: var(--success); box-shadow: 0 0 6px var(--dot-glow-success); }
.dot-danger { background: var(--danger); box-shadow: 0 0 6px var(--dot-glow-danger); }
.dot-warn { background: var(--warn); box-shadow: 0 0 6px var(--dot-glow-warn); }
.dot-muted { background: var(--dot-idle); }

.dot-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}

.tone-success { color: var(--success-text); }
.tone-warn { color: var(--warn-text); }
.tone-danger { color: var(--danger-text); }
.tone-info { color: var(--info-text); }

/* ---------------------------------------------------------- 反馈 */
.toast-wrap {
  position: fixed;
  left: 50%;
  top: 18px;
  bottom: auto;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: min(520px, calc(100vw - 36px));
  width: max-content;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--info);
  box-shadow: var(--shadow-2);
  animation: toast-in 0.16s ease-out;
}

.toast.leaving {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.toast[data-tone="success"] { border-left-color: var(--success); }
.toast[data-tone="error"] { border-left-color: var(--danger); }
.toast[data-tone="warn"] { border-left-color: var(--warn); }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warn); }

.toast-text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  word-break: break-word;
}

.toast-close {
  width: 20px;
  height: 20px;
  padding: 0;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.spinner {
  animation: spin 0.85s linear infinite;
  flex: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 26px;
  color: var(--text-dim);
}

.empty-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 34px 18px;
  text-align: center;
}

.empty-icon,
.error-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-faint);
  margin-bottom: 2px;
}

.error-icon {
  color: var(--danger-text);
  border-color: var(--danger-border-soft);
  background: var(--danger-soft);
}

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

.empty-message,
.error-message {
  color: var(--text-dim);
  font-size: 12.5px;
  max-width: 460px;
}

.empty-action,
.error-action {
  margin-top: 6px;
}

.progress {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 16px;
  border-radius: 8px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 8px 0 0 8px;
  background: linear-gradient(90deg, var(--progress-grad-a), var(--progress-grad-b));
  transition: width 0.3s ease;
}

.progress-warn .progress-bar { background: linear-gradient(90deg, var(--progress-warn-a), var(--progress-warn-b)); }
.progress-danger .progress-bar { background: linear-gradient(90deg, var(--progress-danger-a), var(--progress-danger-b)); }

.progress-label {
  position: absolute;
  right: 7px;
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--on-accent);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-2), var(--bg-3), var(--bg-2));
  background-size: 200% 100%;
  animation: skeleton 1.2s ease-in-out infinite;
  height: 14px;
}

@keyframes skeleton {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---------------------------------------------------------- 控制台/日志 */
.log-viewer {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  /*
   * ★ 日志/控制台区在**两个主题下都是深底浅字**（刻意，见 :root 里 --log-bg 的注释）。
   *
   *   这里**就地重新声明**了三个语义色变量：错误行/警告行用的是 --danger-text / --warn-text，
   *   而浅色主题把那两个变量换成了深红/深棕（那是给亮底用的）。如果不在这里改回来，
   *   浅色主题下的日志区就会出现"深底 + 深红字"——几乎看不见。
   *   值就是深色主题里那一套，与 :root 的原始定义一致。
   */
  --log-bg: #0b0d11;
  --danger-text: #fca5a5;
  --warn-text: #fcd34d;
  background: var(--log-bg);
}

.log-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.log-count {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--mono);
}

.log-search {
  width: 190px;
  padding: 4px 8px;
  font-size: 12px;
}

.log-lines {
  flex: 1 1 auto;
  height: 380px;
  overflow: auto;
  padding: 7px 9px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}

.log-wrap .log-text {
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line {
  display: flex;
  gap: 9px;
  white-space: pre;
  color: var(--log-text);
}

.log-line .log-time {
  color: var(--log-time);
  flex: none;
  user-select: none;
}

.log-line .log-text {
  min-width: 0;
}

.log-line.err,
.log-line.level-error {
  color: var(--danger-text);
}

.log-line.err .log-text,
.log-line.level-error .log-text {
  color: var(--danger-text);
}

.log-line.level-warn { color: var(--warn-text); }
.log-line.level-info { color: var(--log-text); }
.log-line.level-debug { color: var(--log-debug); }

/* ---------------------------------------------------------- 弹窗 */
/*
 * 尺寸口径（唯一一份，js 侧只传档名 —— core/ui.js 的 `modal({ width })`）
 *   sm  上限 420px  短确认 / 短提示（一句话就能说完的）
 *   md  上限 600px  **默认档**：单字段表单、错误提示、小确认框
 *   lg  上限 880px  宽内容：表格 / 日志 / JSON / 长文预览
 *   xl  上限 1400px 表单档：字段多（≥6）或含多行文本 / 表格的长表单
 *
 * ★★ 宽度 = `fit-content` + `min-width` + `max-width`（本轮从"固定像素"改过来的）★★
 *
 *   上一轮是 `width: min(1400px, 96vw, 100%)` —— 那是"**一律顶到档位上限**"：
 *   27 个字段的表单在 1920px 屏幕上真的就是 1400px，看着空；而一句「确定要删除吗？」
 *   的确认框也是 600px，内容只占三分之一，小屏上尤其难受。
 *
 *   现在：
 *     · `width: fit-content` —— 让**内容**决定要多大（"刚好撑开即可"）。
 *       fit-content 的语义是 `min(max-content, max(min-content, 可用宽度))`，
 *       所以字段少的弹窗就只占内容那么宽，字段多的会一直撑到 max-width 为止；
 *     · `min-width` —— 给每档一个"不至于塌成一条"的下限（短弹窗也不能窄到按钮换行）；
 *     · `max-width: min(<档位上限>, 96vw, 100%)` —— 那个像素**只是上限**：
 *       屏幕不够宽时自动收缩；`96vw` 左右各留 2vw 呼吸位；
 *       末尾的 `100%`（= 遮罩内容盒宽度，已扣掉遮罩左右内边距）保证极窄屏也
 *       **永远不会出现横向滚动条**（只靠 96vw 时，320px 屏幕上它仍比"视口 - 内边距"宽）。
 *
 *   三条一起才成立：只写 fit-content 会让长内容把弹窗顶穿屏幕，只写 max-width
 *   会回到"短弹窗也占满上限"的老问题。
 *
 * ★ 高度：`max-height: 90vh` + `.modal-body { overflow-y: auto }`（内容区自己滚，
 *   空高时不会把页面顶长）。用户拖拽时写入的内联 height 也会被这条 max-height 夹住 ——
 *   JS 侧同样按 90vh 钳制，两处口径一致（见 MODAL_RESIZE_MAX_VH）。
 *
 * ★ 为什么确认框不跟着变宽：确认框只有一两句话，拉宽只会让"确定 / 取消"两个按钮
 *   离文案十万八千里；真正需要宽度的是**字段多的表单**。有了 fit-content 之后，
 *   确认框自然就只有内容那么宽了。
 *
 * ★ 拖拽把手 `.modal-resize-handle` 见下方（鼠标 / 触摸 / 键盘三套输入共用一份钳制逻辑）。
 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 24px;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  overflow-y: auto;
}

.modal {
  /* 默认档 = md（上限 600px）。与 .modal-md 同一个值，写两份是为了
     "没传 width" 的弹窗不依赖调用方补一个 class。 */
  width: fit-content;
  min-width: min(320px, 100%);
  max-width: min(600px, 96vw, 100%);
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  animation: modal-in 0.14s ease-out;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  /* 定位上下文：右下角的拖拽把手是绝对定位的 */
  position: relative;
  /*
   * 横向兜底：绝不允许出现横向滚动条。
   * fit-content 下，一个"最小内容宽度 > max-width"的控件（超长不可断的 URL、
   * 列很宽的内联表格）理论上仍可能顶出去，这一行是最后一道闸。
   */
  overflow-x: hidden;
}

.modal-sm { min-width: min(280px, 100%); max-width: min(420px, 96vw, 100%); }
.modal-md { min-width: min(320px, 100%); max-width: min(600px, 96vw, 100%); }
.modal-lg { min-width: min(360px, 100%); max-width: min(880px, 96vw, 100%); }
.modal-xl { min-width: min(420px, 100%); max-width: min(1400px, 96vw, 100%); }

/*
 * 拖拽调整大小期间的全局状态：
 *   · `user-select: none` —— 否则按住拖动会顺手把页面文字全选（整屏变蓝）；
 *   · `cursor: nwse-resize` —— 指针在整个页面上都保持"斜向缩放"的形状，
 *     拖到弹窗外面也不会突然变回箭头（拖拽是全局的，不是只在把手上）。
 * 只加在**正在拖的那个**弹窗所在的文档上（body 上的 class 由 .modal-resizing 的兄弟规则兜）。
 */
body.modal-resize-active,
body.modal-resize-active * {
  user-select: none !important;
  cursor: nwse-resize !important;
}

/*
 * 拖拽尺寸期间：把内容层的布局/绘制隔离出来，并禁用过渡。
 * 大文本编辑器的自动换行会在每次改宽度时重排；contain 让重排限制在弹窗内部，
 * white-space: pre 避免整段文本反复折行，拖动会明显更顺。
 */
.modal-resizing .modal-body {
  contain: layout paint;
}
.modal-resizing textarea {
  white-space: pre;
  overflow: auto;
  resize: none;
}
.modal-resizing *,
.modal-resizing *::before,
.modal-resizing *::after {
  transition: none !important;
  animation: none !important;
}

/*
 * 拖拽把手：**八个方向各一个**（四条边 + 四个角，见 core/ui.js 的 MODAL_RESIZE_DIRS）。
 *
 * 为什么不是"右下角一个"：用户原话「配置拖动大小需要四周都可以，而不止是右下角」——
 * 只有一个角把手时，想把弹窗往左收窄得先把鼠标挪到右下角去，很别扭。
 * 现在四条边与四个角都能抓，行为与桌面窗口边框一致。
 *
 * 视觉上的取舍（为什么其余七个几乎看不见）：
 *   · **边条**只有 6px 厚、且两端各让开 22px 给角把手（避免两个把手重叠互相抢事件），
 *     默认完全透明、悬停时才显出一点底色 —— 八个把手都画出来会让弹窗四边挂满色块；
 *   · **角把手** 18×18，其中只有右下角那个保留了既有的斜纹角标（用户已经认识它），
 *     其余三个角与四条边一样是"看不见但抓得到"，并用各自方向的缩放光标提示可拖拽
 *     （`ns-resize` / `ew-resize` / `nwse-resize` / `nesw-resize`）。
 * `touch-action: none` 是触屏必需：否则手指按住边条时浏览器会把它当成滚动手势。
 */
.modal-resize-handle {
  position: absolute;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  cursor: nwse-resize;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  z-index: 1;
}

/* 上 / 下边：细长条，横向拉伸 */
.modal-resize-dir-n,
.modal-resize-dir-s {
  left: 22px;
  right: 22px;
  height: 6px;
  cursor: ns-resize;
}

.modal-resize-dir-n { top: 0; }
.modal-resize-dir-s { bottom: 0; }

/* 左 / 右边：细长条，纵向拉伸 */
.modal-resize-dir-w,
.modal-resize-dir-e {
  top: 22px;
  bottom: 22px;
  width: 10px;
  cursor: ew-resize;
  z-index: 6;
}

.modal-resize-dir-w { left: 0; }
.modal-resize-dir-e { right: 0; }

/* 四个角：18×18 的方块，光标按"对角线方向"分开给（nwse / nesw 两种） */
.modal-resize-dir-nw { top: 0; left: 0; cursor: nwse-resize; }
.modal-resize-dir-ne { top: 0; right: 0; cursor: nesw-resize; }
.modal-resize-dir-sw { bottom: 0; left: 0; cursor: nesw-resize; }
.modal-resize-dir-se {
  bottom: 0;
  right: 0;
  border-bottom-right-radius: var(--radius-lg);
}

.modal-resize-dir-se::before {
  /* 视觉上的"对角斜纹"角标（不用图片、也不占 DOM）—— 只给右下角那一个：
     它是既有实现里那个用户已经认识的角标，其余七个把手保持"看不见但抓得到" */
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 11px;
  height: 11px;
  background-image: linear-gradient(
    135deg,
    transparent 0 42%,
    var(--border-strong) 42% 54%,
    transparent 54% 74%,
    var(--border-strong) 74% 86%,
    transparent 86%
  );
}

.modal-resize-handle .icon {
  opacity: 0;
  transform: rotate(45deg);
}

.modal-resize-handle:hover {
  color: var(--text-dim);
  background: var(--bg-hover);
}

.modal-resize-handle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  color: var(--text);
  background: var(--bg-hover);
}

/* ---------------------------------------------------------- 工单（第 7 项） */
/*
 * 对话式工单：一条消息一个气泡。
 * 为什么要区分左右（from-user / from-staff）：工单是"用户 ↔ 管理员"的两方对话，
 * 一眼看出哪几句是自己说的、哪几句是对方说的，比通篇一个样式的流水账好读得多。
 * 用左边框颜色而不是整块背景色，是为了在深色/浅色主题下都保持可读（背景色对比度很难同时合适）。
 */
.ticket-message {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-md, 8px);
  padding: 10px 12px;
  background: var(--bg-2, transparent);
}

.ticket-message.from-user { border-left-color: var(--primary); }
.ticket-message.from-staff { border-left-color: var(--success-text); }

/* 工单正文那一条（区别于回复）：底色稍重一点，一眼能认出"这是问题本身" */
.ticket-message.is-main { background: var(--bg-1); }

.ticket-message-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

/* ---------------------------------------------------------- 工单附件（第 8 项） */
/*
 * 附件在工单里的两种出现位置：
 *   · 气泡下方（.ticket-message-attachments）—— 已上传的附件列表；
 *   · 弹窗/回复框里（.attachment-picker）—— 待上传的已选文件。
 * 颜色一律走既有变量（--border / --bg-* / --text-dim / --primary-soft），
 * 深浅两套主题各自有值，所以这里不写死任何一种颜色。
 */
.ticket-message-attachments {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 下载链接：整条可点，指针与下划线都只在这一行内生效 */
.attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 5px);
  background: var(--bg-1);
  color: var(--text);
  text-decoration: none;
  max-width: 100%;
}

.attachment-link:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 46ch;
}

.attachment-meta {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}

.attachment-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attachment-pick-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.attachment-pick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 5px);
  background: var(--bg-1);
}

.attachment-pick-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 44ch;
}

/* ---------------------------------------------------------- 站内通知铃铛（第 8 项） */
/*
 * 顶栏铃铛 + 未读徽标 + 下拉面板。
 * 未读数为 0 时徽标由 JS 直接隐藏（而不是显示 "0"），所以这里只负责"有未读"的样式。
 */
.notification-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.bell-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 5px);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.bell-trigger:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/*
 * 铃铛图标本身。
 *
 * ★ 为什么要单独写一条（而不是只靠 icon() 写在 <svg> 上的 width/height 属性）：
 *   之前的组件测试只断言到"按钮在、徽标在"，于是"图标到底画没画出来"没有任何约束 ——
 *   <svg> 是透明的，真正看得见的是它里面的 <path>。这里把尺寸/显示方式**显式**钉在 CSS 里
 *   （CSS 的优先级高于 width/height 属性），测试再拿这条规则做结构断言，
 *   "按钮有尺寸但图标被压成 0×0"就成了一条能被测出来的回归，而不是只能靠肉眼看。
 *
 * 18px 落在 32×32 的点击区正中；颜色不写死，继承 .bell-trigger 的 color
 * （--text-dim → 有未读时 --text），深浅两套主题下都取各自主题的变量值。
 */
.bell-trigger .icon {
  display: block;
  flex: none;
  width: 18px;
  height: 18px;
  color: inherit;
}

.notification-bell.has-unread .bell-trigger {
  color: var(--text);
}

/* 未读徽标：压在铃铛右上角（绝对定位，不影响顶栏排版） */
.bell-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: var(--on-accent);
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  box-shadow: var(--shadow-1);
}

.notification-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  background: var(--bg-1);
  box-shadow: var(--shadow-2);
  z-index: 40;
  overflow: hidden;
}

.notification-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.notification-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1 1 auto;
}

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.notification-item:hover {
  background: var(--bg-hover);
}

/* 未读条目：左侧一个小圆点 + 稍重的背景，一眼看出"哪几条还没看" */
.notification-item-dot {
  flex: none;
  width: 7px;
  height: 7px;
  margin-top: 5px;
  border-radius: 50%;
  background: transparent;
}

.notification-item.is-unread .notification-item-dot {
  background: var(--primary);
}

.notification-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.notification-item-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 40ch;
}

.notification-item-meta {
  color: var(--text-dim);
  font-size: 11px;
}

.notification-item-body {
  color: var(--text-dim);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 42ch;
}

.notification-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 22px 14px;
  color: var(--text-dim);
  text-align: center;
}

.notification-footer {
  display: flex;
  justify-content: flex-end;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

/**
 * 声音提醒一行（第 1 项）：开关 + 中文提示。
 *
 * 为什么单独占一行且提示文案允许省略号换行：提示里要说清"首次点击页面后才会响"，
 * 这句话不能被挤成两段消失 —— 用户看不到它就会以为声音坏了（这正是本项要解决的问题）。
 */
.notification-sound-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.notification-sound-hint {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.995); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.modal-title {
  font-size: 14.5px;
  font-weight: 620;
  flex: 1 1 auto;
  min-width: 0;
}

.modal-body {
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
  /*
   * fit-content 下的宽度保险：内容盒允许被压缩（flex 项默认 min-width: auto，
   * 一个内含长 URL / 宽表格的 .col 会把弹窗顶到 max-width 之外）。
   * **不**在这里写 overflow-wrap: anywhere —— 那会改变"内容要多宽"的计算，
   * 把所有文字都变成可断行，弹窗会塌到 min-width。长串该断的地方由 .break-all 负责。
   */
  min-width: 0;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 15px;
  border-top: 1px solid var(--border);
  flex: none;
}

.confirm-dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.confirm-message {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ---------------------------------------------------------- 标签页 */
.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent-text-strong);
  border-bottom-color: var(--primary);
}

.tab-badge {
  padding: 0 5px;
  border-radius: 8px;
  background: var(--bg-3);
  font-size: 11px;
  font-family: var(--mono);
}

.segmented {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-0);
}

.segment {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12.5px;
}

.segment:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.segment.active {
  background: var(--bg-3);
  color: var(--text);
}

/* ---------------------------------------------------------- 主题切换控件（顶栏） */
/*
 * 三态分段控件（自动 / 浅色 / 深色），复用 .segmented / .segment 的既有外观，
 * 这里只做三件事：不抢顶栏的注意力、窄屏收起文字、选中态用主色描边
 * （背景用的是"比周围更深/更浅一档"的 --bg-0，与顶栏的 --bg-1/--bg-2 拉开层次）。
 */
.theme-control {
  display: inline-flex;
  align-items: center;
  flex: none;
}

.theme-segmented {
  padding: 2px;
}

.theme-segmented .segment {
  padding: 4px 8px;
  gap: 4px;
}

.theme-segmented .segment.active {
  background: var(--primary-soft);
  color: var(--accent-text-strong);
  box-shadow: inset 0 0 0 1px var(--primary-border);
}

.theme-segmented .segment .icon {
  opacity: 0.85;
}

/* 窄屏（≤900px，全站既有的断点）收起文字只留图标：顶栏在手机上本来就很挤 */
@media (max-width: 900px) {
  .theme-segmented .segment-label {
    display: none;
  }

  .theme-segmented .segment {
    padding: 5px 7px;
  }
}

/* ---------------------------------------------------------- 主题切换控件（公开页面右上角） */
/*
 * 登录 / 注册 / 找回密码 / 重置密码 / 验证邮箱 这几页**没有顶栏**，卡片是居中的，
 * 页面右上角本来就是空白 —— 控件就放在那儿（绝对定位在 `.login-page` 里）。
 * 与顶栏那个控件是**同一个组件**（core/theme-control.js），只有 variant 不同，
 * 所以三态、文案、写入的 localStorage 键、无障碍属性全都一样。
 *
 * 为什么是 absolute 而不是 fixed：
 *   · 这几页内容很短，几乎不滚动；fixed 在矮屏滚动时会浮在卡片上方压住输入框，
 *     而 absolute 属于页面本身，只会跟着一起走 —— 不会遮挡内容；
 *   · 绝对定位不参与网格布局，`.login-page` 的 place-items:center 完全不受影响
 *     （卡片顶部留白由 `.login-page` 的 padding-top 保证）。
 * 窄屏不溢出：≤900px 时文字已经在上面那个断点里收起，只剩三个图标（约 90px 宽）。
 */
.theme-control-floating {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
}

@media (max-width: 480px) {
  .theme-control-floating {
    top: 10px;
    right: 10px;
  }
}

/* ---------------------------------------------------------- 键值表 */
.kv-list {
  display: grid;
  grid-template-columns: minmax(96px, auto) minmax(0, 1fr);
  gap: 6px 14px;
  font-size: 12.5px;
}

.kv-list dt {
  color: var(--text-faint);
}

.kv-list dd {
  color: var(--text);
  word-break: break-word;
}

.kv-compact {
  gap: 4px 12px;
}

/**
 * 紧凑键值**网格**（概览「服务器信息」/「A2S 查询」用）。
 *
 * 4 条轨道 = 一行放两对：`dt dd dt dd`。键列用 minmax 自适应（短的至少 96px、
 * 长的按内容撑开），值列吃掉剩余空间并**右对齐** —— 于是同一列里所有值的右边缘
 * 是对齐的，扫一眼就能比"配置值到底填了什么"，而不是被一列到底拉成长条。
 *
 * 窄屏（< 760px）退化成 2 条轨道：一行一对，仍然键左值右。
 * 只加在 `.kv-list` 上（`.kv-list.kv-grid`），不改变其它键值表的既有排版。
 */
.kv-list.kv-grid {
  grid-template-columns: minmax(96px, max-content) minmax(0, 1fr) minmax(96px, max-content) minmax(0, 1fr);
  gap: 4px 18px;
  align-items: baseline;
}

.kv-list.kv-grid dd {
  text-align: right;
}

@media (max-width: 760px) {
  .kv-list.kv-grid {
    grid-template-columns: minmax(88px, max-content) minmax(0, 1fr);
  }
}

/* ---------------------------------------------------------- 文件/树/代码 */
.file-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
}

.file-row:hover {
  background: var(--bg-hover);
}

.file-row.selected {
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

.file-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12.5px;
}

.file-meta,
.file-size {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--mono);
  flex: none;
}

.tree {
  font-family: var(--mono);
  font-size: 12.5px;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.tree-item:hover {
  background: var(--bg-hover);
}

.code,
.code-block {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
}

.code-block {
  display: block;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.55;
}

.diff {
  font-family: var(--mono);
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.diff-add {
  background: var(--success-tint);
  color: var(--success-text);
}

.diff-del {
  background: var(--danger-tint);
  color: var(--danger-text);
}

/* ---------------------------------------------------------- 模板卡/向导 */
.template-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 13px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.template-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-2);
}

.template-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.template-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.template-body {
  font-size: 12.5px;
  color: var(--text-dim);
}

.template-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--mono);
}

.template-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.wizard {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wizard-steps {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-1);
  color: var(--text-dim);
  font-size: 12.5px;
}

.wizard-step.active {
  border-color: var(--primary);
  color: var(--accent-text-strong);
  background: var(--primary-soft);
}

.wizard-step.done {
  border-color: var(--success-border);
  color: var(--success-text);
}

.wizard-step-index {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-3);
  font-size: 11px;
  font-family: var(--mono);
}

.wizard-step.active .wizard-step-index { background: var(--primary); color: var(--on-accent); }
.wizard-step.done .wizard-step-index { background: var(--success-soft); color: var(--success-text); }

.wizard-body {
  min-height: 220px;
}

.wizard-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  background: var(--info-soft);
  color: var(--info-text);
  font-size: 12.5px;
}

.notice-warn { border-left-color: var(--warn); background: var(--warn-soft); color: var(--warn-text); }
.notice-danger { border-left-color: var(--danger); background: var(--danger-soft); color: var(--danger-text); }
.notice-info { border-left-color: var(--info); background: var(--info-soft); color: var(--info-text); }
.notice-success { border-left-color: var(--success); background: var(--success-soft); color: var(--success-text); }

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.drawer-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.fieldset {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
}

.fieldset-title {
  font-size: 12.5px;
  font-weight: 620;
  color: var(--text-dim);
  letter-spacing: 0.3px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.toolbar .input,
.toolbar .select {
  width: auto;
  min-width: 150px;
}

.mono-input {
  font-family: var(--mono);
  font-size: 12.5px;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 9px;
}

.role-cell {
  display: flex;
  align-items: center;
  gap: 7px;
}

.host-meter {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* ---------------------------------------------------------- 登录页 */
.login-page {
  /* 追加：右上角的主题控件（.theme-control-floating）相对本页定位 */
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  /* 顶部留出主题控件的高度（14px + 约 30px）：卡片居中，矮屏时也不会被它压住 */
  padding: 56px 24px 24px;
  background:
    radial-gradient(1000px 480px at 50% -8%, var(--login-glow), transparent 70%),
    var(--bg-0);
}

.login-card {
  width: min(374px, 100%);
  padding: 26px 24px 20px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 18px;
}

.login-brand .brand-mark {
  width: 36px;
  height: 36px;
}

.login-brand .brand-name {
  font-size: 17px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.login-error {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
  font-size: 12.5px;
}

.login-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-faint);
}

.login-version {
  font-family: var(--mono);
}

/* ---------------------------------------------------------- 登录图形验证码 */
/*
 * 图片由服务端渲染成 PNG（深色字 + 浅色底，见 src/service/captcha.js）。
 * 因此容器只负责"边框 + 底色兜底"：图片没加载出来时也能看出这里应该有一张图，
 * 而不是留一块与卡片同色的空白。边框 / 提示文字都用既有主题变量，
 * 深色与浅色主题下都不刺眼；图片本身是浅底，两种主题下都清晰可读。
 */
.captcha-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.captcha-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.captcha-image {
  display: block;
  width: 160px;
  height: 56px;
  flex: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  /*
   * 底色用主题变量（`--bg-2` = 二级底色），**不写死**：
   * 图片未加载出来时这一块要跟着深色/浅色主题走，写死浅色会在深色主题下露出一块白斑。
   * 图片本身是不透明 PNG（浅底深字，见 src/service/captcha.js），所以这里只是占位与兜底。
   */
  background: var(--bg-2);
  object-fit: cover;
  /* 图片是一次性凭据的载体：不允许用户选中/拖动，避免误触把图拖走 */
  user-select: none;
  -webkit-user-drag: none;
}

.captcha-refresh {
  flex: none;
  white-space: nowrap;
}

.captcha-hint {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-faint);
}

/* 加载失败时用警示色，并保证提示是"可操作"的一句话（点「换一张」重试） */
.captcha-hint[data-tone="error"] {
  color: var(--danger-text);
}

/* ---------------------------------------------------------- 响应式 */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar {
    width: var(--sidebar-w-compact);
  }

  .sidebar .brand-text,
  .sidebar .nav-section-title,
  .sidebar .nav-item-label,
  .sidebar .nav-item-badge {
    display: none;
  }

  .sidebar .nav-item {
    justify-content: center;
    padding: 9px 0;
  }

  .sidebar-brand {
    justify-content: center;
    padding: 0;
  }

  .view {
    margin-left: var(--sidebar-w-compact);
    padding: 14px 13px 32px;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }

  /*
   * 窄屏一律单列（沿用全站 ≤900px 的既有约定）。
   * 为什么必须显式写在这里：`.field-grid` / `.form-grid` 的列宽是
   * `min(100%, max(320px, 46%))`，而 `.grid-2` 在本媒体查询里也会把
   * `grid-2 + field-grid` 的组合压成单列 —— 但 `form-grid` 不在其中，
   * 不写的话它会在 900px 的窗口里继续并排两列，说明文字又开始折行。
   */
  .form-grid,
  .field-grid,
  .grid.field-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .user-meta {
    display: none;
  }

  .topbar-subtitle {
    display: none;
  }

  .modal-backdrop {
    padding: 3vh 10px 16px;
  }

  .table th,
  .table td {
    padding: 8px 10px;
  }
}

@media (max-width: 620px) {
  .page-title { font-size: 17px; }
  .stat-value { font-size: 19px; }
  .page-actions { width: 100%; margin-left: 0; }
  .toast-wrap { left: 50%; right: auto; top: 10px; bottom: auto; transform: translateX(-50%); max-width: calc(100vw - 20px); }
  .log-lines { height: 300px; }
}

/* 打印/低动画偏好：关闭所有装饰性动画 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
 * 追加（实例详情页 / views/instance/console.js 使用）
 * 控制台里「用户发出的命令」行：logViewer 只区分 out/err，
 * 因此把 stream:"input" 映射成 level:"input"，这里补上对应样式，
 * 让「我发的」和「服务端输出的」一眼可分。
 * ============================================================ */
.log-line.level-input,
.log-line.level-input .log-text {
  color: var(--info-text);
}

.log-line.level-input .log-text::before {
  content: "$ ";
  color: var(--info);
  user-select: none;
}

/* ============================================================
 * 追加（未登录公开页面 / views/register.js、forgot-password.js、
 * reset-password.js、verify-email.js、login.js 使用）
 * 这四类页面复用登录页的 .login-page / .login-card / .login-brand /
 * .login-form / .login-footer，只补「表单下方入口链接」与「提示条里的排版」两处：
 *   - .login-links：登录页的「忘记密码 / 注册账号」，固定一行两个入口；
 *   - .auth-alt：注册、找回密码等页面里居中的次要跳转；
 *   - .login-error 内部再嵌一行按钮（账号未验证时的「重新发送验证邮件」），
 *     因此需要把默认的纯文本行改成纵向排列。
 * ============================================================ */
.login-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 3px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}

/* 只有一个入口时（注册关闭）不要留出右侧空洞 */
.login-links > :only-child {
  margin-left: auto;
  margin-right: auto;
}

.login-error .col {
  gap: 8px;
}

.login-error .login-error-text {
  display: block;
  line-height: 1.55;
}

.auth-alt {
  margin-top: 2px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-faint);
}

.login-footer .link {
  font-size: 12.5px;
}

/* ============================================================
 * 追加（管理员计费与全局服务器管理）
 *   views/plans.js          锁定项徽章、价格录入表
 *   views/redeem-codes.js   卡密明文行、批次选择
 *   views/users.js          余额流水（正负着色）、分页条
 * 全部为新增类名，不覆盖上面的既有规则。
 * ============================================================ */

/* 锁定项 / 规格徽章成组展示时允许换行 */
.locked-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

/* 余额流水的金额：正数入账绿色，负数出账红色 */
.money-delta {
  font-weight: 600;
  white-space: nowrap;
}

.money-in {
  color: var(--success-text);
}

.money-out {
  color: var(--danger-text);
}

/* 卡密明文：等宽 + 略大的字号，方便逐字符核对 */
.code-text {
  font-size: 12.5px;
  letter-spacing: 0.3px;
  word-break: break-all;
}

/* 生成成功弹窗里的卡密列表：等宽、可滚动、允许换行选择 */
.code-lines {
  max-height: 340px;
  overflow: auto;
  white-space: pre;
  line-height: 1.7;
}

/* 分页条（卡密列表 / 流水列表） */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 2px 2px 0;
}

/* 套餐表单里的模板白名单：两列自适应，每项是一个复选框标签 */
.template-picker {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  max-height: 260px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-0);
}

.template-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
}

.template-pick:hover {
  background: var(--bg-hover);
}

/* 套餐弹窗里的价格录入表：单元格留白小一点，避免挤压输入框 */
.template-picker + .field-hint {
  margin-top: 4px;
}

/* ============================================================
 * 追加（用户侧计费界面 / views/shop.js、views/billing.js、
 * views/dashboard.js、views/instance/overview.js 使用）
 * 只补这几处新结构，其余一律复用既有设计系统类：
 *   - .balance-chip / .balance-value：顶栏余额胶囊（app.js 已在用，这里补上样式；
 *     .balance-chip-lg 是总览页余额卡里的大号版本，可点击进入钱包）；
 *   - .plan-card 系列：套餐商店的套餐卡片（.highlight 视觉强调、.selected 选中态）；
 *   - .plan-features：套餐特性列表；
 *   - .purchase-panel：选中套餐后展开的购买表单面板；
 *   - .purchase-confirm：扣款确认行。
 * 全部为新增类名，不覆盖上面的既有规则。
 * ============================================================ */
.balance-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-2);
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.balance-chip:hover {
  border-color: var(--border-strong);
  background: var(--bg-3);
}

.balance-chip .icon {
  color: var(--text-faint);
}

.balance-value {
  font-family: var(--mono);
  font-weight: 620;
  color: var(--success-text);
}

.balance-chip-lg {
  padding: 2px 10px;
}

.balance-chip-lg .balance-value {
  font-size: 19px;
  letter-spacing: -0.4px;
}

.plan-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.plan-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-2);
}

/* 管理员标记为「推荐」的套餐：金色描边 + 轻投影，不用高饱和色块 */
.plan-card.highlight {
  border-color: var(--warn-border);
  box-shadow: 0 0 0 1px var(--warn-soft);
}

.plan-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.plan-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.plan-name {
  font-size: 14px;
  font-weight: 640;
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.plan-price-value {
  font-size: 21px;
  font-weight: 650;
  font-family: var(--mono);
  letter-spacing: -0.4px;
  color: var(--accent-text-strong);
}

.plan-card .kv-list {
  margin: 0;
}

.plan-features {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  color: var(--text-dim);
}

.plan-features li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.plan-features .icon {
  margin-top: 3px;
  flex: 0 0 auto;
  color: var(--success);
}

/* 购买表单：紧跟在套餐卡片网格之后，视觉上像「从卡片里展开的一块」 */
.purchase-panel {
  margin-top: 14px;
  background: var(--bg-1);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.purchase-panel .card-header {
  background: var(--primary-soft);
}

.purchase-confirm {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  font-size: 13px;
}

.purchase-confirm .mono,
.purchase-confirm .strong {
  font-family: var(--mono);
}

@media (max-width: 760px) {
  .plan-price-value {
    font-size: 19px;
  }

  .balance-chip-lg .balance-value {
    font-size: 17px;
  }
}


/* ============================================================
 * 节点管理（views/nodes.js）与套餐「每个游戏单独定价」（views/plans.js）
 * 本段是追加内容：只为上面两块新界面提供样式，不修改文件里已有的任何规则。
 * ============================================================ */

/* 单选组：协议 http / https */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  font-size: 13px;
  cursor: pointer;
}

.radio-option:hover {
  border-color: var(--primary);
}

.radio-option input {
  accent-color: var(--primary);
}

/* 明文密钥：唯一一次展示，必须显眼、可全选、等宽 */
.token-value {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.4px;
  line-height: 1.6;
  word-break: break-all;
}

/* 节点表格里的地址、状态副标题允许换行，避免把表格撑出横向滚动 */
.node-address {
  word-break: break-all;
}

/* 套餐编辑：每个游戏单独定价的映射编辑器 */
.game-price-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-price-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.game-price-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}

.game-price-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.game-price-input {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.game-price-monthly {
  flex: 0 0 auto;
  min-width: 96px;
  text-align: right;
  font-size: 13px;
  color: var(--text-dim);
}

/* 商店里的「该游戏单独定价」标记 */
.plan-game-prices {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
}

@media (max-width: 760px) {
  .game-price-row {
    flex-wrap: wrap;
  }

  .game-price-monthly {
    text-align: left;
  }
}

/* ============================================================
 * 实例插件页的「已安装文件」折叠块（views/instance/plugins.js）
 * 本段是追加内容：只为插件卡的折叠列表提供样式，不修改文件里已有的任何规则。
 *
 * 为什么要折叠：一个插件包可能写入几十上百个文件（Oxide 框架包、MOD 全量包），
 * 展开的列表会把后面的插件卡一路挤出屏幕。默认收起，需要时点开。
 * 用原生 <details>/<summary>：键盘可达与读屏语义都由浏览器提供。
 * ============================================================ */

.plugin-files {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  padding: 6px 10px;
}

.plugin-files > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  list-style: none; /* 去掉默认三角，改用下面的自定义箭头 */
  padding: 2px 0;
}

.plugin-files > summary::-webkit-details-marker {
  display: none;
}

/* 自定义展开箭头：收起时朝右、展开时朝下 */
.plugin-files > summary::before {
  content: '▸';
  color: var(--text-dim);
  font-size: 12px;
  margin-right: 2px;
}

.plugin-files[open] > summary::before {
  content: '▾';
}

.plugin-files > summary:hover .strong {
  color: var(--primary);
}

/* 展开后的文件行：最多占一段可滚动区域，文件再多也不会把后面的卡片推走 */
.plugin-files > .col {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  max-height: 320px;
  overflow-y: auto;
}

/* ============================================================
 * 浅色（白天）主题的收尾微调
 * ============================================================
 * 走的还是**同一套变量**（:root[data-theme="light"] 里那一份），
 * 这里只处理"变量表达不了"的那一点点 —— 例如同一个变量在两个主题下需要不同强度的阴影。
 * 放在文件最后是有意的：它靠"后出现的规则"覆盖上面那几条，而不是加 !important。
 * 品牌标记 / 进度条的渐变色也已经变成变量（--brand-grad-* / --progress-grad-*），
 * 所以这里不需要为它们写覆盖规则。
 */

/* 进度条上的白字在浅色主题下要更实的阴影，否则压在黄色/绿色条上会发飘 */
:root[data-theme="light"] .progress-label {
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.35);
}

/* ============================================================
 * 公开首页（落地页）—— views/home.js
 * ============================================================
 * 两条硬约束（写在样式里，而不是靠"记得"):
 *   1. **只用既有主题变量**，不写死任何颜色 —— 深浅两套主题都要可读
 *      （浅色主题下写死的浅灰字会直接看不见；这里一个 #hex 都没有）；
 *   2. **窄屏单列**：卡片网格用 auto-fill + minmax，媒体查询把 hero 的字号与
 *      内边距收一收。首页是未登录用户看到的第一屏，手机上看得舒服比好看重要。
 * 全部是新增类名（.home-*），不覆盖上面的既有规则。
 * ============================================================ */

.home-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 50% -10%, var(--login-glow), transparent 72%),
    var(--bg-0);
  color: var(--text);
}

/* 已登录时同一个视图嵌在外壳的 #view 里：不要 100vh、不要自己的背景 */
.home-embed {
  padding: 18px 20px 40px;
}

.home-topbar-inner,
.home-footer-inner,
.home-main {
  width: 100%;
  /**
   * 首页宽度：1080 太窄（1920 两侧各空 400px），1720 又太宽（卡片被拉得很散）。
   * 取中间值 1280，三列套餐宽度正常，两侧也不会显得空。
   */
  max-width: min(1280px, calc(100vw - 40px));
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

.home-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  padding-bottom: 16px;
  flex-wrap: wrap;
}

.home-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.home-brand .brand-name {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.2px;
  color: var(--text);
}

.home-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 「当前使用 HTTPS」小标记：用既有徽章配色，不抢按钮的位置 */
.protocol-flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--success-border);
  border-radius: 20px;
  background: var(--success-soft);
  color: var(--success-text);
  font-size: 11.5px;
  white-space: nowrap;
  cursor: help;
}

.home-main {
  flex: 1 1 auto;
  padding-top: 26px;
  padding-bottom: 40px;
}

.home-content {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* ---------------------------------------------------------- Hero */
.home-hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-title {
  margin: 0;
  font-size: 34px;
  line-height: 1.18;
  letter-spacing: -0.6px;
  color: var(--text);
}

.home-tagline {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-dim);
  max-width: 62ch;
}

.home-hero-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--mono);
}

.home-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--dot-idle);
}

.home-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ---------------------------------------------------------- 区块 */
.home-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.home-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  font-weight: 640;
  color: var(--text);
}

.home-section-title .icon {
  color: var(--text-faint);
}

.home-section-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ---------------------------------------------------------- 可开通的游戏卡片 */
.home-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 12px;
}

.home-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.12s ease, background 0.12s ease;
}

.home-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-2);
}

.home-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.home-card-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 640;
  color: var(--text);
}

.home-card-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-dim);
}

.home-plan-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.home-plan {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding: 6px 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.home-plan-name {
  font-weight: 620;
  color: var(--text);
}

.home-plan-price {
  font-family: var(--mono);
  color: var(--success-text);
  font-weight: 620;
}

.home-plan-spec {
  color: var(--text-faint);
  font-size: 11.5px;
}

.home-card-actions {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
}

/* ---------------------------------------------------------- 卖点 */
.home-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 10px;
}

.home-feature {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.home-feature-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--accent-text);
}

.home-feature-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.home-feature-title {
  font-size: 13px;
  font-weight: 620;
  color: var(--text);
}

.home-feature-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
}

/* ---------------------------------------------------------- 使用教程 */
.home-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  counter-reset: home-step;
}

.home-step {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.home-step-no {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--accent-text-strong);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 640;
}

.home-step-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.home-step-title {
  font-size: 13px;
  font-weight: 620;
  color: var(--text);
}

.home-step-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
}

.home-step-link {
  flex: none;
  font-size: 12px;
  white-space: nowrap;
  align-self: center;
}

/* ---------------------------------------------------------- 底部 */
.home-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 14px;
  padding-bottom: 22px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-faint);
}

.home-footer-left,
.home-footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.home-footer-right .link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* 表单校验提示的错误色（「访问协议」卡片的即时校验会用 data-tone="danger"） */
.field-hint[data-tone="danger"] {
  color: var(--danger-text);
}

/* 窄屏：单列 + 收紧字号与留白（首页在手机上也要能读完） */
@media (max-width: 760px) {
  .home-title {
    font-size: 25px;
  }

  .home-tagline {
    font-size: 13.5px;
  }

  .home-card-grid,
  .home-feature-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .home-main {
    padding-top: 16px;
  }

  .home-content {
    gap: 22px;
  }

  .home-embed {
    padding: 12px 12px 28px;
  }

  .home-topbar-inner,
  .home-footer-inner,
  .home-main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .home-step {
    flex-wrap: wrap;
  }
}



/* ---------------------------------------------------------- 服务器操作（大按钮卡片） */
.operation-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.operation-tile {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-align: left;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.operation-tile:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--bg-3);
  transform: translateY(-1px);
}

.operation-tile:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.operation-tile:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.operation-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  flex: 0 0 auto;
}

.operation-body {
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------- 控制台「终端模式」 */
.log-viewer.log-terminal {
  border-color: var(--border);
}

.log-viewer.log-terminal .log-lines {
  background: var(--log-bg);
  color: var(--log-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.45;
  padding: 10px 12px;
}

.log-viewer.log-terminal .log-line {
  color: var(--log-text);
  gap: 0;
}

.log-viewer.log-terminal .log-line.err,
.log-viewer.log-terminal .log-line.err .log-text,
.log-viewer.log-terminal .log-line.level-error,
.log-viewer.log-terminal .log-line.level-error .log-text {
  color: var(--danger-text);
}

.log-viewer.log-terminal .log-line.level-warn {
  color: var(--warn-text);
}

.log-viewer.log-terminal .log-wrap .log-text {
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------------------------------------------------------- 独立终端窗口（?popout=1） */
body.terminal-popout .sidebar,
body.terminal-popout .topbar,
body.terminal-popout .page-header,
body.terminal-popout .tabs {
  display: none !important;
}

body.terminal-popout .page {
  padding: 8px 12px;
  gap: 0;
}

body.terminal-popout .page-content {
  padding: 0;
}

/* ---------------------------------------------------------- 弹窗拖动 */
.modal-header.modal-draggable {
  cursor: move;
  user-select: none;
}

.modal-header.modal-draggable .btn-icon,
.modal-header.modal-draggable button,
.modal-header.modal-draggable a {
  cursor: pointer;
}

.modal.modal-dragging {
  transition: none !important;
}

/* ---------------------------------------------------------- 首页特价：左文右图 */
.home-deals-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 0.85fr);
  gap: 24px;
  align-items: stretch;
}

.home-deals-hero:not(.has-art) {
  grid-template-columns: minmax(0, 1fr);
}

.home-deals-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.home-deals-art {
  width: 100%;
  height: 100%;
  min-height: 260px;
  border-radius: 18px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}

/* 活动卡片：网格 + 卡片本体（此前没有样式，单张卡片会被拉满整行，左右失衡） */
.home-deal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 320px));
  gap: 12px;
  margin-top: 6px;
}

.home-deal-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-2);
  min-width: 0;
}

.home-deal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.home-deal-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-dim);
  font-size: 12px;
}

.home-deal-code {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.home-deal-code-value {
  font-weight: 600;
}

.home-deal-grid .home-card-actions {
  margin-top: auto;
}

@media (max-width: 900px) {
  .home-deals-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .home-deals-art {
    height: 180px;
    min-height: 0;
  }
}

/* ---------------------------------------------------------- 首页特价：腾讯云式「左菜单 + 大 Banner + 推荐条」 */
.home-deals-showcase {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-2);
}

.home-deals-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.home-deals-menu-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.home-deals-menu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
  min-width: 0;
}

.home-deals-menu-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  padding: 9px 10px;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-deals-menu-item:hover {
  background: var(--bg-3);
}

.home-deals-menu-item.active {
  background: var(--bg-3);
  border-left-color: var(--primary);
  color: var(--text);
  font-weight: 600;
}

.home-deals-banner-host {
  min-width: 0;
}

.home-deals-banner {
  display: flex;
  align-items: center;
  min-height: 320px;
  padding: 36px 42px;
  color: var(--on-accent);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.home-deals-banner-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 620px;
}

.home-deals-eyebrow {
  width: max-content;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.86);
  color: var(--on-accent);
  font-size: 12px;
}

.home-deals-banner-title {
  margin: 0;
  color: var(--on-accent);
  font-size: 30px;
  line-height: 1.25;
}

.home-deals-banner-desc {
  margin: 0;
  color: var(--on-accent); opacity: 0.86;
}

.home-deals-banner-code {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--on-accent);
}

.home-deals-banner-cta {
  width: max-content;
  margin-top: 4px;
}

.home-deals-more {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 16px 16px;
  overflow: hidden;
  background: var(--bg-2);
}

.home-deals-more-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-right: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.home-deals-more-item:last-child {
  border-right: 0;
}

.home-deals-more-item:hover {
  background: var(--bg-3);
}

.home-deals-more-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  font-size: 13px;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .home-deals-showcase {
    grid-template-columns: minmax(0, 1fr);
  }

  .home-deals-menu {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .home-deals-menu-list {
    flex-direction: row;
    overflow-x: auto;
  }

  .home-deals-banner {
    min-height: 240px;
    padding: 24px;
  }

  .home-deals-banner-title {
    font-size: 24px;
  }

  .home-deals-more {
    grid-template-columns: minmax(0, 1fr);
  }

  .home-deals-more-item {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

/* ---------------------------------------------------------- 首页首屏 + 套餐分页 */
.home-hero {
  min-height: calc(100vh - 132px);
  justify-content: center;
}

@supports (height: 100svh) {
  .home-hero {
    min-height: calc(100svh - 132px);
  }
}

.home-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
}

.home-pager-info {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* 首屏不再强撑整屏：1280 宽下居中一块小区域会显得四周空，改回左对齐的紧凑首屏 */
.home-hero {
  align-items: flex-start;
  text-align: left;
  padding-left: 0;
  padding-right: 0;
  min-height: 420px;
  justify-content: center;
}

.home-hero-actions,
.home-hero-meta {
  justify-content: flex-start;
}

/* 套餐固定三列（配合每页 9 个 = 三行）；窄屏再降为两列/一列 */
.home-card-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1000px) {
  .home-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .home-card-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* 首页套餐：标题行「显示所有」+ 最后一行补满 */
.home-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.home-section-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.home-card-span-2 {
  grid-column: span 2;
}

.home-card-span-3 {
  grid-column: span 3;
}

@media (max-width: 1000px) {
  .home-card-span-2,
  .home-card-span-3 {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .home-card-span-2,
  .home-card-span-3 {
    grid-column: span 1;
  }
}

/* 文件管理：拖拽上传高亮 */
.drop-active {
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}


/* 系统设置：TCAdmin 风格左侧分类 + 右侧内容 */
.settings-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.settings-sidebar {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}
.settings-sidebar-title {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 8px;
}
.settings-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-menu-item {
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.settings-menu-item:hover {
  background: var(--hover);
}
.settings-menu-item.active {
  background: var(--accent-soft, var(--hover));
  color: var(--accent);
  font-weight: 600;
}
@media (max-width: 760px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-sidebar { position: static; }
  .settings-menu { flex-direction: row; flex-wrap: wrap; }
}


/* 系统设置首页：分类按钮 */
.settings-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.settings-category-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.settings-category-card:hover {
  border-color: var(--accent);
  background: var(--hover);
}
.settings-category-title {
  font-size: 15px;
  font-weight: 600;
}


.sf-busy-mask {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: grayscale(1);
  color: #fff;
  font-size: 14px;
}
.sf-busy-mask .sf-busy-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: sf-busy-spin 0.8s linear infinite;
}
@keyframes sf-busy-spin {
  to { transform: rotate(360deg); }
}
.mail-log-body { white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 10px; font-size: 12px; }
