/* ═══════════════════════════════════════════════════
   VulnDash COMEX — Professional Dark Theme
   ═══════════════════════════════════════════════════ */

:root {
    --bg-primary: #0c0e14;
    --bg-secondary: #12151e;
    --bg-card: #171b27;
    --bg-card-hover: #1c2133;
    --bg-elevated: #1e2336;
    --border: #252a3a;
    --border-subtle: #1e2336;
    --text-primary: #e8eaf0;
    --text-secondary: #8b91a8;
    --text-muted: #5c6278;
    --text-accent: #a0b4ff;
    --accent: #5b7cfa;
    --accent-soft: rgba(91, 124, 250, 0.12);
    --critical: #ff4757;
    --critical-bg: rgba(255, 71, 87, 0.10);
    --high: #ff8c42;
    --high-bg: rgba(255, 140, 66, 0.10);
    --medium: #ffc842;
    --medium-bg: rgba(255, 200, 66, 0.10);
    --low: #45d9a8;
    --low-bg: rgba(69, 217, 168, 0.10);
    --info: #5b7cfa;
    --info-bg: rgba(91, 124, 250, 0.10);
    --success: #45d9a8;
    --warning: #ffc842;
    --danger: #ff4757;
    --font-body: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --shadow: 0 2px 12px rgba(0,0,0,0.25);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────── */
.header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 2rem; height: 64px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    backdrop-filter: blur(12px);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { color: var(--accent); font-size: 1.3rem; }
.logo h1 { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.02em; }
.version {
    font-size: 0.7rem; color: var(--text-muted);
    font-family: var(--font-mono);
    background: var(--bg-elevated); padding: 2px 8px; border-radius: var(--radius-sm);
}
.header-center {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.85rem; color: var(--text-secondary);
}
.meta-sep { color: var(--text-muted); }
.header-right { display: flex; align-items: center; gap: 12px; }
.mode-switch {
    display: flex; background: var(--bg-elevated);
    border-radius: var(--radius); padding: 3px; border: 1px solid var(--border);
}
.mode-btn {
    padding: 5px 14px; border: none; background: none;
    color: var(--text-secondary); font-family: var(--font-body);
    font-size: 0.78rem; font-weight: 500; border-radius: 7px;
    cursor: pointer; transition: all 0.2s;
}
.mode-btn.active { background: var(--accent); color: #fff; }
.mode-btn:hover:not(.active) { color: var(--text-primary); }

/* ── Buttons ────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px; border: 1px solid transparent;
    border-radius: var(--radius); font-family: var(--font-body);
    font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all 0.2s;
    text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #4a6be8; }
.btn-outline { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 28px; font-size: 0.95rem; }

/* ── Main ───────────────────────────────────────── */
.main { padding: 1.5rem 2rem 3rem; max-width: 1600px; margin: 0 auto; }
.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 50vh; text-align: center; gap: 16px;
}
.empty-icon { font-size: 4rem; opacity: 0.5; }
.empty-state h2 { font-size: 1.5rem; font-weight: 600; }
.empty-state p { color: var(--text-secondary); max-width: 480px; }
.hidden { display: none !important; }

/* ── KPI Cards ──────────────────────────────────── */
.kpi-cards {
    display: grid; grid-template-columns: repeat(6, 1fr);
    gap: 14px; margin-bottom: 1.5rem;
}
.kpi-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
    position: relative; overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.kpi-total::before { background: var(--accent); }
.kpi-critical::before { background: var(--critical); }
.kpi-high::before { background: var(--high); }
.kpi-network::before { background: var(--warning); }
.kpi-auto::before { background: var(--danger); }
.kpi-recent::before { background: var(--critical); }
.kpi-value {
    font-size: 2rem; font-weight: 700; letter-spacing: -0.03em;
    font-family: var(--font-mono); line-height: 1.1;
}
.kpi-total .kpi-value { color: var(--accent); }
.kpi-critical .kpi-value { color: var(--critical); }
.kpi-high .kpi-value { color: var(--high); }
.kpi-network .kpi-value { color: var(--warning); }
.kpi-auto .kpi-value { color: var(--danger); }
.kpi-recent .kpi-value { color: var(--critical); }
.kpi-label { font-size: 0.82rem; font-weight: 500; color: var(--text-secondary); margin-top: 6px; }
.kpi-hint { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }

/* ── Section titles ─────────────────────────────── */
.section-title {
    font-size: 1.1rem; font-weight: 600;
    display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
}
.section-icon { font-size: 1.2rem; }
.section-hint {
    font-size: 0.72rem; color: var(--text-muted);
    font-weight: 400; margin-left: 8px;
}

/* ── Insights ───────────────────────────────────── */
.insights-section { margin-bottom: 1.5rem; }
.insights-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px;
}
.insight-card {
    display: flex; gap: 14px; padding: 16px 18px;
    border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--bg-card);
}
.insight-card.danger { border-left: 3px solid var(--danger); }
.insight-card.warning { border-left: 3px solid var(--warning); }
.insight-card.info { border-left: 3px solid var(--info); }
.insight-icon { font-size: 1.5rem; flex-shrink: 0; }
.insight-body { flex: 1; }
.insight-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.insight-msg { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 6px; }
.insight-action {
    font-size: 0.78rem; color: var(--accent); font-weight: 500;
    padding: 4px 10px; background: var(--accent-soft);
    border-radius: var(--radius-sm); display: inline-block;
}

