body {
  background-color: #f8f9fa;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'PingFang SC', sans-serif;
  padding: 15px;
  font-size: 0.9rem;
}

/* 盈亏统计表格列宽优化 */
#strategyGroupPnlStatsBody td:nth-child(1),
#strategyGroupPnlStatsBody th:nth-child(1),
#contractGroupPnlStatsBody td:nth-child(1),
#contractGroupPnlStatsBody th:nth-child(1),
#strategyContractPnlStatsBody td:nth-child(1),
#strategyContractPnlStatsBody th:nth-child(1),
#strategyContractPnlStatsBody td:nth-child(2),
#strategyContractPnlStatsBody th:nth-child(2) {
  width: 20%;
  max-width: 200px;
  word-break: break-word;
}

#strategyGroupPnlStatsBody td:nth-child(2),
#strategyGroupPnlStatsBody th:nth-child(2),
#contractGroupPnlStatsBody td:nth-child(2),
#contractGroupPnlStatsBody th:nth-child(2),
#strategyContractPnlStatsBody td:nth-child(3),
#strategyContractPnlStatsBody th:nth-child(3) {
  width: 15%;
}

#strategyGroupPnlStatsBody td:not(:nth-child(1)):not(:nth-child(2)),
#strategyGroupPnlStatsBody th:not(:nth-child(1)):not(:nth-child(2)),
#contractGroupPnlStatsBody td:not(:nth-child(1)):not(:nth-child(2)),
#contractGroupPnlStatsBody th:not(:nth-child(1)):not(:nth-child(2)),
#strategyContractPnlStatsBody td:not(:nth-child(1)):not(:nth-child(2)):not(:nth-child(3)),
#strategyContractPnlStatsBody th:not(:nth-child(1)):not(:nth-child(2)):not(:nth-child(3)) {
  width: 13%;
}

/* 8等分布局 - 每个占12.5%宽度 */
.col-lg-1-5 {
  flex: 0 0 12.5%;
  max-width: 12.5%;
}

/* 状态栏6等分布局 - 每个占16.67%宽度 */
.col-status-5 {
  flex: 0 0 16.6667%;
  max-width: 16.6667%;
}

/* 响应式适配 */
@media (min-width: 992px) {
  .col-lg-1-5 {
    flex: 0 0 12.5%;
    max-width: 12.5%;
  }
}

