/* gradylitics ai pro — kush tech solutions
 * author: kushal pokhrel, lead researcher & engineer
 * © 2026 kush tech solutions. all rights reserved.
 * licensed under the elastic license 2.0 (elv2) — use freely, do not redistribute or resell.
 */

:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-light: #a78bfa;
    --secondary: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --credit: #0ea5e9;
    --distinction: #8b5cf6;
    --high-distinction: #ec4899;
    --dark-bg: #06060c;
    --card-bg: rgba(22, 22, 35, 0.45);
    --header-bg: rgba(10, 10, 18, 0.6);
    --border-color: rgba(139, 92, 246, 0.2);
    --border-focus: rgba(139, 92, 246, 0.45);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    /* use specific properties only — avoids costly 'all' repaints */
    --transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 15px rgba(139, 92, 246, 0.15);
}

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

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    background: var(--dark-bg);
    background-image: radial-gradient(circle at 10% 20%, rgba(26, 20, 64, 0.4) 0%, rgba(6, 6, 12, 1) 90%);
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Glassmorphism Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: var(--header-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-container img {
    width: 45px;
    height: 45px;
    border-radius: 10px;
    border: 2px solid var(--primary);
    object-fit: cover;
}

.brand-text h1 {
    font-size: 1.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.brand-text span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Loader Screen Overlay */
#loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
    background-image: radial-gradient(circle at center, rgba(30, 20, 70, 0.5) 0%, rgba(6, 6, 12, 1) 100%);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

.loader-content {
    text-align: center;
    padding: 3rem;
    width: 100%;
    max-width: 500px;
    /* Prevent the card from ever overflowing the viewport on small screens */
    min-width: 0;
    max-width: min(500px, calc(100vw - 24px));
    /* Fixed min-height prevents the card from jumping when status text changes length */
    min-height: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    box-sizing: border-box;
}

.loader-logo {
    width: 70px;
    height: 70px;
    margin-bottom: 20px;
    border-radius: 14px;
    border: 2px solid rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 25px rgba(139, 92, 246, 0.35);
    animation: pulseLogo 2s infinite ease-in-out;
}

.loader-auth-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.15);
    padding-bottom: 14px;
    margin-bottom: 24px;
    width: 100%;
}

.loader-auth-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary-light);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.diag-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: 0.65rem;
    font-weight: 700;
    color: #ef4444;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: background 0.4s ease, border-color 0.4s ease, color 0.4s ease, box-shadow 0.4s ease;
}

.diag-dot::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
    animation: diagPulse 1.5s infinite ease-in-out;
}

@keyframes diagPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(0.85); }
}

@keyframes pulseLogo {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.05); filter: brightness(1.2); }
}

.loader-sub {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 2.5px;
    color: var(--primary-light);
    margin-bottom: 25px;
    text-transform: uppercase;
}

.brand-title {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.progress-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
    margin: 2rem auto;
    max-width: 300px;
}

#p-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    transition: width 0.3s ease;
}

.loader-status {
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    margin: 20px 0 10px;
    font-weight: 500;
    text-align: center;
    letter-spacing: 0.5px;
    /* Reserve a fixed height so text changes don't shift the layout */
    /* Use block (not flex) so text wraps normally on narrow screens */
    display: block;
    min-height: 2.5rem;
    width: 100%;
    line-height: 1.4;
    animation: pulseText 1.5s infinite ease-in-out;
}

@keyframes pulseText {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

#start-btn {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.3);
}

#start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(139, 92, 246, 0.5);
}

/* Main Container and Dashboard Strip */
#main-container {
    padding-top: 70px;
    min-height: calc(100vh - 150px);
    display: block;
}

#main-container.init-blurred {
    filter: blur(8px) saturate(80%);
    pointer-events: none;
}

.datasets-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 30px;
    background: rgba(15, 15, 25, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: thin;
}

.dataset-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    white-space: nowrap;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    will-change: transform;
}

