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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #ffffff;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    color: #667eea;
}

.subtitle {
    color: #a0aec0;
    font-size: 1.1em;
}

.tagline {
    color: #667eea;
    font-size: 0.95em;
    font-style: italic;
    margin-top: 8px;
    opacity: 0.9;
}

/* Top Section - Two Column Layout */
.top-section {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.search-section {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 25px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.metadata-section {
    flex: 0 0 400px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    display: none;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#searchInput {
    flex: 1;
    padding: 12px 20px;
    font-size: 16px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    outline: none;
    font-family: monospace;
}

#searchInput::placeholder {
    color: #a0aec0;
}

#searchInput:focus {
    border-color: #764ba2;
    background: rgba(255, 255, 255, 0.15);
}

.btn {
    padding: 12px 30px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.examples {
    color: #a0aec0;
    font-size: 14px;
}

.examples strong {
    color: #ffffff;
}

.examples code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    color: #667eea;
}

#statusMessage {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    display: none;
}

#statusMessage.info {
    background: rgba(102, 126, 234, 0.2);
    border: 1px solid #667eea;
    color: #a3b8ff;
}

#statusMessage.error {
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid #ff6b6b;
    color: #ffa5a5;
}

#statusMessage.success {
    background: rgba(81, 207, 102, 0.2);
    border: 1px solid #51cf66;
    color: #a3e7b0;
}

.metadata-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metadata-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
}

.metadata-label {
    color: #a0aec0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.metadata-value {
    font-size: 18px;
    font-weight: 600;
    color: #667eea;
}

.controls {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: none;
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    color: #a0aec0;
    font-size: 14px;
    white-space: nowrap;
}

.control-group select {
    padding: 8px 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

#visualization {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    position: relative;
}

#threejs-container {
    width: 100%;
    height: 700px;
    border-radius: 8px;
    background: #0f1419;
    position: relative;
}

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Statistics Panel */
.statistics {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.statistics h2 {
    color: #667eea;
    font-size: 1.5em;
    margin-bottom: 15px;
}

.statistics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
}

.stat-label {
    color: #a0aec0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 20px;
    font-weight: 600;
    color: #667eea;
}

/* Distribution Section */
.distribution-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.distribution-section h3 {
    color: #667eea;
    font-size: 1.2em;
    margin-bottom: 15px;
}

.distribution-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.dist-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.dist-label {
    color: #a0aec0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.dist-value {
    font-size: 18px;
    font-weight: 600;
    color: #51cf66;
}

/* Port List Section */
.port-list-section {
    margin-top: 20px;
}

.port-list-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.port-list-header:hover {
    background: rgba(255, 255, 255, 0.15);
}

.collapse-icon {
    font-size: 12px;
    color: #667eea;
    transition: transform 0.2s ease;
}

.port-list-container {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.port-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
    transition: background 0.2s ease;
}

.port-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.port-number {
    color: #667eea;
    font-weight: 600;
}

.port-desc {
    color: #a0aec0;
    font-weight: 400;
    font-size: 11px;
}

.port-count {
    color: #ffffff;
}

.show-more-btn {
    width: 100%;
    margin-top: 10px;
}

/* IP Filters Section (directly below visualization) */
.ip-filters-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    margin-top: 20px;
    margin-bottom: 20px;
    display: none;
}

.ip-filters-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ip-filters-header:hover {
    background: rgba(255, 255, 255, 0.15);
}

.ip-filters-header strong {
    color: #ffffff;
}

.ip-filters-content {
    padding: 15px 20px;
}

.ip-toggles-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ip-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(102, 126, 234, 0.3);
    font-size: 12px;
    font-family: monospace;
    transition: all 0.2s ease;
}

.ip-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #667eea;
}

.ip-toggle input[type="checkbox"] {
    margin-right: 6px;
}

.ip-color-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Data Table Section */
.data-table-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.data-table-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.data-table-header:hover {
    background: rgba(255, 255, 255, 0.15);
}

.data-table-header strong {
    color: #ffffff;
}

.row-count {
    color: #a0aec0;
    font-size: 13px;
    margin-left: 10px;
}

.data-table-wrapper {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: auto;
    margin: 15px 20px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: monospace;
    font-size: 12px;
    min-width: 100%;
}

.data-table thead {
    position: sticky;
    top: 0;
    background: rgba(102, 126, 234, 0.3);
    z-index: 10;
}

.data-table th {
    padding: 10px 12px;
    text-align: left;
    color: #667eea;
    font-weight: 600;
    border-bottom: 2px solid rgba(102, 126, 234, 0.4);
    white-space: nowrap;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #ffffff;
    vertical-align: top;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.08);
}

