/* ===================================================
   USAR RANKLIST - Minimalist Monochrome Design System
   =================================================== */

/* ----- Google Fonts ----- */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,500;1,600;1,700&family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,500;0,8..60,600;0,8..60,700;1,8..60,400;1,8..60,500&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ----- Design Tokens ----- */
:root {
    /* Colors - Strictly Monochrome */
    --background: #FFFFFF;
    --foreground: #000000;
    --muted: #F5F5F5;
    --muted-foreground: #525252;
    --accent: #000000;
    --accent-foreground: #FFFFFF;
    --border: #000000;
    --border-light: #E5E5E5;
    --card: #FFFFFF;
    --card-foreground: #000000;
    --ring: #000000;
    
    /* Typography */
    --font-display: "Playfair Display", Georgia, serif;
    --font-body: "Source Serif 4", Georgia, serif;
    --font-mono: "JetBrains Mono", monospace;
    
    /* Type Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;
    --text-4xl: 2.5rem;
    --text-5xl: 3.5rem;
    --text-6xl: 4.5rem;
    --text-7xl: 6rem;
    --text-8xl: 8rem;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;
    
    /* Borders */
    --border-hairline: 1px solid var(--border-light);
    --border-thin: 1px solid var(--border);
    --border-medium: 2px solid var(--border);
    --border-thick: 4px solid var(--border);
    --border-ultra: 8px solid var(--border);
    
    /* Border Radius - ZERO everywhere */
    --radius: 0px;
    
    /* Transitions - Instant */
    --transition-instant: 0ms;
    --transition-fast: 100ms;
}

/* ----- CSS Reset & Base ----- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-lg);
    line-height: 1.625;
    color: var(--foreground);
    background-color: var(--background);
    min-height: 100vh;
    position: relative;
}

/* Noise texture overlay for paper-like quality */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* ----- Typography ----- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.025em;
    color: var(--foreground);
}

h1 { font-size: var(--text-7xl); }
h2 { font-size: var(--text-5xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }

p {
    font-family: var(--font-body);
    line-height: 1.625;
}

a {
    color: var(--foreground);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast);
}

a:hover {
    border-bottom-color: var(--foreground);
}

a:focus-visible {
    outline: 3px solid var(--foreground);
    outline-offset: 3px;
}

/* Monospace for data */
.mono {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    letter-spacing: 0.05em;
}

/* ----- Layout ----- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

@media (min-width: 768px) {
    .container {
        padding: 0 var(--space-8);
    }
}

@media (min-width: 1024px) {
    .container {
        padding: 0 var(--space-12);
    }
}

/* ----- Header ----- */
header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--background);
    border-bottom: var(--border-medium);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-6) 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: var(--foreground);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon span {
    color: var(--background);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--text-xl);
}

.logo-text h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: -0.05em;
}

.logo-text p {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: var(--space-1);
}

/* Navigation */
nav ul {
    display: flex;
    gap: var(--space-8);
    list-style: none;
}

nav a {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: var(--space-2) 0;
    border-bottom: 2px solid transparent;
    transition: border-color var(--transition-fast);
}

nav a:hover,
nav a.active {
    border-bottom-color: var(--foreground);
}

nav a:focus-visible {
    outline: 3px solid var(--foreground);
    outline-offset: 3px;
}

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: var(--border-medium);
    padding: var(--space-3);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.mobile-menu-btn:hover {
    background: var(--foreground);
    color: var(--background);
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: currentColor;
    margin: 5px 0;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
    
    nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--background);
        border-bottom: var(--border-medium);
        padding: var(--space-6);
    }
    
    nav.active {
        display: block;
    }
    
    nav ul {
        flex-direction: column;
        gap: var(--space-4);
    }
}

/* ----- Main Content ----- */
main {
    min-height: calc(100vh - 200px);
}

/* Section with horizontal rule */
.section {
    padding: var(--space-16) 0;
    position: relative;
}

.section::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - var(--space-12));
    max-width: 1280px;
    height: 4px;
    background: var(--foreground);
}

.section:last-child::after {
    display: none;
}

/* Section with texture */
.section-textured {
    position: relative;
}

.section-textured::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.015;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 1px,
        #000 1px,
        #000 2px
    );
    background-size: 100% 4px;
}

/* Inverted section */
.section-inverted {
    background: var(--foreground);
    color: var(--background);
    position: relative;
}

.section-inverted::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.03;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 1px,
        #fff 1px,
        #fff 2px
    );
    background-size: 4px 100%;
}

