:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --bg-dark: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --glass-border: rgba(255, 255, 255, 0.1);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.login-screen {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image:
        url("login-library-bg.png"),
        url("https://images.unsplash.com/photo-1521587760476-6c12a4b040da?auto=format&fit=crop&w=1800&q=80");
    background-size: cover;
    background-position: center;
    z-index: 2000;
}

.login-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
}

.login-card {
    position: relative;
    z-index: 1;
    width: min(360px, calc(100vw - 44px));
    background: transparent;
    border-radius: 20px;
    padding: 30px 26px 22px;
    box-shadow: none;
}

.login-card h1 {
    text-align: center;
    font-size: 2.2rem;
    margin-bottom: 16px;
    font-weight: 800;
    background: linear-gradient(to right, #ffffff, #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-input-wrap {
    margin-bottom: 16px;
}

.login-input-wrap input {
    width: 100%;
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    font-size: 0.96rem;
    color: #222;
    background: #eceff3;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.08);
}

.login-input-wrap input:focus {
    outline: 2px solid rgba(128, 90, 213, 0.45);
}

.password-wrap {
    position: relative;
}

.toggle-pass-btn {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #4b5563;
    cursor: pointer;
    font-size: 1.1rem;
}

.login-btn {
    margin-top: 8px;
    width: 100%;
    border: none;
    border-radius: 999px;
    padding: 13px;
    font-size: 1rem;
    letter-spacing: 1px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(90deg, #a855f7, #7c3aed);
    box-shadow: 0 10px 20px rgba(124, 58, 237, 0.35);
}

.login-status {
    min-height: 20px;
    text-align: center;
    margin-top: 10px;
    font-size: 0.88rem;
    color: #dc2626;
    font-weight: 600;
}

.login-footer {
    text-align: center;
    margin-top: 12px;
    font-size: 0.82rem;
    background: linear-gradient(to right, #ffffff, #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 600;
}

.background-accents {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.5;
    border-radius: 50%;
    animation: float 10s infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: var(--primary);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: var(--secondary);
    animation-delay: 2s;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(50px, 50px);
    }
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 5%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.logo span {
    color: var(--primary);
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.7rem;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--text-main);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
}

.hero {
    text-align: center;
    margin-bottom: 2.5rem;
    margin-top: 0;
}

.hero h1 {
    font-size: 1.1rem;
    background: linear-gradient(to right, #a855f7, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 0.8rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem 3rem;
    margin-bottom: 0;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.glass-panel h2 {
    margin-bottom: 2rem;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.input-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.input-group input,
.input-group select {
    padding: 0.6rem;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-size: 0.7rem;
    transition: border-color 0.3s;
}

.input-group input[type="file"]::file-selector-button {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    margin-right: 10px;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

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

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

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

.secondary-btn:hover {
    background: var(--secondary);
    color: white;
    transform: translateY(-2px);
}

.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

.hidden {
    display: none !important;
}

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

.status-msg {
    margin-top: 1rem;
    text-align: center;
    font-weight: 600;
}

.subject-delete-panel {
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.subject-delete-panel h3 {
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
}

.subject-delete-panel p {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.delete-btn {
    margin-top: 0.5rem;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #fca5a5;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-2px);
}

.download-links {
    margin-top: 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.download-card {
    padding: 1.5rem;
    border-radius: 15px;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.3s;
    border: 1px solid var(--glass-border);
}

.docx {
    background: rgba(43, 87, 154, 0.2);
    color: #4da3ff;
}

.pdf {
    background: rgba(226, 82, 82, 0.2);
    color: #ff6b6b;
}

.download-card:hover {
    transform: translateY(-5px);
}

/* Modal CSS */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    margin: auto;
    width: 80%;
    max-width: 500px;
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

/* Outline Button CSS */
.outline-btn {
    background: transparent;
    border: 1px dashed var(--primary);
    color: var(--primary);
    padding: 0.6rem;
    font-size: 0.8rem;
}

.outline-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    transform: none;
}

/* Dynamic Section Item */
.dynamic-section-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--glass-border);
}

.remove-section {
    color: #ff6b6b;
    cursor: pointer;
    font-size: 0.9rem;
    background: none;
    border: none;
    float: right;
}

/* Analytics Dashboard Styles */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.08);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.analytics-item-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid var(--glass-border);
}

.analytics-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-weight: 600;
}

.progress-container {
    height: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 5px;
    transition: width 0.5s ease-out;
}

.percentage-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
}

.status-indicator {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-high {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.status-moderate {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.status-critical {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
}

.subject-health-header {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 15px;
    margin-bottom: 25px;
    border: 1px dashed var(--glass-border);
}

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

.health-stat .val {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
}

.health-stat .lbl {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =============================================
   HISTORY TAB — Professional Pill-Filter UI
   ============================================= */

.hist-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
}

.hist-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}

.hist-filter-group {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.hist-filter-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 80px;
}

.hist-pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hist-pill {
    padding: 7px 20px;
    border-radius: 999px;
    border: 1.5px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.04);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: 'Outfit', sans-serif;
}

.hist-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99,102,241,0.1);
    transform: translateY(-1px);
}

.hist-pill.active {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 16px rgba(99,102,241,0.35);
    transform: translateY(-1px);
}

.hist-pill-placeholder {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.3);
    font-style: italic;
}

.hist-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease;
}

.hist-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.hist-stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
    animation: fadeIn 0.4s ease;
}

.hist-stat-card {
    flex: 1;
    min-width: 120px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 16px 20px;
    text-align: center;
}

.hist-stat-card .val {
    font-size: 0.9rem;
    font-weight: 800;
    display: block;
    line-height: 1;
    margin-bottom: 4px;
}

.hist-stat-card .lbl {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.hist-exam-section {
    margin-bottom: 28px;
    animation: fadeIn 0.4s ease;
}

.hist-exam-section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

.hist-subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.hist-subject-card {
    position: relative;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 16px 18px 16px 22px;
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
    overflow: hidden;
}

.hist-subject-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.hist-subject-card.generated::before {
    background: linear-gradient(180deg, #4ade80, #22c55e);
}

.hist-subject-card.not-generated::before {
    background: rgba(255,255,255,0.08);
}

.hist-subject-card:hover {
    transform: translateY(-3px);
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.15);
}

.hist-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.hist-subject-name-card {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
    flex: 1;
    margin-right: 8px;
}

.hist-subject-code-badge {
    font-size: 0.55rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(99,102,241,0.15);
    border: 1px solid rgba(99,102,241,0.3);
    color: #a5b4fc;
    white-space: nowrap;
}

.hist-card-meta {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.5;
}

.hist-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hist-gen-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
}

.hist-gen-badge.generated {
    background: rgba(74,222,128,0.12);
    color: #4ade80;
    border: 1px solid rgba(74,222,128,0.35);
}

.hist-gen-badge.not-generated {
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

.hist-dl-btn {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 8px;
    border: 1px solid rgba(99,102,241,0.4);
    color: #a5b4fc;
    background: rgba(99,102,241,0.1);
    text-decoration: none;
    transition: background 0.2s;
}

.hist-dl-btn:hover {
    background: rgba(99,102,241,0.25);
}

.hist-generated-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hist-no-items {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.25);
    font-style: italic;
    padding: 8px 4px;
}

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

/* === CSV Import Lock Banner === */
.csv-lock-banner {
    margin-top: 14px;
    padding: 14px 18px;
    border-radius: 12px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.4);
    animation: fadeIn 0.3s ease;
    font-size: 0.82rem;
    line-height: 1.6;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}