:root {
    --bg-body: #0b1120;
    --bg-sidebar: #0f172a;
    --bg-card: #131c31;
    --bg-card-hover: #19243d;
    --bg-input: #0b1324;
    --border: #1e293b;
    --border-light: #334155;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --accent: #38bdf8;
    --accent-dark: #0284c7;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #a855f7;
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* Layout */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
}

.brand {
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    color: #fff;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
}

.brand-text h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
}
.brand-text span {
    font-size: 11px;
    color: var(--text-dim);
    display: block;
}

.nav-links {
    padding: 16px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    padding: 10px 10px 4px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.15s ease;
    text-decoration: none !important;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
}

.nav-item.active {
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.22);
}

.nav-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-badge {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 999px;
    font-weight: 600;
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

.main-area {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 62px;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-title h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content {
    padding: 26px 28px 48px;
    max-width: 1500px;
}

/* Cards & Grids */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}

.stat-label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin: 8px 0 4px;
    letter-spacing: -0.02em;
}

.stat-sub {
    font-size: 12px;
    color: var(--text-dim);
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 22px;
    overflow: hidden;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 20px;
}

.grid-equal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Tables */
.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 11px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.55);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(30, 41, 59, 0.65);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges & Pills */
.ip-pill {
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 12.5px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--border-light);
    padding: 3px 8px;
    border-radius: 6px;
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-clean {
    background: rgba(16, 185, 129, 0.14);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.28);
}

.badge-suspicious {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-spam, .badge-blocked {
    background: rgba(239, 68, 68, 0.16);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.32);
}

.badge-info {
    background: rgba(56, 189, 248, 0.14);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.28);
}

.badge-purple {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge-neutral {
    background: rgba(148, 163, 184, 0.12);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.22);
}

/* Forms & Inputs */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="url"],
select,
textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    border-radius: 7px;
    padding: 8px 12px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: #cbd5e1;
    margin-bottom: 6px;
}

.form-group small {
    display: block;
    color: var(--text-dim);
    font-size: 11.5px;
    margin-top: 4px;
}

.form-control-full {
    width: 100%;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none !important;
    white-space: nowrap;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-primary {
    background: var(--accent-dark);
    color: #fff;
}
.btn-primary:hover {
    background: #0369a1;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.16);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.35);
}
.btn-danger:hover {
    background: #dc2626;
    color: #fff;
}

.btn-secondary {
    background: #1e293b;
    color: #e2e8f0;
    border-color: var(--border-light);
}
.btn-secondary:hover {
    background: #334155;
}

.btn-success {
    background: rgba(16, 185, 129, 0.16);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.35);
}
.btn-success:hover {
    background: #059669;
    color: #fff;
}

/* Code blocks */
.code-box {
    background: #070d19;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 14px;
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 12.5px;
    color: #e2e8f0;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    position: relative;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 13.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.alert-success {
    background: rgba(16, 185, 129, 0.14);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #6ee7b7;
}
.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

/* Mini Bar Chart */
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    height: 170px;
    padding-top: 16px;
}
.chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}
.chart-bar-group {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    width: 100%;
    justify-content: center;
    height: 135px;
}
.chart-bar {
    width: 16px;
    border-radius: 4px 4px 0 0;
    min-height: 3px;
}
.chart-bar.traffic { background: #38bdf8; }
.chart-bar.threats { background: #ef4444; }
.chart-label {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-dim);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.78);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-backdrop.open {
    display: flex;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    width: 100%;
    max-width: 680px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.6);
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }

.reason-list {
    margin: 6px 0 0;
    padding-left: 18px;
    font-size: 12px;
    color: #fca5a5;
}
.reason-list li { margin-bottom: 2px; }

/* Auth Standalone Box */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top, #172554 0%, #0b1120 55%);
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    width: 100%;
    max-width: 430px;
    padding: 32px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
}

@media (max-width: 980px) {
    .sidebar { position: static; width: 100%; height: auto; }
    .app-shell { flex-direction: column; }
    .main-area { margin-left: 0; }
    .grid-2, .grid-equal { grid-template-columns: 1fr; }
}
