/*
 * Turb Console 基础样式
 *
 * 当前管理界面与登录页共用的视觉变量和基础样式。
 * 下方变量别名继续供现有模块使用，保留其 DOM 与 JavaScript 契约。
 */

:root {
  /* palette:start — Dispatch board palette. Every legacy colour in the console is mapped onto these ramps. */
  --n-0: #ffffff;
  --n-25: #fafbf9;
  --n-50: #f4f6f2;
  --n-100: #eceeea;
  --n-150: #e3e6e0;
  --n-200: #d8dcd5;
  --n-300: #c3c9c1;
  --n-400: #9da59e;
  --n-500: #78817a;
  --n-600: #5a635c;
  --n-700: #424a45;
  --n-800: #2c3330;
  --n-900: #1c2321;
  --a-50: #f1f3fe;
  --a-100: #e4e8fc;
  --a-200: #c8d0f7;
  --a-300: #9baaf0;
  --a-400: #6b80e6;
  --a-500: #2f4bd8;
  --a-600: #2840ba;
  --a-700: #213496;
  --g-50: #eff7f1;
  --g-100: #dceee2;
  --g-200: #b5dbc2;
  --g-300: #7fbf97;
  --g-400: #47a06c;
  --g-500: #1f7a4d;
  --g-600: #19663f;
  --g-700: #134e31;
  --w-50: #fdf7ea;
  --w-100: #f9eccf;
  --w-200: #f0d59c;
  --w-300: #e2b55e;
  --w-400: #cc8b1f;
  --w-500: #a65f00;
  --w-600: #8a4e00;
  --w-700: #6a3c00;
  --r-50: #fdf3f1;
  --r-100: #fae3df;
  --r-200: #f2bfb7;
  --r-300: #e58f82;
  --r-400: #d45e4f;
  --r-500: #c0362c;
  --r-600: #a22c24;
  --r-700: #80231c;
  /* palette:end */

  /* Color roles */
  /* "Brand" is the ink you act with; cobalt is kept for links and focus. */
  --ui-color-brand: var(--n-900);
  --ui-color-brand-hover: var(--n-700);
  --ui-color-brand-soft: var(--n-100);
  --ui-color-link: var(--a-500);
  --ui-color-ink: var(--n-900);
  --ui-color-ink-hover: var(--n-800);
  --ui-color-bg: var(--n-100);
  --ui-color-surface: var(--n-0);
  --ui-color-surface-subtle: var(--n-50);
  --ui-color-surface-raised: var(--n-25);
  --ui-color-border: var(--n-200);
  --ui-color-border-strong: var(--n-300);
  --ui-color-text: var(--n-900);
  --ui-color-text-secondary: var(--n-600);
  --ui-color-text-muted: var(--n-500);
  --ui-color-text-subtle: var(--n-400);
  --ui-color-success: var(--g-500);
  --ui-color-success-soft: var(--g-50);
  --ui-color-success-border: var(--g-200);
  --ui-color-warning: var(--w-500);
  --ui-color-warning-soft: var(--w-50);
  --ui-color-warning-border: var(--w-200);
  --ui-color-danger: var(--r-500);
  --ui-color-danger-soft: var(--r-50);
  --ui-color-danger-border: var(--r-200);
  --ui-color-info: var(--a-500);
  --ui-color-info-soft: var(--a-50);
  --ui-color-sidebar: var(--n-150);
  --ui-color-sidebar-text: var(--n-600);
  --ui-color-sidebar-muted: var(--n-500);

  /* Typography: Archivo carries Latin text and figures; CJK falls through to the system face. */
  --ui-font-sans: "Archivo Console", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  --ui-font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ui-font-size-xs: 12px;
  --ui-font-size-sm: 12.5px;
  --ui-font-size-md: 13px;
  --ui-font-size-lg: 15px;
  --ui-font-size-xl: 19px;
  --ui-font-size-page: 24px;
  --ui-line-height-tight: 1.25;
  --ui-line-height-normal: 1.5;

  /* Spacing and shape: sheets 10px, controls 7px, badges 4px. */
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-5: 20px;
  --ui-space-6: 24px;
  --ui-space-8: 32px;
  --ui-radius-xs: 4px;
  --ui-radius-sm: 6px;
  --ui-radius-md: 7px;
  --ui-radius-lg: 10px;
  --ui-radius-xl: 12px;
  --ui-radius-pill: 999px;
  --ui-shadow-sm: none;
  --ui-shadow-md: 0 18px 48px rgba(28, 35, 33, .16), 0 2px 6px rgba(28, 35, 33, .08);
  --ui-shadow-pop: 0 10px 28px rgba(28, 35, 33, .14), 0 1px 3px rgba(28, 35, 33, .08);

  /* 现有模块使用的变量别名；新增样式使用上方 --ui-* 语义变量。 */
  --bg: var(--ui-color-bg);
  --surface: var(--ui-color-surface);
  --soft: var(--ui-color-surface-subtle);
  --text: var(--ui-color-text);
  --muted: var(--ui-color-text-secondary);
  --line: var(--ui-color-border);
  --blue: var(--ui-color-brand);
  --green: var(--ui-color-success);
  --red: var(--ui-color-danger);
  --amber: var(--ui-color-warning);
  --sidebar-accent: var(--n-900);
  --sidebar-accent-soft: var(--n-200);
  --sidebar-width: 216px;
  --page-gutter: 20px;
  --topbar-height: 60px;
  --shadow-sm: none;
}

html {
  color-scheme: light;
  scrollbar-gutter: stable;
  text-size-adjust: 100%;
}

body {
  font-family: var(--ui-font-sans);
  font-size: var(--ui-font-size-md);
  line-height: var(--ui-line-height-normal);
  color: var(--ui-color-text);
  background: var(--ui-color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

button,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ui-color-brand) 24%, transparent);
  outline-offset: 2px;
}

input,
textarea,
select {
  color: var(--ui-color-text);
  border-color: var(--ui-color-border-strong);
  background: var(--ui-color-surface);
  border-radius: var(--ui-radius-md);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--ui-color-text-subtle);
}

input:hover:not(:disabled),
textarea:hover:not(:disabled),
select:hover:not(:disabled) {
  border-color: var(--n-300);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--a-300);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--a-500) 10%, transparent);
  outline: none;
}

/* App shell */
.app-sidebar {
  width: var(--sidebar-width);
  padding: var(--ui-space-3);
  background: var(--ui-color-sidebar);
  color: var(--n-0);
  border: 0;
  box-shadow: 14px 0 40px rgba(17, 19, 33, .09);
}

.sidebar-brand {
  min-height: 48px;
  height: auto;
  padding: 0 8px 8px;
  border-bottom-color: rgba(255, 255, 255, .09);
}

.sidebar-brand-title {
  font-size: 15px;
  line-height: var(--ui-line-height-tight);
}

.sidebar-brand-subtitle,
.sidebar-nav-group-label {
  color: var(--ui-color-sidebar-muted);
}

.sidebar-nav {
  padding: 12px 0;
  gap: 2px;
}

.app-sidebar .sidebar-nav button,
.app-sidebar .sidebar-nav button.sidebar-item {
  min-height: 36px;
  padding: 7px 10px;
  border-radius: var(--ui-radius-md);
  color: var(--ui-color-sidebar-text);
  font-size: var(--ui-font-size-sm);
  font-weight: 650;
}

.app-sidebar .sidebar-nav button:hover {
  color: var(--n-0);
  background: rgba(255, 255, 255, .06);
}

.app-sidebar .sidebar-nav button.active {
  color: var(--n-0);
  background: linear-gradient(100deg, color-mix(in srgb, var(--a-500) 34%, transparent), color-mix(in srgb, var(--a-500) 14%, transparent));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--a-300) 14%, transparent);
}

.sidebar-item-meta {
  min-width: 22px;
  height: 20px;
  border-radius: var(--ui-radius-pill);
  font-size: 10px;
}

.app-topbar {
  height: var(--topbar-height);
  padding-inline: var(--page-gutter);
  border-bottom-color: color-mix(in srgb, var(--n-150) 92%, transparent);
  background: rgba(248, 249, 252, .90);
}

.topbar-eyebrow,
.data-panel-kicker {
  color: var(--ui-color-text-subtle);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .11em;
}

.topbar-title {
  color: var(--ui-color-text);
  font-size: var(--ui-font-size-xl);
  line-height: var(--ui-line-height-tight);
}

.topbar-description {
  color: var(--ui-color-text-muted);
  font-size: var(--ui-font-size-xs);
}

.system-health {
  min-height: 30px;
  border-color: var(--ui-color-border);
  border-radius: var(--ui-radius-pill);
  color: var(--ui-color-text-secondary);
  font-size: var(--ui-font-size-xs);
}

