/* ========== 基础暗黑主题 + 字体清晰优化 ========== */
body {
  background: #0a0c10;
  font-family: 'Segoe UI', 'Roboto', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: #e8edf5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.bg-light {
  background-color: #13161a !important;
}

/* ========== 全局文字高亮（纯色，无透明） ========== */
body, p, span, div, li, .text-muted, .form-text, .card-body, .table td, .table th {
  color: #e8edf5 !important;
}

h1, h2, h3, h4, h5, .card-header-custom, .table thead th {
  font-weight: 600;
  color: #ffffff !important;
  letter-spacing: 0.2px;
}

/* ========== 涨跌颜色（红涨绿跌）- 高优先级 ========== */
.profit-positive {
  color: #ff4d4f !important;
  font-weight: 700 !important;
}

.profit-negative {
  color: #2bc48a !important;
  font-weight: 700 !important;
}

/* 表格内数字强调 */
table .profit-positive, table .profit-negative,
.table td.profit-positive, .table td.profit-negative {
  font-weight: 700;
  font-size: 0.9rem;
}

/* 统计卡片中的数值样式（继承涨跌色） */
.stat-item .value {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
}

/* ========== 表单与输入框 ========== */
.form-label {
  color: #e2e8f0;
  font-weight: 500;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.form-control, .form-select, .input-group-text {
  background-color: #1a1e26;
  border: 1px solid #3a3f4a;
  color: #f0f3fa;
  font-size: 0.85rem;
  padding: 0.4rem 0.7rem;
}

.form-control:focus, .form-select:focus {
  background-color: #1e2229;
  color: #fff;
  border-color: #e67e22;
  box-shadow: 0 0 0 0.2rem rgba(230, 126, 34, 0.25);
}

::placeholder {
  color: #7f8c8d !important;
  opacity: 0.7;
}

/* 紧凑表单（模态框内） */
.modal-body {
  padding: 1rem 1.25rem;
}
.modal-body .mb-3 {
  margin-bottom: 0.75rem !important;
}
.modal-body .form-text {
  font-size: 0.7rem;
  margin-top: 0.2rem;
  color: #9ca3af !important;
}
.modal-body .form-label {
  font-size: 0.8rem;
}

/* ========== 卡片、模态框、列表等 ========== */
.card, .modal-content, .list-group-item, .dropdown-menu, .input-group-text, .btn-close {
  background-color: #1e2229;
  border-color: #2c313a;
  color: #e8edf5;
}

.card-dashboard {
  background: #161a20;
  border: 1px solid #2a2f38;
  border-radius: 24px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
  margin-bottom: 1.8rem;
  overflow: hidden;
}

.card-header-custom {
  background: #0e1117;
  border-bottom: 1px solid #2a2f38;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  color: #ffffff;
  font-size: 1rem;
}

.btn-close {
  filter: invert(1) brightness(0.8);
}

/* ========== 统计卡片 ========== */
.compact-stats-card {
  background: linear-gradient(145deg, #15191f 0%, #101318 100%);
  border-radius: 28px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 0.8rem 1rem;
  margin-bottom: 1.5rem;
  border: 1px solid #2c313a;
}

/* 第一行：4列布局 */
.stats-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

/* 第二行：左侧卡片组 + 右侧费率信息 */
.stats-row-2 {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: space-between;
  gap: 1rem;
}
.stats-row-2-left {
  display: flex;
  gap: 0.75rem;
  flex: 2.5;
}
.stats-row-2-left .stat-item {
  flex: 1;
}
.rates-info {
  flex: 1;
  text-align: right;
  font-size: 0.7rem;
  color: #9ca3af;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: flex-end;
  justify-content: center;
}
.rates-line {
  white-space: nowrap;
}

/* 运行天数徽章（调小字体） */
.running-days-badge {
  font-size: 0.7rem !important;
  font-weight: normal !important;
  padding: 2px 8px !important;
  background: rgba(30, 34, 41, 0.85) !important;
  border-radius: 30px !important;
  line-height: 1.4 !important;
  display: inline-block;
}

.stat-item {
  text-align: center;
  padding: 0.5rem 0.2rem;
  border-radius: 20px;
  background: rgba(10, 14, 18, 0.6);
  backdrop-filter: blur(2px);
}
.stat-item .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #8e9aaf;
  letter-spacing: 1px;
  font-weight: 500;
  margin-bottom: 0.2rem;
}

/* ========== 表格暗黑全覆盖 ========== */
.table, .data-table, .table-hover, .table-responsive table,
table, .table td, .table th, .table tr,
.data-table td, .data-table th, .data-table tr,
#stockListBody td, #stockListBody th,
.table-bordered, .table-bordered td, .table-bordered th,
.table-striped tbody tr:nth-of-type(odd),
.table-hover tbody tr:hover {
  background-color: #1a1e24 !important;
  color: #e8edf5 !important;
  border-color: #2c313a !important;
}

.table thead th, .data-table thead th,
.table thead, .data-table thead {
  background: #0f1219 !important;
  color: #ffffff !important;
  border-bottom: 2px solid #2c313a;
  font-weight: 600;
}

.table-hover tbody tr:hover td,
.table-hover tbody tr:hover th {
  background-color: #2a2f38 !important;
  color: #ffffff !important;
}

/* ========== 分页控件暗黑 ========== */
.pagination .page-link {
  background-color: #1e2229;
  border-color: #2c313a;
  color: #e8edf5;
}
.pagination .page-item.active .page-link {
  background-color: #e67e22;
  border-color: #e67e22;
  color: #0a0c10;
}
.pagination .page-link:hover {
  background-color: #2c313a;
  color: #fff;
}

/* ========== 侧边栏 ========== */
.admin-sidebar .list-group-item {
  background: transparent;
  color: #cdd9f4;
  border: none;
  margin-bottom: 6px;
  border-radius: 16px;
  transition: all 0.2s;
  font-weight: 500;
}
.admin-sidebar .list-group-item.active {
  background: linear-gradient(95deg, #e67e22, #f39c12);
  color: #0a0c10;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(230, 126, 34, 0.3);
}
.admin-sidebar .list-group-item:hover:not(.active) {
  background: #2a2f38;
  color: #f5f7fa;
}
/* 移动端侧边栏横向滚动 */
@media (max-width: 768px) {
  .admin-sidebar .list-group {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    flex-wrap: nowrap;
  }
  .admin-sidebar .list-group-item {
    display: inline-block;
    margin-right: 8px;
    flex: 0 0 auto;
  }
}

/* ========== 按钮 ========== */
.btn-primary {
  background: #e67e22;
  border: none;
  font-weight: 600;
}
.btn-primary:hover {
  background: #f39c12;
  transform: translateY(-1px);
}
.btn-sm {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

/* ========== 徽章状态 ========== */
.badge-status {
  padding: 0.25rem 0.6rem;
  border-radius: 40px;
  font-weight: 600;
  font-size: 0.7rem;
}
.badge-holding { background: #3b82f6; color: white; }
.badge-watching { background: #e67e22; color: #0a0c10; }
.badge-sold { background: #6c757d; color: #f0f0f0; }

/* ========== 其他细节 ========== */
a {
  color: #f39c12;
}
a:hover {
  color: #ffb347;
}

/* 滚动条暗黑 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #1e2229;
}
::-webkit-scrollbar-thumb {
  background: #3a3f4b;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #e67e22;
}

/* ========== 暗黑公告栏（窄版，无标题，居中） ========== */
.dark-announcement-card {
  background: linear-gradient(145deg, #0f1219 0%, #0a0c10 100%);
  border-left: 4px solid #f5b041;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  margin-bottom: 1rem;
  padding: 0.4rem 0.8rem;
  position: relative;
}
.dark-announcement-card.compact .announcement-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dark-announcement-card .announcement-icon {
  font-size: 1rem;
  background: #f5b04120;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #f5b041;
  flex-shrink: 0;
}
.announcement-marquee {
  flex: 0 1 auto;
  overflow: hidden;
  position: relative;
  height: 32px;
  text-align: center;
}
.announcement-item {
  display: none;
  align-items: center;
  justify-content: center;
  color: #e8edf5;
  font-size: 0.8rem;
  line-height: 1.3;
  padding: 0.2rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.announcement-item.active {
  display: flex;
  animation: fadeIn 0.5s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}
.announcement-item strong {
  color: #f5b041;
  margin-right: 8px;
  font-weight: 600;
  white-space: nowrap;
}
.announcement-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-close-dark {
  background: none;
  border: none;
  color: #8e9aaf;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 3px;
  transition: color 0.2s;
  line-height: 1;
  margin-left: auto;
}
.btn-close-dark:hover {
  color: #f5b041;
}
.announcement-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}
.announcement-dots .dot {
  width: 5px;
  height: 5px;
  background-color: #4a5568;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.announcement-dots .dot.active {
  width: 16px;
  background-color: #f5b041;
}

/* ========== 添加/编辑股票模态框紧凑样式 ========== */
#addStockModal .modal-body,
#editStockModal .modal-body {
  padding: 0.75rem 1rem;
}
#addStockModal .mb-3,
#editStockModal .mb-3 {
  margin-bottom: 0.5rem !important;
}
#addStockModal .form-label,
#editStockModal .form-label {
  font-size: 0.75rem;
  margin-bottom: 0.15rem;
}
#addStockModal .form-control,
#editStockModal .form-control,
#addStockModal .form-select,
#editStockModal .form-select {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  height: auto;
}
#addStockModal .form-text,
#editStockModal .form-text {
  font-size: 0.65rem;
  margin-top: 0.1rem;
}
#addStockModal .modal-header,
#editStockModal .modal-header {
  padding: 0.5rem 1rem;
}
#addStockModal .modal-footer,
#editStockModal .modal-footer {
  padding: 0.5rem 1rem;
}

