/* ============================================
   通达信监控系统 - 专业深色主题
   ============================================ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-card: #1c1e2e;
    --bg-card-hover: #232538;
    --bg-header: #252740;
    --border-color: #2a2d40;
    --border-hover: #3b82f6;
    --text-primary: #e2e4ec;
    --text-secondary: #8b8fa8;
    --text-muted: #5c6078;
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.25);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

html.light-theme,
body.light-theme {
    --bg-primary: #f5f7fb;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-header: #eef2f7;
    --border-color: #d8dee9;
    --border-hover: #2563eb;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #8a94a6;
    --shadow-sm: 0 1px 3px rgba(15,23,42,0.08);
    --shadow-md: 0 8px 24px rgba(15,23,42,0.10);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ====== 导航栏 ====== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    padding: 0 24px;
    height: 56px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.navbar-menu {
    display: flex;
    gap: 2px;
}

.nav-item {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-size: 0.88rem;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-blue);
    color: #fff;
}

.navbar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.status-indicator { font-size: 10px; }
.status-indicator.online { color: var(--accent-green); }
.status-indicator.offline { color: var(--accent-red); }

.theme-toggle {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.82rem;
}

.theme-toggle:hover {
    border-color: var(--accent-blue);
}

/* ====== 主容器 ====== */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
    min-height: calc(100vh - 100px);
}

/* ====== 页面头部 ====== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 1.4rem;
    color: var(--text-primary);
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ====== 统计卡片 ====== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stats-row.small {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: border-color 0.2s, transform 0.2s;
}

.stat-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}

.stat-icon { font-size: 1.8rem; }

.stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stats-row.small .stat-value { font-size: 1.3rem; }

.stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* ====== 区块 ====== */
.section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}

.section-title {
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.view-all {
    font-size: 0.85rem;
    color: var(--accent-blue);
    text-decoration: none;
}
.view-all:hover { text-decoration: underline; }

/* ====== 节点网格 ====== */
.nodes-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.node-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 7px 14px;
    transition: border-color 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
}

.node-card.online { border-left: 3px solid var(--accent-green); }
.node-card.offline { border-left: 3px solid var(--accent-red); opacity: 0.65; }

.node-card-row1 {
    display: flex;
    align-items: center;
    gap: 7px;
}
.node-card-row2 {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
}

.node-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.status-dot.online { background: var(--accent-green); box-shadow: 0 0 5px var(--accent-green); }
.status-dot.offline { background: var(--accent-red); }