.ip-cell {
    font-weight: 500;
    color: #51cf66;
}

.port-cell {
    color: #667eea;
}

.timestamp-cell {
    color: #a0aec0;
    white-space: nowrap;
    font-size: 11px;
}

.data-cell {
    color: #e0e0e0;
}

.load-more-row {
    background: rgba(255, 255, 255, 0.02) !important;
}

.load-more-row td {
    padding: 15px;
    text-align: center;
    border: none;
}

.load-more-row .load-more-btn {
    width: 100%;
    max-width: 400px;
}

/* Cowrie Honeypot Section */
.cowrie-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 30px;
    margin-top: 40px;
    border: 2px solid rgba(102, 126, 234, 0.3);
}

.cowrie-header {
    text-align: center;
    margin-bottom: 30px;
}

.cowrie-header h2 {
    color: #667eea;
    font-size: 2em;
    margin-bottom: 10px;
}

.cowrie-search {
    max-width: 900px;
    margin: 0 auto 30px;
}

.cowrie-search .search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.cowrie-search input[type="text"] {
    flex: 1;
    padding: 12px 20px;
    font-size: 16px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    outline: none;
    font-family: monospace;
}

.cowrie-search input[type="text"]::placeholder {
    color: #a0aec0;
}

.cowrie-search input[type="text"]:focus {
    border-color: #764ba2;
    background: rgba(255, 255, 255, 0.15);
}

.status-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
}

.status-loading {
    background: rgba(102, 126, 234, 0.2);
    border: 1px solid #667eea;
    color: #a3b8ff;
}

.status-error {
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid #ff6b6b;
    color: #ffa5a5;
}

.status-success {
    background: rgba(81, 207, 102, 0.2);
    border: 1px solid #51cf66;
    color: #a3e7b0;
}

.status-warning {
    background: rgba(255, 193, 7, 0.2);
    border: 1px solid #ffc107;
    color: #ffe082;
}

#cowrieResults {
    margin-top: 30px;
}

#cowrieMetadata {
    margin-bottom: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.cowrie-table-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    margin-top: 20px;
}

.event-badge {
    background: rgba(102, 126, 234, 0.3);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #a3b8ff;
    white-space: nowrap;
}

.message-cell {
    max-width: 600px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #a0aec0;
    font-size: 11px;
    line-height: 1.4;
}

.username-cell {
    max-width: 300px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #51cf66;
    font-weight: 500;
    font-size: 11px;
    line-height: 1.4;
}

.password-cell {
    max-width: 300px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #ff6b6b;
    font-weight: 500;
    font-size: 11px;
    font-family: monospace;
    line-height: 1.4;
}

.session-cell {
    color: #667eea;
    font-family: monospace;
    font-size: 11px;
    white-space: nowrap;
}

.ip-cell {
    white-space: nowrap;
    font-family: monospace;
    color: #51cf66;
    font-weight: 500;
}

.extra-cell {
    text-align: center;
    cursor: help;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .top-section {
        flex-direction: column;
    }

    .metadata-section {
        flex: 1;
    }

    .metadata-grid {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .metadata-item {
        flex: 1 1 calc(50% - 6px);
        min-width: 150px;
    }

    .data-table-wrapper {
        max-height: 400px;
    }

    .cowrie-section {
        padding: 20px;
    }

    .message-cell {
        max-width: 300px;
    }

    .username-cell {
        max-width: 150px;
    }

    .password-cell {
        max-width: 150px;
    }
}

/* ===== TABLE FILTER & SORT STYLES ===== */

/* Filter row */
.filter-row {
    background: #2d3748;
}

.filter-cell {
    padding: 4px 8px;
}

.column-filter {
    width: 100%;
    padding: 6px 8px;
    background: #1a202c;
    border: 1px solid #4a5568;
    border-radius: 4px;
    color: #e2e8f0;
    font-size: 12px;
    transition: border-color 0.2s, background 0.2s;
}

.column-filter:focus {
    outline: none;
    border-color: #4299e1;
    background: #2d3748;
}

.column-filter::placeholder {
    color: #718096;
}

/* Sort indicators */
.sortable {
    user-select: none;
    transition: background 0.2s;
}

.sortable:hover {
    background: #374151;
}

.sort-indicator {
    margin-left: 4px;
    color: #718096;
    font-size: 14px;
    transition: color 0.2s;
}

/* Clear filters button */
.clear-filters-btn {
    display: inline-block;
    margin-left: 10px;
    padding: 6px 12px;
    background: #4299e1;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.2s;
}

.clear-filters-btn:hover {
    background: #3182ce;
}

.clear-filters-btn:active {
    background: #2c5282;
}
