:root {
    --bg-dark: #07090e;
    --panel-bg: #0d1117;
    --header-bg: #161b22;
    --border-color: #21262d;
    --text-main: #c9d1d9;
    --text-dim: #8b949e;
    --text-bright: #ffffff;
    --red: #ef5350;
    --green: #26a69a;
    --red-bg: rgba(239, 83, 80, 0.15);
    --green-bg: rgba(38, 166, 154, 0.15);
    --amber: #d29922;
    --blue: #58a6ff;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* --- 全局深色极简滚动条 (5px) --- */
*::-webkit-scrollbar,
.panel-body::-webkit-scrollbar,
#news-list-box::-webkit-scrollbar,
#workspace::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

*::-webkit-scrollbar-track,
.panel-body::-webkit-scrollbar-track,
#news-list-box::-webkit-scrollbar-track,
#workspace::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
    background: rgba(13, 17, 23, 0.5);
}

*::-webkit-scrollbar-thumb,
.panel-body::-webkit-scrollbar-thumb,
#news-list-box::-webkit-scrollbar-thumb,
#workspace::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover,
.panel-body::-webkit-scrollbar-thumb:hover,
#news-list-box::-webkit-scrollbar-thumb:hover,
#workspace::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
    background: #8b949e;
}

html, body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.25;
    width: 100vw;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

/* 顶部导航栏 */
#top-nav {
    min-height: 34px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 8px;
    gap: 8px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.brand {
    color: #fff;
    font-weight: bold;
    font-size: 12px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.badge-v {
    color: #8b949e;
    font-size: 10px;
    white-space: nowrap;
}

.ticker-bar {
    display: flex;
    gap: 10px;
    font-size: 11px;
    background: #000;
    padding: 3px 8px;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.ticker-bar span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ticker-bar b.price {
    color: #ffffff;
    font-weight: 600;
    font-family: monospace;
}

.ticker-bar b.rate {
    font-family: monospace;
    font-weight: bold;
}

.up-text { color: var(--red) !important; }
.down-text { color: var(--green) !important; }
.up-bg { background-color: var(--red) !important; }
.down-bg { background-color: var(--green) !important; }

.btn {
    background: #21262d;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    white-space: nowrap;
    min-height: 24px;
}

.btn:hover {
    background: #30363d;
    color: #fff;
    border-color: #484f58;
}

.btn-primary {
    background: #1f6feb !important;
    color: #fff !important;
    border-color: #388bfd !important;
}

.btn-primary:hover {
    background: #388bfd !important;
}

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
    border-color: var(--red);
}

/* 工作区排版 */
#workspace {
    width: 100%;
    padding: 6px;
    box-sizing: border-box;
}

/* 1. PC 横屏模式 (Landscape) */
@media (min-width: 769px) and (orientation: landscape) {
    #workspace {
        display: grid;
        grid-template-columns: 1.8fr 1fr;
        gap: 8px;
        min-height: calc(100vh - 36px);
    }

    #workspace .panel {
        min-height: 220px;
    }

    .panel-p1 {
        min-height: 380px;
    }

    .panel-p4 {
        min-height: 360px;
    }

    .panel-p3 {
        grid-column: 1 / -1;
        min-height: 180px;
    }
}

/* 2. PC 竖屏模式 (Portrait > 768px) */
@media (min-width: 769px) and (orientation: portrait) {
    #workspace {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        overflow-y: auto;
        padding-bottom: 24px;
    }

    .panel-p1 {
        grid-column: 1 / -1;
        min-height: 400px;
    }

    .panel-p4 {
        grid-column: 1 / -1;
        min-height: 360px;
    }

    .panel-p3 {
        grid-column: 1 / -1;
        min-height: 220px;
    }
}