/* ── Charts ─────────────────────────────────────── */
.charts-row {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 14px; margin-bottom: 14px;
}
.charts-row:has(.chart-wide) { grid-template-columns: 2fr 1fr; }
.chart-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
}
.chart-title { font-size: 0.95rem; font-weight: 600; }
.chart-desc { font-size: 0.75rem; color: var(--text-muted); margin: 4px 0 16px; }

/* ── Quality bars ───────────────────────────────── */
.quality-section { margin-bottom: 1.5rem; }
.quality-bars {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
}
.quality-header {
    display: flex; justify-content: space-between;
    font-size: 0.82rem; margin-bottom: 8px;
}
.quality-header span:last-child { font-family: var(--font-mono); font-weight: 600; }
.quality-bar {
    height: 6px; background: var(--bg-elevated);
    border-radius: 3px; overflow: hidden;
}
.quality-fill {
    height: 100%; border-radius: 3px;
    transition: width 0.8s ease; width: 0%;
}
.quality-fill[data-color="blue"] { background: var(--accent); }
.quality-fill[data-color="purple"] { background: #a78bfa; }
.quality-fill[data-color="teal"] { background: var(--success); }

/* ── Priority list ──────────────────────────────── */
.priority-section { margin-bottom: 1.5rem; }
.priority-list { display: grid; gap: 8px; }
.priority-item {
    display: grid;
    grid-template-columns: 48px 120px 70px 80px 1fr auto;
    align-items: center; gap: 14px; padding: 12px 16px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); cursor: pointer; transition: all 0.2s;
}
.priority-item:hover { background: var(--bg-card-hover); border-color: var(--accent); }
.priority-rank {
    font-family: var(--font-mono); font-size: 0.85rem;
    font-weight: 700; color: var(--text-muted); text-align: center;
}
.priority-rank.top3 { color: var(--critical); }
.priority-cve {
    font-family: var(--font-mono); font-size: 0.82rem;
    font-weight: 600; color: var(--text-accent);
}
.priority-score { font-family: var(--font-mono); font-weight: 700; font-size: 0.9rem; }
.sev-badge {
    display: inline-block; padding: 2px 10px; border-radius: 4px;
    font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.sev-CRITICAL { background: var(--critical-bg); color: var(--critical); }
.sev-HIGH { background: var(--high-bg); color: var(--high); }
.sev-MEDIUM { background: var(--medium-bg); color: var(--medium); }
.sev-LOW { background: var(--low-bg); color: var(--low); }
.sev-UNKNOWN, .sev-NONE { background: var(--bg-elevated); color: var(--text-muted); }
.priority-explain {
    font-size: 0.75rem; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.priority-vendor { font-size: 0.78rem; color: var(--text-muted); text-align: right; }

/* ── Data Table ─────────────────────────────────── */
.table-section { margin-bottom: 2rem; }
.table-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.table-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-input {
    padding: 7px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--bg-elevated);
    color: var(--text-primary); font-family: var(--font-body);
    font-size: 0.82rem; width: 260px; outline: none; transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }
.filter-select {
    padding: 7px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--bg-elevated);
    color: var(--text-primary); font-family: var(--font-body);
    font-size: 0.82rem; outline: none; cursor: pointer;
}
.filter-select:focus { border-color: var(--accent); }
.filter-group { display: flex; gap: 6px; }
.filter-tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; background: var(--accent-soft);
    color: var(--accent); border-radius: var(--radius-sm);
    font-size: 0.73rem; font-weight: 500;
}
.filter-tag button {
    background: none; border: none; color: var(--accent);
    cursor: pointer; font-size: 0.9rem; line-height: 1;
}
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.data-table thead { background: var(--bg-elevated); position: sticky; top: 0; }
.data-table th {
    padding: 10px 12px; text-align: left; font-weight: 600;
    color: var(--text-secondary); font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--accent); }
