:root {
    --bg-canvas: #f4f7fb;
    --bg-surface: #ffffff;
    --bg-subtle: #eef3f8;
    --bg-elevated: #fbfdff;

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    --border-soft: #d9e2ec;
    --border-strong: #c3d1df;

    --accent: #0f6cbd;
    --accent-hover: #0b5fa8;
    --accent-subtle: rgba(15, 108, 189, 0.12);

    --success: #15803d;
    --warning: #b45309;
    --danger: #b91c1c;
    --info: #0369a1;

    --shadow-1: 0 2px 6px rgba(15, 23, 42, 0.05);
    --shadow-2: 0 10px 25px rgba(15, 23, 42, 0.09);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;

    --focus-ring: 0 0 0 3px rgba(15, 108, 189, 0.24);

    --topbar-height: 70px;
    --sidebar-width: 268px;

    --font-ui: "Manrope", "Source Sans 3", "Segoe UI", sans-serif;

    /* Legacy token compatibility */
    --primary-light: #5aa4dc;
    --primary-dark: #0b5fa8;
    --dark: #0f172a;
    --dark-75: #334155;
    --dark-65: #475569;
    --dark-50: #64748b;
    --dark-25: #94a3b8;
    --light: #eef3f8;
    --light-dark: #d9e2ec;
    --light-darker: #c3d1df;
    --white: #ffffff;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
}

html,
body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at 20% -20%, #eaf2ff 0%, transparent 50%), var(--bg-canvas);
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.5;
    min-height: 100%;
}

a {
    color: var(--accent);
}

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

*:focus {
    outline: none;
}

