* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
}

/* 导航 */
.nav {
  background: #16213e;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid #0f3460;
}

.nav-title {
  font-size: 18px;
  font-weight: bold;
  color: #00d2ff;
  margin-right: 12px;
}

.nav a {
  color: #a0a0a0;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 4px;
  transition: all 0.2s;
}

.nav a:hover, .nav a.active {
  color: #fff;
  background: #0f3460;
}

.nav-right {
  margin-left: auto;
}

.btn-logout {
  background: none;
  border: 1px solid #e94560;
  color: #e94560;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-logout:hover {
  background: #e94560;
  color: #fff;
}

/* 容器 */
.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 24px;
}

/* 卡片 */
.card {
  background: #16213e;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid #0f3460;
}

.card-title {
  font-size: 16px;
  font-weight: bold;
  color: #00d2ff;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #0f3460;
}

/* 统计网格 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #0f3460;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: bold;
  color: #00d2ff;
}

.stat-label {
  font-size: 13px;
  color: #a0a0a0;
  margin-top: 4px;
}

.stat-value.green { color: #00e676; }
.stat-value.red { color: #e94560; }
.stat-value.yellow { color: #ffc107; }
.stat-value.neutral { color: #e0e0e0; }

.stat-subtext {
  font-size: 12px;
  color: #6f88a8;
  margin-top: 8px;
}

.status-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 32px;
}

.status-item {
  color: #d6def0;
  font-size: 14px;
}

.trend-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.trend-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  flex: 1;
}

.trend-overview-item {
  background: #0f3460;
  border: 1px solid #1b446f;
  border-radius: 8px;
  padding: 12px 14px;
}

.trend-overview-label {
  display: block;
  color: #8ea7c7;
  font-size: 12px;
  margin-bottom: 6px;
}

.trend-overview-value {
  display: block;
  color: #e0e0e0;
  font-size: 18px;
  font-weight: 700;
}

.trend-overview-value.green { color: #00e676; }
.trend-overview-value.red { color: #e94560; }
.trend-overview-value.neutral { color: #e0e0e0; }

.tab-switch {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  background: #0d2b4b;
  border: 1px solid #1b446f;
  border-radius: 999px;
  flex-shrink: 0;
}

.tab-btn {
  border: none;
  background: transparent;
  color: #8ea7c7;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  background: #00d2ff;
  color: #11213a;
}

.chart-shell {
  position: relative;
  background: #0b162b;
  border: 1px solid #153556;
  border-radius: 14px;
  min-height: 360px;
  overflow: hidden;
}

.chart-container {
  width: 100%;
  min-height: 360px;
}

.trend-chart-svg {
  display: block;
  width: 100%;
  height: 360px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8ea7c7;
  font-size: 14px;
  z-index: 1;
}

.chart-empty[hidden] {
  display: none;
}

/* 表格 */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #0f3460;
  font-size: 13px;
}

th {
  color: #a0a0a0;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
}

tr:hover { background: #0f3460; }

.badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
}

.badge-buy { background: #00e67633; color: #00e676; }
.badge-sell { background: #e9456033; color: #e94560; }
.badge-executed { background: #00e67633; color: #00e676; }
.badge-failed { background: #e9456033; color: #e94560; }
.badge-skipped { background: #ffc10733; color: #ffc107; }

.position-row-own td:first-child {
  border-left: 3px solid #00d2ff;
}

.position-row-target td:first-child {
  border-left: 3px solid #ffb347;
}

.position-row-target td {
  color: #ffd3a1;
  background: #2b2217;
}

.position-row-own:hover {
  background: #0f3b5f;
}

.position-row-target:hover {
  background: #3a2a16;
}

.position-legend {
  display: flex;
  gap: 20px;
  align-items: center;
  margin-bottom: 12px;
  color: #a0a0a0;
  font-size: 12px;
}

.position-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.position-legend-line {
  display: inline-block;
  width: 24px;
  height: 3px;
  border-radius: 999px;
}

.position-legend-line.own {
  background: #00d2ff;
}

.position-legend-line.target {
  background: #ffb347;
}

/* 表单 */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: #a0a0a0;
  font-size: 13px;
}

.form-group input, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: #0f3460;
  border: 1px solid #1a1a4e;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 14px;
}

.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: #00d2ff;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-primary {
  background: #00d2ff;
  color: #1a1a2e;
}

.btn-primary:hover {
  background: #00b8e6;
}

.btn-danger {
  background: #e94560;
  color: #fff;
}

/* 日志容器 */
.log-container {
  background: #0a0a1a;
  border-radius: 4px;
  padding: 12px;
  height: 600px;
  overflow-y: auto;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  line-height: 1.6;
}

.log-line { white-space: pre-wrap; word-break: break-all; }
.log-info { color: #a0d0ff; }
.log-warn { color: #ffc107; }
.log-error { color: #e94560; }

/* 登录页 */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.login-box {
  background: #16213e;
  border-radius: 12px;
  padding: 40px;
  width: 360px;
  border: 1px solid #0f3460;
}

.login-box h1 {
  text-align: center;
  color: #00d2ff;
  margin-bottom: 24px;
  font-size: 22px;
}

.login-box .btn {
  width: 100%;
  margin-top: 8px;
}

.error-msg {
  color: #e94560;
  font-size: 13px;
  text-align: center;
  margin-top: 8px;
  display: none;
}

/* 筛选栏 */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-bar select, .filter-bar input {
  padding: 8px 12px;
  background: #0f3460;
  border: 1px solid #1a1a4e;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 13px;
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.pagination button {
  padding: 6px 12px;
  background: #0f3460;
  border: 1px solid #1a1a4e;
  border-radius: 4px;
  color: #e0e0e0;
  cursor: pointer;
}

.pagination button:hover { background: #1a1a4e; }
.pagination button.active { background: #00d2ff; color: #1a1a2e; }
.pagination span { padding: 6px 12px; color: #a0a0a0; }

/* 连接状态 */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.online { background: #00e676; }
.status-dot.offline { background: #e94560; }

/* 全局日志面板 */
#globalLogPanel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #0d1117;
  border-top: 1px solid #0f3460;
  transition: height 0.2s ease;
}

#globalLogPanel:not(.expanded) {
  height: 36px;
}

#globalLogPanel.expanded {
  height: 280px;
}

#logPanelHeader {
  display: flex;
  align-items: center;
  padding: 6px 16px;
  background: #161b22;
  border-bottom: 1px solid #0f3460;
  cursor: pointer;
  font-size: 13px;
  color: #e0e0e0;
  height: 36px;
  user-select: none;
}

#logPanelHeader button {
  background: #0f3460;
  border: 1px solid #1a1a4e;
  color: #a0a0a0;
  padding: 2px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
}

#logPanelHeader button:hover {
  background: #1a1a4e;
  color: #fff;
}

#logPanelBody {
  height: calc(100% - 36px);
  overflow-y: auto;
  padding: 8px 12px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  line-height: 1.5;
}

#globalLogPanel:not(.expanded) #logPanelBody {
  display: none;
}

/* 给页面内容留底部空间 */
body { padding-bottom: 40px; }

/* 响应式 */
@media (max-width: 768px) {
  .nav { flex-wrap: wrap; gap: 8px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; }
  .trend-toolbar { flex-direction: column; }
  .tab-switch { width: 100%; justify-content: space-between; }
  .tab-btn { flex: 1; }
  .chart-shell,
  .chart-container,
  .trend-chart-svg { min-height: 300px; height: 300px; }
  #globalLogPanel.expanded { height: 200px; }
}
