:root {
    --primary: #0078D4;
    --primary-dark: #005a9e;
    --secondary: #6c757d;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    --bg: #0a0e17;
    --bg-light: #0f1624;
    --text: #e9eef8;
    --text-muted: #a9b6cc;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Portal Layout */
.portal-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.3rem;
    font-weight: 700;
}

.logo-icon {
    font-size: 1.5rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
    overflow-y: auto;
}

.menu-section {
    margin-bottom: 2rem;
}

.menu-title {
    padding: 0 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.8rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.3s;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.menu-item.active {
    background: rgba(0, 120, 212, 0.15);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

.menu-icon {
    font-size: 1.2rem;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-logout {
    width: 100%;
    background: rgba(255, 59, 74, 0.1);
    border: 1px solid rgba(255, 59, 74, 0.3);
    color: #ffd0d4;
    padding: 0.7rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: rgba(255, 59, 74, 0.2);
}

/* Main Content */
.main-content {
    background: var(--bg);
    overflow-y: auto;
}

.page-header {
    padding: 2rem;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.page-header h1 {
    font-size: 1.8rem;
    margin: 0;
}

.page-content {
    padding: 2rem;
}

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

.stat-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 40px var(--shadow);
}

.stat-icon {
    font-size: 2.5rem;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

/* Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
}

.card {
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 2rem;
}

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

.card-header h3 {
    font-size: 1.2rem;
    margin: 0;
}

.card-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.card-link:hover {
    text-decoration: underline;
}

.card-body {
    padding: 1.5rem;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead th {
    text-align: left;
    padding: 0.8rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
}

.data-table tbody td {
    padding: 1rem 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

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

/* Badges */
.badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background: rgba(0, 120, 212, 0.2);
    color: var(--primary);
}

.badge-success {
    background: rgba(40, 167, 69, 0.2);
    color: var(--success);
}

.badge-warning {
    background: rgba(255, 193, 7, 0.2);
    color: var(--warning);
}

.badge-danger {
    background: rgba(220, 53, 69, 0.2);
    color: var(--danger);
}

.badge-secondary {
    background: rgba(108, 117, 125, 0.2);
    color: var(--secondary);
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.9rem 1.2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 1rem;
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    padding: 0.9rem 1.8rem;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 8px 20px rgba(0, 120, 212, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(0, 120, 212, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
    display: block;
}

/* Messages */
.error-message, .success-message, .alert {
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.error-message {
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #ffb3ba;
}

.success-message {
    background: rgba(40, 167, 69, 0.15);
    border: 1px solid rgba(40, 167, 69, 0.3);
    color: #b3ffb3;
}

.alert-warning {
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: #ffe9b3;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(1200px 600px at 50% 50%, rgba(0,120,212,0.25), transparent 70%), var(--bg);
}

.login-box {
    width: 100%;
    max-width: 440px;
    background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 30px 80px var(--shadow);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header .logo-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.login-header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-muted);
}

.login-demo {
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.login-demo p {
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.btn-demo {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    margin: 0.3rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.btn-demo:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

/* Utilities */
.mono {
    font-family: 'Courier New', monospace;
}

.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.keys-textarea {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    resize: vertical;
}

/* Responsive */
@media (max-width: 1024px) {
    .portal-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .dashboard-cards {
        grid-template-columns: 1fr;
    }
}
