:root {
    --svm-primary: #6b4ea0;
    --svm-primary-dark: #50357f;
    --svm-teal: #2f8f87;
    --svm-ink: #24313b;
    --svm-muted: #687782;
    --svm-bg: #f5f6f8;
    --svm-border: #e3e7eb;
    --svm-sidebar: #24313b;
    --bs-primary: #6b4ea0;
    --bs-primary-rgb: 107, 78, 160;
}

html, body { min-height: 100%; }
body { color: var(--svm-ink); background: var(--svm-bg); }
a { color: var(--svm-primary); }
.btn-primary { --bs-btn-bg: var(--svm-primary); --bs-btn-border-color: var(--svm-primary); --bs-btn-hover-bg: var(--svm-primary-dark); --bs-btn-hover-border-color: var(--svm-primary-dark); }
.btn-outline-primary { --bs-btn-color: var(--svm-primary); --bs-btn-border-color: var(--svm-primary); --bs-btn-hover-bg: var(--svm-primary); --bs-btn-hover-border-color: var(--svm-primary); }
.form-control:focus, .form-select:focus { border-color: #a795c8; box-shadow: 0 0 0 .25rem rgba(107, 78, 160, .14); }
.eyebrow { color: var(--svm-primary); font-size: .76rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.min-width-0 { min-width: 0; }

.auth-body {
    background:
        radial-gradient(circle at 15% 15%, rgba(107, 78, 160, .18), transparent 34%),
        radial-gradient(circle at 85% 85%, rgba(47, 143, 135, .18), transparent 34%),
        #f8f7fb;
    display: grid;
    place-items: center;
}
.auth-card { max-width: 480px; border-radius: 1.4rem; overflow: hidden; }
.auth-alert { max-width: 480px; }
.auth-logo { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 20px; background: linear-gradient(135deg, var(--svm-primary), var(--svm-teal)); color: #fff; font-weight: 800; letter-spacing: .06em; }
.subtle-link { color: #8a939a; font-size: .86rem; text-decoration: none; }
.subtle-link:hover { color: var(--svm-primary); }

.public-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 18%, rgba(107, 78, 160, .15), transparent 30%),
        radial-gradient(circle at 82% 82%, rgba(47, 143, 135, .14), transparent 30%),
        #f8f8fa;
}
.public-main { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.public-access { width: min(100%, 390px); display: flex; align-items: center; flex-direction: column; text-align: center; }
.public-brand { display: flex; align-items: center; flex-direction: column; margin-bottom: 2.5rem; }
.public-brand-mark {
    width: 104px;
    height: 104px;
    margin-bottom: 1.35rem;
    border-radius: 29px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--svm-primary), var(--svm-teal));
    box-shadow: 0 18px 42px rgba(82, 64, 122, .2);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 850;
    letter-spacing: .08em;
}
.public-brand h1 { margin: 0; color: var(--svm-ink); font-size: 2rem; font-weight: 760; letter-spacing: -.035em; line-height: 1.05; }
.public-brand h1 span, .public-brand h1 small { display: block; }
.public-brand h1 small { margin-top: .3rem; color: var(--svm-muted); font-size: 1rem; font-weight: 500; letter-spacing: .04em; }
.public-student-access { width: min(100%, 300px); padding-block: .85rem; border-radius: .8rem; font-weight: 700; box-shadow: 0 10px 25px rgba(107, 78, 160, .18); }
.public-admin-access { margin-top: 1.15rem; color: #a2a8ad; font-size: .76rem; text-decoration: none; }
.public-admin-access:hover, .public-admin-access:focus { color: var(--svm-primary); }

.sidebar {
    --bs-offcanvas-width: 265px;
    --bs-offcanvas-bg: var(--svm-sidebar);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    width: 265px;
    background-color: var(--svm-sidebar) !important;
    color: #fff;
    display: flex;
    flex-direction: column;
}
.sidebar-brand { padding: 1.7rem 1.3rem; display: flex; align-items: center; gap: .8rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand small { color: rgba(255,255,255,.62); }
.brand-mark { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, #8a68c5, #42a69d); font-size: .8rem; font-weight: 800; }
.sidebar-nav { padding: 1rem; display: grid; gap: .3rem; }
.sidebar-nav a { color: rgba(255,255,255,.72); text-decoration: none; padding: .78rem .9rem; border-radius: .75rem; font-weight: 600; }
.sidebar-nav a:hover, .sidebar-nav a.active { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-footer { margin-top: auto; padding: 1.25rem 1.5rem; border-top: 1px solid rgba(255,255,255,.08); display: grid; gap: .65rem; }
.sidebar-footer a, .sidebar-footer button { color: rgba(255,255,255,.68); text-decoration: none; }
.sidebar-footer a:hover, .sidebar-footer button:hover { color: #fff; }
.admin-main { min-height: 100vh; margin-left: 265px; }
.page-container { max-width: 1480px; padding: 2.25rem 2.5rem 4rem; }
.mobile-header { height: 58px; background: var(--svm-sidebar); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 1rem; font-weight: 700; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; }
.page-heading h1 { font-size: clamp(1.8rem, 3vw, 2.45rem); margin: 0; letter-spacing: -.04em; }
.page-heading p:last-child { margin: .35rem 0 0; color: var(--svm-muted); }
.page-heading.compact { max-width: 680px; }
.content-card { background: #fff; border: 1px solid var(--svm-border); border-radius: 1.1rem; padding: clamp(1rem, 3vw, 1.6rem); box-shadow: 0 8px 30px rgba(27, 36, 43, .035); }
.narrow-card { max-width: 680px; }

.metric-card { min-height: 190px; background: linear-gradient(145deg, var(--svm-primary), #8769bd); color: #fff; border-radius: 1.2rem; padding: 1.5rem; display: flex; flex-direction: column; text-decoration: none; box-shadow: 0 12px 32px rgba(107,78,160,.18); transition: transform .2s, box-shadow .2s; }
.metric-card:hover { color: #fff; transform: translateY(-3px); box-shadow: 0 18px 38px rgba(107,78,160,.23); }
.metric-card-alt { background: linear-gradient(145deg, var(--svm-teal), #43a89f); box-shadow: 0 12px 32px rgba(47,143,135,.18); }
.metric-card-dark { background: linear-gradient(145deg, var(--svm-ink), #40505c); box-shadow: 0 12px 32px rgba(36,49,59,.18); }
.metric-card span { font-weight: 700; }
.metric-card strong { font-size: 3.1rem; line-height: 1; margin: auto 0 .65rem; }
.metric-card small { color: rgba(255,255,255,.72); }

.status-pill { display: inline-flex; align-items: center; border-radius: 99px; padding: .3rem .62rem; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.status-pill.active { background: #e4f5f0; color: #247166; }
.status-pill.inactive { background: #eef0f2; color: #6c757d; }
.table > :not(caption) > * > * { padding: .85rem .75rem; border-color: #edf0f2; }
.table thead th { color: var(--svm-muted); font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
.student-row-inactive > * { color: #b42318 !important; }
.mobile-list { border-top: 1px solid var(--svm-border); }
.mobile-list-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem .15rem; border-bottom: 1px solid var(--svm-border); color: inherit; text-decoration: none; }
.mobile-list-item strong, .mobile-list-item span { display: block; }
.mobile-list-item div > span { margin-top: .2rem; color: var(--svm-muted); font-size: .86rem; }
.student-mobile-item.student-row-inactive { color: #b42318; }
.student-mobile-item.student-row-inactive div > span { color: #b42318; }
.student-mobile-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; margin-top: .75rem; }
.student-mobile-meta small { color: var(--svm-muted); font-size: .72rem; }
.student-mobile-meta b { display: block; margin-bottom: .1rem; color: var(--svm-ink); }
.student-mobile-item.student-row-inactive .student-mobile-meta small,
.student-mobile-item.student-row-inactive .student-mobile-meta b { color: #b42318; }
.empty-state { min-height: 200px; display: grid; place-content: center; text-align: center; color: var(--svm-muted); }
.empty-state strong { color: var(--svm-ink); font-size: 1.1rem; }
.empty-state span { margin-top: .35rem; }

.form-section { padding-bottom: 1.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--svm-border); }
.form-section h2 { font-size: 1rem; margin-bottom: 1rem; }
.form-label { font-weight: 650; font-size: .88rem; }
.student-access-summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; border: 1px solid var(--svm-border); border-radius: .75rem; background: #f8f9fa; }
.student-access-summary span, .student-access-summary strong { display: block; }
.student-access-summary span { margin-bottom: .2rem; color: var(--svm-muted); font-size: .78rem; }
.student-selector { max-height: 260px; overflow-y: auto; border: 1px solid var(--svm-border); border-radius: .75rem; padding: .4rem .85rem; }
.student-option { display: flex; gap: .7rem; align-items: center; padding: .65rem 0; border-bottom: 1px solid #f0f2f4; cursor: pointer; }
.student-option:last-child { border-bottom: 0; }

.material-admin-card { height: 100%; border: 1px solid var(--svm-border); border-radius: .9rem; padding: 1rem; display: flex; gap: 1rem; }
.material-admin-card h2 { font-size: 1rem; margin: .1rem 0 .4rem; overflow: hidden; text-overflow: ellipsis; }
.material-admin-card p { color: var(--svm-muted); font-size: .88rem; margin: 0 0 .35rem; }
.material-admin-card small { color: var(--svm-muted); }
.material-icon, .file-badge { background: #f0ebf8; color: var(--svm-primary); font-weight: 800; font-size: .72rem; }
.material-icon { width: 48px; height: 54px; flex: 0 0 auto; border-radius: .65rem; display: grid; place-items: center; }

.student-body { background: #f7f8fa; }
.student-header { min-height: 66px; padding: .8rem max(1rem, calc((100vw - 1140px) / 2)); background: linear-gradient(110deg, var(--svm-sidebar), #354653); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.student-header a { color: rgba(255,255,255,.82); text-decoration: none; font-size: .88rem; }
.student-header .student-brand { color: #fff; font-size: 1rem; font-weight: 800; }
.student-header form { margin: 0; }
.student-welcome h1 { font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -.045em; margin-bottom: .5rem; }
.student-welcome p:last-child { color: var(--svm-muted); }
.student-material-card { min-height: 280px; height: 100%; background: #fff; border: 1px solid var(--svm-border); border-radius: 1.15rem; padding: 1.35rem; display: flex; flex-direction: column; box-shadow: 0 8px 25px rgba(27,36,43,.035); }
.file-badge { align-self: flex-start; border-radius: .45rem; padding: .35rem .5rem; margin-bottom: 1.15rem; }
.student-material-card h2 { font-size: 1.2rem; }
.student-material-card p { color: var(--svm-muted); }
.error-code { display: block; color: var(--svm-primary); font-size: 3rem; font-weight: 850; }
.viewer-body { margin: 0; background: #1d242a; overflow: hidden; }
.viewer-header { height: 62px; background: var(--svm-sidebar); color: #fff; padding: .65rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.viewer-header > div:first-child { min-width: 0; display: flex; align-items: center; gap: .75rem; }
.viewer-header strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-header .file-badge { margin: 0; flex: 0 0 auto; }
.viewer-actions, .viewer-toolbar { display: flex; align-items: center; gap: .5rem; }
.viewer-actions { flex: 0 0 auto; }
.viewer-toolbar { padding-right: .5rem; border-right: 1px solid rgba(255,255,255,.18); }
.viewer-toolbar .btn { min-width: 32px; }
.viewer-zoom { width: 54px; color: rgba(255,255,255,.8); font-size: .78rem; text-align: center; }
.viewer-counter { min-width: 58px; color: rgba(255,255,255,.68); font-size: .75rem; text-align: center; }
.viewer-frame-wrap { position: relative; height: calc(100vh - 62px); }
.pdfjs-pages { width: 100%; height: 100%; padding: 24px; overflow: auto; background: #3d4145; }
.pdfjs-page { position: relative; width: max-content; margin: 0 auto 24px; background: #fff; box-shadow: 0 5px 22px rgba(0,0,0,.32); }
.pdfjs-page canvas { display: block; max-width: none; background: #fff; }
.pdfjs-page-number { position: absolute; right: .5rem; bottom: .45rem; padding: .18rem .42rem; border-radius: .3rem; background: rgba(24,31,37,.72); color: #fff; font-size: .68rem; opacity: 0; transition: opacity .15s; }
.pdfjs-page:hover .pdfjs-page-number { opacity: 1; }
.viewer-state { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 1rem; background: #3d4145; color: rgba(255,255,255,.8); text-align: center; }
.viewer-state.error { color: #fff; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; }
    .admin-main { margin-left: 0; }
    .page-container { padding: 1.35rem 1rem 3rem; }
}

@media (max-width: 575.98px) {
    .page-heading { align-items: stretch; flex-direction: column; }
    .page-heading > .btn { width: 100%; }
    .content-card { border-radius: .85rem; }
    .student-header { align-items: flex-start; }
    .student-header > div { gap: .5rem !important; flex-direction: column; align-items: flex-end !important; }
    .student-access-summary { align-items: stretch; flex-direction: column; }
    .viewer-header { padding-inline: .65rem; }
    .viewer-header > div:first-child { max-width: 34%; }
    .viewer-toolbar { gap: .25rem; padding-right: 0; border-right: 0; }
    .viewer-counter, #fit-width { display: none; }
    .viewer-actions { gap: .3rem; }
    .pdfjs-pages { padding: 12px; }
}
