/* ============================================================================
   Adobe2API 控制台 — 设计系统
   ----------------------------------------------------------------------------
   布局：固定侧栏 + 顶栏 + 内容区（.app / .sidebar / .main / .content）
   配色：深蓝灰中性色阶 + 青色强调色。
   ⚠️ --text-2 (#a8bfd8) / --text-3 (#7f96ad) / --danger-2 (#ffb4bc) 等值
      与 admin.js 模板里的内联色硬编码一致，改动会让动态渲染的单元格失配。
   ============================================================================ */

:root {
  color-scheme: dark;

  /* 表面：蓝调中性色阶，由深到浅 */
  --bg: #080c12;
  --sidebar-bg: #0b1119;
  --surface: #0f1621;
  --surface-2: #131c28;
  --surface-3: #182231;
  --field: #0a1017;

  /* 描边 */
  --border: #1c2836;
  --border-strong: #26364a;

  /* 文字 */
  --text: #e6eef8;
  --text-2: #a8bfd8;
  --text-3: #7f96ad;

  /* 强调色与语义色 */
  --accent: #2cc7aa;
  --accent-hover: #33dcbc;
  --accent-bright: #4de2c4;
  --accent-ink: #042019;
  --accent-soft: rgba(44, 199, 170, 0.12);
  --accent-line: rgba(44, 199, 170, 0.34);

  --danger: #e16068;
  --danger-2: #ffb4bc;
  --danger-soft: rgba(225, 96, 104, 0.13);
  --danger-line: rgba(225, 96, 104, 0.42);

  --warn: #ffca58;
  --warn-soft: rgba(225, 163, 44, 0.14);

  --info: #63d4ff;
  --info-soft: rgba(48, 170, 255, 0.13);

  /* 方正克制的直角风格：半径只用于消除锯齿感，不做圆润造型。
     胶囊形（999px）仅保留给状态徽标一类确实需要区分形状的元素。 */
  --radius-sm: 2px;
  --radius: 3px;
  --radius-lg: 4px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px -8px rgba(0, 0, 0, 0.55);
  --shadow-3: 0 28px 64px -16px rgba(0, 0, 0, 0.72);

  --ring: 0 0 0 3px rgba(44, 199, 170, 0.24);

  /* 系统字体栈：无外部依赖，且中英文混排渲染一致 */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono",
    "IBM Plex Mono", Menlo, Consolas, monospace;

  --sidebar-w: 208px;
  --topbar-h: 48px;
  --content-max: 1960px;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 极轻的顶部光晕，代替原来的模糊色球装饰 */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 420px;
  background:
    radial-gradient(90% 100% at 18% 0%, rgba(29, 121, 209, 0.13), transparent 70%),
    radial-gradient(70% 100% at 92% 0%, rgba(44, 199, 170, 0.09), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* 兼容旧标记：装饰球已从页面移除，保留空规则避免历史缓存的 HTML 露出色块 */
.bg-orb {
  display: none;
}

::selection {
  background: rgba(44, 199, 170, 0.28);
  color: #fff;
}

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

/* 滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: #263546 transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: #263546;
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: #33475e;
  background-clip: content-box;
}

/* ==========================================================================
   1. 应用骨架
   ========================================================================== */

.app {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

/* --- 侧栏 --- */

.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 18px 14px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 8px;
  background: linear-gradient(150deg, var(--accent) 0%, #1d79d1 100%);
  color: var(--accent-ink);
  box-shadow: 0 2px 10px -2px rgba(44, 199, 170, 0.5);
}

.brand-mark svg {
  width: 18px;
  height: 18px;
}

.brand-text {
  min-width: 0;
}

.brand-name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-label {
  padding: 0 8px;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* .tabs / .tab-btn / .tab-pane 的类名由 admin.js 绑定，勿改名 */
.tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.tab-btn svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  opacity: 0.75;
}

.tab-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tab-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-bright);
}

.tab-btn.active svg {
  opacity: 1;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px 0;
  border-top: 1px solid var(--border);
}

.sidebar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-3);
}

