/* ===== CSS Custom Properties ===== */
:root {
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-alt: #f8fafc;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
    --radius: 10px;
    --radius-sm: 6px;
    --header-bg: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    --header-text: #f1f5f9;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --green: #16a34a;
    --green-bg: rgba(22,163,74,.08);
    --red: #dc2626;
    --red-bg: rgba(220,38,38,.08);
    --orange: #d97706;
    --orange-bg: rgba(217,119,6,.08);
    --purple: #7c3aed;
    --teal: #0d9488;
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --tab-hover: rgba(255,255,255,.08);
    --kbd-bg: #f1f5f9;
    --kbd-border: #cbd5e1;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-card-alt: #1a2332;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --border-strong: #475569;
    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.4);
    --header-bg: linear-gradient(135deg, #0f172a 0%, #020617 100%);
    --header-text: #e2e8f0;
    --green-bg: rgba(22,163,74,.15);
    --red-bg: rgba(220,38,38,.15);
    --orange-bg: rgba(217,119,6,.15);
    --input-bg: #1e293b;
    --input-border: #475569;
    --tab-hover: rgba(255,255,255,.06);
    --kbd-bg: #334155;
    --kbd-border: #475569;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    transition: background .25s, color .25s;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Hero / Landing Section ===== */
.hero {
    height: 100vh;
    background: var(--header-bg);
    color: var(--header-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 40px 20px;
}
.hero-content {
    text-align: center;
    max-width: 560px;
}
.hero-icon { opacity: .8; margin-bottom: 16px; }
.hero-title {
    font-size: 42px;
    font-weight: 800;
    margin: 0 0 8px;
    letter-spacing: -.5px;
}
.hero-subtitle {
    font-size: 16px;
    opacity: .7;
    margin: 0 0 40px;
    font-weight: 400;
}
.hero-upload {
    background: rgba(255,255,255,.06);
    border: 2px dashed rgba(255,255,255,.25);
    border-radius: var(--radius);
    padding: 40px 32px;
    transition: background .2s, border-color .2s;
    cursor: pointer;
}
.hero-upload:hover,
.hero-upload.drag-over {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.5);
}
.hero-upload-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.hero-upload-inner svg { opacity: .6; }
.hero-upload-inner p { margin: 0; font-size: 15px; opacity: .85; }
.hero-upload-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    text-decoration: underline;
    padding: 0;
}
.hero-upload-btn:hover { color: #60a5fa; }
.hero-upload-hint { font-size: 12px; opacity: .5; }
.hero-scroll-hint {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    opacity: .4;
    animation: bounceDown 2s infinite;
    cursor: pointer;
    padding: 8px;
    border: none;
    background: none;
    color: inherit;
}
.hero-scroll-hint:hover { opacity: .8; }
@keyframes bounceDown {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(8px); }
}
/* Smooth scroll behavior for hero transitions */
/* When no report, hide report content */
body:not(.has-report) .app-main { display: none; }
body:not(.has-report) .app-footer { display: none; }

/* ===== Header ===== */
.app-header {
    background: var(--header-bg);
    color: var(--header-text);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 48px;
    max-width: 1440px;
    margin: 0 auto;
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--header-text);
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
}
.brand-icon { opacity: .9; }
.header-actions { display: flex; gap: 4px; }
.icon-btn {
    background: none;
    border: none;
    color: var(--header-text);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    opacity: .7;
    transition: opacity .15s, background .15s;
}
.icon-btn:hover { opacity: 1; background: rgba(255,255,255,.1); }
/* Dark mode toggle icons */
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ===== Tab Bar ===== */
.tab-bar {
    display: flex;
    gap: 0;
    padding: 0 16px;
    max-width: 1440px;
    margin: 0 auto;
    position: relative;
    overflow-x: auto;
    scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: none;
    border: none;
    color: rgba(255,255,255,.55);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: color .15s, background .15s;
    border-bottom: 2px solid transparent;
    position: relative;
}
.tab:hover { color: rgba(255,255,255,.85); background: var(--tab-hover); }
.tab.active {
    color: #ffffff;
    border-bottom-color: var(--accent);
}
.tab svg { opacity: .8; }
.tab.active svg { opacity: 1; }
.tab-badge {
    font-size: 10px;
    font-weight: 700;
    background: var(--red);
    color: #fff;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 18px;
    text-align: center;
    display: none;
}
.tab-badge.visible { display: inline-block; }
.tab-indicator { display: none; }

