:root {
    --primary: #5e17eb; /* Volinq Purple */
    --primary-hover: #4b12bd;
    --bg-dark: #0f111a;
    --bg-card: rgba(25, 28, 41, 0.6);
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.08);
    --blue: #3b82f6;
    --green: #10b981;
    --purple: #8b5cf6;
    --orange: #f59e0b;
    --red: #ef4444;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Glassmorphism utilities */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
}
.screen.active {
    display: flex;
}

/* Login */
#login-screen {
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, rgba(94, 23, 235, 0.15), transparent 40%);
}
.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.logo-container {
    text-align: center;
    margin-bottom: 32px;
}
.logo {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    margin: 0 auto 16px;
}
.logo-container h2 {
    font-size: 24px;
    margin-bottom: 8px;
}
.logo-container p {
    color: var(--text-muted);
    font-size: 14px;
}
.input-group {
    margin-bottom: 20px;
}
.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-muted);
}
.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
    font-size: 15px;
    transition: all 0.2s;
}
.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(94, 23, 235, 0.05);
}
.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary:hover {
    background: var(--primary-hover);
}
.error-msg {
    color: var(--red);
    font-size: 13px;
    text-align: center;
    margin-bottom: 16px;
    min-height: 16px;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* Dashboard Layout */
#dashboard-screen {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
    z-index: 10;
}
.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo-small {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}
.sidebar-nav {
    padding: 16px;
    flex: 1;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 8px;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-item svg {
    width: 20px;
    height: 20px;
}
.nav-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}
.nav-item.active {
    color: white;
    background: var(--primary);
}
.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
}
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.avatar {
    width: 40px;
    height: 40px;
    background: var(--blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}
.user-info {
    display: flex;
    flex-direction: column;
}
.user-info #user-name {
    font-weight: 600;
    font-size: 14px;
}
.role-badge {
    font-size: 11px;
    color: var(--orange);
    background: rgba(245, 158, 11, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
    margin-top: 4px;
}
.btn-ghost {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.top-header {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-radius: 0;
    border-top: none;
    border-right: none;
    border-left: none;
    z-index: 5;
}
.top-header h2 {
    font-size: 20px;
    font-weight: 600;
}
select {
    background: rgba(0, 0, 0, 0.3);
    color: white;
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
}
select option {
    background: var(--bg-dark);
}

.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

/* Sections */
.page-section {
    display: none;
    animation: fadeIn 0.3s ease;
}
.page-section.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Referral Link Widget */
.ref-widget {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    background: linear-gradient(to right, rgba(25, 28, 41, 0.8), rgba(94, 23, 235, 0.1));
}
.ref-info h3 {
    margin-bottom: 4px;
}
.ref-info p {
    color: var(--text-muted);
    font-size: 14px;
}
.ref-copy-box {
    display: flex;
    gap: 8px;
    align-items: center;
}
.ref-copy-box input {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 10px 16px;
    border-radius: 8px;
    width: 300px;
}
.ref-copy-box button {
    width: auto;
    padding: 10px 20px;
}
.ref-code-box {
    background: rgba(0,0,0,0.3);
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px dashed var(--primary);
    color: var(--text-muted);
}
.ref-code-box strong {
    color: white;
    font-size: 18px;
    letter-spacing: 1px;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}
.metric-card {
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.metric-card.highlight {
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.1);
}
.metric-card.warning {
    border-color: rgba(245, 158, 11, 0.3);
}
.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.metric-icon svg {
    width: 24px;
    height: 24px;
}
.metric-icon.blue { background: rgba(59, 130, 246, 0.1); color: var(--blue); }
.metric-icon.green { background: rgba(16, 185, 129, 0.1); color: var(--green); }
.metric-icon.purple { background: rgba(139, 92, 246, 0.1); color: var(--purple); }
.metric-icon.orange { background: rgba(245, 158, 11, 0.1); color: var(--orange); }

.metric-info {
    display: flex;
    flex-direction: column;
}
.metric-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}
.metric-value {
    font-size: 28px;
    font-weight: 700;
}
.metric-sub {
    font-size: 11px;
    color: var(--orange);
    margin-top: 4px;
}

/* Dashboard Row (Chart + Performance) */
.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}
.chart-container, .performance-container {
    padding: 24px;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.section-header h3 {
    font-size: 16px;
    font-weight: 600;
}
.perf-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.perf-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}
.perf-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.perf-label {
    font-size: 14px;
    color: var(--text-muted);
}
.perf-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    font-size: 16px;
}
.perf-stat svg {
    width: 16px;
    height: 16px;
}
.perf-stat.positive { color: var(--green); }
.perf-stat.negative { color: var(--red); }
.perf-stat.neutral { color: var(--text-muted); }

/* Tables */
.full-height {
    min-height: calc(100vh - 140px);
    padding: 24px;
}
.status-legend {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.dot.active { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.inactive { background: var(--text-muted); }

.table-responsive {
    overflow-x: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.data-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.data-table tbody tr {
    transition: background 0.2s;
}
.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}
.data-table td {
    font-size: 14px;
}
.empty-row td {
    text-align: center;
    color: var(--text-muted);
    padding: 32px !important;
}

/* Terms */
.content-box {
    max-width: 800px;
    margin: 0 auto;
}
.terms-content {
    margin-top: 24px;
    color: var(--text-muted);
    line-height: 1.6;
}
.terms-content h4 {
    color: white;
    margin: 24px 0 12px;
    font-size: 16px;
}
.terms-content ul {
    margin-left: 20px;
    margin-bottom: 16px;
}
.terms-content li {
    margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-row {
        grid-template-columns: 1fr;
    }
    .ref-widget {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .ref-copy-box input {
        width: 100%;
    }
}
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        height: 100vh;
        transition: left 0.3s ease;
    }
    .sidebar.open {
        left: 0;
    }
    /* Add a hamburger menu for mobile */
    .top-header {
        padding: 0 16px;
    }
}
