:root {
    --bg-color: #121212;
    --text-color: #E0E0E0;
    --table-bg: #1E1E1E;
    --th-bg: #2C2C2C;
    --border-color: #333333;
    --hover-bg: #2A2A2A;
    --title-color: #00FFFF;
    --up-color: #FF4500;
    --down-color: #00FF00;
    --flash-bg: rgba(0, 255, 255, 0.4);
    --flash-text: #ffffff;
    --modal-bg: rgba(0, 0, 0, 0.85);
    --modal-content: #1E1E1E;
    --sparkline-color: rgba(0, 215, 255, 0.45);
    --dash-color: rgba(255, 255, 255, 0.3);
    --btn-text: #121212;
}

/* ================= 🚨 新增：焊死浏览器外层视窗 ================= */
html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    /* 彻底物理抹杀浏览器外层滚动条 */
}

body.light-mode {
    --bg-color: #F5F7FA;
    --text-color: #333333;
    --table-bg: #FFFFFF;
    --th-bg: #E4E7EB;
    --border-color: #D1D5DB;
    --hover-bg: #F0F4F8;
    --title-color: #0056b3;
    --up-color: #D32F2F;
    --down-color: #1B5E20;
    --flash-bg: rgba(0, 86, 179, 0.2);
    --flash-text: #000000;
    --modal-bg: rgba(255, 255, 255, 0.7);
    --modal-content: #FFFFFF;
    --sparkline-color: rgba(70, 130, 180, 0.4);
    --dash-color: rgba(136, 150, 160, 0.5);
    --btn-text: #FFFFFF;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    padding: 15px;
    transition: all 0.3s;
    /* 🚨 核心修复 1：开启全局纵向弹性排版 */
    display: flex;
    flex-direction: column;
    box-sizing: border-box; 
}

/* ================= 头部导航与控制台 ================= */
.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
    flex-shrink: 0;
    /* 🚨 新增：不管屏幕怎么挤，这里绝对不准缩小！ */
}

.dashboard-title {
    color: var(--title-color);
    margin: 0;
    font-size: 18px;
    letter-spacing: 1px;
}

.btn-group {
    display: flex;
    gap: 10px;
}

.theme-btn,
.cmd-btn {
    background-color: transparent;
    border: 1px solid rgba(136, 150, 160, 0.4);
    color: var(--text-color);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: all 0.3s;
    /* 统一控件高度矩阵 */
    height: 32px;
    line-height: 30px;
    padding: 0 12px;
    box-sizing: border-box;
}

.theme-btn:hover,
.cmd-btn:hover {
    background-color: var(--hover-bg);
    border-color: var(--title-color);
    color: var(--title-color);
}

/* ================= 战术雷达与过滤栏 ================= */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
    /* 🚨 新增：不管屏幕怎么挤，这里绝对不准缩小！ */
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 250px;
    max-width: 350px;
}

.search-box .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-color);
    font-size: 13px;
    opacity: 0.5;
}

.search-box input {
    width: 100%;
    background-color: var(--table-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 20px;
    font-size: 13px;
    transition: all 0.3s;
    /* 统一控件高度矩阵 */
    height: 32px;
    line-height: 30px;
    padding: 0 12px 0 32px;
    box-sizing: border-box;
}

.search-box input:focus {
    outline: none;
    border-color: var(--title-color);
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.2);
}

.filter-toggles {
    display: flex;
    gap: 10px;
}

.filter-btn {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    opacity: 0.6;
    /* 统一控件高度矩阵 */
    height: 32px;
    line-height: 30px;
    padding: 0 14px;
    box-sizing: border-box;
}

.filter-btn:hover {
    opacity: 1;
    border-color: var(--title-color);
}

.filter-btn.active {
    background-color: rgba(0, 255, 255, 0.1);
    border-color: var(--title-color);
    color: var(--title-color);
    opacity: 1;
    box-shadow: inset 0 0 5px rgba(0, 255, 255, 0.2);
}

body.light-mode .filter-btn.active {
    background-color: rgba(0, 86, 179, 0.1);
    box-shadow: inset 0 0 5px rgba(0, 86, 179, 0.2);
}

