:root {
    --bg-dark: #090e17;
    --card-bg: #111827;
    --border-color: #1f2937;
    --accent: #38bdf8;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    padding-bottom: 40px;
    min-height: 100vh;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    background-color: #111827;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}
.logo { font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.tag { font-size: 0.72rem; background: #0284c7; padding: 2px 8px; border-radius: 4px; font-weight: 500; }
.status-bar { display: flex; align-items: center; gap: 12px; }
.btn-tool {
    background: #0284c7;
    border: none;
    color: #fff;
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}
.hint-text { font-size: 0.82rem; color: var(--text-muted); }

/* 下拉菜单 */
.dropdown { position: relative; display: inline-block; }
.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 105%;
    background-color: #1e293b;
    min-width: 190px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px;
    z-index: 100;
}
.dropdown-content.show { display: flex; flex-direction: column; gap: 8px; }
.dropdown-content label {
    font-size: 0.82rem;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
}
.dropdown-content label:hover { background-color: #334155; }

/* 两栏布局 */
.workbench-layout {
    display: flex;
    gap: 18px;
    max-width: 1880px;
    margin: 16px auto;
    padding: 0 16px;
    align-items: flex-start;
}

/* 左侧栏 */
.symbol-sidebar {
    width: 270px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 92vh;
    position: sticky;
    top: 72px;
}
.sidebar-header { display: flex; justify-content: space-between; align-items: center; }
.sidebar-header h3 { font-size: 0.98rem; color: var(--text-main); }
.count-tag { font-size: 0.75rem; background: #1e293b; border: 1px solid #334155; padding: 2px 8px; border-radius: 10px; color: var(--accent); }

.search-box input {
    width: 100%;
    background: #090e17;
    border: 1px solid #334155;
    color: #fff;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    outline: none;
}
.sector-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab-pill {
    background: #090e17;
    border: 1px solid #1f2937;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}
.tab-pill.active { background: #0284c7; color: #fff; border-color: #0284c7; }

.symbol-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    max-height: 68vh;
    padding-right: 4px;
}
.symbol-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #090e17;
    border: 1px solid #1f2937;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.symbol-item:hover { border-color: #38bdf8; background: #131c2e; }
.symbol-item.active {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.12);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}
.sym-info { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.sym-name { font-weight: 600; font-size: 0.88rem; color: #f8fafc; }
.sym-code { font-size: 0.76rem; color: #64748b; }
/* 三周期 N 结构标签：定宽三格并右对齐，替换原交易所标签列，保证各行严格对齐 */
.sym-nmarks { display: inline-flex; align-items: center; justify-content: flex-end; }
.sym-nmarks .nmark {
    display: inline-block; width: 15px; text-align: center;
    font-size: 0.8rem; font-weight: 400; line-height: 1;
}
.sym-nmarks .nmark.ok { color: #22c55e; }
.sym-nmarks .nmark.bear { color: #ef4444; }
.sym-nmarks .nmark.none { color: #f8fafc; }
.sym-nmarks .nmark.na { color: #475569; font-weight: 400; }

/* 共振栏“结构状态”里的中文标签：多头绿 / 空头红 / 无结构白 */
.n-txt.bull { color: #22c55e; }
.n-txt.bear { color: #ef4444; }
.n-txt.none { color: #f8fafc; }

/* 右侧主工作区 */
.workbench-main {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
    align-content: flex-start;
    min-width: 0;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

/* 核心：自由移动与缩放窗口通用规范 */
.movable-window {
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* 拖拽时的虚线占位符与半透明状态 */
.movable-window.dragging {
    opacity: 0.25;
    border: 2px dashed #38bdf8 !important;
}
.window-placeholder {
    border: 2px dashed #0284c7;
    background: rgba(2, 132, 199, 0.08);
    border-radius: 12px;
    box-sizing: border-box;
    transition: all 0.2s;
}

/* 拖拽把手高亮与光标 */
.window-header.drag-handle {
    cursor: grab;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #1f2937;
}
.window-header.drag-handle:active {
    cursor: grabbing;
}
.win-title { font-size: 0.92rem; font-weight: 600; color: #e2e8f0; pointer-events: none; }
.drag-hint { font-size: 0.72rem; color: #64748b; pointer-events: none; }

/* 合约切换条（位于卡片主体内，非拖拽区，确保下拉可点击） */
.contract-switch-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 0 10px; }
.contract-switch-bar .contract-switch-lbl { font-size: 0.78rem; color: #94a3b8; }
.contract-switch-bar .contract-switch-tip { font-size: 0.72rem; color: #64748b; }
.contract-switch-bar select {
    background: #1e293b; color: #38bdf8; border: 1px solid #334155; border-radius: 6px;
    padding: 4px 10px; font-size: 0.82rem; font-family: monospace; cursor: pointer;
}
.contract-switch-bar select:hover { border-color: #38bdf8; }

/* 专门的右下角缩放拉伸把手（高亮斜杠小三角） */
.resize-grip {
    position: absolute;
    right: 3px;
    bottom: 3px;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    z-index: 20;
    background: linear-gradient(135deg, transparent 50%, #475569 50%, #475569 60%, transparent 60%, transparent 75%, #38bdf8 75%);
    border-bottom-right-radius: 8px;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.resize-grip:hover {
    opacity: 1;
}

/* 默认窗口尺寸基准 */
.single-scan-window {
    width: 100%;
    min-height: 90px;
}
.single-sig-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #090e17;
    border: 1px solid #1f2937;
    border-radius: 8px;
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.single-sig-box.border-bull { border-color: #22c55e; box-shadow: 0 0 8px rgba(34, 197, 94, 0.25); }
.single-sig-box.border-bear { border-color: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.25); }
.sig-main-stat { display: flex; align-items: center; gap: 12px; }
.stat-badge { padding: 4px 10px; border-radius: 4px; font-size: 0.8rem; font-weight: bold; }
.badge-buy { background: #166534; color: #86efac; }
.badge-sell { background: #991b1b; color: #fca5a5; }
.badge-none { background: #1e293b; color: #94a3b8; }
.stat-desc { font-size: 0.82rem; color: #cbd5e1; }
.sig-details-row { display: flex; align-items: center; gap: 20px; font-size: 0.85rem; color: var(--text-muted); flex-wrap: wrap; }
.sig-details-row b { color: #f8fafc; }
/* 未共振时给出的原因提示条 */
.sig-hint {
    width: 100%;
    padding-top: 8px;
    margin-top: 2px;
    border-top: 1px dashed #1f2937;
    font-size: 0.76rem;
    color: #64748b;
}
/* 品种列表里的共振徽标（🔥多头/⚡空头） */
.sym-right .sym-status-badge {
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(148, 163, 184, 0.12);
}

.exposure-window {
    width: 100%;
}
.exposure-bar {
    display: grid;
    grid-template-columns: 1.4fr repeat(4, 1fr);
    gap: 12px;
}
.exp-item { display: flex; flex-direction: column; gap: 2px; }
.exp-item .label { font-size: 0.75rem; color: var(--text-muted); }
.exp-item .val { font-size: 1.05rem; font-weight: 700; color: #f8fafc; }
.exp-item .highlight { color: #38bdf8; }
.badge-bull { color: #22c55e; font-size: 0.95rem; }
.badge-bear { color: #ef4444; font-size: 0.95rem; }
.badge-neutral { color: #64748b; font-size: 0.85rem; }

/* 3 个 K 线图默认三列并排（可拉伸扩大或缩小） */
.chart-window {
    width: calc(33.333% - 11px);
    height: 480px;
    min-width: 320px;
    min-height: 280px;
}
.time-periods { display: flex; gap: 4px; }
.time-periods .btn-tab {
    background: #090e17;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}
.time-periods .btn-tab.active { background: #0284c7; color: #fff; border-color: #0284c7; }
.chart-container { flex: 1; width: 100%; height: 100%; min-height: 200px; }

.fund-window {
    width: 100%;
}
.btn-sm {
    background: #0284c7;
    border: none;
    color: #fff;
    padding: 4px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.78rem;
}
.btn-sm.outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-muted); }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; text-align: left; }
.data-table th, .data-table td { padding: 8px 10px; border-bottom: 1px solid #1f2937; }
.data-table th { color: var(--text-muted); font-weight: 500; }

.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-content {
    background: #111827;
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 12px;
    width: 380px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.modal-content input {
    background: #090e17;
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    color: #fff;
    border-radius: 6px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.btn-primary { background: #0284c7; color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; }
.btn-cancel { background: #475569; color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; }

@media (max-width: 1200px) {
    .chart-window { width: 100%; }
}


/* === 全局极简暗黑悬浮滚动条 (Modern Overlay Scrollbar) === */
* {
    scrollbar-width: thin !important;
    scrollbar-color: rgba(148, 163, 184, 0.25) transparent !important;
}

::-webkit-scrollbar {
    width: 4px !important;
    height: 4px !important;
}
::-webkit-scrollbar-track {
    background: transparent !important;
}
::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2) !important;
    border-radius: 999px !important;
}
::-webkit-scrollbar-thumb:hover {
    background: #0284c7 !important;
}
::-webkit-scrollbar-button {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* 侧边栏及品种列表平滑滚动与边距微调 */
aside.sidebar {
    overflow: hidden !important;
}
.symbol-list {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    padding: 6px 6px 12px 6px !important;
    scrollbar-gutter: stable;
}

/* 彻底解决敞口监控卡片被切断/遮挡问题 */
#panel-exposure {
    height: auto !important;
    min-height: 120px !important;
    overflow: visible !important;
}
#panel-exposure .exposure-grid {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 12px !important;
    margin-top: 10px !important;
}
#panel-exposure .stat-card {
    background: #0b1120 !important;
    border: 1px solid #1e293b !important;
    border-radius: 6px !important;
    padding: 10px 14px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
}
#panel-exposure .stat-label {
    font-size: 0.76rem !important;
    color: #94a3b8 !important;
}
#panel-exposure .stat-val {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    color: #f1f5f9 !important;
}
