/* 通用样式 */
* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background-color: #f8f9fa;
  margin: 0;
  padding: 0;
  color: #333;
}

/* ========== 导航栏样式（兼容 Bootstrap 5） ========== */
.navbar {
  background: linear-gradient(90deg, #0d6efd, #0b5ed7);
  padding: 0.5rem 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
  color: white !important;
  font-weight: 600;
}

.navbar-nav .nav-link {
  color: rgba(255, 255, 255, 0.85);
  padding: 0.5rem 1rem;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
  color: #ffc107;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.navbar-toggler {
  border-color: rgba(255, 255, 255, 0.5);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* 确保导航栏菜单项不换行（必要时出现横向滚动） */
.navbar-nav {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* Flash 消息 */
.flash-messages {
  margin: 20px 0;
  padding: 10px;
  background-color: #d1ecf1;
  border-left: 5px solid #0d6efd;
  width: 100%;
  max-width: 1200px;
  box-sizing: border-box;
}

.flash-messages ul {
  list-style: none;
  padding: 0;
}

.flash-messages li {
  margin: 5px 0;
}

/* 内容容器 */
.content {
  padding: 20px;
  width: 100%;
  box-sizing: border-box;
}

/* 卡片样式 */
.card {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  border: none;
  border-radius: 10px;
}

.card-header {
  background-color: #0d6efd;
  color: white;
  border-radius: 10px 10px 0 0 !important;
  font-weight: 600;
  padding: 15px 20px;
}

/* 登录页面样式 */
.login-container {
  max-width: 400px;
  margin: 50px auto;
  padding: 30px;
  border: none;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  background-color: #fff;
}

.login-container h2 {
  text-align: center;
  margin-bottom: 25px;
  color: #333;
  font-weight: 600;
}

.login-container label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #555;
}

.login-container input {
  width: 100%;
  padding: 10px;
  margin-bottom: 15px;
  border: 1px solid #dee2e6;
  border-radius: 5px;
  box-sizing: border-box;
}

.login-container button {
  width: 100%;
  padding: 12px;
  background-color: #0d6efd;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
}

.login-container button:hover {
  background-color: #0b5ed7;
}

/* 控制面板页面样式 */
.dashboard-container {
  max-width: 1200px;
  margin: 30px auto;
  padding: 25px;
  border: none;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  background-color: #fff;
}

.dashboard-container h2 {
  margin-bottom: 25px;
  color: #333;
  font-weight: 600;
}

.dashboard-container p {
  color: #555;
  line-height: 1.6;
}

/* 头部样式 */
.header {
  background-color: #f8f9fa;
  padding: 20px;
  text-align: center;
}

/* 自定义列样式 */
.column-left, .column-right {
  width: 100%;
  text-align: center;
}

.row:after {
  content: "";
  display: table;
  clear: both;
}

/* 底部样式 */
.footer {
  background-color: #f8f9fa;
  padding: 15px;
  text-align: center;
  margin-top: 30px;
}

.column {
  width: 100%;
  text-align: left;
  color: #0d6efd;
}

/* 通用表格容器（用于其他页面） */
.table-container {
  width: 100%;
  margin: 20px 0;
  overflow-x: auto;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 10px 0;
}

/* 分析页面表格容器（保留原有） */
.table-ana {
  width: 80%;
  margin: 20px auto;
  overflow-x: auto;
  white-space: nowrap;
  padding: 10px 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  border-radius: 8px;
  background-color: white;
}

/* 用户配置表格样式（用于天地网格等） */
.table-config {
  width: 100%;
  min-width: 1200px;
  border-collapse: collapse;
}

.table-config th, .table-config td {
  border: 1px solid #dee2e6;
  padding: 12px;
  text-align: left;
  font-size: 14px;
}

.table-config th {
  background-color: #e9ecef;
  font-weight: 600;
  color: #495057;
}

/* 当 bot_run=0, 或者 reduce-only 时的行样式 */
.bot-run-zero,
.reduce-only {
  color: #dc3545;
  background-color: #f8d7da !important;
}

/* 收入表格样式 */
.table-income {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
}

.table-income th, .table-income td {
  border: 1px solid #dee2e6;
  padding: 12px;
  text-align: left;
  font-size: 14px;
}

.table-income th {
  background-color: #e9ecef;
  font-weight: 600;
  color: #495057;
}

.table-income tr.fee td {
  background-color: #fff3cd;
}

.table-income tr.pnl td {
  background-color: #d1ecf1;
}

.table-income tr.commission td {
  background-color: #f8d7da;
}

/* 确保表格在移动设备上可滚动 */
.table-responsive {
  border-radius: 5px;
  overflow: hidden;
}

/* 特殊行样式 */
.table .fee {
  background-color: #fff3cd !important;
}

.table .pnl {
  background-color: #d1ecf1 !important;
}

.table .commission {
  background-color: #f8d7da !important;
}

/* 分页和菜单样式 */
ul.men, ul.pagination {
  list-style-type: none;
  margin: 0;
  padding: 0;
  display: inline-block;
}

li.men {
  margin: 0 auto;
  display: inline-block;
}

li.page-item {
  margin: 1px 3px;
  display: inline-block;
}

a:visited {
  font-weight: bold;
  color: black;
  background-color: #d4edda;
  text-align: center;
  padding: 8px 12px;
  text-decoration: none;
  text-transform: uppercase;
  border-radius: 4px;
}

a:hover, a:active {
  background-color: #c3e6cb;
}

ul.a li.a {
  display: block;
  list-style: none;
  margin: 5px 5px;
}

/* 表单元素样式 */
input[type=text], select {
  width: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 8px 12px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
}

input[type=submit] {
  justify-content: space-between;
  background-color: #198754;
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  white-space: nowrap;
  font-weight: 600;
}

input[type=submit]:hover {
  background-color: #157347;
}

/* 弹出配置表单样式 */
#config_style {
  float: left;
  color: black;
  text-align: center;
  padding: 10px 10px;
  text-decoration: none;
}

/* 通用模态框样式（用于配置管理等） */
.modal {
  display: none;
  position: fixed;
  z-index: 1050;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
  background-color: #fefefe;
  margin: 10% auto;
  padding: 25px;
  border: none;
  border-radius: 10px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.close {
  color: #6c757d;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

.close:hover,
.close:focus {
  color: #495057;
  text-decoration: none;
  cursor: pointer;
}

/* 天地网格专用模态框（独立类名，避免 Bootstrap 干扰） */
.td-grid-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.4);
}

.td-grid-modal .modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  max-width: 800px;
  border-radius: 8px;
}

