:root {
    --sidebar-bg: #1e1e2d;
    /* Deep smooth navy/black */
    --sidebar-text: #a2a3b7;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 260px;

    --body-bg: #f9f9fc;
    /* Very light, airy, slight blue tint */
    --card-bg: #ffffff;
    --text-main: #3f4254;
    --text-muted: #b5b5c3;

    --primary: #0d6efd;
    /* Bootstrap Blue */
    --primary-hover: #0b5ed7;
    --danger: #f1416c;
    --success: #50cd89;
    --warning: #ffc700;

    --radius: 1rem;
    /* 16px - softer look */
    --shadow-card: 0 0 20px 0 rgba(76, 87, 125, 0.02);
    /* Extremely subtle shadow */
    --shadow-hover: 0 0 20px 0 rgba(76, 87, 125, 0.1);
}

/* Badge Soft Styles */
.badge-soft-primary {
    background-color: rgba(13, 110, 253, 0.15);
    color: #0d6efd !important;
    border: 1px solid rgba(13, 110, 253, 0.25);
}

.badge-soft-info {
    background-color: rgba(13, 202, 240, 0.15);
    color: #009ef7 !important;
    /* Vibrant readable cyan */
    border: 1px solid rgba(13, 202, 240, 0.25);
}

.badge-soft-secondary {
    background-color: #f1f1f4;
    color: #7e8299;
    border: 1px solid #e4e6ef;
}

html,
body {
    background-color: var(--body-bg);
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

/* Layout Structure */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1100;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-content {
        margin-left: 0 !important;
    }

    .top-header {
        padding: 1rem 1.5rem;
    }

    .content-wrapper {
        padding: 0 1rem 1rem 1rem;
    }
}

.sidebar-header {
    height: 80px;
    /* Taller header */
    padding: 0 2rem;
    color: white;
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.1);
}