@media (max-width: 991px) {
  .col-lg-1-5 {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

@media (max-width: 767px) {
  .col-lg-1-5 {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

/* 持仓明细表格 操作列宽度优化 */
#positionsTable td:last-child,
#positionsTable th:last-child,
#deliveryTimeRangesTable td:last-child,
#deliveryTimeRangesTable th:last-child {
  width: 1%;
  white-space: nowrap;
  text-align: left;
}

.btn-warning {
  background-color: #ffc107;
  border-color: #ffc107;
  color: #212529;
  font-size: 0.9rem;
  padding: 0.375rem 0.75rem;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.btn-warning:hover {
  background-color: #e0a800;
  border-color: #d39e00;
  color: #212529;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.btn-info {
  background-color: #17a2b8;
  border-color: #17a2b8;
  color: #fff;
  font-size: 0.9rem;
  padding: 0.375rem 0.75rem;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.btn-info:hover {
  background-color: #138496;
  border-color: #117a8b;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.control-btn {
  transition: all 0.2s ease-in-out;
  min-width: 100px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-bottom: 5px;
  padding: 0 10px;
  white-space: nowrap;
}
.control-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.header {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: white;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.card-stat {
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  height: 100%;
  border: none;
}
.card-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 5px;
}
.stat-title {
  font-size: 0.8rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.section-title {
  border-left: 3px solid #6c5ce7;
  padding-left: 10px;
  margin-top: 25px;
  margin-bottom: 15px;
  font-weight: 600;
  font-size: 1.1rem;
}
.nav-tabs .nav-link {
  font-weight: 500;
  color: #495057;
  border: none;
  padding: 10px 15px;
  font-size: 0.9rem;
}
.nav-tabs .nav-link.active {
  color: #6c5ce7;
  border: none;
  border-bottom: 3px solid #6c5ce7 !important;
  background-color: transparent;
}
.nav-tabs {
  border-bottom: 2px solid #e9ecef;
  margin-bottom: 15px;
}
.table th {
  font-weight: 600;
  color: #495057;
  font-size: 0.85rem;
  padding: 0.5rem;
  border-right: 1px solid #dee2e6;
}
.table th:last-child {
  border-right: none;
}
.table td {
  font-size: 0.85rem;
  padding: 0.4rem;
}
.order-client-order-id-col {
  width: 96px;
  max-width: 96px;
}
.order-client-order-id-cell {
  width: 96px;
  max-width: 96px;
}
.order-client-order-id-text {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.order-contract-name-col,
.order-contract-name-cell {
  white-space: nowrap;
}
.order-contract-name-text {
  display: inline;
  white-space: nowrap;
}
.order-time-col,
.order-time-cell,
.order-trade-time-col,
.order-trade-time-cell,
.order-updated-time-col,
.order-updated-time-cell {
  min-width: 148px;
  white-space: nowrap;
}
.order-strategy-col,
.order-strategy-cell {
  width: 104px;
  min-width: 104px;
  max-width: 104px;
}
.order-open-strategy-col,
.order-open-strategy-cell {
  width: 80px;
  min-width: 80px;
  max-width: 80px;
  padding-right: 4px !important;
  padding-left: 4px !important;
}
.order-strategy-text,
.order-open-strategy-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-comment-cell {
  width: 200px;
  max-width: 200px;
}
.order-comment-text {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.dashboard-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
#ordersTable th,
#ordersTable td,
#ordersTable .table-header-cell,
#ordersTable .order-action-menu,
#ordersTable .order-action-menu .btn {
  white-space: nowrap;
}
.order-operation-col,
.order-operation-cell {
  width: 68px;
  min-width: 68px;
  max-width: 68px;
}
#ordersTable .order-action-menu > .btn {
  width: 100%;
  padding-right: 6px;
  padding-left: 6px;
}
#ordersTable .order-action-menu .dropdown-menu {
  min-width: 104px;
}
#ordersTable .order-open-strategy-col .table-header-cell,
#ordersTable .order-client-order-id-col .table-header-cell {
  gap: 2px;
}
#ordersTable .order-client-order-id-col,
#ordersTable .order-client-order-id-cell {
  padding-right: 4px;
  padding-left: 4px;
}
.table-header-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.table-header-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.table-header-btn {
  border: none;
  background: transparent;
  color: #6c757d;
  padding: 0;
  line-height: 1;
}
.table-header-btn:hover {
  color: #343a40;
}
.table-header-btn:focus {
  outline: none;
  color: #343a40;
}
.table-header-btn .bi {
  font-size: 0.95rem;
}
.filter-active {
  color: #6c5ce7 !important;
}
.table-filter-panel {
  position: absolute;
  z-index: 1050;
  width: 280px;
  background-color: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  padding: 12px;
}
.table-filter-panel.d-none {
  display: none;
}
.filter-panel-title {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 10px;
  color: #343a40;
}
.filter-option-list {
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 10px;
  padding-right: 4px;
}
.filter-option-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: #495057;
}
.filter-text-input{
  margin-bottom: 10px;
}
.filter-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.btn-primary {
  background-color: #6c5ce7;
  border-color: #6c5ce7;
  font-size: 0.9rem;
  padding: 0.375rem 0.75rem;
}
.btn-primary:hover {
  background-color: #5d4de0;
  border-color: #5d4de0;
}
.btn-outline-primary {
  color: #6c5ce7;
  border-color: #6c5ce7;
  font-size: 0.9rem;
  padding: 0.375rem 0.75rem;
}
.btn-outline-primary:hover {
  background-color: #6c5ce7;
  border-color: #6c5ce7;
}
.pagination-btn {
  min-width: 85px;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
}
.status-badge {
  font-size: 0.8em;
}
.running {
  background-color: #d4edda;
  color: #155724;
}
.stopped {
  background-color: #f8d7da;
  color: #721c24;
}
.connected {
  background-color: #d1ecf1;
  color: #0c5460;
}
.disconnected {
  background-color: #f8d7da;
  color: #721c24;
}
.data-table {
  background-color: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
/* 顶部状态信息紧凑显示 */
.header-status {
  flex-wrap: wrap;
  white-space: nowrap;
  padding: 2px 0;
}
@media (min-width: 768px) {
  .header-status {
    display: grid !important;
    width: max-content;
    max-width: 100%;
    margin-left: auto;
  }
}
.header-status > div {
  margin-bottom: 4px;
}
.header-status .row {
  width: 100%;
  margin: 0;
  justify-content: flex-start;
}
.header-status .d-flex {
  padding: 1px 0;
  margin: 0;
}
.header-status .badge {
  margin-right: 3px !important;
  font-size: 0.75rem;
  padding: 2px 4px;
}

/* 移动端：将操作区收拢成双列控制台，状态改为可扫读摘要 */
@media (max-width: 767px) {
  body {
    padding: 8px;
    font-size: 0.85rem;
  }

  .container-fluid {
    --bs-gutter-x: 0.75rem;
  }

  .header {
    padding: 12px;
    margin-bottom: 14px;
    border-radius: 12px;
  }

  .header > .container-fluid {
    --bs-gutter-x: 0;
  }

  .header-controls {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 0 !important;
  }

  .header-controls .region-control {
    grid-column: 1 / -1;
    margin-right: 0 !important;
  }

  .header-controls .region-control .form-select {
    width: 100%;
    min-height: 42px;
    font-weight: 600;
  }

  .header-controls .control-btn {
    width: 100%;
    min-width: 0;
    height: 42px;
    margin: 0 !important;
    padding: 0 8px;
    border-radius: 8px;
    font-size: 0.82rem;
    box-shadow: 0 2px 5px rgba(38, 30, 95, 0.18);
  }

  .header-controls .control-btn .bi {
    font-size: 0.95rem;
  }

  .header .col-md-4 {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
  }

  .header-status {
    display: block !important;
    padding: 0;
    white-space: normal;
    text-align: center;
  }

  .header-status > .row {
    display: grid;
    gap: 5px;
    width: 100%;
    margin: 0;
  }

  .header-status > .row:first-child {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .header-status > .row:last-child {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 5px !important;
  }

  .header-status .col-status-5 {
    flex: none;
    width: auto;
    max-width: none;
    padding: 0;
  }

  .header-status .col-status-5 > .d-flex {
    min-width: 0;
    min-height: 42px;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.14);
  }

  .header-status .badge {
    max-width: 100%;
    margin-right: 0 !important;
    padding: 2px 3px;
    overflow: hidden;
    font-size: 0.58rem;
    text-overflow: ellipsis;
  }

  .header-status .fw-bold {
    display: block;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    font-size: 0.66rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .section-title {
    margin-top: 18px;
    margin-bottom: 10px;
    font-size: 1rem;
  }

  .card-stat .card-body {
    min-height: 78px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px !important;
  }

  .card-stat .stat-title {
    font-size: 0.7rem;
    line-height: 1.25;
    letter-spacing: 0;
  }

  .card-stat .stat-value {
    margin-top: 8px;
    font-size: 1rem;
    line-height: 1.15;
  }

  /* Tab 保持单行，以横向滑动代替多行铺开 */
  #dataTabs {
    flex-wrap: nowrap;
    gap: 3px;
    margin-bottom: 12px;
    padding: 0 2px 3px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  #dataTabs::-webkit-scrollbar {
    display: none;
  }

  #dataTabs .nav-item {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  #dataTabs .nav-link {
    padding: 9px 12px;
    border-radius: 8px 8px 0 0;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  #dataTabs .nav-link.active {
    background: rgba(108, 92, 231, 0.08);
  }

  .tab-content,
  .tab-pane,
  .data-table {
    min-width: 0;
  }

  .tab-pane > .data-table {
    min-height: 0 !important;
  }

  .tab-pane > .data-table > .pagination-container {
    position: static;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 12px 8px;
    border-top: 1px solid #e9ecef;
    background: #fff;
    white-space: nowrap;
  }

  .tab-pane > .data-table > .pagination-container .pagination-btn {
    min-width: 78px;
    margin-right: 0 !important;
  }

  /* 搜索区独立于表格横滚动，手机上先输入、再操作 */
  .tab-pane > .data-table > .row:first-child {
    margin: 0 !important;
    padding: 10px;
    background: #fff;
  }

  .tab-pane > .data-table > .row:first-child > [class*="col-"] {
    padding: 0;
  }

  .tab-pane > .data-table > .row:first-child .input-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .tab-pane > .data-table > .row:first-child .input-group > .form-control {
    flex: 1 0 100%;
    width: 100%;
    min-height: 40px;
    border-radius: 8px !important;
  }

  .tab-pane > .data-table > .row:first-child .input-group > .btn {
    flex: 1 1 0;
    min-height: 38px;
    margin-left: 0 !important;
    border-radius: 8px !important;
  }

  /* 表格保留数据密度，通过横滑查看；首列固定作为行标识 */
  .dashboard-table-scroll,
  .table-responsive {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .dashboard-table-scroll > .table,
  .table-responsive > .table {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
  }

  .dashboard-table-scroll > .table th,
  .dashboard-table-scroll > .table td,
  .table-responsive > .table th,
  .table-responsive > .table td {
    padding: 0.55rem 0.65rem;
    vertical-align: middle;
    white-space: nowrap;
    word-break: normal;
  }

  .dashboard-table-scroll .table-header-cell {
    min-width: max-content;
  }

  .dashboard-table-scroll > .table th:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #f8f9fa;
    box-shadow: 2px 0 0 #dee2e6;
  }

  .dashboard-table-scroll > .table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    box-shadow: 2px 0 0 #edf0f2;
  }

  #panel-risk .dashboard-table-scroll > .table td:last-child,
  #panel-trades .dashboard-table-scroll > .table td:last-child {
    min-width: 220px;
    max-width: 300px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}
/* 分页控件定位在右下角 */
.pagination-container {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  align-items: center;
}


/* 隐藏按钮的CSS类 */
.btn-hidden {
  display: none !important;
}

/* 平仓按钮样式 - 更小的尺寸 */
.position-action-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

.position-action-buttons .btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  min-width: 80px;
}

/* 粘性表头 */
.sticky-top {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #f8f9fa !important;
}