.sidebar-meta code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
}

/* --- 主列 --- */

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--topbar-h);
  padding: 10px 24px;
  background: rgba(8, 12, 18, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-titles {
  min-width: 0;
  flex: 1 1 auto;
}

.topbar-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.topbar-desc {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.content {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--content-max);
  padding: 22px 24px 56px;
}

/* 居中单列骨架（登录页复用） */
.shell {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100vw - 32px));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==========================================================================
   2. 状态指示 / 徽标
   ========================================================================== */

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--text-3);
}

.status-chip.is-online {
  border-color: var(--accent-line);
  color: var(--accent-bright);
}
.status-chip.is-online .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(44, 199, 170, 0.18);
}

.status-chip.is-offline {
  border-color: var(--danger-line);
  color: var(--danger-2);
}
.status-chip.is-offline .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(225, 96, 104, 0.18);
}

/* ==========================================================================
   3. 卡片与区块
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 20px;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.muted {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
}

.help {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-2);
}

.help code {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--field);
  border: 1px solid var(--border);
  color: var(--accent-bright);
}

.help strong {
  color: var(--text);
  font-weight: 700;
}

.small {
  font-size: 13px;
}

/* 区块头：标题 + 说明 + 右侧操作 */
.list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.list-head h2 {
  margin: 0;
}

.list-head > div:first-child {
  min-width: 0;
}

.list-head .help {
  margin-top: 4px;
}

.section-note {
  margin: -6px 0 14px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-2);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent-line);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-2);
}

.section-note code {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--field);
  border: 1px solid var(--border);
  color: var(--accent-bright);
}

.section-note strong {
  color: var(--text);
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 18px;
}

.tab-pane.active {
  display: flex;
  animation: paneIn 0.18s ease-out;
}

@keyframes paneIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   4. 按钮
   ========================================================================== */

button {
  font: inherit;
  font-weight: 650;
  font-size: 13px;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease,
    box-shadow 0.14s ease, opacity 0.14s ease;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: translateY(0.5px);
}

button:focus-visible {
  box-shadow: var(--ring);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

button.secondary {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}
button.secondary:hover {
  background: var(--surface-3);
  border-color: #32465e;
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
button.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

button.danger {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger-2);
}
button.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

button.small {
  min-height: 28px;
  padding: 5px 11px;
  font-size: 12px;
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}
button.small:hover {
  background: var(--surface-3);
}

button.icon-btn {
  width: 30px;
  min-height: 30px;
  padding: 0;
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
button.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
button.icon-btn svg {
  width: 16px;
  height: 16px;
}

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

.actions-end {
  justify-content: flex-end;
}

.actions-spaced {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.msg {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-2);
}

/* ==========================================================================
   5. 表单
   ========================================================================== */

.add-form,
.config-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 表单限制在可读宽度内，避免单行输入框在宽屏上被拉到 1200px+ */
.config-form {
  max-width: 980px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: 0.01em;
}

.config-inline-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.config-inline-row .inline-item {
  min-width: 0;
}

.input-text,
.input-select,
textarea {
  width: 100%;
  min-height: 34px;
  padding: 7px 11px;
  background: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.input-text::placeholder,
textarea::placeholder {
  color: #5c718a;
}

.input-text:hover,
.input-select:hover,
textarea:hover {
  border-color: #32465e;
}

.input-text:focus,
.input-select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

textarea {
  resize: vertical;
}

.input-select {
  min-width: 120px;
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(50% + 1px), calc(100% - 10px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

textarea#tokenInput {
  min-height: 96px;
}

input[type="file"] {
  width: 100%;
  padding: 7px 10px;
  background: var(--field);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 4px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  background: var(--surface-3);
}

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

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

/* 一行内并排的小控件（开关 / 步进 / 按钮 / 状态） */
.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.field-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text);
}

.field-inline-num {
  width: 84px;
  min-height: 28px;
  padding: 3px 8px;
  font-size: 12.5px;
}

/* 配置页二级分类 */
.config-category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.config-cat-btn {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 650;
}

.config-cat-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.config-cat-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-bright);
}

