:root {
    --app-bg: #dff0f4;
    --app-fg: #1f2937;
    --app-muted: #6b7280;
    --app-border: rgba(15, 23, 42, 0.08);
    --surface: #ffffff;
    --surface-soft: #f5fbfa;
    --surface-muted: #eff7f6;
    --surface-dark: #0f172a;
    --card-bg: #ffffff;
    --card-border: rgba(15, 23, 42, 0.08);
    --card-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    --topbar-bg: #10b981;
    --topbar-border: rgba(255, 255, 255, 0.22);
    --primary: #10b981;
    --primary-dark: #0f9d75;
    --primary-soft: rgba(16, 185, 129, 0.12);
    --primary-soft-strong: rgba(16, 185, 129, 0.2);
    --danger-soft: rgba(239, 68, 68, 0.12);
    --warning-soft: rgba(245, 158, 11, 0.16);
    --shadow-sm: 0 10px 30px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.12);
    --radius: 20px;
    --radius-sm: 14px;
    --radius-md: 20px;
    --radius-lg: 28px;
    --sidebar-collapsed: 96px;
    --sidebar-expanded: 280px;
    --topbar-height: 74px;
}

body[data-bs-theme="dark"] {
    --app-bg: #09141b;
    --app-fg: #e5eef4;
    --app-muted: #93a4b3;
    --app-border: rgba(255, 255, 255, 0.08);
    --surface: #0f1d26;
    --surface-soft: #112430;
    --surface-muted: #10212b;
    --surface-dark: #061017;
    --card-bg: #0f1d26;
    --card-border: rgba(255, 255, 255, 0.08);
    --card-shadow: 0 12px 34px rgba(0, 0, 0, 0.3);
    --topbar-bg: #0f9d75;
    --topbar-border: rgba(255, 255, 255, 0.2);
    --primary-soft: rgba(16, 185, 129, 0.18);
    --primary-soft-strong: rgba(16, 185, 129, 0.28);
    --danger-soft: rgba(239, 68, 68, 0.18);
    --warning-soft: rgba(245, 158, 11, 0.22);
    --shadow-sm: 0 12px 34px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 28px 56px rgba(0, 0, 0, 0.34);
}

html,
body {
    min-height: 100%;
}

body {
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), transparent 34%),
        linear-gradient(180deg, #cfe6ed 0%, var(--app-bg) 28%, var(--app-bg) 100%);
    color: var(--app-fg);
    font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

a {
    color: var(--primary-dark);
}

a:hover {
    color: var(--primary);
}

#preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
}

body[data-bs-theme="dark"] #preloader {
    background: rgba(6, 16, 23, 0.72);
}

.spinner {
    border: 12px solid rgba(15, 157, 117, 0.16);
    border-top: 12px solid var(--primary);
    border-radius: 50%;
    width: 90px;
    height: 90px;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.app-sidebar {
    position: fixed;
    top: 18px;
    left: 18px;
    bottom: 18px;
    width: var(--sidebar-collapsed);
    background: var(--surface);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 16px 12px;
    z-index: 1045;
    transition: width 180ms ease, transform 180ms ease;
    transform: translateX(-120%);
    overflow: hidden;
}

.app-sidebar.is-expanded {
    width: var(--sidebar-expanded);
}

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

@media (min-width: 992px) {
    .app-sidebar {
        transform: translateX(0);
    }
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
}

.brand-mark {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), #34d399);
    color: #fff;
    display: grid;
    place-items: center;
    box-shadow: 0 14px 24px rgba(16, 185, 129, 0.3);
}

.brand-mark img {
    object-fit: cover;
}

.brand-name {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary-dark);
    line-height: 1;
}

.brand-caption {
    font-size: 0.78rem;
    color: var(--app-muted);
    margin-top: 4px;
}

.app-sidebar:not(.is-expanded) .brand-copy {
    display: none;
}

.sidebar-profile {
    background: linear-gradient(180deg, var(--surface-soft), transparent);
    border: 1px solid var(--app-border);
    border-radius: 22px;
    padding: 18px 12px;
    text-align: center;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    margin: 0 auto 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, #e6fffa, #c7f9eb);
    color: var(--primary-dark);
    display: grid;
    place-items: center;
    overflow: hidden;
    font-weight: 800;
    font-size: 1.25rem;
    box-shadow: inset 0 0 0 4px rgba(16, 185, 129, 0.12);
}

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

.profile-name {
    font-weight: 700;
    line-height: 1.2;
}

