:root {
  /* ========== 基础色彩系统 ========== */
  
  /* 主色调 - 专业交易蓝 */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;
  
  /* 辅助色 - 稳定灰蓝 */
  --neutral-50: #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-200: #e2e8f0;
  --neutral-300: #cbd5e1;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #0f172a;
  
  /* 功能色 - 交易状态指示 */
  --success-50: #ecfdf5;
  --success-100: #d1fae5;
  --success-200: #a7f3d0;
  --success-300: #6ee7b7;
  --success-400: #34d399;
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047857;
  --success-800: #065f46;
  --success-900: #064e3b;
  
  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --warning-200: #fde68a;
  --warning-300: #fcd34d;
  --warning-400: #fbbf24;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;
  --warning-800: #92400e;
  --warning-900: #78350f;
  
  --danger-50: #fef2f2;
  --danger-100: #fee2e2;
  --danger-200: #fecaca;
  --danger-300: #fca5a5;
  --danger-400: #f87171;
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  --danger-700: #b91c1c;
  --danger-800: #991b1b;
  --danger-900: #7f1d1d;
  
  --info-50: #ecfeff;
  --info-100: #cffafe;
  --info-200: #a5f3fc;
  --info-300: #67e8f9;
  --info-400: #22d3ee;
  --info-500: #06b6d4;
  --info-600: #0891b2;
  --info-700: #0e7490;
  --info-800: #155e75;
  --info-900: #164e63;
  
  /* ========== 语义化映射 ========== */
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-sunken: #f1f5f9;
  --bg-sidebar: linear-gradient(180deg, var(--neutral-800) 0%, var(--neutral-900) 100%);
  
  --text-primary: var(--neutral-900);
  --text-secondary: var(--neutral-600);
  --text-tertiary: var(--neutral-500);
  --text-inverse: #ffffff;
  
  --border-light: rgba(0, 0, 0, 0.06);
  --border-default: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.15);
  
  --interactive-hover: rgba(59, 130, 246, 0.06);
  --interactive-active: rgba(59, 130, 246, 0.1);
  --interactive-focus: rgba(59, 130, 246, 0.15);
  
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-full: 9999px;
  
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  
  /* 布局尺寸 */
  --sidebar-width: 260px;
  --header-height: 56px;
  --toolbar-height: 52px;
  
  /* ========== 向后兼容别名 ========== */
  --bg: var(--bg-surface);
  --bg-strong: var(--bg-sunken);
  --panel: var(--bg-elevated);
  --panel-strong: var(--bg-elevated);
  --sidebar: var(--neutral-800);
  --line: var(--border-light);
  --line-strong: var(--border-default);
  --text: var(--text-primary);
  --muted: var(--text-secondary);
  --accent: var(--primary-500);
  --accent-strong: var(--primary-600);
  --success: var(--success-500);
  --warning: var(--warning-500);
  --danger: var(--danger-500);
  --info: var(--info-500);
  --neutral: var(--neutral-400);
  --shadow: var(--shadow-md);
  --shadow-soft: var(--shadow-sm);
}

/* ========== 基础重置 ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 14px;
}

body {
  min-height: 100vh;
  color: var(--text);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    "WenQuanYi Micro Hei",
    sans-serif;
  line-height: 1.6;
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
  border-radius: var(--radius-md);
  outline: none;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  padding: var(--space-3) var(--space-3);
  color: var(--text);
  background: var(--bg-surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--interactive-focus);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

button {
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

/* ========== 三段式布局 ========== */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* 侧边栏遮罩层（移动端） */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ========== 侧边栏 ========== */
.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  color: var(--neutral-200);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

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

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-5) var(--space-4) var(--space-3);
  gap: var(--space-2);
}

