/* ==========================================================================
   PAYAPIWEB 管理后台样式
   浅色、扁平、克制的商业管理风格；所有组件消费语义令牌。
   ========================================================================== */

:root {
  color-scheme: light;

  /* 颜色 - 视觉层 */
  --color-primary-50: #eff6ff;
  --color-primary-100: #dbeafe;
  --color-primary-500: #2563eb;
  --color-primary-600: #1d4ed8;
  --color-primary-700: #1e40af;
  --color-neutral-50: #f8fafc;
  --color-neutral-100: #f1f5f9;
  --color-neutral-200: #e5e7eb;
  --color-neutral-300: #cbd5e1;
  --color-neutral-400: #94a3b8;
  --color-neutral-500: #64748b;
  --color-neutral-700: #334155;
  --color-neutral-900: #0f172a;
  --color-success-500: #16a34a;
  --color-warning-500: #d97706;
  --color-error-500: #dc2626;
  --color-info-500: #0284c7;

  /* 颜色 - 语义层 */
  --color-bg-page: var(--color-neutral-50);
  --color-bg-surface: #ffffff;
  --color-bg-subtle: var(--color-neutral-100);
  --color-text-primary: var(--color-neutral-900);
  --color-text-secondary: var(--color-neutral-500);
  --color-text-disabled: var(--color-neutral-400);
  --color-border-default: var(--color-neutral-200);
  --color-border-focus: var(--color-primary-500);
  --color-brand: var(--color-primary-500);
  --color-brand-hover: var(--color-primary-600);
  --color-brand-soft: var(--color-primary-50);
  --color-feedback-success: var(--color-success-500);
  --color-feedback-warning: var(--color-warning-500);
  --color-feedback-error: var(--color-error-500);
  --color-feedback-info: var(--color-info-500);

  /* 尺寸 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --font-family-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  --font-family-mono: 'Cascadia Mono', Consolas, 'Courier New', monospace;
  --motion-fast: 120ms;
  --motion-normal: 200ms;
  --sidebar-width: 224px;
  --topbar-height: 56px;
}

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

html { font-size: 14px; }

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

a { color: var(--color-brand); text-decoration: none; transition: color var(--motion-fast); }
a:hover { color: var(--color-brand-hover); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.35; }
p { margin: 0 0 8px; }
ul, ol { margin: 0; padding-left: 20px; }
code { font-family: var(--font-family-mono); }
img { max-width: 100%; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-neutral-300); border-radius: 4px; }
::selection { background: rgba(37, 99, 235, 0.18); }

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

.mono, .num { font-family: var(--font-family-mono); }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--color-text-secondary); }
.text-success { color: var(--color-feedback-success); }
.text-muted { color: var(--color-text-secondary); }
.break-all { word-break: break-all; }
.inline-form { display: inline; }

/* ==========================================================================
   后台框架
   ========================================================================== */
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--color-bg-surface);
  border-right: 1px solid var(--color-border-default);
  display: flex;
  flex-direction: column;
  z-index: 300;
  transition: transform var(--motion-normal);
}

.sidebar-brand {
  height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--color-border-default);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: var(--color-brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  flex: none;
}

.brand-mark-lg { width: 40px; height: 40px; border-radius: var(--radius-lg); font-size: 19px; }

.brand-name { font-size: 14px; font-weight: 600; letter-spacing: 0.04em; }
.brand-sub { font-size: 11px; color: var(--color-text-secondary); margin-top: 1px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar-group {
  font-size: 11px;
  color: var(--color-text-secondary);
  padding: 12px 10px 6px;
  letter-spacing: 0.06em;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 10px;
  margin-bottom: 2px;
  border-radius: var(--radius-md);
  color: var(--color-neutral-700);
  font-size: 13.5px;
  border-left: 2px solid transparent;
  transition: background var(--motion-fast), color var(--motion-fast);
}

.sidebar-link:hover { background: var(--color-neutral-50); color: var(--color-text-primary); }
.sidebar-link.active {
  background: var(--color-brand-soft);
  color: var(--color-brand);
  border-left-color: var(--color-brand);
  font-weight: 500;
}
.sidebar-icon { width: 18px; height: 18px; display: inline-flex; flex: none; }
.sidebar-icon svg { width: 18px; height: 18px; }

.sidebar-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border-default);
  font-size: 11px;
  color: var(--color-text-disabled);
}