.dataset-pill:hover {
    background: rgba(139, 92, 246, 0.08);
    border-color: var(--primary-light);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.dataset-pill.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.dataset-pill .delete-ds {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dataset-pill .delete-ds:hover {
    background: rgba(239, 68, 68, 0.8);
}

.app-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 25px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 25px;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-glow);
    will-change: transform;
    animation: fadeSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.card:hover {
    transform: translateY(-3px);
    border-color: var(--border-focus);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(139, 92, 246, 0.12);
}

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

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    opacity: 0.8;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Quick Stats */
.stat-card {
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-3px);
    border-color: var(--border-color);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 10px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.category-risk { color: var(--danger); }
.category-pass { color: var(--warning); }
.category-credit { color: var(--credit); }
.category-distinction { color: var(--distinction); }
.category-high-distinction { color: var(--high-distinction); }

/* File Drop Zone / Upload Area */
.file-upload-area {
    border: 3px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 60px 30px;
    text-align: center;
    cursor: pointer;
    margin: 20px 0;
    transition: var(--transition);
    background: rgba(139, 92, 246, 0.02);
}

.file-upload-area:hover,
.file-upload-area.dragover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.08);
    transform: translateY(-2px);
}

.file-upload-icon {
    font-size: 3.5rem;
    color: var(--primary);
    margin-bottom: 20px;
    opacity: 0.8;
}

/* Drag and Drop global overlay */
.drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 6, 12, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    border: 4px dashed var(--primary);
    pointer-events: none;
    animation: pulseBorder 1.5s infinite;
}

.drag-overlay-content {
    text-align: center;
    color: white;
}

.drag-overlay-content span {
    font-size: 6rem;
    color: var(--primary-light);
    margin-bottom: 20px;
}

.drag-overlay-content h2 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

@keyframes pulseBorder {
    0% { border-color: rgba(139, 92, 246, 0.3); }
    50% { border-color: rgba(139, 92, 246, 0.9); }
    100% { border-color: rgba(139, 92, 246, 0.3); }
}

.btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.15s ease, opacity 0.12s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    will-change: transform;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: #fff;
}

.btn-outline {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ripple burst on click */
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.08);
    opacity: 0;
    border-radius: inherit;
    transition: opacity 0.2s ease;
}
.btn:active::after { opacity: 1; transition: none; }

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Navigation Tabs */
.tabs-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: none;
}

.tab-btn {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    will-change: transform;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.25);
}

/* Data Tables */
.data-table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.01);
    backdrop-filter: blur(5px);
}

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

.data-table th {
    background: rgba(139, 92, 246, 0.08);
    padding: 16px 20px;
    text-align: left;
    color: var(--primary-light);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: rgba(139, 92, 246, 0.06);
    transform: translateX(2px);
    transition: background 0.12s ease, transform 0.12s ease;
}

