:root {
    --sms-bg: #f4f7fb;
    --sms-sidebar: #172033;
    --sms-sidebar-deep: #101827;
    --sms-sidebar-panel: #30292f;
    --sms-sidebar-module: #5d575b;
    --sms-sidebar-module-active: #272127;
    --sms-sidebar-raised: rgba(255, 255, 255, .08);
    --sms-sidebar-active: #2563eb;
    --sms-sidebar-active-soft: rgba(37, 99, 235, .18);
    --sms-sidebar-text: rgba(255, 255, 255, .78);
    --sms-sidebar-width: 286px;
    --sms-text: #172033;
    --sms-muted: #64748b;
    --sms-border: #e2e8f0;
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    margin: 0;
    background: var(--sms-bg);
    color: var(--sms-text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
    overflow-x: hidden;
}

img,
svg,
canvas,
iframe {
    max-width: 100%;
}

input,
select,
textarea,
button {
    max-width: 100%;
}

.row > *,
.content,
.content-body,
.panel,
.modal-content,
.modal-body {
    min-width: 0;
}

.form-select[multiple] {
    min-height: 132px;
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
}

.table th,
.table td {
    vertical-align: middle;
}

.table td.text-end {
    white-space: nowrap;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(120deg, rgba(37, 99, 235, .12), rgba(20, 184, 166, .14)),
        #eef4ff;
}

.auth-shell {
    width: min(100%, 440px);
}

.auth-panel,
.panel,
.metric-card {
    background: #fff;
    border: 1px solid var(--sms-border);
    border-radius: 8px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, .08);
}

.auth-panel {
    padding: 32px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    font-weight: 800;
    text-decoration: none;
}

.brand-mark.has-logo,
.sidebar-brand-mark.has-logo {
    background: #fff;
    color: var(--sms-primary);
    padding: 4px;
}

.brand-mark img,
.sidebar-brand-mark img {
    display: block;
    height: 100%;
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    width: 100%;
}

.brand-mark img {
    border-radius: 6px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .08);
    color: #fff;
    text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
}

.sidebar-brand:hover {
    color: #fff;
    background: rgba(255, 255, 255, .11);
}

.sidebar-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--sms-sidebar-active);
    box-shadow: 0 10px 24px rgba(37, 99, 235, .28);
}

.sidebar-brand-mark img {
    border-radius: 6px;
}

.sidebar-brand-copy {
    min-width: 0;
}

.sidebar-brand-title {
    display: block;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.18;
    overflow-wrap: anywhere;
}

.sidebar-brand-subtitle {
    display: block;
    margin-top: 3px;
    color: rgba(255, 255, 255, .62);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.app-layout {
    min-height: 100vh;
    display: flex;
    position: relative;
}

.sidebar {
    width: var(--sms-sidebar-width);
    min-height: 100vh;
    max-height: 100vh;
    background: linear-gradient(180deg, var(--sms-sidebar) 0%, var(--sms-sidebar-deep) 100%);
    color: #fff;
    padding: 16px 14px;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1020;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border-right: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 12px 0 34px rgba(15, 23, 42, .18);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .18);
    border-radius: 8px;
}

.sidebar-close {
    display: none;
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    padding-right: 2px;
}

.sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 4px;
}

.sidebar-list .sidebar-list {
    margin: 6px 0 2px 18px;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, .1);
}

.sidebar-item {
    min-width: 0;
}

.sidebar-link,
.sidebar-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    border: 1px solid transparent;
    color: var(--sms-sidebar-text);
    text-decoration: none;
    padding: 9px 10px;
    border-radius: 8px;
    font-weight: 600;
    line-height: 1.25;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.sidebar-link-main {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    gap: 10px;
    min-width: 0;
}

.sidebar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    color: rgba(255, 255, 255, .8);
    font-size: 13px;
}

.sidebar-text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.sidebar-summary {
    cursor: pointer;
    list-style: none;
}

.sidebar-summary::-webkit-details-marker {
    display: none;
}

.sidebar-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 18px;
    color: currentColor;
    font-size: 11px;
    opacity: .7;
    transition: transform .18s ease, opacity .18s ease;
}

.sidebar-details[open] > .sidebar-summary .sidebar-chevron {
    opacity: 1;
    transform: rotate(90deg);
}

.sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-summary {
    color: #fff;
    background: rgba(255, 255, 255, .06);
    font-weight: 800;
}

.sidebar-level-1 .sidebar-link,
.sidebar-level-1 .sidebar-summary {
    font-size: 13px;
    min-height: 38px;
    padding: 8px 9px;
}

.sidebar-level-1 .sidebar-icon {
    flex-basis: 24px;
    width: 24px;
    height: 24px;
    font-size: 11px;
}

.sidebar-level-2 .sidebar-link,
.sidebar-level-2 .sidebar-summary {
    font-size: 12.5px;
    min-height: 34px;
    padding: 7px 8px;
}

.sidebar-level-2 .sidebar-icon {
    flex-basis: 18px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    font-size: 7px;
    background: rgba(255, 255, 255, .12);
}

.sidebar-link.active,
.sidebar-link:hover,
.sidebar-summary:hover {
    border-color: rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .09);
    color: #fff;
}

.sidebar-details[open] > .sidebar-summary {
    border-color: rgba(37, 99, 235, .34);
    background: var(--sms-sidebar-active-soft);
    color: #fff;
}