.config-cat-pane {
  display: none;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.012);
}

.config-cat-pane.active {
  display: flex;
}

/* ==========================================================================
   6. 统计卡
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card {
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.stat-label {
  margin-bottom: 4px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.stat-value {
  font-size: 23px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* 概览条：Token 总数 / 生效数 / 积分总量 */
.token-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
}

.token-summary strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 无内容时不要留下一条空的边框横条（如未启用会话刷新守护进程时的 #srSummary） */
.token-summary:empty,
.log-stream:empty {
  display: none;
}

.token-list-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.token-credits-summary {
  font-size: 12.5px;
  color: var(--text-2);
  text-align: right;
}

.token-credits-summary strong {
  color: var(--accent-bright);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* 日志筛选器 */
.logs-filter-actions {
  align-items: flex-end;
  flex-wrap: wrap;
}

.logs-filter-item {
  display: grid;
  gap: 4px;
}

.logs-filter-item label {
  line-height: 1;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.logs-account-filter .input-select {
  min-width: 240px;
  max-width: 400px;
}

/* ==========================================================================
   7. 表格
   ========================================================================== */

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

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

thead {
  background: var(--surface-2);
}

th {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  transition: background 0.1s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.022);
}

td input[type="number"] {
  background: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}

td input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

.empty-state {
  padding: 44px 20px !important;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* --- Token 表：固定列宽 + 紧凑行 --- */

.token-list-card .table-wrapper {
  overflow-x: auto;
}

/* 固定布局下所有列都用像素宽，min-width 必须 ≥ 各列之和（1459px），
   否则百分比/自动列会被挤成一个字符宽。各列之和 = 1376px，1920 屏可完整放下；
   更窄的屏靠横向滚动 + 右侧吸附的「操作」列保证操作始终可点。 */
#tokenTable {
  table-layout: fixed;
  min-width: 1380px;
}

#tokenTable th,
#tokenTable td {
  padding-left: 8px;
  padding-right: 8px;
}

/* 行内含开关/输入框等多行内容，收紧内边距与行高避免整行被撑高 */
#tokenTable td {
  padding-top: 6px;
  padding-bottom: 6px;
  line-height: 1.3;
  vertical-align: middle;
}

#tokenTable th {
  padding-top: 6px;
  padding-bottom: 6px;
}

#tokenTable th:nth-child(1),
#tokenTable td:nth-child(1) {
  width: 36px;
}
#tokenTable th:nth-child(2),
#tokenTable td:nth-child(2) {
  width: 140px;
}
#tokenTable th:nth-child(3),
#tokenTable td:nth-child(3) {
  width: 130px;
}
#tokenTable th:nth-child(4),
#tokenTable td:nth-child(4) {
  width: 120px;
}
/* 自动刷新：不换行 */
#tokenTable th:nth-child(5),
#tokenTable td:nth-child(5) {
  width: 84px;
  white-space: nowrap;
}
/* 能力：视频 / 4K / 高品质 / 免费号 四个紧凑开关合并成一列（原本是两列独立开关） */
#tokenTable th:nth-child(6),
#tokenTable td:nth-child(6) {
  width: 168px;
}
#tokenTable th:nth-child(7),
#tokenTable td:nth-child(7) {
  width: 70px;
}
/* 积分：给足单行宽度，避免“重置时间”被挤成多行 */
#tokenTable th:nth-child(8),
#tokenTable td:nth-child(8) {
  width: 110px;
}
#tokenTable th:nth-child(9),
#tokenTable td:nth-child(9) {
  width: 58px;
}
#tokenTable th:nth-child(10),
#tokenTable td:nth-child(10) {
  width: 130px;
}
#tokenTable th:nth-child(11),
#tokenTable td:nth-child(11) {
  width: 132px;
}

/* 「操作」列吸附在右边缘：横向滚动时始终可点。
   吸附单元格必须自带不透明背景，否则会透出下方滚动的内容。
   ⚠ 序号跟着列数走：视频+4K 合并成「能力」后总列数 13 -> 12。 */