/* ===== Main Content ===== */
.app-main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 16px 32px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Filter Bar ===== */
.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: 16px 0;
    box-shadow: var(--shadow);
}
.filter-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.filter-field { flex: 1; min-width: 140px; }
.filter-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.filter-field input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 13px;
    transition: border-color .15s, box-shadow .15s;
}
.filter-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.date-time-pair { display: flex; gap: 4px; }
.date-time-pair input { min-width: 0; }
.filter-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    padding-bottom: 1px;
}
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.active-filters:empty { margin: 0; }
.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 10px;
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}
.filter-tag button {
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}
.filter-tag button:hover { color: #fff; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, transform .1s, box-shadow .15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:active { transform: scale(.97); }
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 7px 8px;
}
.btn-ghost:hover { background: var(--bg-card-alt); color: var(--text); text-decoration: none; }
.btn-export {
    background: var(--bg-card-alt);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 12px;
    padding: 5px 12px;
}
.btn-export:hover { background: var(--border); text-decoration: none; }
.btn-icon {
    background: transparent;
    color: var(--text-secondary);
    padding: 7px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.btn-icon:hover { background: var(--bg-card-alt); }

/* ===== Metadata Strip ===== */
.meta-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.meta-chip {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    box-shadow: var(--shadow);
}
.meta-k {
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 6px;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: .3px;
}
.meta-v { color: var(--text); }

/* ===== Export Bar ===== */
.export-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.export-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
    transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.card-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

/* ===== Badges ===== */
.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: .3px;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    background: var(--bg-card-alt);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.data-table thead th:hover { color: var(--text); }
.th-sort-asc::after { content: " \25B2"; font-size: 9px; }
.th-sort-desc::after { content: " \25BC"; font-size: 9px; }
.data-table tbody td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: var(--bg-card-alt); }
.data-table tbody tr.focused { background: rgba(59,130,246,.08); }
.row-accepted { border-left: 3px solid var(--green); }
.row-failed { border-left: 3px solid var(--red); }
.row-threat { background: var(--red-bg) !important; }
td.clickable { cursor: pointer; }
td.clickable:hover { color: var(--accent); }
.ip-link {
    color: var(--text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.ip-link:hover { color: var(--accent); }
.ext-icon { font-size: 11px; opacity: .4; }
.ip-link:hover .ext-icon { opacity: 1; }
.no-data {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

/* Detail table bar styling */
.detail-table .bar-cell { position: relative; padding-right: 60px; }
.pct-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    border-radius: 2px;
    transition: width .3s;
}
.pct-bar.green { background: var(--green); }
.pct-bar.red { background: var(--red); }

/* ===== Table Pagination ===== */
.table-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
}
.table-pagination button {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    transition: all .15s;
}
.table-pagination button:hover { background: var(--bg-card-alt); color: var(--text); }
.table-pagination button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ===== Stats Cards ===== */
.stats-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}
.stat-card {
    flex: 1;
    min-width: 120px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-align: center;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--accent);
    transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}
.stat-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== View Toggle ===== */
.view-toggle {
    display: flex;
    justify-content: flex-end;
    gap: 2px;
    margin-bottom: 8px;
}
.toggle-btn {
    padding: 6px 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .15s;
    display: flex;
    align-items: center;
}
.toggle-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.toggle-btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.toggle-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ===== Carousel ===== */
.carousel {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}
.carousel-viewport {
    flex: 1;
    overflow: hidden;
    border-radius: var(--radius);
}
.carousel-track {
    display: flex;
    transition: transform .4s cubic-bezier(.25,.8,.25,1);
}
.carousel-slide {
    flex: 0 0 100%;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.carousel-slide h3 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}
.carousel-slide canvas { max-height: 380px; }
.carousel-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    box-shadow: var(--shadow);
}
.carousel-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: scale(1.08);
}
.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
}
.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-strong);
    border: none;
    cursor: pointer;
    transition: all .2s;
    padding: 0;
}
.carousel-dot:hover { background: var(--text-muted); }
.carousel-dot.active {
    background: var(--accent);
    transform: scale(1.3);
}