/* 3. 手机与窄屏模式 (<= 768px) */
@media (max-width: 768px) {
    #top-nav {
        padding: 4px 6px;
        gap: 6px;
    }

    .brand {
        font-size: 11px;
    }

    .ticker-bar {
        width: 100%;
        order: 3;
        padding: 4px 6px;
        font-size: 10px;
        gap: 8px;
    }

    .nav-right {
        gap: 4px;
    }

    .btn {
        padding: 3px 6px;
        font-size: 10px;
        min-height: 26px;
    }

    #workspace {
        display: flex !important;
        flex-direction: column !important;
        padding: 4px !important;
        gap: 8px !important;
    }

    .panel {
        width: 100% !important;
        min-height: 260px !important;
        flex-shrink: 0 !important;
    }

    .panel-p1 {
        min-height: 340px !important;
    }

    .panel-p4 {
        min-height: 340px !important;
    }

    .panel-p3 {
        min-height: 220px !important;
    }
}

/* 模块面板基础设置 */
.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    overflow: hidden;
    position: relative;
    width: 100%;
    border-radius: 3px;
}

.panel-header {
    height: 25px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    cursor: default;
    font-weight: bold;
    color: var(--text-bright);
    flex-shrink: 0;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-subtext {
    font-weight: normal;
    color: var(--text-dim);
    font-size: 10px;
}

.panel-body {
    flex: 1;
    padding: 4px;
    position: relative;
    overflow-y: auto !important;
    display: flex;
    flex-direction: column;
}

/* 编辑 Layout 模式 */
#workspace.layout-editable .panel {
    cursor: grab;
    border: 1px dashed var(--amber, #d29922) !important;
    resize: vertical;
    overflow: auto !important;
}

#workspace.layout-editable .panel:active {
    cursor: grabbing;
}

.panel.dragging {
    opacity: 0.35;
    border: 2px dashed #58a6ff !important;
}

/* 01 面板：热力图容器 */
.tree-node {
    border: 1px solid #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1px 2px;
    text-align: center;
    overflow: hidden;
    font-weight: bold;
}

/* 03 新闻快讯排版 */
#body-p3 {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 4px;
}

.news-tabs {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    padding-bottom: 4px;
    overflow-x: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab-btn {
    background: #161b22;
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    font-size: 11px;
    padding: 2px 7px;
    cursor: pointer;
    border-radius: 2px;
    flex-shrink: 0;
}

.tab-btn:hover {
    color: var(--text-bright);
    border-color: #30363d;
}

.tab-btn.active {
    border-color: var(--amber);
    color: #000;
    background: var(--amber);
    font-weight: bold;
}

#news-list-box {
    flex: 1;
    overflow-y: auto;
    padding-right: 2px;
}

.news-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 4px;
    border-bottom: 1px dashed #21262d;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 12px;
}

.news-item:hover {
    background: rgba(210, 153, 34, 0.08);
}