.section-inverted h2,
.section-inverted h3,
.section-inverted p,
.section-inverted span {
    color: var(--background);
}

/* ----- Filters Section ----- */
.filters-section {
    padding: var(--space-8) 0;
    border-bottom: var(--border-thick);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-6);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.filter-group label {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted-foreground);
}

/* Select & Input Styles */
select,
input[type="text"],
input[type="search"] {
    font-family: var(--font-body);
    font-size: var(--text-base);
    padding: var(--space-4);
    background: var(--background);
    border: none;
    border-bottom: 2px solid var(--foreground);
    color: var(--foreground);
    width: 100%;
    transition: border-width var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000000' stroke-width='2' stroke-linecap='square' stroke-linejoin='miter'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-4) center;
    background-size: 16px;
    padding-right: var(--space-12);
    cursor: pointer;
}

select:focus,
input[type="text"]:focus,
input[type="search"]:focus {
    outline: none;
    border-bottom-width: 4px;
}

input::placeholder {
    color: var(--muted-foreground);
    font-style: italic;
}

/* Search container */
.search-container {
    position: relative;
    grid-column: span 2;
}

@media (max-width: 768px) {
    .search-container {
        grid-column: span 1;
    }
}

.search-container::before {
    content: "→";
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    color: var(--muted-foreground);
}

.search-container input {
    padding-left: var(--space-10);
}

/* ----- Stats Bar ----- */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-6) 0;
    border-bottom: var(--border-thin);
    flex-wrap: wrap;
    gap: var(--space-4);
}

.stats-info {
    display: flex;
    gap: var(--space-8);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
}

.stat-value {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: 700;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted-foreground);
}

/* ----- Table Styles ----- */
.table-container {
    overflow-x: auto;
    margin: var(--space-8) 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-body);
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: left;
    padding: var(--space-4) var(--space-3);
    background: var(--foreground);
    color: var(--background);
    border: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

th:hover {
    background: var(--muted-foreground);
}

th.sorted-asc::after {
    content: " ↑";
}

th.sorted-desc::after {
    content: " ↓";
}

td {
    padding: var(--space-4) var(--space-3);
    border-bottom: var(--border-hairline);
    vertical-align: middle;
}

tr {
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

tbody tr:hover {
    background: var(--foreground);
    color: var(--background);
}

tbody tr:hover td {
    border-bottom-color: var(--muted-foreground);
}

/* Rank styling */
.rank-cell {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    width: 60px;
}

.rank-1 { 
    position: relative;
}

.rank-1::before {
    content: "①";
    font-size: var(--text-3xl);
}

.rank-2::before {
    content: "②";
    font-size: var(--text-3xl);
}

.rank-3::before {
    content: "③";
    font-size: var(--text-3xl);
}

/* Student name */
.student-name {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 600;
}

.student-roll {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    margin-top: var(--space-1);
}

tbody tr:hover .student-roll {
    color: var(--border-light);
}

/* Percentage display */
.percentage-cell {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 700;
}

.percentage-bar {
    width: 100px;
    height: 4px;
    background: var(--border-light);
    margin-top: var(--space-2);
    position: relative;
    overflow: hidden;
}

.percentage-fill {
    height: 100%;
    background: var(--foreground);
    transition: width var(--transition-fast);
}

tbody tr:hover .percentage-bar {
    background: var(--muted-foreground);
}

tbody tr:hover .percentage-fill {
    background: var(--background);
}

/* Programme badge */
.programme-badge {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-2) var(--space-3);
    border: 1px solid currentColor;
    display: inline-block;
}