main {
  margin-top: calc(var(--topbar-height) + 12px);
  margin-bottom: var(--ui-space-4);
}

/* Shared surfaces */
section.card,
.accounts-panel-v2,
.account-tasks-panel,
.codex-panel-v2,
.overview-panel,
.overview-metric {
  border-color: var(--ui-color-border);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-sm);
}

.data-panel-title,
.overview-panel-head h3 {
  color: var(--ui-color-text);
  font-size: var(--ui-font-size-lg);
  line-height: var(--ui-line-height-tight);
}

.data-panel-copy,
.overview-panel-head span {
  color: var(--ui-color-text-muted);
}

/* Shared control hierarchy */
button.btn,
.jobs-tb-btn,
.actions button,
.pager-bar button,
.overview-panel-head button {
  min-height: 30px;
  padding-inline: 9px;
  border: 1px solid var(--ui-color-border-strong);
  border-radius: var(--ui-radius-md);
  color: var(--ui-color-text-secondary);
  background: var(--ui-color-surface);
  font-size: var(--ui-font-size-xs);
  font-weight: 700;
  transition: border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease;
}

button.btn:hover:not(:disabled),
.jobs-tb-btn:hover:not(:disabled),
.actions button:hover:not(:disabled),
.pager-bar button:hover:not(:disabled),
.overview-panel-head button:hover:not(:disabled) {
  border-color: var(--n-300);
  color: var(--ui-color-text);
  background: var(--ui-color-surface-subtle);
}

button.btn.primary,
.jobs-tb-btn--primary,
.overview-refresh {
  border-color: var(--ui-color-brand);
  color: var(--n-0);
  background: var(--ui-color-brand);
  box-shadow: 0 7px 16px color-mix(in srgb, var(--a-500) 16%, transparent);
}

button.btn.primary:hover:not(:disabled),
.jobs-tb-btn--primary:hover:not(:disabled),
.overview-refresh:hover:not(:disabled) {
  border-color: var(--ui-color-brand-hover);
  background: var(--ui-color-brand-hover);
}

button.btn.good,
.jobs-tb-btn--good,
.actions button.good {
  border-color: var(--g-300);
  color: var(--g-600);
  background: var(--ui-color-success-soft);
}

button.btn.danger,
.jobs-tb-btn--danger,
.actions button.danger {
  border-color: var(--r-200);
  color: var(--ui-color-danger);
  background: var(--ui-color-danger-soft);
}

button:disabled,
button.btn:disabled,
.jobs-tb-btn:disabled,
.actions button:disabled {
  color: var(--n-400);
  background: var(--n-50);
  border-color: var(--ui-color-border);
  box-shadow: none;
}

/* Shared status language */
.pill {
  min-height: 24px;
  padding: 3px 9px;
  border-radius: var(--ui-radius-pill) !important;
  font-size: var(--ui-font-size-xs);
  font-weight: 700 !important;
  line-height: 1.2;
}

.status-success,
.status-available {
  color: var(--ui-color-success) !important;
  background: var(--ui-color-success-soft) !important;
}

.status-running,
.status-stopping,
.status-pending {
  color: var(--ui-color-warning) !important;
  background: var(--ui-color-warning-soft) !important;
}

.status-failed {
  color: var(--ui-color-danger) !important;
  background: var(--ui-color-danger-soft) !important;
}

.status-used,
.status-cancelled,
.status-stopped,
.status-disabled,
.status-skipped {
  color: var(--ui-color-text-muted) !important;
  background: var(--n-100) !important;
}

/* Tables and list scaffolding */
.accounts-table-v2-wrap,
.codex-table-v2-wrap {
  border-top-color: var(--ui-color-border);
  scrollbar-color: var(--n-300) transparent;
}

table {
  font-size: var(--ui-font-size-sm);
}

th,
td {
  border-bottom-color: var(--n-100);
}

th,
.accounts-table-v2 thead th,
.codex-table-v2 thead th {
  color: var(--ui-color-text-muted);
  background: var(--ui-color-surface-subtle);
  font-size: var(--ui-font-size-xs);
  font-weight: 750;
}

tr:hover td,
.accounts-table-v2 tbody tr:hover td,
.codex-table-v2 tbody tr:hover td {
  background: var(--n-25);
}

.list-state-row:hover .table-state-cell,
.list-state-row .table-state-cell {
  height: 210px !important;
  padding: 28px !important;
  overflow: visible !important;
  color: var(--ui-color-text-secondary);
  background: var(--ui-color-surface) !important;
  text-align: center;
  text-overflow: clip !important;
  white-space: normal !important;
}

.table-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  min-height: 150px;
}

.table-state strong {
  color: var(--ui-color-text);
  font-size: var(--ui-font-size-md);
  font-weight: 750;
}

.table-state small {
  max-width: 360px;
  color: var(--ui-color-text-muted);
  font-size: var(--ui-font-size-xs);
  line-height: 1.55;
}

.table-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-bottom: 3px;
  border-radius: var(--ui-radius-lg);
  color: var(--ui-color-text-subtle);
  background: var(--ui-color-surface-subtle);
}

.table-state-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.table-state.is-error .table-state-icon {
  color: var(--ui-color-danger);
  background: var(--ui-color-danger-soft);
}

.table-state-spinner {
  width: 24px;
  height: 24px;
  margin-bottom: 8px;
  border: 2px solid var(--a-100);
  border-top-color: var(--ui-color-brand);
  border-radius: 50%;
  animation: table-state-spin .8s linear infinite;
}

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

.sub-cell,
.muted,
.pager-bar .pager-info {
  color: var(--ui-color-text-muted);
}

/* List pages: make the page title, selection actions, and row content read as
   one deliberate hierarchy instead of a wall of controls. */

/* Account assets: keep the heading in the fixed-height list layout. */

.acc-v2-email-link {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.acc-v2-email-link:hover .acc-v2-email {
  color: var(--ui-color-brand-hover);
}

.acc-v2-email-link:focus-visible {
  outline: 2px solid var(--ui-color-brand);
  outline-offset: 3px;
}

/* Keep secondary actions visually quieter than the primary selection actions. */

/* Account detail drawer */
.account-detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 4800;
  background: color-mix(in srgb, var(--a-700) 42%, transparent);
  backdrop-filter: blur(2px);
}

.account-detail-drawer {
  position: fixed;
  z-index: 4900;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(520px, calc(100vw - 24px));
  padding: 24px;
  overflow: auto;
  border-left: 1px solid var(--ui-color-border);
  background: var(--ui-color-surface);
  box-shadow: -18px 0 40px color-mix(in srgb, var(--a-700) 18%, transparent);
}

.account-detail-drawer.hidden,
.account-detail-backdrop.hidden {
  display: none !important;
}

.account-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ui-space-4);
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ui-color-border);
}

.account-detail-head h2 {
  max-width: 420px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ui-color-text);
  font-size: 20px;
  line-height: 1.25;
  text-overflow: clip;
  white-space: nowrap;
}

.account-detail-head p {
  margin-top: 5px;
  color: var(--ui-color-text-muted);
  font-size: var(--ui-font-size-xs);
}

.account-detail-close {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--ui-color-border-strong);
  border-radius: var(--ui-radius-md);
  color: var(--ui-color-text-secondary);
  background: var(--ui-color-surface);
  font-size: 22px;
  line-height: 1;
}

.account-detail-close:hover {
  color: var(--ui-color-text);
  background: var(--ui-color-surface-subtle);
}

/* Protocol-only email change dialog */
.email-change-modal {
  position: fixed;
  z-index: 5000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--a-700) 48%, transparent);
  backdrop-filter: blur(2px);
}

.email-change-modal.hidden {
  display: none !important;
}

.email-change-dialog {
  width: min(520px, 100%);
  max-height: min(720px, calc(100dvh - 32px));
  overflow: auto;
  border: 1px solid var(--ui-color-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-color-surface);
  box-shadow: var(--ui-shadow-lg, 0 20px 50px color-mix(in srgb, var(--a-700) 20%, transparent));
}

.email-change-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ui-space-4);
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--ui-color-border);
}

.email-change-head h2 {
  margin-top: 4px;
  color: var(--ui-color-text);
  font-size: 20px;
  line-height: 1.25;
}

.email-change-head p {
  max-width: 390px;
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: var(--ui-color-text-muted);
  font-size: var(--ui-font-size-xs);
  line-height: 1.5;
}

.email-change-modal .account-detail-close {
  width: 44px;
  height: 44px;
}

.email-change-form {
  display: grid;
  gap: 16px;
  padding: 20px 22px 22px;
}

.email-change-field {
  display: grid;
  gap: 7px;
  color: var(--ui-color-text-secondary);
  font-size: var(--ui-font-size-sm);
  font-weight: 650;
}