.news-tag {
    font-size: 10px;
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 2px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.tag-global { background: #3b82f622; color: #60a5fa; border: 1px solid #3b82f644; }
.tag-shares { background: #ef444422; color: #f87171; border: 1px solid #ef444444; }
.tag-bonds  { background: #10b98122; color: #34d399; border: 1px solid #10b98144; }

.news-title {
    font-size: 12px;
    color: #e5e7eb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    line-height: 1.4;
}

.news-tabs, .news-item, .inspector-modal {
    user-select: text;
}

/* 检查器弹窗 Inspector Modal */
.inspector-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 12px;
}

.inspector-content {
    width: 100%;
    max-width: 460px;
    max-height: 85vh;
    background: #0d1117;
    border: 1px solid var(--amber);
    box-shadow: 0 0 20px rgba(210, 153, 34, 0.25);
    font-family: var(--font-mono);
    color: #d1d5db;
    display: flex;
    flex-direction: column;
    border-radius: 3px;
}

.inspector-header {
    background: var(--amber);
    color: #000;
    font-weight: bold;
    padding: 6px 10px;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.inspector-header .close-btn {
    background: none;
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    color: #000;
    line-height: 1;
}

.inspector-body {
    padding: 12px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.5;
}

.insp-tag { color: var(--amber); font-weight: bold; margin-bottom: 4px; display: inline-block; }
.insp-time { color: #888; font-size: 11px; margin-left: 8px; }
.insp-title { font-size: 14px; font-weight: bold; color: #fff; margin: 6px 0; line-height: 1.35; }
.insp-summary { color: #a1a1aa; margin-bottom: 12px; border-left: 2px solid var(--amber); padding-left: 8px; }
.insp-grid {
    border-top: 1px dashed #30363d;
    padding-top: 8px;
    display: grid;
    grid-template-columns: 85px 1fr;
    gap: 6px;
}
.insp-label { color: #6e7681; }
.insp-val { color: #58a6ff; word-break: break-all; }
.insp-link { color: #38bdf8; text-decoration: none; }
.insp-link:hover { text-decoration: underline; }

/* 05 面板：格隆汇题材热度榜精细化排版 */
.theme-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    font-size: 11px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
    background: #0d1117;
    color: #c9d1d9;
    box-sizing: border-box;
    position: relative;
}

.theme-header-row {
    display: grid;
    grid-template-columns: 100px 1fr 60px;
    padding: 5px 8px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    color: #8b949e;
    font-size: 10px;
    font-weight: 600;
}

.theme-list-box {
    flex: 1;
    overflow-y: auto;
    padding: 2px 0;
}

.theme-row {
    display: grid;
    grid-template-columns: 100px 1fr 60px;
    align-items: center;
    padding: 5px 8px;
    border-bottom: 1px solid #21262d;
    transition: background 0.15s ease;
    cursor: pointer;
}

.theme-row:hover {
    background: #161b22;
}

.col-name {
    font-weight: bold;
    color: #f0f6fc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-bar-wrap {
    position: relative;
    height: 16px;
    display: flex;
    align-items: center;
    margin: 0 8px;
}

.axis-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #484f58;
    z-index: 1;
}

.bar-container {
    width: 100%;
    display: flex;
    height: 10px;
    z-index: 2;
}

.bar-left, .bar-right {
    width: 50%;
    display: flex;
    align-items: center;
}

.bar-left {
    justify-content: flex-end;
    padding-right: 2px;
}

.bar-right {
    justify-content: flex-start;
    padding-left: 2px;
}

.bar-fill {
    height: 100%;
    border-radius: 1px;
    transition: width 0.3s ease;
}

.bar-val {
    font-size: 10px;
    font-weight: 600;
    font-family: monospace;
    white-space: nowrap;
}

.col-limit {
    text-align: right;
    font-family: monospace;
    color: #8b949e;
    font-size: 10px;
}

.col-limit .num-highlight {
    color: var(--red);
    font-weight: bold;
}

.theme-tooltip {
    position: fixed;
    display: none;
    z-index: 9999;
    background: #161b22;
    border: 1px solid #484f58;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    padding: 8px 12px;
    border-radius: 4px;
    max-width: 280px;
    pointer-events: none;
    font-size: 11px;
    line-height: 1.5;
    color: #e6edf3;
}

.theme-tooltip .tt-title {
    font-weight: bold;
    color: #58a6ff;
    margin-bottom: 4px;
    border-bottom: 1px solid #30363d;
    padding-bottom: 3px;
}

.theme-tooltip .tt-item {
    color: #8b949e;
    font-size: 10px;
}

.theme-tooltip .tt-desc {
    margin-top: 4px;
    color: #c9d1d9;
    word-break: break-all;
}

/* 06 面板：华尔街见闻大宗商品标签与表格 */
.wscn-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
}

.wscn-tabs {
    display: flex;
    background: #12151c;
    border-bottom: 1px solid #222;
    flex-shrink: 0;
}

.wscn-tab-btn {
    padding: 4px 10px;
    cursor: pointer;
    color: #888;
    font-size: 11px;
    transition: 0.2s;
    border-bottom: 2px solid transparent;
}

.wscn-tab-btn:hover {
    color: #ccc;
}

.wscn-tab-btn.active {
    color: #58a6ff;
    font-weight: bold;
    border-bottom: 2px solid #58a6ff;
}

.wscn-table-box {
    flex: 1;
    overflow-y: auto;
    padding-right: 2px;
}