#tokenTable th:nth-child(12),
#tokenTable td:nth-child(12) {
  position: sticky;
  right: 0;
  width: 210px;
  border-left: 1px solid var(--border);
  background: var(--surface);
}

#tokenTable thead th:nth-child(12) {
  background: var(--surface-2);
}

#tokenTable tbody tr:hover td:nth-child(12) {
  background: #121b26;
}

/* 状态列较窄，长文案徽标（如「额度耗尽·1K/2K可用」）允许折行而不是溢出压住邻列 */
#tokenTable .status-badge {
  white-space: normal;
  text-transform: none;
  letter-spacing: 0.02em;
  line-height: 1.35;
}

/* 脱敏 token 只用于辨识，单行省略号即可，避免 break-all 把行高撑成 3 行。
   ⚠️ .token-val 是 <td> 本身（admin.js 写在 td 上），不能设 display:block，
   否则该单元格会脱离表格布局。 */
#tokenTable .token-val {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
}

/* --- 日志表 --- */

#logsTable,
#runningLogsTable {
  table-layout: auto;
  min-width: 1100px;
}

#logsTable th:nth-child(1),
#logsTable td:nth-child(1),
#runningLogsTable th:nth-child(1),
#runningLogsTable td:nth-child(1) {
  width: 104px;
}

#logsTable th:nth-child(2),
#logsTable td:nth-child(2),
#runningLogsTable th:nth-child(2),
#runningLogsTable td:nth-child(2),
#logsTable th:nth-child(4),
#logsTable td:nth-child(4),
#runningLogsTable th:nth-child(4),
#runningLogsTable td:nth-child(4),
#logsTable th:nth-child(8),
#logsTable td:nth-child(8),
#runningLogsTable th:nth-child(8),
#runningLogsTable td:nth-child(8) {
  width: auto;
  white-space: nowrap;
}

#logsTable th:nth-child(3),
#logsTable td:nth-child(3),
#runningLogsTable th:nth-child(3),
#runningLogsTable td:nth-child(3) {
  width: 68px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#logsTable th:nth-child(5),
#logsTable td:nth-child(5),
#runningLogsTable th:nth-child(5),
#runningLogsTable td:nth-child(5) {
  width: 420px;
}

#logsTable th:nth-child(6),
#logsTable td:nth-child(6),
#runningLogsTable th:nth-child(6),
#runningLogsTable td:nth-child(6) {
  width: 180px;
}

#logsTable th:nth-child(7),
#logsTable td:nth-child(7),
#runningLogsTable th:nth-child(7),
#runningLogsTable td:nth-child(7) {
  min-width: 220px;
  width: 32%;
}

#logsTable td,
#runningLogsTable td {
  padding: 10px 12px;
  vertical-align: top;
}

/* --- 单元格排版 --- */

.token-val {
  font-family: var(--mono);
  font-size: 11.5px;
  color: #8fb0d3;
  word-break: break-all;
  line-height: 1.4;
}

.log-account-cell {
  display: block;
  color: var(--text-2);
  line-height: 1.4;
}

.log-account-email {
  color: var(--text-3);
  word-break: break-all;
}

.log-time-cell {
  color: var(--text-2);
  line-height: 1.3;
  white-space: normal;
  font-variant-numeric: tabular-nums;
}

.log-time-cell .date {
  display: block;
}

.log-time-cell .time {
  display: block;
  color: var(--text-3);
}

.log-model-cell {
  font-family: var(--mono);
  font-size: 11.5px;
  color: #8fb0d3;
  word-break: break-word;
}

.log-prompt-cell {
  color: var(--text-2);
  line-height: 1.45;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.metric-danger {
  color: var(--danger-2);
  font-weight: 700;
}

.rank-cell {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* --- 状态徽标 --- */

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-bright);
}
.status-exhausted {
  background: var(--warn-soft);
  border-color: rgba(255, 202, 88, 0.34);
  color: var(--warn);
}
.status-invalid,
.status-error {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger-2);
}
.status-disabled {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-strong);
  color: var(--text-3);
}
.status-missing {
  background: rgba(127, 150, 173, 0.12);
  border-color: var(--border-strong);
  color: var(--text-2);
}