/* ========== 响应式布局 ========== */
@media (max-width: 768px) {
  .stats-row-4 {
    grid-template-columns: repeat(4, minmax(100px, 1fr));
    overflow-x: auto;
  }
  .stats-row-2 {
    flex-direction: column;
    align-items: stretch;
  }
  .stats-row-2-left {
    width: 100%;
    flex-wrap: wrap;
  }
  .rates-info {
    text-align: left;
    align-items: flex-start;
    margin-top: 0.5rem;
  }
  .rates-line {
    white-space: normal;
  }
  .running-days-badge {
    font-size: 0.7rem !important;
    position: static !important;
    margin-top: 8px !important;
    display: inline-block !important;
  }
  /* 公告栏手机适配 */
  .dark-announcement-card {
    padding: 0.3rem 0.6rem;
  }
  .announcement-marquee {
    height: auto;
    min-height: 36px;
  }
  .announcement-item {
    white-space: normal;
    font-size: 0.85rem;
  }
  .announcement-item strong,
  .announcement-item span {
    white-space: normal;
    font-size: 0.85rem;
  }
  /* 表格字体微调 */
  .table-sm th, .table-sm td {
    font-size: 0.75rem;
  }
  .badge-status {
    font-size: 0.6rem;
    padding: 0.2rem 0.5rem;
  }
  .btn-sm {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding-left: 10px;
    padding-right: 10px;
  }
  .stats-row-4 {
    gap: 0.5rem;
  }
  .stat-item .value {
    font-size: 1rem;
  }
}

/* ========== 强制红涨绿跌（前后台所有表格统一） ========== */
.profit-positive,
#stockListBody td.profit-positive,
.table td.profit-positive,
table td.profit-positive {
  color: #ff4d4f !important;
  font-weight: 700 !important;
}
.profit-negative,
#stockListBody td.profit-negative,
.table td.profit-negative,
table td.profit-negative {
  color: #2bc48a !important;
  font-weight: 700 !important;
}