/* ======================================================================
   冬瓜AI数据 全局样式（v5 · 连板天梯化）
   设计来源：https://stock.quicktiny.cn 实测（2026-07-07）
   布局：左 sidebar(240) + 顶 navbar(64) + 全宽内容区
   视觉：紧凑信息密度、4px 圆角、克制阴影、Google 蓝 + 连板天梯红
   主题：CSS 变量驱动 + data-theme 切换 + 红涨绿跌（中国惯例）
   ====================================================================== */

/* ------------------------------------------------------------------
   默认主题：连板天梯浅色（白底 + 浅灰 sidebar）
   ------------------------------------------------------------------ */
:root {
    /* 布局尺寸 */
    --sidebar-width: 200px;
    --navbar-height: 64px;
    --content-padding: 24px;

    /* 表面 */
    --bg: #F7F8FA;
    --surface: #FFFFFF;
    --surface-2: #F0F2F5;
    --surface-hover: #E8EAED;
    --surface-3: rgba(245, 158, 11, 0.06);  /* 弱强调底（§1.3，token 化） */
    --border: #E8EAED;
    --border-light: #F0F2F5;

    /* 文字 */
    --text: #1F1F1F;
    --text-secondary: #333333;
    --text-muted: #8B95A1;

    /* 主题色：Google 蓝 + 连板天梯红 */
    --primary: #1A73E8;            /* Google Blue 600 - 与连板天梯完全一致 */
    --primary-hover: #1557B0;
    --primary-bg: #E8F0FE;          /* active 项背景 = Google Blue 50 */
    --primary-border: #C6DAFC;
    --primary-text-on-bg: #1A73E8;  /* active 项文字色 */

    /* sidebar 菜单项默认色（连板天梯实测：#5F6368 Google Gray 700） */
    --sidebar-item-color: #5F6368;
    --sidebar-item-hover-bg: rgba(60, 64, 67, 0.08);  /* Google Gray hover */
    --sidebar-group-title-color: #80868B;              /* 实测 128,134,139 */

    --danger: #DC2626;
    --danger-hover: #B91C1C;
    --warning: #F59E0B;
    --success: #10B981;
    --info: #3B82F6;
    --info-alt: #5B8FF9;  /* 信息蓝辅助（图表/连线，避与 primary 撞色） */

    /* 股市语义色：红涨绿跌（中国惯例，连板天梯主红） */
    --up: #FF2442;
    --up-bg: rgba(255, 36, 66, 0.1);
    --down: #00B366;
    --down-bg: rgba(0, 179, 102, 0.1);
    --neutral: #8B95A1;

    /* 强调 active（Tab/重点，§1.4）—— 替代原 var(--accent,#f59e0b) 硬兜底 */
    --accent: var(--danger);

    /* 分类色板 qualitative（§1.8）：只用于概念/题材类目区分，禁用于涨跌/强度/状态。
       刻意避开纯红纯绿，不与涨跌实色混淆；超 14 类按 i%14 循环。 */
    --cat-1: #4E79A7;  --cat-2: #6BAED6;  --cat-3: #2171B5;  --cat-4: #F28E2B;
    --cat-5: #E6853A;  --cat-6: #B07AA1;  --cat-7: #9467BD;  --cat-8: #FF9DA7;
    --cat-9: #D37295;  --cat-10: #76B7B2; --cat-11: #1B9E97; --cat-12: #EDC948;
    --cat-13: #BAB0AC; --cat-14: #9C755F;

    /* 圆角：连板天梯紧凑风格 */
    --radius: 4px;
    --radius-sm: 2px;
    --radius-pill: 999px;

    /* 阴影：克制 */
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);

/* 字号：默认 16（连板天梯 body=16），UI 控件 14 */
--font-size-xs: 11px;
--font-size-sm: 12px;
--font-size-base: 14px;   /* UI 控件、表格 */
--font-size-body: 16px;   /* 正文（连板天梯 body 默认） */
--font-size-lg: 18px;
--font-size-xl: 20px;
--font-size-2xl: 22px;

    /* 过渡 */
    --transition-fast: 120ms ease;
    --transition-normal: 200ms ease;

    /* 兼容字段（旧样式仍引用） */
    --nav-height: 64px;
    --max-width: 100%;  /* 不再限制最大宽度，连板天梯是全宽布局 */

    color-scheme: light;
}

/* ------------------------------------------------------------------
   深色主题：连板天梯暗色（量化终端）
   ------------------------------------------------------------------ */
[data-theme="dark"] {
    --bg: #0F1419;
    --surface: #1A1F26;
    --surface-2: #232932;
    --surface-hover: #2D3340;
    --surface-3: rgba(251, 191, 36, 0.08);
    --border: #2D3340;
    --border-light: #232932;

    --text: #E6EDF3;
    --text-secondary: #B0B8C4;
    --text-muted: #6B7785;

    --primary: #4F9EF8;
    --primary-hover: #66AAF9;
    --primary-bg: rgba(79, 158, 248, 0.16);
    --primary-border: rgba(79, 158, 248, 0.3);
    --primary-text-on-bg: #93C5FD;

    --sidebar-item-color: #9AA7B4;
    --sidebar-item-hover-bg: rgba(154, 167, 180, 0.12);
    --sidebar-group-title-color: #6B7785;

    --danger: #F85149;
    --danger-hover: #FF6B5C;
    --warning: #FBBF24;
    --success: #34D399;
    --info: #60A5FA;
    --info-alt: #7CA8F7;  /* 信息蓝辅助（图表/连线） */

    --up: #FF4D6A;
    --up-bg: rgba(255, 77, 106, 0.16);
    --down: #2EE08C;
    --down-bg: rgba(46, 224, 140, 0.16);
    --neutral: #6B7785;

    --accent: var(--danger);

    /* 分类色板（暗色提亮 + 降饱和保可读） */
    --cat-1: #6B93C4;  --cat-2: #85C3E8;  --cat-3: #4A93D4;  --cat-4: #F5A85E;
    --cat-5: #EFA05E;  --cat-6: #C99BBC;  --cat-7: #B08FD6;  --cat-8: #FFB3BB;
    --cat-9: #E293B2;  --cat-10: #93CFCA; --cat-11: #3CC0B8; --cat-12: #F2D66E;
    --cat-13: #C9C2BE; --cat-14: #B8956F;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);

    color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Google Sans", "Product Sans", -apple-system, BlinkMacSystemFont, Roboto, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: var(--font-size-body);
    min-height: 100vh;
    transition: background var(--transition-fast), color var(--transition-fast);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; opacity: 0.85; }

/* ======================================================================
   顶部 navbar（h=64, fixed）
   ====================================================================== */
.qt-navbar {
    height: var(--navbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    /* navbar 内容直接从左边开始：toggle + logo + page-title，
       sidebar 不再从 navbar 下方"让位"出来——sidebar 是 fixed 的，自己覆盖在 navbar 左下方。
       小屏（移动端）下 sidebar 收起后也不需要调整。 */
    padding-left: 16px;
    padding-right: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

body.qt-sidebar-collapsed .qt-navbar {
    padding-left: 16px;
}

.qt-navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    flex: 1;
}

.qt-sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.qt-sidebar-toggle:hover { background: var(--surface-hover); color: var(--text); }
.qt-sidebar-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* logo：navbar 左上角 + sidebar 顶部（已存在），随主题切换颜色（currentColor） */
.qt-navbar-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    text-decoration: none;
    padding: 4px 8px;
    margin-left: -4px;
    border-radius: var(--radius);
    transition: color var(--transition-fast), background var(--transition-fast);
    flex-shrink: 0;
}
.qt-navbar-logo:hover {
    color: var(--primary);
    background: var(--primary-bg);
    text-decoration: none;
}
.qt-navbar-logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--primary);
    flex-shrink: 0;
}
.qt-navbar-logo-text {
    font-family: "Google Sans", "Product Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.2px;
    white-space: nowrap;
    color: inherit;
}

