/* Claude Style Color Tokens & Reset */
:root {
    --bg-app: #F9F6F0;          /* Claude 温润乳白底色 */
    --bg-sidebar: #F3ECE5;      /* 稍微偏深的温和沙色 */
    --border-warm: #E6DBD0;     /* 暖色调轻边界线 */
    --card-bg: #FFFFFF;         /* 白色卡片背景 */
    --text-primary: #191919;    /* 煤炭黑，柔和高阅读性 */
    --text-secondary: #6B6862;  /* 带有温和暖调的次级灰色 */
    --amber-primary: #CC7A00;   /* 琥珀橙高亮色 */
    --amber-hover: #B36B00;     
    --green-up: #0F8A5F;        /* 涨势绿色 */
    --red-down: #C53030;        /* 跌势红色 */
    --shadow-soft: 0 6px 18px rgba(214, 201, 187, 0.25);
    --font-serif: 'Newsreader', Georgia, serif;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* 核心布局框架 - 左右分栏 */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ==========================================
   1. 左侧侧边栏 (Sidebar) 样式
   ========================================== */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-warm);
    display: flex;
    flex-direction: column;
    padding: 24px;
    flex-shrink: 0;
}

.sidebar-header {
    margin-bottom: 36px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 0;
}

/* ==========================================
   1.5. 历史分析记录 (Sidebar History) 样式
   ========================================== */
.sidebar-history {
    margin-top: 24px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
}

.history-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-left: 8px;
    border-left: 2px solid var(--amber-primary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 4px;
}

/* 隐藏或美化滚动条 */
.history-list::-webkit-scrollbar {
    width: 4px;
}
.history-list::-webkit-scrollbar-track {
    background: transparent;
}
.history-list::-webkit-scrollbar-thumb {
    background: var(--border-warm);
    border-radius: 4px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-warm);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(214, 201, 187, 0.15);
    border-color: var(--amber-primary);
}

.history-item.active {
    background-color: #E7DDD3;
    border-color: var(--amber-primary);
}

.history-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.history-item-code {
    font-size: 11px;
    color: var(--text-secondary);
}

.history-item-time {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-item:hover {
    background-color: rgba(222, 203, 190, 0.35);
    transform: translateX(3px);
}

.menu-item.active {
    background-color: #E7DDD3;
    font-weight: 600;
    color: var(--amber-primary);
}

.menu-icon {
    font-size: 16px;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-warm);
}

.stock-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--card-bg);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-warm);
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.badge-dot {
    width: 8px;
    height: 8px;
    background-color: var(--green-up);
    border-radius: 50%;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(15, 138, 95, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(15, 138, 95, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(15, 138, 95, 0); }
}

.badge-title {
    font-weight: 600;
    display: block;
    font-size: 14px;
}

.badge-sub {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
}

/* ==========================================
   2. 右侧主体内容区域 样式
   ========================================== */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

/* 顶通设计 */
.top-bar {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-warm);
    padding: 24px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.serif-title {
    font-family: var(--font-serif);
    font-size: 28px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.serif-title.md-title {
    font-size: 22px;
}

.subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.top-bar-stats {
    display: flex;
    gap: 32px;
}

.quick-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 22px;
    font-weight: 600;
}

.stat-value.up { color: var(--green-up); }
.stat-value.down { color: var(--red-down); }

.stat-unit {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
}

/* 内容卡片区 */
.content-body {
    padding: 40px;
    flex-grow: 1;
}

/* 控制模块切换显示/隐藏 */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 指标卡片网格网格 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-warm);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.card-icon {
    font-size: 24px;
    margin-bottom: 12px;
}

.stat-card-title {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-card-num {
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 6px;
}

.stat-card-num .up { color: var(--green-up); }
.stat-card-num .down { color: var(--red-down); }
.stat-card-num.text-amber { color: var(--amber-primary); }

.stat-card-unit {
    font-size: 15px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 4px;
}

.stat-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 面板底座 */
.card-panel {
    background-color: var(--card-bg);
    border: 1px solid var(--border-warm);
    border-radius: 12px;
    padding: 32px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 32px;
}

.panel-header {
    margin-bottom: 24px;
}

.panel-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 图表容器 */
.chart-wrapper {
    position: relative;
    height: 380px;
    width: 100%;
}

/* ==========================================
   3. 表格与明细列表 样式
   ========================================== */
.table-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 540px; /* 固定高度以支持垂直滚动，与右侧诊断卡片等高对齐 */
    border-radius: 8px;
    border: 1px solid var(--border-warm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.data-table th {
    background-color: var(--bg-sidebar);
    color: var(--text-primary);
    font-weight: 600;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-warm);
}

.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-warm);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background-color: rgba(243, 236, 229, 0.4);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.table-val-up {
    color: var(--green-up);
    font-weight: 500;
}

.table-val-down {
    color: var(--red-down);
    font-weight: 500;
}

/* ==========================================
   4. 量价诊断分析 样式
   ========================================== */
.grid-two-cols {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 32px;
}