*:focus-visible {
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

.dashboard-main-wrapper {
    min-height: 100vh;
}

.dashboard-header .navbar {
    height: var(--topbar-height);
    padding: 0.6rem 1.5rem;
    background: rgba(255, 255, 255, 0.94) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.navbar-brand {
    color: var(--text-primary) !important;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.navbar-logo {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.navbar-brand-text-wrap {
    min-width: 0;
    max-width: min(42vw, 380px);
}

.navbar-brand-title {
    color: var(--text-primary);
    font-size: clamp(0.95rem, 1.1vw, 1.12rem);
    line-height: 1.15;
    letter-spacing: 0.005em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-brand-subtitle {
    font-size: 0.73rem;
    line-height: 1.2;
    color: var(--text-muted) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar .nav-link {
    color: var(--text-secondary) !important;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.navbar .nav-link:hover {
    background: var(--bg-subtle);
    color: var(--text-primary) !important;
}

.user-avatar-md {
    width: 38px;
    height: 38px;
    border: 2px solid var(--bg-subtle);
}

.badge {
    border-radius: 999px;
    font-weight: 700;
}

.badge-danger {
    background: var(--danger) !important;
}

.dropdown-menu {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-2);
    overflow: hidden;
}

.dropdown-item {
    color: var(--text-secondary);
    font-weight: 600;
}

.dropdown-item:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.nav-left-sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border-right: 1px solid var(--border-soft);
    overflow-y: auto;
    z-index: 1010;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-left-sidebar::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.nav-left-sidebar .menu-list {
    padding: 0.9rem 0;
}

.nav-left-sidebar .nav-divider {
    margin: 1rem 1.15rem 0.5rem;
    padding: 0.75rem 0.5rem 0.35rem;
    font-size: 0.72rem;
    color: var(--text-muted) !important;
    border-bottom: 1px solid var(--bg-subtle);
}

.nav-left-sidebar .navbar-nav .nav-link {
    margin: 0.12rem 0.85rem !important;
    padding: 0.64rem 0.9rem !important;
    border-radius: 10px !important;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary) !important;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-left-sidebar .navbar-nav .nav-link i {
    width: 20px !important;
    margin-right: 0.7rem !important;
    color: var(--text-muted) !important;
}

.nav-left-sidebar .navbar-nav .nav-link:hover {
    background: var(--bg-subtle) !important;
    color: var(--text-primary) !important;
    transform: translateX(2px);
}

.nav-left-sidebar .navbar-nav .nav-link:hover i {
    color: var(--accent) !important;
}

.nav-left-sidebar .navbar-nav .nav-link.active,
.nav-left-sidebar .navbar-nav .nav-link[style*="background-color"] {
    background: linear-gradient(135deg, #0f6cbd 0%, #0891b2 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 8px 18px rgba(8, 145, 178, 0.22) !important;
}

.nav-left-sidebar .navbar-nav .nav-link.active i,
.nav-left-sidebar .navbar-nav .nav-link[style*="background-color"] i,
.nav-left-sidebar .navbar-nav .nav-link.active span,
.nav-left-sidebar .navbar-nav .nav-link[style*="background-color"] span {
    color: #ffffff !important;
}

.nav-left-sidebar .submenu {
    margin: 0.2rem 0.9rem 0.45rem;
    background: rgba(238, 243, 248, 0.75) !important;
    border: 1px solid #e4edf7;
    border-radius: 10px;
}

.nav-left-sidebar .submenu .nav-link {
    margin: 0 !important;
    padding: 0.58rem 0.8rem 0.58rem 2.55rem !important;
    font-size: 0.83rem;
}

.dashboard-wrapper {
    margin-left: var(--sidebar-width);
    padding: calc(var(--topbar-height) + 0.9rem) 1.2rem 1.2rem;
    min-height: 100vh;
}

.dashboard-content {
    width: 100%;
}

.container-fluid {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

.page-header {
    margin-bottom: 1.3rem;
}

.pageheader-title {
    color: var(--text-primary);
    font-weight: 800;
    letter-spacing: -0.02em;
    font-size: clamp(1.2rem, 2vw, 1.7rem);
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin-top: 0.35rem;
}

.breadcrumb-item,
.breadcrumb-item a {
    color: var(--text-muted);
    font-weight: 600;
}

.breadcrumb-item.active {
    color: var(--text-secondary);
}

.card,
.dashboard-card,
.table-card,
.chart-card {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-soft) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-1);
}

.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--bg-subtle) !important;
    color: var(--text-primary);
    font-weight: 700;
}

.card:hover,
.dashboard-card:hover,
.table-card:hover,
.chart-card:hover {
    box-shadow: var(--shadow-2);
}

.table {
    color: var(--text-secondary);
}

.table thead th,
.table-responsive table thead th {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody td,
.table-responsive table tbody td {
    border-bottom: 1px solid #edf2f7;
    padding-top: 0.62rem;
    padding-bottom: 0.62rem;
}

.table tbody tr:hover,
.table-responsive table tbody tr:hover {
    background: #f7fbff;
    transform: none;
}

.form-control,
.custom-select,
.bootstrap-select .dropdown-toggle {
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-primary);
    background: #ffffff;
    min-height: 36px;
    box-shadow: none !important;
}

.form-control:focus,
.custom-select:focus,
.bootstrap-select .dropdown-toggle:focus {
    border-color: var(--accent) !important;
    box-shadow: var(--focus-ring) !important;
}

.form-group label,
label {
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.83rem;
}

.btn {
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.42rem 0.85rem;
    letter-spacing: 0.01em;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    box-shadow: none;
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-light {
    background: var(--bg-subtle);
    border-color: var(--border-soft);
    color: var(--text-secondary);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #ffffff;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

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

.btn-outline-primary:hover {
    background: var(--accent);
    color: #ffffff;
}

.alert {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.alert-warning {
    border-color: #fddca5;
    background: #fff9ec;
    color: #8c5f00;
}

.progress {
    border-radius: 999px;
    background: #e7eef6;
}

.progress-bar {
    background: var(--accent);
}

.pagination .page-link,
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important;
    border: 1px solid var(--border-soft) !important;
    color: var(--text-secondary) !important;
    background: #fff !important;
    box-shadow: none !important;
}

.pagination .page-item.active .page-link,
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
}

.se-pre-con {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #ffffff url('../img/preloader_1.gif') center no-repeat;
}

#ai-widget-fab {
    background: var(--accent) !important;
    box-shadow: 0 8px 24px rgba(15, 108, 189, 0.3) !important;
}

#ai-widget-fab:hover {
    background: var(--accent-hover) !important;
}

#ai-widget-window {
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-2) !important;
}

#ai-widget-header {
    background: linear-gradient(135deg, #0f6cbd 0%, #0891b2 100%) !important;
}

/* Standardized Status Badges - Following notifications/templates design */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.4;
}