/* ================= 沉浸式表格视窗体系 ================= */
.table-viewport {
    /* 🚨 核心修复 2：彻底废除 calc，霸占剩余所有纵向屏幕空间！ */
    flex: 1;         
    min-height: 0;   
    
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--table-bg);
    scrollbar-width: thin;
    scrollbar-color: var(--title-color) transparent;
}

table {
    width: 100%;
    /* 为了支持悬浮不掉边框，必须使用 separate 并清零间距 */
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* 重新分配表格原生边框权责，防止加倍重叠 */
th,
td {
    border-top: none;
    border-left: none;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    padding: 8px 6px;
}

th:last-child,
td:last-child {
    border-right: none;
}

table td {
    text-align: center;
}

table td:nth-child(n+3) {
    text-align: right;
}

/* ================= 表头与底部的双锁定装甲 ================= */
th {
    background-color: var(--th-bg);
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 12;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 4px 6px -2px rgba(0, 0, 0, 0.5);
}

th:hover {
    background-color: var(--hover-bg);
}

tfoot td {
    position: sticky;
    bottom: -1px;
    z-index: 12;
    background-color: var(--hover-bg);
    border-top: 2px solid var(--title-color);
    border-bottom: none;
    font-weight: bold;
    box-shadow: 0 -4px 6px -2px rgba(0, 0, 0, 0.5);
}

body.light-mode th {
    box-shadow: 0 4px 6px -2px rgba(0, 0, 0, 0.15);
}

body.light-mode tfoot td {
    box-shadow: 0 -4px 6px -2px rgba(0, 0, 0, 0.15);
}

/* ================= 数据状态样式 ================= */
.sort-icon {
    display: none;
    font-size: 10px;
    margin-left: 2px;
}

.sort-active {
    display: inline;
    color: var(--title-color);
}

.red {
    color: var(--up-color);
    font-weight: bold;
}

.green {
    color: var(--down-color);
    font-weight: bold;
}

table {
    --active-row: -1;
    --active-col: -1;
}

#board tr.active-row {
    background-color: rgba(0, 255, 255, 0.08);
}

#board td.active-col {
    background-color: rgba(0, 255, 255, 0.1);
    box-shadow: inset 0 0 1px rgba(105, 147, 147, 0.3);
}

#board tr.active-row td.active-col {
    background-color: rgba(0, 255, 255, 0.25);
    color: var(--title-color);
    font-weight: bold;
}

@keyframes flashUpdate {
    0% {
        background-color: var(--flash-bg);
        color: var(--flash-text);
    }

    100% {
        background-color: transparent;
    }
}

.flash {
    animation: flashUpdate 1s ease-out;
}

@keyframes flipInX {
    0% {
        transform: perspective(400px) rotateX(90deg);
        opacity: 0;
    }

    40% {
        transform: perspective(400px) rotateX(-10deg);
        opacity: 1;
    }

    70% {
        transform: perspective(400px) rotateX(10deg);
    }

    100% {
        transform: perspective(400px) rotateX(0deg);
        opacity: 1;
    }
}

.market-ticker {
    display: inline-block;
    animation: flipInX 0.6s ease-out both;
    font-family: Consolas, monospace;
    font-size: 13px;
    letter-spacing: 0.5px;
}

.unit {
    font-size: 0.75em;
    font-weight: normal;
    color: #888888;
    margin-left: 2px;
    vertical-align: baseline;
}

.data-badge {
    display: inline-block;
    padding: 0px 4px;
    border-radius: 3px;
    font-size: 10px;
    margin-left: 6px;
    vertical-align: text-top;
    cursor: help;
    font-style: normal;
    font-weight: normal;
}

.badge-actual {
    background-color: rgba(46, 213, 115, 0.15);
    color: #2ed573;
    border: 1px solid rgba(46, 213, 115, 0.4);
}

.badge-est {
    background-color: rgba(136, 150, 160, 0.15);
    color: #8896A0;
    border: 1px solid rgba(136, 150, 160, 0.3);
}

body.light-mode .badge-actual {
    background-color: rgba(27, 94, 32, 0.1);
    color: #1B5E20;
    border-color: rgba(27, 94, 32, 0.3);
}

body.light-mode .badge-est {
    background-color: rgba(136, 150, 160, 0.1);
    color: #666666;
    border-color: rgba(136, 150, 160, 0.3);
}

