:root {
    /* Colors */
    --bg-body: #f2edf3;
    --bg-white: #ffffff;
    --text-main: #343a40;
    --text-sidebar: #3e4b5b;
    --text-muted: #a3a4a5;
    --icon-muted: #bba8bff5;
    --border-color: #f3f3f3;

    --color-primary: #b66dff;
    --color-primary-dark: #4f46e5;

    /* Gradients - Primary */
    --grad-primary-start: #da8cff;
    --grad-primary-end: #9a55ff;
    --grad-primary-hover-start: #b66dff;
    --grad-primary-hover-end: #823de2;

    /* Gradients - Semantic */
    --grad-success-start: #84d9d2;
    --grad-success-end: #07cdae;

    --grad-info-start: #90caf9;
    --grad-info-end: #047edf;

    --grad-danger-start: #ffbf96;
    --grad-danger-end: #fe7096;

    --grad-warning-start: #f6e384;
    --grad-warning-end: #ffd500;

    /* Shadows */
    --shadow-sm: 0 0 10px rgba(0, 0, 0, 0.02);
    --shadow-md: 0px 5px 15px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0px 8px 20px rgba(0, 0, 0, 0.06);
    --shadow-login: 0 10px 25px rgba(0, 0, 0, 0.1);
    --shadow-navbar: 0px 5px 21px -5px rgba(0, 0, 0, 0.02);
}

/* =========================================================================
   GLOBAL CSS (Typography, Base)
========================================================================= */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    font-size: 0.875rem;
    color: var(--text-main);
}

body.login-page {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
}

/* =========================================================================
   SIDEBAR
========================================================================= */
.sidebar {
    min-height: 100vh;
    width: 260px;
    background-color: var(--bg-white);
    color: var(--text-sidebar);
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--color-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.025em;
}

.sidebar-user-profile {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--bg-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-sidebar);
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.sidebar-menu-item a {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.5rem;
    color: var(--text-sidebar);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-menu-item a:hover {
    color: var(--color-primary);
}

.sidebar-menu-item.active a {
    color: var(--color-primary);
    font-weight: 600;
}

.sidebar-menu-item i {
    margin-right: 1rem;
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
    color: var(--icon-muted);
    transition: all 0.2s;
}

.sidebar-menu-item.active i {
    color: var(--color-primary);
}

.sidebar-menu-item a:hover i {
    color: var(--color-primary);
}

/* Sidebar Nested Menu */
.sidebar-menu-item .sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: var(--bg-white);
    border-left: 2px solid var(--border-color);
    margin-left: 2.2rem;
    margin-bottom: 0.5rem;
}

.sidebar-submenu-item a {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem 0.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border-left: none;
}

.sidebar-submenu-item a:hover,
.sidebar-submenu-item.active a {
    color: var(--color-primary);
}

.sidebar-submenu-item a::before {
    content: "•";
    margin-right: 8px;
    font-size: 1rem;
    line-height: 1;
}

.sidebar-menu-item>a.menu-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-menu-item>a.menu-toggle::after {
    content: '\F282';
    /* bootstrap icon chevron-down */
    font-family: "bootstrap-icons";
    font-size: 0.8rem;
    transition: transform 0.2s;
    margin-left: auto;
    border: none;
}

.sidebar-menu-item>a.menu-toggle[aria-expanded="true"]::after {
    transform: rotate(180deg);
}

/* =========================================================================
   LAYOUT & NAVBAR
========================================================================= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

.navbar-custom {
    background-color: var(--bg-white);
    border-bottom: none;
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-navbar);
}

.content-body {
    padding: 1.5rem 1.5rem 1rem 1.5rem;
    flex: 1 0 auto;
}

.footer {
    margin-top: auto;
    width: 100%;
}

/* =========================================================================
   CARDS & PANELS
========================================================================= */
.card-custom {
    border: 1px solid rgba(182, 109, 255, 0.18);
    /* Deeper structural border */
    border-radius: 0.75rem;
    /* Smoother corner rounding */
    box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.04);
    background-color: var(--bg-white);
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-custom:hover {
    box-shadow: 0px 8px 25px rgba(182, 109, 255, 0.12);
}

.card-custom-header {
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-color);
    background-color: transparent;
}

/* =========================================================================
   BUTTONS & BADGES
========================================================================= */
.btn {
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    padding: 0.5rem 1.25rem;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}

.btn-custom-primary {
    background: linear-gradient(to right, var(--grad-primary-start), var(--grad-primary-end));
    color: var(--bg-white);
    border: none;
}

.btn-custom-primary:hover {
    background: linear-gradient(to right, var(--grad-primary-hover-start), var(--grad-primary-hover-end));
    color: var(--bg-white);
}

.btn-indigo {
    background: linear-gradient(to right, var(--grad-primary-start), var(--grad-primary-end));
    color: var(--bg-white);
    border: none;
}