.email-change-field select {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--ui-color-border-strong);
  border-radius: var(--ui-radius-md);
  color: var(--ui-color-text);
  background: var(--ui-color-surface);
  font: inherit;
  font-weight: 400;
}

.email-change-field select:focus-visible,
.email-change-modal button:focus-visible {
  outline: 2px solid var(--ui-color-brand);
  outline-offset: 2px;
}

.email-change-field small {
  color: var(--ui-color-text-muted);
  font-size: var(--ui-font-size-xs);
  font-weight: 400;
  line-height: 1.5;
}

.email-change-field .email-change-error {
  color: var(--ui-color-danger);
}

.email-change-note {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--a-500) 20%, transparent);
  border-radius: var(--ui-radius-md);
  color: var(--ui-color-text-secondary);
  background: var(--ui-color-brand-soft, color-mix(in srgb, var(--a-500) 6%, transparent));
  font-size: var(--ui-font-size-xs);
  line-height: 1.55;
}

.email-change-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}

.account-detail-body {
  display: grid;
  gap: 20px;
  padding-top: 20px;
}

.account-detail-section {
  display: grid;
  gap: 10px;
}

.account-detail-section-title {
  color: var(--ui-color-text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.account-detail-section-copy {
  margin: -2px 0 2px;
  color: var(--ui-color-text-subtle);
  font-size: 11px;
  line-height: 1.45;
}

.account-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.account-detail-state {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--n-100);
  border-radius: var(--ui-radius-md);
  background: var(--n-25);
}

.account-detail-label {
  color: var(--ui-color-text-muted);
  font-size: 11px;
}

.account-detail-state-value {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  margin-top: 6px;
}

.account-detail-state-value strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ui-color-text);
  font-size: 13px;
  text-overflow: clip;
  white-space: nowrap;
}

.account-detail-state small {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: var(--ui-color-text-subtle);
  font-size: 11px;
  line-height: 1.4;
  text-overflow: clip;
  white-space: nowrap;
}

.account-detail-note {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--ui-color-border);
  border-radius: var(--ui-radius-md);
  background: var(--ui-color-surface-subtle);
}

.account-detail-note span {
  color: var(--ui-color-text-muted);
  font-size: 11px;
  font-weight: 750;
}

.account-detail-note p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ui-color-text-secondary);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.account-detail-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--n-400);
}

.account-detail-dot--success { background: var(--ui-color-success); }
.account-detail-dot--info { background: var(--ui-color-brand); }
.account-detail-dot--warning { background: var(--ui-color-warning); }
.account-detail-dot--danger { background: var(--ui-color-danger); }

@media (max-width: 560px) {

  .account-detail-drawer {
    width: 100%;
    padding: 18px 14px;
  }

  .account-detail-grid {
    grid-template-columns: 1fr;
  }

  .email-change-modal {
    padding: 10px;
  }

  .email-change-dialog {
    max-height: calc(100dvh - 20px);
  }

  .email-change-head,
  .email-change-form {
    padding-inline: 16px;
  }

  .email-change-foot {
    flex-direction: column-reverse;
  }

  .email-change-foot button {
    width: 100%;
    min-height: 44px;
  }
}

/* Configuration workspace */

.config-dirty-badge[hidden] {
  display: none;
}

.config-dirty-badge {
  color: var(--w-300);
  background: color-mix(in srgb, var(--w-500) 18%, transparent);
}

.app-sidebar .sidebar-item.active .config-dirty-badge {
  color: var(--w-300);
  background: color-mix(in srgb, var(--w-500) 25%, transparent);
}

#tab-config [data-save-config-v2] {
  min-width: 104px;
}

#tab-config [data-save-config-v2]:disabled {
  color: var(--ui-color-text-muted);
  border-color: var(--ui-color-border);
  background: var(--n-100);
  box-shadow: none;
  cursor: default;
  opacity: 1;
}

@keyframes config-save-pulse {
  50% { opacity: .35; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .table-state-spinner { animation: none; }
}

/* Proxy and traffic workspace. The tables keep the dense operational rhythm
   of the existing list pages while the scroll container owns narrow screens. */
.proxy-traffic-page {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: var(--ui-space-4);
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  height: calc(100vh - var(--topbar-height) - 42px);
  height: calc(100dvh - var(--topbar-height) - 42px);
}

#tab-proxy-traffic[data-module-view="pool"] [data-proxy-module-panel="records"],
#tab-proxy-traffic[data-module-view="records"] [data-proxy-module-panel="pool"] { display: none; }

.proxy-traffic-page .column-filter-trigger:focus-visible,
.proxy-traffic-page .column-filter-clear-inline:focus-visible,
.proxy-traffic-page .column-filter-option:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ui-color-brand) 24%, transparent);
  outline-offset: 2px;
}

.proxy-traffic-page .column-filter-header {
  overflow: visible;
  text-overflow: clip;
  transition: color .16s ease, box-shadow .16s ease;
}

.proxy-traffic-page .column-filter-header.has-filter-value {
  color: var(--ui-color-brand);
  box-shadow: inset 0 -2px var(--ui-color-brand);
}

.proxy-traffic-page .column-filter-trigger {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 24px;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.proxy-traffic-page .column-filter-trigger:hover { color: var(--ui-color-brand); }
.proxy-traffic-page .column-filter-trigger-label { min-width: 0; overflow: hidden; text-overflow: clip; }

.proxy-traffic-page .column-filter-trigger-icon,
.proxy-traffic-page .column-filter-search-icon,
.proxy-traffic-page .column-filter-option-check {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.proxy-traffic-page .column-filter-trigger-icon { color: var(--ui-color-text-subtle); }
.proxy-traffic-page .has-filter-value .column-filter-trigger-icon { color: var(--ui-color-brand); }

.proxy-traffic-page .column-filter-search {
  display: none;
  width: 100%;
  min-width: 0;
  min-height: 28px;
  align-items: center;
  gap: 3px;
}

.proxy-traffic-page .column-filter-header.is-searching .column-filter-trigger { display: none; }
.proxy-traffic-page .column-filter-header.is-searching .column-filter-search { display: flex; }
.proxy-traffic-page .column-filter-search-icon { color: var(--ui-color-brand); }

.proxy-traffic-page .column-filter-search input {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  min-height: 28px;
  margin: 0;
  padding: 0 6px;
  border: 1px solid var(--ui-color-border-strong);
  border-radius: var(--ui-radius-sm);
  color: var(--ui-color-text);
  background: var(--ui-color-surface);
  font: inherit;
  font-size: 11px;
  outline: none;
}

.proxy-traffic-page .column-filter-search input:focus {
  border-color: var(--ui-color-brand);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ui-color-brand) 14%, transparent);
}

.proxy-traffic-page .column-filter-clear-inline {
  display: inline-flex;
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-sm);
  color: var(--ui-color-text-muted);
  background: transparent;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.proxy-traffic-page .column-filter-clear-inline:hover { color: var(--ui-color-brand); background: var(--ui-color-brand-soft); }
.proxy-traffic-page .column-filter-native { display: none !important; }

.proxy-traffic-page .column-filter-popover {
  position: fixed;
  z-index: 4200;
  display: none;
  width: min(208px, calc(100vw - 20px));
  padding: 6px;
  border: 1px solid var(--ui-color-border);
  border-radius: var(--ui-radius-md);
  color: var(--ui-color-text-secondary);
  background: var(--ui-color-surface);
  box-shadow: var(--ui-shadow-md);
  text-align: left;
}

.proxy-traffic-page .column-filter-header.is-filter-open .column-filter-popover { display: grid; gap: 5px; }
.proxy-traffic-page .column-filter-options { max-height: min(312px, calc(100vh - 40px)); overflow: auto; overscroll-behavior: contain; }

.proxy-traffic-page .column-filter-option {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--ui-radius-sm);
  color: var(--ui-color-text-secondary);
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 680;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.proxy-traffic-page .column-filter-option:hover,
.proxy-traffic-page .column-filter-option:focus-visible,
.proxy-traffic-page .column-filter-option[aria-checked="true"] {
  color: var(--ui-color-brand);
  background: var(--ui-color-brand-soft);
}

.proxy-traffic-page .column-filter-option-check { color: var(--ui-color-brand); opacity: 0; stroke-width: 2.2; }
.proxy-traffic-page .column-filter-option[aria-checked="true"] .column-filter-option-check { opacity: 1; }

.proxy-traffic-detail-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: min(80vh, 760px);
  padding: 0;
  border: 1px solid var(--ui-color-border);
  border-radius: var(--ui-radius-md);
  color: var(--ui-color-text);
  background: var(--ui-color-surface);
  box-shadow: var(--ui-shadow-md);
}

