:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-main: #f8fafc;
    --sidebar-bg: #0f172a;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

.app-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar Styles */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: white;
    padding: 25px 20px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar-brand {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #818cf8;
    margin-bottom: 40px;
}

.sidebar-brand div {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-close-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.sidebar-menu li a {
    color: #94a3b8;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
}

.sidebar-menu li.active a, .sidebar-menu li a:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.sidebar-menu .logout-link {
    color: #f87171;
    margin-top: auto;
}

/* Main Content Styles */
.main-content {
    flex: 1;
    padding: 30px 40px;
    overflow-x: hidden;
    max-width: 100%;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 15px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mobile-menu-btn {
    display: none;
    background: white;
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-main);
}

.topbar-title h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
}

.topbar-title p {
    margin: 4px 0 0 0;
    color: var(--text-muted);
    font-size: 14px;
}

.topbar-user {
    background: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    display: inline-block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
}

.stat-icon.blue { background: #3b82f6; }
.stat-icon.green { background: #10b981; }
.stat-icon.red { background: #ef4444; }

.stat-info h3 { margin: 0; font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-info p { margin: 4px 0 0 0; font-size: 22px; font-weight: 700; color: var(--text-main); }

/* Panel Cards */
.panel-card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 30px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.panel-header h2 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    transition: all 0.2s;
}

.form-group input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 11px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover { background: var(--primary-dark); }

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 650px;
}

.modern-table th {
    background: #f1f5f9;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}

.modern-table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

.key-tag {
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
    word-break: break-all;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.badge.active { background: #d1fae5; color: #065f46; }
.badge.blocked { background: #fee2e2; color: #991b1b; }

.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-sm {
    padding: 6px 10px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    color: white;
    font-size: 13px;
    transition: opacity 0.2s;
}

.btn-sm:hover { opacity: 0.85; }
.btn-success { background: var(--success); }
.btn-warning { background: var(--warning); }
.btn-danger { background: var(--danger); }

/* Alerts & API box */
.alert-banner {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 25px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-banner.success { background: #d1fae5; color: #065f46; }

.api-box { background: #0f172a; color: white; }
.api-box h2 { color: #f8fafc; }
.api-box p { color: #94a3b8; font-size: 13px; }

.code-snippet {
    background: rgba(255,255,255,0.06);
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    gap: 15px;
    flex-wrap: wrap;
}

.code-snippet code {
    color: #38bdf8;
    font-family: monospace;
    font-size: 13px;
    word-break: break-all;
}

.btn-copy {
    background: #334155;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.btn-copy:hover { background: #475569; }

/* Login Page */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--sidebar-bg);
    padding: 20px;
}

.auth-card {
    background: #1e293b;
    padding: 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

.auth-logo { text-align: center; margin-bottom: 30px; }
.auth-logo h2 { color: white; margin: 0; font-size: 24px; }
.auth-logo p { color: #94a3b8; margin: 5px 0 0 0; font-size: 13px; }

.input-group { margin-bottom: 20px; }
.input-group label { display: block; color: #94a3b8; font-size: 12px; text-transform: uppercase; font-weight: 600; margin-bottom: 8px; }
.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    color: white;
    font-size: 14px;
}
.input-group input:focus { border-color: #818cf8; outline: none; }

.btn-glow {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.2s;
}

.btn-glow:hover { background: var(--primary-dark); }

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Responsive Media Queries */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100%;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    .sidebar.open {
        left: 0;
    }
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .mobile-close-btn {
        display: block;
    }
    .main-content {
        padding: 20px 15px;
    }
}

@media (max-width: 576px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .topbar-user {
        align-self: flex-start;
    }
    .auth-card {
        padding: 25px 20px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
}