/* ----- Buttons ----- */
.btn {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: var(--space-4) var(--space-8);
    border: none;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.btn:focus-visible {
    outline: 3px solid var(--foreground);
    outline-offset: 3px;
}

.btn-primary {
    background: var(--foreground);
    color: var(--background);
    border: 2px solid var(--foreground);
}

.btn-primary:hover {
    background: var(--background);
    color: var(--foreground);
}

.btn-secondary {
    background: transparent;
    color: var(--foreground);
    border: 2px solid var(--foreground);
}

.btn-secondary:hover {
    background: var(--foreground);
    color: var(--background);
}

.btn-ghost {
    background: transparent;
    color: var(--foreground);
    border: none;
    padding: var(--space-2) 0;
    border-bottom: 1px solid transparent;
}

.btn-ghost:hover {
    border-bottom-color: var(--foreground);
}

/* Arrow indicator */
.btn-arrow::after {
    content: "→";
    transition: transform var(--transition-fast);
}

.btn-arrow:hover::after {
    transform: translateX(4px);
}

/* ----- Pagination ----- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-8) 0;
    border-top: var(--border-thin);
    margin-top: var(--space-8);
}

.pagination-btn {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border: var(--border-thin);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.pagination-btn:hover,
.pagination-btn.active {
    background: var(--foreground);
    color: var(--background);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-btn:focus-visible {
    outline: 3px solid var(--foreground);
    outline-offset: 3px;
}

.pagination-info {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--muted-foreground);
    padding: 0 var(--space-4);
}

/* ----- Tabs ----- */
.tabs {
    display: flex;
    border-bottom: var(--border-medium);
    margin-bottom: var(--space-8);
    overflow-x: auto;
}

.tab-btn {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: var(--space-4) var(--space-6);
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: color var(--transition-fast);
}

.tab-btn::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 4px;
    background: transparent;
    transition: background-color var(--transition-fast);
}

.tab-btn:hover {
    color: var(--foreground);
}

.tab-btn.active {
    font-weight: 600;
}

.tab-btn.active::after {
    background: var(--foreground);
}

.tab-btn:focus-visible {
    outline: 3px solid var(--foreground);
    outline-offset: 3px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ----- Cards ----- */
.card {
    background: var(--card);
    border: var(--border-thin);
    padding: var(--space-8);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.card:hover {
    background: var(--foreground);
    color: var(--background);
}

.card:hover .card-title,
.card:hover .card-value,
.card:hover .card-label {
    color: var(--background);
}

.card-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 600;
    margin-bottom: var(--space-4);
}

.card-value {
    font-family: var(--font-display);
    font-size: var(--text-5xl);
    font-weight: 700;
    line-height: 1;
}

.card-label {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted-foreground);
    margin-top: var(--space-2);
}

/* Card grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-6);
    margin: var(--space-8) 0;
}

/* ----- Analytics Charts ----- */
.chart-container {
    padding: var(--space-8);
    border: var(--border-thin);
    margin: var(--space-8) 0;
}

.chart-title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 600;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: var(--border-thin);
}

/* Bar chart */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.bar-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.bar-label {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    width: 80px;
    flex-shrink: 0;
}

.bar-track {
    flex: 1;
    height: 24px;
    background: var(--muted);
    position: relative;
}

.bar-fill {
    height: 100%;
    background: var(--foreground);
    transition: width 300ms ease-out;
}

.bar-value {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    width: 60px;
    text-align: right;
    flex-shrink: 0;
}

/* ----- Modal ----- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: var(--space-6);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--background);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--space-8);
    border-bottom: var(--border-thick);
    position: sticky;
    top: 0;
    background: var(--background);
    z-index: 10;
}

.modal-title {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: 700;
}

.modal-subtitle {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--muted-foreground);
    margin-top: var(--space-2);
}

.modal-close {
    width: 48px;
    height: 48px;
    background: var(--foreground);
    color: var(--background);
    border: none;
    font-size: var(--text-2xl);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast);
    flex-shrink: 0;
}

.modal-close:hover {
    background: var(--muted-foreground);
}

.modal-close:focus-visible {
    outline: 3px solid var(--foreground);
    outline-offset: 3px;
}

.modal-body {
    padding: var(--space-8);
}

/* Student detail in modal */
.student-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-8);
    border-bottom: var(--border-thin);
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.detail-label {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted-foreground);
}

.detail-value {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 600;
}

/* Subjects table in modal */
.subjects-table {
    width: 100%;
    margin-top: var(--space-6);
}

.subjects-table th {
    font-size: var(--text-xs);
    padding: var(--space-3) var(--space-2);
}

.subjects-table td {
    font-size: var(--text-sm);
    padding: var(--space-3) var(--space-2);
}

/* Grade badges */
.grade-badge {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 600;
    padding: var(--space-1) var(--space-2);
    border: 1px solid currentColor;
    display: inline-block;
    min-width: 32px;
    text-align: center;
}

.grade-O { background: var(--foreground); color: var(--background); }
.grade-A-plus { border-width: 2px; }
.grade-A { }
.grade-B-plus { }
.grade-B { color: var(--muted-foreground); }
.grade-C { color: var(--muted-foreground); }
.grade-P { color: var(--muted-foreground); }
.grade-F { background: var(--foreground); color: var(--background); text-decoration: line-through; }