/* Modal Windows (Glassmorphic Pop-ups) */
.student-modal, .docs-modal, .preview-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.student-modal-content, .docs-modal-content, .preview-modal-content {
    background: rgba(20, 20, 32, 0.75);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border-radius: var(--radius-lg);
    padding: 30px;
    max-width: 850px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid rgba(139, 92, 246, 0.25);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Documentation Content styling */
.docs-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.docs-section:last-child {
    border-bottom: none;
}

.docs-section h3 {
    color: var(--primary-light);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.docs-section p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.docs-section ul {
    list-style-type: none;
    padding-left: 5px;
}

.docs-section li {
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.9rem;
}

.docs-section li span {
    color: var(--primary);
}

/* Chart Container & Correlation Controls */
.chart-container {
    width: 100%;
    height: 400px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}

.correlation-controls {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* Badges */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.badge-risk { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.25); }
.badge-pass { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.25); }
.badge-credit { background: rgba(14, 165, 233, 0.15); color: var(--credit); border: 1px solid rgba(14, 165, 233, 0.25); }
.badge-distinction { background: rgba(139, 92, 246, 0.15); color: var(--distinction); border: 1px solid rgba(139, 92, 246, 0.25); }
.badge-high-distinction { background: rgba(236, 72, 153, 0.15); color: var(--high-distinction); border: 1px solid rgba(236, 72, 153, 0.25); }

/* Footer */
.grad-footer {
    background: rgba(10, 10, 18, 0.45);
    border-top: 1px solid rgba(139, 92, 246, 0.15);
    padding: 30px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

.footer-links a:hover {
    color: var(--primary-light);
}

.footer-separator {
    color: rgba(255, 255, 255, 0.1);
}

.donate-button {
    background: rgba(0, 112, 186, 0.1) !important;
    border: 1px solid rgba(0, 112, 186, 0.4) !important;
    color: #72c0ff !important;
    padding: 6px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.donate-button:hover {
    background: rgba(0, 112, 186, 0.2) !important;
    border-color: #009cde !important;
    color: #fff !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 112, 186, 0.25);
}

.footer-copyright {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.8rem;
    margin-top: 10px;
}

/* Grids helper */
.grid-col-span-3 { grid-column: span 3; }
.grid-col-span-4 { grid-column: span 4; }
.grid-col-span-6 { grid-column: span 6; }
.grid-col-span-8 { grid-column: span 8; }
.grid-col-span-12 { grid-column: span 12; }

/* ============================================================
   RESPONSIVE BREAKPOINTS — TABLET (≤1200px)
   ============================================================ */
@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: repeat(6, 1fr); }
    .grid-col-span-3, .grid-col-span-4 { grid-column: span 3; }
    .grid-col-span-6, .grid-col-span-8 { grid-column: span 6; }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS — MOBILE (≤768px)
   ============================================================ */
@media (max-width: 768px) {
    /* ---- Header ---- */
    .app-header {
        padding: 0 16px;
        height: 60px;
    }
    .logo-container img {
        width: 36px;
        height: 36px;
    }
    .brand-text h1 { font-size: 1.15rem; }
    .brand-text span { display: none; } /* hide subtitle on mobile */

    /* Shrink Docs button to icon-only on tablets */
    .app-header .btn-outline .btn-text-label { display: none; }

    /* ---- Main container ---- */
    #main-container { padding-top: 60px; }
    .app-content { padding: 12px; }

    /* ---- Datasets strip ---- */
    .datasets-strip { padding: 10px 12px; gap: 8px; }
    .dataset-pill { padding: 10px 12px; font-size: 0.8rem; min-height: 40px; }

    /* ---- Dashboard grid ---- */
    .dashboard-grid { grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
    .grid-col-span-3,
    .grid-col-span-4,
    .grid-col-span-6,
    .grid-col-span-8,
    .grid-col-span-12 { grid-column: 1; }

    /* ---- Cards ---- */
    .card { padding: 18px; }
    .card-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .card-header > div:last-child { width: 100%; }
    .card-header .btn { width: 100%; justify-content: center; }
    .card-title { font-size: 1.1rem; }

    /* ---- Stat cards — 2 columns on mobile ---- */
    .stat-value { font-size: 2rem; }

    /* ---- File Upload ---- */
    .file-upload-area { padding: 36px 16px; }
    .file-upload-icon { font-size: 2.5rem; }

    /* ---- Tabs — scrollable row, icon + short label ---- */
    .tabs-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .tabs-nav::-webkit-scrollbar { display: none; }
    .tab-btn {
        padding: 10px 14px;
        flex-shrink: 0;
        font-size: 0.82rem;
        white-space: nowrap;
        min-height: 44px; /* touch target */
    }
    .tab-btn .tab-label { display: none; } /* icon-only mode */
    .tab-btn .material-icons-round { font-size: 20px; margin: 0; }

    /* ---- Correlation controls — stack ---- */
    .correlation-controls { grid-template-columns: 1fr; gap: 12px; }

    /* ---- Data Tables — horizontal scroll with better UX ---- */
    .data-table-container {
        border-radius: var(--radius-sm);
        -webkit-overflow-scrolling: touch;
    }
    .data-table { min-width: 650px; font-size: 0.85rem; }
    .data-table th { padding: 12px 14px; font-size: 0.78rem; }
    .data-table td { padding: 10px 14px; }

    /* Action buttons in table cells — stack them */
    .data-table td .btn { padding: 6px 10px; font-size: 0.8rem; }

    /* ---- Buttons ---- */
    .btn { min-height: 44px; } /* WCAG touch target */

    /* ---- Search input ---- */
    #search-students {
        width: 100% !important;
        min-width: unset !important;
        box-sizing: border-box;
    }

    /* ---- Modals ---- */
    .student-modal, .docs-modal, .preview-modal {
        padding: 10px;
        align-items: flex-end; /* slide up from bottom on mobile */
    }
    .student-modal-content, .docs-modal-content, .preview-modal-content {
        max-height: 92vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 20px 16px;
        max-width: 100% !important;
        animation: slideUpMobile 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* ---- Export modal format cards — 1 column ---- */
    .format-cards-grid { grid-template-columns: 1fr !important; }

    /* ---- Loader ---- */
    .loader-content {
        padding: 2rem 1.5rem;
        margin: 0 12px;
        min-height: 380px; /* keep stable height on tablet/mobile */
        width: calc(100% - 24px);
    }
    .brand-title { font-size: 1.8rem; }
    .loader-logo { width: 55px; height: 55px; }

    /* ---- Footer ---- */
    .grad-footer { padding: 20px 16px; }
    .footer-links { flex-direction: column; gap: 12px; }
    .footer-separator { display: none; }
    .donate-button { align-self: center; }
    .footer-copyright { font-size: 0.75rem; }

    /* ---- Toast notifications — full width on mobile ---- */
    #toast-container {
        bottom: 12px !important;
        right: 12px !important;
        left: 12px !important;
        align-items: stretch;
    }
    .toast {
        max-width: 100%;
        right: auto;
        bottom: auto;
        position: relative;
        animation: slideInUp 0.3s ease;
    }

    /* ---- Charts — reduce height for readability ---- */
    .chart-container { height: 300px; padding: 10px; }

    /* ---- Drag overlay text ---- */
    .drag-overlay-content h2 { font-size: 1.4rem; }
    .drag-overlay-content span { font-size: 4rem; }

    /* ---- Overview tab: Quick stats 2-col grid ---- */
    .stats-2col-mobile {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    /* ---- AI Banner — stack vertically ---- */
    .gradie-banner-inner {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    .gradie-banner-inner .btn { width: 100%; justify-content: center; margin-top: 8px; }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS — SMALL PHONES (≤480px)
   ============================================================ */
@media (max-width: 480px) {
    /* ---- Header stays single row, just icon + name ---- */
    .app-header { padding: 0 12px; height: 56px; }
    .brand-text h1 { font-size: 1rem; }
    .logo-container img { width: 32px; height: 32px; }
    .logo-container { gap: 10px; }

    /* ---- Docs button: icon-only circle ---- */
    .app-header .btn-outline {
        padding: 0;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        flex-shrink: 0;
    }
    .app-header .btn-outline span[class*="material"] { font-size: 18px; }

    /* ---- Bump main-container top padding ---- */
    #main-container { padding-top: 56px; }

    /* ---- App content ---- */
    .app-content { padding: 10px; }
    .card { padding: 14px; }

    /* ---- Loader ---- */
    .loader-content {
        padding: 1.5rem 1rem;
        min-height: 360px; /* keep stable height on small phones */
        width: calc(100% - 20px);
        margin: 0 10px;
    }
    .brand-title { font-size: 1.5rem; }

    /* ---- Stat values ---- */
    .stat-value { font-size: 1.7rem; }
    .stat-label { font-size: 0.78rem; }

    /* ---- File upload ---- */
    .file-upload-area { padding: 28px 12px; }

    /* ---- Tabs nav ---- */
    .tab-btn { padding: 9px 11px; font-size: 0.78rem; }

    /* ---- Data table — tighter ---- */
    .data-table { min-width: 560px; font-size: 0.8rem; }
    .data-table th { padding: 10px 10px; font-size: 0.72rem; }
    .data-table td { padding: 9px 10px; }

    /* ---- Footer ---- */
    .footer-copyright { font-size: 0.7rem; line-height: 1.5; }

    /* ---- Modals ---- */
    .student-modal-content, .docs-modal-content, .preview-modal-content {
        padding: 16px 12px;
    }

    /* ---- Format card grid — keep 1-col ---- */
    .format-cards-grid { grid-template-columns: 1fr !important; }
}

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

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

.hidden { display: none !important; }
.visible { display: block !important; }
.text-center { text-align: center; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-10 { gap: 10px; }
.w-full { width: 100%; }

/* Toast Notifications styling */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: var(--shadow-lg);
    z-index: 4000;
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 400px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }

/* Form inputs & select components */
.custom-select {
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    width: 100%;
    cursor: pointer;
    transition: var(--transition);
}

.custom-select:hover {
    border-color: var(--border-focus);
}

.custom-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

select {
    background-color: #161622 !important;
    color: #fff !important;
    border: 1px solid var(--border-color) !important;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
}

select option {
    background-color: #06060c;
    color: #fff;
}

#correlation-tab select {
    background-color: #161622 !important;
    color: #fff !important;
}

/* Format Option Cards for Report Export Modal */
.format-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.format-card:hover {
    background: rgba(139, 92, 246, 0.1) !important;
    border-color: rgba(139, 92, 246, 0.3) !important;
}

.format-card.selected {
    background: rgba(139, 92, 246, 0.15) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
}

/* ============================================================
   MOBILE TOUCH & SCROLL POLISH
   ============================================================ */

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.data-table-container,
.tabs-nav,
.datasets-strip {
    touch-action: pan-x pan-y;
}

/* Subtle right-fade shadow on scrollable containers to hint at more content */
.data-table-container {
    position: relative;
}

/* Active / pressed state for touch interactions */
.btn:active:not(:disabled) {
    transform: scale(0.97) translateY(0) !important;
    box-shadow: none !important;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.tab-btn:active,
.dataset-pill:active {
    transform: scale(0.97) !important;
    transition: transform 0.1s ease;
}

/* Prevent text selection on interactive elements */
.btn, .tab-btn, .dataset-pill, .format-card {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling for the whole page */
html {
    scroll-behavior: smooth;
}

/* iOS-safe bottom padding for modals (notch-aware) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .student-modal-content,
    .docs-modal-content,
    .preview-modal-content {
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
    #toast-container {
        bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    }
}

/* ============================================================
   ASK GRADIE — DATASET Q&A MODAL STYLES
   ============================================================ */

/* Modal container — wider, taller than default preview-modal-content */
.qa-modal-content {
    background: rgba(14, 14, 24, 0.96);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(139, 92, 246, 0.3);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), 0 0 40px rgba(139, 92, 246, 0.08);
    max-width: 780px;
    width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Modal Header ──────────────────────────────────────────── */
.qa-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.15);
    flex-shrink: 0;
}

.qa-modal-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.qa-modal-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, #6d28d9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.35);
}

.qa-modal-icon .material-icons-round {
    color: white;
    font-size: 24px;
}

.qa-modal-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 3px;
    line-height: 1.2;
}

.qa-modal-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 380px;
}

.qa-close-btn {
    padding: 0 !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    flex-shrink: 0;
    min-height: unset !important;
}

/* ── Suggested Question Chips ─────────────────────────────── */
.qa-chips-bar {
    display: flex;
    gap: 7px;
    padding: 12px 24px;
    overflow-x: auto;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.qa-chips-bar::-webkit-scrollbar { display: none; }

.qa-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 13px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.22);
    border-radius: 20px;
    color: var(--primary-light);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    min-height: 34px;
}