.proxy-traffic-detail-dialog::backdrop { background: rgb(12 20 37 / 52%); }

@media (max-height: 740px) {
  .proxy-traffic-page {
    height: auto;
  }
}

@media (max-height: 500px) and (min-width: 561px) {
  #tab-proxy-traffic { gap: 4px; }
}

@media (max-width: 860px) {
  .accounts-table-v2-wrap,
  .codex-table-v2-wrap {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }

  table[data-resizable-table="jobs"] { min-width: 1120px !important; }
  table[data-resizable-table="accounts"] { min-width: 1180px !important; }
  table[data-resizable-table="codex"] { min-width: 980px !important; }
  table[data-resizable-table="outlook"] { min-width: 860px !important; }
}

@media (max-width: 560px) {
  .list-state-row:hover .table-state-cell,
  .list-state-row .table-state-cell {
    height: 180px !important;
    padding: 20px !important;
  }

  .table-state {
    align-items: flex-start;
    min-height: 120px;
    text-align: left;
  }
}

/* Dense data workspaces: keep the action bar and pager in view while the
   table body owns the scroll area. */
#tab-accounts:not([data-module-view="tasks"]) #accountsPanelV2 {
  min-height: 0;
  height: calc(100vh - var(--topbar-height) - 42px);
  height: calc(100dvh - var(--topbar-height) - 42px);
  display: flex;
  flex-direction: column;
}

/* 任务中心复用账号标签容器，空弹窗挂载点无需占用网格行距。 */
main:has(> #tab-accounts[data-module-view="tasks"]:not(.hidden)) {
  --task-center-top-gap: var(--ui-space-2);
  --task-center-bottom-gap: max(var(--ui-space-2), env(safe-area-inset-bottom));
  margin-block: calc(var(--topbar-height) + var(--task-center-top-gap)) var(--task-center-bottom-gap);
}

#tab-accounts[data-module-view="tasks"]:not(.hidden) {
  row-gap: 0;
}

#tab-accounts[data-module-view="tasks"] #accountTasksPanel {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--topbar-height) - var(--task-center-top-gap) - var(--task-center-bottom-gap));
  min-height: 0;
}

#tab-accounts #accountsPanelV2 > .accounts-command-deck,
#tab-accounts #accountsPanelV2 > .column-filter-summary,
#tab-accounts #accountsPanelV2 > .jobs-v2-pager {
  flex: 0 0 auto;
}

#tab-accounts:not([data-module-view="tasks"]) #accountsPanelV2 > .accounts-table-v2-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

/* 批量任务回执独立滚动，避免展开后挤出任务工具栏与表格。 */

.operation-receipts-header-v2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.operation-receipts-header-v2 strong {
  color: var(--ui-color-text);
}

.operation-receipts-header-v2 p {
  flex: 1 1 240px;
  margin: 0;
  color: var(--ui-color-text-secondary);
  overflow-wrap: anywhere;
}

.operation-receipts-details-v2 > summary {
  display: list-item;
  width: fit-content;
  max-width: 100%;
  min-height: 36px;
  padding: 8px 0;
  color: var(--ui-color-brand);
  cursor: pointer;
}

.operation-receipts-list-v2 {
  max-height: min(220px, 24dvh);
  overflow: auto;
  overscroll-behavior: contain;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  scrollbar-gutter: stable;
}

.operation-receipt-row-v2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 6px 0;
  border-top: 1px solid var(--ui-color-border);
}

.operation-receipt-row-v2 .jobs-tb-btn {
  max-width: 100%;
  height: auto;
  min-height: 36px;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
}

.operation-receipt-message-v2 {
  min-width: 0;
  color: var(--ui-color-text-secondary);
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .operation-receipts-header-v2 p { flex-basis: 100%; order: 1; }
  .operation-receipts-header-v2 > button { margin-left: auto; }
  #codexToolbarV2 #btnCodexUploadProgressV2 { min-height: 44px; grid-column: 1 / -1; }
  .operation-receipts-details-v2 > summary,
  .operation-receipt-row-v2 .jobs-tb-btn { min-height: 44px; }
}

/* Make horizontal overflow discoverable on desktop and mobile. */
.accounts-table-v2-wrap,
.codex-table-v2-wrap,
.account-tasks-table-wrap {
  scrollbar-width: auto;
  scrollbar-color: var(--n-400) var(--n-100);
  scrollbar-gutter: stable;
}

.accounts-table-v2-wrap::-webkit-scrollbar,
.codex-table-v2-wrap::-webkit-scrollbar,
.account-tasks-table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.accounts-table-v2-wrap::-webkit-scrollbar-track,
.codex-table-v2-wrap::-webkit-scrollbar-track,
.account-tasks-table-wrap::-webkit-scrollbar-track {
  background: var(--n-100);
}

.accounts-table-v2-wrap::-webkit-scrollbar-thumb,
.codex-table-v2-wrap::-webkit-scrollbar-thumb,
.account-tasks-table-wrap::-webkit-scrollbar-thumb {
  border: 2px solid var(--n-100);
  border-radius: 999px;
  background: var(--n-400);
}

/* Account rows carry rich state, but the list itself should scan at one line
   per account; the detail drawer remains the place for full metadata. */
.accounts-table-v2 th,
.accounts-table-v2 td {
  padding-top: 6px;
  padding-bottom: 6px;
}

.accounts-table-v2 tbody tr,
.accounts-table-v2 tbody td {
  height: 50px;
}

.accounts-table-v2 .acc-v2-email-link,
.accounts-table-v2 .acc-v2-email {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.accounts-table-v2 .acc-v2-email-link {
  width: auto;
  max-width: 100%;
}

.accounts-table-v2 .acc-v2-sub {
  display: none;
}

/* 套餐列同时承载提炼结果；该状态不能被账号行的单行扫描规则隐藏。 */
.accounts-table-v2 .col-plan > .acc-v2-sub {
  display: inline-block;
  margin: 0 0 0 4px;
  max-width: none;
  overflow: visible;
  vertical-align: middle;
  white-space: nowrap;
}

.accounts-table-v2 .col-plan .extract-link-cell .pill.status-failed {
  min-width: 0;
  padding-left: 6px;
  padding-right: 6px;
  font-size: 12px;
}

.accounts-table-v2 .col-plan .extract-link-cell {
  margin-top: 0;
  white-space: nowrap;
}

/* Token 单元格只显示一个可点击状态；状态按钮本身负责复制完整 Token。 */
.accounts-table-v2 .col-token {
  width: 126px;
}

.accounts-table-v2 .acc-v2-token-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  vertical-align: middle;
  white-space: nowrap;
  cursor: pointer;
}

.accounts-table-v2 .acc-v2-token-state.is-normal {
  color: var(--g-700);
  border-color: var(--g-300);
  background: var(--n-50);
}

.accounts-table-v2 .acc-v2-token-state.is-expired {
  color: var(--w-600);
  border-color: var(--w-300);
  background: var(--w-100);
}

.accounts-table-v2 .acc-v2-token-state.is-invalid {
  color: var(--r-500);
  border-color: var(--r-300);
  background: var(--n-50);
}

.accounts-table-v2 .acc-v2-token-state:hover:not(:disabled) {
  filter: brightness(.97);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--a-500) 8%, transparent);
}

.accounts-table-v2 .acc-v2-token-state:disabled {
  cursor: wait;
  opacity: .62;
}

.accounts-table-v2 .status-action-cell,
.accounts-table-v2 .extract-link-cell {
  flex-wrap: nowrap;
  gap: 5px;
  margin-top: 0;
  white-space: nowrap;
}

/* Codex rows use a single scan line and reserve just enough space for the
   action cluster; all longer values keep their full text in title tooltips. */
.codex-table-v2 {
  width: 100% !important;
  min-width: 100% !important;
  table-layout: auto;
}

table[data-resizable-table="jobs"],
table[data-resizable-table="accounts"],
table[data-resizable-table="codex"],
table[data-resizable-table="outlook"] {
  width: max-content;
  min-width: 100% !important;
}

table[data-resizable-table="accounts"] {
  min-width: 1280px !important;
}

/* Desktop account rows fit the panel; narrow screens keep the full-width
   table and its horizontal scrollbar so no account field is removed. */
