:root {
    --bg-dark: #09090b;
    --bg-card: rgba(23, 23, 23, 0.6);
    --sidebar-bg: #000000;
    --accent-aurora: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    --accent-vibrant: #a78bfa;
    --text-high: #fafafa;
    --text-med: #a1a1aa;
    --border-glass: rgba(255, 255, 255, 0.1);
    --shadow-aurora: 0 0 30px rgba(129, 140, 248, 0.15);
    --radius-xl: 24px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-high);
    font-family: 'Plus Jakarta Sans', sans-serif;
    line-height: 1.6;
    height: 100vh;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(129, 140, 248, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(192, 132, 252, 0.05) 0%, transparent 40%);
}

#app-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
}

.main-content {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.content-body {
    width: 100%;
    max-width: 1100px;
    padding: 3rem 2rem;
}

.top-bar {
    width: 100%;
    max-width: 1100px;
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Sidebar - Matte Black */
.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-glass);
    padding: 2.5rem 1.5rem;
}

.sidebar-header h2 {
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: -0.04em;
    background: var(--accent-aurora);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav a {
    color: var(--text-med);
    padding: 0.9rem 1.2rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-high);
}

.sidebar-nav a.active {
    box-shadow: 0 0 0 1px var(--border-glass);
    background: rgba(255, 255, 255, 0.03);
    position: relative;
}

.sidebar-nav a.active::after {
    content: '';
    position: absolute;
    left: -1px;
    width: 3px;
    height: 60%;
    background: var(--accent-aurora);
    border-radius: 4px;
}

.nav-icon {
    font-size: 1.1rem;
    width: 28px;
    display: inline-flex;
    justify-content: center;
    margin-right: 0.5rem;
}

.nav-text {
    flex: 1;
}

/* Glass Cards */
.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-aurora);
}

.stat-label {
    color: var(--text-med);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    margin-top: 0.5rem;
    color: var(--text-high);
}

.nav-btn-link {
    background: none;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.9rem 1.2rem;
    border-radius: 12px;
    transition: all 0.3s;
}

.nav-btn-link:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Dept Cards Table/Grid Alignment */
.dept-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 2rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    min-height: 200px;
}

.dept-card:hover {
    transform: translateY(-8px);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(129, 140, 248, 0.4);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Non-admin: cards are read-only */
.dept-card-locked {
    cursor: default;
    opacity: 0.8;
}

.dept-card-locked:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border-glass);
    background: var(--bg-card);
}

/* Premium Centered Search Bar */
.search-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 4.5rem auto 3.5rem auto;
}

.search-bar {
    width: 100%;
    max-width: 650px;
    position: relative;
}

.search-bar input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    padding: 1.25rem 2rem 1.25rem 4rem;
    border-radius: 100px;
    color: white;
    font-family: inherit;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    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='%23818cf8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 1.5rem center;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.search-bar input:focus {
    border-color: #818cf8;
    background-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 15px 40px -10px rgba(129, 140, 248, 0.2), 0 0 0 4px rgba(129, 140, 248, 0.1);
    transform: translateY(-2px);
}

/* Scoring Header Enhancement */
.scoring-header-new {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    margin-bottom: 5rem;
    align-items: center;
    text-align: center;
}

.dept-title-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--accent-aurora);
    border-color: transparent;
}

.phase-tabs {
    display: flex;
    gap: 0.75rem;
}

.goal-item {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    transition: transform 0.2s;
}

.goal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-high);
}

.score-options {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.score-btn {
    flex: 1;
    padding: 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-med);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.score-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-med);
}

.score-btn.active {
    background: var(--accent-aurora);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(129, 140, 248, 0.3);
}

.notes-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    color: var(--text-high);
    font-family: inherit;
    outline: none;
}

.progress-bar-bg {
    background: rgba(255, 255, 255, 0.03);
    height: 10px;
    border-radius: 20px;
    margin-top: 1.5rem;
}

.progress-fill {
    background: var(--accent-aurora);
    height: 100%;
    border-radius: 20px;
    box-shadow: 0 0 15px rgba(129, 140, 248, 0.3);
}

/* Buttons & Tabs */
.tab-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    color: var(--text-med);
    padding: 0.8rem 1.8rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background: var(--text-high);
    color: var(--bg-dark);
    border-color: var(--text-high);
}