.qa-chip .material-icons-round {
    font-size: 14px;
}

.qa-chip:hover {
    background: rgba(139, 92, 246, 0.18);
    border-color: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.qa-chip:active {
    transform: scale(0.96) !important;
}

/* ── Chat Thread ──────────────────────────────────────────── */
.qa-chat-thread {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    min-height: 200px;
}

.qa-chat-thread::-webkit-scrollbar {
    width: 4px;
}
.qa-chat-thread::-webkit-scrollbar-track {
    background: transparent;
}
.qa-chat-thread::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.25);
    border-radius: 2px;
}

/* Welcome state (shown before first message) */
.qa-welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    gap: 12px;
    flex: 1;
}

.qa-welcome-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(109, 40, 217, 0.08) 100%);
    border: 1px solid rgba(139, 92, 246, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
}

.qa-welcome-icon .material-icons-round {
    font-size: 32px;
    color: var(--primary-light);
    animation: pulseLogo 2s infinite ease-in-out;
}

.qa-welcome-text {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.5;
    max-width: 380px;
}

.qa-welcome-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 340px;
    line-height: 1.5;
}

/* Chat messages */
.qa-message {
    display: flex;
    gap: 10px;
    animation: slideInUp 0.25s ease;
}

.qa-message.user {
    flex-direction: row-reverse;
}