.profile-role {
    color: var(--app-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.app-sidebar:not(.is-expanded) .sidebar-profile {
    padding: 12px 6px;
}

.app-sidebar:not(.is-expanded) .profile-avatar {
    width: 48px;
    height: 48px;
    margin-bottom: 0;
    font-size: 1rem;
}

.app-sidebar:not(.is-expanded) .profile-name,
.app-sidebar:not(.is-expanded) .profile-role {
    display: none;
}

.sidebar-nav,
.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-footer {
    margin-top: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    color: #68818f;
    text-decoration: none;
    font-weight: 600;
    transition: transform 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.sidebar-link:hover {
    background: var(--surface-soft);
    color: var(--primary-dark);
    transform: translateX(2px);
}

.sidebar-link.active {
    background: linear-gradient(135deg, var(--primary), #16c08a);
    color: #fff;
    box-shadow: 0 14px 30px rgba(16, 185, 129, 0.25);
}

.sidebar-link .bi {
    width: 22px;
    text-align: center;
    font-size: 1.05rem;
}

.sidebar-link .label {
    white-space: nowrap;
}

.app-sidebar:not(.is-expanded) .sidebar-link {
    justify-content: center;
    padding-inline: 8px;
}

.app-sidebar:not(.is-expanded) .sidebar-link .label {
    display: none;
}

.dropdown-menu {
    border: 1px solid var(--app-border);
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    padding: 10px;
}

.dropdown-item {
    border-radius: 12px;
    padding: 10px 12px;
}

.dropdown-item:hover {
    background: var(--surface-soft);
}

.app-topbar {
    position: fixed;
    top: 18px;
    right: 18px;
    left: 18px;
    height: var(--topbar-height);
    background: linear-gradient(135deg, var(--primary), #0bbf78);
    color: #fff;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 18px;
    box-shadow: 0 24px 48px rgba(16, 185, 129, 0.24);
    z-index: 1040;
    transition: left 180ms ease;
}

@media (min-width: 992px) {
    .app-topbar {
        left: calc(var(--sidebar-collapsed) + 30px);
    }

    .app-shell.sidebar-expanded .app-topbar {
        left: calc(var(--sidebar-expanded) + 30px);
    }
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-left {
    min-width: 0;
    flex: 1;
}

.topbar-right {
    flex-shrink: 0;
}

.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.86);
    font-size: 0.92rem;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.14);
    color: inherit;
    display: grid;
    place-items: center;
    transition: background 140ms ease, transform 140ms ease, border-color 140ms ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 4px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
}

.topbar-user-copy {
    line-height: 1.1;
}

.topbar-user-name {
    font-size: 0.92rem;
    font-weight: 700;
}

.topbar-user-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.76);
}

.topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.24);
    display: grid;
    place-items: center;
    font-weight: 700;
}

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

.app-main {
    padding: 112px 18px 30px;
    transition: margin-left 180ms ease;
}

.app-main.no-topbar {
    padding-top: 28px;
}

