/* CSS Variables - Design Tokens */
:root {
  /* Colors */
  --color-profit: #67c23a;
  --color-profit-light: #e1f3d8;
  --color-loss: #f56c6c;
  --color-loss-light: #fde2e2;
  --color-brand: #6366F1;
  --color-brand-light: #EEF2FF;
  --color-brand-hover: #818CF8;
  --color-brand-deep: #4F46E5;
  --color-warning: #e6a23c;
  --color-neutral: #909399;
  --color-text-primary: #303133;
  --color-text-secondary: #606266;
  --color-text-muted: #909399;
  --color-surface: #ffffff;
  --color-bg: #f5f7fa;
  --color-border: #ebeef5;
  --color-border-dark: #e4e7ed;
  --color-sidebar: #1E1B4B;
  --color-terminal-bg: #0F172A;
  --color-terminal-text: #d4d4d4;
  --color-terminal-timestamp: #A5B4FC;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;

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

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease-out;
  --transition-slow: 300ms ease-out;
}

body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue","PingFang SC","Hiragino Sans GB","Microsoft YaHei",Arial,sans-serif;background:var(--color-bg)}
.container{max-width:1280px;margin:0 auto;padding:20px}
.center{text-align:center}
.mb-24{margin-bottom:24px}
.mt-16{margin-top:16px}
.mt-8{margin-top:8px}
.w-full{width:100%}
/* Login - Centered Box */
.login-center{display:flex;justify-content:center;align-items:center;height:100vh;background:var(--color-bg)}
.login-box{width:100%;max-width:400px;padding:40px;background:#fff;border-radius:12px;box-shadow:0 8px 30px rgba(0,0,0,.08)}
.login-brand{text-align:center;margin-bottom:28px}
.login-brand h2{font-size:22px;font-weight:700;color:#1E1B4B;margin:0 0 6px}
.login-desc{font-size:14px;color:#909399}
.login-box .el-button--primary{background:var(--color-brand);border-color:var(--color-brand)}
.login-box .el-button--primary:hover{background:var(--color-brand-hover);border-color:var(--color-brand-hover)}

.aside-dark{background:#1E1B4B;color:#fff;display:flex;flex-direction:column;height:100%}
.aside-head{padding:16px 12px 8px;display:flex;align-items:center;gap:10px}
.brand-mark{width:32px;height:32px;border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:800;color:#fff;background:linear-gradient(135deg,#6366F1 0%,#818CF8 100%);flex-shrink:0}
.brand{font-weight:700;font-size:14px}
.brand-subtitle{font-size:11px;opacity:0.5;margin-top:2px}
.who{font-size:12px;opacity:.8;margin-top:6px}
.aside-footer{margin-top:auto;padding:12px;display:flex;flex-direction:column;gap:8px}
.aside-user{display:flex;align-items:center;gap:8px;padding:8px;border-radius:6px;background:rgba(255,255,255,0.06)}
.aside-user-avatar{width:28px;height:28px;border-radius:6px;background:linear-gradient(135deg,#6366F1,#818CF8);display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;color:#fff;flex-shrink:0}
.aside-user-name{font-size:13px;opacity:0.9;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* Sidebar menu active state */
.aside-dark .el-menu-item.is-active{background:rgba(99,102,241,0.15) !important;border-left:3px solid #818CF8;padding-left:17px !important}
.aside-dark .el-menu-item:hover{background:#312E81 !important}

.topbar{display:flex;align-items:center;justify-content:space-between;background:rgba(255,255,255,0.85);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);border-radius:12px;margin-bottom:16px;padding:0 16px}
.topbar .left{display:flex;align-items:center;gap:8px}
.brand-link{font-weight:700;color:#6366F1;text-decoration:none}
.main{padding:0}
.grid-2{display:grid;grid-template-columns:1fr;gap:16px}
@media(min-width:1100px){.grid-2{grid-template-columns:1fr 1fr}}
.panel{min-height:360px}
.panel-head{display:flex;align-items:center;justify-content:space-between}
.gap-8>*{margin-left:8px}

/* Log + Orders - Vertical Flex Layout for space efficiency */
.log-orders{
  display:flex;
  flex-direction:column;
  gap:16px;
  height:calc(100vh - 160px);
}

/* Log Panel - collapsible */
.log-panel{
  flex-shrink:0;
  transition:var(--transition-slow);
}
.log-panel.collapsed{
  min-height:auto !important;
}
.log-panel.collapsed .el-card__body{
  display:none !important;
  padding:0 !important;
}

/* Orders Panel - auto-expand to fill remaining space */
.log-orders > .el-card:last-child{
  flex:1;
  min-height:200px;
  display:flex;
  flex-direction:column;
}
.log-orders > .el-card:last-child > .el-card__body{
  flex:1;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

/* Orders window - flex to fill available space */
.orders-window{
  background:#fff;
  padding:10px;
  flex:1;
  overflow-y:auto;
  border-radius:8px;
  border:1px solid #ebeef5;
}

/* Responsive: stack vertically on mobile */
@media(max-width:768px){
  .log-orders{
    height:auto;
  }
  .orders-window{
    min-height:400px;
  }
}
.log-line{padding:2px 0;border-bottom:1px dashed rgba(255,255,255,.06)}
.timestamp{color:#A5B4FC;margin-right:8px}
/* Order Item - Enhanced */
.order-item{padding:14px;margin-bottom:10px;border-radius:10px;background:#fff;border:1px solid #e4e7ed;transition:all 0.2s ease-out}
.order-item:hover{transform:translateY(-1px);box-shadow:0 4px 12px rgba(0,0,0,0.06)}
.order-item.order-profit{border-left:3px solid var(--color-profit)}
.order-item.order-loss{border-left:3px solid var(--color-loss)}
.order-item.order-open{border-left:3px solid var(--color-warning);background:linear-gradient(135deg,#fffaf0 0%,#fff8e6 100%)}
.order-open-footer{background:linear-gradient(135deg,#fdf6ec 0%,#faecd8 100%)}
.pnl-value.pending{color:var(--color-warning);font-size:14px}
.order-header{display:flex;align-items:center;gap:10px;margin-bottom:10px;padding-bottom:10px;border-bottom:1px solid #ebeef5}
.order-seq{font-size:13px;font-weight:700;color:#303133;min-width:32px}
.side-tag{font-size:10px;font-weight:700;padding:3px 8px;border-radius:4px;text-transform:uppercase;letter-spacing:0.5px}
.side-tag.long{background:linear-gradient(135deg,#e1f3d8 0%,#d9f0ce 100%);color:#67c23a;border:1px solid #c2e7b0}
.side-tag.short{background:linear-gradient(135deg,#fde2e2 0%,#fcd5d5 100%);color:#f56c6c;border:1px solid #f9b4b4}
.symbol{font-weight:600;color:#303133;font-size:13px;flex:1}
.order-status{font-size:10px;font-weight:600;padding:2px 6px;border-radius:3px;background:#e6a23c;color:#fff;animation:pulse 2s infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.7}}
.order-grid{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:12px;background:#fafbfc;padding:10px;border-radius:6px;margin-bottom:10px}
.order-row{display:grid;grid-template-columns:48px 1fr 100px 100px;gap:0;padding:6px 0;align-items:center}
.order-row:not(:last-child){border-bottom:1px dashed #ebeef5}
.order-row .label{color:#909399;font-weight:600;font-size:11px;text-transform:uppercase;padding-right:8px}
.order-row .time{color:#606266;font-size:12px;padding:0 10px;border-left:1px solid #e4e7ed}
.order-row .price{color:#303133;font-weight:500;padding:0 10px;border-left:1px solid #e4e7ed}
.order-row .qty{color:#606266;text-align:right;padding-left:10px;border-left:1px solid #e4e7ed}
.order-row.closed .label{color:#67c23a}
.order-footer{display:flex;justify-content:space-between;align-items:center;padding:10px 12px;background:linear-gradient(135deg,#fafafa 0%,#f5f7fa 100%);border-radius:6px}
.pnl-label{color:#606266;font-size:12px;font-weight:500}
.pnl-value{font-weight:700;font-size:16px;font-family:ui-monospace,SFMono-Regular,monospace}
.pnl-value.profit{color:#67c23a}
.pnl-value.loss{color:#f56c6c}

/* Summary Card - MAC Strategy */
.summary-card{padding:16px;margin-bottom:12px;border-radius:10px;background:linear-gradient(135deg,#f8fafc 0%,#f0f4f8 100%);border:1px solid #e4e7ed;border-left:4px solid #6366F1}
.summary-header{display:flex;align-items:center;gap:10px;margin-bottom:14px;padding-bottom:12px;border-bottom:1px solid #e4e7ed}
.summary-header b{font-size:14px;color:#303133;letter-spacing:0.3px}
.summary-icon{width:24px;height:24px;border-radius:6px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;color:#fff;background:linear-gradient(135deg,#6366F1 0%,#818CF8 100%);box-shadow:0 2px 6px rgba(99,102,241,0.3)}
.summary-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:14px}
.summary-stat{padding:10px 12px;background:#fff;border-radius:6px;border:1px solid #ebeef5;transition:all 0.15s ease}
.summary-stat:hover{border-color:#dcdfe6;box-shadow:0 2px 8px rgba(0,0,0,0.04)}
.stat-label{display:block;font-size:11px;color:#909399;text-transform:uppercase;letter-spacing:0.5px;margin-bottom:4px}
.stat-value{font-size:16px;font-weight:700;color:#303133;font-family:ui-monospace,SFMono-Regular,monospace}
.stat-value.profit{color:#67c23a}
.stat-value.loss{color:#f56c6c}
.stat-value.positive{color:#67c23a}
.stat-value.neutral{color:#909399}
.summary-footer{display:flex;justify-content:space-between;align-items:center;padding:12px 14px;background:#fff;border-radius:8px;border:1px solid #ebeef5}
.net-pnl-label{font-size:13px;font-weight:600;color:#606266}
.net-pnl-value{font-size:20px;font-weight:700;font-family:ui-monospace,SFMono-Regular,monospace}
.net-pnl-value.profit{color:#67c23a}
.net-pnl-value.loss{color:#f56c6c}
.muted{color:#909399}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.label{font-size:12px;color:#606266;margin-bottom:6px}

/* Settings Readonly View */
.settings-readonly{padding:4px 0}
.config-section{margin-bottom:20px;padding-bottom:16px;border-bottom:1px solid var(--color-border)}
.config-section:last-of-type{border-bottom:none;margin-bottom:12px}
.config-section-title{font-size:14px;font-weight:600;color:var(--color-text-primary);margin-bottom:12px;display:flex;align-items:center;gap:8px}
.config-section-title::before{content:'';display:block;width:3px;height:14px;background:var(--color-brand);border-radius:2px}
.config-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
@media(max-width:600px){.config-grid{grid-template-columns:repeat(2,1fr)}}
.config-item{padding:10px 12px;background:var(--color-bg);border-radius:var(--radius-sm);border:1px solid var(--color-border)}
.config-label{display:block;font-size:11px;color:var(--color-text-muted);text-transform:uppercase;letter-spacing:0.5px;margin-bottom:4px}
.config-value{display:block;font-size:14px;font-weight:600;color:var(--color-text-primary);font-family:ui-monospace,monospace}
.config-hint{display:flex;align-items:center;gap:8px;padding:12px;background:#EEF2FF;border-radius:var(--radius-sm);color:#6366F1;font-size:13px}

.el-main{padding:0;height:100vh}
.el-main iframe{width:100%;height:100vh;border:0;display:block}

.status-dot{display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:8px}
.status-dot.running{background-color:#67c23a}
.status-dot.stopped{background-color:#f56c6c}
.status-dot.checking{background-color:#e6a23c;animation:status-pulse 1.5s infinite}
.status-dot.unknown{background-color:#909399;animation:status-pulse 2s infinite}
@keyframes status-pulse{0%,100%{opacity:1}50%{opacity:0.4}}
.run-id-tag{margin-left:8px;font-family:monospace}

/* Volume Statistics & Paired Orders - now using Tailwind */
.leg-empty{font-size:12px;color:var(--color-text-muted);font-style:italic}

/* Split Layout for Orders Panel */
.orders-split {
  display: flex;
  gap: 16px;
  height: 100%;
}

.orders-summary-fixed {
  flex: 0 0 35%;
  min-width: 260px;
  max-width: 320px;
  overflow: hidden;  /* No scroll, fixed content */
  display: flex;
  flex-direction: column;
}

.orders-list-scroll {
  flex: 1;
  min-width: 0;  /* Prevent content from expanding */
  overflow-y: auto;
  padding-right: 4px;  /* Space for scrollbar */
}

/* Mobile responsive: vertical stack */
@media (max-width: 768px) {
  .orders-split {
    flex-direction: column;
  }
  .orders-summary-fixed {
    flex: none;
    max-width: none;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
  }
  .orders-list-scroll {
    flex: 1;
    min-height: 300px;
  }
}