.qa-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.qa-message.ai .qa-message-avatar {
    background: linear-gradient(135deg, var(--primary) 0%, #6d28d9 100%);
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

.qa-message.ai .qa-message-avatar .material-icons-round {
    color: white;
    font-size: 16px;
}

.qa-message.user .qa-message-avatar {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.qa-message.user .qa-message-avatar .material-icons-round {
    color: var(--secondary);
    font-size: 16px;
}

.qa-message-bubble {
    max-width: 82%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    line-height: 1.6;
    font-size: 0.9rem;
}

.qa-message.ai .qa-message-bubble {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    color: var(--text-primary);
    border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
}

.qa-message.user .qa-message-bubble {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25) 0%, rgba(59, 130, 246, 0.2) 100%);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: var(--text-primary);
    text-align: right;
    border-radius: var(--radius-md) 4px var(--radius-md) var(--radius-md);
}

/* AI is typing / streaming indicator */
.qa-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
}

.qa-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-light);
    animation: typingBounce 1.2s infinite ease-in-out;
}

.qa-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.qa-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input Row ────────────────────────────────────────────── */
.qa-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 12px 20px 10px;
    border-top: 1px solid rgba(139, 92, 246, 0.12);
    flex-shrink: 0;
    background: rgba(10, 10, 18, 0.4);
}