/* ================= 弹窗 (Modal) 与抽屉系统 ================= */
.modal {
    display: none;
    position: fixed;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--modal-content);
    padding: 25px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 85%;
    max-width: 900px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.modal-header h2 {
    margin: 0;
    color: var(--title-color);
    font-size: 20px;
}

.close-btn {
    color: var(--text-color);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.close-btn:hover {
    color: var(--up-color);
}

.modal input {
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 5px;
    border-radius: 3px;
    width: 90%;
    font-family: Consolas, monospace;
    text-align: center;
}

.modal input[readonly] {
    background-color: var(--table-bg);
    color: gray;
    border-color: transparent;
    cursor: not-allowed;
}

.modal input:focus {
    outline: none;
    border-color: var(--title-color);
}

.modal-body {
    position: relative;
    max-height: 55vh;
    overflow-y: auto;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--modal-content);
}

.modal-table {
    width: 100%;
    border-collapse: collapse;
    /* 内部弹窗表格保留简单的折叠模式即可 */
    margin: 0;
}

.modal-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--th-bg);
    color: var(--text-color);
    padding: 12px 8px;
    border-bottom: 2px solid var(--border-color);
    box-shadow: none;
    /* 内部表格不需要复杂的阴影 */
}

.modal-table td {
    background-color: var(--modal-content);
    border-bottom: 1px solid var(--border-color);
}

.modal-table input {
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    position: relative;
    z-index: 1;
}

.capital-input {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    font-weight: bold;
    font-size: 16px;
}

.capital-input input {
    width: 150px;
    font-size: 16px;
}

.conf-name-td {
    font-weight: bold;
    font-size: 12px;
}

.text-center {
    text-align: center;
}

.btn-danger {
    background-color: transparent;
    border: 1px solid var(--up-color);
    color: var(--up-color);
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
}

.btn-danger:hover {
    background-color: var(--up-color);
    color: white;
}

.btn-add {
    background-color: transparent;
    border: 1px dashed var(--title-color);
    color: var(--title-color);
    padding: 10px;
    cursor: pointer;
    border-radius: 4px;
    width: 100%;
    font-weight: bold;
    margin-top: 15px;
}

.btn-add:hover {
    background-color: rgba(0, 255, 255, 0.1);
}

.modal-footer {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.btn-save {
    background-color: var(--title-color);
    color: var(--btn-text);
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
}

.btn-save:hover {
    filter: brightness(1.2);
}

/* ================= 侧抽屉面板 ================= */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(3px);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.drawer-panel {
    position: fixed;
    top: 0;
    right: -650px;
    width: 600px;
    max-width: 90vw;
    height: 100vh;
    background-color: var(--modal-content);
    color: var(--text-color);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
    z-index: 1050;
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow-y: auto;
    border-left: 1px solid rgba(136, 150, 160, 0.2);
}

.drawer-panel.active {
    right: 0;
}

.drawer-header {
    padding: 20px 25px;
    border-bottom: 1px solid rgba(136, 150, 160, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
}

.drawer-body {
    padding: 20px 25px;
}

.chart-container {
    width: 100%;
    height: 280px;
    margin-bottom: 30px;
    border: 1px solid rgba(136, 150, 160, 0.1);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.02);
}

.stock-trigger {
    cursor: pointer;
    transition: color 0.2s;
}

.stock-trigger:hover {
    color: #00d7ff;
    text-shadow: 0 0 8px rgba(0, 215, 255, 0.4);
}

/* ================= 联想输入雷达 UI ================= */
.autocomplete-wrapper {
    position: relative;
    width: 100%;
}

.autocomplete-dropdown {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    bottom: auto;
    width: 200px;
    background-color: var(--modal-content);
    border: 1px solid var(--title-color);
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    max-height: 250px;
    overflow-y: auto;
    z-index: 9999;
    text-align: left;
    margin-top: 2px;
}

.autocomplete-dropdown.drop-up {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 2px;
    border-radius: 4px 4px 0 0;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.6);
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border-color);
    color: var(--text-color);
    transition: background-color 0.2s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background-color: rgba(0, 255, 255, 0.15);
}

.autocomplete-item .ac-code {
    font-family: Consolas, monospace;
    color: var(--up-color);
    font-weight: bold;
}

.autocomplete-item .ac-name {
    font-weight: bold;
    letter-spacing: 1px;
}