/* logo 已移到 sidebar 顶部 + navbar 左上角 */
.qt-logo { display: none; }

.qt-page-title {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0;
    border-left: none;
}

/* navbar 页标题插槽（nav_page block）：页标题 + 副标题上提到顶栏，省内容区垂直空间 */
.qt-nav-page {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;           /* 允许收缩，触发副标题 ellipsis */
    overflow: hidden;
}
.qt-nav-page-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
}
.qt-nav-page-sub {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.qt-navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.qt-theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.qt-theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}
.qt-theme-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.qt-icon-moon { display: inline; }
.qt-icon-sun { display: none; }
[data-theme="dark"] .qt-icon-moon { display: none; }
[data-theme="dark"] .qt-icon-sun { display: inline; }

/* 用户菜单 */
.qt-user-menu { position: relative; }
.qt-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--up);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: filter var(--transition-fast);
}
.qt-user-avatar:hover { filter: brightness(1.1); }
.qt-user-avatar:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.qt-user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 150;
    overflow: hidden;
    padding: 4px 0;
}
.qt-user-dropdown.qt-open { display: block; }
.qt-user-info { padding: 10px 14px; }
.qt-user-name {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--text);
}
.qt-user-tier {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-top: 2px;
}
.qt-dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}
.qt-user-dropdown a,
.qt-user-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 14px;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: var(--font-size-base);
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: background var(--transition-fast);
}
.qt-user-dropdown a:hover,
.qt-user-dropdown button:hover {
    background: var(--surface-hover);
}
.qt-user-dropdown .qt-logout {
    color: var(--danger);
}

.qt-login-link {
    display: inline-flex;
    align-items: center;
    padding: 7px 16px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    font-size: var(--font-size-base);
    text-decoration: none;
    transition: background var(--transition-fast);
}
.qt-login-link:hover { background: var(--primary-hover); }

/* 会员升级入口（navbar 右侧，主题切换按钮左侧） */
.qt-membership-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--warning), var(--danger));
    color: #fff;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
}
.qt-membership-link:hover {
    color: #fff;
    text-decoration: none;
    opacity: 0.9;
    transform: translateY(-1px);
}
.qt-membership-link svg { flex-shrink: 0; }

/* ======================================================================
   会员权益页（/membership）
   ====================================================================== */
.membership-wrap {
    max-width: 760px;
    margin: 32px auto;
    padding: 0 16px;
}
.membership-card {
    padding: 32px 28px;
}
.membership-head {
    text-align: center;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.membership-head h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}
.membership-sub {
    color: var(--text-secondary);
    font-size: 14px;
}
.membership-features {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}
.feature-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--surface-2);
}
.feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--down-bg);
    color: var(--success);
    flex-shrink: 0;
}
.feature-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.feature-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.membership-cta {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(239, 68, 68, 0.06));
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.membership-cta-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}
.membership-qr {
    display: inline-block;
    padding: 12px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 12px;
}
.membership-qr img {
    display: block;
    width: 200px;
    height: 200px;
    object-fit: contain;
}
.qr-placeholder {
    width: 200px;
    height: 200px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}
.qr-placeholder code {
    display: inline-block;
    padding: 2px 6px;
    background: var(--surface-2);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}
.membership-note {
    font-size: 12px;
    color: var(--text-muted);
}

/* ======================================================================
   微信二维码更新页（/admin/wechat-qr）
   ====================================================================== */
.qr-intro {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}
.qr-intro strong { color: var(--text); }
.qr-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
}
.qr-current-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
/* 当前展示复用 .membership-qr（与会员页区块一致），仅在此居中显示 */
.qr-current {
    text-align: center;
}
.qr-updated {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}
.qr-upload .qr-current-label { margin-bottom: 8px; }

/* 上传体容器：dropzone 与 selected 互斥切换 */
.qr-upload-body {
    position: relative;
}
.qr-dropzone {
    display: block;
    border: 1.5px dashed var(--border-strong, var(--border));
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    outline: none;
}
.qr-dropzone:hover,
.qr-dropzone:focus-visible,
.qr-dropzone.dragover {
    border-color: var(--accent);
    background: var(--surface-3, rgba(245, 158, 11, 0.06));
}
.qr-dropzone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 13px;
}
.qr-dropzone-inner small { font-size: 11px; color: var(--text-muted); }

/* 已选择状态：缩略图 + 文件信息 + 重新选择（紧凑横排） */
.qr-selected {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}
.qr-selected-thumb {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
}
.qr-selected-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.qr-selected-info {
    flex: 1;
    min-width: 0;
}
.qr-filename {
    font-size: 13px;
    color: var(--text-secondary);
    word-break: break-all;
    margin-bottom: 4px;
}
.qr-uploading { margin-left: 10px; font-size: 13px; color: var(--text-muted); }

/* ======================================================================
   左 sidebar（w=200, fixed）—— 展开 200 / 折叠成 48px 图标列
   ====================================================================== */
.qt-sidebar {
    width: var(--sidebar-width);
    background: var(--bg);
    border-right: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 90;
    overflow-x: hidden;
    overflow-y: auto;
    transition: width var(--transition-normal);
    /* 默认隐藏滚动条（消除常驻竖带）；Firefox / 旧 Edge */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* sidebar 滚动条：默认零宽（无竖带），鼠标移入侧栏才显 6px 细条可拖拽 */
.qt-sidebar::-webkit-scrollbar {
    width: 0;
    height: 0;
    background: transparent;
}
.qt-sidebar:hover {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.qt-sidebar:hover::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.qt-sidebar:hover::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.qt-sidebar:hover::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 折叠态：宽度变 48px，只保留图标列（不是彻底消失） */
body.qt-sidebar-collapsed .qt-sidebar {
    width: 48px;
}

.qt-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 85;
    display: block;
}
.qt-sidebar-overlay[hidden] { display: none; }

/* 折叠态：隐藏文字、分组标题、logo 文字、版本号；菜单项只留图标居中 */
body.qt-sidebar-collapsed .qt-sidebar-logo-text,
body.qt-sidebar-collapsed .qt-sidebar-title,
body.qt-sidebar-collapsed .qt-sidebar-item-text,
body.qt-sidebar-collapsed .qt-sidebar-foot {
    display: none;
}
body.qt-sidebar-collapsed .qt-sidebar-logo {
    justify-content: center;
    padding: 0;
}
body.qt-sidebar-collapsed .qt-sidebar-item {
    justify-content: center;
    padding: 10px 0;
    margin: 2px 6px;
}
body.qt-sidebar-collapsed .qt-sidebar-item-icon {
    margin-right: 0;
}
body.qt-sidebar-collapsed .qt-live-dot {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}
body.qt-sidebar-collapsed .qt-sidebar-item {
    position: relative;
}

/* logo：sidebar 顶部，与 navbar 高度对齐（h=64） */
.qt-sidebar-logo {
    display: flex;
    align-items: center;
    height: var(--navbar-height);
    padding: 0 16px 0 24px;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color var(--transition-fast);
}
.qt-sidebar-logo:hover { color: var(--primary); text-decoration: none; }
.qt-sidebar-logo-text {
    font-family: "Google Sans", "Product Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qt-sidebar-inner {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--navbar-height));
}

.qt-sidebar-nav {
    flex: 1;
    padding: 8px 0 16px;
}

.qt-sidebar-group {
    margin-bottom: 8px;
}

/* 分组标题：11px/500/灰色/uppercase/letter-spacing 0.6（对齐连板天梯） */
.qt-sidebar-title {
    font-family: "Google Sans", -apple-system, sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: var(--sidebar-group-title-color);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 14px 14px 6px;
    line-height: 1.4;
}

.qt-sidebar-list {
    list-style: none;
}

/* 菜单项：连板天梯对齐
   - h≈36（padding 8 上下）
   - padding 8px 14px
   - font 14/400（不是 16，更紧凑）
   - border-radius 8px
   - margin 2 8
   - hover/active 切换 bg + color
*/
.qt-sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin: 2px 6px;
    border-radius: var(--radius);
    color: var(--sidebar-item-color);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    border: none;
    transition: background var(--transition-fast), color var(--transition-fast);
    cursor: pointer;
}