.qa-textarea {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
    max-height: 120px;
    overflow-y: auto;
    scrollbar-width: thin;
    min-height: 44px;
}

.qa-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.18);
}

.qa-textarea::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

.qa-send-btn {
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    border-radius: var(--radius-md) !important;
    flex-shrink: 0;
    min-height: unset !important;
}

.qa-send-btn:disabled {
    opacity: 0.35 !important;
}

/* ── Footer note ──────────────────────────────────────────── */
.qa-footer-note {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 20px 12px;
    color: rgba(148, 163, 184, 0.5);
    font-size: 0.72rem;
    flex-shrink: 0;
}

.qa-footer-note .material-icons-round {
    font-size: 13px;
}

/* ── Mobile responsive ────────────────────────────────────── */
@media (max-width: 768px) {
    .qa-modal-content {
        max-height: 94vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .qa-modal-header { padding: 16px 16px 12px; }
    .qa-modal-title { font-size: 1rem; }
    .qa-modal-subtitle { max-width: 200px; }
    .qa-chips-bar { padding: 10px 14px; }
    .qa-chat-thread { padding: 12px 14px; }
    .qa-input-row { padding: 10px 14px 8px; }
    .qa-footer-note { padding: 4px 14px 10px; }
    .qa-message-bubble { max-width: 90%; font-size: 0.85rem; }
}

@media (max-width: 480px) {
    .qa-modal-icon { width: 38px; height: 38px; }
    .qa-modal-icon .material-icons-round { font-size: 20px; }
    .qa-modal-title { font-size: 0.95rem; }
    .qa-modal-subtitle { display: none; }
    .qa-welcome-state { padding: 24px 12px; }
    .qa-welcome-icon { width: 52px; height: 52px; }
}
