/* ==========================================
   styles.css - EasyTrader 量化交易平台
   Design System: Financial Dashboard (Dark OLED)
   Font: Inter | Palette: #020617 deep navy
   ========================================== */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ── */
:root {
  /* Surfaces */
  --bg-primary: #020617;
  --bg-secondary: #0E1223;
  --bg-card: #111827;
  --bg-hover: #1E293B;
  --bg-input: #0F172A;

  /* Borders */
  --border-color: #1E293B;
  --border-focus: #3B82F6;

  /* Text */
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  /* Semantic Colors */
  --accent-blue: #3B82F6;
  --accent-green: #22C55E;
  --accent-red: #EF4444;
  --accent-yellow: #F59E0B;
  --accent-purple: #A78BFA;
  --accent-orange: #F97316;
  --color-positive: #22C55E;
  --color-negative: #EF4444;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);

  /* Transitions */
  --transition-fast: 0.1s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Layout */
  --sidebar-width: 200px;
  --header-height: 52px;
  --bottom-nav-height: 56px;
}

/* ── Light Theme ── */
body.light {
  --bg-primary: #F8FAFC;
  --bg-secondary: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-hover: #F1F5F9;
  --bg-input: #F8FAFC;
  --border-color: #E2E8F0;
  --border-focus: #2563EB;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --accent-blue: #2563EB;
  --accent-green: #16A34A;
  --accent-red: #DC2626;
  --accent-yellow: #CA8A04;
  --color-positive: #16A34A;
  --color-negative: #DC2626;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-slow), color var(--transition-slow);
}

/* ── Header ── */
.header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo svg { flex-shrink: 0; }

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

.header-spacer { flex: 1; }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-base);
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
  animation: pulse 2s infinite;
}

/* ── Layout ── */
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar (Desktop) ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 8px;
  flex-shrink: 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition-base);
  margin-bottom: 1px;
  user-select: none;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-blue);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-section-title {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 12px 4px;
}

/* ── Main Content ── */
.main {
  flex: 1;
  overflow-y: scroll;
  padding: 20px;
  background: var(--bg-primary);
  max-height: calc(100vh - var(--header-height));
}

.main-full {
  overflow: hidden;
  background: var(--bg-primary);
  height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
}

.main::-webkit-scrollbar { width: 4px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  line-height: 1.5;
}
.badge-blue { background: rgba(59,130,246,0.15); color: #60A5FA; }
.badge-green { background: rgba(34,197,94,0.15); color: var(--accent-green); }
.badge-red { background: rgba(239,68,68,0.15); color: #F87171; }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--accent-yellow); }
.badge-purple { background: rgba(167,139,250,0.15); color: var(--accent-purple); }
.badge-default { background: var(--bg-hover); color: var(--text-secondary); }

/* ── Tags ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 2px 8px;
  border-radius: 12px;
}
.tag-close { cursor: pointer; color: var(--text-muted); font-size: 14px; line-height: 1; display: flex; }
.tag-close:hover { color: var(--accent-red); }

.tags-input {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  background: var(--bg-hover); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 6px 10px; min-height: 38px; cursor: text;
}
.tags-input:focus-within { border-color: var(--border-focus); }
.tags-input input {
  border: none; outline: none; background: transparent;
  color: var(--text-primary); font-size: 13px; min-width: 120px; flex: 1;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-md); font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid transparent; transition: all var(--transition-base);
  user-select: none; white-space: nowrap; font-family: inherit;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:not(:disabled):hover { background: #2563EB; }
.btn-success { background: var(--accent-green); color: #fff; }
.btn-success:not(:disabled):hover { background: #16A34A; }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:not(:disabled):hover { background: #DC2626; }
.btn-secondary { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-color); }
.btn-secondary:not(:disabled):hover { background: #334155; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:not(:disabled):hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 15px; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-hint { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }
.form-label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.form-input {
  width: 100%; background: var(--bg-hover); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 8px 12px; color: var(--text-primary);
  font-size: 13px; outline: none; transition: border-color var(--transition-base); font-family: inherit;
}
.form-input:focus { border-color: var(--border-focus); }
.form-input::placeholder { color: var(--text-muted); }
select.form-input {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Metrics Grid ── */
.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.metric-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 14px 16px; text-align: center;
}
.metric-value { font-size: 20px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.metric-value.positive { color: var(--color-positive); }
.metric-value.negative { color: var(--color-negative); }
.metric-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 16px; gap: 0; overflow-x: auto; }
.tabs::-webkit-scrollbar { height: 0; }
.tab-item {
  padding: 8px 16px; font-size: 13px; cursor: pointer; color: var(--text-secondary);
  border-bottom: 2px solid transparent; transition: all var(--transition-base);
  white-space: nowrap; user-select: none;
}
.tab-item:hover { color: var(--text-primary); }
.tab-item.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); }