.btn-indigo:hover {
    background: linear-gradient(to right, var(--grad-primary-hover-start), var(--grad-primary-hover-end));
    color: var(--bg-white);
}

.badge-priority {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 0.25rem;
}

.badge-status {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.35rem 0.7rem;
    border-radius: 0.25rem;
}

/* Custom Dropdown Hover/Active states matching purple branding */
.dropdown-item:hover,
.dropdown-item:focus,
.dropdown-item:active {
    background-color: #f3ebff !important; /* Soft premium purple */
    color: #4f46e5 !important; /* Indigo text */
}

.dropdown-item:hover i,
.dropdown-item:focus i,
.dropdown-item:active i {
    color: #4f46e5 !important;
}

/* =========================================================================
   REPORTS SPECIFIC & GRADIENTS (Purple Admin matching)
========================================================================= */

.bg-gradient-primary {
    background: linear-gradient(to right, var(--grad-primary-start), var(--grad-primary-end)) !important;
}

.bg-gradient-success {
    background: linear-gradient(to right, var(--grad-success-start), var(--grad-success-end)) !important;
}

.bg-gradient-info {
    background: linear-gradient(to right, var(--grad-info-start), var(--grad-info-end)) !important;
}

.bg-gradient-danger {
    background: linear-gradient(to right, var(--grad-danger-start), var(--grad-danger-end)) !important;
}

.bg-gradient-warning {
    background: linear-gradient(to right, var(--grad-warning-start), var(--grad-warning-end)) !important;
}

.bg-white-10 {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

.stat-icon-bg {
    width: 40px;
    height: 40px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.card-stat {
    border-radius: 0.5rem;
    color: var(--bg-white);
}

/* =========================================================================
   TABLES
========================================================================= */
.table {
    font-size: 0.875rem;
    color: var(--text-main);
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.table > thead > tr > th,
.table thead.table-light > tr > th {
    background-color: #ede2ff !important; /* Deeper premium purple tint */
    color: #4a1d96 !important; /* Deep dark purple text for high contrast */
    font-weight: 700 !important; /* Fully Bold */
    font-size: 0.92rem; /* Increased size */
    letter-spacing: 0.02em;
    padding: 0.85rem 1rem;
    border-bottom: 2px solid rgba(182, 109, 255, 0.3) !important; /* Stronger divider */
}

.table>tbody>tr:nth-child(odd)>td,
.table-striped>tbody>tr:nth-of-type(odd)>td,
.table-striped>tbody>tr:nth-of-type(odd)>* {
    --bs-table-accent-bg: transparent !important;
    background-color: #ffffff !important;
}

.table>tbody>tr:nth-child(even)>td,
.table-striped>tbody>tr:nth-of-type(even)>td,
.table-striped>tbody>tr:nth-of-type(even)>* {
    --bs-table-accent-bg: transparent !important;
    background-color: #f9f7fd !important;
    /* Subtle premium lavender-slate tint */
}

.table>tbody>tr:hover>td {
    background-color: #f1ebfc !important;
    /* Smooth hover transition */
    transition: background-color 0.2s ease;
}

.table>tbody>tr:has(td[colspan])>td {
    background-color: #ffffff !important;
    border-bottom: none !important;
}

.table>tbody>tr:last-child>td {
    border-bottom: none !important;
}

.table td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04) !important;
}

/* =========================================================================
   TOM SELECT & FLATPICKR OVERRIDES
========================================================================= */
.ts-control {
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    box-shadow: none;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-white);
}

.ts-control.focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.25rem rgba(182, 109, 255, 0.25);
}

.ts-dropdown {
    border-color: var(--border-color);
    box-shadow: var(--shadow-md);
    border-radius: 0.375rem;
}

.ts-dropdown .option.active {
    background-color: var(--color-primary);
    color: var(--bg-white);
}

.flatpickr-calendar {
    box-shadow: var(--shadow-md) !important;
    border: 1px solid var(--border-color) !important;
}

/* =========================================================================
   LOGIN SPECIFIC
========================================================================= */
.login-card {
    border: none;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-login);
    background-color: var(--bg-white);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

.login-page .brand-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-page .brand-title {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 1.6rem;
    margin: 0 0 0.25rem 0;
}

.btn-login {
    background: linear-gradient(to right, var(--grad-primary-start), var(--grad-primary-end));
    color: var(--bg-white);
    border: none;
    font-weight: 600;
}

.btn-login:hover {
    background: linear-gradient(to right, var(--grad-primary-hover-start), var(--grad-primary-hover-end));
    color: var(--bg-white);
}

/* CKEditor Rich Text Formatting Rules */
.ckeditor-content ul {
    list-style-type: disc !important;
    padding-left: 2rem !important;
    margin-bottom: 1rem !important;
}