/* ===== Dashboard Grid ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 12px;
}
.dashboard-cell {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
}
.dashboard-cell h3 {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}

/* ===== Severity Filter ===== */
.severity-filter {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}
.sev-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
    margin-right: 4px;
}
.sev-btn {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}
.sev-btn:hover { border-color: var(--text-muted); color: var(--text); }
.sev-btn.active { color: #fff; border-color: transparent; }
.sev-btn.active[data-severity="all"] { background: var(--accent); }
.sev-critical.active { background: var(--red); }
.sev-high.active { background: var(--orange); }
.sev-medium.active { background: #ca8a04; }
.sev-low.active { background: #3b82f6; }

/* ===== Threat Groups & Alert Cards ===== */
.threat-group { margin-bottom: 20px; }
.threat-group h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.alert-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 8px;
    border-left: 4px solid var(--border-strong);
    box-shadow: var(--shadow);
    transition: box-shadow .15s;
}
.alert-card:hover { box-shadow: var(--shadow-md); }
.alert-critical { border-left-color: var(--red); background: var(--red-bg); }
.alert-high { border-left-color: var(--orange); background: var(--orange-bg); }
.alert-medium { border-left-color: #ca8a04; background: rgba(202,138,4,.08); }
.alert-low { border-left-color: #3b82f6; background: rgba(59,130,246,.08); }
.alert-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-sev-tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 1px 6px;
    border-radius: 4px;
    color: #fff;
}
.alert-sev-tag.critical { background: var(--red); }
.alert-sev-tag.high { background: var(--orange); }
.alert-sev-tag.medium { background: #ca8a04; }
.alert-sev-tag.low { background: #3b82f6; }
.alert-detail {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.alert-detail strong { color: var(--text); }
.threat-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
}
.threat-pagination button {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
}
.threat-pagination button:hover { background: var(--bg-card-alt); }
.threat-pagination button:disabled { opacity: .4; cursor: default; }
.threat-pagination span { font-size: 12px; color: var(--text-muted); }

/* ===== Detail Table Pagination & Controls ===== */
.page-size-control {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}
.page-size-control select {
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
}
.detail-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
}
.detail-pagination button {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    transition: all .15s;
}
.detail-pagination button:hover { background: var(--bg-card-alt); color: var(--text); }
.detail-pagination button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.detail-pagination button:disabled { opacity: .4; cursor: default; }
.detail-pagination .pg-info { font-size: 12px; color: var(--text-muted); margin-right: 8px; }

/* Mini ratio bars in detail tables */
.rate-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}
.rate-cell span { font-size: 12px; min-width: 40px; }
.mini-bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    min-width: 40px;
    max-width: 80px;
}
.mini-bar-ok { background: var(--green); }
.mini-bar-fail { background: var(--red); }

/* ===== Threat Summary ===== */
.threat-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.threat-summary-cards {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 280px;
}
.threat-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    text-align: center;
    min-width: 100px;
    flex: 1;
    box-shadow: var(--shadow);
}
.threat-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}
.threat-stat-ip { font-size: 13px; font-family: monospace; }
.threat-stat-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--text-muted);
    margin-top: 2px;
}
.threat-stat-critical { border-top: 3px solid var(--red); }
.threat-stat-critical .threat-stat-value { color: var(--red); }
.threat-stat-high { border-top: 3px solid var(--orange); }
.threat-stat-high .threat-stat-value { color: var(--orange); }
.threat-stat-medium { border-top: 3px solid #ca8a04; }
.threat-stat-medium .threat-stat-value { color: #ca8a04; }
.threat-severity-chart-wrap {
    min-width: 260px;
    max-width: 400px;
    min-height: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

/* Threat group headers with counts */
.threat-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}
.threat-group-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
    padding: 0;
    border: none;
}
.threat-group-count {
    font-size: 11px;
    font-weight: 700;
    background: var(--accent);
    color: #fff;
    padding: 1px 7px;
    border-radius: 8px;
    min-width: 18px;
    text-align: center;
}
.threat-group-count:empty { display: none; }

/* ===== Expandable Threat Cards ===== */
.alert-card-wrap { margin-bottom: 8px; }
.alert-card-wrap .alert-card {
    margin-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
}
.alert-expand-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all .15s;
    user-select: none;
}
.alert-expand-bar:hover {
    background: var(--bg-card);
    color: var(--accent);
}
.alert-detail-panel {
    display: none;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--bg-card);
}
.alert-detail-panel.expanded {
    display: block;
}
.alert-card-wrap:has(.alert-detail-panel.expanded) .alert-expand-bar {
    border-radius: 0;
}