/* ── Tables ── */
.table-container { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border-color); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 11px; color: var(--text-muted); font-weight: 600;
  padding: 8px 12px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.data-table td {
  padding: 8px 12px; font-size: 13px; border-bottom: 1px solid rgba(30,41,59,0.5);
  color: var(--text-secondary);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(30,41,59,0.4); }

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000;
  display: flex; align-items: center; justify-content: center; animation: fadeIn 0.15s ease;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-xl); width: 560px; max-width: 90vw; max-height: 90vh;
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
.modal-lg { width: 900px; }
.modal-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border-color);
  display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px; border-radius: var(--radius-sm); font-size: 18px; line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Alerts ── */
.alert {
  padding: 10px 14px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 12px;
  border: 1px solid; display: flex; align-items: center; gap: 8px;
}
.alert-info { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.2); color: #60A5FA; }
.alert-success { background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.2); color: var(--accent-green); }
.alert-error { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.2); color: #F87171; }
.alert-warning { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.2); color: var(--accent-yellow); }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-desc { font-size: 13px; }

/* ── Progress Bar ── */
.progress-bar { height: 4px; background: var(--bg-hover); border-radius: 2px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; background: var(--accent-blue); border-radius: 2px; transition: width 0.3s ease; }

/* ── Spinner ── */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--bg-hover); border-top-color: var(--accent-blue);
  border-radius: 50%; animation: spin 0.6s linear infinite; flex-shrink: 0;
}
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

