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

:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f2e;
    --bg-card: #232b3b;
    --text-primary: #e6e9ed;
    --text-secondary: #8b929a;
    --accent: #3b82f6;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --critical: #dc2626;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

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

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--bg-card);
}

header h1 {
    font-size: 24px;
    font-weight: 600;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: 20px;
    font-size: 14px;
}

.status .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--warning);
    animation: pulse 2s infinite;
}

.status.connected .dot {
    background: var(--success);
    animation: none;
}

.status.error .dot {
    background: var(--danger);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.tab {
    padding: 12px 24px;
    background: var(--bg-card);
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.tab.active {
    background: var(--accent);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.banned { background: rgba(239, 68, 68, 0.2); }
.stat-icon.restricted { background: rgba(245, 158, 11, 0.2); }
.stat-icon.drop-cache { background: rgba(139, 92, 246, 0.2); }
.stat-icon.profiles { background: rgba(59, 130, 246, 0.2); }
.stat-icon.tcp { background: rgba(16, 185, 129, 0.2); }
.stat-icon.udp { background: rgba(236, 72, 153, 0.2); }
.stat-icon.subnet { background: rgba(99, 102, 241, 0.2); }
.stat-icon.dst { background: rgba(20, 184, 166, 0.2); }

.stat-icon::before {
    font-size: 20px;
}

.stat-icon.banned::before { content: '🚫'; }
.stat-icon.restricted::before { content: '⚠️'; }
.stat-icon.drop-cache::before { content: '🗑️'; }
.stat-icon.profiles::before { content: '👤'; }
.stat-icon.tcp::before { content: '🔗'; }
.stat-icon.udp::before { content: '📡'; }
.stat-icon.subnet::before { content: '🌐'; }
.stat-icon.dst::before { content: '🎯'; }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Section */
.section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.section h2 {
    font-size: 18px;
    margin-bottom: 20px;
}

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

.section-header h2 {
    margin-bottom: 0;
}

/* Info Box */
.info-box {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
}

.info-box .placeholder {
    color: var(--text-secondary);
}

.info-box .subnet-info {
    display: flex;
    gap: 30px;
    align-items: center;
}

.info-box .subnet-name {
    font-size: 18px;
    font-weight: 600;
}

.info-box .subnet-stat {
    display: flex;
    flex-direction: column;
}

.info-box .subnet-stat .value {
    font-size: 20px;
    font-weight: 600;
}

.info-box .subnet-stat .label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--bg-card);
}

th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
}

tbody tr:hover {
    background: var(--bg-card);
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn.primary {
    background: var(--accent);
    color: white;
}

.btn.primary:hover {
    background: #2563eb;
}

.btn.danger {
    background: var(--danger);
    color: white;
}

.btn.danger:hover {
    background: #dc2626;
}

.btn.warning {
    background: var(--warning);
    color: black;
}

.btn.warning:hover {
    background: #d97706;
}

.btn.success {
    background: var(--success);
    color: white;
}

.btn.success:hover {
    background: #059669;
}

.btn.refresh {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn.refresh:hover {
    background: var(--bg-primary);
}

.btn.small {
    padding: 4px 10px;
    font-size: 12px;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.critical {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
}

.status-badge.warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.status-badge.elevated {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
}

.status-badge.normal {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.status-badge.low {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.status-badge.medium {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.status-badge.high {
    background: rgba(249, 115, 22, 0.2);
    color: #fdba74;
}

.status-badge.active {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

.status-badge.mitigated {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
}

.status-badge.ended {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
}

/* Traffic Cards */
.traffic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.traffic-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    border-left: 4px solid transparent;
}

.traffic-card.clean {
    border-left-color: var(--success);
}

.traffic-card.dirty {
    border-left-color: var(--danger);
}

.traffic-card.ratio {
    border-left-color: var(--warning);
}

.traffic-icon {
    font-size: 36px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--bg-secondary);
}

.traffic-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.traffic-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.traffic-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.1;
}

.traffic-card.rx .traffic-value {
    color: #22c55e; /* Green for RX */
}

.traffic-card.tx .traffic-value {
    color: #3b82f6; /* Blue for TX */
}

.traffic-card.clean .traffic-value {
    color: var(--success);
}

.traffic-card.dirty .traffic-value {
    color: var(--danger);
}

.traffic-card.ratio .traffic-value {
    color: var(--warning);
}

.traffic-sub {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Chart Container */
.chart-container {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    height: 300px;
    position: relative;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Country Flag */
.country {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.country-code {
    font-weight: 600;
    font-size: 12px;
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--bg-card);
}

.modal-header h3 {
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-body h4 {
    margin: 20px 0 12px;
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.modal-body h4:first-child {
    margin-top: 0;
}

.detail-stats {
    display: flex;
    gap: 30px;
    background: var(--bg-card);
    padding: 16px 20px;
    border-radius: 8px;
}

.detail-stat {
    display: flex;
    flex-direction: column;
}

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

.detail-stat .value {
    font-size: 20px;
    font-weight: 600;
}

.ports-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.port-badge {
    background: var(--bg-card);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
}

.port-badge .port {
    font-weight: 600;
    margin-right: 8px;
}

.port-badge .count {
    color: var(--text-secondary);
}

/* Management Grid */
.manage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.manage-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
}

.manage-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
}

.manage-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.manage-card input {
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--bg-primary);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

.manage-card input:focus {
    outline: none;
    border-color: var(--accent);
}

.manage-card input::placeholder {
    color: var(--text-secondary);
}

.result-box {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 13px;
    min-height: 60px;
}

.result-box.error {
    border: 1px solid var(--danger);
    color: #fca5a5;
}

.result-box.success {
    border: 1px solid var(--success);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .tabs {
        justify-content: center;
    }

    .tab {
        padding: 10px 16px;
        font-size: 13px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .manage-grid {
        grid-template-columns: 1fr;
    }

    .info-box .subnet-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .detail-stats {
        flex-direction: column;
        gap: 12px;
    }
}

/* Clickable row for history table */
.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clickable-row:hover {
    background: rgba(59, 130, 246, 0.1) !important;
}

/* History extra info in modal */
.history-info {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.history-extra {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.history-extra .detail-stat {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: 8px;
    min-width: 150px;
}