/* Threat detail panel content */
.threat-detail-grid {
    display: flex;
    gap: 16px;
    padding: 16px;
    flex-wrap: wrap;
}
.threat-detail-info {
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.threat-detail-stat {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}
.tdl { color: var(--text-muted); font-weight: 500; }
.tdv { font-weight: 600; color: var(--text); font-family: monospace; font-size: 11px; }
.threat-detail-chart-wrap {
    flex: 1;
    min-width: 280px;
    height: 200px;
    position: relative;
}
.threat-detail-chart-wrap h4 {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.threat-detail-bottom {
    display: flex;
    gap: 16px;
    padding: 0 16px 16px;
    flex-wrap: wrap;
}
.threat-detail-targets,
.threat-detail-methods { flex: 1; min-width: 200px; }
.threat-detail-targets h4,
.threat-detail-methods h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 8px;
}
.target-chips,
.method-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.target-chip,
.method-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.target-chip strong,
.method-chip strong {
    color: var(--text);
    font-weight: 700;
}

/* Loading spinner */
.detail-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    font-size: 12px;
    color: var(--text-muted);
}
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Geo Map ===== */
#geo-map {
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ===== Comparison ===== */
.comparison-form {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 18px;
}
.comparison-period {
    flex: 1;
    min-width: 240px;
}
.comparison-period h4 {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
.comparison-period label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin: 6px 0 2px;
}
.comparison-period input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 13px;
}
.comparison-period input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.comparison-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 18px 18px;
}
.comparison-card {
    background: var(--bg-card-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.comparison-card h4 {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.comparison-stats {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 8px;
}
.comparison-stat { min-width: 60px; }
.comparison-stat .value {
    font-size: 20px;
    font-weight: 700;
}
.comparison-stat .label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: .3px;
}

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.modal-overlay.visible { display: flex; }
.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 20px 24px;
    max-width: 380px;
    width: 90%;
    animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.shortcuts-table { width: 100%; }
.shortcuts-table td {
    padding: 6px 4px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.shortcuts-table td:first-child { white-space: nowrap; padding-right: 16px; }
kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-family: inherit;
    background: var(--kbd-bg);
    border: 1px solid var(--kbd-border);
    border-radius: 4px;
    box-shadow: 0 1px 0 var(--kbd-border);
}

/* ===== Upload Overlay ===== */
.upload-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(6px);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}
.upload-overlay.visible { display: flex; }
.upload-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 36px 48px;
    animation: modalIn .2s ease;
}
.upload-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.upload-status {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
}
.toast {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    background: #1e293b;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    transition: transform .3s cubic-bezier(.25,.8,.25,1);
    max-width: 300px;
}
.toast.show { transform: translateX(0); }
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }

/* ===== Footer ===== */
.app-footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: var(--text-muted);
}
.app-footer .sep { margin: 0 6px; }
.app-footer kbd { font-size: 10px; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .hero-title { font-size: 28px; }
    .hero-subtitle { font-size: 14px; }
    .hero-upload { padding: 28px 20px; }
    .filter-row { flex-direction: column; }
    .filter-field { min-width: 100%; }
    .filter-actions { justify-content: flex-start; }
    .stats-cards { flex-direction: column; }
    .stat-card { min-width: 100%; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .comparison-form { flex-direction: column; }
    .comparison-results { grid-template-columns: 1fr; }
    .meta-strip { flex-direction: column; }
    .tab-label { display: none; }
    .tab { padding: 10px 12px; }
    .threat-summary { flex-direction: column; }
    .threat-severity-chart-wrap { max-width: 100%; }
    .threat-detail-grid { flex-direction: column; }
    .threat-detail-bottom { flex-direction: column; }
}