.data-table th.sort-asc::after { content: ' ▲'; font-size: 0.6rem; }
.data-table th.sort-desc::after { content: ' ▼'; font-size: 0.6rem; }
.data-table td {
    padding: 9px 12px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle;
}
.data-table tbody tr { transition: background 0.15s; cursor: pointer; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.cell-cve {
    font-family: var(--font-mono); font-weight: 600;
    font-size: 0.78rem; color: var(--text-accent);
}
.cell-score { font-family: var(--font-mono); font-weight: 700; font-size: 0.82rem; }
.cell-mono { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-secondary); }
.score-high { color: var(--critical); }
.score-med { color: var(--high); }
.score-low { color: var(--medium); }
.score-min { color: var(--low); }

/* ── Pagination ─────────────────────────────────── */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 4px; margin-top: 14px;
}
.page-btn {
    padding: 5px 11px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg-card);
    color: var(--text-secondary); font-family: var(--font-mono);
    font-size: 0.78rem; cursor: pointer; transition: all 0.15s;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.page-info { font-size: 0.78rem; color: var(--text-muted); margin: 0 8px; }

/* ── Overlay / Modal ────────────────────────────── */
.overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px); z-index: 1000;
    display: flex; align-items: center; justify-content: center; padding: 2rem;
}
.overlay-content {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-xl); padding: 2rem;
    max-width: 600px; width: 100%; max-height: 85vh; overflow-y: auto;
    position: relative; box-shadow: var(--shadow-lg);
}
.modal-wide { max-width: 800px; }
.overlay-close {
    position: absolute; top: 14px; right: 18px;
    background: none; border: none; color: var(--text-muted);
    font-size: 1.5rem; cursor: pointer; transition: color 0.15s;
}
.overlay-close:hover { color: var(--text-primary); }
.overlay-content h2 { font-size: 1.2rem; margin-bottom: 6px; }
.overlay-desc { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 18px; }

/* ── Drop zone ──────────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--border); border-radius: var(--radius-lg);
    padding: 2.5rem 1.5rem; text-align: center;
    transition: all 0.25s; background: var(--bg-primary);
}
.drop-zone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { font-size: 2.5rem; margin-bottom: 10px; }
.drop-zone p { color: var(--text-secondary); font-size: 0.9rem; }
.drop-or { display: block; color: var(--text-muted); font-size: 0.78rem; margin: 10px 0; }
.drop-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 10px; }
.upload-progress { margin-top: 18px; }
.progress-bar {
    height: 6px; background: var(--bg-elevated);
    border-radius: 3px; overflow: hidden; margin-bottom: 8px;
}
.progress-fill {
    height: 100%; background: var(--accent);
    border-radius: 3px; width: 0%; transition: width 0.3s;
}
#uploadStatus { font-size: 0.82rem; color: var(--text-secondary); text-align: center; }

/* ── Import history ─────────────────────────────── */
.import-history { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px; }
.import-history h3 { font-size: 0.9rem; margin-bottom: 10px; color: var(--text-secondary); }
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 14px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); cursor: pointer; font-family: var(--font-body);
    color: var(--text-primary); transition: all 0.15s; text-align: left; width: 100%;
}
.history-item:hover { border-color: var(--accent); background: var(--bg-card-hover); }
.history-file { font-size: 0.82rem; font-weight: 500; }
.history-meta { font-size: 0.72rem; color: var(--text-muted); font-family: var(--font-mono); }