/* ================= 时光机控制台与卡片 ================= */
.drawer-section-title {
    color: var(--title-color);
    border-left: 4px solid var(--sparkline-color);
    padding-left: 10px;
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 16px;
    letter-spacing: 1px;
}

.time-machine-controls-pro {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: var(--widget-bg);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid rgba(136, 150, 160, 0.15);
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.tm-form-row {
    display: flex;
    gap: 15px;
    width: 100%;
}

.tm-form-row.align-end {
    align-items: flex-end;
}

.tm-input-group-pro {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.tm-input-group-pro label {
    font-size: 12px;
    color: var(--title-color);
    font-weight: bold;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.tm-input-group-pro input {
    width: 100%;
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    border-radius: 6px;
    font-family: Consolas, monospace;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.tm-input-group-pro input:focus {
    outline: none;
    border-color: var(--up-color);
    box-shadow: 0 0 5px rgba(255, 69, 0, 0.3);
}

#tm-run-btn-pro {
    width: 100%;
    height: 40px;
    background-color: transparent;
    border: 1.5px solid var(--up-color);
    color: var(--up-color);
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 15px;
    transition: all 0.3s;
    letter-spacing: 1px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#tm-run-btn-pro:hover {
    background-color: var(--up-color);
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 69, 0, 0.6);
}

#tm-run-btn-pro:disabled {
    border-color: gray;
    color: gray;
    cursor: not-allowed;
    box-shadow: none;
}

.tm-stats-panel {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.tm-stat-card {
    flex: 1;
    background: var(--widget-bg);
    border: 1px solid rgba(136, 150, 160, 0.2);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.tm-stat-card.no-drip::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: #aab0bd;
}

.tm-stat-card.drip::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: #ff4757;
}

.tm-card-title {
    font-size: 13px;
    color: var(--text-color);
    font-weight: bold;
    opacity: 0.8;
    margin-bottom: 10px;
}

.tm-card-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
}

.tm-card-main .val {
    font-size: 22px;
    font-weight: 900;
    font-family: Consolas, monospace;
}

.tm-card-main .pct {
    font-size: 14px;
    font-weight: bold;
}

.tm-card-sub {
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.7;
    display: flex;
    justify-content: space-between;
    border-top: 1px dashed rgba(136, 150, 160, 0.3);
    padding-top: 8px;
}

.tm-card-sub b {
    color: var(--text-color);
    opacity: 1;
    font-family: Consolas, monospace;
}

/* ================= 流通股东雷达专属样式 ================= */
.holders-table {
    table-layout: fixed;    /* 🚨 核心：必须开启固定布局，否则列宽比例无效 */
    width: 100%; 
    border-collapse: collapse; 
    font-size: 12px; 
    margin: 0;
}

/* 🛡️ 压榨空间：手动定义每一列的完美比例，确保右侧两列永不退让 */
.holders-table th:nth-child(1), .holders-table td:nth-child(1) { width: 5%; }  /* # */
.holders-table th:nth-child(2), .holders-table td:nth-child(2) { width: 45%; } /* 股东名称 (核心截断列) */
.holders-table th:nth-child(3), .holders-table td:nth-child(3) { width: 17%; } /* 机构类型 */
.holders-table th:nth-child(4), .holders-table td:nth-child(4) { width: 15%; } /* 持仓占比 */
.holders-table th:nth-child(5), .holders-table td:nth-child(5) { width: 18%; } /* 近期动作 */

/* 🛡️ 核心截断类 */
.holder-name-truncated {
    white-space: nowrap;        /* 🚨 核心 1：不换行 */
    overflow: hidden;           /* 🚨 核心 2：隐藏超出部分 */
    text-overflow: ellipsis;     /* 🚨 核心 3：显示省略号 ... */
    cursor: help;              /* 增加“帮助”手势，提示可以悬停 */
    color: var(--text-color) !important; /* 确保名字颜色正确 */
}

/* 基础美化 */
.holders-table td {
    padding: 8px;
    border-bottom: 1px solid rgba(136, 150, 160, 0.15);
}
.holders-table tr:last-child td {
    border-bottom: none;
}
.holders-table tr:hover {
    background-color: rgba(0, 255, 255, 0.05);
}
body.light-mode .holders-table tr:hover {
    background-color: rgba(0, 86, 179, 0.05);
}