.status-badge i {
    font-size: 0.9rem;
}

.status-badge.approved,
.status-badge.success,
.status-badge.active {
    background: rgba(21, 128, 61, 0.12);
    color: #15803d;
}

.status-badge.approved i,
.status-badge.success i,
.status-badge.active i {
    color: #15803d;
}

.status-badge.pending,
.status-badge.warning {
    background: rgba(180, 83, 9, 0.12);
    color: #b45309;
}

.status-badge.pending i,
.status-badge.warning i {
    color: #b45309;
}

.status-badge.rejected,
.status-badge.danger,
.status-badge.inactive {
    background: rgba(185, 28, 28, 0.12);
    color: #b91c1c;
}

.status-badge.rejected i,
.status-badge.danger i,
.status-badge.inactive i {
    color: #b91c1c;
}

.status-badge.info {
    background: rgba(15, 108, 189, 0.12);
    color: #0f6cbd;
}

.status-badge.info i {
    color: #0f6cbd;
}

/* Legacy badge compatibility - maps old classes to new styling */
.badge.badge-success,
.badge.badge-primary {
    background: rgba(21, 128, 61, 0.12) !important;
    color: #15803d !important;
}

.badge.badge-danger {
    background: rgba(185, 28, 28, 0.12) !important;
    color: #b91c1c !important;
}

.badge.badge-warning {
    background: rgba(180, 83, 9, 0.12) !important;
    color: #b45309 !important;
}

.badge.badge-info {
    background: rgba(15, 108, 189, 0.12) !important;
    color: #0f6cbd !important;
}

.badge.badge-secondary {
    background: rgba(100, 116, 139, 0.12) !important;
    color: #64748b !important;
}

.badge.badge-light {
    background: rgba(100, 116, 139, 0.12) !important;
    color: #64748b !important;
}

/* Icon-only action buttons */
.btn-icon-only {
    padding: 0.5rem 0.6rem !important;
    border-radius: 8px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    transition: all 0.2s ease;
}

.btn-icon-only i {
    margin: 0 !important;
    font-size: 0.95rem;
}

.btn-icon-only.btn-primary {
    background: var(--accent) !important;
    color: #fff !important;
}

.btn-icon-only.btn-primary:hover {
    background: var(--accent-hover) !important;
    transform: translateY(-1px);
}

.btn-icon-only.btn-danger {
    background: rgba(185, 28, 28, 0.12);
    color: #b91c1c !important;
    border: 1px solid rgba(185, 28, 28, 0.2) !important;
}

.btn-icon-only.btn-danger:hover {
    background: rgba(185, 28, 28, 0.2);
    border-color: rgba(185, 28, 28, 0.4) !important;
}

#ai-widget-input:focus {
    border-color: var(--accent) !important;
    box-shadow: var(--focus-ring) !important;
}

@media (max-width: 1199px) {
    .nav-left-sidebar {
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-2);
    }

    .nav-left-sidebar.show {
        transform: translateX(0);
    }

    .dashboard-wrapper {
        margin-left: 0;
        padding: calc(var(--topbar-height) + 0.9rem) 0.85rem 1rem;
    }

    .dashboard-header .navbar {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (max-width: 767px) {
    .navbar-logo {
        height: 36px;
    }

    .navbar-brand-text-wrap {
        max-width: 42vw;
    }

    .navbar-brand-title {
        font-size: 0.92rem;
    }

    .navbar-brand-subtitle {
        display: none;
    }

    .pageheader-title {
        font-size: 1.25rem;
    }

    .card-body,
    .dashboard-card .card-body {
        padding: 1rem;
    }

    .navbar-brand .d-flex.flex-column {
        display: none !important;
    }

    #ai-widget-window {
        width: min(92vw, 360px) !important;
        right: 0;
    }
}
