:root {
    --app-sidebar-width: 236px;
    --app-bg: #eef3f7;
    --app-panel: #ffffff;
    --app-line: #d6dee8;
    --app-line-strong: #c2cfdd;
    --app-ink: #1f2f3d;
    --app-muted: #53677b;
    --app-brand: #2263c6;
    --app-brand-deep: #174b97;
    --app-sidebar-collapsed-width: 68px;
    --app-sidebar-bg: linear-gradient(180deg, #19314c 0%, #1a3857 100%);
    --app-sidebar-border: rgba(255, 255, 255, 0.08);
    --app-sidebar-text: rgba(255, 255, 255, 0.9);
    --app-sidebar-muted: rgba(255, 255, 255, 0.62);
}

body {
    background:
        radial-gradient(circle at top right, rgba(34, 99, 198, 0.06), transparent 22%),
        linear-gradient(180deg, #f6f9fc 0%, var(--app-bg) 100%);
    color: var(--app-ink);
    font-size: .95rem;
    line-height: 1.6;
    font-family: 'Sarabun', sans-serif;
    font-weight: 400;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--app-ink);
    font-family: 'Sarabun', sans-serif;
    font-weight: 600;
    line-height: 1.35;
}

p,
li,
td,
th,
.form-label,
.form-check-label,
.btn,
.nav-link,
.dropdown-item,
.page-link,
.form-control,
.form-select,
.form-text,
.alert,
.card,
.table {
    font-weight: 400;
}

p,
li,
.form-text,
.text-body-secondary,
.text-secondary {
    line-height: 1.65;
}

.text-body-secondary,
.text-secondary,
.form-text,
.app-breadcrumb,
.app-breadcrumb a {
    color: var(--app-muted) !important;
}

.app-shell {
    min-height: 100vh;
}

.app-main .dropdown-menu {
    z-index: 1050;
}

.app-action-toolbar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: .85rem;
}

.app-sidebar {
    width: var(--app-sidebar-width);
    background: var(--app-sidebar-bg);
    color: var(--app-sidebar-text);
    border-right: 1px solid var(--app-sidebar-border);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    overflow-y: auto;
    box-shadow: .7rem 0 2rem rgba(20, 35, 56, 0.12);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    min-height: 54px;
    padding: .38rem .8rem;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid var(--app-sidebar-border);
}

.app-brand-mark {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.16);
    font-size: .88rem;
    color: #fff;
}

.app-brand-title {
    margin: 0;
    font-size: .9rem;
    font-weight: 700;
    letter-spacing: .01em;
    font-family: 'Sarabun', sans-serif;
}

.app-sidebar-section {
    padding: .55rem .65rem;
}

.app-sidebar-label {
    color: var(--app-sidebar-muted);
    font-size: .68rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin: 0 0 .4rem;
}

.app-menu {
    display: grid;
    gap: .2rem;
}

.app-menu-link {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .58rem .68rem;
    border-radius: .55rem;
    color: var(--app-sidebar-text);
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
    border: 1px solid transparent;
    font-size: .88rem;
}

.app-menu-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.08);
}

.app-menu-link.active {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.app-menu-icon {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: .4rem;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.09);
    flex: 0 0 auto;
    font-size: .8rem;
}

.app-menu-text {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 400;
}

.app-menu-external {
    flex: 0 0 auto;
    font-size: .72rem;
    color: var(--app-sidebar-muted);
}

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

.app-shell.sidebar-collapsed .app-sidebar {
    width: var(--app-sidebar-collapsed-width);
}

.app-shell.sidebar-collapsed .app-main {
    margin-left: var(--app-sidebar-collapsed-width);
}

.app-shell.sidebar-collapsed .app-brand {
    justify-content: center;
    padding-left: .6rem;
    padding-right: .6rem;
}

.app-shell.sidebar-collapsed .app-brand > span:last-child,
.app-shell.sidebar-collapsed .app-sidebar-label,
.app-shell.sidebar-collapsed .app-menu-text,
.app-shell.sidebar-collapsed .app-menu-external {
    display: none;
}

