:root {
    --bg-primary: #0B0F19;
    --bg-secondary: #111827;
    --bg-elevated: #1F2937;
    --bg-glass: rgba(17, 24, 39, 0.7);
    --surface: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    --text-primary: #F9FAFB;
    --text-secondary: #9CA3AF;
    --text-tertiary: #6B7280;
    --accent: #818CF8;
    --accent-hover: #6366F1;
    --accent-glow: rgba(129, 140, 248, 0.3);
    --accent-subtle: rgba(129, 140, 248, 0.1);
    --green: #34D399;
    --green-subtle: rgba(52, 211, 153, 0.15);
    --red: #F87171;
    --red-subtle: rgba(248, 113, 113, 0.15);
    --blue: #60A5FA;
    --blue-subtle: rgba(96, 165, 250, 0.15);
    --orange: #FBBF24;
    --orange-subtle: rgba(251, 191, 36, 0.15);
    --gradient-1: linear-gradient(135deg, #818CF8 0%, #C084FC 100%);
    --gradient-2: linear-gradient(135deg, #34D399 0%, #60A5FA 100%);
    --gradient-3: linear-gradient(135deg, #F472B6 0%, #818CF8 100%);
    --shadow-glow: 0 0 20px rgba(129, 140, 248, 0.1);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ─── TYPOGRAPHY ─── */
h1, h2, h3, h4, h5 { color: var(--text-primary); font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-hover); }

/* ─── CONTAINER (Index Page) ─── */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 60px 24px;
}

header { text-align: center; margin-bottom: 48px; }

.logo {
    max-width: 180px;
    margin-bottom: 24px;
    filter: drop-shadow(0 0 12px rgba(129, 140, 248, 0.2));
}

.header-user-info {
    position: absolute;
    top: 20px;
    right: 24px;
}

/* ─── GLASS PANELS ─── */
.glass-panel, .card-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-card);
    margin-bottom: 28px;
}

/* ─── FORMS ─── */
.form-group { margin-bottom: 24px; }

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.required { color: var(--accent); }
.optional { color: var(--text-tertiary); font-size: 0.75rem; font-weight: 400; }

input[type="text"],
input[type="url"],
input[type="password"],
input[type="date"],
select,
.search-box {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

input:focus, select:focus, .search-box:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(255, 255, 255, 0.06);
}

select option {
    background: #1F2937;
    color: #F9FAFB;
    padding: 8px;
}

input::placeholder, .search-box::placeholder { color: var(--text-tertiary); }

/* ─── CHECKBOXES ─── */
.checkbox-group { display: flex; gap: 12px; flex-wrap: wrap; }

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    padding: 12px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.checkbox-label:hover { border-color: var(--border-light); background: var(--surface-hover); }
.checkbox-label input { display: none; }

.custom-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--text-tertiary);
    border-radius: 4px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.checkbox-label input:checked + .custom-checkbox {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-label input:checked + .custom-checkbox::after {
    content: '✓';
    color: white;
    font-size: 11px;
    font-weight: 700;
}

.checkbox-label:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--text-primary);
}

/* ─── BUTTONS ─── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    background: var(--gradient-1);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
    filter: brightness(1.1);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    background: var(--surface);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    width: auto;
}

.btn-secondary:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

/* ─── RESULTS ─── */
.hidden { display: none !important; }

.results-container {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-top: 24px;
    box-shadow: var(--shadow-card);
}

.results-container h2 {
    font-size: 1.15rem;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.link-item {
    background: var(--surface);
    padding: 18px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    word-break: break-all;
}

.link-platform {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 6px;
    display: block;
}

.link-url {
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.copy-btn {
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: var(--transition);
}

.copy-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.copy-btn.copied { background: var(--green); border-color: var(--green); color: #fff; }

/* ─── MODAL ─── */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-elevated);
    padding: 36px;
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-elevated);
    border: 1px solid var(--border-light);
}

.modal-content h3 { color: var(--red); margin-bottom: 16px; }
.modal-content p { margin-bottom: 24px; line-height: 1.6; color: var(--text-secondary); }
.modal-actions { display: flex; gap: 12px; }

/* ─── TABLES ─── */
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

th {
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
    background: transparent;
}

tr:hover td { background: var(--surface); }

/* ─── ADMIN SIDEBAR ─── */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 28px 24px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.sidebar-header img {
    max-width: 140px;
    margin-bottom: 16px;
    height: auto;
    filter: drop-shadow(0 0 8px rgba(129, 140, 248, 0.15));
}

.sidebar-header h2 {
    font-size: 1rem;
    color: var(--text-tertiary);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin: 0;
}

.sidebar-menu {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    cursor: pointer;
    border-left: 3px solid transparent;
    margin: 2px 0;
}

.menu-item:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.menu-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-left-color: var(--accent);
}

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

.user-profile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.user-profile strong { color: var(--text-primary); }

/* ─── ADMIN TOPBAR ─── */
.topbar {
    height: 64px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 32px;
}

/* ─── LEADERBOARD CARDS ─── */
.leaderboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.lb-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: var(--radius-md);
    text-align: center;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.lb-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-1);
}

.lb-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
    border-color: var(--border-light);
}

.lb-card h3 { font-size: 0.8rem; color: var(--text-tertiary); margin-bottom: 8px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.lb-card .lb-value { font-size: 2rem; font-weight: 700; background: var(--gradient-1); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.lb-card .lb-domain { font-size: 0.85rem; color: var(--text-secondary); margin-top: 8px; font-weight: 500; }

/* ─── FILTER PANEL ─── */
.filters-panel {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 28px;
    border: 1px solid var(--border);
}

.filter-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

/* ─── STAT BADGES ─── */
.stat-badges { display: flex; gap: 8px; align-items: center; }

.stat-badge {
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 9999px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.stat-badge.ad { background: var(--blue-subtle); color: var(--blue); }
.stat-badge.manual { background: var(--red-subtle); color: var(--red); }

/* ─── MISC ─── */
.admin-link-wrapper { text-align: center; margin-top: 24px; }
.admin-link { color: var(--accent); font-size: 0.9rem; font-weight: 500; }
.admin-link:hover { text-decoration: underline; }

.error-msg { color: var(--red); margin-bottom: 16px; text-align: center; }

.badge {
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge.meta { background: rgba(24, 119, 242, 0.2); color: #60A5FA; }
.badge.google { background: rgba(234, 67, 53, 0.15); color: #F87171; }
.badge.yandex { background: rgba(251, 191, 36, 0.15); color: #FBBF24; }

/* ─── MULTI-SELECT DROPDOWN ─── */
.multiselect {
    position: relative;
    display: inline-block;
}
.selectBox {
    position: relative;
    cursor: pointer;
}
.selectBox select {
    width: 100%;
    margin-bottom: 0;
}
.overSelect {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
}
.checkboxes {
    display: none;
    position: absolute;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-elevated);
    z-index: 100;
    width: 100%;
    min-width: 180px;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 4px;
}
.checkboxes label {
    display: block;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}
.checkboxes label:hover {
    background: var(--surface-hover);
}
.checkboxes input {
    margin-right: 8px;
    cursor: pointer;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 1024px) {
    .channels-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}
@media (max-width: 768px) {
    .container { padding: 24px 16px; }
    h1 { font-size: 1.3rem; }
    .glass-panel { padding: 20px; }
    .header-user-info { position: static; text-align: center; margin-bottom: 16px; }
    .channels-grid {
        grid-template-columns: 1fr !important;
    }
}