/* ── CVE Detail Modal ───────────────────────────── */
.cve-detail-header {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.cve-detail-id {
    font-family: var(--font-mono); font-size: 1.3rem;
    font-weight: 700; color: var(--text-accent);
}
.cve-detail-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px;
}
.cve-detail-field {
    padding: 10px 14px; background: var(--bg-card);
    border-radius: var(--radius); border: 1px solid var(--border-subtle);
}
.cve-detail-field-label {
    font-size: 0.7rem; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 3px;
}
.cve-detail-field-value { font-size: 0.88rem; font-weight: 500; }
.cve-detail-field-value.mono { font-family: var(--font-mono); font-size: 0.82rem; }
.cve-detail-summary {
    padding: 14px; background: var(--bg-card);
    border-radius: var(--radius); border: 1px solid var(--border-subtle); margin-bottom: 16px;
}
.cve-detail-summary h4 {
    font-size: 0.78rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px;
}
.cve-detail-summary p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }
.cve-detail-priority {
    padding: 14px; background: var(--accent-soft);
    border: 1px solid rgba(91,124,250,0.2); border-radius: var(--radius);
}
.cve-detail-priority h4 {
    font-size: 0.78rem; text-transform: uppercase; color: var(--accent); margin-bottom: 6px;
}
.cve-detail-priority .score-big {
    font-family: var(--font-mono); font-size: 1.8rem; font-weight: 700; margin-bottom: 4px;
}
.cve-detail-priority .explain { font-size: 0.82rem; color: var(--text-secondary); }

/* ── Footer ─────────────────────────────────────── */
.footer {
    padding: 16px 2rem; border-top: 1px solid var(--border);
    text-align: center; font-size: 0.72rem; color: var(--text-muted);
}

/* ── Mode switching ─────────────────────────────── */
body.mode-comex .analyst-only { display: none; }
body.mode-comex .analyst-col { display: none; }
body.mode-analyst .analyst-only { display: block; }
body.mode-analyst .analyst-col { display: table-cell; }
body:not(.mode-analyst) .analyst-only { display: none; }
body:not(.mode-analyst) .analyst-col { display: none; }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 1200px) {
    .kpi-cards { grid-template-columns: repeat(3, 1fr); }
    .charts-row, .charts-row:has(.chart-wide) { grid-template-columns: 1fr; }
    .quality-bars { grid-template-columns: 1fr; }
    .priority-item { grid-template-columns: 40px 100px 60px 70px 1fr; }
    .priority-vendor { display: none; }
}
@media (max-width: 768px) {
    .header { padding: 10px 1rem; flex-wrap: wrap; height: auto; gap: 8px; }
    .header-center { display: none; }
    .main { padding: 1rem; }
    .kpi-cards { grid-template-columns: repeat(2, 1fr); }
    .insights-grid { grid-template-columns: 1fr; }
    .cve-detail-grid { grid-template-columns: 1fr; }
    .table-actions { flex-direction: column; width: 100%; }
    .search-input { width: 100%; }
}

/* ── Animations ─────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.kpi-card { animation: fadeIn 0.4s ease both; }
.kpi-card:nth-child(1) { animation-delay: 0s; }
.kpi-card:nth-child(2) { animation-delay: 0.05s; }
.kpi-card:nth-child(3) { animation-delay: 0.1s; }
.kpi-card:nth-child(4) { animation-delay: 0.15s; }
.kpi-card:nth-child(5) { animation-delay: 0.2s; }
.kpi-card:nth-child(6) { animation-delay: 0.25s; }
.insight-card { animation: fadeIn 0.4s ease both; }
.insight-card:nth-child(1) { animation-delay: 0.1s; }
.insight-card:nth-child(2) { animation-delay: 0.15s; }
.insight-card:nth-child(3) { animation-delay: 0.2s; }
.insight-card:nth-child(4) { animation-delay: 0.25s; }
.insight-card:nth-child(5) { animation-delay: 0.3s; }
.chart-card { animation: fadeIn 0.5s ease both; animation-delay: 0.15s; }

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