:root {
    --bs-body-bg: #f0f2f5;
    --bs-body-color: #182230;
    --bs-primary: #2d6cdf;
    --bs-secondary: #667085;
    --bs-light: #ffffff;
    --bs-dark: #182230;
    --primary: #0f1b2d;
    --primary-dark: #0a1220;
    --primary-light: #1a2d4a;
    --sidebar-width: 260px;
    --header-height: 60px;
    --sidebar-bg: linear-gradient(180deg, #0f1b2d 0%, #162340 100%);
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-text-active: #ffffff;
    --sidebar-accent: #3b82f6;
}

body {
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    overflow-x: hidden;
}

/* ── App Layout ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.app-content {
    flex: 1;
    padding: 1.5rem 2rem 2rem;
    min-width: 0;
    overflow-x: auto;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.sidebar-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--sidebar-accent);
    color: #fff;
    font-size: 1rem;
}

.sidebar-brand-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}
.sidebar-close-btn:hover {
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

.sidebar-nav-section {
    margin-bottom: 0.5rem;
}

.sidebar-nav-label {
    display: block;
    padding: 0.5rem 1.25rem 0.35rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
}

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

.sidebar-menu-item {
    padding: 0 0.65rem;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.sidebar-menu-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.8;
}

.sidebar-menu-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--sidebar-text-active);
}
.sidebar-menu-link:hover i {
    opacity: 1;
}

.sidebar-menu-link.active {
    background: rgba(59, 130, 246, 0.18);
    color: var(--sidebar-text-active);
    font-weight: 600;
}
.sidebar-menu-link.active i {
    color: var(--sidebar-accent);
    opacity: 1;
}

/* ── Top Header / Navbar ── */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 2rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1030;
    min-width: 0;
}

.top-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.top-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-toggle-btn {
    display: none;
    background: none;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 1.25rem;
    color: #475467;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    line-height: 1;
}
.sidebar-toggle-btn:hover {
    background: #f9fafb;
    color: #182230;
}

/* Breadcrumb */
.header-breadcrumb ol {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.header-breadcrumb li {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    color: #667085;
}

.header-breadcrumb li a {
    color: #667085;
    text-decoration: none;
}
.header-breadcrumb li a:hover {
    color: var(--bs-primary);
}

.header-breadcrumb li + li::before {
    content: '/';
    margin: 0 0.4rem;
    color: #d0d5dd;
    font-size: 0.8rem;
}

.header-breadcrumb li.current {
    color: #182230;
    font-weight: 600;
}

/* User button in header */
.header-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 0.35rem 0.75rem 0.35rem 0.35rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #344054;
    transition: all 0.15s ease;
}
.header-user-btn:hover {
    background: #f9fafb;
    border-color: #d0d5dd;
}
.header-user-btn::after {
    font-size: 0.65rem;
    vertical-align: 0.1em;
}

.header-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #eef4ff;
    color: var(--bs-primary);
    font-size: 1rem;
}

.header-user-name {
    font-weight: 600;
}

/* ── Sidebar Overlay (mobile) ── */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ── Responsive ── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }

    .sidebar-toggle-btn {
        display: inline-flex;
    }

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

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

@media (max-width: 575.98px) {
    .app-content {
        padding: 0.75rem;
    }

    .page-heading {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── Page heading ── */
.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card,
.panel-card {
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 12px 24px rgba(16, 24, 40, 0.06);
    background: #ffffff;
}

.metric-card .metric-label {
    font-size: 0.9rem;
    color: #667085;
}

.metric-card .metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table thead th {
    white-space: nowrap;
    font-size: 0.875rem;
    color: #475467;
}

.table tbody td {
    vertical-align: middle;
}

/* Prevent DataTables from overflowing */
.dataTables_wrapper {
    overflow-x: auto;
    width: 100%;
}

.dataTables_wrapper .row {
    margin: 0;
}

.dataTables_wrapper table.dataTable {
    width: 100% !important;
}

.badge-soft {
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    font-weight: 600;
}

.empty-state {
    border: 2px dashed #d0d5dd;
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    color: #667085;
    background: #fff;
}

.form-section-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.chart-wrap {
    position: relative;
    min-height: 320px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #eef4ff;
    color: #1849a9;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.subtle-text {
    color: #667085;
}

code {
    color: #175cd3;
}

/* Modern Form Styles */
.modern-form .form-label {
    font-weight: 600;
    color: #344054;
    margin-bottom: 0.5rem;
}

.modern-form .form-control,
.modern-form .form-select {
    border: 1px solid #d0d5dd;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    transition: all 0.2s ease-in-out;
}

.modern-form .form-control:focus,
.modern-form .form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.1);
    outline: none;
}

.modern-form .input-group .form-control,
.modern-form .input-group .form-select {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.modern-form .input-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: 0;
}

.modern-form .form-text {
    font-size: 0.75rem;
    color: #667085;
    margin-top: 0.25rem;
}

.modern-form .form-check {
    margin-bottom: 1rem;
}

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

.modern-form .btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

.modern-form .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modern-form .card-body {
    padding: 2rem;
}

.modern-form hr {
    border: 0;
    border-top: 1px solid #e5e7eb;
    margin: 2rem 0;
}

.modern-form .section-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 1.5rem;
}

.modern-form .file-input-group {
    position: relative;
}

.modern-form .file-input-group .form-control {
    padding-right: 3rem;
}

.modern-form .file-input-group .file-preview {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: #667085;
}

/* ── Sidebar bottom (help link) ── */
.sidebar-nav-bottom {
    padding: 0.5rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: auto;
}

/* ── Intro.js custom theme ── */
.introjs-custom .introjs-tooltip {
    max-width: 360px;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
.introjs-custom .introjs-tooltip-header {
    padding-bottom: 0;
}
.introjs-custom .introjs-tooltiptext {
    font-size: 0.9rem;
    line-height: 1.6;
    padding: 12px 16px;
}
.introjs-custom .introjs-button {
    border-radius: 6px;
    font-size: 0.8rem;
    padding: 6px 14px;
    text-shadow: none;
    border: 1px solid #d1d5db;
}
.introjs-custom .introjs-button.introjs-nextbutton,
.introjs-custom .introjs-button.introjs-donebutton {
    background: var(--bs-primary, #2d6cdf);
    color: #fff;
    border-color: var(--bs-primary, #2d6cdf);
}
.introjs-custom .introjs-button.introjs-nextbutton:hover,
.introjs-custom .introjs-button.introjs-donebutton:hover {
    background: #1d5bc0;
    border-color: #1d5bc0;
}
.introjs-custom .introjs-progressbar {
    background: var(--bs-primary, #2d6cdf);
}
.introjs-helperLayer {
    border-radius: 8px;
}
