:root {
    --app-primary: #174f43;
    --app-primary-dark: #103b32;
    --app-accent: #b4975a;
    --app-sidebar-width: 310px;
    --app-topbar-height: 92px;
    --app-dark-canvas: #111715;
    --app-dark-surface: #19201e;
    --app-dark-surface-soft: #202a27;
    --app-dark-border: #303a37;
    --app-canvas: #f5f7f6;
    --app-surface: #ffffff;
    --app-surface-soft: #eef4f1;
    --app-border: #dce4e1;
    --app-text: #24312e;
    --app-muted: #6c7975;
}

[data-bs-theme="dark"] {
    --app-canvas: var(--app-dark-canvas);
    --app-surface: var(--app-dark-surface);
    --app-surface-soft: var(--app-dark-surface-soft);
    --app-border: var(--app-dark-border);
    --app-text: #f1f5f3;
    --app-muted: #9da7a3;
}

body {
    min-height: 100vh;
    font-family: Tahoma, Arial, sans-serif;
    color: #24312e;
}

body.app-authenticated {
    background: var(--app-canvas) !important;
    color: var(--app-text);
}

.app-navbar,
.app-topbar {
    background: linear-gradient(110deg, var(--app-primary-dark), var(--app-primary));
    border-bottom: 3px solid var(--app-accent);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1040;
    min-height: var(--app-topbar-height);
    color: white;
    background: #115849;
}

.app-topbar-inner {
    min-height: var(--app-topbar-height);
    padding: .7rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
}

.app-brand {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    line-height: 1.25;
}

.app-brand:hover,
.app-brand:focus {
    color: white;
}

.app-brand strong,
.app-brand small {
    display: block;
}

.app-brand strong {
    font-size: clamp(1.12rem, 1.2vw, 1.38rem);
    line-height: 1.4;
}

.app-brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 2px solid var(--app-accent);
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    font-size: 1.1rem;
    font-weight: 700;
}

.app-account-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-theme-button {
    min-width: 92px;
}

.app-theme-menu {
    min-width: 165px;
}

.app-theme-choice {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.app-theme-choice.active {
    background: var(--app-primary);
    color: white;
}

.app-user-name {
    max-width: 310px;
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-user-name small {
    display: block;
    color: rgba(255, 255, 255, .7);
    font-weight: 400;
    font-size: .82rem;
}

.app-shell {
    min-height: calc(100vh - var(--app-topbar-height));
    display: flex;
    align-items: stretch;
    background: var(--app-canvas);
}

.app-sidebar {
    --bs-offcanvas-width: var(--app-sidebar-width);
    width: var(--app-sidebar-width);
    flex: 0 0 var(--app-sidebar-width);
    background: var(--app-surface);
    border-left: 1px solid var(--app-border);
}

.app-sidebar-body {
    padding: 1.6rem .85rem !important;
}

.app-side-nav {
    width: 100%;
}

.app-nav-group {
    padding: .35rem 0 .95rem;
    margin-bottom: .7rem;
    border-bottom: 1px solid var(--app-border);
}

.app-nav-group:last-child {
    border-bottom: 0;
}

.app-nav-heading {
    padding: 0 .85rem;
    margin: 0 0 .45rem;
    color: var(--app-muted);
    font-size: .88rem;
    font-weight: 700;
}

.app-nav-link {
    position: relative;
    display: block;
    padding: .72rem .85rem;
    margin: .12rem 0;
    border-radius: .5rem;
    color: var(--app-text);
    text-decoration: none;
    font-size: 1.06rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .7rem;
    transition: background-color .15s ease, color .15s ease;
}

.app-nav-link:hover,
.app-nav-link:focus {
    color: #fff;
    background: var(--app-surface-soft);
}

.app-nav-link.active {
    color: #fff;
    background: #235d50;
    box-shadow: 0 4px 10px rgba(23, 79, 67, .16);
}

.app-nav-icon {
    width: 1.4rem;
    flex: 0 0 1.4rem;
    text-align: center;
    color: currentColor;
    font-size: 1.18rem;
    line-height: 1;
}

.app-page {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    background: var(--app-canvas);
}

.app-main-content {
    width: 100%;
    max-width: 1500px;
    padding: 2rem 2.25rem;
    flex: 1 0 auto;
}

.app-footer {
    max-width: 1500px;
}

.app-sidebar-mobile-header {
    border-bottom: 1px solid var(--app-border);
    background: var(--app-surface);
}

.app-authenticated .card,
.app-authenticated .table,
.app-authenticated .list-group-item {
    --bs-card-bg: var(--app-surface);
    --bs-table-bg: var(--app-surface);
    --bs-table-striped-bg: var(--app-surface-soft);
    --bs-list-group-bg: var(--app-surface);
    border-color: var(--app-border) !important;
}

.app-authenticated .table > :not(caption) > * > * {
    border-color: var(--app-border);
}

.app-authenticated .text-secondary,
.app-authenticated .text-muted {
    color: var(--app-muted) !important;
}

[data-bs-theme="dark"] .app-authenticated .alert-success {
    --bs-alert-color: #e3f3ed;
    --bs-alert-bg: #205445;
    --bs-alert-border-color: #2e7764;
}

.app-sort-link {
    color: var(--app-text);
}

.app-sort-link:hover,
.app-sort-link:focus {
    color: #4f9f89;
}

.app-checkbox-list {
    max-height: 250px;
    overflow-y: auto;
    padding: .35rem;
    border: 1px solid var(--app-border);
    border-radius: .5rem;
    background: var(--app-surface);
}

.app-checkbox-list > div {
    border-radius: .4rem;
}

.app-checkbox-list > div:hover {
    background: var(--app-surface-soft);
}

.app-checkbox-list label {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .6rem;
    margin: 0;
    cursor: pointer;
}

.app-checkbox-list input[type="checkbox"] {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    accent-color: var(--app-primary);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--app-primary);
    color: white;
    border: 3px solid var(--app-accent);
    font-size: 1.75rem;
    font-weight: 700;
}

.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary-dark);
    --bs-btn-hover-border-color: var(--app-primary-dark);
}

.login-card {
    border-top: 4px solid var(--app-accent) !important;
}

@media (min-width: 992px) {
    .app-sidebar {
        position: sticky;
        top: var(--app-topbar-height);
        height: calc(100vh - var(--app-topbar-height));
        overflow-y: auto;
    }

    .app-sidebar-mobile-header {
        display: none;
    }
}

@media (max-width: 991.98px) {
    .app-topbar-inner {
        padding-inline: 1rem;
    }

    .app-sidebar {
        width: var(--app-sidebar-width) !important;
    }

    .app-sidebar-body {
        overflow-y: auto;
    }

    .app-main-content {
        padding: 1.25rem 1rem;
    }
}

@media (max-width: 575.98px) {
    :root {
        --app-topbar-height: 66px;
    }

    .app-brand-mark,
    .app-user-name {
        display: none;
    }

    .app-brand strong {
        font-size: .98rem;
    }

    .app-brand small {
        display: none;
    }

    .app-menu-toggle {
        display: inline-flex;
        align-items: center;
        gap: .35rem;
    }

    .app-account-area {
        gap: .5rem;
    }

    .app-account-area .btn {
        padding-inline: .55rem;
        font-size: .75rem;
    }

    .app-nav-heading {
        font-size: .8rem;
    }

    .app-nav-link {
        font-size: 1rem;
    }
}
