@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@600;700&display=swap');

:root {
    --bg: #0a0b10;
    --bg-alt: #0d0f16;
    --surface: rgba(26, 29, 39, 0.6);
    --surface-solid: #151824;
    --surface-hover: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #f0f1f5;
    --text-muted: #8b8fa3;
    --text-dim: #5b5f72;
    --primary: #7c6cf6;
    --primary-2: #a78bfa;
    --primary-hover: #6d5cf0;
    --green: #2dd4a7;
    --red: #f4506e;
    --orange: #f5a623;
    --blue: #4d9eff;
    --purple: #b565f3;
    --cyan: #22d3ee;
    --radius: 16px;
    --radius-sm: 10px;
    --sidebar-w: 252px;
    --shadow-glow: 0 0 0 1px rgba(255,255,255,0.04), 0 8px 30px rgba(0,0,0,0.5);
    --transition: cubic-bezier(0.22, 1, 0.36, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    background-image:
        radial-gradient(circle at 15% 0%, rgba(124, 108, 246, 0.12) 0%, transparent 45%),
        radial-gradient(circle at 85% 15%, rgba(34, 211, 238, 0.08) 0%, transparent 45%),
        radial-gradient(circle at 50% 100%, rgba(181, 101, 243, 0.06) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text);
    overflow: hidden;
    letter-spacing: -0.01em;
}

.app { display: flex; height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, rgba(21,24,36,0.9) 0%, rgba(13,15,22,0.9) 100%);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.sidebar-header {
    padding: 26px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    font-size: 22px;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--cyan));
    box-shadow: 0 4px 16px rgba(124, 108, 246, 0.4);
}
.logo-text {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 30%, var(--text-muted));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu { padding: 18px 14px; display: flex; flex-direction: column; gap: 3px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    position: relative;
    transition: all 0.2s var(--transition);
}

.nav-item:hover { background: var(--surface-hover); color: var(--text); transform: translateX(2px); }
.nav-item.active {
    background: linear-gradient(135deg, rgba(124,108,246,0.18), rgba(34,211,238,0.10));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(124,108,246,0.35);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -14px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 60%;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--primary), var(--cyan));
}
.nav-icon { font-size: 17px; width: 20px; text-align: center; filter: saturate(1.3); }

/* ── Main Content ────────────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }

.topbar {
    height: 72px;
    background: rgba(13, 15, 22, 0.7);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    flex-shrink: 0;
    z-index: 5;
}

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

.topbar-left h1 {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.topbar-right { display: flex; align-items: center; gap: 18px; }

.date-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-solid);
    padding: 5px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.date-input {
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 6px 8px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    font-family: inherit;
}
.date-input::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }
.date-sep { color: var(--text-dim); font-size: 13px; }

.site-selector { display: flex; align-items: center; gap: 8px; }
.site-selector label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.select {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 14px;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}
.select:hover, .select:focus { border-color: var(--primary); }

.btn {
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s var(--transition);
    font-family: inherit;
}
.btn-ghost {
    background: var(--surface-solid);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }

/* ── Tab Content ─────────────────────────────────────────── */
.tab-content { display: none; flex: 1; overflow-y: auto; padding: 28px; }
.tab-content.active { display: block; animation: fadeIn 0.35s var(--transition); }

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

/* ── Stat Cards ──────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: linear-gradient(160deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-glow);
}
.stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 100% 0%, rgba(124,108,246,0.10), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
}
.stat-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-4px);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 16px 40px rgba(0,0,0,0.55);
}
.stat-card:hover::after { opacity: 1; }

.stat-icon {
    width: 50px; height: 50px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}
.stat-blue { background: linear-gradient(135deg, rgba(77,158,255,0.25), rgba(77,158,255,0.05)); box-shadow: inset 0 0 0 1px rgba(77,158,255,0.3); }
.stat-green { background: linear-gradient(135deg, rgba(45,212,167,0.25), rgba(45,212,167,0.05)); box-shadow: inset 0 0 0 1px rgba(45,212,167,0.3); }
.stat-purple { background: linear-gradient(135deg, rgba(181,101,243,0.25), rgba(181,101,243,0.05)); box-shadow: inset 0 0 0 1px rgba(181,101,243,0.3); }
.stat-orange { background: linear-gradient(135deg, rgba(245,166,35,0.25), rgba(245,166,35,0.05)); box-shadow: inset 0 0 0 1px rgba(245,166,35,0.3); }
.stat-red { background: linear-gradient(135deg, rgba(244,80,110,0.25), rgba(244,80,110,0.05)); box-shadow: inset 0 0 0 1px rgba(244,80,110,0.3); }
.stat-cyan { background: linear-gradient(135deg, rgba(34,211,238,0.25), rgba(34,211,238,0.05)); box-shadow: inset 0 0 0 1px rgba(34,211,238,0.3); }

.stat-value {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    position: relative; z-index: 1;
}
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 3px; font-weight: 500; position: relative; z-index: 1; }

/* ── Charts ──────────────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.chart-card {
    background: linear-gradient(160deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-glow);
    transition: border-color 0.3s;
}
.chart-card:hover { border-color: var(--border-strong); }
.chart-card h3 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 18px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.chart-card canvas { max-height: 260px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-container {
    background: linear-gradient(160deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-glow);
}

.data-table { width: 100%; border-collapse: collapse; }

.data-table thead { background: rgba(255,255,255,0.02); }
.data-table th {
    padding: 15px 18px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 18px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    color: var(--text);
}
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: rgba(45,212,167,0.15); color: var(--green); box-shadow: inset 0 0 0 1px rgba(45,212,167,0.25); }
.badge-failed { background: rgba(244,80,110,0.15); color: var(--red); box-shadow: inset 0 0 0 1px rgba(244,80,110,0.25); }
.badge-warning { background: rgba(245,166,35,0.15); color: var(--orange); box-shadow: inset 0 0 0 1px rgba(245,166,35,0.25); }
.badge-info { background: rgba(77,158,255,0.15); color: var(--blue); box-shadow: inset 0 0 0 1px rgba(77,158,255,0.25); }

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 0 8px;
}

.page-btn {
    min-width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-solid);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s var(--transition);
}
.page-btn:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--primary-2); transform: translateY(-1px); }
.page-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 14px rgba(124,108,246,0.45);
}
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.page-info { font-size: 13px; color: var(--text-muted); margin: 0 14px; font-weight: 500; }

/* ── Loaders ─────────────────────────────────────────────── */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 11, 16, 0.55);
    backdrop-filter: blur(3px);
    border-radius: inherit;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.loading-overlay.active { opacity: 1; pointer-events: all; }

.spinner {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary-2);
    border-right-color: var(--cyan);
    animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }

@keyframes spin { to { transform: rotate(360deg); } }

.stat-card, .chart-card, .table-container { position: relative; }

.stat-value.is-loading, .stat-value:empty {
    display: inline-block;
    min-width: 40px;
    height: 22px;
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-row td {
    padding: 14px 18px;
}
.skeleton-bar {
    height: 14px;
    width: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease infinite;
}

.topbar-loader {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.15);
    border-top-color: var(--primary-2);
    animation: spin 0.6s linear infinite;
    display: none;
}
.topbar-loader.active { display: inline-block; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
    .charts-grid { grid-template-columns: 1fr; }
    .sidebar { width: 68px; }
    .logo-text, .nav-item span:not(.nav-icon) { display: none; }
    .nav-item { justify-content: center; }
    .date-filters { display: none; }
}