/* ── Utility Classes ── */
.text-positive { color: var(--color-positive); }
.text-negative { color: var(--color-negative); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-mono { font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace; }
.font-tabular { font-variant-numeric: tabular-nums; }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

/* ── Drawer ── */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 400; }
.drawer {
  position: fixed; top: 0; left: 0; height: 100%; width: 280px;
  background: var(--bg-secondary); border-right: 1px solid var(--border-color);
  z-index: 500; transform: translateX(-100%); transition: transform var(--transition-slow);
  overflow-y: auto; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-header { padding: 14px 16px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.drawer-content { padding: 12px; flex: 1; overflow-y: auto; }

/* ── Strategy Cards ── */
.strategy-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px; transition: all var(--transition-base);
}
.strategy-card:hover { border-color: #334155; }
.strategy-card-info { flex: 1; min-width: 0; }
.strategy-card-name { font-size: 14px; font-weight: 600; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strategy-card-desc { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strategy-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Template Items ── */
.template-item {
  padding: 12px 14px; border-radius: var(--radius-md); cursor: pointer;
  border: 1px solid var(--border-color); margin-bottom: 8px; transition: all var(--transition-base);
}
.template-item:hover { background: var(--bg-hover); border-color: var(--accent-blue); }
.template-item-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.template-item-desc { font-size: 12px; color: var(--text-muted); }

/* ── Backtest Layout ── */
.backtest-layout { display: flex; height: calc(100vh - var(--header-height)); overflow: hidden; }
.backtest-editor-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.backtest-toolbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.backtest-toolbar-title { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.editor-container { flex: 1; overflow: hidden; }
.backtest-config {
  width: 280px; background: var(--bg-secondary); border-left: 1px solid var(--border-color);
  overflow-y: auto; padding: 14px; flex-shrink: 0;
}
.backtest-config::-webkit-scrollbar { width: 4px; }
.backtest-config::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }
.config-section-title {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 10px;
}

/* ── Result Page ── */
.result-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border-color);
}
.result-title { font-size: 16px; font-weight: 700; flex: 1; }
.result-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Progress (Backtest) ── */
.bt-progress-wrap { padding: 8px 12px 6px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.bt-progress-bar-track { height: 4px; background: var(--bg-hover); border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.bt-progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-blue), #60A5FA); border-radius: 2px; transition: width 0.4s ease; }
.bt-progress-info { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; }
.bt-progress-pct { font-weight: 600; color: var(--accent-blue); min-width: 38px; }
.bt-progress-date { font-family: monospace; color: var(--text-primary); }
.bt-progress-spacer { flex: 1; }
.bt-progress-value { font-family: monospace; color: var(--text-primary); }
.bt-progress-returns { font-weight: 600; font-family: monospace; }

/* ── AI Panel ── */
.bt-ai-panel {
  width: 0; min-width: 0; overflow: hidden; display: flex; flex-direction: column;
  background: var(--bg-secondary); border-left: 1px solid var(--border-color);
  transition: width 0.2s ease, min-width 0.2s ease; flex-shrink: 0;
}
.bt-ai-panel.open { width: 360px; min-width: 300px; }
.bt-ai-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border-color); font-size: 13px; flex-shrink: 0; }
.bt-ai-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.bt-ai-hint { font-size: 12px; color: var(--text-secondary); line-height: 1.7; }
.bt-ai-hint ul { padding-left: 16px; margin: 6px 0; }
.bt-ai-hint li { color: var(--accent-blue); text-decoration: underline dotted; margin-bottom: 4px; }
.bt-ai-msg { display: flex; }
.bt-ai-msg.user { justify-content: flex-end; }
.bt-ai-msg.assistant { justify-content: flex-start; }
.bt-ai-msg-bubble { max-width: 92%; border-radius: 10px; padding: 8px 12px; font-size: 12.5px; line-height: 1.6; }
.bt-ai-msg.user .bt-ai-msg-bubble { background: var(--accent-blue); color: #fff; border-bottom-right-radius: 3px; }
.bt-ai-msg.assistant .bt-ai-msg-bubble { background: var(--bg-card); border: 1px solid var(--border-color); border-bottom-left-radius: 3px; }
.bt-ai-msg-text { margin: 0; white-space: pre-wrap; word-break: break-word; }
.bt-ai-msg-text code, .bt-ai-msg-text pre { font-family: 'SF Mono', Consolas, monospace; font-size: 11.5px; }
.bt-ai-apply-btn {
  display: block; margin-top: 8px; padding: 4px 10px; font-size: 11px;
  background: var(--bg-hover); border: 1px solid var(--border-color); border-radius: 4px;
  color: var(--accent-blue); cursor: pointer; width: 100%; text-align: center;
}
.bt-ai-apply-btn:hover { background: var(--bg-secondary); }
.bt-ai-loading { display: flex; gap: 4px; padding: 4px 2px; }
.bt-ai-loading span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-secondary); animation: bt-ai-blink 1.2s infinite ease-in-out; }
.bt-ai-loading span:nth-child(2) { animation-delay: 0.2s; }
.bt-ai-loading span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bt-ai-blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
.bt-ai-input-row { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border-color); flex-shrink: 0; align-items: flex-end; }
.bt-ai-textarea { flex: 1; resize: none; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-primary); font-size: 12.5px; padding: 7px 10px; font-family: inherit; outline: none; min-height: 52px; }
.bt-ai-textarea:focus { border-color: var(--accent-blue); }
.bt-ai-send-btn { width: 36px; height: 36px; background: var(--accent-blue); border: none; border-radius: 6px; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bt-ai-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.bt-ai-btn-active { color: var(--accent-blue) !important; border-color: var(--accent-blue) !important; }

/* ── Checkbox ── */
.checkbox-wrapper { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.checkbox-wrapper input[type="checkbox"] { width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent-blue); }

/* ── Data Management ── */
.data-result-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; border-bottom: 1px solid rgba(30,41,59,0.3); }
.data-result-item:last-child { border-bottom: none; }

/* ── Run Status ── */
.run-status {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: rgba(59,130,246,0.08); border: 1px solid rgba(59,130,246,0.2);
  border-radius: var(--radius-md); font-size: 13px; color: #60A5FA; margin-top: 8px;
}