.ckeditor-content ol {
    list-style-type: decimal !important;
    padding-left: 2rem !important;
    margin-bottom: 1rem !important;
}

.ckeditor-content blockquote {
    border-left: 4px solid var(--color-primary);
    padding-left: 1rem;
    color: #666;
    font-style: italic;
    margin: 1rem 0;
}

.ckeditor-content img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 6px;
    margin: 1rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ckeditor-content table {
    width: 100% !important;
    border-collapse: collapse;
    margin: 1rem 0;
}

.ckeditor-content table th,
.ckeditor-content table td {
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
}

.ckeditor-content table th {
    background-color: var(--bg-light);
    font-weight: 600;
}

.ck-editor__editable_inline {
    min-height: 200px !important;
}

.focus-border-bottom {
    border-bottom: 2px solid transparent !important;
    border-radius: 0 !important;
    transition: border-color 0.2s ease-in-out;
}

.focus-border-bottom:focus {
    border-bottom-color: var(--color-primary) !important;
    background-color: rgba(0, 0, 0, 0.01) !important;
}

/* =========================================================================
   PREMIUM ANALYTICS CARDS (With Animating Waves & Progress Rings)
========================================================================= */
.card-premium {
    position: relative;
    background: #ffffff;
    border: 1px solid rgba(182, 109, 255, 0.12);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 8px 24px rgba(90, 48, 166, 0.04);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 1;
}
.card-premium:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(90, 48, 166, 0.08);
}

/* Header icon */
.card-premium-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* Circular Progress Ring */
.progress-ring-wrapper {
    position: relative;
    width: 36px;
    height: 36px;
}
.progress-ring-text {
    font-size: 0.65rem;
    font-weight: 700;
    color: #4a5568;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Sparkline trend graphic */
.sparkline-svg {
    width: 55px;
    height: 25px;
    margin-left: 12px;
    opacity: 0.85;
}
.sparkline-path {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Animating Wave Background */
.card-wave-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%; /* Double width to loop wave seamlessly */
    height: 50px;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}
.card-wave {
    display: block;
    width: 100%;
    height: 100%;
    fill: currentColor;
    transform: translate3d(0, 0, 0);
}
.card-wave-1 {
    animation: wave-animation-1 12s linear infinite;
}
.card-wave-2 {
    animation: wave-animation-2 8s linear infinite;
    opacity: 0.45;
}

@keyframes wave-animation-1 {
    0% { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-50%, 0, 0); }
}
@keyframes wave-animation-2 {
    0% { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-50%, 0, 0); }
}

/* Color variations */
.card-prem-purple .card-premium-icon {
    background-color: #f3ebff;
    color: #9a55ff;
}
.card-prem-purple .progress-ring-circle-val {
    stroke: #9a55ff;
}
.card-prem-purple .card-wave-container {
    color: rgba(154, 85, 255, 0.04);
}
.card-prem-purple .sparkline-path {
    stroke: #9a55ff;
}

.card-prem-pink .card-premium-icon {
    background-color: #ffeef2;
    color: #fe7096;
}
.card-prem-pink .progress-ring-circle-val {
    stroke: #fe7096;
}
.card-prem-pink .card-wave-container {
    color: rgba(254, 112, 150, 0.04);
}
.card-prem-pink .sparkline-path {
    stroke: #fe7096;
}

.card-prem-blue .card-premium-icon {
    background-color: #e8f4ff;
    color: #047edf;
}
.card-prem-blue .progress-ring-circle-val {
    stroke: #047edf;
}
.card-prem-blue .card-wave-container {
    color: rgba(4, 126, 223, 0.04);
}
.card-prem-blue .sparkline-path {
    stroke: #047edf;
}

.card-prem-green .card-premium-icon {
    background-color: #e1fbf7;
    color: #07cdae;
}
.card-prem-green .progress-ring-circle-val {
    stroke: #07cdae;
}
.card-prem-green .card-wave-container {
    color: rgba(7, 205, 174, 0.04);
}
.card-prem-green .sparkline-path {
    stroke: #07cdae;
}

.card-prem-orange .card-premium-icon {
    background-color: #fff6e0;
    color: #ffd500;
}
.card-prem-orange .progress-ring-circle-val {
    stroke: #ffd500;
}
.card-prem-orange .card-wave-container {
    color: rgba(255, 213, 0, 0.04);
}
.card-prem-orange .sparkline-path {
    stroke: #ffd500;
}

/* Custom Indigo Outline Button */
.btn-outline-indigo {
    color: #4f46e5;
    border-color: #4f46e5;
    background-color: transparent;
    transition: all 0.2s ease-in-out;
}
.btn-outline-indigo:hover, .btn-outline-indigo:focus, .btn-outline-indigo:active {
    color: #fff !important;
    background-color: #4f46e5 !important;
    border-color: #4f46e5 !important;
}