.sidebar-link.active {
    border-color: rgba(255, 255, 255, .2);
    background: linear-gradient(135deg, var(--sms-sidebar-active), #1d4ed8);
    box-shadow: 0 12px 26px rgba(37, 99, 235, .28);
}

.sidebar-link.active .sidebar-icon,
.sidebar-details[open] > .sidebar-summary .sidebar-icon,
.sidebar-link:hover .sidebar-icon,
.sidebar-summary:hover .sidebar-icon {
    background: rgba(255, 255, 255, .16);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    padding: 0;
    border-top: none;
}

.sidebar-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    background: rgba(23, 32, 51, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}

.sidebar-user-card:hover {
    background: rgba(37, 99, 235, 0.2);
    border-color: rgba(37, 99, 235, 0.4);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.sidebar-user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex-grow: 1;
}

.sidebar-user-caption {
    font-size: 0.66rem;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.sidebar-user-title {
    font-size: 0.84rem;
    color: #ffffff;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-badge {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.38);
    transition: transform 0.2s ease, color 0.2s ease;
    margin-left: auto;
}

.sidebar-user-card:hover .sidebar-user-badge {
    color: #60a5fa;
    transform: translateX(2px) translateY(-1px);
}

.sidebar {
    width: var(--sms-sidebar-width);
    padding: 10px 0 14px;
    gap: 8px;
    background: var(--sms-sidebar-panel);
    border-right: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 14px 0 36px rgba(15, 23, 42, .2);
}

.sidebar-brand {
    min-height: 58px;
    margin: 0 10px 8px;
    padding: 10px 12px;
    background: rgba(23, 32, 51, .72);
}

.sidebar-brand-mark {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
}

.sidebar-nav {
    padding-right: 0;
}

.sidebar-list {
    gap: 0;
}

.sidebar-list .sidebar-list {
    margin: 0;
    padding: 0;
    border-left: 0;
}

.sidebar-level-0 {
    gap: 6px;
}

.sidebar-level-0 > .sidebar-item {
    padding-inline: 0;
}

.sidebar-level-0 > .sidebar-item > .sidebar-link,
.sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-summary {
    min-height: 72px;
    padding: 14px 18px 14px 42px;
    border-radius: 0 8px 8px 0;
    border-width: 0 0 0 4px;
    background: var(--sms-sidebar-module);
    color: #fff;
    font-size: 18px;
    font-weight: 500;
}

.sidebar-level-0 > .sidebar-item > .sidebar-link .sidebar-icon,
.sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-summary .sidebar-icon {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
    background: transparent;
    color: #fff;
    font-size: 25px;
}

.sidebar-level-0 > .sidebar-item > .sidebar-link.active {
    border-color: #7c3aed;
    background: #337fb9;
    box-shadow: none;
}

.sidebar-level-0 > .sidebar-branch > .sidebar-details[open] > .sidebar-summary,
.sidebar-level-0 > .sidebar-branch > .sidebar-details.is-active-tree > .sidebar-summary {
    border-color: var(--sms-sidebar-active);
    background: var(--sms-sidebar-module-active);
    box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, .78),
        0 12px 26px rgba(15, 23, 42, .16);
}

.sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-summary:hover,
.sidebar-level-0 > .sidebar-item > .sidebar-link:hover {
    background: #3a82b9;
    color: #fff;
}

.sidebar-level-0 > .sidebar-branch > .sidebar-details[open] > .sidebar-summary:hover,
.sidebar-level-0 > .sidebar-branch > .sidebar-details.is-active-tree > .sidebar-summary:hover {
    background: var(--sms-sidebar-module-active);
}

.sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-list {
    padding: 16px 12px 18px 92px;
    background: var(--sms-sidebar-module-active);
}

.sidebar-level-1,
.sidebar-level-2 {
    gap: 9px;
}

.sidebar-level-1 .sidebar-list,
.sidebar-level-2 .sidebar-list {
    padding: 8px 0 6px 32px;
}

.sidebar-level-1 .sidebar-link,
.sidebar-level-1 .sidebar-summary,
.sidebar-level-2 .sidebar-link,
.sidebar-level-2 .sidebar-summary {
    min-height: 46px;
    padding: 7px 8px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 15px;
    font-weight: 500;
}

.sidebar-level-1 .sidebar-icon,
.sidebar-level-2 .sidebar-icon {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
    background: transparent;
    color: #fff;
    font-size: 18px;
}

.sidebar-level-2 .sidebar-icon {
    flex-basis: 26px;
    width: 26px;
    height: 26px;
    font-size: 12px;
}

.sidebar-level-1 .sidebar-link:hover,
.sidebar-level-1 .sidebar-summary:hover,
.sidebar-level-2 .sidebar-link:hover,
.sidebar-level-2 .sidebar-summary:hover {
    background: rgba(255, 255, 255, .08);
}

.sidebar-level-1 .sidebar-details[open] > .sidebar-summary,
.sidebar-level-2 .sidebar-details[open] > .sidebar-summary {
    background: rgba(255, 255, 255, .06);
    box-shadow: none;
}

.sidebar-level-1 .sidebar-link.active,
.sidebar-level-2 .sidebar-link.active {
    background: var(--sms-sidebar-active);
    box-shadow: none;
}

.sidebar-level-1 .sidebar-text,
.sidebar-level-2 .sidebar-text {
    overflow-wrap: anywhere;
}

.sidebar-chevron {
    font-size: 13px;
}

.sidebar-footer {
    margin: 10px 12px 0;
    border-radius: 8px;
    background: rgba(23, 32, 51, .42);
}

.sidebar {
    overflow: hidden;
}

.sidebar-brand,
.sidebar-close,
.sidebar-footer {
    flex: 0 0 auto;
}

.sidebar-nav {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

.sidebar-nav::-webkit-scrollbar {
    width: 8px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .18);
    border-radius: 8px;
}

.sidebar-nav ul,
.sidebar-nav li {
    list-style: none !important;
    margin: 0;
    padding: 0;
}

.sidebar-nav li {
    display: block;
}

.sidebar-nav li::marker,
.sidebar-summary::marker {
    content: "";
    font-size: 0;
}

.sidebar-summary {
    display: flex;
    appearance: none;
    -webkit-appearance: none;
    list-style: none !important;
}

.sidebar-summary::-webkit-details-marker {
    display: none !important;
}

.sidebar-details {
    display: block;
}

.sidebar-link,
.sidebar-summary {
    text-align: left;
}

.sidebar-level-0 > .sidebar-item > .sidebar-link,
.sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-summary {
    min-height: 64px;
    padding: 12px 12px 12px 18px;
}

.sidebar-level-0 > .sidebar-item > .sidebar-link .sidebar-icon,
.sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-summary .sidebar-icon {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    font-size: 22px;
}

.sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-list {
    padding: 8px 10px 12px 18px;
}

.sidebar-level-1,
.sidebar-level-2 {
    gap: 4px;
}

.sidebar-level-1 .sidebar-list,
.sidebar-level-2 .sidebar-list {
    padding: 4px 0 4px 16px;
}

.sidebar-level-1 .sidebar-link,
.sidebar-level-1 .sidebar-summary,
.sidebar-level-2 .sidebar-link,
.sidebar-level-2 .sidebar-summary {
    min-height: 38px;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 14px;
}

.sidebar-level-1 .sidebar-icon,
.sidebar-level-2 .sidebar-icon {
    flex-basis: 28px;
    width: 28px;
    height: 28px;
    font-size: 15px;
}

.sidebar-level-2 .sidebar-icon {
    flex-basis: 22px;
    width: 22px;
    height: 22px;
    font-size: 11px;
}

.sidebar-link-main {
    max-width: 100%;
}

.sidebar-text {
    overflow-wrap: normal;
    word-break: normal;
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: var(--sms-sidebar-width);
    min-height: 100vh;
    min-width: 0;
}

.wrapper {
    min-height: 100vh;
}

.wrapper > .topbar {
    margin-left: var(--sms-sidebar-width);
}

.wrapper > .container-fluid {
    padding: 0;
}

.wrapper > .container-fluid > .row {
    display: block;
    margin: 0;
}

.main-content {
    width: auto;
    max-width: none;
    margin-left: var(--sms-sidebar-width);
    padding: 24px;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--sms-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
    padding: 12px 24px;
    position: sticky;
    top: 0;
    z-index: 1010;
    flex-wrap: wrap;
}

.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border: 1px solid var(--sms-border);
    border-radius: 8px;
    background: #fff;
    color: var(--sms-text);
}

