/* ── 智投云 ── 样式系统 ── */
:root {
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-hover: #252540;
    --text: #e0e0f0;
    --text-dim: #8888aa;
    --primary: #6c5ce7;
    --primary-glow: rgba(108, 92, 231, 0.3);
    --up: #00b894;
    --up-bg: rgba(0, 184, 148, 0.12);
    --down: #e17055;
    --down-bg: rgba(225, 112, 85, 0.12);
    --warn: #fdcb6e;
    --warn-bg: rgba(253, 203, 110, 0.12);
    --danger: #d63031;
    --border: #2d2d48;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── 导航栏 ── */
.navbar {
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 700;
    margin-right: 32px;
}

.brand-icon { font-size: 1.5rem; }
.brand-text { background: linear-gradient(135deg, #6c5ce7, #a29bfe); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.nav-links { display: flex; gap: 4px; flex: 1; }

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.nav-link:hover { color: var(--text); background: var(--bg-hover); }
.nav-link.active { color: var(--primary); background: var(--primary-glow); font-weight: 600; }

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

.update-time { font-size: 0.85rem; color: var(--text-dim); font-family: monospace; }

/* ── 按钮 ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #5a4bd1; box-shadow: 0 0 20px var(--primary-glow); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-hover); border-color: var(--primary); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-lg { padding: 14px 40px; font-size: 1.1rem; border-radius: 50px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b71c1c; }

/* ── 容器 ── */
.container { max-width: 1280px; margin: 0 auto; padding: 20px 24px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; }
.header-actions { display: flex; gap: 8px; }

/* ── 统计卡片行 ── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.up::before { background: var(--up); }
.stat-card.down::before { background: var(--down); }
.stat-card.flat::before { background: var(--warn); }

.stat-label { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 4px; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-value.up { color: var(--up); }
.stat-value.down { color: var(--down); }
.stat-detail { font-size: 0.8rem; color: var(--text-dim); margin-top: 4px; }

.stat-loading { display: flex; align-items: center; justify-content: center; min-height: 100px; }

/* ── 卡片 ── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-body { padding: 16px 20px; }

/* ── 网格 ── */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── 表格 ── */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.8rem;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.table td {
    padding: 10px 12px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(45, 45, 72, 0.5);
}
.table tr:hover { background: var(--bg-hover); }
.table tr:last-child td { border-bottom: none; }

.pct-up { color: var(--up); font-weight: 600; }
.pct-down { color: var(--down); font-weight: 600; }
.pct-flat { color: var(--text-dim); }

/* ── 标签 / 徽章 ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: var(--up-bg); color: var(--up); }
.badge-danger { background: var(--down-bg); color: var(--down); }
.badge-warning { background: var(--warn-bg); color: var(--warn); }
.badge-secondary { background: rgba(136, 136, 170, 0.15); color: var(--text-dim); }

/* ── 板块标签 ── */
.sector-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}
.sector-tag.up { background: var(--up-bg); color: var(--up); }
.sector-tag.down { background: var(--down-bg); color: var(--down); }
.sector-tag.flat { background: rgba(136, 136, 170, 0.12); color: var(--text-dim); }

/* ── Tabs ── */
.tab-group { display: flex; gap: 2px; background: rgba(0,0,0,0.2); border-radius: var(--radius-sm); padding: 2px; }
.tab-btn {
    padding: 4px 12px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.2s;
}
.tab-btn.active { background: var(--primary); color: #fff; }
.tab-btn:hover:not(.active) { color: var(--text); }

/* ── 搜索框 ── */
.search-box input {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    width: 220px;
    outline: none;
    transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--primary); }
.search-box input::placeholder { color: var(--text-dim); }

/* ── 预警条目 ── */
.alert-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(45, 45, 72, 0.4);
}
.alert-item:last-child { border-bottom: none; }
.alert-icon { font-size: 1.2rem; }
.alert-level-danger .alert-icon { color: var(--danger); }
.alert-level-warning .alert-icon { color: var(--warn); }
.alert-content { flex: 1; }
.alert-stock { font-weight: 600; }
.alert-msg { font-size: 0.85rem; color: var(--text-dim); margin-top: 2px; }

/* ── 预警规则卡片 ── */
.alert-rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.rule-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(0,0,0,0.15);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.rule-icon { font-size: 1.5rem; }
.rule-info { flex: 1; }
.rule-name { font-weight: 600; font-size: 0.9rem; }
.rule-desc { font-size: 0.8rem; color: var(--text-dim); margin-top: 2px; }

/* ── 股票列表项（池管理） ── */
.stock-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(45, 45, 72, 0.3);
}
.stock-list-item:last-child { border-bottom: none; }
.stock-info { display: flex; align-items: center; gap: 12px; }
.stock-code { font-family: monospace; font-size: 0.8rem; color: var(--text-dim); }
.stock-name { font-weight: 600; }
.stock-sector { font-size: 0.8rem; color: var(--text-dim); }
.stock-market { font-size: 0.75rem; padding: 1px 6px; border-radius: 4px; background: var(--bg-hover); }
.stock-actions { display: flex; gap: 6px; }
.pool-type-badge { font-size: 0.7rem; padding: 1px 6px; border-radius: 4px; }
.pool-type-core { background: rgba(108, 92, 231, 0.2); color: #a29bfe; }
.pool-type-hot { background: rgba(253, 203, 110, 0.2); color: var(--warn); }
.pool-type-manual { background: rgba(0, 184, 148, 0.15); color: var(--up); }

/* ── 板块池卡片 ── */
.sector-pool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.sector-pool-card {
    padding: 16px;
    background: rgba(0,0,0,0.15);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.sector-pool-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sector-pool-name { font-weight: 600; font-size: 0.95rem; }
.sector-pool-count { font-size: 0.8rem; color: var(--text-dim); }
.sector-pool-stocks { display: flex; flex-wrap: wrap; gap: 4px; }
.sector-pool-stock {
    padding: 2px 8px;
    background: var(--bg);
    border-radius: 4px;
    font-size: 0.8rem;
}

/* ── 报告 ── */
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.recommendation-item {
    padding: 10px 0;
    border-bottom: 1px solid rgba(45, 45, 72, 0.3);
    font-size: 0.95rem;
    line-height: 1.6;
}
.recommendation-item:last-child { border-bottom: none; }

/* ── 弹窗 ── */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal.show { display: flex; }
.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: 420px;
    max-width: 90vw;
    box-shadow: var(--shadow);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 1.5rem; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }

/* ── 表单 ── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 4px; }
.form-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
}
.form-input:focus { border-color: var(--primary); }
select.form-input { cursor: pointer; }

/* ── 首页 landing ── */
.landing {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
}
.landing-content { max-width: 500px; }
.landing-logo { font-size: 4rem; margin-bottom: 16px; }
.landing-title { font-size: 2.8rem; font-weight: 800; background: linear-gradient(135deg, #6c5ce7, #a29bfe, #74b9ff); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.landing-subtitle { font-size: 1.1rem; color: var(--text-dim); margin: 8px 0 32px; }
.landing-features { display: grid; gap: 12px; margin-bottom: 32px; }
.feature-item { padding: 12px; background: var(--bg-card); border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 0.95rem; }
.landing-info { margin-top: 16px; color: var(--text-dim); font-size: 0.85rem; }

/* ── 工具类 ── */
.text-muted { color: var(--text-dim); }
.loading-text { text-align: center; padding: 20px; color: var(--text-dim); }

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 响应式 ── */
@media (max-width: 768px) {
    .grid-2col { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .nav-links { gap: 0; }
    .nav-link { padding: 8px 10px; font-size: 0.8rem; }
    .search-box input { width: 140px; }
    .sector-pool-grid { grid-template-columns: 1fr; }
    .container { padding: 12px; }
}