.node-name { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-id { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.node-info { display: flex; gap: 10px; font-size: 0.82rem; color: var(--text-secondary); white-space: nowrap; }
.node-heartbeat { font-size: 0.78rem; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* ====== 表格 ====== */
.table-container { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table th,
.data-table td {
    padding: 11px 14px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--bg-header);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-table td {
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.data-table .loading,
.data-table .empty {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* ====== 颜色类 ====== */
.text-red { color: var(--accent-red) !important; }
.text-green { color: var(--accent-green) !important; }

/* ====== 状态标签 ====== */
.status-active {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(34,197,94,0.15);
    color: var(--accent-green);
    border-radius: 4px;
    font-size: 0.78rem;
}

.status-sold {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(245,158,11,0.15);
    color: var(--accent-yellow);
    border-radius: 4px;
    font-size: 0.78rem;
}

.profit { color: var(--accent-red); }
.loss   { color: var(--accent-green); }

/* ====== 按钮 ====== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-primary {
    background: var(--accent-blue);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-blue-hover); }

.btn-danger {
    padding: 4px 10px;
    background: var(--accent-red);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: opacity 0.2s;
}
.btn-danger:hover { opacity: 0.85; }

.btn-sm {
    padding: 2px 8px;
    font-size: 0.7rem;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
}
.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-secondary); }
.btn-sm.btn-danger {
    padding: 2px 8px;
    font-size: 0.7rem;
}

.card-actions {
    display: flex;
    justify-content: flex-end;
    padding: 6px 16px 0;
}

/* ====== 筛选器 ====== */
.filter-select {
    padding: 7px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-width: 120px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    cursor: pointer;
    color: var(--text-secondary);
}

/* ====== 空状态 ====== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state .hint { font-size: 0.82rem; margin-top: 8px; }

/* ====== 页脚 ====== */
.footer {
    text-align: center;
    padding: 14px;
    color: var(--text-muted);
    font-size: 0.8rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

/* ====== 策略收益回撤卡片 ====== */
.strategy-returns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.node-group {
    grid-column: 1 / -1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
}

.node-group + .node-group {
    margin-top: 12px;
}

.node-group-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 600;
}

.node-group-title span {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 400;
}

.strategy-return-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s;
}

.strategy-return-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.empty-pos-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.18);
    color: #f59e0b;
    font-size: 0.7rem;
    font-weight: 600;
    vertical-align: middle;
    letter-spacing: 0.5px;
}

.card-footer-actions {
    display: flex;
    gap: 6px;
    padding: 10px 16px 12px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    justify-content: flex-end;
}

.card-footer-actions .btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.card-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #1a2744 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.strategy-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
}

.node-badge {
    background: rgba(255,255,255,0.12);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.8);
}

.return-section { padding: 0; }

.section-title-bar {
    background: var(--bg-header);
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.return-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

.return-item {
    padding: 12px;
    text-align: center;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}
.return-item:nth-child(3n) { border-right: none; }
.return-item:nth-last-child(-n+3) { border-bottom: none; }

.return-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.return-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}
.return-value.positive { color: var(--accent-red); }
.return-value.negative { color: var(--accent-green); }

.card-footer {
    background: var(--bg-header);
    padding: 10px 14px;
    display: flex;
    justify-content: space-around;
    border-top: 1px solid var(--border-color);
}

.footer-item { text-align: center; }
.footer-label { font-size: 0.72rem; color: var(--text-muted); display: block; margin-bottom: 2px; }
.footer-value { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); }

.loading-card {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

/* ====== 通达信板块页面 ====== */
.tdx-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.tdx-header h2 { margin: 0; color: var(--text-primary); font-weight: 700; }
.tdx-header .refresh-btn {
    padding: 8px 16px;
    background: var(--accent-blue);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
}
.tdx-header .refresh-btn:hover { background: var(--accent-blue-hover); }

.blocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.block-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.2s;
}
.block-card:hover { border-color: var(--accent-blue); }
.block-card.selected-block {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.25);
}

.block-card .block-name { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
.block-card .block-meta { font-size: 0.78rem; color: var(--text-muted); }
.block-card .stock-count { font-size: 2rem; font-weight: 700; color: var(--accent-blue); }
.block-card .stock-count-label { font-size: 0.78rem; color: var(--text-muted); margin-left: 4px; }
.block-card .node-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-header);
    border-radius: 12px;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.block-card .view-btn {
    padding: 4px 12px;
    background: transparent;
    color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.78rem;
}
.block-card .view-btn:hover { background: var(--accent-blue); color: #fff; }

.stock-list-section { margin-top: 24px; }
.stock-list-section h3 { color: var(--text-primary); margin-bottom: 12px; font-weight: 600; }

.stock-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.stock-table th {
    background: var(--bg-header);
    color: var(--text-secondary);
    padding: 10px 14px;
    text-align: left;
    font-size: 0.82rem;
    font-weight: 600;
}
.stock-table td {
    padding: 10px 14px;
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: 'Consolas', 'SF Mono', monospace;
}
.stock-table tr:hover td { background: var(--bg-card-hover); }

.update-time { color: var(--text-muted); font-size: 0.78rem; }

/* ====== 响应式 ====== */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        height: auto;
        padding: 10px;
    }
    .navbar-menu {
        flex-wrap: wrap;
        justify-content: center;
        margin: 8px 0;
    }
    .page-header { flex-direction: column; gap: 12px; }
    .header-actions { flex-wrap: wrap; justify-content: center; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .strategy-returns-grid { grid-template-columns: 1fr; }
    .blocks-grid { grid-template-columns: 1fr; }
}