.sidebar-toggle:hover,
.sidebar-toggle:focus {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: var(--sms-sidebar-active);
}

.topbar-heading {
    flex: 1 1 320px;
    min-width: 0;
}

.topbar-title {
    display: block;
    font-size: 1rem;
    line-height: 1.25;
}

.topbar-meta {
    margin-top: 2px;
    overflow-wrap: anywhere;
}

.topbar-account {
    flex: 0 1 auto;
    margin-left: auto;
    min-width: 0;
}

.topbar-account .dropdown-toggle::after,
.topbar-user-btn::after {
    display: none !important;
}

.topbar-user-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 4px 12px 4px 5px;
    background: #ffffff;
    border: 1px solid var(--sms-border);
    border-radius: 9999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    text-decoration: none;
}

.topbar-user-btn:hover,
.topbar-user-btn:focus,
.topbar-account.show .topbar-user-btn {
    background: #f8fafc;
    border-color: #93c5fd;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

.topbar-avatar-pill {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(37, 99, 235, 0.25);
}

.topbar-user-meta {
    line-height: 1.15;
}

.topbar-user-label {
    font-size: 0.66rem;
    color: var(--sms-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.topbar-user-name {
    font-size: 0.82rem;
    color: var(--sms-text);
    font-weight: 700;
    white-space: nowrap;
}

.topbar-user-arrow {
    font-size: 0.72rem;
    color: #94a3b8;
    transition: transform 0.2s ease;
}

.topbar-account.show .topbar-user-arrow {
    transform: rotate(180deg);
    color: #2563eb;
}

.topbar-dropdown-menu {
    min-width: 250px;
    border-radius: 12px !important;
}

.topbar-avatar-lg {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.content-body {
    padding: 24px;
}

.panel {
    padding: 24px;
}

.panel h1,
.panel h2 {
    margin: 0 0 6px;
    font-size: 1.35rem;
}

.metric-card {
    padding: 20px;
}

.metric-card span {
    color: var(--sms-muted);
    display: block;
    font-size: .92rem;
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 2rem;
}

.section-title {
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--sms-border);
    color: var(--sms-text);
    font-weight: 800;
}

.admission-steps {
    display: none;
}

.admission-step {
    border: 1px solid var(--sms-border);
    background: #fff;
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 700;
    color: var(--sms-text);
    text-decoration: none;
}

.admission-step.active,
.admission-step:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.admission-step-panel {
    display: block;
    scroll-margin-top: 74px;
}

.builder-board {
    display: grid;
    gap: 14px;
}

.builder-section {
    border: 1px solid var(--sms-border);
    border-radius: 8px;
    background: #f8fafc;
    overflow: hidden;
}

.builder-section-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    background: #fff;
    border-bottom: 1px solid var(--sms-border);
}

.builder-field-list {
    min-height: 54px;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.builder-field {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--sms-border);
    border-radius: 8px;
    padding: 10px;
}

.builder-field-main {
    flex: 1 1 260px;
    min-width: 180px;
}

.builder-field small {
    display: block;
    color: var(--sms-muted);
}

.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--sms-border);
    border-radius: 8px;
    background: #f8fafc;
    cursor: grab;
    color: var(--sms-muted);
    font-weight: 800;
}

.drag-handle:active {
    cursor: grabbing;
}

.builder-field-order,
.builder-field-switches,
.builder-field-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.builder-field-order .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
}

.builder-position-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: var(--sms-muted);
    font-size: .78rem;
    font-weight: 700;
}

.builder-position-label .form-select {
    width: 74px;
}

.choice-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 38px;
    align-items: center;
}

.student-pick-list {
    max-height: 260px;
    overflow: auto;
    border: 1px solid var(--sms-border);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.student-pick {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
}

.student-pick:hover {
    background: #f8fafc;
}

.attendance-row {
    display: grid;
    grid-template-columns: 1fr 130px 1fr;
    gap: 10px;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid var(--sms-border);
}

.attendance-row:last-child {
    border-bottom: 0;
}

.academic-attendance-list {
    max-height: 420px;
}

.academic-summary-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.academic-summary-strip span {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    color: #1e3a8a;
    font-size: .85rem;
    font-weight: 700;
    padding: 8px 10px;
}

.timetable-print-grid th,
.timetable-print-grid td {
    min-width: 140px;
    vertical-align: top;
}

.timetable-print-grid th:first-child {
    min-width: 110px;
}

.print-page {
    background: #eef2f7;
    padding: 24px;
}

.print-sheet {
    width: min(100%, 980px);
    margin: 0 auto;
    background: #fff;
    padding: 32px;
    border-radius: 8px;
}

.profile-head {
    display: flex;
    align-items: center;
    gap: 18px;
    border: 1px solid var(--sms-border);
    border-radius: 8px;
    padding: 18px;
}

.profile-head img {
    width: 112px;
    height: 112px;
    object-fit: cover;
    border-radius: 8px;
}

.print-field {
    border: 1px solid var(--sms-border);
    border-radius: 8px;
    padding: 12px;
    min-height: 74px;
}

.print-field span {
    display: block;
    color: var(--sms-muted);
    font-size: .85rem;
}

.print-field strong {
    display: block;
    margin-top: 4px;
    font-weight: 700;
}

.id-card-sheet {
    width: min(100%, 420px);
    margin: 0 auto;
}

.employee-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--sms-border);
    text-align: center;
    box-shadow: 0 16px 40px rgba(15, 23, 42, .08);
}