.qt-sidebar-item:hover {
    background: var(--sidebar-item-hover-bg);
    color: var(--text);
    text-decoration: none;
}
.qt-sidebar-item.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 500;
}
.qt-sidebar-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.qt-sidebar-item-text { flex: 1; }
.qt-sidebar-item-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: 10px;
    flex-shrink: 0;
    color: inherit;
}
.qt-sidebar-item-icon svg { width: 16px; height: 16px; display: block; }
.qt-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--up);
    flex-shrink: 0;
    animation: qt-pulse 1.6s infinite;
}
@keyframes qt-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
/* 交易时段外：隐藏 sidebar 实时红点（body.qt-market-closed 由 base.html 同步脚本 +
   dashboard.js 轮询 /api/intraday-window 共同维护，复用后端 in_intraday_window 单一真相源） */
.qt-market-closed .qt-live-dot { display: none; }
/* 竞价窗口外：仅隐藏竞价分析 tab 红点（body.qt-auction-closed 由 base.html 同步脚本 +
   dashboard.js 轮询维护，复用后端 in_auction_window；连续竞价期间竞价数据已定型，红点熄灭） */
.qt-auction-closed .qt-live-dot-auction { display: none; }

.qt-sidebar-foot {
    padding: 12px 14px;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: auto;
}

/* ======================================================================
   主内容区（margin-left: 200 展开 / 48 折叠 / 0 未登录）
   ====================================================================== */
.qt-main {
    margin-left: var(--sidebar-width);
    padding-top: var(--navbar-height);
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

/* 折叠态：sidebar 缩到 48px，主区也让 48px（不再是 0） */
body.qt-sidebar-collapsed .qt-main {
    margin-left: 48px;
}

/* 未登录态：完全无 sidebar */
.qt-main-full {
    margin-left: 0;
}

/* ======================================================================
   兼容旧样式（保持现有页面无需改动模板）
   ====================================================================== */

/* 旧 navbar 隐藏（被 qt-navbar 替代） */
.navbar { display: none; }

/* 旧 .container 现在是 qt-main 内的内容容器 */
.container {
    max-width: 100%;
    margin: 0;
    padding: var(--content-padding);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}
.card-header h2 { font-size: var(--font-size-lg); font-weight: 600; }
.card-header .card-actions { display: flex; gap: 8px; }

/* 网格 */
.grid {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) {
    .grid-2, .grid-4 { grid-template-columns: 1fr; }
}

/* ======================================================================
   表单
   ====================================================================== */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: var(--font-size-base);
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-group input:disabled { opacity: 0.5; cursor: not-allowed; }

/* 按钮 */
.btn {
    display: inline-block;
    padding: 7px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: var(--font-size-base);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--text-secondary); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: var(--font-size-sm); }

/* ======================================================================
   登录页
   ====================================================================== */
.login-wrap {
    max-width: 380px;
    margin: 80px auto 0;
}
.login-card { padding: 32px; }
.login-card h1 {
    text-align: center;
    margin-bottom: 24px;
    font-size: var(--font-size-2xl);
    font-weight: 700;
}
.login-card .form-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}
.login-card .btn-primary { width: 100%; padding: 10px; }
.login-card .guest-btn {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
    text-align: center;
    font-size: var(--font-size-sm);
    padding: 8px;
}
.login-card .guest-btn:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text);
}

/* ======================================================================
   提示信息
   ====================================================================== */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: var(--font-size-sm);
    border: 1px solid;
}
.alert-error { background: var(--up-bg); border-color: var(--danger); color: var(--danger); }
.alert-success { background: var(--down-bg); border-color: var(--success); color: var(--success); }
.alert-warning { background: rgba(245, 158, 11, 0.1); border-color: var(--warning); color: var(--warning); }
.alert-info { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); }

/* ======================================================================
   表格
   ====================================================================== */
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}
.data-table th,
.data-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
/* 表头 sticky 浮在 navbar 下方（Excel 冻结首行），所有 .data-table 通用。
   ⚠️ 要求 table 到视口之间无 overflow!=visible 的祖先，否则该祖先成为 sticky
   滚动容器（即使垂直不滚动）、垂直 sticky 失效——宽表不要用 overflow-x:auto 包裹，
   水平滚动交给 body。各页 .panel 默认无 overflow，符合约束。 */
.data-table th {
    color: var(--text-secondary);
    font-weight: 500;
    background: var(--surface-2);
    position: sticky;
    top: var(--navbar-height);   /* 避开 fixed navbar 遮挡 */
    z-index: 5;                  /* 压在 tbody 之上、navbar(100) 之下 */
}
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .actions { display: flex; gap: 6px; }
/* RPS 板块表：板块名可点击 → 联动右侧成分股卡片 */
.board-link { cursor: pointer; color: var(--primary); text-decoration: none; font-weight: 600; }
.board-link:hover { text-decoration: underline; }

/* 竞价表 17 列紧凑布局 */
table.auction-table {
    font-size: var(--font-size-xs);
    table-layout: auto;
    white-space: nowrap;
}
.auction-table th, .auction-table td { padding: 6px 8px; text-align: right; }
.auction-table th:first-child,
.auction-table td:first-child { text-align: center; }
.auction-table .col-name,
.auction-table .concept,
.auction-table .concept-analysis { text-align: left; }
.auction-table .col-seq      { width: 32px; color: var(--text-secondary); }
.auction-table .col-name     { min-width: 70px; font-weight: 600; }
.auction-table .col-limit    { width: 44px; text-align: center; }
.auction-table .col-rank     { width: 42px; color: var(--text-secondary); }
.auction-table .col-pct      { min-width: 58px; font-variant-numeric: tabular-nums; }
.auction-table .col-price    { min-width: 56px; font-variant-numeric: tabular-nums; }
.auction-table .col-diff     { min-width: 56px; font-variant-numeric: tabular-nums; }
.auction-table .col-seal     { min-width: 64px; font-variant-numeric: tabular-nums; }
.auction-table .col-auction   { min-width: 64px; font-variant-numeric: tabular-nums; }
.auction-table .col-prev-bid { min-width: 64px; font-variant-numeric: tabular-nums; }
.auction-table .col-diff-amt  { min-width: 60px; font-variant-numeric: tabular-nums; }
.auction-table .col-dev      { width: 60px; color: var(--text-secondary); }
.auction-table .concept,
.auction-table .concept-analysis { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

/* —— 可点击表头排序 —— */
.auction-table th.sortable {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: color .12s ease;
}
.auction-table th.sortable:hover { color: var(--primary); }
.auction-table th.sortable::after {
    content: "\2195"; /* ↕ 可排序提示，未激活时淡显 */
    margin-left: 2px;
    font-size: 9px;
    opacity: .35;
}
.auction-table th.sorted-asc::after { content: "\25B2"; opacity: 1; color: var(--primary); }
.auction-table th.sorted-desc::after { content: "\25BC"; opacity: 1; color: var(--primary); }

/* —— 通用 data-table 可点击表头排序（板块轮动等）—— 与 auction 风格一致 */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: color .12s ease;
}
.data-table th.sortable:hover { color: var(--primary); }
.data-table th.sortable::after {
    content: "\2195"; /* ↕ 可排序提示，未激活时淡显 */
    margin-left: 2px;
    font-size: 9px;
    opacity: .35;
}
.data-table th.sorted-asc::after { content: "\25B2"; opacity: 1; color: var(--primary); }
.data-table th.sorted-desc::after { content: "\25BC"; opacity: 1; color: var(--primary); }