.sidebar-mask { display: none; }

.admin-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  height: var(--topbar-height);
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border-default);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 200;
}

.topbar-toggle {
  display: none;
  border: 0;
  background: transparent;
  color: var(--color-neutral-700);
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.topbar-toggle:hover { background: var(--color-bg-subtle); }

.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-user { font-size: 13px; color: var(--color-text-secondary); }

.admin-content { padding: 20px 24px 40px; flex: 1; }

/* ==========================================================================
   页头与卡片
   ========================================================================== */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 20px; font-weight: 600; }
.page-desc { margin: 4px 0 0; font-size: 13px; color: var(--color-text-secondary); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.ui-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.ui-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--color-border-default);
}
.ui-card-title { font-size: 14px; font-weight: 600; }
.ui-card-link { font-size: 12.5px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-2 > .ui-card { margin-bottom: 16px; }

/* ==========================================================================
   KPI 与仪表盘
   ========================================================================== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-card { padding: 16px 18px; margin: 0; }
.kpi-label { font-size: 13px; color: var(--color-text-secondary); }
.kpi-value { margin-top: 8px; font-size: 28px; font-weight: 600; font-family: var(--font-family-mono); line-height: 1.2; }

.cloud-strip { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 16px; }
.cloud-strip-title { font-size: 13px; font-weight: 500; }
.cloud-strip-items { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; font-size: 13px; }
.cloud-item { display: inline-flex; align-items: center; gap: 6px; }
.cloud-source { margin-left: auto; font-size: 12px; color: var(--color-text-secondary); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-neutral-400); display: inline-block; }
.status-dot-online { background: var(--color-feedback-success); }
.status-dot-offline { background: var(--color-feedback-error); }

.trend-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  height: 180px;
  padding: 8px 4px 0;
}
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 8px; }
.trend-bars { display: flex; align-items: flex-end; gap: 4px; height: calc(100% - 22px); width: 100%; justify-content: center; }
.trend-bar {
  width: 14px;
  min-height: 3px;
  background: var(--color-primary-100);
  border-radius: 3px 3px 0 0;
  transition: background var(--motion-fast);
}
.trend-bar-paid { background: var(--color-primary-500); }
.trend-col:hover .trend-bar { background: var(--color-primary-200, #bfdbfe); }
.trend-col:hover .trend-bar-paid { background: var(--color-primary-600); }
.trend-label { font-size: 11px; color: var(--color-text-secondary); font-family: var(--font-family-mono); }

.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--color-text-secondary); padding-left: 4px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.legend-dot-total { background: var(--color-primary-100); }
.legend-dot-paid { background: var(--color-primary-500); }

.pending-list { display: flex; flex-direction: column; gap: 8px; }
.pending-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: 13px;
}
.pending-item:hover { background: var(--color-neutral-50); color: var(--color-text-primary); }
.pending-item strong { font-family: var(--font-family-mono); font-size: 18px; font-weight: 600; }

.status-card { margin: 0; }
.status-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status-card-name { font-size: 15px; font-weight: 600; }
.status-card-meta { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--color-text-secondary); }

/* ==========================================================================
   表格
   ========================================================================== */
.table-wrap { width: 100%; overflow-x: auto; }
.ui-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ui-table th {
  text-align: left;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--color-text-secondary);
  background: var(--color-bg-subtle);
  padding: 9px 10px;
  border-bottom: 1px solid var(--color-border-default);
  white-space: nowrap;
}
.ui-table td { padding: 10px; border-bottom: 1px solid var(--color-border-default); vertical-align: middle; }
.ui-table tbody tr:last-child td { border-bottom: 0; }
.ui-table tbody tr:hover { background: var(--color-neutral-50); }
.ui-table tr[data-href] { cursor: pointer; }
.ui-table .actions { white-space: nowrap; }
.ui-table .actions .link { margin-right: 8px; font-size: 12.5px; cursor: pointer; background: none; border: 0; padding: 0; font-family: inherit; }
.ui-table .table-empty { text-align: center; color: var(--color-text-secondary); padding: 32px 10px; }
.ui-table-plain th { width: 140px; background: transparent; }
.ui-table-plain td { color: var(--color-text-primary); }
.row-danger { background: #fff5f5; }
.cell-sub { font-size: 11.5px; color: var(--color-text-secondary); margin-top: 2px; }
.cell-url { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.cell-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   徽标
   ========================================================================== */
.ui-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}
.ui-badge-success { background: #e8f7ee; color: #15803d; }
.ui-badge-info { background: #e6f2fb; color: #0369a1; }
.ui-badge-warning { background: #fdf3e3; color: #b45309; }
.ui-badge-error { background: #fdecec; color: #b91c1c; }
.ui-badge-neutral { background: var(--color-bg-subtle); color: var(--color-text-secondary); }
.badge-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

/* ==========================================================================
   按钮
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
  white-space: nowrap;
}
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--color-brand); color: #fff; }
.btn-primary:hover { background: var(--color-brand-hover); color: #fff; }
.btn-secondary { background: var(--color-bg-surface); border-color: var(--color-border-default); color: var(--color-text-primary); }
.btn-secondary:hover { background: var(--color-neutral-50); color: var(--color-text-primary); }
.btn-ghost { background: transparent; color: var(--color-text-secondary); }
.btn-ghost:hover { background: var(--color-bg-subtle); color: var(--color-text-primary); }
.btn-danger { background: var(--color-feedback-error); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-danger-ghost { background: transparent; border-color: #fca5a5; color: #b91c1c; }
.btn-danger-ghost:hover { background: #fdecec; color: #b91c1c; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==========================================================================
   表单
   ========================================================================== */
.ui-field { margin-bottom: 14px; min-width: 0; }
.ui-label { display: block; font-size: 12.5px; color: var(--color-neutral-700); margin-bottom: 6px; font-weight: 500; }
.req { color: var(--color-feedback-error); }

.ui-input, .ui-select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
textarea.ui-input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.ui-input:focus, .ui-select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.ui-input[readonly] { background: var(--color-neutral-50); color: var(--color-text-secondary); }
.ui-input::placeholder { color: var(--color-text-disabled); }
.ui-help { font-size: 11.5px; color: var(--color-text-secondary); margin-top: 4px; }

.ui-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; user-select: none; }
.ui-check input { width: 16px; height: 16px; accent-color: var(--color-brand); cursor: pointer; }
.check-row { display: flex; gap: 18px; align-items: center; min-height: 34px; flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.ui-field-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row .ui-input { flex: 1; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-family: var(--font-family-mono);
}

/* 开关 */
.ui-switch {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: var(--radius-full);
  border: 0;
  background: var(--color-neutral-300);
  cursor: pointer;
  padding: 0;
  transition: background var(--motion-fast);
}
.ui-switch span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--motion-fast);
}
.ui-switch.on { background: var(--color-brand); }
.ui-switch.on span { transform: translateX(16px); }

/* 筛选条 */
.ui-filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 14px;
  align-items: flex-end;
  padding: 14px 16px;
}
.filter-item { min-width: 130px; flex: 0 1 auto; }
.filter-item .ui-label { margin-bottom: 4px; }
.filter-item .ui-input, .filter-item .ui-select { min-width: 130px; }
.filter-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }

/* ==========================================================================
   标签页 / 分页 / 空态
   ========================================================================== */
.ui-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--color-border-default); margin-bottom: 16px; }
.ui-tab { padding: 10px 2px; font-size: 13.5px; color: var(--color-text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.ui-tab.active { color: var(--color-brand); border-bottom-color: var(--color-brand); font-weight: 500; }

.ui-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  flex-wrap: wrap;
}
.ui-pagination-info { font-size: 12px; color: var(--color-text-secondary); }
.ui-pagination-pages { display: flex; align-items: center; gap: 4px; }
.ui-page-link {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--color-neutral-700);
  background: var(--color-bg-surface);
}
.ui-page-link:hover { background: var(--color-neutral-50); }
.ui-page-link.active { background: var(--color-brand); border-color: var(--color-brand); color: #fff; }
.ui-page-ellipsis { padding: 0 4px; color: var(--color-text-secondary); }

.ui-empty { padding: 40px 16px; text-align: center; }
.ui-empty-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.ui-empty-desc { font-size: 12.5px; color: var(--color-text-secondary); margin-bottom: 14px; }

/* ==========================================================================
   弹窗 / 抽屉 / Toast / 提示
   ========================================================================== */
.ui-modal { display: none; position: fixed; inset: 0; z-index: 1000; }
.ui-modal.open { display: flex; align-items: center; justify-content: center; padding: 20px; }
.ui-modal-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.ui-modal-box {
  position: relative;
  width: 480px;
  max-width: 100%;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--color-bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.ui-modal-wide { width: 720px; }
.ui-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border-default);
  font-weight: 600;
}
.ui-modal-body { padding: 18px; overflow-y: auto; }
.ui-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--color-border-default);
  background: var(--color-neutral-50);
}
.modal-close {
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--color-bg-subtle); }

