/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(18, 18, 28, 0.7);
    --bg-card-hover: rgba(24, 24, 38, 0.8);
    --border: rgba(99, 102, 241, 0.15);
    --border-hover: rgba(99, 102, 241, 0.35);
    --text-primary: #f1f1f4;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #818cf8;
    --accent-2: #c084fc;
    --accent-glow: rgba(129, 140, 248, 0.15);
    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;
    --radius: 14px;
    --radius-sm: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.bg-grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ===== HEADER ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    background: rgba(10, 10, 15, 0.75);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    display: flex;
    align-items: center;
}

.logo-text {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-badge {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 3px 7px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    transform: translateY(-4px);
}

.header-stats {
    display: flex;
    gap: 12px;
}

.stat-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--accent-glow);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
}

.stat-label {
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    color: var(--accent);
    font-weight: 700;
}

/* ===== MAIN ===== */
.main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    z-index: 1;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    backdrop-filter: blur(12px);
    transition: border-color var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
}

.card-header {
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.card-title svg {
    color: var(--accent);
    flex-shrink: 0;
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== SEARCH FORM ===== */
.search-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input[type="text"],
.filter-input {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: all var(--transition);
    outline: none;
}

.form-group input[type="text"]:focus,
.filter-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder,
.filter-input::placeholder {
    color: var(--text-muted);
}

/* Range slider */
.slider-group {
    max-width: 280px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    outline: none;
    margin-top: 6px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
    transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.accent {
    color: var(--accent);
    font-weight: 700;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.45);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-accent {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent);
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.btn-accent:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--accent);
}

.btn-group {
    flex: none !important;
}

/* ===== LOADING ===== */
.loading-card {
    text-align: center;
    padding: 48px;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.loader-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.loader-content p {
    color: var(--text-muted);
    font-size: 0.85rem;
    max-width: 400px;
}

.spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== ERROR ===== */
.error-card {
    border-color: rgba(248, 113, 113, 0.3);
}

.error-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.error-content h3 {
    color: var(--danger);
}

.error-content p {
    color: var(--text-muted);
    font-size: 0.85rem;
    max-width: 500px;
}

/* ===== FILTERS ===== */
.filters-row {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-grow {
    flex: 1;
    min-width: 160px;
}

.toggle-group {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.toggle-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border-right: 1px solid var(--border);
}

.toggle-btn:last-child {
    border-right: none;
}

.toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.toggle-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(192, 132, 252, 0.15));
    color: var(--accent);
    font-weight: 600;
}

/* ===== TABLE ===== */
.table-wrapper {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.table-wrapper::-webkit-scrollbar {
    height: 6px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 3px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead th {
    padding: 12px 14px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    user-select: none;
}

th.sortable {
    cursor: pointer;
    transition: color var(--transition);
}

th.sortable:hover {
    color: var(--accent);
}

th.sortable.asc::after {
    content: ' ▲';
    font-size: 0.6rem;
}

th.sortable.desc::after {
    content: ' ▼';
    font-size: 0.6rem;
}

.th-index {
    width: 40px;
    text-align: center;
}

tbody tr {
    transition: background var(--transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

tbody tr:hover {
    background: var(--bg-card-hover);
}

tbody td {
    padding: 12px 14px;
    color: var(--text-secondary);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

tbody td:first-child {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
}

td a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

td a:hover {
    color: var(--accent-2);
    text-decoration: underline;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(52, 211, 153, 0.12);
    color: var(--success);
}

.badge-muted {
    background: rgba(107, 114, 128, 0.12);
    color: var(--text-muted);
}

/* Stars */
.stars {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.stars-value {
    color: var(--warning);
    font-weight: 600;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
    }

    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .header-stats {
        display: none;
    }

    .slider-group {
        max-width: 100%;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.4s ease-out;
}

tbody tr {
    animation: fadeIn 0.3s ease-out;
    animation-fill-mode: both;
}

tbody tr:nth-child(1) {
    animation-delay: 0.02s;
}

tbody tr:nth-child(2) {
    animation-delay: 0.04s;
}

tbody tr:nth-child(3) {
    animation-delay: 0.06s;
}

tbody tr:nth-child(4) {
    animation-delay: 0.08s;
}

tbody tr:nth-child(5) {
    animation-delay: 0.10s;
}

tbody tr:nth-child(6) {
    animation-delay: 0.12s;
}

tbody tr:nth-child(7) {
    animation-delay: 0.14s;
}

tbody tr:nth-child(8) {
    animation-delay: 0.16s;
}

tbody tr:nth-child(9) {
    animation-delay: 0.18s;
}

tbody tr:nth-child(10) {
    animation-delay: 0.20s;
}