.sidebar-nav {
    padding: 1.5rem;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-link-dashboard {
    display: flex;
    align-items: center;
    padding: 1.1rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-link-dashboard:hover,
.nav-link-dashboard.active {
    background-color: #2b2b40;
    color: var(--sidebar-text-active);
}

.nav-link-dashboard i {
    margin-right: 1rem;
    font-size: 1.2rem;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    /* Offset for fixed sidebar */
    display: flex;
    flex-direction: column;
    background: var(--body-bg);
}

.top-header {
    background-color: transparent;
    padding: 1.5rem 2.5rem;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 900;
}

.content-wrapper {
    padding: 0 2.5rem 2.5rem 2.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Welcome Banner Grad */
.welcome-banner {
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    /* Soft Purple-Blue Gradient */
    border-radius: var(--radius);
    padding: 2.5rem;
    color: var(--text-main);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px -10px rgba(132, 88, 246, 0.2);
}

.welcome-banner h2 {
    font-weight: 800;
    color: #2d2d3a;
    margin-bottom: 0.5rem;
}

.welcome-banner p {
    color: #4a4a5e;
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Nav Pills Override for Purple Consistency */
.nav-pills .nav-link.active,
.nav-pills .show>.nav-link {
    background-color: var(--primary);
    color: white;
}

.nav-pills .nav-link {
    color: var(--text-muted);
}

.nav-pills .nav-link:hover {
    color: var(--primary);
    background-color: rgba(13, 110, 253, 0.05);
}

/* Card Styles - Dashboard Style */
.card-dashboard {
    background-color: var(--card-bg);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    margin-bottom: 1.5rem;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    position: relative;
    /* CRITICAL for stretched-link containment */
}

.card-dashboard:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.card-header-dashboard {
    padding: 1.5rem 2rem;
    border-bottom: 1px dashed #eff2f5;
    background-color: transparent;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body-dashboard {
    padding: 2rem;
}

/* Button Overrides */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

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

.btn-soft-primary {
    background-color: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
    border: 1px solid transparent;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-soft-primary:hover {
    background-color: rgba(13, 110, 253, 0.2);
    color: #0b5ed7;
}

.btn-soft-secondary {
    background-color: #f1f1f4;
    color: #7e8299;
    border: 1px solid transparent;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-soft-secondary:hover {
    background-color: #e4e6ef;
    color: #3f4254;
}

.btn-soft-danger {
    background-color: rgba(241, 65, 108, 0.1);
    color: #f1416c;
    border: 1px solid transparent;
    font-weight: 600;
}
.btn-soft-danger:hover {
    background-color: rgba(241, 65, 108, 0.2);
    color: #d9214e;
}

.btn-soft-success {
    background-color: rgba(80, 205, 137, 0.1);
    color: #50cd89;
    border: 1px solid transparent;
    font-weight: 600;
}
.btn-soft-success:hover {
    background-color: rgba(80, 205, 137, 0.2);
    color: #47be7d;
}

.btn-soft-info {
    background-color: rgba(0, 158, 247, 0.1);
    color: #009ef7;
    border: 1px solid transparent;
    font-weight: 600;
}
.btn-soft-info:hover {
    background-color: rgba(0, 158, 247, 0.2);
    color: #0095e8;
}

/* Mobile Square Button Utility */
@media (max-width: 767.98px) {
    .btn-mobile-square {
        width: 38px !important;
        height: 38px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 0.5rem !important;
    }
}

/* Form Controls */
.form-control,
.form-select {
    border: 1px solid transparent;
    /* No border by default */
    padding: 0.65rem 1.1rem;
    font-size: 0.95rem;
    border-radius: var(--radius);
    background-color: #f1f1f4;
    /* Softer gray background */
    color: var(--text-main);
    transition: all 0.2s ease;
    box-shadow: none;
}

.form-control:focus,
.form-select:focus {
    background-color: #ffffff;
    border-color: var(--primary);
    box-shadow: none;
}

/* Labels */
.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    letter-spacing: 0.025em;
}

/* Detail View Helpers */
.detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
    display: block;
}

.detail-value {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-main);
}

.detail-block {
    background-color: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: var(--radius);
    padding: 1.5rem;
}

/* Table Clean Up */
.table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    background-color: #f8fafc;
}

/* Soft Pagination */
.pagination-soft .page-item .page-link {
    border: none;
    border-radius: 50% !important;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: transparent;
    transition: all 0.2s;
    margin: 0 4px;
    font-weight: 600;
    font-size: 0.9rem;
}

.pagination-soft .page-item:not(.active) .page-link:hover {
    background-color: #f1f1f4;
    color: var(--primary);
}

.pagination-soft .page-item.active .page-link {
    background-color: rgba(13, 110, 253, 0.1);
    color: var(--primary);
    box-shadow: 0 0 10px rgba(13, 110, 253, 0.1);
}

.pagination-soft .page-item.disabled .page-link {
    opacity: 0.4;
    cursor: default;
}

/* Flip Card Effect */
.flip-container {
    perspective: 1000px;
    display: inline-block;
    cursor: pointer;
}

.flipper {
    transition: 0.6s;
    transform-style: preserve-3d;
    position: relative;
    display: grid;
    /* Use grid to stack faces */
}

.flip-container.flipped .flipper {
    transform: rotateY(-180deg);
}

/* Stack faces on top of each other */
.flip-front,
.flip-back {
    grid-area: 1 / 1;
    /* Both occupy the same cell */
    backface-visibility: hidden;
    transition: 0.6s;
    width: 100%;
    /* Ensure they fill the container */
}

.flip-front {
    z-index: 2;
    transform: rotateY(0deg);
}

.flip-back {
    transform: rotateY(-180deg);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Custom Popover Style */
.popover {
    border: none;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    pointer-events: none;
    /* Prevent popover from interfering with mouse events */
}

.popover-body {
    padding: 1rem 1.25rem;
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.9rem;
}

.cursor-pointer {
    cursor: pointer;
}

/* Utility: Letter Spacing */
.ls-wide {
    letter-spacing: 0.05em;
}

/* Remove focus glow from toggles */
.form-check-input:focus {
    box-shadow: none;
    border-color: #adb5bd;
}

/* Gray toggle when unchecked */
.form-check-input:not(:checked) {
    background-color: #ffffff;
    border-color: #ced4da;
}

/* Hide Spinners globally for number inputs */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
    /* Firefox */
    appearance: textfield;
    /* Standard */
}