/* —— quantplay 风格实色填充（整格背景 + 白字）—— */
/* 涨跌幅实色块（§1.7 幅度分级）：涨停满色，普通涨/跌同 token 明度分级 */
.cell-up { background: color-mix(in srgb, var(--up) 72%, var(--bg)); color: #fff; font-weight: 600; }
.cell-up-max { background: var(--up); color: #fff; font-weight: 700; }
.cell-down { background: color-mix(in srgb, var(--down) 72%, var(--bg)); color: #fff; font-weight: 600; }
.cell-flat { background: var(--surface-2); color: var(--text-secondary); }
/* 竞价额色阶（§1.7 封单强度）：小→蓝 中→橙 大→红 极大→深红 */
.seal-blue { background: var(--info-alt); color: #fff; font-weight: 600; }
.seal-orange { background: var(--warning); color: #fff; font-weight: 600; }
.seal-red { background: var(--up); color: #fff; font-weight: 600; }
.seal-max { background: color-mix(in srgb, var(--up) 85%, #000); color: #fff; font-weight: 700; }
/* 委买额涨跌阶梯（§1.7 bid 八档）：涨红/跌绿 × 委买额强度 4 档。
   浅档（1/2）浅底 + 实色字保对比度，深档（3/max）白字。 */
.bid-up-1 { background: color-mix(in srgb, var(--up) 28%, var(--bg)); color: var(--up); }
.bid-up-2 { background: color-mix(in srgb, var(--up) 55%, var(--bg)); color: #fff; font-weight: 600; }
.bid-up-3 { background: var(--up); color: #fff; font-weight: 600; }
.bid-up-max { background: color-mix(in srgb, var(--up) 85%, #000); color: #fff; font-weight: 700; }
.bid-down-1 { background: color-mix(in srgb, var(--down) 28%, var(--bg)); color: var(--down); }
.bid-down-2 { background: color-mix(in srgb, var(--down) 55%, var(--bg)); color: #fff; font-weight: 600; }
.bid-down-3 { background: var(--down); color: #fff; font-weight: 600; }
.bid-down-max { background: color-mix(in srgb, var(--down) 85%, #000); color: #fff; font-weight: 700; }
/* 深色主题：浅档（1/2）底随 --bg 变深、对比度不足，单独给更高浓度底 + 浅字（§1.7 注） */
[data-theme="dark"] .bid-up-1 { background: color-mix(in srgb, var(--up) 45%, var(--bg)); color: color-mix(in srgb, var(--up) 60%, #fff); }
[data-theme="dark"] .bid-up-2 { background: color-mix(in srgb, var(--up) 55%, var(--bg)); color: #fff; }
[data-theme="dark"] .bid-down-1 { background: color-mix(in srgb, var(--down) 45%, var(--bg)); color: color-mix(in srgb, var(--down) 60%, #fff); }
[data-theme="dark"] .bid-down-2 { background: color-mix(in srgb, var(--down) 55%, var(--bg)); color: #fff; }
/* 排名色：前三红、4-100 蓝 */
.rank-hot { background: var(--up); color: #fff; }
.rank-cold { background: var(--info-alt); color: #fff; }
/* 概念 tag */
.tag-blue { background: var(--info-alt); color: #fff; }
.tag-orange { background: var(--warning); color: #fff; }
.tag-green { background: var(--down); color: #fff; }
/* 竞价概念分组：同「首个概念」统一配色（左侧色条 + 浅底），cat-N 类驱动 --cg（§1.8）。
   --cat-* 双主题，深浅自动跟随；刻意避开纯红/纯绿，不与涨跌实色混淆。 */
.auction-table td.concept.cat-1 { --cg: var(--cat-1); }
.auction-table td.concept.cat-2 { --cg: var(--cat-2); }
.auction-table td.concept.cat-3 { --cg: var(--cat-3); }
.auction-table td.concept.cat-4 { --cg: var(--cat-4); }
.auction-table td.concept.cat-5 { --cg: var(--cat-5); }
.auction-table td.concept.cat-6 { --cg: var(--cat-6); }
.auction-table td.concept.cat-7 { --cg: var(--cat-7); }
.auction-table td.concept.cat-8 { --cg: var(--cat-8); }
.auction-table td.concept.cat-9 { --cg: var(--cat-9); }
.auction-table td.concept.cat-10 { --cg: var(--cat-10); }
.auction-table td.concept.cat-11 { --cg: var(--cat-11); }
.auction-table td.concept.cat-12 { --cg: var(--cat-12); }
.auction-table td.concept.cat-13 { --cg: var(--cat-13); }
.auction-table td.concept.cat-14 { --cg: var(--cat-14); }
.auction-table td.concept { border-left: 3px solid var(--cg, transparent); }
.auction-table td.concept.has-grp {
    background: color-mix(in srgb, var(--cg) 13%, transparent);
}
.auction-table td.concept .lead { font-weight: 600; }
.auction-table td.concept .sub { color: var(--text-secondary); font-weight: 400; }
.auction-table td.concept[data-attribution] { cursor: help; }
/* 偏离值：正偏红（≥20 加深）/ 负偏绿（文字色，不加底） */
.dev-pos { color: var(--up); font-weight: 600; }
.dev-pos-strong { color: color-mix(in srgb, var(--up) 85%, #000); font-weight: 700; }
.dev-neg { color: var(--down); font-weight: 600; }
/* 斑马纹 */
.auction-table tbody tr:nth-child(even) { background: var(--surface-2); }
.auction-table tbody tr:hover { background: var(--surface-hover); }
.auction-table td { font-variant-numeric: tabular-nums; }
/* 品牌标签栏 + 状态栏（统一全站主色蓝，§1.7 结构装饰色收敛） */
.auction-brand-tab {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: var(--font-size-sm);
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
/* 竞价顶部工具行（一行三区）：[日期 tab | 状态条(居中自适应) | 数据逻辑面板] */
.auction-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 2px 0 8px;
    min-height: 32px;       /* fragment 未加载前占位，防布局跳动 */
}
.auction-topbar-main {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;        /* 窄屏状态条折到 tab 下方，不挤压 */
    row-gap: 4px;
}
/* 多日日期 tab（最新在前，左→右新→旧） */
.auction-date-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.auction-date-tab {
    cursor: pointer;
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s, color 0.15s;
}
.auction-date-tab:hover { background: var(--surface-hover); color: var(--text); }
.auction-date-tab.active {
    background: var(--primary);
    color: #fff;
}
.auction-date-tab .today-mark {
    font-size: 10px;
    background: color-mix(in srgb, #fff 25%, transparent);
    padding: 1px 5px;
    border-radius: var(--radius-pill);
}
.auction-status-bar {
    display: flex;
    justify-content: center;  /* 在 tab 与逻辑面板之间的自适应区居中 */
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
    gap: 4px 16px;
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    white-space: nowrap;
}

/* ==================================================================
   竞价分析「数据展示逻辑」折叠面板（顶部工具行右端，下拉浮层）
   折叠态：极简一行「竞价分析数据逻辑」+ chevron，与日期 tab 同行右置
   展开态：absolute 下拉卡片（不顶开表格、不改变工具行高度）
   ================================================================== */
.auction-logic {
    position: relative;     /* 下拉浮层定位锚 */
    flex-shrink: 0;
    margin-left: auto;      /* 工具行内靠右 */
}

/* ---- 折叠行（原生 <summary>，点击展开由浏览器处理，不依赖 JS）---- */
.auction-logic-toggle {
    display: flex; align-items: center; gap: 6px;
    box-sizing: border-box;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 6px 10px;
    font-family: inherit; font-size: var(--font-size-xs); text-align: left;
    list-style: none;            /* 隐藏原生三角 */
    white-space: nowrap;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}
.auction-logic-toggle::-webkit-details-marker { display: none; }
.auction-logic-toggle:hover { color: var(--text-secondary); border-color: var(--text-muted); }
.auction-logic[open] .auction-logic-toggle { color: var(--text-secondary); border-color: var(--text-muted); }
.auction-logic-icon { opacity: .55; transition: opacity var(--transition-fast); pointer-events: none; }
.auction-logic-toggle:hover .auction-logic-icon { opacity: 1; }
.auction-logic-chevron {
    margin-left: 2px;
    width: 0; height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform var(--transition-normal);
    pointer-events: none;
}
.auction-logic[open] .auction-logic-chevron { transform: rotate(-90deg); }

/* ---- 展开体：右对齐下拉浮层（z-index 压过表格，不挤布局）---- */
.auction-logic-body {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: min(720px, calc(100vw - 48px));
    max-height: 72vh;
    overflow: auto;
    z-index: 60;
    padding: 14px 16px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    line-height: 1.65;
}
.auction-logic[open] .auction-logic-body { display: block; }

/* 分区标题 */
.al-section   { margin-bottom: 13px; }
.al-section:last-child { margin-bottom: 0; }
.al-hd        { display: inline-flex; align-items: center; gap: 5px;
                font-size: var(--font-size-xs); font-weight: 600;
                color: var(--primary); margin-bottom: 6px; letter-spacing: .02em; }
.al-p         { margin: 0; padding: 0; }

/* 列定义小表 */
.al-defs      { width: 100%; border-collapse: collapse; font-size: var(--font-size-xs); }
.al-defs td   { padding: 3px 0; vertical-align: top; }
.al-k         { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums;
                white-space: nowrap; width: 140px; padding-right: 12px; }
.al-defs td:last-child { color: var(--text-secondary); }

/* 双栏（展示规则 | 色阶排序） */
.al-row       { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.al-half      { min-width: 0; }
.al-dl        { margin: 2px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; row-gap: 4px; }
.al-dl dt     { color: var(--text); font-weight: 600; white-space: nowrap; font-size: var(--font-size-xs); }
.al-dl dd     { color: var(--text-secondary); margin: 0; }

/* ======================================================================
   徽章 / 标签
   ====================================================================== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: var(--font-size-sm);
    font-weight: 500;
}
.badge-up { background: var(--up-bg); color: var(--up); }
.badge-down { background: var(--down-bg); color: var(--down); }
.badge-neutral { background: rgba(107, 119, 133, 0.15); color: var(--neutral); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-guest { background: var(--primary-bg); color: var(--primary); }

/* ======================================================================
   监控指标
   ====================================================================== */
.metric {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--font-size-sm);
}
.metric:last-child { border-bottom: none; }
.metric-label { color: var(--text-secondary); }
.metric-value { color: var(--text); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.metric-sub { font-size: 11px; color: var(--text-muted); margin-left: 6px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

.progress {
    height: 6px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-top: 4px;
}
.progress-bar {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}
.progress-bar.warn { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

.stat-big {
    font-size: 24px;
    font-weight: 700;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.stat-label { color: var(--text-muted); font-size: var(--font-size-sm); }

/* ======================================================================
   弹窗（模态框）
   ====================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    width: 90%;
    max-width: 460px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.modal h3 { margin-bottom: 16px; font-size: var(--font-size-lg); }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ======================================================================
   htmx 加载指示
   ====================================================================== */
.htmx-indicator { display: none; opacity: 0.7; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline; }
.htmx-swapping { opacity: 0; transition: opacity 0.2s; }

.empty-hint { color: var(--text-muted); text-align: center; padding: 20px; font-size: var(--font-size-sm); }
.loading-hint { color: var(--text-muted); padding: 8px 0; font-size: var(--font-size-sm); }

/* 国际股市子 tab（美股 / 日股）切换 */
.int-tabs { display: flex; gap: 8px; margin: 4px 0 16px; }
.int-tab {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    padding: 6px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.int-tab:hover { color: var(--text); border-color: var(--primary); }
.int-tab.active {
    color: var(--primary);
    background: var(--primary-bg);
    border-color: var(--primary);
}

/* 韩股：数据更新策略条（刷新状态 + 实时倒计时，dashboard.js 驱动） */
.kr-refresh-bar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: var(--font-size-sm);
}
.kr-refresh-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.kr-refresh-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text);
}
.kr-refresh-sub {
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex: none;
}
.dot-live {
    background: var(--success);
    animation: krPulse 1.6s infinite;
}
.dot-off {
    background: var(--text-muted);
}
@keyframes krPulse {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.35); }
    70%  { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ======================================================================
   看盘页面布局（兼容 market_base.html）
   旧的顶部 top-tabs 和左 market-sidebar 都隐藏，由 qt-sidebar 替代
   ====================================================================== */

/* 顶栏一级分类（旧）隐藏 */
.top-tabs { display: none !important; }

/* 看盘布局：旧 market-layout 改为单列（左侧 sidebar 已被 qt-sidebar 取代） */
.market-layout {
    display: block;
    padding: var(--content-padding);
}

/* 旧的 market-sidebar 隐藏（被 qt-sidebar 替代） */
.market-sidebar { display: none !important; }

.market-main {
    padding: 0;
}

.page-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.crumb { font-size: var(--font-size-sm); color: var(--text-muted); }
.warn-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    font-size: var(--font-size-xs);
    color: #e8a33d;
    background: rgba(232, 163, 61, 0.12);
    border: 1px solid rgba(232, 163, 61, 0.4);
    border-radius: var(--radius-pill);
    padding: 2px 8px;
}
.live-bar,
.demo-bar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-xs);
    padding: 3px 8px;
    border-radius: var(--radius-pill);
}
.live-bar { color: var(--up); background: var(--up-bg); }
.live-bar::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--up);
    animation: pulse 1.6s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
.demo-bar { color: var(--warning); background: rgba(245, 158, 11, 0.1); }

/* 管理员「刷新」按钮：仅 admin 渲染（模板 nav_role 门控）。小号主色调药丸，
   与 live-bar 同高、视觉低噪；点 [data-refresh-key] → POST /internal/refresh → 重载片段。 */
.admin-refresh-btn {
    display: inline-flex;
    align-items: center;
    font-size: var(--font-size-xs);
    padding: 3px 12px;
    border: 1px solid var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: var(--radius-pill);
    cursor: pointer;
    line-height: 1.6;
    transition: filter .15s, opacity .15s;
}
.admin-refresh-btn:hover:not(:disabled) { filter: brightness(1.08); }
.admin-refresh-btn:disabled { cursor: progress; opacity: .7; }
.admin-refresh-btn.admin-refreshed { border-color: var(--up); color: var(--up); background: var(--up-bg); }
/* new_high 顶部独立工具行（无现成 info bar 可挂） */
.admin-refresh-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 0 10px;
    font-size: var(--font-size-xs);
    color: var(--text-muted, var(--text-secondary));
}

/* 数据时效标识徽标：实时 vs T+1（宽基资金等页面标注面板数据性质，红=实时 / 灰=T+1） */
.dt-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    line-height: 1.5;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
    vertical-align: middle;
    letter-spacing: .2px;
}
.dt-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex: none;
}
/* 实时：红 + 脉冲点 */
.dt-badge.dt-live {
    color: var(--up);
    background: var(--up-bg);
    border: 1px solid rgba(255, 36, 66, 0.4);
}
.dt-badge.dt-live::before {
    background: var(--up);
    animation: pulse 1.6s infinite;
}
/* T+1：muted 灰调（盘后/冷数据，color-mix 自适应明暗主题） */
.dt-badge.dt-t1 {
    color: var(--text-muted);
    background: color-mix(in srgb, var(--text-muted) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--text-muted) 35%, transparent);
}
.dt-badge.dt-t1::before { background: var(--text-muted); }
/* 采集异常/部分失败：警告橙 */
.dt-badge.dt-warn {
    color: var(--warning);
    background: color-mix(in srgb, var(--warning) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
}
.dt-badge.dt-warn::before { background: var(--warning); }
@media (prefers-reduced-motion: reduce) {
    .dt-badge.dt-live::before { animation: none; }
}
/* 短线周期页：数据时效图例（实时 vs T+1），复刻宽基资金页图例风格 */
.cyc-dt-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0 14px;
    padding: 7px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--text-muted);
    flex-wrap: wrap;
    line-height: 1.5;
}
.cyc-dt-legend .cyc-dt-sep {
    width: 1px;
    height: 14px;
    background: var(--border);
    margin: 0 4px;
}
/* ETF 表格内「代码/名称」外链（东财 ETF 详情页），实时卡与套利预警卡共用 */
.etf-rt-crawl-link { color: var(--info); text-decoration: none; border-bottom: 1px dotted color-mix(in srgb, var(--info) 50%, transparent); }
.etf-rt-crawl-link:hover { color: #7AB8FF; border-bottom-style: solid; }
.page-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin: 6px 0 2px;
}
.page-sub {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: 0 0 16px;
}
/* 副标题行：标题左 + admin 操作（刷新按钮）右；无操作时仅标题，视觉无差 */
.page-sub-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 16px;
}
.page-sub-row .page-sub { margin: 0; min-width: 0; }

/* KPI 行（4 列指标卡） */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}
.kpi-label { font-size: var(--font-size-sm); color: var(--text-muted); }
.kpi-val {
    font-size: 22px;
    font-weight: 600;
    margin-top: 4px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.kpi-val.up { color: var(--up); }
.kpi-val.down { color: var(--down); }
.kpi-val.neutral { color: var(--text); }
.kpi-sub { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 2px; }
/* 过热风险 KPI：极性标注（高=风险红 / 低=安全绿 / 中性灰）+ 数据解释 ⓘ */
.kpi-info { position: relative; cursor: help; color: var(--text-muted); margin-left: 4px; font-size: 11px; }
.kpi-info:hover { color: var(--text); }
.kpi-info::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 6px;
  width: 300px;
  max-width: 78vw;
  white-space: pre-line;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  font-size: var(--font-size-xs);
  font-weight: 400;
  line-height: 1.55;
  text-align: left;
  padding: 8px 11px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .12s ease, transform .12s ease, visibility .12s;
  z-index: 999;
  pointer-events: none;
}
.kpi-info:hover::after { opacity: 1; visibility: visible; transform: translateY(0); }
.kpi-polarity { font-size: var(--font-size-xs); margin-top: 2px; font-weight: 500; }
.kpi-polarity.risk { color: var(--up); }
.kpi-polarity.safe { color: var(--success); }
.kpi-polarity.neutral { color: var(--text-muted); }
.pm-chart { margin-top: 8px; }

/* 通用面板 */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 12px;
}
.panel-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin: 0 0 10px;
    color: var(--text);
}
/* 短线周期页：题材生命周期榜的「显示未知阶段」过滤（内联于标题右侧） */
.cyc-stage-filter {
    float: right;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}
.cyc-stage-filter input {
    vertical-align: middle;
    margin: -2px 3px 0 0;
    cursor: pointer;
}
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.panel-head .panel-title { margin: 0; }
/* 国际股市/美股：板块标题右侧数据来源说明——复用全站次级文字基调（--text-secondary / sm），与页面统一 */
.panel-source {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    white-space: nowrap;
}

/* 大盘情绪：分时曲线 + 涨幅分布 并排（宽屏两列，窄屏堆叠） */
.mood-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: stretch; /* 两卡片强制等高：图表渲染高度已统一，stretch 保证边框一致 */
    margin-bottom: 12px; /* 与下方 panel 间距，对齐 .panel 自身下边距 */
}
.mood-row-2 > .panel { margin-bottom: 0; } /* 行内间距统一交给 grid gap */
@media (max-width: 900px) {
    .mood-row-2 { grid-template-columns: 1fr; }
}

/* mini chart */
.mini-chart {
    width: 100%;
    height: 200px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 8px;
}

/* 悬停 K 线浮层 */
.kline-pop {
    position: fixed;
    z-index: 9999;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    width: 400px;           /* 分时/日K 两张图等宽对齐 */
    max-width: 90vw;
}
.kline-pop[hidden] { display: none; }
.kline-slot + .kline-slot { margin-top: 4px; }
.kline-label {
    display: block;
    font-size: 11px;
    line-height: 1;
    padding: 2px 4px 3px;
    color: var(--text-muted);
}
.kline-pop img {
    display: block;
    width: 100%;            /* 撑满浮层宽度，分时/日K 等比缩放、等宽 */
    height: auto;
    border: 0;
    border-radius: var(--radius-sm);
}

/* 涨跌归因浮层（悬停「竞价分析」概念列；与 kline-pop 同位 fixed，规避 panel 裁剪） */
.concept-pop {
    position: fixed;
    z-index: 9999;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    width: 240px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.concept-pop[hidden] { display: none; }
.concept-pop .cp-head {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}
.concept-pop .cp-verdict {
    align-self: flex-start;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 4px;
    margin-top: 1px;
    color: #fff;
}
/* verdict 配色：实色加深底 + 白字（color-mix 压暗主题变量，保留明暗自适应 + 白字高对比）。
   板块驱动=蓝 / 多题材共振=紫 / 个股独立逻辑=橙 / 数据缺失=灰 */
.concept-pop .cp-verdict.v-concept_driven {
    background: color-mix(in srgb, var(--cat-3) 72%, #000);
}
.concept-pop .cp-verdict.v-resonance {
    background: color-mix(in srgb, var(--cat-7) 75%, #000);
}
.concept-pop .cp-verdict.v-independent {
    background: color-mix(in srgb, var(--cat-4) 75%, #000);
}
.concept-pop .cp-verdict.v-no_data {
    background: var(--neutral);
}
.concept-pop .cp-row {
    font-size: 12px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.concept-pop .cp-note {
    font-size: 11.5px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-top: 2px;
}

/* RPS 表里股票名字：可悬停看 K 线 */
.stock-name { cursor: pointer; }
.stock-name:hover { text-decoration: underline; }
/* RPS 表里股票代码：去链接后同样可悬停看 K 线 */
.stock-code { cursor: pointer; }
.stock-code:hover { text-decoration: underline; }

/* 排序选择器 */
.sort-bar {
    display: inline-flex;
    gap: 2px;
    background: var(--surface-2);
    padding: 3px;
    border-radius: var(--radius);
}
.sort-bar button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 4px 10px;
    font-size: var(--font-size-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition-fast);
}
.sort-bar button.active {
    background: var(--surface);
    color: var(--text);
    font-weight: 500;
    box-shadow: var(--shadow);
}

/* 涨跌色 */
td.up, span.up, .up { color: var(--up); }
td.down, span.down, .down { color: var(--down); }
span.neutral, td.neutral { color: var(--text-secondary); }

/* 演示数据提示 */
.demo-hint {
    padding: 8px 12px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius);
    color: var(--warning);
    font-size: var(--font-size-sm);
    margin-bottom: 12px;
}

/* 涨停梯队连板徽章 */
.limit-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: #fff;
    margin-right: 4px;
}
/* 连板梯队：板数越高色越深，橙→红→暗红→棕，全走 token + color-mix 派生 */
.limit-2 { background: var(--warning); }
.limit-3 { background: var(--danger); }
.limit-4 { background: var(--danger-hover); }
.limit-5 { background: color-mix(in srgb, var(--danger) 75%, #000); }
.limit-6, .limit-7, .limit-8 { background: color-mix(in srgb, var(--danger) 55%, #000); }


/* ======================================================================
   题材生命周期（短线周期页：主线大卡 / 题材榜 / 节点时间线）
   5 阶段配色（badge + timeline 色块通用）：冰点灰 / 启动蓝 / 发酵橙 / 高潮红 / 退潮绿
   方案 §5；L1 高潮暂沿用红（未另立品红），timeline 色块用更深背景以在密集网格中显眼。
   ====================================================================== */
.tc-stage {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: var(--font-size-sm);
    line-height: 1.5;
    white-space: nowrap;
}
.tc-冰点 { background: color-mix(in srgb, var(--text-muted) 16%, transparent); color: var(--text-muted); }
.tc-启动 { background: color-mix(in srgb, #3b82f6 16%, transparent); color: #3b82f6; }
.tc-发酵 { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.tc-高潮 { background: color-mix(in srgb, var(--up) 18%, transparent); color: var(--up); }
.tc-退潮 { background: color-mix(in srgb, var(--down) 18%, transparent); color: var(--down); }
.tc-未知 { background: transparent; color: var(--text-secondary); }

/* 主线大卡 */
.tc-main-card { padding: 14px 18px; }
.tc-main-head { display: flex; align-items: baseline; gap: 10px; margin: 6px 0; flex-wrap: wrap; }
.tc-main-name { font-size: 20px; font-weight: 700; }
.tc-days { color: var(--text-muted); font-size: var(--font-size-sm); }
.tc-main-metrics {
    display: flex; gap: 18px; flex-wrap: wrap;
    color: var(--text-secondary); font-size: var(--font-size-sm);
}
.tc-main-metrics b { color: var(--text); }
.tc-provisional {
    display: inline-block; margin-left: 6px; padding: 0 6px;
    background: color-mix(in srgb, var(--warning) 20%, transparent);
    color: var(--warning); border-radius: var(--radius-sm); font-size: 12px;
}
.tc-star { color: var(--warning); }
.tc-lead { color: var(--text-muted); font-size: var(--font-size-sm); margin-left: 4px; }
.tc-main-row { background: color-mix(in srgb, var(--up) 6%, transparent); }
.tc-hint { color: var(--text-muted); font-size: var(--font-size-sm); font-weight: 400; }

/* 节点时间线：每行一题材 × 近 N 日色块 */
.tc-timeline { display: flex; flex-direction: column; gap: 3px; max-height: 360px; overflow-y: auto; }
.tc-tl-row { display: flex; align-items: center; gap: 8px; }
.tc-tl-name {
    width: 84px; flex-shrink: 0; font-size: var(--font-size-sm); color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tc-tl-cells { display: flex; gap: 2px; }
.tc-cell { width: 18px; height: 18px; border-radius: var(--radius-sm); display: inline-block; background: var(--surface-2); }
.tc-cell.tc-冰点 { background: color-mix(in srgb, var(--text-muted) 35%, transparent); }
.tc-cell.tc-启动 { background: color-mix(in srgb, #3b82f6 38%, transparent); }
.tc-cell.tc-发酵 { background: color-mix(in srgb, var(--warning) 40%, transparent); }
.tc-cell.tc-高潮 { background: color-mix(in srgb, var(--up) 45%, transparent); }
.tc-cell.tc-退潮 { background: color-mix(in srgb, var(--down) 40%, transparent); }
.tc-cell.tc-未知 { background: var(--surface-2); }
.tc-legend { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ======================================================================
   响应式
   ====================================================================== */

/* 桌面（默认）sidebar 固定，main margin-left: 240 */

/* 平板：sidebar 默认隐藏，需要点 ☰ 展开 */
@media (max-width: 1023px) {
    .qt-navbar {
        padding-left: var(--content-padding);
    }
    .qt-main {
        margin-left: 0;
    }
    /* 移动端：sidebar 真正滑出（overlay 模式），不是图标列 */
    .qt-sidebar {
        width: var(--sidebar-width) !important;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    /* 折叠态显示的文字先恢复（避免被桌面规则隐藏） */
    body.qt-sidebar-collapsed .qt-sidebar-logo-text,
    body.qt-sidebar-collapsed .qt-sidebar-title,
    body.qt-sidebar-collapsed .qt-sidebar-item-text,
    body.qt-sidebar-collapsed .qt-sidebar-foot {
        display: revert;
    }
    body.qt-sidebar-collapsed .qt-sidebar-item {
        justify-content: revert;
        padding: 8px 12px;
        margin: 2px 6px;
    }
    body.qt-sidebar-collapsed .qt-sidebar-logo {
        justify-content: revert;
        padding: 0 16px 0 24px;
    }
    body.qt-sidebar-collapsed .qt-sidebar-item-icon {
        margin-right: 10px;
    }
    body.qt-sidebar-collapsed .qt-sidebar {
        transform: translateX(0);
    }
    body.qt-sidebar-collapsed .qt-sidebar-overlay {
        display: block;
    }
    body.qt-sidebar-collapsed .qt-main {
        margin-left: 0;
    }
}

/* 移动端 */
@media (max-width: 768px) {
    .qt-page-title { display: none; }
    .qt-nav-page-sub { display: none; }   /* navbar 只留页标题，副标题让位 */
    .al-row { grid-template-columns: 1fr; }  /* 逻辑面板双栏 → 单栏 */
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .market-layout { padding: 12px; }
    .qt-navbar { padding: 0 12px; }
    .container { padding: 12px; }
}

/* ======================================================================
   报警记录卡片（系统状态页）
   ====================================================================== */
.alarm-list { display: flex; flex-direction: column; }
.alarm-row {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    border-left: 3px solid var(--border);
}
.alarm-row:last-child { border-bottom: none; }
/* 级别左边框：CRITICAL/ERROR 红、WARNING 橙、INFO 灰 */
.alarm-lvl-critical, .alarm-lvl-error { border-left-color: var(--danger); }
.alarm-lvl-warning { border-left-color: var(--warning); }
.alarm-lvl-info { border-left-color: var(--neutral); }
.alarm-row.resolved { opacity: 0.55; }
.alarm-row-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.alarm-title {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--text);
    word-break: break-all;
}
.alarm-resolved-tag {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.alarm-row-meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.alarm-source { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.alarm-id {
    font-size: 11px;
    color: var(--text-muted);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    white-space: nowrap;
}
.alarm-notified { font-size: 11px; white-space: nowrap; }
.alarm-notified.ok { color: var(--success, #2e9e5b); }
.alarm-notified.warn { color: var(--warning); }
/* 报警明细：展开 detail 字典，等宽字体，超长可滚动，便于排查 */
.alarm-detail {
    margin-top: 6px;
    padding: 6px 8px;
    background: var(--bg-subtle, rgba(127,127,127,0.08));
    border-radius: 6px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 11px;
    line-height: 1.55;
    max-height: 180px;
    overflow: auto;
}
.alarm-detail-row { display: flex; gap: 8px; }
.alarm-detail-key {
    flex: 0 0 110px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.alarm-detail-val {
    flex: 1;
    color: var(--text);
    word-break: break-all;
    white-space: pre-wrap;
}
.alarm-resolved-meta {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ======================================================================
   T+1 同步状态卡片（admin 系统状态页，解析 sync_and_compute 报警 detail）
   ====================================================================== */

.sync-hint { font-size: 11px; color: var(--text-muted); margin: 4px 0 8px; }
.sync-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
    margin-top: 6px;
}
.sync-table th, .sync-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}
.sync-table th { color: var(--text-muted); font-weight: 500; font-size: 11px; }
.sync-table .num { text-align: right; font-variant-numeric: tabular-nums; }
/* 核心表失败行红色高亮（🔥 标记的表） */
.sync-row-critical { background: rgba(239, 68, 68, 0.08); }
.sync-src { color: var(--text-muted); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; }
.sync-fire { font-size: 11px; }

/* 聚合新鲜度卡表格 —— 与 sync-table 同风格，保持卡片内表格视觉统一
   （原 .aggs-table 无样式定义，渲染成裸表格与其他卡格格不入） */
.aggs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
    margin-top: 6px;
}
.aggs-table th, .aggs-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}
.aggs-table th { color: var(--text-muted); font-weight: 500; font-size: 11px; }
.aggs-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.agg-missing { color: var(--danger, #ef4444); font-size: 11px; }

/* 报警记录卡筛选条：select change 即带参刷新，关键词 input keyup 防抖 */
.alarm-filter-bar { margin-bottom: 10px; }
.alarm-filter-bar form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.alarm-filter-bar select,
.alarm-filter-bar input {
    padding: 4px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--font-size-sm);
}
.alarm-filter-bar input[type="text"] { min-width: 150px; flex: 1; }
.alarm-filter-count { font-size: 11px; color: var(--text-muted); margin: 0 0 6px; }
.sync-empties { margin-top: 6px; font-size: 11px; line-height: 1.8; }
.sync-empties-label { color: var(--text-muted); }
.sync-empty-tag {
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}
.sync-summary { margin-top: 6px; }
.sync-summary summary { font-size: 11px; color: var(--text-muted); cursor: pointer; }
.sync-summary pre {
    margin-top: 4px;
    padding: 8px;
    background: rgba(128, 128, 128, 0.06);
    border-radius: 4px;
    font-size: 11px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow: auto;
}

/* ======================================================================
   报警弹窗（右下角，仅 admin；5s 自动关闭）
   ====================================================================== */
.alarm-toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 300;          /* 高于模态框(200)，确保报警总能被看到 */
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
    pointer-events: none;  /* 容器不挡点击，单条 toast 自身重新开启 */
}
.alarm-toast {
    pointer-events: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--neutral);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 12px 14px;
    cursor: pointer;
    min-width: 280px;
    opacity: 0;
    transform: translateX(120%);   /* 入场前在屏幕右侧外 */
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.alarm-toast.show { opacity: 1; transform: translateX(0); }
.alarm-toast-danger { border-left-color: var(--danger); }
.alarm-toast-warning { border-left-color: var(--warning); }
.alarm-toast-info { border-left-color: var(--info); }
.alarm-toast-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.alarm-toast-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.5px;
}
.alarm-toast-badge-danger { background: var(--up-bg); color: var(--danger); }
.alarm-toast-badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.alarm-toast-badge-info { background: var(--primary-bg); color: var(--info); }
.alarm-toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.alarm-toast-close:hover { color: var(--text); }
.alarm-toast-title {
    font-size: var(--font-size-sm);
    color: var(--text);
    line-height: 1.4;
    word-break: break-all;
}
.alarm-toast-meta {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
@media (max-width: 480px) {
    .alarm-toast-container { left: 12px; right: 12px; max-width: none; }
    .alarm-toast { min-width: 0; }
}

/* ====================================================================
   运维操作页（admin_ops.html / _ops_timeline.html）
   ==================================================================== */
.ops-page-hint {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-right: 8px;
}
.ops-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.ops-proc {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--font-size-sm);
    font-weight: 600;
}
.ops-proc .ops-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--neutral);
}
.ops-proc-alive .ops-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); }
.ops-proc-dead .ops-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18); }
.ops-proc-unknown .ops-dot { background: var(--neutral); }
.ops-proc-beat,
.ops-proc-overdue {
    font-weight: 400;
    color: var(--text-muted);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 11px;
}
.ops-proc-overdue { color: var(--danger); }
.ops-stats { display: flex; gap: 18px; }
.ops-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 48px;
}
.ops-stat-num {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
}
.ops-stat-crash { color: var(--danger); }
.ops-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* 时间线 */
.ops-timeline {
    position: relative;
    padding: 8px 16px 4px;
}
.ops-row {
    display: flex;
    gap: 12px;
    padding: 8px 0;
}
.ops-row-rail {
    position: relative;
    width: 14px;
    flex: 0 0 14px;
    display: flex;
    justify-content: center;
}
.ops-row-rail::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
    left: 50%;
    transform: translateX(-50%);
}
.ops-row:first-child .ops-row-rail::before { top: 14px; }
.ops-row:last-child .ops-row-rail::before { bottom: calc(100% - 14px); }
.ops-node {
    position: relative;
    z-index: 1;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    margin-top: 3px;
    background: var(--neutral);
    border: 2px solid var(--surface);
}
.ops-node-start { background: var(--info); }
.ops-node-stop { background: var(--neutral); }
.ops-node-hang { background: var(--warning); }
.ops-node-crash { background: var(--danger); }
.ops-node-other { background: var(--info-alt); }
.ops-row-body { flex: 1; min-width: 0; }
.ops-row-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ops-row-title {
    font-size: var(--font-size-sm);
    color: var(--text);
    font-weight: 500;
}
.ops-row-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.ops-cat-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
}
.ops-cat-badge-start { background: var(--primary-bg); color: var(--info); }
.ops-cat-badge-stop { background: rgba(107, 119, 133, 0.15); color: var(--neutral); }
.ops-cat-badge-hang { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.ops-cat-badge-crash { background: var(--up-bg); color: var(--danger); }
.ops-cat-badge-other { background: color-mix(in srgb, var(--info-alt) 15%, transparent); color: var(--info-alt); }