.ui-toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1100;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  background: #fff;
  border: 1px solid var(--color-border-default);
  transition: opacity var(--motion-normal), transform var(--motion-normal);
}
.ui-toast-success { border-color: #bbf7d0; color: #15803d; background: #f0fdf4; }
.ui-toast-error { border-color: #fecaca; color: #b91c1c; background: #fef2f2; }
.ui-toast.hide { opacity: 0; transform: translateY(-6px); }

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-default);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.6;
}
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.alert-list { margin: 6px 0 0; padding-left: 18px; }

/* ==========================================================================
   描述列表 / 时间线 / 代码块 / 密钥面板
   ========================================================================== */
.ui-desc { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; margin: 0; }
.ui-desc > div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: start; }
.ui-desc dt { font-size: 12.5px; color: var(--color-text-secondary); }
.ui-desc dd { margin: 0; font-size: 13px; min-width: 0; }
.ui-desc-single { grid-template-columns: 1fr; }
.ui-desc-single > div { grid-template-columns: 160px minmax(0, 1fr); }

.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ''; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--color-border-default); }
.timeline-item { position: relative; padding: 0 0 16px 12px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -18px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--color-neutral-400); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--color-border-default); }
.timeline-item.is-success .timeline-dot { background: var(--color-feedback-success); }
.timeline-item.is-fail .timeline-dot { background: var(--color-feedback-error); }
.timeline-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.timeline-direction { font-weight: 500; }
.timeline-time { margin-left: auto; font-size: 11.5px; color: var(--color-text-secondary); font-family: var(--font-family-mono); }
.timeline-meta { margin-top: 4px; font-size: 11.5px; color: var(--color-text-secondary); display: flex; gap: 10px; flex-wrap: wrap; }
.timeline-detail { margin-top: 6px; }
.timeline-detail summary { cursor: pointer; font-size: 12px; color: var(--color-brand); }