.log-status-2xx {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-bright);
}
.log-status-4xx {
  background: var(--warn-soft);
  border-color: rgba(255, 202, 88, 0.34);
  color: var(--warn);
}
.log-status-5xx {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger-2);
}

/* --- 运行状态 pill --- */

.log-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.log-state.running {
  color: var(--info);
  background: var(--info-soft);
  border-color: rgba(99, 212, 255, 0.3);
}

.log-state.success {
  color: var(--accent-bright);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.log-state.failed {
  color: var(--danger-2);
  background: var(--danger-soft);
  border-color: var(--danger-line);
}

.log-state-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  min-height: 24px;
  cursor: pointer;
}

.log-state-btn.failed:hover {
  background: rgba(225, 96, 104, 0.24);
  border-color: var(--danger);
  color: #fff;
}

.log-row-running {
  background: rgba(48, 170, 255, 0.05);
}

.icon-spinner {
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.icon-check,
.icon-error {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  font-size: 11px;
  line-height: 1;
}

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

/* --- 行内操作按钮组 --- */

.action-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.action-mini,
.action-btns button {
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.action-mini:hover,
.action-btns button:hover {
  background: var(--surface-3);
  border-color: #32465e;
  color: var(--text);
}

.action-mini.danger,
.action-btns button.danger {
  background: transparent;
  border-color: var(--danger-line);
  color: var(--danger-2);
  padding: 2px 8px;
  font-size: 11px;
}

.action-mini.danger:hover,
.action-btns button.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.preview-btn {
  min-height: 24px;
  padding: 2px 9px;
  font-size: 11px;
}

/* --- 开关 --- */

.switch-btn {
  width: 38px;
  height: 22px;
  min-height: 22px;
  padding: 2px;
  border-radius: 999px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  background: #26313e;
  vertical-align: middle;
}

.switch-btn:hover {
  background: #2e3b4a;
}

.switch-btn.on {
  background: rgba(44, 199, 170, 0.32);
  border-color: var(--accent-line);
}

.switch-btn.on:hover {
  background: rgba(44, 199, 170, 0.42);
}

.switch-btn.off {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--border-strong);
}

.switch-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.switch-knob {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  transform: translateX(0);
  transition: transform 0.16s cubic-bezier(0.32, 0.72, 0, 1);
}

.switch-btn.on .switch-knob {
  transform: translateX(16px);
}

.switch-text {
  margin-left: 7px;
  font-size: 11.5px;
  color: var(--text-2);
}

/* ==========================================================================
   8. 分页
   ========================================================================== */

.logs-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.logs-pagination .help {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   9. 日志流 / 账号选择列表
   ========================================================================== */

.log-stream {
  max-height: 440px;
  overflow-y: auto;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #070c12;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-stream-sm {
  max-height: 160px;
  font-size: 11.5px;
  line-height: 1.55;
}

.pick-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field);
}

.pick-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12.5px;
  color: var(--text-2);
  user-select: none;
  cursor: pointer;
}

.pick-list label:hover {
  color: var(--text);
}

/* 兼容旧 refresh bundle 面板 */
.refresh-status {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.55;
}

.refresh-profiles-table {
  font-size: 12px;
}

.refresh-profiles-table th,
.refresh-profiles-table td {
  padding: 8px;
}

/* ==========================================================================
   10. 弹窗
   ========================================================================== */

.dialog-modal,
.preview-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 7, 11, 0.74);
  backdrop-filter: blur(4px);
}

.dialog-modal {
  z-index: 950;
}

.preview-modal {
  z-index: 1000;
}