@media (min-width: 1101px) {
  #accountsPanelV2 > .accounts-table-v2-wrap {
    overflow-x: auto;
  }

  #accountsPanelV2 table[data-resizable-table="accounts"] {
    width: max(100%, 1100px) !important;
    min-width: 0 !important;
    max-width: none !important;
    table-layout: fixed !important;
  }

  #accountsPanelV2 table[data-resizable-table="accounts"] th,
  #accountsPanelV2 table[data-resizable-table="accounts"] td {
    padding-left: 6px !important;
    padding-right: 6px !important;
    overflow: hidden !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
  }

  #accountsPanelV2 table[data-resizable-table="accounts"] th:first-child,
  #accountsPanelV2 table[data-resizable-table="accounts"] td:first-child {
    padding-left: 8px !important;
  }

  #accountsPanelV2 table[data-resizable-table="accounts"] th:last-child,
  #accountsPanelV2 table[data-resizable-table="accounts"] td:last-child {
    padding-right: 8px !important;
  }

  #accountsPanelV2 table[data-resizable-table="accounts"] .col-email,
  #accountsPanelV2 table[data-resizable-table="accounts"] .col-plan,
  #accountsPanelV2 table[data-resizable-table="accounts"] .col-trial,
  #accountsPanelV2 table[data-resizable-table="accounts"] .col-actions {
    overflow: hidden !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
  }

  #accountsPanelV2 table[data-resizable-table="accounts"] .acc-v2-email-link,
  #accountsPanelV2 table[data-resizable-table="accounts"] .acc-v2-email {
    display: block !important;
    max-width: 100%;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
  }

  #accountsPanelV2 table[data-resizable-table="accounts"] .status-action-cell,
  #accountsPanelV2 table[data-resizable-table="accounts"] .extract-link-cell {
    flex-wrap: nowrap;
    gap: 2px;
    max-width: 100%;
    overflow: hidden;
  }

  #accountsPanelV2 table[data-resizable-table="accounts"] .acc-v2-actions {
    gap: 2px;
    max-width: 100%;
    overflow: hidden;
  }
}

table[data-resizable-table="codex"] {
  width: 100% !important;
  min-width: 100% !important;
  table-layout: fixed !important;
}

.codex-table-v2 .acc-v2-email {
  display: block;
  max-width: 100%;
  margin-top: 0;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.codex-table-v2 .acc-v2-sub {
  display: none;
}

.codex-table-v2 tbody td {
  white-space: nowrap;
}

.codex-table-v2 tbody tr,
.codex-table-v2 tbody td {
  height: 50px;
}

@media (max-width: 860px) {
  #tab-accounts:not([data-module-view="tasks"]) #accountsPanelV2 {
    height: calc(100dvh - var(--topbar-height) - 26px);
  }

}

/* Dialogs and feedback */
#liveLogPanel:not(.hidden),
#qrPanel:not(.hidden) {
  border-color: var(--ui-color-border-strong);
  border-radius: var(--ui-radius-lg);
  box-shadow: 0 0 0 9999px color-mix(in srgb, var(--a-700) 46%, transparent), var(--ui-shadow-md);
}

#toast {
  border-radius: var(--ui-radius-md);
  background: var(--n-900);
  box-shadow: var(--ui-shadow-md);
}

@media (max-width: 860px) {
  /* The desktop width token is 0 on mobile; keep the drawer's real width so
     translateX(-110%) hides the whole sidebar, including its padding. */
  :root { --sidebar-width: 0px; --page-gutter: 12px; --topbar-height: 52px; }
  .app-sidebar {
    width: 252px;
    transform: translateX(-110%);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .app-topbar {
    padding-inline: var(--page-gutter);
  }

  .mobile-nav-toggle {
    border-color: var(--ui-color-border);
    border-radius: var(--ui-radius-md);
  }

  main {
    margin-top: calc(var(--topbar-height) + 10px);
  }
}

@media (max-width: 560px) {
  body {
    font-size: var(--ui-font-size-sm);
  }

  .topbar-title {
    font-size: 18px;
  }

  main {
    margin-bottom: var(--ui-space-6);
  }
}

/* Configuration workspace refresh: visual hierarchy, safe density, and one
   persistent save action for the whole page. */

#tab-config .config-section-v2-subhelp {
  margin-inline: var(--ui-space-5);
}

#tab-config .config-field-v2-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

#tab-config .config-field-label-v2 {
  min-width: 0;
  color: var(--ui-color-text);
  font-size: var(--ui-font-size-sm);
  font-weight: 730;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#tab-config .config-field-key-v2 {
  flex: 0 1 auto;
  min-width: 0;
  color: var(--ui-color-text-subtle);
  font: 10px/1.3 var(--ui-font-mono);
  overflow-wrap: anywhere;
  text-align: right;
}

@media (max-width: 600px) {

  #tab-config .config-section-v2-subhelp {
    margin-inline: 14px;
  }
}


/* Lifecycle settings use a compact settings-list pattern rather than
   repeating a card for every switch or driver. */

#tab-config .config-field-status-v2 {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 6px;
  padding: 2px 7px;
  border: 1px solid var(--ui-color-border);
  border-radius: 999px;
  color: var(--ui-color-text-muted);
  background: var(--ui-color-surface-subtle);
  font-size: 10px;
  font-weight: 650;
  vertical-align: 1px;
  white-space: nowrap;
}

#tab-config .config-field-status-v2.is-effective {
  border-color: color-mix(in srgb, var(--ui-color-success) 35%, var(--ui-color-border));
  color: var(--ui-color-success);
}

#tab-config .config-field-status-v2.is-pending,
#tab-config .config-field-status-v2.is-restart {
  border-color: color-mix(in srgb, var(--ui-color-warning) 40%, var(--ui-color-border));
  color: var(--ui-color-warning);
}

#tab-config .config-field-status-v2.is-error {
  border-color: color-mix(in srgb, var(--ui-color-danger) 40%, var(--ui-color-border));
  color: var(--ui-color-danger);
}

@media (max-width: 420px) {
  #tab-config .config-field-v2-head {
    display: grid;
    gap: 4px;
  }

  #tab-config .config-field-key-v2 {
    text-align: left;
  }
}

/* Configuration audit pass: custom content and dense forms use the same
   horizontal rail as the regular field cards. */

#tab-config .config-tool-panel-v2 > div:first-child {
  display: grid;
  gap: 6px;
  min-width: 0;
}

#tab-config .config-tool-panel-v2 > div:first-child b {
  color: var(--ui-color-text);
  font-size: var(--ui-font-size-sm);
  line-height: 1.35;
}

#tab-config .config-tool-panel-v2 .hint,
#tab-config .config-tool-panel-v2 .muted {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

#tab-config .config-tool-panel-v2 .row {
  min-width: 0;
  gap: 10px 14px;
}

#tab-config .config-tool-panel-v2 .row > * {
  min-width: 0;
}

#tab-config .config-tool-panel-v2 .row > :first-child {
  flex: 1 1 280px;
}

#tab-config .config-tool-panel-v2 .btn,
#tab-config .config-tool-panel-v2 select {
  min-height: 40px;
}

/* 配置页桌面端：锁定外层视口，只让导航列表和右侧配置内容滚动。 */
@media (min-width: 861px) {
  body:has(#tab-config:not(.hidden)) {
    overflow-y: hidden;
  }

  /* 待保存栏出现时，导航列表仍能滚动到最后一个菜单。 */
}

/* 账号表使用两条稳定内容轨道，横向滚动留在现有表格容器内。 */
#accountsPanelV2 table[data-resizable-table="accounts"] {
  --account-font-single: var(--ui-font-size-md);
  --account-font-main: var(--ui-font-size-sm);
  --account-font-sub: var(--ui-font-size-xs);
  width: 1396px !important;
  min-width: 0 !important;
  max-width: none !important;
  table-layout: fixed !important;
  font-size: var(--account-font-single);
}

#accountsPanelV2 > .accounts-table-v2-wrap {
  overflow-x: auto;
  scrollbar-gutter: auto;
}

/* 手柄完整放在所属表头内，避免跨到相邻列或额外产生横向溢出。 */
#accountsPanelV2 table[data-resizable-table="accounts"] th .table-col-resizer { right: 0; }
#accountsPanelV2 table[data-resizable-table="accounts"] th .table-col-resizer::after { left: 8px; }

#accountsPanelV2 table[data-resizable-table="accounts"] tbody tr,
#accountsPanelV2 table[data-resizable-table="accounts"] tbody td {
  height: var(--account-row-height, 50px);
}