.td-grid-modal .close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.td-grid-modal .close:hover {
  color: black;
}

/* ==================== 天地网格页面专用布局 ==================== */
.td-grid-page {
    width: 100%;
}

.horizontal-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
    display: flex;
    justify-content: flex-start;   /* 从 center 改为 flex-start */
}
@media (min-width: 1600px) {
    .horizontal-scroll-wrapper {
        justify-content: center;
    }
}

.content-wrapper {
    min-width: 1600px;
    width: max-content;
    margin: 20px 0;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 10px 20px;
}

.content-wrapper h2 {
    text-align: center;
    color: #333;
    font-weight: 600;
    margin-bottom: 20px;
}

.filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.content-wrapper table {
    width: 100%;
    table-layout: auto;
}

/* 过滤器输入框 */
.input-wrapper {
  position: relative;
  display: inline-block;
  margin-bottom: 15px;
}

.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 16px;
  color: #6c757d;
  display: none;
}

input:not(:placeholder-shown) + .clear-btn {
  display: inline;
}

/* AI诊断容器样式 */
.ai-diagnosis-container {
  max-width: 900px;
  margin: 20px auto;
  padding: 25px;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.symbol-input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.symbols-input-container {
  position: relative;
}

.symbols-buttons {
  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  gap: 5px;
}

.symbols-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: white;
  border: 1px solid #dee2e6;
  transition: all 0.2s;
}

.symbols-btn:hover {
  transform: scale(1.1);
}