.id-card-top {
    background: #172033;
    color: #fff;
    padding: 18px;
    display: grid;
    gap: 4px;
}

.id-photo {
    width: 112px;
    height: 112px;
    object-fit: cover;
    border-radius: 999px;
    margin: 18px auto 8px;
    border: 4px solid #fff;
    box-shadow: 0 0 0 1px var(--sms-border);
}

.id-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 24px;
    border-top: 1px solid var(--sms-border);
    text-align: left;
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
}

.table-responsive .table {
    margin-bottom: 0;
}

.modal-dialog {
    margin: 1rem auto;
    max-width: calc(100vw - 2rem);
}

.modal-content {
    overflow: hidden;
}

.modal-footer {
    gap: 10px;
}

.modal-footer > * {
    margin: 0 !important;
}

.qr-code {
    margin: 16px auto 8px;
}

.barcode {
    font-family: Consolas, monospace;
    letter-spacing: 2px;
    padding-bottom: 18px;
}

@page {
    size: A4 portrait;
    margin: 10mm;
}

@media print {
    html,
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 10pt;
        width: 210mm;
    }

    .no-print {
        display: none !important;
    }

    .sidebar,
    .topbar,
    .sidebar-overlay,
    .app-powered-by,
    button,
    .btn,
    form,
    .dataTables_filter,
    .dataTables_length,
    .dataTables_info,
    .dataTables_paginate {
        display: none !important;
    }

    .app-layout,
    .wrapper,
    .container-fluid,
    .content,
    .main-content,
    .content-body {
        display: block !important;
        margin: 0 !important;
        max-width: none !important;
        min-height: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .panel,
    .card {
        background: #fff !important;
        border: 0 !important;
        box-shadow: none !important;
        margin: 0 0 6mm !important;
        padding: 0 !important;
    }

    .table-responsive {
        overflow: visible !important;
    }

    table {
        border-collapse: collapse !important;
        width: 100% !important;
    }

    thead {
        display: table-header-group;
    }

    tfoot {
        display: table-footer-group;
    }

    tr,
    img,
    .card,
    .panel {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    th,
    td {
        border: 1px solid #777 !important;
        color: #000 !important;
        padding: 2.5mm 2mm !important;
    }

    canvas {
        max-height: 70mm !important;
        max-width: 100% !important;
    }

    .print-page {
        background: #fff;
        padding: 0;
    }

    .print-sheet {
        width: 100%;
        padding: 0;
        border-radius: 0;
    }
}

.btn,
.form-control,
.form-select,
.modal-content {
    border-radius: 8px;
}

.app-powered-by {
    color: #6c757d;
    font-size: 12px;
    padding: 12px 24px;
    text-align: center;
}

.builder-year-select {
    width: 220px;
    max-width: 100%;
}

.operations-module-tabs .nav-link {
    border: 1px solid var(--sms-border);
    color: var(--sms-text);
    font-weight: 700;
}

.operations-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.operation-qr-box {
    align-items: center;
    border: 1px dashed var(--sms-border);
    border-radius: 8px;
    display: inline-flex;
    justify-content: center;
    min-height: 180px;
    min-width: 180px;
    padding: 12px;
}

.operation-qr-box img {
    display: block;
}

.student-login-link {
    color: #2563eb;
    font-weight: 700;
    text-decoration: none;
}

.student-login-link:hover {
    text-decoration: underline;
}

.student-login-page {
    background:
        linear-gradient(135deg, rgba(17, 24, 39, .88), rgba(32, 91, 101, .82)),
        #edf3f8;
    color: var(--sms-text);
    min-height: 100vh;
}

.student-login-shell {
    align-items: center;
    display: grid;
    min-height: 100vh;
    padding: 24px;
}

.student-login-card {
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 8px;
    box-shadow: 0 26px 70px rgba(15, 23, 42, .26);
    margin: 0 auto;
    max-width: 480px;
    padding: 32px;
    width: 100%;
}

.student-login-brand {
    align-items: center;
    display: flex;
    gap: 14px;
    margin-bottom: 28px;
}

.student-login-brand h1 {
    font-size: 1.65rem;
    font-weight: 850;
    line-height: 1.2;
    margin: 0;
}

.student-login-brand p,
.student-login-footer span {
    color: var(--sms-muted);
    margin: 0;
}

.student-pin-input {
    font-size: 1.35rem;
    font-weight: 850;
}

.student-login-footer {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    margin-top: 22px;
}

.student-login-footer a {
    color: #2563eb;
    font-weight: 700;
    text-decoration: none;
}

.portal-public-shell {
    background: #f3f6fb;
    color: var(--sms-text);
    min-height: 100vh;
}

.portal-topbar {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--sms-border);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    min-height: 72px;
    padding: 14px clamp(16px, 4vw, 42px);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.portal-topbar strong,
.portal-topbar span {
    display: block;
}

.portal-topbar span {
    color: #6c757d;
    font-size: .9rem;
}

.portal-main {
    margin: 0 auto;
    max-width: 1440px;
    padding: clamp(16px, 3vw, 32px);
}

.portal-hero,
.portal-card,
.portal-empty {
    background: #fff;
    border: 1px solid var(--sms-border);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .06);
}

.portal-hero {
    margin-bottom: 16px;
    padding: clamp(18px, 3vw, 28px);
}

.portal-hero h1,
.portal-card h2 {
    letter-spacing: 0;
    margin: 0;
}

.portal-hero h1 {
    font-size: clamp(1.45rem, 2.2vw, 2.1rem);
    font-weight: 800;
}

.portal-card,
.portal-empty {
    padding: 20px;
}

.portal-card h2 {
    font-size: 1.05rem;
    font-weight: 800;
    margin-bottom: 16px;
}

.portal-avatar {
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .14);
    flex: 0 0 auto;
    height: 76px;
    object-fit: cover;
    width: 76px;
}

.portal-avatar-initials {
    align-items: center;
    background: #2563eb;
    color: #fff;
    display: inline-flex;
    font-size: 1.8rem;
    font-weight: 800;
    justify-content: center;
}

.portal-switcher {
    min-width: min(320px, 100%);
}

.portal-details {
    display: grid;
    gap: 10px 14px;
    grid-template-columns: minmax(96px, auto) 1fr;
    margin: 0;
}