.sidebar-close-btn {
  display: none;
  padding: var(--space-1);
  color: var(--neutral-300);
  background: transparent;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.sidebar-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.brand {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand-copy {
  margin: var(--space-2) 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(240, 235, 228, 0.6);
}

.login-panel {
  margin: 0 var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.user-panel {
  margin: 0 var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.user-role {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  width: fit-content;
}

.hidden {
  display: none !important;
}

/* ========== 侧边栏导航 ========== */
.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  padding: var(--space-2) var(--space-4) var(--space-4);
}

.nav-btn {
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateX(2px);
}

.nav-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  border-color: transparent;
}

/* ========== 主区域包装器 ========== */
.main-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

/* ========== 顶部导航栏 ========== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  min-height: var(--header-height);
  padding: 0 var(--space-6);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  gap: var(--space-4);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}

.sidebar-toggle-btn {
  display: none;
  padding: var(--space-2);
  color: var(--text-secondary);
  background: transparent;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
  background: var(--interactive-hover);
  color: var(--text-primary);
}

.header-title {
  min-width: 0;
}

.header-title .eyebrow {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.header-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  flex-shrink: 0;
}

.header-copy {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ========== 工具栏 ========== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: var(--toolbar-height);
  min-height: var(--toolbar-height);
  padding: 0 var(--space-6);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.toolbar-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ========== 主内容区域 ========== */
.content {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
  overflow-x: hidden;
}

.content::-webkit-scrollbar {
  width: 8px;
}

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

.content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* ========== 视图切换 ========== */
.view {
  display: none;
}

.view.active {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ========== 网格系统 ========== */
.grid {
  display: grid;
  gap: var(--space-5);
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.config-grid {
  grid-template-columns: minmax(560px, 1.35fr) minmax(340px, 0.65fr);
  align-items: start;
}

/* ========== 面板组件 ========== */
.panel {
  display: flex;
  flex-direction: column;
  padding: var(--space-5);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  background: var(--panel);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: all 0.3s ease;
}

.panel:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-200);
}

.panel-hero {
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--primary-50) 100%);
  border-color: var(--primary-200);
}

.panel-head {
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.panel-head:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.panel-head .eyebrow {
  margin: 0 0 6px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.panel-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.view[data-view="config"] .panel {
  max-height: calc(100vh - 156px);
}

.view[data-view="config"] .panel-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--panel);
}

.view[data-view="config"] .panel-actions {
  justify-content: flex-end;
}

/* ========== 面板内容区域 ========== */
#dashboard-overview,
#dashboard-results,
#dashboard-rules,
#dashboard-signal,
#runtime-overview,
#runtime-access,
#runtime-signals,
#runtime-reconciliations,
#runtime-chain-transactions,
#positions-history,
#orders-history,
#account-balance-risk,
#account-strategy-results,
#account-status-read,
#config-diff {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

#dashboard-rules {
  gap: 8px;
}

#dashboard-signal {
  flex: 1 1 auto;
  min-height: 0;
}

#dashboard-signal .detail-card {
  flex-shrink: 0;
}

#dashboard-signal .divider {
  flex-shrink: 0;
}

#dashboard-signal-table {
  flex: 1 1 auto;
  min-height: 150px;
}

#dashboard-signal-table .data-shell {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

#positions-history .data-shell,
#orders-history .data-shell,
#runtime-reconciliations .data-shell,
#runtime-chain-transactions .data-shell {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

/* ========== 指标网格 ========== */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  min-height: 0;
  overflow: auto;
  align-content: start;
  padding: 2px;
}

/* ========== 卡片组件 ========== */
.metric-card,
.detail-card,
.mini-card {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  transition: all 0.2s ease;
}

.metric-card:hover,
.detail-card:hover {
  border-color: var(--primary-200);
  box-shadow: var(--shadow-sm);
}

.metric-label,
.detail-label,
.mini-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.metric-value {
  display: block;
  margin-top: var(--space-2);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

.metric-hint,
.detail-meta,
.table-meta,
.empty-state {
  margin-top: var(--space-2);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

/* ========== 状态颜色 ========== */
.positive {
  color: var(--success);
}

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

/* ========== 徽章组件 ========== */
.badge-row,
.chip-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  background: var(--neutral-100);
  color: var(--neutral-600);
  letter-spacing: 0.02em;
}

.badge.success {
  background: var(--success-100);
  color: var(--success-700);
}

.badge.warning {
  background: var(--warning-100);
  color: var(--warning-700);
}

.badge.danger {
  background: var(--danger-100);
  color: var(--danger-700);
}

.badge.info {
  background: var(--info-100);
  color: var(--info-700);
}

.badge.neutral {
  background: var(--neutral-100);
  color: var(--neutral-600);
}

/* ========== 规则与详情网格 ========== */
.rule-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3);
  min-height: 0;
  overflow: auto;
  align-content: start;
  padding: 2px;
}

.detail-card {
  padding: 14px;
}

.detail-meta {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}

/* ========== 区块堆叠 ========== */
.section-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  align-content: start;
  padding: 2px;
}

/* ========== 数据容器 ========== */
.data-shell {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.7);
}

.data-shell::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.data-shell::-webkit-scrollbar-track {
  background: rgba(60, 50, 40, 0.05);
  border-radius: 4px;
}

.data-shell::-webkit-scrollbar-thumb {
  background: rgba(60, 50, 40, 0.2);
  border-radius: 4px;
}

.data-shell::-webkit-scrollbar-thumb:hover {
  background: rgba(60, 50, 40, 0.3);
}