.code-block {
  margin: 0 0 12px;
  padding: 12px;
  background: var(--color-neutral-900);
  color: #e2e8f0;
  border-radius: var(--radius-md);
  font-family: var(--font-family-mono);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}
.code-block-scroll { max-height: 320px; overflow: auto; white-space: pre; word-break: normal; }

.secret-panel { border-color: #bfdbfe; background: #f8fbff; }
.secret-row, .access-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.secret-label, .access-label { width: 96px; flex: none; font-size: 12.5px; color: var(--color-text-secondary); }
.secret-value {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  font-family: var(--font-family-mono);
  font-size: 12.5px;
  word-break: break-all;
}

.qr-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--color-text-secondary); margin-bottom: 10px; }
.doc-list { font-size: 13px; line-height: 1.8; color: var(--color-neutral-700); }

/* ==========================================================================
   登录页
   ========================================================================== */
.login-body {
  background:
    radial-gradient(ellipse 700px 400px at 20% -10%, rgba(37, 99, 235, 0.06), transparent 60%),
    radial-gradient(ellipse 600px 400px at 90% 110%, rgba(37, 99, 235, 0.04), transparent 60%),
    var(--color-bg-page);
  min-height: 100vh;
}
.login-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 12vh 16px 32px; }
.login-card {
  width: 380px;
  max-width: 100%;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 30px 30px 24px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand-name { font-size: 18px; font-weight: 600; letter-spacing: 0.06em; }
.login-brand-sub { font-size: 12px; color: var(--color-text-secondary); margin-top: 2px; }
.login-form .ui-field { margin-bottom: 16px; }
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-img { width: 120px; height: 40px; border-radius: var(--radius-md); border: 1px solid var(--color-border-default); cursor: pointer; flex: none; }
.login-foot {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border-default);
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--color-text-disabled);
}