.portal-details dt {
    color: #6c757d;
    font-weight: 700;
}

.portal-details dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.portal-money-row,
.portal-list-item {
    align-items: center;
    border-bottom: 1px solid var(--sms-border);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 10px 0;
}

.portal-money-row:first-of-type,
.portal-list-item:first-of-type {
    padding-top: 0;
}

.portal-money-row:last-child,
.portal-list-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.portal-list-item strong,
.portal-list-item span {
    display: block;
}

.portal-list-item > div {
    min-width: 0;
}

.portal-list-item span {
    color: #6c757d;
    font-size: .86rem;
}

.portal-progress {
    background: #e9eef6;
    border-radius: 999px;
    height: 12px;
    overflow: hidden;
}

.portal-progress > div {
    background: linear-gradient(90deg, #2563eb, #16a34a);
    height: 100%;
}

.student-dashboard-shell {
    background:
        linear-gradient(180deg, #eef5fb 0, #f8fafc 320px, #f4f7fb 100%);
}

.student-dashboard-shell .portal-topbar {
    box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}

.student-premium-hero {
    background:
        linear-gradient(135deg, #132033 0%, #205b65 58%, #b7791f 130%);
    border: 0;
    color: #fff;
    overflow: hidden;
}

.student-hero-grid {
    align-items: center;
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
}

.student-premium-hero .portal-avatar {
    height: 92px;
    width: 92px;
}

.student-eyebrow {
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 999px;
    color: #dbeafe;
    display: inline-flex;
    font-size: .8rem;
    font-weight: 800;
    margin-bottom: 8px;
    padding: 5px 10px;
}

.student-premium-hero p {
    color: rgba(255, 255, 255, .78);
    overflow-wrap: anywhere;
}

.student-hero-panel {
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 8px;
    padding: 18px;
}

.student-hero-panel span,
.student-hero-panel small,
.student-hero-panel strong {
    display: block;
}

.student-hero-panel span {
    color: rgba(255, 255, 255, .72);
    font-size: .82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.student-hero-panel strong {
    font-size: 1.15rem;
    margin-top: 8px;
}

.student-hero-panel small {
    color: rgba(255, 255, 255, .72);
    margin-top: 4px;
}

.student-quick-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.student-quick-grid a {
    background: #fff;
    border: 1px solid var(--sms-border);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .06);
    color: var(--sms-text);
    font-weight: 800;
    min-height: 48px;
    padding: 12px;
    text-align: center;
    text-decoration: none;
}

.student-quick-grid a:hover {
    border-color: #2563eb;
    color: #2563eb;
}

.student-metrics .metric-card {
    min-height: 136px;
}

.student-metrics .metric-card strong {
    overflow-wrap: anywhere;
}

.student-dashboard-shell .portal-card {
    border-color: rgba(226, 232, 240, .9);
}

@media (max-width: 991.98px) {
    body.sidebar-open {
        overflow: hidden;
    }

    body.sidebar-open::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 1030;
    }

    .sidebar {
        width: min(334px, calc(100vw - 24px));
        min-height: 100dvh;
        max-height: 100dvh;
        padding: 10px 0 12px;
        gap: 8px;
        z-index: 1040;
        box-shadow: 18px 0 50px rgba(15, 23, 42, .35);
        overscroll-behavior: contain;
        touch-action: pan-y;
        transform: translateX(-100%);
        transition: transform .2s ease;
        will-change: transform;
    }

    .sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        align-self: flex-end;
        width: 40px;
        height: 40px;
        margin-right: 10px;
        margin-bottom: -4px;
        position: sticky;
        top: 8px;
        z-index: 2;
        border: 1px solid rgba(255, 255, 255, .14);
        border-radius: 8px;
        background: rgba(255, 255, 255, .08);
        color: #fff;
    }

    .sidebar-close:hover,
    .sidebar-close:focus {
        background: rgba(255, 255, 255, .14);
        color: #fff;
    }

    .sidebar-brand {
        min-height: auto;
        margin: 0 10px 8px;
        padding: 10px 11px;
    }

    .sidebar-nav {
        padding-right: 0;
    }

    .sidebar-list {
        gap: 4px;
    }

    .sidebar-list .sidebar-list {
        margin: 0;
        padding: 0;
    }

    .sidebar-level-0 > .sidebar-item > .sidebar-link,
    .sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-summary {
        min-height: 64px;
        padding: 12px 12px 12px 16px;
        font-size: 15.5px;
    }

    .sidebar-level-0 > .sidebar-item > .sidebar-link .sidebar-icon,
    .sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-summary .sidebar-icon {
        flex-basis: 38px;
        width: 38px;
        height: 38px;
        font-size: 22px;
    }

    .sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-list {
        padding: 8px 8px 12px 14px;
    }

    .sidebar-level-1 .sidebar-link,
    .sidebar-level-1 .sidebar-summary,
    .sidebar-level-2 .sidebar-link,
    .sidebar-level-2 .sidebar-summary {
        min-height: 40px;
        padding: 6px 7px;
        font-size: 14px;
    }

    .sidebar-level-1 .sidebar-icon,
    .sidebar-level-2 .sidebar-icon {
        flex-basis: 28px;
        width: 28px;
        height: 28px;
        font-size: 15px;
    }

    .content {
        margin-left: 0;
    }

    .wrapper > .topbar,
    .main-content {
        margin-left: 0;
    }

    .topbar {
        padding-inline: 18px;
    }

    .content-body {
        padding: 18px;
    }

    .content-body > .row,
    .modal-body > .row {
        --bs-gutter-x: 1rem;
    }

    .panel,
    .metric-card {
        padding: 20px;
    }

    .profile-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .table-responsive {
        margin-inline: -20px;
        padding-inline: 20px;
    }

    .student-hero-grid {
        grid-template-columns: 1fr;
    }

    .student-quick-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .dataTables_wrapper .row {
        row-gap: 10px;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: left !important;
    }
}

@media (max-width: 575.98px) {
    .auth-panel,
    .panel {
        padding: 16px;
    }

    .topbar {
        align-items: center;
        display: grid;
        gap: 8px 10px;
        grid-template-columns: auto minmax(0, 1fr) auto;
        min-height: 0;
        padding: 12px 14px;
    }

    .content-body {
        padding: 14px;
    }

    .topbar-heading {
        min-width: 0;
    }

    .topbar-title {
        font-size: .95rem;
    }

    .topbar-meta {
        font-size: .78rem;
        line-height: 1.35;
    }

    .topbar-account {
        margin-left: 0;
        width: auto;
    }

    .topbar-user-btn {
        min-height: 42px;
        padding-inline: 12px;
    }

    .topbar-user-btn span {
        display: none;
    }

    .topbar-account .dropdown-menu {
        max-width: calc(100vw - 28px);
    }

    .app-powered-by {
        padding-inline: 14px;
    }

    .metric-card {
        padding: 16px;
    }

    .metric-card strong {
        font-size: 1.6rem;
    }

    .attendance-row {
        grid-template-columns: 1fr;
    }

    .builder-section-head,
    .builder-field {
        align-items: stretch;
        flex-direction: column;
    }

    .builder-field-main,
    .builder-field-order,
    .builder-field-switches,
    .builder-field-actions {
        width: 100%;
    }

    .builder-field-main {
        min-width: 0;
    }

    .builder-field-order,
    .builder-field-actions {
        flex-wrap: wrap;
    }

    .builder-field-order .btn {
        flex: 0 0 42px;
        width: 42px;
        height: 38px;
    }

    .builder-position-label {
        flex: 1 1 140px;
        justify-content: space-between;
    }

    .builder-position-label .form-select {
        width: 88px;
    }

    .choice-stack {
        align-items: stretch;
        flex-direction: column;
    }

    .id-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .modal-dialog {
        margin: 0;
        max-width: 100vw;
        min-height: 100dvh;
        width: 100%;
    }

    .modal-dialog-scrollable {
        height: 100dvh;
    }

    .modal-content {
        border: 0;
        border-radius: 0;
        min-height: 100dvh;
    }

    .modal-header,
    .modal-footer {
        padding: 12px 14px;
    }

    .modal-body {
        padding: 14px;
    }

    .modal-footer > .btn {
        width: 100%;
    }

    .table-responsive {
        margin-inline: -16px;
        padding-inline: 16px;
    }

    .table {
        font-size: .875rem;
    }

    .table > :not(caption) > * > * {
        padding: .65rem .55rem;
    }

    .dataTables_wrapper .dataTables_filter label,
    .dataTables_wrapper .dataTables_length label {
        align-items: stretch;
        display: flex;
        flex-direction: column;
        gap: 5px;
        width: 100%;
    }

    .dataTables_wrapper .dataTables_filter input,
    .dataTables_wrapper .dataTables_length select {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .dataTables_wrapper .dataTables_paginate {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        padding-top: 12px;
    }

    .content-body .d-flex.justify-content-between > .btn,
    .content-body .d-flex.justify-content-between > .d-flex {
        flex: 1 1 auto;
    }

    .builder-year-select {
        width: 100%;
    }

    .operations-actions {
        justify-content: stretch;
    }

    .operations-actions .btn {
        flex: 1 1 160px;
    }

    .portal-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .portal-avatar {
        height: 60px;
        width: 60px;
    }

    .portal-list-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .portal-details {
        grid-template-columns: 1fr;
    }

    .student-login-shell {
        padding: 14px;
    }

    .student-login-card {
        padding: 22px;
    }

    .sidebar {
        width: min(310px, calc(100vw - 16px));
        padding: 8px 0 10px;
    }

    .sidebar-brand-title {
        font-size: 13px;
    }

    .sidebar-brand-mark {
        flex-basis: 36px;
        width: 36px;
        height: 36px;
    }

    .sidebar-level-0 > .sidebar-item > .sidebar-link,
    .sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-summary {
        min-height: 58px;
        padding: 10px 10px 10px 18px;
        font-size: 15px;
    }

    .sidebar-level-0 > .sidebar-item > .sidebar-link .sidebar-icon,
    .sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-summary .sidebar-icon {
        flex-basis: 34px;
        width: 34px;
        height: 34px;
        font-size: 20px;
    }

    .sidebar-level-0 > .sidebar-branch > .sidebar-details > .sidebar-list {
        padding: 8px 6px 10px 10px;
    }

    .sidebar-level-1 .sidebar-link,
    .sidebar-level-1 .sidebar-summary,
    .sidebar-level-2 .sidebar-link,
    .sidebar-level-2 .sidebar-summary {
        min-height: 38px;
        font-size: 13.25px;
    }

    .sidebar-level-1 .sidebar-icon,
    .sidebar-level-2 .sidebar-icon {
        flex-basis: 24px;
        width: 24px;
        height: 24px;
        font-size: 13px;
    }

    .student-login-brand {
        align-items: flex-start;
        flex-direction: column;
    }

    .student-premium-hero .portal-avatar {
        height: 66px;
        width: 66px;
    }

    .student-quick-grid {
        grid-template-columns: 1fr 1fr;
    }

    .student-quick-grid a {
        min-height: 44px;
        padding: 10px;
    }
}

/* ==========================================
   MOBILE & RESPONSIVE SYSTEM ENHANCEMENTS
   ========================================== */

/* Universal Backdrop for Mobile Drawer */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1040;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-open .sidebar-backdrop,
.sidebar-backdrop.show {
    display: block !important;
    opacity: 1 !important;
}

/* Desktop Sidebar Collapsed State */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%) !important;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    body.sidebar-collapsed .content,
    body.sidebar-collapsed .main-content,
    body.sidebar-collapsed .topbar,
    body.sidebar-collapsed .wrapper > .topbar,
    body.sidebar-collapsed .sticky-save-bar {
        margin-left: 0 !important;
        left: 0 !important;
        transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1), left 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
}

