:root {
    --bs-green: #075e54;
    --bs-green-2: #0f9f8f;
    --bs-mint: #d6f7c5;
    --bs-bg: #e9dfd5;
    --bs-panel: #f6faf8;
    --bs-card: #ffffff;
    --bs-line: #cfdcd7;
    --bs-line-strong: #aebfba;
    --bs-ink: #17211f;
    --bs-muted: #65746f;
    --bs-soft: #edf5f2;
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--bs-ink);
    font-family: Inter, Outfit, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        linear-gradient(180deg, var(--bs-green) 0 132px, transparent 132px),
        radial-gradient(circle at 22px 22px, rgba(7, 94, 84, 0.08) 2px, transparent 2px),
        var(--bs-bg);
    background-size: auto, 34px 34px, auto;
}

body > .erp-company-footer {
    padding: 10px 16px max(14px, calc(env(safe-area-inset-bottom) + 10px));
}

.bs-topbar,
.bs-shell,
.bs-bottom-back-wrap {
    width: min(1480px, calc(100% - 24px));
    margin-inline: auto;
}

.bs-topbar {
    min-height: 84px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    color: #fff;
}

.bs-brand,
.bs-back {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.bs-brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.16);
    font-size: 1.55rem;
}

.bs-brand p,
.bs-brand h1 {
    margin: 0;
}

