/* 投研新闻看板 — 暗色主题 */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2128;
    --bg-hover: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border: #30363d;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --positive: #f85149;
    --negative: #3fb950;
    --neutral: #d29922;
    --warning: #d29922;
    --danger: #f85149;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 200px;
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.15s;
}

.sidebar-nav a:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.sidebar-nav a.active {
    color: var(--accent);
    background: rgba(88,166,255,0.1);
    border-right: 2px solid var(--accent);
}

.sidebar-nav .nav-icon {
    width: 18px;
    text-align: center;
    font-size: 15px;
}

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

/* Sidebar sync section */
.sidebar-sync {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.sync-title {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}
.sync-select {
    width: 100%;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 12px;
    margin-bottom: 6px;
    outline: none;
}
.sync-select:focus {
    border-color: var(--accent);
}
.sync-btn {
    width: 100%;
    padding: 7px 0;
    border-radius: 4px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.sync-btn:hover {
    background: var(--accent-hover);
}
.sync-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}
.sync-status {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
    min-height: 16px;
    line-height: 1.4;
}

/* Topbar sync indicator */
.sync-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--accent);
    margin-right: 12px;
}
.sync-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Main content */
.main {
    flex: 1;
    margin-left: 200px;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
}

.session-badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.session-morning { background: rgba(63,185,80,0.15); color: var(--positive); }
.session-intraday { background: rgba(88,166,255,0.15); color: var(--accent); }
.session-evening { background: rgba(210,153,34,0.15); color: var(--neutral); }

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

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 12px;
    gap: 6px;
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    width: 180px;
}

.search-box input::placeholder { color: var(--text-muted); }

.alert-badge {
    position: relative;
    cursor: pointer;
    font-size: 18px;
}

.alert-badge .count {
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 8px;
    font-weight: 600;
}

/* Content area */
.content {
    padding: 24px;
}

/* Stat cards row */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.stat-card .label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
}

.stat-card .sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Charts row */
.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.chart-card h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
}

.chart-card canvas {
    width: 100% !important;
    max-height: 220px;
}

/* Panels */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

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

.panel-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.panel-body {
    padding: 0;
}

/* News card */
.news-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    cursor: pointer;
}

.news-item:last-child { border-bottom: none; }
.news-item:hover { background: var(--bg-hover); }

.news-importance {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.importance-high { background: rgba(248,81,73,0.15); color: var(--negative); }
.importance-mid { background: rgba(210,153,34,0.15); color: var(--neutral); }
.importance-low { background: rgba(88,166,255,0.15); color: var(--accent); }

.news-body { flex: 1; min-width: 0; }

.news-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.news-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.news-summary {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tags */
.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.tag-positive { background: rgba(63,185,80,0.15); color: var(--positive); }
.tag-negative { background: rgba(248,81,73,0.15); color: var(--negative); }
.tag-neutral { background: rgba(210,153,34,0.15); color: var(--neutral); }
.tag-source { background: rgba(88,166,255,0.1); color: var(--accent); }
.tag-category { background: rgba(139,148,158,0.15); color: var(--text-secondary); }

/* Filters */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    align-items: center;
}

.filter-bar select,
.filter-bar input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

.filter-bar select:focus,
.filter-bar input:focus {
    border-color: var(--accent);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px;
}

.pagination a,
.pagination span {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all 0.15s;
}

.pagination a:hover { background: var(--bg-hover); color: var(--text-primary); }
.pagination .active { background: var(--accent); color: white; border-color: var(--accent); }
.pagination .disabled { opacity: 0.4; cursor: not-allowed; }

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover td { background: var(--bg-hover); }

/* Alert item */
.alert-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.alert-item.unread { border-left: 3px solid var(--danger); }

.alert-item .alert-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.alert-item .alert-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* Two-column layout */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* Responsive */
@media (max-width: 1024px) {
    .chart-row, .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main { margin-left: 0; }
}

/* Market Digest Section */
.digest-section {
    margin-bottom: 24px;
}

.digest-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.digest-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.digest-periods {
    display: flex;
    gap: 8px;
}

.tag-period {
    background: rgba(139,148,158,0.1);
    color: var(--text-secondary);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.tag-period-active {
    background: rgba(88,166,255,0.15);
    color: var(--accent);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.digest-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
}

.digest-card-header {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.digest-meta {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 8px;
}

.digest-subsection {
    margin-bottom: 16px;
}

.digest-subsection h4 {
    font-size: 13px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 8px;
}

.headline-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
}

.headline-importance {
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.headline-importance.high {
    background: rgba(248,81,73,0.15);
    color: #f85149;
}

.headline-importance.medium {
    background: rgba(210,153,34,0.15);
    color: #d29922;
}

.headline-title {
    font-weight: 500;
}

.headline-detail {
    color: var(--text-secondary);
    font-size: 12px;
}

.theme-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    flex-wrap: wrap;
}

.theme-direction {
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.direction-偏多 { background: rgba(248,81,73,0.15); color: #f85149; }
.direction-偏空 { background: rgba(63,185,80,0.15); color: #3fb950; }
.direction-中性 { background: rgba(210,153,34,0.15); color: #d29922; }

.theme-name {
    font-weight: 600;
}

.theme-reasoning {
    color: var(--text-secondary);
    font-size: 12px;
}

.theme-stocks {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.entity-name {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 6px;
}

.digest-summary {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    line-height: 1.8;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