.dialog-modal.open,
.preview-modal.open {
  display: flex;
  animation: fadeIn 0.14s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.dialog-card,
.preview-modal-dialog {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  animation: dialogIn 0.16s cubic-bezier(0.32, 0.72, 0, 1);
}

.preview-modal-dialog {
  width: min(1100px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.dialog-head h2 {
  margin: 0;
}

.dialog-head .help {
  margin-top: 3px;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-head h3 {
  font-size: 14px;
  color: var(--text);
}

.preview-close {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 5px 12px;
  font-size: 12px;
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.preview-close:hover {
  background: var(--surface-3);
}

.preview-content {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  max-height: calc(100vh - 190px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #070c12;
  overflow: auto;
}

.preview-content img,
.preview-content video {
  max-width: 100%;
  max-height: calc(100vh - 210px);
  border-radius: var(--radius-sm);
  background: #070c12;
}

.preview-actions {
  display: flex;
  justify-content: flex-end;
}

.preview-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  min-height: 34px;
  padding: 7px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.preview-download:hover {
  background: var(--surface-3);
}

.error-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.error-detail-head h3 {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

.error-detail-content {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #070c12;
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.error-detail-content pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #cfe3f8;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}

/* ==========================================================================
   11. Toast
   ========================================================================== */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  max-width: min(420px, calc(100vw - 40px));
  padding: 11px 15px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--text-3);
  border-radius: var(--radius);
  background: #101823;
  box-shadow: var(--shadow-2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  border-left-color: var(--accent);
}

.toast.error {
  border-left-color: var(--danger);
}

/* ==========================================================================
   12. 登录页
   ========================================================================== */

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  padding: 30px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
}

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

.auth-title {
  margin: 0 0 5px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.auth-sub {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--text-3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form .input-text {
  min-height: 38px;
  font-family: var(--font);
  font-size: 13.5px;
}

.auth-form button {
  width: 100%;
  min-height: 38px;
  margin-top: 4px;
  font-size: 13.5px;
}

.auth-msg {
  min-height: 18px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--danger-2);
}

.auth-foot {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-3);
  text-align: center;
}

/* ==========================================================================
   13. 响应式
   ========================================================================== */

@media (max-width: 1120px) {
  .app {
    flex-direction: column;
    align-items: stretch;
  }

  .sidebar {
    position: static;
    width: 100%;
    flex: 0 0 auto;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }

  .brand {
    padding: 0;
    flex: 0 0 auto;
  }

  .brand-sub {
    display: none;
  }

  .nav-label,
  .sidebar-foot {
    display: none;
  }

  .tabs {
    flex-direction: row;
    gap: 4px;
  }

  .tab-btn {
    width: auto;
  }

  .topbar {
    padding: 10px 16px;
  }

  .content {
    padding: 18px 16px 48px;
  }
}

@media (max-width: 760px) {
  .list-head {
    flex-direction: column;
    align-items: stretch;
  }

  .list-head .actions {
    width: 100%;
  }

  .token-list-actions {
    width: 100%;
    align-items: flex-start;
  }

  .token-credits-summary {
    text-align: left;
  }

  .topbar-desc {
    display: none;
  }

  .config-category-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .card {
    padding: 16px;
    border-radius: var(--radius);
  }

  .logs-account-filter .input-select {
    min-width: 160px;
  }
}


/* ============================================================================
   能力标签（Token 表「能力」列）
   ----------------------------------------------------------------------------
   四个独立开关（视频 / 4K / 高品质 / 免费号）合并进一列。用紧凑标签而不是
   开关滑块：滑块每个要占 38px + 文字，四个就撑爆表格；标签靠底色区分开关态，
   同样一眼可辨，占位只有三分之一。
   ============================================================================ */

.cap-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.cap-chip {
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.5;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.cap-chip:hover {
  border-color: var(--accent-line);
  color: var(--text-2);
}

.cap-chip.on {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-bright);
}

/* 「免费号」是账号属性而非能力开关，用信息色区分，避免和能力开关混为一谈 */
.cap-chip.on.accent {
  background: var(--info-soft);
  border-color: rgba(48, 170, 255, 0.42);
  color: var(--info);
}

.cap-chip.off {
  background: transparent;
}