/* ==========================================================================
   SMART VIEW RESPONSIVE DESIGN & MOBILE APP SHELL (All Devices)
   ========================================================================== */

:root {
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
    --sar: env(safe-area-inset-right, 0px);
}

/* Base Mobile Bottom Nav (Hidden on Desktop) */
.mobile-bottom-nav {
    display: none;
}

.action-bar-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* Tablet & Mobile Screens (<= 991.98px) */
@media (max-width: 991.98px) {
    /* 1. Reset Main Shell Layout */
    .content,
    .main-content,
    .topbar,
    .wrapper > .topbar {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Reserve space at bottom so mobile bottom nav never covers content */
    .content,
    .main-content,
    .portal-main {
        padding-bottom: calc(76px + var(--sab)) !important;
    }

    /* 2. Mobile Off-Canvas Drawer Navigation */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 300px !important;
        max-width: 86vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        z-index: 1050 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.5) !important;
        display: flex !important;
    }

    body.sidebar-open {
        overflow: hidden !important;
        touch-action: none;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0) !important;
    }

    .sidebar-close {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 14px;
        right: 14px;
        width: 38px;
        height: 38px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        background: rgba(255, 255, 255, 0.14);
        color: #fff;
        border-radius: 10px;
        font-size: 18px;
        z-index: 20;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .sidebar-close:active {
        transform: scale(0.92);
        background: rgba(255, 255, 255, 0.28);
    }

    /* 3. Mobile Topbar Header (Smart Glass App Bar) */
    .topbar {
        padding: 8px 14px !important;
        min-height: 58px !important;
        gap: 8px !important;
        position: sticky;
        top: 0;
        z-index: 1020;
        background: rgba(255, 255, 255, 0.94) !important;
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-bottom: 1px solid rgba(226, 232, 240, 0.85);
        box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
        padding-top: max(8px, var(--sat)) !important;
    }

    #sidebarToggle {
        display: inline-flex !important;
        flex: 0 0 40px !important;
        width: 40px !important;
        height: 40px !important;
        font-size: 18px !important;
        align-items: center;
        justify-content: center;
        padding: 0 !important;
        border-radius: 10px;
        background: #f1f5f9;
        border: 1px solid #e2e8f0;
        color: #1e293b;
        transition: all 0.2s ease;
    }

    #sidebarToggle:active {
        transform: scale(0.92);
        background: #e2e8f0;
    }

    #sidebarToggleDesktop {
        display: none !important;
    }

    .topbar-heading {
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    .topbar-heading > .d-flex {
        flex-wrap: nowrap !important;
        gap: 6px !important;
    }

    .topbar-title {
        font-size: 0.95rem !important;
        font-weight: 700 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 170px;
    }

    .topbar-meta {
        display: none !important;
    }

    .topbar-right {
        gap: 6px !important;
        flex-shrink: 0;
    }

    .topbar-account .topbar-user-btn {
        padding: 4px 6px !important;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
    }

    .topbar-avatar-pill {
        width: 32px !important;
        height: 32px !important;
        font-size: 14px !important;
    }

    .topbar-user-arrow {
        font-size: 11px !important;
        margin-left: 2px;
    }

    .topbar-dropdown-menu {
        position: fixed !important;
        top: 62px !important;
        right: 12px !important;
        left: auto !important;
        width: 290px !important;
        max-width: calc(100vw - 24px) !important;
        border-radius: 16px !important;
        box-shadow: 0 20px 45px rgba(15, 23, 42, 0.18) !important;
        z-index: 1060 !important;
    }

    /* 4. Smart Mobile App Bottom Navigation Bar */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 64px !important;
        background: rgba(255, 255, 255, 0.96) !important;
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid rgba(226, 232, 240, 0.95);
        box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.08);
        z-index: 1030 !important;
        align-items: center;
        justify-content: space-around;
        padding: 4px 6px calc(4px + var(--sab)) !important;
    }

    .mobile-bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1 1 0;
        min-width: 0;
        height: 100%;
        padding: 6px 2px;
        color: #64748b;
        text-decoration: none;
        font-size: 0.7rem;
        font-weight: 600;
        border-radius: 12px;
        border: none;
        background: transparent;
        transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-bottom-nav-item i {
        font-size: 1.25rem;
        margin-bottom: 2px;
        transition: transform 0.2s ease, color 0.2s ease;
    }

    .mobile-bottom-nav-item:active {
        transform: scale(0.9);
        color: #2563eb;
    }

    .mobile-bottom-nav-item.active {
        color: #2563eb;
        font-weight: 700;
    }

    .mobile-bottom-nav-item.active i {
        transform: translateY(-2px);
        color: #2563eb;
    }

    /* 5. Page Content & Padding */
    .content-body,
    .main-content {
        padding: 16px 14px !important;
    }

    .panel {
        padding: 18px 14px !important;
        border-radius: 12px !important;
        margin-bottom: 16px !important;
        box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05) !important;
    }

    .panel h1,
    .panel h2 {
        font-size: 1.25rem !important;
        line-height: 1.35;
    }

    /* 6. Smooth Touch Scrollable Tabs & Action Chips */
    .nav-tabs,
    .nav-pills,
    .portal-tabs,
    .action-bar-chips,
    .page-actions-wrapper {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        padding-bottom: 6px !important;
        gap: 8px !important;
    }

    .nav-tabs::-webkit-scrollbar,
    .nav-pills::-webkit-scrollbar,
    .portal-tabs::-webkit-scrollbar,
    .action-bar-chips::-webkit-scrollbar,
    .page-actions-wrapper::-webkit-scrollbar {
        display: none !important;
    }

    .nav-tabs .nav-link,
    .nav-pills .nav-link,
    .portal-tabs .nav-link,
    .action-bar-chips .btn {
        flex-shrink: 0 !important;
        font-size: 0.85rem !important;
        padding: 8px 14px !important;
        border-radius: 9999px !important;
    }

    /* 7. Action Button Groups in Headers */
    .panel > .d-flex.gap-2:not(.modal-footer):not(.dropdown-menu),
    .content-body > .d-flex.gap-2:not(.modal-footer) {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        scrollbar-width: none !important;
        padding-bottom: 6px !important;
        margin-bottom: 12px !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }

    .panel > .d-flex.gap-2:not(.modal-footer):not(.dropdown-menu)::-webkit-scrollbar,
    .content-body > .d-flex.gap-2:not(.modal-footer)::-webkit-scrollbar {
        display: none !important;
    }

    .panel > .d-flex.gap-2:not(.modal-footer):not(.dropdown-menu) .btn,
    .content-body > .d-flex.gap-2:not(.modal-footer) .btn {
        flex-shrink: 0 !important;
        border-radius: 9999px !important;
        font-size: 0.82rem !important;
        padding: 7px 12px !important;
    }

    /* 8. Touch Scrollable Tables & DataTables */
    .table-responsive {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 10px;
        margin-bottom: 14px;
        border: 1px solid #e2e8f0;
    }

    .table {
        font-size: 0.86rem !important;
        margin-bottom: 0 !important;
    }

    .table th,
    .table td {
        padding: 10px 12px !important;
        white-space: nowrap;
    }

    /* DataTables Controls on Mobile */
    .dataTables_wrapper {
        padding: 0 !important;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        text-align: left !important;
        margin-bottom: 10px !important;
        width: 100% !important;
    }

    .dataTables_wrapper .dataTables_filter label {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        font-weight: 600;
        font-size: 0.82rem;
        color: #475569;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 100% !important;
        margin: 4px 0 0 0 !important;
        min-height: 42px !important;
        border-radius: 10px !important;
        font-size: 16px !important; /* Prevents iOS auto-zoom */
        padding: 8px 12px !important;
    }

    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: center !important;
        margin-top: 10px !important;
        width: 100% !important;
    }

    .dataTables_wrapper .dataTables_paginate .pagination {
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 3px !important;
    }

    .dataTables_wrapper .dataTables_paginate .page-link {
        padding: 7px 12px !important;
        font-size: 0.84rem !important;
        border-radius: 8px !important;
        min-width: 36px;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* 9. Action Bar & Filter Wrapping */
    .d-flex.justify-content-between,
    .d-flex.align-items-center {
        flex-wrap: wrap;
        gap: 10px;
    }

    .sticky-save-bar {
        left: 0 !important;
        padding: 10px 16px !important;
        bottom: 64px !important; /* Clears mobile bottom nav */
    }

    /* 10. Dashboard Responsive Grids on Mobile/Tablet */
    .dashboard-hero-grid {
        grid-template-columns: 1fr !important;
    }

    .dashboard-section-grid {
        grid-template-columns: 1fr !important;
    }

    .admin-dashboard .row {
        --bs-gutter-x: 12px;
        --bs-gutter-y: 12px;
    }

    .quick-actions-grid {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
        gap: 10px !important;
    }
}

