:root {
    --brand: #6c43e8;
    --brand-dark: #5834c9;
    --brand-soft: #efeaff;
    --teal: #1ac6cf;
    --pink: #ff4d6d;
    --body-bg: #f4f5fb;
    --text: #2f3548;
    --muted: #8b91a7;
    --line: #eef0f6;
    --sidebar-bg: #1b1e2b;
    --sidebar-text: #c5cadb;
    --sidebar-muted: #8e96b0;
    --sidebar-width: 260px;
    --sidebar-mini: 76px;
    --topbar-height: 70px;
    --card-shadow: 0 2px 16px rgba(76, 70, 150, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Nunito", "Segoe UI", Tahoma, sans-serif;
    background: var(--body-bg);
    color: var(--text);
}

a { text-decoration: none; }

.skip-link {
    position: absolute;
    left: -999px;
    top: 8px;
    background: #fff;
    padding: 8px 12px;
    z-index: 2000;
    border-radius: 6px;
}

.skip-link:focus { left: 12px; }

.app { min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid #2a2f42;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, transform 0.2s ease;
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 22px;
    color: #fff;
    font-weight: 800;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.sidebar-brand:hover { color: #fff; }

.sidebar-nav {
    overflow-y: auto;
    padding: 8px 14px 28px;
    flex: 1;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #3a4158; border-radius: 99px; }

.menu-heading {
    margin: 18px 12px 8px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
}

.menu-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--sidebar-text);
    font-weight: 700;
    font-size: 0.95rem;
    text-align: left;
}

.menu-link i { font-size: 1.15rem; width: 22px; }

.menu-link:hover,
.menu-toggle:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.menu-link.active,
.menu-toggle.active { background: var(--brand); color: #fff; }

.menu-link.spaced { margin-top: 14px; }

.menu-caret {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.menu-toggle[aria-expanded="true"] .menu-caret { transform: rotate(90deg); }

.submenu { padding: 4px 0 8px 36px; }

.submenu a {
    display: block;
    padding: 7px 12px;
    border-radius: 6px;
    color: var(--sidebar-muted);
    font-weight: 700;
    font-size: 0.9rem;
}

.submenu a:hover,
.submenu a.active { color: #fff; background: rgba(255, 255, 255, 0.06); }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28, 26, 54, 0.45);
    z-index: 1035;
}

.main-panel {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    background: #fff;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.sidebar-toggle {
    width: 42px;
    height: 42px;
    border: 0;
    background: transparent;
    color: #4b5168;
    font-size: 1.6rem;
    border-radius: 8px;
}

.sidebar-toggle:hover { background: #f6f5fb; color: var(--brand); }

.topbar-user { display: flex; align-items: center; gap: 12px; min-width: 0; }

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-name { font-weight: 800; line-height: 1.1; }
.user-meta { color: var(--muted); font-size: 0.82rem; font-weight: 600; }

.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.context-switch-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 280px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 12px;
    background: #fff;
    color: #5c637a;
    font-weight: 800;
    font-size: 0.9rem;
}

.context-switch-toggle span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.context-switch form { margin: 0; }

.context-switch .dropdown-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
}

.context-switch .context-role {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.context-switch .dropdown-item.active .context-role { color: inherit; }

.topbar-date {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 12px;
    color: #5c637a;
    font-weight: 800;
    font-size: 0.9rem;
    background: #fff;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: #5c637a;
    display: inline-grid;
    place-items: center;
}

.btn-icon:hover { background: #f6f5fb; color: var(--brand); }

.notify-menu { width: min(320px, 90vw); padding: 0; }
.notify-title { padding: 12px 14px; font-weight: 800; border-bottom: 1px solid var(--line); }
.notify-empty, .notify-item { padding: 12px 14px; }
.notify-item { border-bottom: 1px solid #f4f5f8; }
.notify-item strong, .notify-item span { display: block; }
.notify-item span { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

.pagebar {
    background: var(--teal);
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    color: #fff;
}

.pagebar-title { display: flex; align-items: center; gap: 16px; min-width: 0; }
.pagebar h1 { font-size: 1.15rem; font-weight: 800; margin: 0; white-space: nowrap; }

.pagebar .breadcrumb { margin: 0; }
.pagebar .breadcrumb-item,
.pagebar .breadcrumb-item a { color: rgba(255, 255, 255, 0.92); font-weight: 700; font-size: 0.92rem; }
.pagebar .breadcrumb-item a:hover { color: #fff; }
.pagebar .breadcrumb-item.active { color: #fff; }
.pagebar .breadcrumb-item + .breadcrumb-item::before { color: rgba(255, 255, 255, 0.75); }

.page-search {
    display: flex;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.page-search input {
    border: 0;
    width: 220px;
    padding: 10px 14px;
    outline: none;
}

.page-search input:focus { outline: none; }
.page-search button { border: 0; background: var(--pink); color: #fff; width: 46px; }
.page-search button:hover { background: #e8435f; }

.content { padding: 24px 24px 76px; flex: 1; }

.app-footer {
    position: fixed;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    z-index: 1020;
    min-height: 52px;
    padding: 12px 56px;
    background: #3d424d;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.92rem;
    font-weight: 700;
}

.app-footer a { color: #fff; }
.app-footer a:hover { color: #fff; }

.app-footer .go-top {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.15rem;
    line-height: 1;
}

.app-footer .go-top:hover { background: rgba(255, 255, 255, 0.24); color: #fff; }

.stat-card,
.panel {
    background: #fff;
    border: 0;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
}

.stat-card { padding: 20px 22px; height: 100%; }
.stat-label { margin: 0; color: var(--muted); font-weight: 700; font-size: 0.92rem; }
.stat-value { margin: 6px 0 0; font-size: 1.8rem; font-weight: 800; }
.stat-note { margin: 2px 0 0; color: #a0a6bb; font-size: 0.82rem; font-weight: 700; }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.stat-icon-purple { background: #efeaff; color: var(--brand); }
.stat-icon-teal { background: #e5faf8; color: #12a8b0; }
.stat-icon-blue { background: #e8f1ff; color: #3b82f6; }
.stat-icon-orange { background: #fff4e5; color: #f59e0b; }

.panel-header,
.panel-body,
.panel-footer { padding: 18px 20px; }

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--line);
}

.panel-header h2 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.panel-header p { margin: 2px 0 0; color: var(--muted); font-size: 0.86rem; }
.panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--line);
}

.section-label {
    font-size: 1rem;
    font-weight: 800;
    margin: 0 0 14px;
}

.table-erp { margin: 0; min-width: 760px; }
.table-erp thead th {
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #8b91a7;
    font-weight: 800;
    background: #fafbfe;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table-erp td { vertical-align: middle; border-color: #f3f4f8; font-weight: 600; }
.table-erp tbody tr:hover { background: #fbfbfe; }
.table-erp td.text-end { white-space: nowrap; }
.table-erp td.text-end > * + * { margin-left: 8px; }

.btn-brand {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 800;
}
.btn-brand:hover,
.btn-brand:focus { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

.btn-action {
    width: auto;
    height: auto;
    min-height: 32px;
    padding: 0.3rem 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.form-label { font-weight: 800; font-size: 0.86rem; color: #4b5168; }
.form-control,
.form-select {
    border-color: #e4e7f0;
    min-height: 46px;
    border-radius: 6px;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.15rem rgba(108, 67, 232, 0.15);
}
textarea.form-control { min-height: 110px; }

.badge-soft-success { background: #e7f8ef; color: #1b9b57; font-weight: 800; }
.badge-soft-muted { background: #f1f2f6; color: #6d7388; font-weight: 800; }
.badge-soft-purple { background: #efeaff; color: var(--brand); font-weight: 800; }
.badge-soft-danger { background: #fdecec; color: #c24141; font-weight: 800; }
.badge-soft-warning { background: #fff4e5; color: #b86e00; font-weight: 800; }

.detail-list dt { color: var(--muted); font-weight: 800; padding-top: 8px; padding-bottom: 8px; }
.detail-list dd { font-weight: 700; padding-top: 8px; padding-bottom: 8px; margin-bottom: 0; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f8;
}
.activity-list li:last-child { border-bottom: 0; }
.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--teal);
    margin-top: 6px;
    flex-shrink: 0;
}
.activity-list p { margin: 0; font-weight: 800; }
.activity-list small { color: var(--muted); font-weight: 700; }

.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--card-shadow);
    color: var(--text);
    font-weight: 800;
    height: 100%;
}
.quick-action i {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 1.15rem;
}
.quick-action:hover { color: var(--brand); }
.quick-action span { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 700; }

.report-card {
    display: block;
    background: #fff;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    padding: 22px;
    color: var(--text);
    height: 100%;
}
.report-card i { font-size: 1.5rem; color: var(--brand); }
.report-card h3 { font-size: 1.05rem; font-weight: 800; margin: 12px 0 6px; }
.report-card p { margin: 0; color: var(--muted); font-weight: 700; }
.report-card:hover h3 { color: var(--brand); }
.report-card.is-soon { opacity: 0.72; }

.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px 16px;
}
.perm-group { margin-bottom: 16px; }
.perm-group h3 {
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 800;
    margin-bottom: 8px;
}

.pagination .page-link { color: var(--brand); border-color: #e6e8f0; font-weight: 700; }
.pagination .page-item.active .page-link { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .page-link:hover { color: var(--brand-dark); background: #f7f5ff; }

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f5fb;
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 450px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 10px 35px rgba(90, 80, 160, 0.08);
    padding: 42px 36px 32px;
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--brand);
    font-weight: 800;
    font-size: 1.45rem;
    margin-bottom: 26px;
}
.auth-card h1 { font-size: 1.35rem; font-weight: 800; margin: 0 0 4px; color: #1f2433; }
.auth-lead { color: #6c7388; margin-bottom: 22px; font-weight: 700; }
.auth-card .form-control { background: #fff; }
.btn-signin {
    width: 100%;
    height: 46px;
    margin-top: 8px;
    background: #6d45e8;
    border: 0;
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.08em;
    border-radius: 4px;
}
.btn-signin:hover { background: #5b36d0; color: #fff; }
.auth-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    font-size: 0.92rem;
    font-weight: 700;
}
.auth-row a { color: #5c637a; }
.auth-row a:hover { color: var(--brand); }
.auth-note { text-align: center; margin: 26px 0 0; color: #6c7388; font-weight: 700; }
.auth-register {
    border: 0;
    padding: 0;
    background: none;
    color: var(--brand);
    font: inherit;
    font-weight: 800;
    text-decoration: underline;
}
.auth-register:hover { color: var(--brand-dark); }
.auth-partner { display: block; width: 180px; height: auto; margin: 18px auto 0; }

.settings-list { margin: 0; }
.settings-list div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f8;
}
.settings-list dt { color: var(--muted); font-weight: 800; }
.settings-list dd { margin: 0; font-weight: 800; text-align: right; }

@media (min-width: 992px) {
    html.sidebar-collapsed .sidebar { width: var(--sidebar-mini); }
    html.sidebar-collapsed .main-panel { margin-left: var(--sidebar-mini); }
    html.sidebar-collapsed .app-footer { left: var(--sidebar-mini); }
    html.sidebar-collapsed .brand-text,
    html.sidebar-collapsed .menu-label,
    html.sidebar-collapsed .menu-caret,
    html.sidebar-collapsed .menu-heading,
    html.sidebar-collapsed .submenu { display: none; }
    html.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
    html.sidebar-collapsed .menu-link { justify-content: center; padding-left: 0; padding-right: 0; }
}

.metric-card {
    display: block;
    height: 100%;
    padding: 1.1rem 1.2rem;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    color: inherit;
}
.metric-card span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.metric-card strong { display: block; margin-top: 0.35rem; font-size: 1.6rem; }
.metric-card small { color: var(--muted); }

.child-tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.child-tabs form { margin: 0; }

.notice-card {
    height: 100%;
    padding: 1rem 1.1rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
}
.notice-card.pinned { border-left: 4px solid var(--brand); }
.notice-card h3 { margin: 0 0 0.4rem; font-size: 1rem; font-weight: 800; }
.notice-card p { margin: 0 0 0.75rem; }
.notice-card small { color: var(--muted); }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-label { color: var(--muted); font-size: 0.75rem; font-weight: 800; text-align: center; }
.calendar-day {
    min-height: 72px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 0.78rem;
}
.calendar-day strong, .calendar-day span { display: block; }
.calendar-day.muted { background: transparent; border-color: transparent; }
.calendar-day.present { background: #e7f8ef; }
.calendar-day.absent { background: #fdecec; }
.calendar-day.late { background: #fff4e5; }
.calendar-day.half_day { background: #efeaff; }
.calendar-day.excused { background: #e8f6ff; }

.grade-row { margin-bottom: 1.25rem; }
.grade-row h3 { margin: 0; font-size: 1rem; font-weight: 800; }
.grade-bar { height: 10px; background: #f1f2f6; border-radius: 99px; overflow: hidden; }
.grade-bar span { display: block; height: 100%; background: var(--brand); }

.inbox-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1rem; align-items: start; }
.inbox-list a {
    display: block;
    padding: 0.8rem 1rem;
    border-top: 1px solid var(--line);
    color: inherit;
}
.inbox-list a.active { background: var(--brand-soft); }
.inbox-list a strong, .inbox-list a small { display: block; }
.inbox-list a small {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.thread-message {
    margin-bottom: 0.75rem;
    padding: 0.75rem 0.9rem;
    background: #f7f8fc;
    border-radius: 12px;
}
.thread-message.mine { background: var(--brand-soft); }
.thread-message header { display: flex; justify-content: space-between; gap: 1rem; }
.thread-message p { margin: 0.35rem 0 0; }
.thread-subject { font-weight: 800; }

.diary-card {
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
    background: #fff;
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: 12px;
}
.diary-card h3 { margin: 0 0 0.4rem; font-size: 1.05rem; font-weight: 800; }
.diary-card p { margin: 0 0 0.75rem; }
.diary-files { margin: 0 0 0.75rem; padding-left: 1.1rem; }
.diary-tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.diary-tabs a {
    padding: 0.35rem 0.75rem;
    border-radius: 99px;
    background: #f1f2f6;
    color: inherit;
    font-weight: 700;
}
.diary-tabs a.active { background: var(--brand); color: #fff; }

.student-id-badge {
    background: var(--sidebar-bg);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.03em;
}
.topbar-search { position: relative; }
.topbar-search i {
    position: absolute;
    left: 12px;
    top: 10px;
    color: var(--muted);
}
.topbar-search input {
    width: 230px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px 0 34px;
    background: #f7f8fc;
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
    html.sidebar-open .sidebar { transform: translateX(0); }
    html.sidebar-open .sidebar-backdrop { display: block; }
    html.sidebar-open { overflow: hidden; }
    .main-panel { margin-left: 0; }
    .app-footer { left: 0; }
    .topbar-date { display: none; }
}

@media (max-width: 767.98px) {
    .content { padding: 16px 16px 76px; }
    .pagebar { flex-direction: column; align-items: stretch; }
    .pagebar-title { flex-direction: column; align-items: flex-start; gap: 4px; }
    .page-search, .page-search input { width: 100%; }
    .user-meta { display: none; }
    .panel-header, .panel-footer { flex-direction: column; align-items: flex-start; }
    .app-footer { padding-left: 16px; padding-right: 52px; }
    .auth-card { padding: 28px 20px; }
    .inbox-layout { grid-template-columns: 1fr; }
}

.api-docs-page { background: #f4f5fb; }
.api-docs {
    max-width: 860px;
    margin: 0 auto;
    padding: 48px 20px 72px;
}
.api-docs-kicker {
    margin: 0 0 8px;
    color: var(--brand);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.api-docs h1 { font-weight: 800; margin-bottom: 8px; }
.api-docs-lead { color: var(--muted); font-size: 1.05rem; margin-bottom: 28px; }
.api-docs section {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 22px 22px 8px;
    margin-bottom: 16px;
}
.api-docs h2 { font-size: 1.15rem; font-weight: 800; }
.api-docs table { width: 100%; border-collapse: collapse; margin: 12px 0 16px; }
.api-docs th, .api-docs td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.api-docs th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.api-docs pre {
    background: var(--sidebar-bg);
    color: #e8ebf5;
    border-radius: 8px;
    padding: 14px 16px;
    overflow: auto;
    font-size: 0.84rem;
}