.bs-brand p {
    max-width: min(64vw, 620px);
    overflow: hidden;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.82rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bs-brand h1 {
    font-size: 1.35rem;
    line-height: 1.1;
}

.bs-back,
.bs-icon-btn,
.bs-call,
.bs-profile-link {
    min-height: 38px;
    border: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.bs-back {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    padding: 8px 12px;
}

.bs-bottom-back-wrap {
    margin-top: 12px;
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
}

.bs-bottom-back {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid rgba(7, 94, 84, 0.22);
    color: #053f39;
    background: linear-gradient(135deg, var(--bs-mint), #e5f2ef);
    box-shadow: 0 14px 34px rgba(7, 94, 84, 0.18);
    font-weight: 900;
    text-decoration: none;
}

.bs-bottom-back:hover {
    transform: translateY(-1px);
    border-color: rgba(7, 94, 84, 0.34);
    box-shadow: 0 18px 40px rgba(7, 94, 84, 0.22);
}

.bs-shell {
    height: clamp(520px, calc(100dvh - 210px), 780px);
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(320px, 430px) minmax(0, 1fr);
    border: 1px solid rgba(15, 23, 42, 0.18);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.2);
}

.bs-sidebar,
.bs-students,
.bs-details {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.bs-panel {
    height: 100%;
    min-width: 0;
    min-height: 0;
    background: var(--bs-panel);
}

.bs-directory,
.bs-roster,
.bs-profile {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    border-right: 1px solid var(--bs-line);
    overflow: hidden;
}

.bs-profile {
    grid-template-rows: minmax(0, 1fr);
    border-right: 0;
    background:
        linear-gradient(rgba(245, 248, 246, 0.92), rgba(245, 248, 246, 0.92)),
        radial-gradient(circle at 16px 16px, rgba(7, 94, 84, 0.08) 2px, transparent 2px);
    background-size: auto, 32px 32px;
}

.bs-panel-head {
    min-height: 72px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(180deg, #f8fbfa 0%, #eef5f2 100%);
    border-bottom: 1px solid var(--bs-line);
}

.bs-panel-head p,
.bs-panel-head h2 {
    margin: 0;
}

.bs-panel-head p {
    color: var(--bs-muted);
    font-size: 0.74rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.bs-panel-head h2 {
    font-size: 1.05rem;
    line-height: 1.2;
}

.bs-icon-btn {
    width: 38px;
    padding: 0;
    color: var(--bs-green);
    background: #ddf2ed;
    border: 1px solid #c8e5df;
}

.bs-search {
    margin: 10px 12px;
    min-height: 42px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    color: var(--bs-muted);
    background: #fff;
    border: 1px solid var(--bs-line-strong);
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
}

.bs-search input {
    width: 100%;
    min-height: 40px;
    border: 0;
    outline: 0;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--bs-ink);
    font: inherit;
    padding: 0;
}

.bs-search input::placeholder {
    color: #8a9691;
}

.bs-class-list,
.bs-student-list {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #86b7ad #eef4f1;
    padding: 0 10px 14px;
}

.bs-class-list::-webkit-scrollbar,
.bs-student-list::-webkit-scrollbar,
.bs-profile-card::-webkit-scrollbar {
    width: 10px;
}

.bs-class-list::-webkit-scrollbar-track,
.bs-student-list::-webkit-scrollbar-track,
.bs-profile-card::-webkit-scrollbar-track {
    background: #eef4f1;
}

.bs-class-list::-webkit-scrollbar-thumb,
.bs-student-list::-webkit-scrollbar-thumb,
.bs-profile-card::-webkit-scrollbar-thumb {
    background: #86b7ad;
    border: 2px solid #eef4f1;
    border-radius: 999px;
}

.bs-class-card,
.bs-student-card {
    width: 100%;
    margin: 8px 0;
    border: 1px solid var(--bs-line);
    border-left: 4px solid transparent;
    border-radius: 8px;
    background: var(--bs-card);
    color: inherit;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06), 0 8px 20px rgba(15, 23, 42, 0.035);
}

.bs-class-card:hover,
.bs-student-card:hover {
    border-color: var(--bs-line-strong);
    background: #fbfefc;
}

.bs-student-card.is-row-even {
    background: #ffffff;
}

.bs-student-card.is-row-odd {
    background: #f6faf8;
}

.bs-student-card.gender-boy {
    border-left-color: #38bdf8;
    background:
        linear-gradient(90deg, rgba(56, 189, 248, 0.15), rgba(255, 255, 255, 0) 46%),
        var(--bs-card);
}

.bs-student-card.gender-girl {
    border-left-color: #f472b6;
    background:
        linear-gradient(90deg, rgba(244, 114, 182, 0.15), rgba(255, 255, 255, 0) 46%),
        var(--bs-card);
}

.bs-student-card.gender-unknown.is-row-odd {
    background: #f6faf8;
}

.bs-class-select,
.bs-section-btn,
.bs-student-main {
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.bs-class-main,
.bs-student-main {
    padding: 12px;
    display: grid;
    align-items: center;
    gap: 10px;
}

.bs-class-main {
    grid-template-columns: minmax(0, 1fr) auto;
}

.bs-class-select {
    min-width: 0;
    padding: 0;
}

.bs-class-name,
.bs-student-name {
    display: block;
    overflow: hidden;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bs-class-meta,
.bs-student-meta,
.bs-student-phone {
    display: block;
    margin-top: 3px;
    color: var(--bs-muted);
    font-size: 0.82rem;
}

.bs-class-card.is-active,
.bs-student-card.is-active {
    border-color: rgba(15, 159, 143, 0.52);
    border-left-color: var(--bs-green-2);
    background: #effdfa;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06), 0 10px 26px rgba(15, 159, 143, 0.11);
}

.bs-class-tools {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bs-expand {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    color: var(--bs-green);
    background: var(--bs-soft);
    border: 1px solid #dce8e4;
    cursor: pointer;
}

.bs-sections {
    display: none;
    padding: 0 10px 10px;
}

.bs-class-card.is-open .bs-sections {
    display: grid;
    gap: 6px;
}

.bs-section-btn {
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #eef5f2;
    border: 1px solid #dbe7e3;
}

.bs-section-btn.is-active {
    color: #053f39;
    background: var(--bs-mint);
    border-color: #bbe7a6;
    font-weight: 900;
}

.bs-count {
    min-width: 38px;
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    color: #053f39;
    background: var(--bs-mint);
    font-weight: 900;
}

.bs-mobile-back {
    display: none;
    min-height: 36px;
    border: 0;
    border-radius: 999px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--bs-green);
    background: #dcefeb;
    font: inherit;
    font-weight: 900;
    padding: 8px 10px;
    cursor: pointer;
}

.bs-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: #053f39;
    background: var(--bs-mint);
    font-weight: 900;
}

.bs-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bs-student-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px;
}

.bs-student-main {
    grid-template-columns: 42px minmax(0, 1fr) auto auto;
}

.bs-student-id {
    padding: 5px 8px;
    border-radius: 999px;
    color: #053f39;
    background: var(--bs-soft);
    font-size: 0.78rem;
    font-weight: 900;
}

.bs-student-chevron {
    width: 24px;
    color: var(--bs-green);
    display: grid;
    place-items: center;
}

.bs-student-call {
    width: 40px;
    height: 40px;
    margin-right: 10px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    color: #053f39;
    background: var(--bs-mint);
    text-decoration: none;
    font-size: 1.08rem;
}

.bs-student-card.gender-boy .bs-student-call {
    color: #075985;
    background: #e0f2fe;
}

.bs-student-card.gender-girl .bs-student-call {
    color: #9d174d;
    background: #fce7f3;
}

.bs-student-call.is-disabled {
    pointer-events: none;
    color: var(--bs-muted);
    background: #eef2f0;
}

.bs-student-extra {
    padding: 0 12px 12px 64px;
}

.bs-student-extra-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.bs-student-extra-actions {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.bs-empty,
.bs-loading {
    min-height: 260px;
    padding: 28px 18px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    color: var(--bs-muted);
    text-align: center;
}

.bs-empty i,
.bs-loading i {
    color: var(--bs-green-2);
    font-size: 2rem;
}

.bs-empty h3,
.bs-empty p,
.bs-loading p {
    margin: 0;
}

.bs-profile-card {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #86b7ad #eef4f1;
    padding: 18px;
}

.bs-profile-hero {
    width: min(640px, 100%);
    margin-inline: auto;
    padding: 18px;
    border: 1px solid var(--bs-line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.12);
}

.bs-profile-top {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
}

.bs-profile-top .bs-avatar {
    width: 76px;
    height: 76px;
    font-size: 1.2rem;
}

.bs-profile-title h2,
.bs-profile-title p {
    margin: 0;
}

.bs-profile-title h2 {
    font-size: 1.25rem;
    line-height: 1.2;
}

.bs-profile-title p {
    margin-top: 4px;
    color: var(--bs-muted);
    font-weight: 800;
}

.bs-actions {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.bs-call {
    color: #053f39;
    background: var(--bs-mint);
    padding: 8px 12px;
}

.bs-call.is-disabled {
    pointer-events: none;
    color: var(--bs-muted);
    background: #eef2f0;
}

.bs-profile-link {
    color: var(--bs-green);
    background: #e5f2ef;
    padding: 8px 12px;
}

.bs-detail-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.bs-detail {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--bs-line);
    border-radius: 8px;
    background: #fbfdfc;
}

.bs-detail span,
.bs-detail strong {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
}

.bs-detail span {
    color: var(--bs-muted);
    font-size: 0.74rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.bs-detail strong {
    margin-top: 3px;
}

.bs-more {
    margin-top: 12px;
    border: 1px solid var(--bs-line-strong);
    border-radius: 8px;
    background: #fff;
}

.bs-more summary {
    padding: 12px;
    color: var(--bs-green);
    font-weight: 900;
    cursor: pointer;
}

.bs-more .bs-detail-grid {
    margin: 0;
    padding: 0 12px 12px;
}

@media (max-width: 980px) {
    .bs-shell {
        height: auto;
        min-height: 0;
        grid-template-columns: 1fr;
        gap: 10px;
        border: 0;
        border-radius: 0;
        overflow: visible;
        box-shadow: none;
    }

    .bs-panel {
        height: auto;
        border: 1px solid rgba(15, 23, 42, 0.12);
        border-radius: 8px;
        overflow: hidden;
    }

    .bs-directory,
    .bs-roster,
    .bs-profile {
        border-right: 0;
    }

    .bs-class-list,
    .bs-student-list {
        max-height: 54vh;
    }
}

@media (max-width: 640px) {
    .bs-topbar,
    .bs-shell,
    .bs-bottom-back-wrap {
        width: min(100% - 16px, 1480px);
    }

    .bs-topbar {
        min-height: 76px;
    }

    .bs-brand-mark {
        width: 42px;
        height: 42px;
        border-radius: 12px;
    }

    .bs-brand h1 {
        font-size: 1.12rem;
    }

    .bs-back span {
        display: none;
    }

    .bs-detail-grid {
        grid-template-columns: 1fr;
    }

    .bs-profile-top {
        grid-template-columns: 60px minmax(0, 1fr);
    }

    .bs-profile-top .bs-avatar {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 760px) {
    body {
        background:
            linear-gradient(180deg, var(--bs-green) 0 118px, transparent 118px),
            radial-gradient(circle at 18px 18px, rgba(7, 94, 84, 0.08) 2px, transparent 2px),
            var(--bs-bg);
        background-size: auto, 30px 30px, auto;
    }

    .bs-topbar,
    .bs-shell,
    .bs-bottom-back-wrap {
        width: calc(100% - 12px);
    }

    .bs-topbar {
        min-height: 72px;
        gap: 10px;
    }

    .bs-shell {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        margin-top: 4px;
    }

    .bs-bottom-back-wrap {
        position: sticky;
        bottom: max(8px, env(safe-area-inset-bottom));
        z-index: 30;
        margin-top: 8px;
        margin-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .bs-bottom-back {
        width: 100%;
        min-height: 48px;
        border-radius: 12px;
    }

    .bs-panel {
        border-radius: 8px;
    }

    .bs-panel-head {
        min-height: 62px;
        padding: 10px 12px;
    }

    .bs-shell:not(.is-scope-selected) .bs-students,
    .bs-shell:not(.is-scope-selected) .bs-details,
    .bs-shell.is-scope-selected .bs-sidebar,
    .bs-shell.is-scope-selected .bs-details {
        display: none;
    }

    .bs-shell.is-scope-selected .bs-students {
        display: block;
    }

    .bs-roster-head {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
    }

    .bs-mobile-back {
        display: inline-flex;
    }

    .bs-roster-title-wrap {
        min-width: 0;
    }

    .bs-roster-title-wrap h2 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .bs-class-list,
    .bs-student-list {
        max-height: none;
        padding-bottom: 8px;
    }

    .bs-student-main {
        grid-template-columns: 38px minmax(0, 1fr) auto;
    }

    .bs-student-id {
        display: none;
    }

    .bs-student-call {
        width: 42px;
        height: 42px;
        margin-right: 8px;
    }

    .bs-student-extra {
        padding: 0 10px 10px;
    }

    .bs-student-extra-grid {
        grid-template-columns: 1fr;
    }

    .bs-avatar {
        width: 38px;
        height: 38px;
    }

    .bs-empty,
    .bs-loading {
        min-height: 190px;
    }

    .bs-profile-card {
        padding: 10px;
    }

    .bs-profile-hero {
        padding: 14px;
        box-shadow: 0 8px 22px rgba(15, 23, 42, 0.1);
    }
}