@media (min-width: 992px) {
    .app-main {
        margin-left: calc(var(--sidebar-collapsed) + 18px);
        padding-left: 22px;
        padding-right: 22px;
    }

    .app-shell.sidebar-expanded .app-main {
        margin-left: calc(var(--sidebar-expanded) + 18px);
    }
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.page-title {
    font-size: 2rem;
    font-weight: 800;
    margin: 0;
    color: #21414f;
}

.page-header .subtitle {
    margin: 6px 0 0;
    color: var(--app-muted);
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.content-panel,
.card,
.modal-content,
.offcanvas {
    background: var(--surface);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.card {
    overflow: hidden;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--app-border);
    padding: 1rem 1.2rem;
    font-weight: 700;
}

.card-body {
    padding: 1.2rem;
}

.card-footer {
    background: transparent;
    border-top: 1px solid var(--app-border);
}

.btn {
    border-radius: 14px;
    font-weight: 600;
    padding: 0.62rem 1rem;
}

.btn-sm {
    border-radius: 12px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #19c98f);
    border-color: transparent;
    box-shadow: 0 14px 30px rgba(16, 185, 129, 0.24);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    border-color: transparent;
}

.btn-outline-primary {
    color: var(--primary-dark);
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.04);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-outline-secondary {
    border-color: var(--app-border);
    color: var(--app-fg);
}

.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: transparent;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    border-color: transparent;
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-color: transparent;
}

.form-control,
.form-select {
    border-radius: 14px;
    border-color: rgba(148, 163, 184, 0.34);
    background: var(--surface-soft);
    min-height: 46px;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(16, 185, 129, 0.55);
    box-shadow: 0 0 0 0.22rem rgba(16, 185, 129, 0.14);
    background: var(--surface);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.alert {
    border: 0;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background: rgba(34, 197, 94, 0.14);
    color: #15803d;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.16);
    color: #b45309;
}

.table-responsive {
    border-radius: 18px;
}

.table {
    margin-bottom: 0;
    color: var(--app-fg);
    --bs-table-bg: transparent;
}

.table thead th {
    background: var(--surface-soft);
    border-bottom-width: 0;
    color: #66818e;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.95rem 1rem;
}

.table tbody td {
    vertical-align: middle;
    padding: 0.95rem 1rem;
    border-color: rgba(148, 163, 184, 0.14);
}

.table-hover tbody tr:hover td,
.table-striped tbody tr:nth-of-type(odd) > * {
    background: rgba(16, 185, 129, 0.04);
}

.badge {
    border-radius: 999px;
    padding: 0.55em 0.9em;
    font-weight: 700;
}

.text-bg-warning {
    background: var(--warning-soft) !important;
    color: #b45309 !important;
}

.pagination {
    gap: 8px;
}

.page-item .page-link {
    border: 0;
    border-radius: 12px;
    color: var(--app-fg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.page-item.active .page-link {
    background: var(--primary);
}

.dashboard-grid {
    display: grid;
    gap: 18px;
}

.dashboard-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

@media (max-width: 1200px) {
    .dashboard-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 576px) {
    .dashboard-metrics {
        grid-template-columns: 1fr;
    }
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--app-border);
    border-radius: 22px;
    padding: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-sm);
}

.metric-label {
    color: var(--app-muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1;
}

.metric-hint {
    color: var(--app-muted);
    margin-top: 8px;
    font-size: 0.9rem;
}

.metric-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 1.4rem;
}

.metric-icon.success {
    background: rgba(16, 185, 129, 0.14);
    color: var(--primary-dark);
}

.metric-icon.info {
    background: rgba(59, 130, 246, 0.14);
    color: #2563eb;
}

.metric-icon.warning {
    background: rgba(245, 158, 11, 0.16);
    color: #d97706;
}

.metric-icon.danger {
    background: rgba(239, 68, 68, 0.14);
    color: #dc2626;
}

.panel-card {
    background: var(--surface);
    border: 1px solid var(--app-border);
    border-radius: 24px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel-head {
    padding: 20px 22px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.panel-title {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0;
}

.panel-subtitle {
    color: var(--app-muted);
    margin: 4px 0 0;
    font-size: 0.92rem;
}

.panel-body {
    padding: 20px 22px 22px;
}

.soft-list {
    display: grid;
    gap: 12px;
}

.soft-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    background: var(--surface-soft);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.soft-item-title {
    font-weight: 700;
}

.soft-item-text {
    color: var(--app-muted);
    font-size: 0.9rem;
}

.soft-progress {
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.22);
    overflow: hidden;
}

.soft-progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--primary), #23d39b);
}

.quick-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

@media (max-width: 576px) {
    .quick-links {
        grid-template-columns: 1fr;
    }
}

.quick-link-card {
    background: linear-gradient(180deg, var(--surface-soft), #fff);
    border: 1px solid var(--app-border);
    border-radius: 20px;
    padding: 18px;
    text-decoration: none;
    color: var(--app-fg);
    display: block;
    box-shadow: var(--shadow-sm);
}

.quick-link-card:hover {
    transform: translateY(-2px);
    color: var(--app-fg);
}

.quick-link-card .bi {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    margin-bottom: 12px;
    font-size: 1.2rem;
}

.login-shell {
    min-height: calc(100vh - 56px);
    display: grid;
    place-items: center;
}

.login-card-modern {
    width: min(1080px, 100%);
    background: var(--surface);
    border: 1px solid var(--app-border);
    border-radius: 32px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-brand-side {
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.18), transparent 32%),
        linear-gradient(160deg, #0ea86f 0%, #10b981 50%, #0f9d75 100%);
    color: #fff;
    height: 100%;
    padding: 36px 34px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.login-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    border-radius: 999px;
    padding: 9px 14px;
    background: rgba(255, 255, 255, 0.16);
    font-weight: 700;
}

.login-side-title {
    font-size: clamp(2rem, 3vw, 2.7rem);
    font-weight: 800;
    line-height: 1.05;
    margin: 18px 0 12px;
}

.login-side-text {
    color: rgba(255, 255, 255, 0.82);
    font-size: 1rem;
    max-width: 420px;
}

.login-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.login-stat {
    border-radius: 20px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(6px);
}

.login-stat-value {
    font-size: 1.2rem;
    font-weight: 800;
}

.login-stat-label {
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.88rem;
}

.login-form-side {
    padding: 36px 34px;
}

.login-form-card {
    max-width: 420px;
    margin: 0 auto;
}

.login-logo {
    width: 74px;
    height: 74px;
    border-radius: 22px;
    background: var(--surface-soft);
    display: grid;
    place-items: center;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.login-logo img {
    max-width: 82%;
    max-height: 82%;
    object-fit: contain;
}

.login-heading {
    font-size: 1.9rem;
    font-weight: 800;
    margin: 18px 0 6px;
}

.login-copy {
    color: var(--app-muted);
    margin-bottom: 24px;
}

.login-form-side .form-control {
    min-height: 52px;
}

.login-footer-note {
    color: var(--app-muted);
    text-align: center;
    font-size: 0.92rem;
    margin-top: 20px;
}

.app-footer {
    text-align: right;
    color: var(--app-muted);
    font-size: 0.85rem;
    padding-top: 14px;
}

@media (max-width: 991px) {
    .app-topbar {
        left: 18px !important;
    }

    .topbar-breadcrumb,
    .topbar-user-copy {
        display: none;
    }

    .page-header {
        flex-direction: column;
    }
}

@media (max-width: 767px) {
    .login-brand-side {
        display: none;
    }

    .login-form-side {
        padding: 28px 22px;
    }

    .page-title {
        font-size: 1.6rem;
    }
}