.app-shell.sidebar-collapsed .app-sidebar-section {
    padding-left: .4rem;
    padding-right: .4rem;
}

.app-shell.sidebar-collapsed .app-menu {
    gap: .35rem;
}

.app-shell.sidebar-collapsed .app-menu-link {
    justify-content: center;
    padding-left: .3rem;
    padding-right: .3rem;
    position: relative;
}

.app-shell.sidebar-collapsed .app-menu-icon {
    width: 1.8rem;
    height: 1.8rem;
    font-size: .85rem;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    min-height: 54px;
    backdrop-filter: blur(10px);
    background: rgba(248, 250, 252, 0.84);
    border-bottom: 1px solid rgba(214, 222, 232, 0.92);
}

.app-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .35rem .9rem;
}

.app-topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .6rem;
    min-width: 0;
}

.app-topnav {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
}

.app-topnav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-height: 36px;
    padding: .32rem .68rem;
    border-radius: .55rem;
    color: #41596f;
    text-decoration: none;
    font-size: .84rem;
    font-weight: 400;
    border: 1px solid rgba(214, 222, 232, 0.9);
    background: rgba(255, 255, 255, 0.52);
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.app-topnav-link:hover {
    color: #193f73;
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(189, 203, 220, 0.95);
}

.app-topnav-link.active {
    color: #174b97;
    background: rgba(34, 99, 198, 0.1);
    border-color: rgba(34, 99, 198, 0.15);
    font-weight: 500;
}

.app-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-topbar-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: .32rem .68rem;
    border: 1px solid rgba(214, 222, 232, 0.9);
    background: rgba(255, 255, 255, 0.52);
    color: #41596f;
}

.app-topbar-control:hover,
.app-topbar-control:focus,
.app-topbar-control.show {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(189, 203, 220, 0.95);
    color: #193f73;
}

.app-topbar-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: .32rem .88rem;
}

.app-topbar-profile {
    padding-right: .55rem;
}

.app-avatar {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    background: linear-gradient(135deg, var(--app-brand), var(--app-brand-deep));
    color: #fff;
    font-weight: 700;
    box-shadow: 0 .35rem .8rem rgba(34, 99, 198, 0.18);
    font-size: .76rem;
}

