
:root {
    --bg: #0a0c0f;
    --surface: #111418;
    --surface2: #181c22;
    --border: #1e2530;
    --border2: #2a3340;
    --text: #c8d0dc;
    --text-dim: #5a6476;
    --text-bright: #e8edf5;
    --accent: #00d4ff;
    --accent-dim: #0099bb;
    --red: #ff4455;
    --orange: #ff8c42;
    --green: #00e87a;
    --yellow: #ffd166;
    --purple: #b57bee;
    --mono: 'IBM Plex Mono', monospace;
    --sans: 'Space Grotesk', sans-serif;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── HEADER ─── */
header {
    border-bottom: 1px solid var(--border);
    padding: 18px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.05em;
}
.logo span { color: var(--text-dim); font-weight: 300; }

.header-status {
    margin-left: auto;
    display: flex;
    gap: 20px;
    align-items: center;
    font-size: 11px;
    color: var(--text-dim);
}

.stat-pill {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 4px;
    padding: 3px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.stat-pill b { color: var(--text-bright); font-weight: 500; }

/* ─── MAIN LAYOUT ─── */
main {
    display: grid;
    grid-template-columns: 1fr;
    min-height: calc(100vh - 61px);
}

/* ─── UPLOAD ZONE ─── */
#upload-section {
    padding: 40px 28px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.section-label {
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.drop-zone {
    border: 1px dashed var(--border2);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface);
    position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: #0a1a20;
}
.drop-zone input[type=file] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

.drop-icon { font-size: 32px; margin-bottom: 12px; }

.drop-zone h3 {
    font-family: var(--sans);
    font-size: 16px;
    color: var(--text-bright);
    margin-bottom: 6px;
}
.drop-zone p { color: var(--text-dim); font-size: 12px; }

.or-divider {
    text-align: center;
    color: var(--text-dim);
    margin: 20px 0;
    font-size: 11px;
    position: relative;
}
.or-divider::before, .or-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 44%;
    height: 1px;
    background: var(--border);
}
.or-divider::before { left: 0; }
.or-divider::after { right: 0; }

textarea.log-textarea {
    width: 100%;
    height: 220px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    padding: 14px 16px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.6;
}
textarea.log-textarea:focus { border-color: var(--accent-dim); }
textarea.log-textarea::placeholder { color: var(--text-dim); }
.error-log-textarea { height: 170px; }
.log-field-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    margin-top: 18px;
}
.log-field-head .section-label { margin-bottom: 8px; }
.log-field-head span {
    color: var(--text-dim);
    font-size: 11px;
    text-align: right;
}

.btn-row { display: flex; gap: 10px; margin-top: 14px; align-items: center; }

