/* ================================================================
   ShunyiCapital 暗色主题 — 统一样式
   ================================================================ */

/* ===== 基础 ===== */
:root {
    --bs-body-bg: #0f1117;
    --bs-body-color: #e4e6eb;
    --bs-border-color: rgba(255,255,255,0.1);
}
html {
    scrollbar-gutter: stable;
    overflow-x: hidden;
}
body {
    overflow-x: hidden;
    background-color: #0f1117;
    color: #e4e6eb;
    min-height: 100vh;
}

/* 暗色滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #0f1117; }
::-webkit-scrollbar-thumb { background: #2a2d3a; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3d4a; }

/* ===== 导航栏 ===== */
.navbar {
    background-color: #12141c !important;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 1px 8px rgba(0,0,0,0.3);
}

/* ===== 卡片 ===== */
.card {
    background-color: #1a1d28;
    border-color: rgba(255,255,255,0.06);
    color: #e4e6eb;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.card-header {
    background-color: rgba(255,255,255,0.025);
    border-bottom-color: rgba(255,255,255,0.06);
    font-weight: 600;
}

/* ===== 文字颜色 ===== */
.text-muted { color: #6b7280 !important; }
.text-dark { color: #e4e6eb !important; }
.text-secondary { color: #9ca3af !important; }
.text-primary { color: #60a5fa !important; }
.text-info { color: #67b8e3 !important; }
.text-success { color: #4ade80 !important; }
.text-warning { color: #fbbf24 !important; }
.text-danger { color: #f87171 !important; }
.text-light { color: #f3f4f6 !important; }

/* ===== 徽章 ===== */
.badge.bg-info { background-color: rgba(14,165,233,0.2) !important; color: #7dd3fc !important; }
.badge.bg-success { background-color: rgba(34,197,94,0.2) !important; color: #86efac !important; }
.badge.bg-danger { background-color: rgba(239,68,68,0.2) !important; color: #fca5a5 !important; }
.badge.bg-warning { background-color: rgba(234,179,8,0.2) !important; color: #fde68a !important; }
.badge.bg-secondary { background-color: rgba(255,255,255,0.06) !important; color: #9ca3af !important; }
.badge.bg-dark { background-color: #151722 !important; color: #9ca3af !important; }

/* ===== 按钮 ===== */
.btn-primary { background-color: #2563eb; border-color: #2563eb; }
.btn-primary:hover { background-color: #1d4ed8; border-color: #1d4ed8; }
.btn-secondary { background-color: #2a2d3a; border-color: #3a3d4a; color: #d1d5db; }
.btn-secondary:hover { background-color: #3a3d4a; border-color: #4a4d57; color: #f3f4f6; }
.btn-outline-primary { color: #60a5fa; border-color: rgba(96,165,250,0.4); }
.btn-outline-primary:hover { background-color: #2563eb; border-color: #2563eb; color: #fff; }
.btn-outline-secondary { color: #9ca3af; border-color: rgba(255,255,255,0.12); }
.btn-outline-secondary:hover { background-color: #2a2d3a; border-color: rgba(255,255,255,0.2); color: #e5e7eb; }
.btn-outline-success { color: #4ade80; border-color: rgba(74,222,128,0.4); }
.btn-outline-success:hover { background-color: #16a34a; border-color: #16a34a; color: #fff; }
.btn-outline-danger { color: #f87171; border-color: rgba(248,113,113,0.4); }
.btn-outline-danger:hover { background-color: #dc2626; border-color: #dc2626; color: #fff; }

/* ===== 表单控件 ===== */
/* 使用 html 前缀提升 specificity，完全绕过 Bootstrap 的 CSS 变量 */
html input[type="text"],
html input[type="password"],
html input[type="email"],
html input[type="number"],
html input[type="search"],
html input[type="tel"],
html input[type="url"],
html input[type="date"],
html textarea,
html select,
html .form-control,
html .form-select {
    background-color: #151722 !important;
    color: #e4e6eb !important;
    border-color: rgba(255,255,255,0.1);
}
html .form-control:focus,
html .form-select:focus {
    background-color: #151722 !important;
    color: #e4e6eb !important;
    border-color: #3b82f6;
    box-shadow: 0 0 0 0.2rem rgba(59,130,246,0.15);
}
html .form-control::placeholder { color: #4b5563; }
/* 防止 Chrome 自动填充覆盖背景色 */
html input:-webkit-autofill,
html input:-webkit-autofill:hover,
html input:-webkit-autofill:focus {
    -webkit-text-fill-color: #e4e6eb !important;
    -webkit-box-shadow: 0 0 0 1000px #151722 inset !important;
    caret-color: #e4e6eb;
    transition: background-color 5000s ease-in-out 0s;
}
html option { background-color: #1a1d28; color: #e4e6eb; }

/* ===== 下拉菜单 ===== */
.dropdown-menu {
    background-color: #1a1d28;
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.dropdown-item { color: #9ca3af; }
.dropdown-item:hover { background-color: rgba(255,255,255,0.06); color: #e5e7eb; }
.dropdown-divider { border-color: rgba(255,255,255,0.06); }

/* ===== Alert ===== */
.alert-danger { background-color: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.2); color: #fca5a5; }
.alert-info { background-color: rgba(14,165,233,0.08); border-color: rgba(14,165,233,0.2); color: #7dd3fc; }
.alert-warning { background-color: rgba(234,179,8,0.08); border-color: rgba(234,179,8,0.2); color: #fde68a; }

/* ===== Modal ===== */
.modal-content {
    background-color: #1a1d28;
    border-color: rgba(255,255,255,0.08);
    color: #e4e6eb;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    overflow: visible;
}
.modal-body {
    overflow-y: auto;
    max-height: 70vh;
}

/* flatpickr 暗色主题 */
.flatpickr-calendar {
    background: #1a1d28;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    color: #e4e6eb;
}
.flatpickr-months {
    background: #1a1d28;
    border-radius: 8px 8px 0 0;
}
.flatpickr-months .flatpickr-month {
    color: #e4e6eb;
}
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    color: #e4e6eb;
    fill: #e4e6eb;
}
.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    color: #fff;
    fill: #fff;
}
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
    color: #e4e6eb;
    background: transparent;
}
.flatpickr-current-month .flatpickr-monthDropdown-months option {
    background: #1a1d28;
    color: #e4e6eb;
}
.flatpickr-day {
    color: #e4e6eb;
    border-radius: 4px;
}
.flatpickr-day:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.1);
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}
.flatpickr-day.today {
    border-color: #0d6efd;
}
.flatpickr-day.today:hover {
    background: #0d6efd;
    color: #fff;
}
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: #6b7280;
}
.flatpickr-weekdays {
    color: #9ca3af;
}
span.flatpickr-weekday {
    color: #9ca3af;
}
.flatpickr-input {
    cursor: pointer;
}
.modal-header { border-bottom-color: rgba(255,255,255,0.06); }
.modal-footer { border-top-color: rgba(255,255,255,0.06); }
.btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* ===== 表格 ===== */
/* 覆盖 Bootstrap 5.3 的表格样式（包括 inset box-shadow 填充） */
.table {
    color: #d1d5db !important;
    --bs-table-color: #d1d5db;
    --bs-table-bg: transparent;
    --bs-table-bg-type: transparent;
    --bs-table-bg-state: transparent;
    --bs-table-accent-bg: transparent;
    --bs-table-striped-bg: rgba(255,255,255,0.015);
    --bs-table-striped-color: #d1d5db;
    --bs-table-hover-bg: rgba(255,255,255,0.04);
    --bs-table-hover-color: #e5e7eb;
    --bs-table-active-bg: rgba(255,255,255,0.06);
    --bs-table-active-color: #e5e7eb;
    --bs-table-border-color: rgba(255,255,255,0.06);
}
.table > :not(caption) > * > * {
    color: #d1d5db !important;
    background-color: var(--bs-table-bg) !important;
    box-shadow: none !important;
    border-bottom-color: var(--bs-table-border-color);
}
.table-hover tbody tr:hover > * {
    background-color: var(--bs-table-hover-bg) !important;
}
.table thead th {
    background-color: #12141c !important;
    color: #9ca3af;
    font-weight: 600;
    border-bottom-color: rgba(255,255,255,0.08);
}
.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--bs-table-striped-bg) !important;
}
.table-sm td, .table-sm th { padding: 0.4rem 0.6rem; }

/* ===== 排行榜表格列间距优化 ===== */
.d-none.d-md-block .table-responsive .table.table-sm th,
.d-none.d-md-block .table-responsive .table.table-sm td {
    padding: 0.45rem 0.7rem;
    vertical-align: middle;
}
/* 排名列紧凑 */
.d-none.d-md-block .table-responsive .table.table-sm th:first-child,
.d-none.d-md-block .table-responsive .table.table-sm td:first-child {
    padding: 0.45rem 0.4rem;
    text-align: center;
}
/* 股票列 */
.d-none.d-md-block .table-responsive .table.table-sm th:nth-child(2),
.d-none.d-md-block .table-responsive .table.table-sm td:nth-child(2) {
    padding: 0.45rem 0.6rem;
}
/* 分数列（盈利/健康/危险/估值）：文字和进度条间距 */
.d-none.d-md-block .table-responsive .table.table-sm td:nth-child(4),
.d-none.d-md-block .table-responsive .table.table-sm td:nth-child(5),
.d-none.d-md-block .table-responsive .table.table-sm td:nth-child(6),
.d-none.d-md-block .table-responsive .table.table-sm td:nth-child(7) {
    padding: 0.35rem 0.55rem;
    line-height: 1.4;
}
/* 数据新鲜度列 */
.d-none.d-md-block .table-responsive .table.table-sm th:nth-child(8),
.d-none.d-md-block .table-responsive .table.table-sm td:nth-child(8) {
    padding: 0.45rem 0.5rem;
}
/* 总分列 */
.d-none.d-md-block .table-responsive .table.table-sm th:nth-child(9),
.d-none.d-md-block .table-responsive .table.table-sm td:nth-child(9) {
    padding: 0.45rem 0.35rem;
}
/* 评级列 */
.d-none.d-md-block .table-responsive .table.table-sm th:nth-child(10),
.d-none.d-md-block .table-responsive .table.table-sm td:nth-child(10) {
    padding: 0.45rem 0.65rem;
}
/* 进度条与上方文字间距 */
.d-none.d-md-block .table-responsive .table.table-sm .score-bar {
    margin-top: 3px;
    height: 5px;
    border-radius: 3px;
}
.table code {
    color: #f472b6;
    background: rgba(99,102,241,0.12);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.8em;
}
.table-hover tbody tr { cursor: pointer; }
.table-responsive { width: 100%; overflow-x: auto; }
.table-responsive table { table-layout: fixed; }
.table-responsive th, .table-responsive td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 评级列不截断 */
.table-responsive td.rating { overflow: visible; text-overflow: unset; white-space: nowrap; }

/* 表格行左侧边线（可点击行） */
.table-hover tbody tr { border-left: 3px solid transparent; }
.table-hover tbody tr:hover { border-left-color: #3b82f6; }

/* ===== 进度条 ===== */
.progress {
    background-color: rgba(255,255,255,0.06);
    border-radius: 4px;
}
.progress-bar.bg-info { background-color: #0ea5e9 !important; }
.progress-bar.bg-success { background-color: #22c55e !important; }
.progress-bar.bg-danger { background-color: #ef4444 !important; }
.progress-bar.bg-warning { background-color: #eab308 !important; }
.score-bar { margin-top: 2px; height: 6px; border-radius: 3px; }

/* ===== 分页 ===== */
.pagination .page-link {
    font-size: 0.85rem;
    background-color: #1a1d28;
    border-color: rgba(255,255,255,0.06);
    color: #9ca3af;
}
.pagination .page-link:hover {
    background-color: #22253a;
    border-color: rgba(255,255,255,0.12);
    color: #e5e7eb;
}
.pagination .page-item.active .page-link {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.pagination .page-item.disabled .page-link {
    background-color: #151722;
    border-color: rgba(255,255,255,0.04);
    color: #374151;
}

/* ===== 评级 ===== */
.rating { white-space: nowrap; }

/* ===== 加载动画 ===== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.spin { animation: spin 1s linear infinite; display: inline-block; }

/* ===== 加载遮罩 ===== */
#loadingOverlay { background: #0f1117 !important; }

/* ===== 排序面板 ===== */
.sort-panel {
    background: #161822;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 0.5rem;
}
.sort-th-indicator {
    font-size: 0.65rem; font-weight: 700; color: #fff;
    background: #2563eb; border-radius: 3px; padding: 0 3px; margin-left: 3px;
    vertical-align: middle; line-height: 1.4;
}
.preset-btn-wrapper { gap: 1px; margin-bottom: 4px; }
.preset-btn-wrapper .preset-btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.preset-btn-wrapper .btn-close { padding: 0 4px; cursor: pointer; opacity: 0.5; filter: invert(1); }
.preset-btn-wrapper .btn-close:hover { opacity: 1; }

/* ===== 数据新鲜度徽章 ===== */
.freshness-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}
.freshness-hot { background-color: #dc2626; }
.freshness-warm { background-color: #d97706; }
.freshness-cool { background-color: #854d0e; }
.freshness-cold { background-color: #374151; }
.freshness-period { font-size: 0.75rem; color: #6b7280; display: block; margin-top: 1px; }

/* ===== 手机端股票卡片 ===== */
.stock-card { cursor: pointer; transition: transform 0.1s; }
.stock-card:hover { transform: translateY(-1px); box-shadow: 0 2px 12px rgba(0,0,0,0.4); }

/* ===== 详情值 ===== */
.detail-value { word-break: break-all; color: #6b7280; }

/* ===== 评分圆圈 ===== */
.score-circle {
    width: 80px; height: 80px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: bold; color: #fff;
}
.score-circle-5 { background: #166534; }
.score-circle-4 { background: #1e40af; }
.score-circle-3 { background: #854d0e; color: #fde68a; }
.score-circle-2 { background: #9a3412; }
.score-circle-1 { background: #991b1b; }
.score-circle-0 { background: #374151; }

/* ===== 个股详情 ===== */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    border-left: 3px solid #3b82f6;
    padding-left: 10px;
    margin-bottom: 12px;
    color: #d1d5db;
}

/* ===== 图表卡片 ===== */
.chart-card canvas { max-height: 260px; }
.radar-wrap { width: 200px; height: 200px; }

/* ================================================================
   持仓管理
   ================================================================ */

/* A股红涨绿跌 */
.profit-positive { color: #ef4444 !important; }
.profit-negative { color: #22c55e !important; }

/* 资产概览渐变 */
.portfolio-summary {
    background: linear-gradient(135deg, #1e1b4b 0%, #172042 50%, #0c2647 100%);
    color: #e4e6eb;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; text-align: center; margin-bottom: 20px; }
.summary-grid-2 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; text-align: center; }
.summary-item { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.summary-item .value { font-size: 1.75rem; font-weight: 700; margin-bottom: 6px; line-height: 1.2; }
.summary-item .label { font-size: 0.875rem; opacity: 0.7; }
.summary-divider { border-top: 1px solid rgba(255,255,255,0.1); margin: 16px 0; }

/* 持仓表格 */
.portfolio-table th { font-size: 0.875rem; font-weight: 600; }
.portfolio-table td { font-size: 0.9rem; vertical-align: middle; }

/* 操作记录类型颜色（桌面端 td + 手机端 span 都覆盖） */
table td.operation-type-buy, .card span.operation-type-buy { color: #22c55e !important; }
table td.operation-type-sell, .card span.operation-type-sell { color: #ef4444 !important; }
table td.operation-type-add, .card span.operation-type-add { color: #86efac !important; }
table td.operation-type-reduce, .card span.operation-type-reduce { color: #fca5a5 !important; }
table td.operation-type-deposit, .card span.operation-type-deposit { color: #c084fc !important; }
table td.operation-type-withdraw, .card span.operation-type-withdraw { color: #60a5fa !important; }
table td.operation-type-set_fee_rate, .card span.operation-type-set_fee_rate { color: #fbbf24 !important; }

/* 交易费率（黄色） */
.text-fee-rate { color: #fbbf24 !important; font-weight: 500; }

/* 持仓占比颜色（高 specificity 覆盖表格 color !important） */
.table .weight-normal, .card .weight-normal { color: #60a5fa !important; }
.table .weight-warning-15, .card .weight-warning-15 { color: #fbbf24 !important; font-weight: 500; }
.table .weight-warning-20, .card .weight-warning-20 { color: #fb923c !important; font-weight: 500; }
.table .weight-warning-25, .card .weight-warning-25 { color: #f87171 !important; font-weight: 500; }
.table .weight-warning-30, .card .weight-warning-30 { color: #ef4444 !important; font-weight: 500; }
.table .weight-danger, .card .weight-danger { color: #ff4444 !important; font-weight: 600; }

/* 股票名称链接 */
.stock-link { color: #93c5fd; text-decoration: none; cursor: pointer; }
.stock-link:hover { color: #bfdbfe; text-decoration: underline; }
.stock-code { color: #6b7280; font-size: 0.75rem; }

/* 操作建议 */
.action-clear { color: #ff4444; font-weight: 600; }
.action-reduce { color: #fbbf24; font-weight: 600; }
.action-buy { color: #4ade80; font-weight: 600; }
.action-hold { color: #93c5fd; font-weight: 600; }
.action-edit { color: #f87171; font-weight: 600; }

/* 操作建议方框 */
.action-box {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    border: 2px solid;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}
.action-box:hover { opacity: 0.85; transform: scale(1.05); }
.action-box.action-clear { border-color: #dc2626; background-color: rgba(220,38,38,0.1); }
.action-box.action-reduce { border-color: #d97706; background-color: rgba(217,119,6,0.1); }
.action-box.action-buy { border-color: #16a34a; background-color: rgba(22,163,74,0.1); }
.action-box.action-hold { border-color: #2563eb; background-color: rgba(37,99,235,0.1); }
.action-box.action-edit { border-color: #991b1b; background-color: rgba(153,27,27,0.1); }

/* ================================================================
   数据管理
   ================================================================ */
.stats-card { transition: transform 0.15s; height: 100%; }
.stats-card:hover { transform: translateY(-2px); }
.action-card { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.action-card:hover:not(.disabled) { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.action-card.disabled { opacity: 0.6; cursor: not-allowed; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.status-dot.idle { background: #6b7280; }
.status-dot.running { background: #3b82f6; animation: pulse 1.5s infinite; }
.status-dot.finished { background: #22c55e; }
.status-dot.error { background: #ef4444; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ================================================================
   移动端适配
   ================================================================ */
@media (max-width: 767.98px) {
    .portfolio-summary { padding: 16px; }
    .summary-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px !important; }
    .summary-grid-1 { grid-template-columns: 1fr !important; }
    .summary-item .value { font-size: 1.15rem; }
    .summary-item .label { font-size: 0.75rem; }
    .sort-panel { padding: 8px !important; }
    #fieldButtons .btn, #fieldButtonsM .btn { font-size: 0.75rem; padding: 0.2rem 0.45rem; }
    #filterBar .input-group, #filterBarM .input-group { width: 100% !important; }
}

/* ===== 统一股票代码样式 ===== */
.stock-code-inline {
    color: #f472b6;
    font-size: 0.7rem;
    background: none !important;
    padding: 0;
}