.clear-symbols {
  color: #dc3545;
}

.load-default {
  color: #0d6efd;
}

/* 价格容器样式 */
.price-container {
  margin-top: 10px;
  padding: 12px 15px;
  background-color: #f0f8ff;
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #cce5ff;
}

#price-label {
  font-weight: 500;
  color: #0066cc;
}

#current-price {
  font-weight: bold;
  font-size: 16px;
  color: #198754;
}

#price-timestamp {
  font-size: 12px;
  color: #6c757d;
  margin-left: auto;
}

/* 加载动画样式 */
.loading-indicator,
.spinner {
  display: none;
  position: absolute;
  right: 45px;
  top: 12px;
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #0d6efd;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 按钮组样式 */
.btn-group-custom {
  display: flex;
  gap: 10px;
  margin: 15px 0;
}

/* 证书状态的颜色提示 */
.text-danger {
  color: #dc3545;
  font-weight: bold;
}

.text-warning {
  color: #ffc107;
  font-weight: bold;
}

.ssl-info {
  margin: 20px 0;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 5px;
  border-left: 4px solid #0d6efd;
}

/* 表格内容居中 */
.table-striped.text-center th,
.table-striped.text-center td {
  text-align: center !important;
}

/* 用户表格样式 */
.table-users {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 14px;
  background-color: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-users th {
  background-color: #e9ecef;
  color: #495057;
  font-weight: 600;
  padding: 12px;
  text-align: center;
  border-bottom: 2px solid #dee2e6;
}

.table-users td {
  padding: 12px;
  text-align: center;
  border-bottom: 1px solid #dee2e6;
}

.table-users tr:hover {
  background-color: #f8f9fa;
}

.filter-container {
  margin: 15px 0;
  padding: 10px;
  background-color: #f5f5f5;
  border-radius: 5px;
}

.filter-container label {
  margin: 0 5px 0 15px;
  font-weight: bold;
}

.filter-container select {
  padding: 5px 10px;
  border: 1px solid #ddd;
  border-radius: 3px;
  background-color: white;
}

.filter-container select:focus {
  outline: none;
  border-color: #4d90fe;
}

/* 响应式设计 */
@media (max-width: 991px) {
  .navbar-collapse {
    margin-top: 10px;
  }

  .navbar-nav .nav-item {
    margin: 0; /* 去除多余间距 */
  }

  .flash-messages {
    margin: 10px;
    max-width: calc(100% - 20px);
  }

  .table-container,
  .table-ana {
    width: 95%;
  }
}

@media (max-width: 768px) {
  body {
    padding-top: 10px;
  }

  .content {
    padding: 10px;
    width: 100%;
  }

  .table-container,
  .table-ana {
    width: 95%;
    margin: 10px auto;
  }

  .table-income {
    width: 95%;
  }

  .dashboard-container,
  .login-container {
    margin: 20px auto;
    width: 95%;
    padding: 20px;
  }

  .btn-group-custom {
    flex-direction: column;
  }

  .card {
    margin-bottom: 15px;
  }

  .ai-diagnosis-container {
    padding: 15px;
    margin: 10px auto;
  }

  .content-wrapper {
    padding: 10px;
  }
}

@media (max-width: 576px) {
  .navbar {
    padding: 0.5rem;
  }

  .navbar-nav .nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 14px;
  }

  .login-container {
    padding: 20px;
    margin: 20px auto;
  }

  .modal-content {
    width: 95%;
    margin: 5% auto;
    padding: 20px;
  }

  .price-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  #price-timestamp {
    margin-left: 0;
  }
}

/* ========== 天地网格表格覆盖样式（强制红色高亮） ========== */
/*
   修复 Bootstrap 表格样式覆盖问题，确保 bot_run=0 的行及其所有单元格
   显示红色背景和红色文字，无论是否为奇数/偶数行。
*/
.table tbody tr.bot-run-zero,
.table tbody tr.bot-run-zero td,
.table tbody tr.reduce-only,
.table tbody tr.reduce-only td {
    background-color: #f8d7da !important;
    color: #dc3545 !important;
}