/* ========== 表格 ========== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

th {
  position: sticky;
  top: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-inverse);
  background: linear-gradient(135deg, var(--neutral-800), var(--neutral-700));
  z-index: 1;
  white-space: nowrap;
}

td {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
}

tr:hover {
  background: var(--interactive-hover);
}

.table-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.table-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

tbody tr:hover {
  background: rgba(60, 50, 40, 0.03);
}

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

/* ========== 列表 ========== */
.line-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.line-item {
  color: var(--text);
  line-height: 1.6;
  word-break: break-word;
}

/* ========== 配置表单 ========== */
.config-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 2px;
}

.config-form::-webkit-scrollbar {
  width: 8px;
}

.config-form::-webkit-scrollbar-track {
  background: transparent;
}

.config-form::-webkit-scrollbar-thumb {
  background: rgba(60, 50, 40, 0.15);
  border-radius: 4px;
}

.config-section {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.config-section-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.config-section h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.config-section-head p {
  margin-top: 4px;
  max-width: 760px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.field-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  align-items: start;
}

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

.field > span:first-child {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.field.compact {
  margin-bottom: 10px;
}

.field.checkbox {
  flex-direction: row;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--neutral-50);
}

.field.checkbox input {
  width: auto;
}

.field-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.config-array-field {
  grid-column: 1 / -1;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.config-array-title {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--neutral-50);
}

.config-array-title strong {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
}

.config-array-title p {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.config-array-title span {
  flex: 0 0 auto;
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-700);
  background: var(--primary-50);
}

.config-array-table {
  min-width: 560px;
}

.config-array-table th,
.config-array-table td {
  padding: 10px 12px;
}

.config-array-table th {
  position: static;
  color: var(--text-secondary);
  background: var(--neutral-100);
  letter-spacing: 0;
  text-transform: none;
}

.config-row-index {
  width: 56px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--neutral-50);
}

.config-table-field {
  gap: 0;
}

.config-table-field > span:first-child {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.config-table-field input {
  min-width: 96px;
  padding: 8px 10px;
}

/* ========== YAML 预览 ========== */
.yaml-preview {
  flex: 0 0 auto;
  min-height: 240px;
  max-height: 280px;
  overflow: auto;
  font-family:
    "JetBrains Mono",
    "Fira Code",
    "SFMono-Regular",
    monospace;
  font-size: 12px;
  line-height: 1.5;
}

.yaml-preview::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.yaml-preview::-webkit-scrollbar-track {
  background: transparent;
}

.yaml-preview::-webkit-scrollbar-thumb {
  background: rgba(60, 50, 40, 0.15);
  border-radius: 4px;
}

.divider {
  height: 1px;
  margin: 10px 0;
  background: var(--line);
}

/* ========== 按钮系统 ========== */
.btn {
  padding: var(--space-2) var(--space-4);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--interactive-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  color: var(--text-inverse);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: transparent;
}

.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
  transform: translateY(-2px);
}

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #dc2626, var(--danger));
  border-color: transparent;
}

.btn-danger:hover {
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
  transform: translateY(-2px);
}

.btn-block {
  width: 100%;
}

/* ========== 辅助文本 ========== */
.eyebrow {
  margin: 0 0 6px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar .eyebrow,
.sidebar .helper-text {
  color: rgba(240, 235, 228, 0.6);
}

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

/* ========== 弹窗 ========== */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 16, 12, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(440px, 100%);
  padding: 20px;
  border-radius: var(--radius-xl);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.modal-card h3 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

.modal-copy {
  margin: var(--space-2) 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

/* ========== 提示堆栈 ========== */
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(320px, calc(100vw - 32px));
  z-index: 200;
}

.toast {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-soft);
  font-size: 13px;
}

.toast.success {
  border-color: rgba(45, 138, 110, 0.2);
}

.toast.warning {
  border-color: rgba(184, 134, 11, 0.2);
}

.toast.danger {
  border-color: rgba(201, 68, 68, 0.2);
}

/* ========== 空状态 ========== */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 20px;
}

/* ========== 状态分组 ========== */
.status-group {
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--neutral-400);
  background: var(--neutral-50);
  transition: all 0.2s ease;
}

.status-group:hover {
  box-shadow: var(--shadow-sm);
}

.status-group.status-cancelled {
  border-left-color: var(--neutral-400);
  background: var(--neutral-50);
}

.status-group.status-win {
  border-left-color: var(--success-500);
  background: var(--success-50);
}

.status-group.status-loss {
  border-left-color: var(--danger-500);
  background: var(--danger-50);
}

.status-group.status-redeeming {
  border-left-color: var(--warning-500);
  background: var(--warning-50);
}

.status-group.status-failed {
  border-left-color: var(--danger-500);
  background: var(--danger-50);
}

.status-group.status-filled {
  border-left-color: var(--success-500);
  background: var(--success-50);
}