#accountsPanelV2 table[data-resizable-table="accounts"] tbody td {
  padding-top: 1px !important;
  padding-bottom: 1px !important;
  vertical-align: middle !important;
  line-height: var(--ui-line-height-normal);
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-cell-lines {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 2px;
  min-width: 0;
  min-height: 0;
  height: calc(var(--account-row-height, 50px) - 4px);
  width: 100%;
  font-size: var(--account-font-main);
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-cell-line {
  display: flex;
  min-width: 0;
  min-height: 0;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  white-space: nowrap;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-cell-line:only-child {
  grid-row: 1 / -1;
  font-size: var(--account-font-single);
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-cell-line--sub {
  color: var(--n-500);
  font-size: var(--account-font-sub);
  line-height: var(--ui-line-height-normal);
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-cell-line button { flex: 0 0 auto; }

#accountsPanelV2 table[data-resizable-table="accounts"] .pill {
  min-height: 0;
  height: 22px;
  padding-top: 0;
  padding-bottom: 0;
  font-size: inherit;
  line-height: 20px;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-cell-line button,
#accountsPanelV2 table[data-resizable-table="accounts"] .acc-v2-actions > button,
#accountsPanelV2 table[data-resizable-table="accounts"] .acc-v2-more-btn {
  min-height: 22px;
  height: 22px;
  padding: 0 6px;
  font-size: inherit;
  line-height: 20px;
}

/* 单行放大，双行保持主次层级，控件继承所在内容行的字号。 */
#accountsPanelV2 table[data-resizable-table="accounts"] :is(.acc-v2-email-link, .acc-v2-token-copy, .acc-v2-account-status, .acc-v2-codex) {
  font-size: inherit;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-cell-line:only-child :is(button, .pill) {
  min-height: 26px;
  height: 26px;
  line-height: 24px;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .acc-v2-token-state {
  min-width: 0;
  max-width: 100%;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-time-label {
  flex: 0 0 auto;
  color: var(--n-500);
  font-size: inherit;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-times-cell { font-size: var(--account-font-sub); }
#accountsPanelV2 table[data-resizable-table="accounts"] td.col-time { padding-left: 6px !important; padding-right: 6px !important; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-times-cell .account-cell-line { gap: 3px; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-times-cell time {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .quota-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 2px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  height: calc(var(--account-row-height, 50px) - 4px);
  font-size: var(--account-font-main);
  line-height: var(--ui-line-height-normal);
}

#accountsPanelV2 table[data-resizable-table="accounts"] .col-quota {
  text-align: left;
}

#accountsPanelV2 table[data-resizable-table="accounts"] tbody td.col-quota,
#accountsPanelV2 table[data-resizable-table="accounts"] tbody td.col-trial {
  overflow: hidden !important;
  text-overflow: clip !important;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .quota-cell-line {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .quota-cell--single {
  grid-template-rows: minmax(0, 1fr);
  font-size: var(--account-font-single);
}

#accountsPanelV2 table[data-resizable-table="accounts"] .col-check {
  padding-left: 8px !important;
  padding-right: 4px !important;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .col-source,
#accountsPanelV2 table[data-resizable-table="accounts"] .col-id,
#accountsPanelV2 table[data-resizable-table="accounts"] .col-small,
#accountsPanelV2 table[data-resizable-table="accounts"] .col-time { font-variant-numeric: tabular-nums; }

#accountsPanelV2 table[data-resizable-table="accounts"] .col-actions .acc-v2-actions {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  justify-items: start;
  align-items: center;
  gap: 2px;
  min-height: 0;
  overflow: visible !important;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-cell--countries {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: calc(var(--account-row-height, 50px) - 12px);
  gap: 4px;
  align-items: center;
  font-size: var(--account-font-sub);
  line-height: var(--ui-line-height-tight);
}

/* 无国家前缀的单行状态占满内容区，避免落在双行布局的首行。 */
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-cell--single:has(> .account-promotion-country-row > .account-promotion-label:only-child) {
  grid-template-rows: minmax(0, 1fr);
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row {
  width: fit-content;
  max-width: 100%;
  height: auto;
  min-height: 0;
  overflow: hidden;
  justify-self: start;
  align-self: center;
  justify-content: flex-start;
  font-size: inherit;
  line-height: inherit;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country {
  font-size: inherit;
}

/* 单条与多条优惠共用首行轨道，国家前缀等宽以对齐优惠文字。 */
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row:not(.is-stale) .account-promotion-country {
  width: 2.5em;
  flex-basis: 2.5em;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-stale {
  padding-top: 0;
  padding-bottom: 0;
  font-size: var(--account-font-sub);
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row .account-promotion-label {
  text-overflow: clip;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row > .account-promotion-label:only-child {
  color: inherit;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-summary {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: visible !important;
  cursor: help;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-summary-count,
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-summary-badge {
  flex: 0 0 auto;
  white-space: nowrap;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-summary-count {
  color: var(--n-600);
  font-size: var(--account-font-sub);
  font-weight: 700;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-summary-badge {
  padding: 1px 4px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: var(--account-font-sub);
  font-weight: 700;
  line-height: 1.2;
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-summary-badge.is-failed {
  color: var(--r-500);
  background: var(--n-50);
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-summary-badge.is-stale {
  color: var(--n-500);
  background: var(--n-50);
}

#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row {
  box-sizing: border-box;
  padding: 0 6px;
  border: 1px solid var(--n-150);
  background: var(--n-25);
}

/* palette:start — 国家行使用独立的分类色区分国家，不属于状态色，颜色映射跳过。 */
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-0 { color: #1d4ed8; border-color: #bfdbfe; background: #eff6ff; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-1 { color: #047857; border-color: #a7f3d0; background: #ecfdf5; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-2 { color: #7e22ce; border-color: #e9d5ff; background: #faf5ff; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-3 { color: #b45309; border-color: #fde68a; background: #fffbeb; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-4 { color: #be123c; border-color: #fecdd3; background: #fff1f2; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-5 { color: #0f766e; border-color: #99f6e4; background: #f0fdfa; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-6 { color: #4338ca; border-color: #c7d2fe; background: #eef2ff; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-7 { color: #0e7490; border-color: #a5f3fc; background: #ecfeff; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-8 { color: #3f6212; border-color: #d9f99d; background: #f7fee7; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-9 { color: #0369a1; border-color: #bae6fd; background: #f0f9ff; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-10 { color: #a21caf; border-color: #f5d0fe; background: #fdf4ff; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-11 { color: #854d0e; border-color: #fef08a; background: #fefce8; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-12 { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-13 { color: #9d174d; border-color: #fbcfe8; background: #fdf2f8; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-14 { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
#accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row.is-country-15 { color: #6d28d9; border-color: #ddd6fe; background: #f5f3ff; }
/* palette:end */

@media (max-width: 860px) {
  #accountsPanelV2 table[data-resizable-table="accounts"] { --account-row-height: 60px; }
  #accountsPanelV2 table[data-resizable-table="accounts"] .account-cell-line button,
  #accountsPanelV2 table[data-resizable-table="accounts"] .acc-v2-actions > button,
  #accountsPanelV2 table[data-resizable-table="accounts"] .acc-v2-more-btn { min-height: 26px; height: 26px; }
  #accountsPanelV2 table[data-resizable-table="accounts"] .account-promotion-country-row { min-height: 20px; }
}

/* ==========================================================================
   Dispatch board theme
   One quiet board, white sheets, graphite ink for anything you act on, and
   colour reserved for status. Archivo's width axis carries the hierarchy:
   wide for page titles and headline figures, narrow for column labels.
   ========================================================================== */

@font-face {
  font-family: "Archivo Console";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url("../../fonts/archivo-variable.woff2") format("woff2-variations"), url("../../fonts/archivo-variable.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

body {
  background: var(--ui-color-bg);
  color: var(--ui-color-text);
  font-family: var(--ui-font-sans);
  letter-spacing: 0;
}

::selection { background: var(--a-100); color: var(--n-900); }

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--a-500);
  outline-offset: 2px;
}

input:hover:not(:disabled),
textarea:hover:not(:disabled),
select:hover:not(:disabled) {
  border-color: var(--n-400);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--a-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--a-500) 16%, transparent);
  outline: none;
}

input[type="checkbox"],
input[type="radio"] { accent-color: var(--n-900); }

/* --- Shell: sidebar ------------------------------------------------------ */
.app-sidebar {
  padding: 14px 12px 12px;
  background: var(--ui-color-sidebar);
  color: var(--n-800);
  border-right: 1px solid var(--n-200);
  box-shadow: none;
}

.sidebar-brand {
  height: auto;
  min-height: 44px;
  gap: 10px;
  padding: 2px 8px 14px;
  border-bottom: 1px solid var(--n-200);
}

.sidebar-brand-icon { width: 28px; height: 30px; }
.sidebar-brand-icon path:first-of-type { fill: var(--n-900); }
.sidebar-brand-icon path:last-of-type { fill: var(--a-400); fill-opacity: 1; }

.sidebar-brand-title {
  color: var(--n-900);
  font-size: 16px;
  font-weight: 760;
  font-stretch: 116%;
  letter-spacing: -.01em;
}

.sidebar-brand-subtitle {
  color: var(--n-500);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.sidebar-nav { padding: 14px 0; gap: 2px; }

.sidebar-nav-group-label {
  padding: 0 10px 6px;
  color: var(--n-500);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.sidebar-nav-group-label:not(:first-child) { margin-top: 16px; }

.app-sidebar .sidebar-nav button,
.app-sidebar .sidebar-nav button.sidebar-item {
  min-height: 36px;
  padding: 7px 10px;
  gap: 10px;
  border-radius: var(--ui-radius-md);
  color: var(--n-700);
  font-size: 13px;
  font-weight: 560;
}

.app-sidebar .sidebar-nav button .sidebar-item-icon { stroke: var(--n-500); width: 17px; height: 17px; }

.app-sidebar .sidebar-nav button:hover {
  color: var(--n-900);
  background: var(--n-200);
}

.app-sidebar .sidebar-nav button:hover .sidebar-item-icon { stroke: var(--n-800); }

.app-sidebar .sidebar-nav button.active {
  color: var(--n-0);
  background: var(--n-900);
  box-shadow: none;
}

.app-sidebar .sidebar-nav button.active .sidebar-item-icon { stroke: var(--n-0); }
.app-sidebar .sidebar-nav button.active::before { display: none; }

.sidebar-item-meta {
  min-width: 0;
  height: 18px;
  padding: 0 6px;
  border: 1px solid var(--n-300);
  border-radius: var(--ui-radius-xs);
  color: var(--n-600);
  background: transparent;
  font-size: 10.5px;
  font-weight: 600;
  font-stretch: 92%;
}

.sidebar-item.active .sidebar-item-meta {
  border-color: color-mix(in srgb, var(--n-0) 28%, transparent);
  color: var(--n-150);
  background: transparent;
}

.config-dirty-badge.sidebar-item-meta,
.sidebar-item.active .config-dirty-badge.sidebar-item-meta {
  border-color: var(--w-500);
  color: var(--n-0);
  background: var(--w-500);
}

.sidebar-subnav { padding: 2px 0 6px; gap: 1px; }
.sidebar-subnav::before { left: 18px; top: 2px; bottom: 8px; background: var(--n-300); }

.app-sidebar .sidebar-nav .sidebar-subnav button {
  min-height: 30px;
  padding: 5px 10px 5px 34px;
  border-radius: var(--ui-radius-sm);
  color: var(--n-600);
  font-size: 12.5px;
  font-weight: 500;
}

.app-sidebar .sidebar-nav .sidebar-subnav button::before {
  left: 16px;
  width: 5px;
  height: 5px;
  border: 0;
  border-radius: 1px;
  background: var(--n-400);
  box-shadow: 0 0 0 3px var(--ui-color-sidebar);
}

.app-sidebar .sidebar-nav .sidebar-subnav button:hover { color: var(--n-900); background: var(--n-200); }

.app-sidebar .sidebar-nav .sidebar-subnav button.is-active {
  color: var(--n-900);
  background: transparent;
  font-weight: 680;
}

.app-sidebar .sidebar-nav .sidebar-subnav button.is-active::before {
  width: 3px;
  height: 16px;
  left: 17px;
  border-radius: 2px;
  background: var(--n-900);
  box-shadow: none;
}

.sidebar-footer { padding: 10px 0 0; border-top: 1px solid var(--n-200); }

.sidebar-footer a,
.sidebar-logout button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: var(--ui-radius-md);
  color: var(--n-600);
  font-size: 12.5px;
  font-weight: 560;
}

.sidebar-footer-icon { stroke: currentColor; }
.sidebar-footer a:hover { color: var(--n-900); background: var(--n-200); }
.sidebar-logout button:hover { color: var(--r-600); background: var(--r-50); }

/* --- Shell: top bar -------------------------------------------------------- */
.app-topbar {
  height: var(--topbar-height);
  border-bottom: 1px solid var(--n-200);
  background: color-mix(in srgb, var(--n-100) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar-eyebrow { display: none; }
.topbar-title-row { margin-top: 0; gap: 12px; align-items: baseline; }

.topbar-title {
  color: var(--n-900);
  font-size: 21px;
  font-weight: 760;
  font-stretch: 114%;
  letter-spacing: -.012em;
  line-height: 1.2;
}

.topbar-description { color: var(--n-500); font-size: 12.5px; }

.nav-history-back,
.mobile-nav-toggle {
  width: 32px;
  height: 32px;
  border: 1px solid var(--n-300);
  border-radius: var(--ui-radius-md);
  color: var(--n-700);
  background: var(--n-0);
}

.nav-history-back:hover:not(:disabled) { color: var(--n-900); border-color: var(--n-500); background: var(--n-0); }
.nav-history-back:disabled { opacity: .45; }

.topbar-clock {
  color: var(--n-500);
  font-size: 12px;
  font-stretch: 92%;
  font-variant-numeric: tabular-nums;
}

.system-health {
  min-height: 28px;
  padding: 0 10px;
  gap: 7px;
  border: 1px solid var(--n-200);
  border-radius: var(--ui-radius-md);
  color: var(--n-700);
  background: var(--n-0);
  font-size: 12px;
  font-weight: 600;
}

.system-health-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--g-500);
  box-shadow: none;
}

main { margin-top: calc(var(--topbar-height) + 20px); }

/* --- Sheets ---------------------------------------------------------------- */
section.card,
.accounts-panel-v2,
.account-tasks-panel,
.codex-panel-v2,
.overview-panel,
.overview-metric {
  border: 1px solid var(--n-200);
  border-radius: var(--ui-radius-lg);
  background: var(--n-0);
  box-shadow: none;
}

.data-panel-kicker {
  color: var(--n-500);
  font-size: 12px;
  font-weight: 560;
  letter-spacing: 0;
  text-transform: none;
}

.data-panel-title,
.overview-panel-head h3 {
  color: var(--n-900);
  font-size: 15px;
  font-weight: 700;
  font-stretch: 104%;
  letter-spacing: -.005em;
}

/* --- Controls -------------------------------------------------------------- */
button.btn,
.ui-button,
.jobs-tb-btn,
.actions button,
.pager-bar button,
.overview-panel-head button,
.overview-customize-trigger {
  min-height: 30px;
  padding-inline: 11px;
  border: 1px solid var(--n-300);
  border-radius: var(--ui-radius-md);
  color: var(--n-800);
  background: var(--n-0);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: none;
  transition: border-color .14s ease, background-color .14s ease, color .14s ease;
}

button.btn:hover:not(:disabled),
.ui-button:hover:not(:disabled),
.jobs-tb-btn:hover:not(:disabled),
.actions button:hover:not(:disabled),
.pager-bar button:hover:not(:disabled),
.overview-panel-head button:hover:not(:disabled),
.overview-customize-trigger:hover:not(:disabled) {
  border-color: var(--n-500);
  color: var(--n-900);
  background: var(--n-50);
}

button.btn.primary,
.ui-button--primary,
.jobs-tb-btn--primary,
.overview-refresh {
  border-color: var(--n-900);
  color: var(--n-0);
  background: var(--n-900);
  box-shadow: none;
}

button.btn.primary:hover:not(:disabled),
.ui-button--primary:hover:not(:disabled),
.jobs-tb-btn--primary:hover:not(:disabled),
.overview-refresh:hover:not(:disabled) {
  border-color: var(--n-700);
  color: var(--n-0);
  background: var(--n-700);
}

button.btn.good,
.jobs-tb-btn--good,
.actions button.good {
  border-color: var(--g-200);
  color: var(--g-600);
  background: var(--g-50);
}

button.btn.good:hover:not(:disabled),
.jobs-tb-btn--good:hover:not(:disabled) { border-color: var(--g-400); color: var(--g-700); background: var(--g-100); }

button.btn.danger,
.ui-button--danger,
.jobs-tb-btn--danger,
.actions button.danger {
  border-color: var(--r-200);
  color: var(--r-600);
  background: var(--r-50);
}

button.btn.danger:hover:not(:disabled),
.ui-button--danger:hover:not(:disabled),
.jobs-tb-btn--danger:hover:not(:disabled) { border-color: var(--r-400); color: var(--r-700); background: var(--r-100); }

button:disabled,
button.btn:disabled,
.ui-button:disabled,
.jobs-tb-btn:disabled,
.actions button:disabled,
#accountsToolbarV2 .jobs-tb-btn:disabled,
#accountsToolbarV2 .jobs-tb-btn--primary:disabled,
#accountsToolbarV2 .jobs-tb-btn--good:disabled {
  border-color: var(--n-200);
  color: var(--n-400);
  background: var(--n-50);
  box-shadow: none;
  opacity: 1;
}

/* Selection actions stay quiet until rows are picked, then read as ink. */

/* --- Status language ------------------------------------------------------- */
.pill {
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: var(--ui-radius-xs) !important;
  font-size: 12px;
  font-weight: 620 !important;
  line-height: 1.3;
}

.status-success,
.status-available {
  border-color: var(--g-200) !important;
  color: var(--g-600) !important;
  background: var(--g-50) !important;
}

.status-running,
.status-stopping,
.status-pending {
  border-color: var(--w-200) !important;
  color: var(--w-600) !important;
  background: var(--w-50) !important;
}

.status-failed {
  border-color: var(--r-200) !important;
  color: var(--r-600) !important;
  background: var(--r-50) !important;
}

.status-used,
.status-cancelled,
.status-stopped,
.status-disabled,
.status-skipped {
  border-color: var(--n-200) !important;
  color: var(--n-600) !important;
  background: var(--n-50) !important;
}

/* --- Tables ---------------------------------------------------------------- */
table { font-size: 13px; font-variant-numeric: tabular-nums; }

th,
td { border-bottom-color: var(--n-150); }

th,
.accounts-table-v2 thead th,
.codex-table-v2 thead th {
  color: var(--n-600);
  background: var(--n-50);
  font-size: 12px;
  font-weight: 650;
  font-stretch: 94%;
  letter-spacing: 0;
  text-transform: none;
}

tr:hover td,
.accounts-table-v2 tbody tr:hover td,
.codex-table-v2 tbody tr:hover td { background: var(--n-25); }

.accounts-table-v2-wrap,
.codex-table-v2-wrap { scrollbar-color: var(--n-300) transparent; }

.table-state-icon { border-radius: var(--ui-radius-md); color: var(--n-500); background: var(--n-50); }
.table-state-spinner { border-color: var(--n-200); border-top-color: var(--n-900); }

/* --- Overview -------------------------------------------------------------- */
.overview-hero {
  min-height: 0;
  align-items: flex-end;
  padding: 4px 2px 6px;
  border: 0;
  border-radius: 0;
  color: var(--n-900);
  background: none;
  box-shadow: none;
}

.overview-hero::after { display: none; }
.overview-hero .data-panel-kicker { display: none; }

.overview-hero h2 {
  margin-top: 0;
  color: var(--n-900);
  font-size: 30px;
  font-weight: 780;
  font-stretch: 118%;
  letter-spacing: -.02em;
  line-height: 1.12;
}

.overview-hero p { margin-top: 8px; color: var(--n-600); font-size: 13px; }

.overview-customize-trigger,
.overview-refresh { min-height: 32px; padding: 0 13px; border-radius: var(--ui-radius-md); font-size: 12.5px; font-weight: 600; }

.overview-customize-trigger { border-color: var(--n-300); color: var(--n-800); background: var(--n-0); }

.overview-metric { padding: 16px 18px 22px; }

.overview-metric-top { color: var(--n-600); font-size: 12.5px; font-weight: 600; }

.overview-metric-dot { display: none; }

.overview-metric strong {
  margin-top: 14px;
  color: var(--n-900);
  font-size: 34px;
  font-weight: 720;
  font-stretch: 120%;
  letter-spacing: -.025em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.overview-metric small { margin-top: 8px; color: var(--n-500); font-size: 12px; }

.overview-panel { padding: 18px 18px 28px; }

.overview-panel-head { margin-bottom: 14px; }

.overview-panel-head span {
  color: var(--n-500);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.overview-panel-head h3 { margin-top: 2px; font-size: 16px; }

.overview-panel-head button { min-height: 28px; padding: 0 10px; font-size: 12px; }

.overview-card-drag,
.overview-resize-handle { color: var(--n-300); }

.overview-panel:hover .overview-card-drag,
.overview-metric:hover .overview-card-drag,
.overview-panel:hover .overview-resize-handle,
.overview-metric:hover .overview-resize-handle { color: var(--n-500); }

.overview-card-drag:hover,
.overview-card-drag:focus-visible,
.overview-resize-handle:hover,
.overview-resize-handle:focus-visible { color: var(--n-900); background: var(--n-100); }

.overview-source,
.overview-status-item,
.overview-proxy-item,
.overview-exit-row,
.overview-job-row,
.overview-plan-row,
.overview-more-summary {
  border: 0;
  border-radius: var(--ui-radius-md);
  background: var(--n-50);
}

.overview-source-name { color: var(--n-800); font-size: 12.5px; font-weight: 650; }
.overview-source-state,
.overview-exit-row i { border-radius: 2px; box-shadow: none !important; }

.overview-source strong,
.overview-status-item strong {
  color: var(--n-900);
  font-size: 22px;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: -.015em;
  font-variant-numeric: tabular-nums;
}

.overview-source small,
.overview-status-item span,
.overview-proxy-item span { color: var(--n-500); font-size: 11.5px; }

.overview-proxy-item strong { color: var(--n-900); font-size: 14px; font-weight: 650; }
.overview-exit-row span { color: var(--n-700); font-family: var(--ui-font-mono); font-size: 11.5px; font-weight: 500; }
.overview-exit-row small { color: var(--n-500); font-size: 11px; }
.overview-job-main strong { color: var(--n-900); font-size: 12.5px; }
.overview-job-main small { color: var(--n-500); font-size: 11px; }
.overview-plan-row span { color: var(--n-700); font-size: 12.5px; font-weight: 600; }
.overview-plan-row strong { min-width: 40px; color: var(--n-900); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.overview-plan-bar { height: 6px; border-radius: 2px; background: var(--n-200); }
.overview-plan-bar i { border-radius: 2px; background: var(--n-800); }

/* --- Account rows: one ink language for actions, colour only for state --- */
.accounts-table-v2 .acc-v2-token-state,
.accounts-table-v2 .acc-v2-token-copy,
#accountsPanelV2 table[data-resizable-table="accounts"] .acc-v2-token-state {
  gap: 6px;
  min-width: 0;
  min-height: 24px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--n-300);
  border-radius: var(--ui-radius-xs);
  color: var(--n-800);
  background: var(--n-0);
  font-size: 12px;
  font-weight: 600;
}

.accounts-table-v2 .acc-v2-token-state::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 1.5px;
  background: var(--n-400);
}

.accounts-table-v2 .acc-v2-token-state.is-normal { border-color: var(--n-300); color: var(--n-800); background: var(--n-0); }
.accounts-table-v2 .acc-v2-token-state.is-normal::before { background: var(--g-500); }
.accounts-table-v2 .acc-v2-token-state.is-expired { border-color: var(--w-200); color: var(--w-600); background: var(--w-50); }
.accounts-table-v2 .acc-v2-token-state.is-expired::before { background: var(--w-500); }
.accounts-table-v2 .acc-v2-token-state.is-invalid { border-color: var(--r-200); color: var(--r-600); background: var(--r-50); }
.accounts-table-v2 .acc-v2-token-state.is-invalid::before { background: var(--r-500); }

.accounts-table-v2 .acc-v2-token-state:hover:not(:disabled),
.accounts-table-v2 .acc-v2-token-copy:hover:not(:disabled) {
  border-color: var(--n-900);
  color: var(--n-0);
  background: var(--n-900);
  filter: none;
  box-shadow: none;
}

.accounts-table-v2 .acc-v2-account-status.is-ok { color: var(--g-600); }
.accounts-table-v2 .acc-v2-account-status.is-fail { color: var(--r-600); }
.accounts-table-v2 .acc-v2-account-status.is-mute { color: var(--n-400); }

/* A plan is a fact about the account, not a health signal. */
.accounts-table-v2 td[data-label="套餐"] .pill.status-success {
  border-color: var(--n-300) !important;
  color: var(--n-900) !important;
  background: var(--n-0) !important;
  box-shadow: none;
  font-stretch: 96%;
  text-transform: capitalize;
}

.accounts-table-v2 .col-id { color: var(--n-500); font-variant-numeric: tabular-nums; }

/* Dialog / drawer mount points must not take grid rows (each empty row added a 20px gap). */
#accountDetailHost,
#accountC2aConfirmHost,
#accountEmailChangeHost { display: contents; }

/* --- Feedback -------------------------------------------------------------- */
#toast {
  border: 0;
  border-radius: var(--ui-radius-md);
  color: var(--n-0);
  background: var(--n-900);
  box-shadow: var(--ui-shadow-pop);
}

dialog::backdrop,
.account-detail-backdrop { background: color-mix(in srgb, var(--n-900) 40%, transparent); }

@media (max-width: 860px) {
  main { margin-top: calc(var(--topbar-height) + 12px); }
  .topbar-description { display: none; }
  body.sidebar-open .app-sidebar { box-shadow: var(--ui-shadow-md); }
  .overview-hero h2 { font-size: 24px; }
  .overview-metric strong { font-size: 28px; }
}

@media (max-width: 560px) {
  .topbar-title { font-size: 18px; }
  .overview-hero { padding-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