/* Login Overhaul */
.login-container {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #09090b 0%, #000000 100%);
    z-index: 1000;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: 36px;
    padding: 3.5rem;
    width: 100%;
    max-width: 440px;
    text-align: center;
    box-shadow: 0 50px 100px -20px rgba(0, 0, 0, 0.9), 0 0 40px -10px rgba(129, 140, 248, 0.25);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-form {
    width: 100%;
}

.login-footer {
    width: 100%;
    margin-top: 3rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    opacity: 0.4;
}

.footer-line {
    flex: 1;
    height: 1px;
    background: white;
    /* Ensure visible */
}

.login-badge {
    width: 64px;
    height: 64px;
    background: var(--accent-aurora);
    border-radius: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    box-shadow: 0 10px 20px rgba(129, 140, 248, 0.3);
    margin-bottom: 2rem;
}

.login-title {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -1.5px;
    margin-bottom: 0.5rem;
    color: white;
}

.login-subtitle {
    color: var(--text-med);
    font-size: 1rem;
    margin-bottom: 3rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 600;
}

.login-form input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    color: white;
    margin-bottom: 1rem;
    width: 100%;
    font-size: 1rem;
    transition: all 0.3s;
}

.login-form input:focus {
    border-color: #818cf8;
    background: rgba(255, 255, 255, 0.06);
    outline: none;
}

.login-form button {
    width: 100%;
    background: var(--accent-aurora);
    color: white;
    padding: 1.25rem;
    border-radius: 16px;
    font-weight: 700;
    border: none;
    margin-top: 1.5rem;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-form button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(129, 140, 248, 0.4);
}

.login-footer {
    margin-top: 4rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    opacity: 0.4;
}

.footer-line {
    flex: 1;
    height: 1px;
    background: var(--border-glass);
}

.footer-text {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    white-space: nowrap;
}

/* Champion View - Full Screen Pro */
.champion-container {
    height: calc(100vh - 120px);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: rgba(0, 0, 0, 0.4);
}

.aurora-glow-giant {
    position: absolute;
    width: 600px;
    height: 600px;
    background: var(--accent-aurora);
    filter: blur(150px);
    opacity: 0.2;
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.champion-content-box {
    position: relative;
    z-index: 10;
    text-align: center;
}

.medal-giant {
    font-size: 8rem;
    margin-bottom: 2rem;
    filter: drop-shadow(0 0 20px rgba(192, 132, 252, 0.5));
}

.champion-title {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: -0.05em;
    margin-bottom: 1rem;
    background: var(--accent-aurora);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.champion-dept {
    font-size: 2rem;
    color: white;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.champion-message {
    color: var(--text-med);
    margin-bottom: 3rem;
    font-size: 1.1rem;
}

/* Activity Log Badges */
.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge.score_update {
    background: rgba(129, 140, 248, 0.1);
    color: #818cf8;
    border: 1px solid rgba(129, 140, 248, 0.2);
}

.badge.note_update {
    background: rgba(52, 211, 153, 0.1);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.2);
}

/* Alignment Polish */
.btn-primary {
    background: var(--accent-aurora);
    color: white;
    padding: 1rem 2.5rem;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    font-size: 1.1rem;
    transition: transform 0.2s;
}

.btn-primary:hover {
    transform: scale(1.05);
}

/* Table Alignments */
.leaderboard-table th {
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 1.5rem;
}

.leaderboard-table td {
    padding: 1.5rem 1rem;
    vertical-align: middle;
}

.text-right {
    text-align: right !important;
}

/* Grid Consistency */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

.dept-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

/* Activity Logs */
.badge.score_update {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge.permission_change {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ── Create User Button ─────────────────────── */
.btn-create-user {
    background: var(--accent-aurora);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.btn-create-user:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(129, 140, 248, 0.4);
}

.btn-delete-user {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.2);
    padding: 0.4rem 1rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-delete-user:hover {
    background: rgba(248, 113, 113, 0.25);
    border-color: #f87171;
}

/* ── Create User Modal ──────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-card {
    background: #141416;
    border: 1px solid var(--border-glass);
    border-radius: 28px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.9), 0 0 30px rgba(129, 140, 248, 0.15);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 2rem 1.5rem 2rem;
    border-bottom: 1px solid var(--border-glass);
}

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 800;
}

.modal-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-med);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
}

.modal-body {
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-row label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-med);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-row input[type="text"],
.form-row input[type="password"],
.form-row select {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s;
    width: 100%;
}

.form-row input:focus,
.form-row select:focus {
    border-color: #818cf8;
}

.form-row select option {
    background: #141416;
}

.form-row-check {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.form-row-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #818cf8;
    cursor: pointer;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-med);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-submit {
    background: var(--accent-aurora);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(129, 140, 248, 0.4);
}