/* ===== 认证：用户区 / 角色徽章 / 登录页 / 提示横幅 ===== */
.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--border-color);
}
.user-menu .user-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
}
.user-menu .user-link {
    color: var(--accent-blue);
    font-size: 0.82rem;
    text-decoration: none;
}
.user-menu .user-link:hover { text-decoration: underline; }
.btn-logout {
    padding: 2px 10px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}
.btn-logout:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
}

/* 角色徽章：管理员=橙红，游客=蓝 */
.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
}
.role-badge.role-admin {
    background: rgba(245, 158, 11, 0.18);
    color: var(--accent-yellow);
    border: 1px solid rgba(245, 158, 11, 0.4);
}
.role-badge.role-guest {
    background: rgba(59, 130, 246, 0.18);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.4);
}

/* 默认密码提示横幅 */
.alert-banner {
    background: rgba(245, 158, 11, 0.12);
    border-bottom: 1px solid rgba(245, 158, 11, 0.4);
    color: var(--accent-yellow);
    padding: 8px 24px;
    font-size: 0.85rem;
    text-align: center;
}
.alert-banner a { color: var(--accent-yellow); font-weight: 600; text-decoration: underline; }

/* === 新功能红点 + 顶部 banner === */
.nav-new-dot {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    background: #ef4444;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.4;
    border-radius: 8px;
    letter-spacing: 0.5px;
    vertical-align: middle;
    animation: pulse-new 2s ease-in-out infinite;
}
@keyframes pulse-new {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.1); opacity: 0.85; }
}
.new-feature-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: linear-gradient(90deg, rgba(16,185,129,0.18) 0%, rgba(16,185,129,0.10) 50%, rgba(16,185,129,0.18) 100%);
    border-bottom: 1px solid rgba(16,185,129,0.4);
    color: var(--text-primary);
    padding: 10px 24px;
    font-size: 0.88rem;
    text-align: center;
    position: relative;
}
.new-feature-banner a {
    color: #10b981;
    font-weight: 700;
    text-decoration: none;
    margin-left: 4px;
}
.new-feature-banner a:hover { text-decoration: underline; }
.new-feature-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 8px;
}
.new-feature-close:hover { color: var(--text-primary); }

/* 登录 / 个人中心 表单卡片 */
.login-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 16px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    box-shadow: var(--shadow-md);
}
.login-card h2 {
    margin: 0 0 6px;
    text-align: center;
    color: var(--text-primary);
    font-size: 1.3rem;
}
.login-card .login-sub {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 22px;
}
.form-field { margin-bottom: 16px; }
.form-field label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--accent-blue); }
.login-card .btn-primary {
    width: 100%;
    padding: 11px;
    font-size: 0.95rem;
    margin-top: 6px;
    cursor: pointer;
}
.form-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: var(--accent-red);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    margin-bottom: 14px;
}
.form-msg {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: var(--accent-green);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    margin-bottom: 14px;
}
.login-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 18px;
}

/* 403 拒绝页 */
.denied-wrap {
    text-align: center;
    padding: 60px 16px;
}
.denied-wrap .denied-icon { font-size: 3rem; margin-bottom: 12px; }
.denied-wrap h2 { color: var(--accent-red); margin-bottom: 8px; }
.denied-wrap p { color: var(--text-secondary); margin-bottom: 20px; }

/* 管理员操作按钮容器（游客时由 JS 隐藏） */
.admin-only { /* 默认显示，游客由 app.js 隐藏 */ }
body.role-guest .admin-only { display: none !important; }