.status-group.status-other {
  border-left-color: var(--info-500);
  background: var(--info-50);
}

.status-group.status-empty {
  border-left-color: var(--neutral-300);
  background: var(--neutral-100);
}

.status-group-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-group-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--neutral-100);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* ========== 专用组件 ========== */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-truncate-2 {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.text-truncate-3 {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.order-id-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 11px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.pnl-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
}

.pnl-indicator.win {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.pnl-indicator.loss {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.pnl-indicator.flat {
  background: rgba(148, 163, 184, 0.12);
  color: var(--neutral);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.data-cell {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-cell-expandable {
  cursor: pointer;
  transition: all 0.2s ease;
}

.data-cell-expandable:hover {
  background: rgba(59, 130, 246, 0.05);
  border-radius: var(--radius-sm);
}

/* ========== 响应式 - 平板横屏 (1024px) ========== */
@media (max-width: 1024px) {
  .header {
    padding: 0 var(--space-4);
  }

  .toolbar {
    padding: 0 var(--space-4);
  }

  .content {
    padding: var(--space-5);
  }

  .header-copy {
    display: none;
  }

  .two-col,
  .config-grid {
    grid-template-columns: 1fr;
  }

  .data-cell {
    max-width: 150px;
  }

  .table-title {
    max-width: 150px;
  }
}

/* ========== 响应式 - 平板竖屏 (768px) ========== */
@media (max-width: 768px) {
  html {
    font-size: 13px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    transform: translateX(-100%);
    width: 280px;
    min-width: 280px;
    height: 100vh;
    box-shadow: var(--shadow-xl);
  }

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

  .sidebar-close-btn {
    display: inline-flex;
  }

  .sidebar-toggle-btn {
    display: inline-flex;
  }

  .header {
    padding: 0 var(--space-4);
    height: 48px;
    min-height: 48px;
  }

  .header-title h2 {
    font-size: 18px;
  }

  .toolbar {
    padding: 0 var(--space-4);
    height: auto;
    min-height: auto;
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
  }

  .toolbar-actions {
    width: 100%;
    justify-content: flex-start;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: var(--space-2);
  }

  .toolbar-actions .btn {
    text-align: center;
    justify-content: center;
  }

  .content {
    padding: var(--space-4);
  }

  .panel {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
  }

  .panel h3 {
    font-size: 16px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-value {
    font-size: 18px;
  }

  .rule-grid,
  .detail-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 8px 10px;
    min-width: 80px;
  }

  .data-cell {
    max-width: 120px;
  }

  .table-title {
    max-width: 120px;
    -webkit-line-clamp: 1;
  }

  .status-group {
    padding: 10px;
    margin-bottom: 12px;
  }

  .toast-stack {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

  .modal-card {
    width: 95%;
    max-width: none;
    padding: 16px;
    margin: 10px;
  }
}

/* ========== 响应式 - 手机 (480px) ========== */
@media (max-width: 480px) {
  html {
    font-size: 13px;
  }

  .header {
    padding: 0 var(--space-3);
  }

  .header-title h2 {
    font-size: 16px;
  }

  .toolbar {
    padding: var(--space-2) var(--space-3);
  }

  .toolbar-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .content {
    padding: var(--space-3);
  }

  .panel {
    padding: var(--space-3);
    border-radius: var(--radius-md);
  }

  .panel h3 {
    font-size: 15px;
  }

  .btn {
    padding: var(--space-2) var(--space-3);
    font-size: 12px;
  }

  .nav-btn {
    padding: 10px 12px;
    font-size: 12px;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
  }

  .metric-card,
  .detail-card {
    padding: 10px;
  }

  .metric-label,
  .detail-label {
    font-size: 10px;
  }

  .metric-value {
    font-size: 16px;
  }

  th,
  td {
    padding: 6px 8px;
    font-size: 11px;
    min-width: 60px;
  }

  th {
    font-size: 10px;
  }

  .table-title {
    font-size: 12px;
    max-width: 100px;
  }

  .badge {
    font-size: 10px;
    padding: var(--space-1) var(--space-2);
  }

  .yaml-preview {
    min-height: 150px;
    max-height: 150px;
    font-size: 11px;
  }

  .modal-card {
    padding: 14px;
  }

  .toast-stack {
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
  }

  .toast {
    font-size: 12px;
    padding: 10px 12px;
  }
}

/* ========== 打印样式 ========== */
@media print {
  .sidebar,
  .toolbar-actions,
  .toast-stack,
  .sidebar-overlay,
  .sidebar-toggle-btn {
    display: none !important;
  }

  .app-layout {
    display: block;
    height: auto;
  }

  .main-wrapper {
    height: auto;
  }

  .content {
    overflow: visible;
    padding: 0;
  }

  .panel {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }
}
