:root {
    --bg: #f8fcff;
    --card: #ffffff;
    --text: #14304b;
    --muted: #6e8aa6;
    --line: #dceaf7;
    --primary: #77bdfb;
    --primary-2: #9dd3ff;
    --primary-3: #e9f6ff;
    --shadow: 0 12px 35px rgba(82, 149, 210, 0.12);
    --shadow-soft: 0 8px 24px rgba(82, 149, 210, 0.08);
    --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: Inter, Arial, Helvetica, sans-serif;
    background: linear-gradient(180deg, #f7fbff 0%, #f4faff 100%);
    color: var(--text);
}

a { text-decoration: none; color: inherit; }
small { color: var(--muted); }
strong { color: #0b2d4d; }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    overflow: hidden;
    position: relative;
}

.auth-bg,
.floating-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(8px);
    z-index: 0;
    pointer-events: none;
}

.auth-bg {
    width: 620px;
    height: 620px;
    background: radial-gradient(circle, rgba(157,211,255,.6) 0%, rgba(157,211,255,0) 70%);
    top: -140px;
    right: -120px;
    animation: floatSlow 8s ease-in-out infinite;
}

.orb-1 {
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(157,211,255,.45) 0%, rgba(157,211,255,0) 72%);
    top: 40px;
    left: -80px;
    animation: floatSlow 10s ease-in-out infinite;
}

.orb-2 {
    width: 260px;
    height: 260px;
    background: radial-gradient(circle, rgba(119,189,251,.3) 0%, rgba(119,189,251,0) 72%);
    bottom: 60px;
    right: 50px;
    animation: floatSlow 12s ease-in-out infinite reverse;
}

@keyframes floatSlow {
    0%,100% { transform: translateY(0) translateX(0); }
    50% { transform: translateY(18px) translateX(12px); }
}

.glass {
    background: rgba(255,255,255,.82);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(170, 215, 255, .55);
    box-shadow: var(--shadow);
}

.container,
.panel,
.login-card,
.stat-card,
.podium-card,
.mini-stat,
.sidebar {
    border-radius: var(--radius);
}

.container {
    width: min(1200px, calc(100% - 32px));
    margin: 40px auto;
    position: relative;
    z-index: 1;
}

.leaderboard-page {
    background: rgba(255,255,255,.88);
    border: 1px solid rgba(173, 221, 255, .55);
    box-shadow: var(--shadow);
    padding: 28px;
}

.hero-bar {
    display: grid;
    grid-template-columns: 1.3fr .9fr;
    gap: 22px;
    align-items: start;
    margin-bottom: 24px;
}

.hero-stats,
.stats-grid,
.podium-grid,
.form-grid {
    display: grid;
    gap: 16px;
}

.hero-stats { grid-template-columns: repeat(3, 1fr); }
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 22px; }
.podium-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 22px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.mini-stat,
.stat-card,
.podium-card,
.panel,
.login-card {
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-soft);
}

.mini-stat,
.stat-card {
    padding: 18px;
}

.mini-stat span,
.stat-card span,
.hint-box span,
.eyebrow {
    display: block;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.mini-stat strong,
.stat-card strong,
.score-counter {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    font-weight: 800;
}

.podium-card {
    padding: 22px;
    position: relative;
    overflow: hidden;
}

.podium-card::after {
    content: "";
    position: absolute;
    inset: auto -40px -60px auto;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(119,189,251,.18), rgba(119,189,251,0));
}

.podium-card.winner {
    border-color: #8cc9ff;
    box-shadow: 0 18px 38px rgba(108, 181, 245, .18);
}

.podium-rank,
.rank-badge,
.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--primary-3);
    border: 1px solid #cfe9ff;
    color: #2b6ca3;
    font-size: 12px;
    font-weight: 700;
}

