:root {
    --bg-base: #090d16;
    --bg-surface: #111827;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.08);
    --border-active: #3b82f6;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --purple: #8b5cf6;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

code, pre, .mono {
    font-family: 'JetBrains Mono', monospace;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Ambient Glow */
.ambient-glow {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 350px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.12) 0%, rgba(139, 92, 246, 0.05) 50%, transparent 80%);
    pointer-events: none;
    z-index: 0;
}

/* Header */
header {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(12px);
    background: rgba(9, 13, 22, 0.85);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #fff, #93c5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-subtitle {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-dot {
    width: 7px;
    height: 7px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 0.35rem 0.85rem;
    border-radius: 8px;
    font-size: 0.82rem;
}

.btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.5rem 1.1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

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

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

.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-main);
}

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

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 0.4rem;
    padding: 0.75rem 2rem 0;
    background: rgba(9, 13, 22, 0.5);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.7rem 1.2rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Main Container */
main {
    flex: 1;
    padding: 1.75rem 2rem 3rem;
    max-width: 1500px;
    width: 100%;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Custom Cyber Checkbox & Toggle Switch */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    background-color: rgba(15, 23, 42, 0.8);
    margin: 0;
    font: inherit;
    color: var(--primary);
    width: 1.15em;
    height: 1.15em;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    display: grid;
    place-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    vertical-align: middle;
    position: relative;
    flex-shrink: 0;
}

input[type="checkbox"]::before {
    content: "";
    width: 0.65em;
    height: 0.65em;
    transform: scale(0);
    transition: 0.15s transform ease-in-out;
    background-color: var(--primary);
    transform-origin: center;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

input[type="checkbox"]:checked {
    border-color: var(--primary);
    background-color: rgba(59, 130, 246, 0.15);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

input[type="checkbox"]:checked::before {
    transform: scale(1);
}

input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Switch Toggle Component */
.switch-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    user-select: none;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-slider {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.12);
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.switch-slider::before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: #fff;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.switch-toggle input:checked + .switch-slider {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
}

.switch-toggle input:checked + .switch-slider::before {
    transform: translateX(18px);
}

/* Drag & Drop Upload Zone */
.dropzone {
    border: 2px dashed rgba(59, 130, 246, 0.35);
    border-radius: 12px;
    padding: 2.25rem 1.5rem;
    text-align: center;
    background: rgba(59, 130, 246, 0.03);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
}

.dropzone-icon {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
}

/* Subpage Navigation Tabs */
.subnav-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    flex-wrap: wrap;
}

.subnav-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.45rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

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

.subnav-btn.active {
    color: #fff;
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
}

/* Metric Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin-top: 0.35rem;
    font-family: 'JetBrains Mono', monospace;
}

.stat-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
}

/* Content Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 1.75rem;
    backdrop-filter: blur(8px);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.01);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.card-body {
    padding: 1.5rem;
}

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

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

th {
    background: rgba(0, 0, 0, 0.25);
    padding: 0.85rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 0.95rem 1rem;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-main);
}

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

.badge {
    display: inline-block;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.badge-real {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-poison {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-music {
    background: rgba(139, 92, 246, 0.15);
    color: var(--purple);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.badge-auth {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Forms & Inputs */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.form-group {
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    padding: 0.65rem 0.9rem;
    border-radius: 8px;
    color: #fff;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1.5rem;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    from { transform: scale(0.94); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.15);
}

.qr-box {
    text-align: center;
    background: #fff;
    padding: 1rem;
    border-radius: 12px;
    margin: 1.25rem auto;
    display: inline-block;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.qr-box img {
    width: 170px;
    height: 170px;
    display: block;
}

.secret-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px dashed var(--border);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.95rem;
    text-align: center;
    letter-spacing: 0.15em;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 1.25rem;
    cursor: pointer;
}

/* Log Terminal */
.log-terminal {
    background: #06090e;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    max-height: 520px;
    overflow-y: auto;
    font-size: 0.8rem;
    line-height: 1.55;
}

.log-row {
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
}

.log-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.log-time {
    color: var(--text-dim);
    white-space: nowrap;
    font-size: 0.72rem;
}

.log-msg {
    color: var(--text-main);
    flex: 1;
    word-break: break-all;
}

/* Toast Notifications Container */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    width: calc(100% - 48px);
    pointer-events: none;
}

.toast {
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid var(--border);
    backdrop-filter: blur(12px);
    color: #fff;
    padding: 0.9rem 1.2rem;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    pointer-events: auto;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: all 0.3s ease;
}

.toast.hiding {
    opacity: 0;
    transform: translateX(40px) scale(0.95);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.toast-success {
    border-color: rgba(16, 185, 129, 0.4);
    border-left: 4px solid var(--success);
}
.toast-success .toast-icon { color: var(--success); }

.toast-error {
    border-color: rgba(239, 68, 68, 0.4);
    border-left: 4px solid var(--danger);
}
.toast-error .toast-icon { color: var(--danger); }

.toast-info {
    border-color: rgba(59, 130, 246, 0.4);
    border-left: 4px solid var(--primary);
}
.toast-info .toast-icon { color: var(--primary); }

.toast-warning {
    border-color: rgba(245, 158, 11, 0.4);
    border-left: 4px solid var(--warning);
}
.toast-warning .toast-icon { color: var(--warning); }

.toast-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
    line-height: 1.4;
}