/* ----- Footer ----- */
footer {
    background: var(--foreground);
    color: var(--background);
    padding: var(--space-16) 0;
    margin-top: var(--space-16);
    position: relative;
}

footer::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.03;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 1px,
        #fff 1px,
        #fff 2px
    );
    background-size: 4px 100%;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
    text-align: center;
    position: relative;
    z-index: 1;
}

.footer-logo {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--background);
}

.footer-text {
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--border-light);
    max-width: 600px;
}

.footer-credits {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted-foreground);
    margin-top: var(--space-8);
}

.footer-credits a {
    color: var(--background);
    border-bottom: 1px solid var(--background);
}

.footer-credits a:hover {
    border-bottom-width: 2px;
}

/* ----- Loading State ----- */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    gap: var(--space-6);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-light);
    border-top-color: var(--foreground);
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted-foreground);
}

/* ----- Empty State ----- */
.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-8);
    border: var(--border-thin);
    border-style: dashed;
}

.empty-icon {
    font-size: var(--text-6xl);
    margin-bottom: var(--space-6);
    opacity: 0.3;
}

.empty-title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    margin-bottom: var(--space-4);
}

.empty-text {
    font-family: var(--font-body);
    color: var(--muted-foreground);
    max-width: 400px;
    margin: 0 auto;
}

/* ----- Top Performers Section ----- */
.top-performers {
    padding: var(--space-12) 0;
}

.top-performers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-1);
}

.performer-card {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    padding: var(--space-6);
    border: var(--border-thin);
    transition: background-color var(--transition-fast), color var(--transition-fast);
    cursor: pointer;
}

.performer-card:hover {
    background: var(--foreground);
    color: var(--background);
}

.performer-rank {
    font-family: var(--font-display);
    font-size: var(--text-4xl);
    font-weight: 700;
    width: 60px;
    text-align: center;
    flex-shrink: 0;
}

.performer-info {
    flex: 1;
    min-width: 0;
}

.performer-name {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.performer-details {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    margin-top: var(--space-1);
}

.performer-card:hover .performer-details {
    color: var(--border-light);
}

.performer-percentage {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    flex-shrink: 0;
}

/* ----- Responsive Adjustments ----- */
@media (max-width: 1024px) {
    h1 { font-size: var(--text-5xl); }
    h2 { font-size: var(--text-4xl); }
    
    .card-value {
        font-size: var(--text-4xl);
    }
}

@media (max-width: 768px) {
    h1 { font-size: var(--text-4xl); }
    h2 { font-size: var(--text-3xl); }
    
    .section {
        padding: var(--space-12) 0;
    }
    
    .stats-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stat-value {
        font-size: var(--text-2xl);
    }
    
    .card-value {
        font-size: var(--text-3xl);
    }
    
    .modal-title {
        font-size: var(--text-2xl);
    }
    
    .student-detail-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Hide less important columns on mobile */
    .table-container th:nth-child(4),
    .table-container td:nth-child(4),
    .table-container th:nth-child(5),
    .table-container td:nth-child(5) {
        display: none;
    }
}

@media (max-width: 480px) {
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
    
    .logo-text h1 {
        font-size: var(--text-xl);
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
    }
    
    .search-container {
        grid-column: span 1;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .student-detail-grid {
        grid-template-columns: 1fr;
    }
    
    .top-performers-grid {
        grid-template-columns: 1fr;
    }
}

/* ----- Print Styles ----- */
@media print {
    body::before {
        display: none;
    }
    
    header, footer, .filters-section, .pagination, .tabs {
        display: none;
    }
    
    .section::after {
        display: none;
    }
    
    table {
        font-size: 10pt;
    }
    
    th {
        background: #000 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ----- Utility Classes ----- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-muted {
    color: var(--muted-foreground);
}

.text-center {
    text-align: center;
}

.uppercase {
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.border-b {
    border-bottom: var(--border-thin);
}

.border-t {
    border-top: var(--border-thin);
}

.mt-8 {
    margin-top: var(--space-8);
}

.mb-8 {
    margin-bottom: var(--space-8);
}

.py-8 {
    padding-top: var(--space-8);
    padding-bottom: var(--space-8);
}
/* ...existing code... */

/* ----- Disclaimer Banner ----- */
.disclaimer-banner {
    background: var(--foreground);
    color: var(--background);
    padding: var(--space-3) 0;
    text-align: center;
    border-bottom: var(--border-medium);
    position: relative;
}

.disclaimer-banner::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.05;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        #fff 10px,
        #fff 12px
    );
}

.disclaimer-banner p {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0;
    position: relative;
    z-index: 1;
}

.disclaimer-banner strong {
    background: var(--background);
    color: var(--foreground);
    padding: var(--space-1) var(--space-2);
    margin-right: var(--space-2);
}

/* ----- Header (update for clickable logo) ----- */
/* ...existing code for header... */

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    text-decoration: none;
    border-bottom: none;
    transition: opacity var(--transition-fast);
}

.logo:hover {
    opacity: 0.8;
    border-bottom: none;
}

.logo:focus-visible {
    outline: 3px solid var(--foreground);
    outline-offset: 3px;
}

/* ...existing code... */

/* ----- Footer (enhanced) ----- */
footer {
    background: var(--foreground);
    color: var(--background);
    padding: var(--space-16) 0 var(--space-8);
    margin-top: var(--space-16);
    position: relative;
}

footer::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.03;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 1px,
        #fff 1px,
        #fff 2px
    );
    background-size: 4px 100%;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-8);
    text-align: center;
    position: relative;
    z-index: 1;
}