/* Smartphone Screens (<= 575.98px) */
@media (max-width: 575.98px) {
    .content-body,
    .main-content {
        padding: 12px 10px !important;
    }

    .panel {
        padding: 14px 12px !important;
        border-radius: 12px !important;
    }

    /* iOS Auto-Zoom Prevention: Always 16px font-size for inputs */
    .form-control,
    .form-select,
    select,
    textarea,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="search"] {
        font-size: 16px !important;
        min-height: 44px !important;
        padding: 10px 12px !important;
        border-radius: 10px !important;
    }

    .form-label {
        font-size: 0.82rem !important;
        font-weight: 600 !important;
        margin-bottom: 4px !important;
        color: #334155 !important;
    }

    .btn:not(.d-none) {
        min-height: 42px !important;
        font-size: 0.88rem !important;
        font-weight: 600 !important;
        border-radius: 10px !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-sm:not(.d-none) {
        min-height: 34px !important;
        font-size: 0.78rem !important;
        padding: 5px 10px !important;
    }

    /* Metric & Dashboard Cards: Ultra-Sleek 2-Column Grid on Phones */
    .metric-grid,
    .admin-dashboard .row:has(.metric-card),
    .admin-dashboard .row:has(.dashboard-card) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .admin-dashboard .row:has(.metric-card) > div,
    .admin-dashboard .row:has(.dashboard-card) > div {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
    }

    .dashboard-card {
        padding: 12px 10px !important;
        border-radius: 12px !important;
        min-height: 110px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
    }

    .dashboard-card strong {
        font-size: 1.25rem !important;
        margin: 4px 0 !important;
    }

    .dashboard-card span {
        font-size: 0.72rem !important;
    }

    .dashboard-card-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 13px !important;
        flex: 0 0 32px !important;
    }

    /* Quick Actions: Clean 2-column or 3-column app tile grid */
    .dashboard-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    .dashboard-action {
        padding: 12px 10px !important;
        border-radius: 12px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 6px !important;
    }

    .dashboard-action-icon {
        width: 38px !important;
        height: 38px !important;
        font-size: 16px !important;
        border-radius: 10px !important;
        margin: 0 auto !important;
    }

    .dashboard-action strong {
        font-size: 0.8rem !important;
    }

    .dashboard-action small {
        display: none !important;
    }

    .metric-card {
        padding: 12px 10px !important;
        border-radius: 12px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
    }

    .metric-card strong {
        font-size: 1.35rem !important;
        line-height: 1.2 !important;
    }

    .metric-card .text-muted,
    .metric-card span {
        font-size: 0.72rem !important;
    }

    /* Native App Style Bottom Sheet Modals */
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        min-height: 100vh;
        display: flex !important;
        align-items: flex-end !important;
    }

    .modal-content {
        border-radius: 20px 20px 0 0 !important;
        max-height: 90vh !important;
        display: flex !important;
        flex-direction: column !important;
        border: none !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25) !important;
    }

    .modal-header {
        padding: 14px 16px !important;
        border-bottom: 1px solid #f1f5f9 !important;
        position: relative;
    }

    /* Sheet drag indicator bar */
    .modal-header::before {
        content: "";
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: #cbd5e1;
        border-radius: 9999px;
    }

    .modal-body {
        padding: 16px 14px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        flex: 1 1 auto;
    }

    .modal-footer {
        padding: 12px 14px !important;
        border-top: 1px solid #f1f5f9 !important;
        flex-direction: column-reverse !important;
        gap: 8px !important;
    }

    .modal-footer .btn {
        width: 100% !important;
        margin: 0 !important;
    }

    /* Full width buttons in form rows on small phones */
    .panel .btn-primary:not(.btn-sm):not(.action-bar-chips .btn),
    .panel .btn-secondary:not(.btn-sm):not(.action-bar-chips .btn) {
        width: 100%;
        margin-bottom: 6px;
    }

    /* Stack list items neatly */
    .dashboard-session-row,
    .dashboard-list-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 4px !important;
        padding: 10px 0 !important;
    }

    .dashboard-session-row strong,
    .dashboard-list-value {
        text-align: left !important;
        font-size: 0.95rem !important;
    }

    /* Student & Teacher Portals on Phone */
    .student-hero-grid,
    .teacher-hero-card {
        padding: 16px 14px !important;
        border-radius: 14px !important;
    }

    .student-hero-grid > .d-flex {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .portal-avatar {
        width: 56px !important;
        height: 56px !important;
    }
}

/* Extra Small Phones (<= 374.98px like iPhone SE 1st gen) */
@media (max-width: 374.98px) {
    .topbar-title {
        max-width: 120px !important;
        font-size: 0.88rem !important;
    }

    .metric-grid,
    .admin-dashboard .row:has(.metric-card) {
        grid-template-columns: 1fr !important;
    }

    .mobile-bottom-nav-item span {
        font-size: 0.62rem !important;
    }
}