.login-options { margin: 2px 0 16px; }
.login-options .ui-check { font-size: 13px; }
.login-options .ui-help { margin-left: 24px; }

/* 白天 / 夜间切换按钮 */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  background: var(--color-bg-surface);
  color: var(--color-text-secondary);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast);
}
.theme-toggle:hover { background: var(--color-neutral-50); color: var(--color-text-primary); }
.theme-toggle svg { width: 16px; height: 16px; flex: none; }
.theme-toggle .icon-moon,
.theme-toggle .theme-label-dark { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun,
[data-theme="dark"] .theme-toggle .theme-label-light { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon,
[data-theme="dark"] .theme-toggle .theme-label-dark { display: inline; }

.login-theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.92);
}
[data-theme="dark"] .login-theme-toggle { background: rgba(17, 24, 39, 0.92); }

/* ==========================================================================
   夜间模式
   ========================================================================== */
[data-theme="dark"] {
  color-scheme: dark;

  --color-primary-50: #172554;
  --color-primary-100: #1e3a8a;
  --color-primary-200: #1d4ed8;
  --color-primary-500: #3b82f6;
  --color-primary-600: #60a5fa;
  --color-primary-700: #93c5fd;
  --color-neutral-50: #1e293b;
  --color-neutral-100: #1f2937;
  --color-neutral-200: #334155;
  --color-neutral-300: #475569;
  --color-neutral-400: #64748b;
  --color-neutral-500: #94a3b8;
  --color-neutral-700: #cbd5e1;
  --color-neutral-900: #0b1220;
  --color-success-500: #4ade80;
  --color-warning-500: #fbbf24;
  --color-error-500: #f87171;
  --color-info-500: #38bdf8;

  --color-bg-page: #0b1220;
  --color-bg-surface: #111827;
  --color-bg-subtle: #1f2937;
  --color-text-primary: #e5e7eb;
  --color-text-secondary: #94a3b8;
  --color-text-disabled: #64748b;
  --color-border-default: #334155;
  --color-border-focus: #60a5fa;
  --color-brand: #3b82f6;
  --color-brand-hover: #60a5fa;
  --color-brand-soft: rgba(59, 130, 246, 0.16);
  --color-feedback-success: #4ade80;
  --color-feedback-warning: #fbbf24;
  --color-feedback-error: #f87171;
  --color-feedback-info: #38bdf8;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(ellipse 900px 500px at 85% -10%, rgba(59, 130, 246, 0.08), transparent 60%),
    radial-gradient(ellipse 800px 500px at -10% 110%, rgba(59, 130, 246, 0.05), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0, transparent 39px, rgba(255, 255, 255, 0.015) 39px, rgba(255, 255, 255, 0.015) 40px),
    repeating-linear-gradient(90deg, transparent 0, transparent 39px, rgba(255, 255, 255, 0.015) 39px, rgba(255, 255, 255, 0.015) 40px);
}
[data-theme="dark"] .login-body {
  background:
    radial-gradient(ellipse 700px 400px at 20% -10%, rgba(59, 130, 246, 0.12), transparent 60%),
    radial-gradient(ellipse 600px 400px at 90% 110%, rgba(59, 130, 246, 0.06), transparent 60%),
    var(--color-bg-page);
}
[data-theme="dark"] .ui-table tbody tr:hover,
[data-theme="dark"] .sidebar-link:hover,
[data-theme="dark"] .btn-secondary:hover,
[data-theme="dark"] .pending-item:hover,
[data-theme="dark"] .ui-page-link:hover { background: #1e293b; }
[data-theme="dark"] .ui-toast { background: var(--color-bg-surface); border-color: var(--color-border-default); color: var(--color-text-primary); }
[data-theme="dark"] .ui-toast-success { background: rgba(22, 163, 74, 0.16); border-color: rgba(74, 222, 128, 0.35); color: #86efac; }
[data-theme="dark"] .ui-toast-error { background: rgba(220, 38, 38, 0.16); border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }
[data-theme="dark"] .alert-success { background: rgba(22, 163, 74, 0.14); border-color: rgba(74, 222, 128, 0.3); color: #86efac; }
[data-theme="dark"] .alert-error { background: rgba(220, 38, 38, 0.14); border-color: rgba(248, 113, 113, 0.3); color: #fca5a5; }
[data-theme="dark"] .alert-warning { background: rgba(217, 119, 6, 0.16); border-color: rgba(251, 191, 36, 0.3); color: #fcd34d; }
[data-theme="dark"] .ui-badge-success { background: rgba(22, 163, 74, 0.18); color: #86efac; }
[data-theme="dark"] .ui-badge-info { background: rgba(2, 132, 199, 0.2); color: #7dd3fc; }
[data-theme="dark"] .ui-badge-warning { background: rgba(217, 119, 6, 0.2); color: #fcd34d; }
[data-theme="dark"] .ui-badge-error { background: rgba(220, 38, 38, 0.2); color: #fca5a5; }
[data-theme="dark"] .ui-badge-neutral { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; }
[data-theme="dark"] .secret-panel { background: rgba(37, 99, 235, 0.1); border-color: rgba(59, 130, 246, 0.35); }
[data-theme="dark"] .row-danger { background: rgba(220, 38, 38, 0.12); }
[data-theme="dark"] .timeline-dot { border-color: var(--color-bg-surface); }
[data-theme="dark"] .code-block { background: #020617; }
[data-theme="dark"] .login-card { box-shadow: var(--shadow-md); }
[data-theme="dark"] .captcha-img { background: #f8fafc; }
[data-theme="dark"] .trend-col:hover .trend-bar { background: #1e40af; }
[data-theme="dark"] .trend-col:hover .trend-bar-paid { background: #60a5fa; }
[data-theme="dark"] .legend-dot-total { background: #1e3a8a; }

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 1199px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cell-url { max-width: 160px; }
}

@media (max-width: 959px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-shell.sidebar-open .admin-sidebar { transform: translateX(0); }
  .admin-shell.sidebar-open .sidebar-mask {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 250;
  }
  .admin-main { margin-left: 0; }
  .topbar-toggle { display: inline-flex; }
  .admin-content { padding: 16px; }
  .admin-topbar { padding: 0 16px; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
  .ui-desc { grid-template-columns: 1fr; }
  .filter-actions { margin-left: 0; }
}

@media (max-width: 767px) {
  .kpi-grid, .kpi-grid-3 { grid-template-columns: 1fr; }
  .admin-content { padding: 12px; }
  .page-title { font-size: 18px; }
  .page-actions { width: 100%; }
  .ui-card { padding: 14px; }
  .ui-filterbar { padding: 12px; }
  .filter-item { flex: 1 1 100%; }
  .filter-item .ui-input, .filter-item .ui-select { min-width: 0; }
  .trend-chart { height: 150px; }
  .ui-modal-box, .ui-modal-wide { width: 100%; }
  .login-card { padding: 24px 20px 20px; }
  .ui-table th, .ui-table td { padding: 8px; }
}