.podium-rank,
.rank-badge { padding: 8px 12px; }
.pill { padding: 8px 14px; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

h1, h2, h3 { margin: 0 0 8px; }
h1 { font-size: clamp(30px, 4vw, 44px); }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
p { color: #426684; line-height: 1.7; margin: 0 0 8px; }
.subtitle { margin-bottom: 18px; }

.panel {
    padding: 22px;
    margin-bottom: 22px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border-radius: 18px;
}

thead th {
    background: linear-gradient(180deg, #dff2ff 0%, #d4edff 100%);
    color: #23527c;
    font-weight: 700;
}

th, td {
    padding: 16px 14px;
    border-bottom: 1px solid #e7f1fb;
    text-align: left;
    background: rgba(255,255,255,.92);
}

tbody tr:last-child td { border-bottom: none; }
.hover-lift { transition: transform .25s ease, box-shadow .25s ease, background .25s ease; }
.hover-lift:hover td { background: #f7fbff; }
.hover-lift:hover { transform: translateY(-2px); }

.progress-bar {
    width: 100%;
    height: 12px;
    background: #eaf4fd;
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #8fd0ff 0%, #62b4ff 100%);
    box-shadow: 0 0 20px rgba(98,180,255,.35);
    transition: width 1.4s cubic-bezier(.2,.9,.2,1);
}

.stack-form label {
    display: block;
    margin: 12px 0 8px;
    font-weight: 700;
}

input, select, textarea, button {
    width: 100%;
    border: 1px solid #d8eaf8;
    border-radius: 14px;
    padding: 13px 14px;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #8dcfff;
    box-shadow: 0 0 0 4px rgba(119,189,251,.18);
}

button,
.btn-primary,
.btn-small {
    cursor: pointer;
    border: none;
}

.btn-primary,
button {
    background: linear-gradient(135deg, #8fd0ff 0%, #64b7ff 100%);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(101, 183, 255, .25);
}

button:hover,
.btn-primary:hover,
.btn-small:hover { transform: translateY(-1px); }
.glow-btn:hover { box-shadow: 0 12px 26px rgba(101, 183, 255, .35); }

.btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px;
    border-radius: 10px;
    margin-right: 6px;
    background: #82c4ff;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}
.btn-small.danger { background: #ff7f9c; }

.alert {
    padding: 12px 16px;
    border-radius: 14px;
    margin-bottom: 16px;
    border: 1px solid #ffd5df;
}
.alert.error { background: #fff1f5; color: #b23b5a; }

.hint-box {
    background: #f5fbff;
    border: 1px dashed #cbe6fb;
    color: #4d7aa0;
    padding: 12px 14px;
    border-radius: 14px;
    margin-top: 12px;
}
.hint-box.compact { padding: 10px 12px; }

.login-card {
    width: min(460px, calc(100% - 32px));
    padding: 28px;
    position: relative;
    z-index: 1;
}

.admin-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    padding: 24px;
    border-right: 1px solid rgba(200, 228, 250, .65);
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.brand small { display: block; }
.brand-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8fd0ff, #64b7ff);
    box-shadow: 0 0 18px rgba(101,183,255,.45);
}

.nav-menu { display: grid; gap: 10px; }
.nav-menu a {
    padding: 12px 14px;
    border-radius: 14px;
    color: #305877;
    font-weight: 600;
    transition: background .2s ease, transform .2s ease;
}
.nav-menu a:hover {
    background: #edf8ff;
    transform: translateX(2px);
}

.content-area {
    padding: 28px;
}

.reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .7s ease, transform .7s ease;
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}
.delay-1 { transition-delay: .08s; }
.delay-2 { transition-delay: .16s; }
.delay-3 { transition-delay: .24s; }
.delay-4 { transition-delay: .32s; }

.tilt-card {
    transform-style: preserve-3d;
    transition: transform .18s ease, box-shadow .18s ease;
}

@media (max-width: 980px) {
    .hero-bar,
    .admin-shell,
    .form-grid {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(200, 228, 250, .65);
    }
}

@media (max-width: 720px) {
    .hero-stats { grid-template-columns: 1fr; }
    .container { width: min(100%, calc(100% - 18px)); margin: 16px auto; }
    .leaderboard-page, .panel, .login-card, .content-area, .sidebar { padding: 18px; }
    th, td { padding: 12px 10px; font-size: 13px; }
}


.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #7cc1ff 0%, #5aaef7 100%);
    border-radius: 999px;
    width: 0;
    transition: width 1.1s ease;
}

.toolbar {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.search-box {
    flex: 1 1 280px;
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.table-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 14px;
}

.bulk-form .row-check,
.bulk-form [data-check-all] {
    width: 18px;
    height: 18px;
    accent-color: #69b7ff;
}

.btn-primary,
.btn-secondary,
.btn-warning,
.btn-danger {
    width: auto;
    padding: 11px 16px;
    border-radius: 12px;
    font-weight: 700;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.btn-primary { background: linear-gradient(180deg, #84c8ff 0%, #68b8ff 100%); color: #083860; }
.btn-secondary { background: #edf7ff; color: #2d6796; border: 1px solid #d6ecff; }
.btn-warning { background: linear-gradient(180deg, #ffd98f 0%, #ffc65f 100%); color: #714700; }
.btn-danger { background: linear-gradient(180deg, #ffadbf 0%, #ff8eaa 100%); color: #7c1130; }

.btn-primary:hover,
.btn-secondary:hover,
.btn-warning:hover,
.btn-danger:hover,
.btn-small:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(89, 160, 225, 0.14);
}

.alert.success {
    background: #ecfbf3;
    color: #17643d;
    border: 1px solid #cbefd9;
}

.empty-row td {
    text-align: center;
    color: var(--muted);
}

@media (max-width: 768px) {
    .toolbar-actions {
        width: 100%;
    }
    .toolbar-actions .btn-secondary,
    .toolbar-actions .btn-warning,
    .toolbar-actions .btn-danger {
        flex: 1 1 calc(50% - 10px);
        text-align: center;
        justify-content: center;
    }
}


.batch-box {
    margin-top: 16px;
}

.matrix-toolbar {
    margin-top: 16px;
}

.batch-score-table input[type="number"],
.batch-score-table input[type="text"] {
    min-width: 100%;
}

.batch-score-table tbody tr td {
    vertical-align: middle;
}

#batchModeBadge {
    white-space: nowrap;
}


/* Student leaderboard */
.student-board-page .hero-bar {
    align-items: end;
}

.student-toolbar {
    display: flex;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
}

.muted-text {
    margin: 6px 0 0;
    color: var(--muted);
}

.search-input-wrap {
    width: 100%;
    max-width: 360px;
}

.search-input-wrap input {
    background: #fff;
}

.student-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.student-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #76bbfb, #a9ddff);
    color: #0b2d4d;
    font-weight: 800;
    box-shadow: var(--shadow-soft);
}

.student-avatar.large {
    width: 64px;
    height: 64px;
    font-size: 24px;
}

.btn-detail {
    border: none;
    cursor: pointer;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 31, 53, 0.32);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 999;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn .22s ease;
}

.modal-card {
    width: min(1100px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border-radius: 26px;
    box-shadow: 0 24px 60px rgba(16, 58, 97, 0.22);
    padding: 24px;
    position: relative;
    animation: liftUp .28s ease;
}

.modal-close {
    position: absolute;
    right: 16px;
    top: 16px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: #edf7ff;
    color: #24527d;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.modal-header {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
}

.modal-header h2 {
    margin: 2px 0 4px;
}

.modal-header p {
    margin: 0;
    color: var(--muted);
}

.modal-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.mini-stat.bordered {
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: none;
}

.modal-progress-wrap {
    padding: 16px 18px;
    border: 1px solid var(--line);
    background: #f9fdff;
    border-radius: 18px;
    margin-bottom: 18px;
}

.progress-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    color: var(--muted);
}

.modal-table-wrap {
    max-height: 46vh;
    overflow: auto;
}

.score-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #edf7ff;
    color: #16436d;
    font-weight: 700;
}

.note-empty {
    color: #9cb0c4;
    font-style: italic;
}

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

@keyframes liftUp {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}


.group-member-list {
    font-size: 13px;
    line-height: 1.6;
    color: #486b89;
    max-width: 380px;
    white-space: normal;
}

.batch-score-table td {
    vertical-align: top;
}

.batch-score-table th,
.batch-score-table td {
    white-space: normal;
}

@media (max-width: 900px) {
    .student-toolbar,
    .modal-header {
        flex-direction: column;
        align-items: start;
    }

    .modal-stats {
        grid-template-columns: 1fr;
    }
}

.muted-copy {
    color: var(--muted);
}

.status-chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-chip.done {
    background: #e8f8ef;
    color: #1f7a45;
}

.status-chip.pending {
    background: #fff5df;
    color: #9a6c00;
}

.compact-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.max-form-sm {
    max-width: 520px;
}

.my-row td {
    background: #f1f9ff;
    font-weight: 700;
}

.student-shell .sidebar small {
    display: block;
    margin-top: 4px;
}

.page-intro { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-group.full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.btn-secondary {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 8px;
    background: #e5e7eb;
    color: #111827;
}
.table-wrap { overflow-x: auto; }
.text-muted { color: #6b7280; }
.alert.success { background: #dcfce7; color: #166534; }
.table-subtext {
    font-size: 12px;
    line-height: 1.5;
    color: #64748b;
}

.status-chip.submitted {
    background: #fef3c7;
    color: #92400e;
}
.task-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.detail-box {
    background: #f8fbff;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    padding: 14px;
}

.detail-box span {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 6px;
}

.detail-box strong {
    color: #0f172a;
    font-size: 16px;
}

.task-instruction-box {
    margin-top: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
    background: #ffffff;
}

.task-instruction-box h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

.instruction-copy {
    line-height: 1.7;
    color: #334155;
}

.task-meta-note {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
}

.task-meta-note p {
    margin: 0 0 8px;
    color: #334155;
}

.task-meta-note p:last-child {
    margin-bottom: 0;
}

.upload-placeholder-box {
    margin-top: 14px;
    padding: 16px;
    background: #eff6ff;
    border: 1px dashed #93c5fd;
    border-radius: 14px;
    color: #1e3a8a;
}

@media (max-width: 900px) {
    .task-detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .task-detail-grid {
        grid-template-columns: 1fr;
    }
}