button.btn-primary {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 5px;
    padding: 10px 24px;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.02em;
}
button.btn-primary:hover { background: #33ddff; transform: translateY(-1px); }
button.btn-primary:disabled { background: var(--border2); color: var(--text-dim); cursor: not-allowed; transform: none; }

button.btn-secondary {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border2);
    border-radius: 5px;
    padding: 10px 18px;
    font-family: var(--mono);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
button.btn-secondary:hover { color: var(--text); border-color: var(--border2); background: var(--surface2); }

.parse-info { font-size: 11px; color: var(--text-dim); margin-left: auto; }

/* ─── LOADING ─── */
#loading {
    display: none;
    text-align: center;
    padding: 60px 28px;
    color: var(--text-dim);
}
.spinner {
    width: 32px; height: 32px;
    border: 2px solid var(--border2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── RESULTS ─── */
#results { display: none; }

/* ─── SUMMARY CARDS ─── */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    padding: 24px 28px 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
}
.card-label { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px; }
.card-value { font-size: 22px; font-weight: 600; color: var(--text-bright); line-height: 1; }
.card-sub { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

.card.danger .card-value { color: var(--red); }
.card.warn .card-value { color: var(--orange); }
.card.ok .card-value { color: var(--green); }
.card.info .card-value { color: var(--accent); }

/* ─── TABS ─── */
.tabs {
    display: flex;
    gap: 0;
    padding: 20px 28px 0;
    border-bottom: 1px solid var(--border);
    margin-top: 20px;
}
.tab {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    user-select: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-pane { display: none; padding: 20px 28px; }
.tab-pane.active { display: block; }

/* ─── FILTER/SEARCH BAR ─── */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar input[type=text] {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 5px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    padding: 7px 12px;
    outline: none;
    flex: 1;
    min-width: 200px;
    transition: border-color 0.2s;
}
.filter-bar input:focus { border-color: var(--accent-dim); }

.filter-btn {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 11px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.filter-btn:hover, .filter-btn.active { color: var(--text-bright); border-color: var(--accent-dim); background: #0a1a20; }
.filter-btn.f-attacker.active { border-color: var(--red); color: var(--red); background: #1a0507; }
.filter-btn.f-suspicious.active { border-color: var(--orange); color: var(--orange); background: #1a0e05; }
.filter-btn.f-legitimate.active { border-color: var(--green); color: var(--green); background: #051a0c; }

/* ─── TABLE ─── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

thead th {
    background: var(--surface2);
    color: var(--text-dim);
    text-align: left;
    padding: 10px 14px;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}
thead th:hover { color: var(--text); }
thead th.sort-asc::after { content: ' ↑'; color: var(--accent); }
thead th.sort-desc::after { content: ' ↓'; color: var(--accent); }

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody tr.expanded { background: #0d1520; }

td { padding: 9px 14px; vertical-align: middle; }

.ip-cell { font-weight: 500; color: var(--text-bright); white-space: nowrap; }
.ip-cell a { color: inherit; text-decoration: none; }
.ip-cell a:hover { color: var(--accent); }

.badge {
    display: inline-block;
    border-radius: 3px;
    padding: 2px 7px;
    font-size: 10px;
    letter-spacing: 0.06em;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-attacker { background: #2a0508; color: var(--red); border: 1px solid #3d0a0f; }
.badge-suspicious { background: #2a1505; color: var(--orange); border: 1px solid #3d2008; }
.badge-legitimate { background: #051a0c; color: var(--green); border: 1px solid #0a2e15; }

.threat-bar-wrap { width: 70px; display: inline-flex; align-items: center; gap: 6px; }
.threat-bar { height: 4px; border-radius: 2px; flex: 1; background: var(--border2); position: relative; overflow: hidden; }
.threat-bar-fill { height: 100%; border-radius: 2px; transition: width 0.4s; }
.threat-score-val { font-size: 11px; color: var(--text-dim); width: 24px; text-align: right; }

.bytes-cell { color: var(--text-dim); white-space: nowrap; }

.geo-cell { color: var(--text-dim); font-size: 11px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flag-img { width: 16px; height: 16px; border-radius: 50%; vertical-align: -3px; box-shadow: 0 0 0 1px rgba(255,255,255,0.08); }
.geo-flag { margin-right: 6px; }
.ip-flag { display: inline-block; width: 22px; margin-right: 6px; text-align: center; }
.subnet-title { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.subnet-title h4 { margin-bottom: 0; }
.subnet-heading { min-width: 0; }
.subnet-hostname {
    color: var(--text-dim);
    font-size: 11px;
    line-height: 1.35;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.subnet-flags { display: inline-flex; align-items: center; gap: 3px; min-width: 18px; white-space: nowrap; }
.subnet-flags .flag-img { width: 15px; height: 15px; }

.expand-btn {
    background: none;
    border: 1px solid var(--border2);
    color: var(--text-dim);
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    padding: 2px 6px;
    font-family: var(--mono);
}
.expand-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ─── EXPANDED ROW ─── */
.detail-row td {
    padding: 0;
    background: #090c10;
    border-bottom: 1px solid var(--border);
}
.detail-inner {
    padding: 16px 20px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}
.detail-section h4 {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.detail-section pre {
    font-size: 11px;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.7;
    max-height: 140px;
    overflow-y: auto;
}
.detail-section pre::-webkit-scrollbar { width: 4px; }
.detail-section pre::-webkit-scrollbar-track { background: var(--surface); }
.detail-section pre::-webkit-scrollbar-thumb { background: var(--border2); }

/* ─── GEO STATUS ─── */
.geo-loading { color: var(--text-dim); font-style: italic; font-size: 11px; }
.geo-progress-wrap {
    display: none;
    padding: 10px 28px 0;
}
.geo-progress-line {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: var(--text-dim);
}
.geo-progress-track {
    flex: 1;
    height: 4px;
    background: var(--border2);
    border-radius: 2px;
    overflow: hidden;
}
.geo-progress-fill {
    width: 0%;
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.25s ease;
}
.geo-progress-text { min-width: 180px; text-align: right; }

/* ─── SUBNET TAB ─── */
.subnet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
}
.subnet-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px 16px;
    transition: border-color 0.15s;
}
.subnet-card:hover { border-color: var(--border2); }
.subnet-card h4 { font-size: 13px; color: var(--text-bright); margin-bottom: 8px; font-weight: 500; }
.subnet-meta { display: flex; gap: 14px; flex-wrap: wrap; }
.subnet-meta span { font-size: 11px; color: var(--text-dim); }
.subnet-meta b { color: var(--text); }
.subnet-bar-wrap { margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.subnet-bar { flex: 1; height: 3px; background: var(--border2); border-radius: 2px; overflow: hidden; }
.subnet-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; }

/* ─── TIMELINE ─── */
.timeline-wrap {
    padding: 22px 28px 0;
    touch-action: none;
}
.timeline-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}
.timeline-head .section-label { margin-bottom: 5px; }
.timeline-range {
    color: var(--text-bright);
    font-size: 12px;
    line-height: 1.4;
}
canvas#timeline-chart {
    width: 100%;
    height: 150px;
    display: block;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: crosshair;
    user-select: none;
}

/* ─── EMPTY STATE ─── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
    font-size: 12px;
}

/* ─── SCROLL ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a4455; }

/* ─── ANIMATIONS ─── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

@media (max-width: 900px) {
    .detail-inner { grid-template-columns: 1fr; }
    .log-field-head {
        display: block;
    }
    .log-field-head span {
        display: block;
        text-align: left;
        margin: -4px 0 8px;
    }
}