.footer-logo {
    font-family: var(--font-display);
    font-size: var(--text-4xl);
    font-weight: 700;
    color: var(--background);
}

.footer-disclaimer {
    max-width: 700px;
    padding: var(--space-6);
    border: 2px solid var(--background);
    background: rgba(255, 255, 255, 0.05);
}

.footer-disclaimer h4 {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--background);
    margin-bottom: var(--space-3);
}

.footer-disclaimer p {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--border-light);
    line-height: 1.6;
    margin: 0;
}

.footer-disclaimer strong {
    color: var(--background);
}

.footer-text {
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--border-light);
    max-width: 600px;
}

.footer-credits-section {
    width: 100%;
    max-width: 700px;
    padding-top: var(--space-8);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.credits-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-8);
}

@media (max-width: 600px) {
    .credits-grid {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
}

.credit-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}

.credit-label {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted-foreground);
}

.credit-name {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--background);
}

.credit-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-4);
    margin-top: var(--space-2);
}

.credit-links a {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--border-light);
    padding: var(--space-2) var(--space-3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.credit-links a:hover {
    background: var(--background);
    color: var(--foreground);
    border-color: var(--background);
}

.credit-links a:focus-visible {
    outline: 3px solid var(--background);
    outline-offset: 3px;
}

.credit-links svg {
    flex-shrink: 0;
}

.footer-legal {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted-foreground);
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ...existing code... */
/* ...existing code... */

/* ----- Ranking Toggle ----- */
.ranking-toggle {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-4);
    background: var(--background);
    border: none;
    border-bottom: 2px solid var(--foreground);
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.ranking-toggle:hover {
    background: var(--foreground);
    color: var(--background);
}

.ranking-toggle:focus-visible {
    outline: 3px solid var(--foreground);
    outline-offset: 3px;
}

.toggle-active {
    font-weight: 700;
    color: inherit;
}

.toggle-inactive {
    font-weight: 400;
    opacity: 0.5;
}

.ranking-toggle:hover .toggle-active,
.ranking-toggle:hover .toggle-inactive {
    color: inherit;
}

/* ----- Score Cell (GPA mode) ----- */
.score-cell {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 700;
}

.score-sub {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    margin-top: var(--space-1);
}

tbody tr:hover .score-sub {
    color: var(--border-light);
}

/* ...existing code... */
/* ...existing code... */

/* Searchable Subject Dropdown */
.subject-dropdown {
    position: relative;
    width: 100%;
}

.subject-dropdown-input {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.subject-dropdown-input input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
}

.subject-dropdown-input input::placeholder {
    color: var(--text-muted);
}

.subject-dropdown-input .dropdown-arrow {
    padding: 0.75rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    transition: transform var(--transition);
}

.subject-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.subject-dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: var(--shadow-lg);
}

.subject-dropdown.open .subject-dropdown-list {
    display: block;
}

.subject-option {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: background var(--transition);
    border-bottom: 1px solid var(--border);
}

.subject-option:last-child {
    border-bottom: none;
}

.subject-option:hover {
    background: var(--bg-tertiary);
}

.subject-option[data-value=""] {
    color: var(--text-muted);
    font-style: italic;
}

/* ...existing code... */