/* ── Dropdowns ── */
.dropdown { position: relative; display: inline-flex; }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); right: 0; background: var(--bg-card);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); z-index: 200; min-width: 150px; overflow: hidden;
}
.dropdown-item { padding: 8px 14px; font-size: 13px; cursor: pointer; color: var(--text-secondary); transition: all var(--transition-fast); }
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Log Container ── */
.log-container {
  background: var(--bg-primary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 10px; max-height: 300px;
  overflow-y: auto; font-family: 'SF Mono', Consolas, monospace; font-size: 12px;
}
.log-container::-webkit-scrollbar { width: 4px; }
.log-container::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }
.log-line { padding: 1px 0; white-space: pre-wrap; word-break: break-all; line-height: 1.6; }

/* ── Scrollbar ── */
.scrollbar-custom::-webkit-scrollbar { width: 4px; height: 4px; }
.scrollbar-custom::-webkit-scrollbar-track { background: transparent; }
.scrollbar-custom::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

/* ── Vue ── */
[v-cloak] { display: none; }

/* ── Divider ── */
.divider { height: 1px; background: var(--border-color); margin: 16px 0; }

/* Page Title */
.page-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }

/* ── Animations ── */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ========================================
   RESPONSIVE - Tablet
   ======================================== */
@media (max-width: 1199px) {
  :root { --sidebar-width: 56px; }
  .nav-item span { display: none; }
  .nav-section-title { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
}

/* ========================================
   RESPONSIVE - Mobile (< 768px)
   ======================================== */

/* Desktop: show table, hide cards */
.m-cards { display: none; }
.m-table { display: block; }

/* Mobile bottom nav (hidden on desktop) */
.mobile-nav { display: none; }

@media (max-width: 767px) {
  :root {
    --header-height: 48px;
  }

  /* Hide sidebar */
  .sidebar { display: none; }

  /* Compact header */
  .header { padding: 0 12px; gap: 6px; }
  .header-subtitle { display: none; }
  .header-title { font-size: 15px; }
  .header-status span { display: none; }

  /* ── Bottom Tab Bar (iOS style) ── */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0));
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease;
    min-height: 44px; /* touch target */
  }
  .mobile-nav-item.active {
    color: var(--accent-blue);
  }
  .mobile-nav-item svg {
    width: 22px; height: 22px;
  }

  /* Content area reserves space for bottom nav */
  .layout {
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0));
  }
  .main {
    padding: 12px;
    max-height: calc(100vh - var(--header-height) - var(--bottom-nav-height) - env(safe-area-inset-bottom, 0));
  }
  .main-full {
    height: calc(100vh - var(--header-height) - var(--bottom-nav-height) - env(safe-area-inset-bottom, 0));
  }

  /* Grids → 2 col on mobile */
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }

  /* Backtest responsive */
  .backtest-layout {
    flex-direction: column;
    height: calc(100vh - var(--header-height) - var(--bottom-nav-height) - env(safe-area-inset-bottom, 0));
  }
  .backtest-config { width: 100%; border-left: none; border-top: 1px solid var(--border-color); max-height: 40vh; }

  /* Cards compact */
  .card { padding: 12px; border-radius: var(--radius-md); }
  .card-title { font-size: 12px; margin-bottom: 8px; }

  /* Modal mobile */
  .modal { width: 95vw; border-radius: var(--radius-lg); }

  /* ── Switch: hide desktop table, show mobile cards ── */
  .m-table { display: none !important; }
  .m-cards { display: block !important; }

  /* ── Position Card (Mobile) ── */
  .pos-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 8px;
  }
  .pos-card-row1 {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
  }
  .pos-card-left {
    display: flex;
    align-items: baseline;
    gap: 6px;
  }
  .pos-card-code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
  }
  .pos-card-name {
    font-size: 12px;
    color: var(--text-muted);
  }
  .pos-card-pct {
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }
  .pos-card-row2 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    font-size: 11px;
  }
  .pos-card-cell {
    display: flex;
    flex-direction: column;
    gap: 1px;
  }
  .pos-card-label {
    color: var(--text-muted);
    font-size: 10px;
  }
  .pos-card-val {
    color: var(--text-primary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
  }

  /* ── Order Card (Mobile) ── */
  .order-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .order-card-side {
    font-size: 14px;
    font-weight: 700;
    width: 36px;
    text-align: center;
    flex-shrink: 0;
  }
  .order-card-info {
    flex: 1;
    min-width: 0;
  }
  .order-card-code {
    font-family: monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
  }
  .order-card-detail {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .order-card-badge {
    flex-shrink: 0;
  }
}