.app-profile-trigger {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.app-profile-meta {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    line-height: 1.1;
}

.app-profile-name {
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-profile-username {
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #6d8094;
    font-size: .66rem;
}

.app-profile-caret {
    color: #7b8da1;
    font-size: .8rem;
}

.app-content {
    flex: 1 1 auto;
    padding: .95rem 1rem 1.1rem;
}

.app-crumbs {
    margin-bottom: .65rem;
}

.breadcrumb {
    margin-bottom: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    padding: .35rem .05rem;
    background: transparent;
    font-size: .78rem;
}

.breadcrumb-item,
.breadcrumb > li {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    color: var(--app-muted);
}

.breadcrumb-item + .breadcrumb-item,
.breadcrumb > li + li {
    padding-left: 0;
}

.app-crumbs .breadcrumb-item + .breadcrumb-item::before,
.app-crumbs .breadcrumb > li + li::before {
    float: none;
    padding-right: .35rem;
    color: #8ea0b4 !important;
    content: "›" !important;
    font-size: .95em;
    line-height: 1;
    opacity: 1 !important;
}

.breadcrumb-item a,
.breadcrumb > li > a {
    color: #4d6986;
    text-decoration: none;
    font-weight: 400;
}

.breadcrumb-item a:hover,
.breadcrumb > li > a:hover {
    color: #1e4f87;
}

.breadcrumb-item.active,
.breadcrumb > .active {
    color: var(--app-ink);
    font-weight: 600;
}

.table thead th > a {
    color: inherit;
    text-decoration: none;
}

.table thead th > a:hover {
    text-decoration: underline;
}

.table thead th > a .caret,
.grid-view .caret,
.kv-grid-table .caret {
    display: none;
}

.table thead th > a.asc::after,
.table thead th > a.desc::after {
    display: inline-block;
    margin-left: .35rem;
    color: #6d8095;
    font-size: .75rem;
    vertical-align: middle;
    font-weight: 400;
}

.table thead th > a.asc::after {
    content: "↑";
}

.table thead th > a.desc::after {
    content: "↓";
}

.app-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: .4rem .65rem;
    color: var(--app-muted);
    padding: .55rem 1rem .8rem;
    margin-top: .45rem;
    border-top: 1px solid rgba(214, 222, 232, 0.75);
    font-size: .86rem;
    line-height: 1.35;
    text-align: center;
}

.app-build-version {
    font-size: .74rem;
    line-height: inherit;
    padding: .2rem .45rem;
}

.app-backdrop {
    display: none;
}

@media (min-width: 768px) and (max-width: 1099.98px) {
    .app-shell:not(.sidebar-expanded) .app-sidebar {
        width: var(--app-sidebar-collapsed-width);
    }

    .app-shell:not(.sidebar-expanded) .app-main {
        margin-left: var(--app-sidebar-collapsed-width);
    }

    .app-shell:not(.sidebar-expanded) .app-brand {
        justify-content: center;
        padding-left: .6rem;
        padding-right: .6rem;
    }

    .app-shell:not(.sidebar-expanded) .app-brand > span:last-child,
    .app-shell:not(.sidebar-expanded) .app-sidebar-label,
    .app-shell:not(.sidebar-expanded) .app-menu-text,
    .app-shell:not(.sidebar-expanded) .app-menu-external {
        display: none;
    }

    .app-shell:not(.sidebar-expanded) .app-sidebar-section {
        padding-left: .4rem;
        padding-right: .4rem;
    }

    .app-shell:not(.sidebar-expanded) .app-menu {
        gap: .35rem;
    }

    .app-shell:not(.sidebar-expanded) .app-menu-link {
        justify-content: center;
        padding-left: .3rem;
        padding-right: .3rem;
        position: relative;
    }

    .app-shell:not(.sidebar-expanded) .app-menu-icon {
        width: 1.8rem;
        height: 1.8rem;
        font-size: .85rem;
    }

}

.app-menu-tooltip {
    position: fixed;
    z-index: 2000;
    white-space: nowrap;
    padding: .7rem 1rem;
    border-radius: .4rem;
    background: #203246;
    color: #fff;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: 0 .5rem 1.2rem rgba(15, 23, 42, 0.22);
    pointer-events: none;
}

@media (max-width: 767.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    .app-shell.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .app-shell.sidebar-collapsed .app-sidebar {
        width: var(--app-sidebar-width);
    }

    .app-main {
        margin-left: 0;
    }

    .app-shell.sidebar-collapsed .app-main {
        margin-left: 0;
    }

    .app-shell.sidebar-collapsed .app-brand > span:last-child,
    .app-shell.sidebar-collapsed .app-sidebar-label,
    .app-shell.sidebar-collapsed .app-menu-text,
    .app-shell.sidebar-collapsed .app-menu-external {
        display: initial;
    }

    .app-shell.sidebar-collapsed .app-brand {
        justify-content: flex-start;
        padding-left: .95rem;
        padding-right: .95rem;
    }

    .app-shell.sidebar-collapsed .app-sidebar-section {
        padding-left: .75rem;
        padding-right: .75rem;
    }

    .app-shell.sidebar-collapsed .app-menu-link {
        justify-content: flex-start;
        padding-left: .68rem;
        padding-right: .68rem;
    }

    .app-topbar-inner {
        align-items: center;
        flex-direction: row;
        justify-content: space-between;
    }

    .app-topbar-actions {
        width: auto;
        justify-content: flex-end;
        gap: .5rem;
    }

    .app-topnav {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: .15rem;
    }

    .app-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 1035;
    }

    .app-shell.sidebar-open .app-backdrop {
        display: block;
    }
}