.panel-border-bottom {
    border-bottom: 1px solid var(--border-warm);
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.diagnostic-flow {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.flow-step {
    display: flex;
    gap: 20px;
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
    margin-top: 3px;
}

.step-num.bg-orange { background-color: var(--amber-primary); }
.step-num.bg-red { background-color: var(--red-down); }
.step-num.bg-green { background-color: var(--green-up); }

.step-title {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}

.step-desc {
    font-size: 14px;
    color: var(--text-secondary);
}

.bg-warm {
    background-color: #FAF5EF !important; /* 更加温润的卡片色 */
    border: 1px dashed var(--border-warm) !important;
}

.flex-column-between {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.advice-block {
    margin-top: 20px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-warm);
    border-radius: 8px;
    padding: 20px;
}

.advice-header {
    margin-bottom: 12px;
}

.advice-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}

.advice-badge.badge-buy {
    background-color: rgba(15, 138, 95, 0.1);
    color: var(--green-up);
}

.advice-body p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.advice-body p:last-child {
    margin-bottom: 0;
}

.advice-body strong {
    color: var(--text-primary);
}

.alert-box {
    margin-top: 24px;
    display: flex;
    gap: 12px;
    background-color: rgba(204, 122, 0, 0.05);
    border: 1px solid rgba(204, 122, 0, 0.15);
    padding: 14px;
    border-radius: 8px;
}

.alert-icon {
    font-size: 16px;
}

.alert-text {
    font-size: 12px;
    color: #995C00;
}

/* ==========================================
   5. 通用按钮设计
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: background-color 0.2s, transform 0.1s;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background-color: var(--amber-primary);
    color: #FFFFFF;
}

.btn-primary:hover {
    background-color: var(--amber-hover);
}

.btn-secondary {
    background-color: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-warm);
}

.btn-secondary:hover {
    background-color: var(--bg-sidebar);
}

.btn-full-width {
    width: 100%;
}

.panel-footer-btn {
    margin-top: 24px;
}

/* 简易响应式适配 */
@media(max-width: 992px) {
    .grid-two-cols {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   6. 顶部搜索框与代理页面补充样式
   ========================================== */
.top-bar-search {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input {
    background-color: #FAF5EF;
    border: 1px solid var(--border-warm);
    border-radius: 6px;
    padding: 10px 16px;
    font-family: var(--font-sans);
    font-size: 14px;
    width: 240px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--amber-primary);
    background-color: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(204, 122, 0, 0.1);
}

/* 代理管理表格徽章 */
.latency-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.latency-fast {
    background-color: rgba(15, 138, 95, 0.1);
    color: var(--green-up);
}

.latency-slow {
    background-color: rgba(204, 122, 0, 0.1);
    color: var(--amber-primary);
}

.latency-fail {
    background-color: rgba(197, 48, 48, 0.1);
    color: var(--red-down);
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
}

.indicator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-online { color: var(--green-up); }
.status-online .indicator-dot { background-color: var(--green-up); }

.status-offline { color: var(--red-down); }
.status-offline .indicator-dot { background-color: var(--red-down); }

.status-untested { color: var(--text-secondary); }
.status-untested .indicator-dot { background-color: var(--text-secondary); }

/* ==========================================
   5. 任务运行日志弹窗 (Modal Container & Overlay)
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(25, 25, 25, 0.45); /* 煤炭黑半透明 */
    backdrop-filter: blur(4px); /* 毛玻璃模糊 */
    display: none; /* 默认隐藏 */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-container {
    background-color: var(--card-bg);
    border: 1px solid var(--border-warm);
    border-radius: 12px;
    width: 90%;
    max-width: 650px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    animation: modal-slide-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modal-slide-in {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.modal-title {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 600;
}

.modal-close-btn {
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

.task-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-sidebar);
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
}

.badge-running {
    background-color: rgba(204, 122, 0, 0.12);
    color: var(--amber-primary);
}

.badge-success {
    background-color: rgba(15, 138, 95, 0.12);
    color: var(--green-up);
}

.badge-failed {
    background-color: rgba(197, 48, 48, 0.12);
    color: var(--red-down);
}

.badge-cancelled {
    background-color: rgba(107, 104, 98, 0.12);
    color: var(--text-secondary);
}

.log-terminal {
    background-color: #1a1a1a;
    color: #38ef7d; /* 护眼亮绿色 */
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    padding: 16px;
    border-radius: 8px;
    height: 320px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
    line-height: 1.5;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-warm);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-danger {
    background-color: var(--red-down);
    color: #FFFFFF;
}

.btn-danger:hover {
    background-color: #a82525;
}

.btn-danger:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ==========================================
   4. 历史分析记录大卡片网格样式
   ========================================== */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 16px;
}

.history-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-warm);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(214, 201, 187, 0.08);
}

.history-card:hover {
    transform: translateY(-3px);
    border-color: var(--amber-primary);
    box-shadow: 0 8px 24px rgba(214, 201, 187, 0.2);
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.history-card-title {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
}

.history-card-code {
    font-size: 11px;
    background-color: var(--bg-sidebar);
    color: var(--text-secondary);
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
    white-space: nowrap;
}

.history-card-body {
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-card-info-item {
    display: flex;
    justify-content: space-between;
}

.history-card-info-val {
    font-weight: 500;
    color: var(--text-primary);
}

.history-card-footer {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-warm);
    padding-top: 12px;
}

.history-card-time {
    font-size: 11px;
    color: var(--text-secondary);
}

.btn-card-view {
    font-size: 13px;
    font-weight: 600;
    color: var(--amber-primary);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: transform 0.2s ease;
}

.history-card:hover .btn-card-view {
    transform: translateX(4px);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin-icon {
    display: inline-block;
    animation: spin 1s linear infinite;
}



