/**
 * app.css — MySupplierList Members Application
 *
 * Custom CSS to complement Bootstrap 5.3.
 * Mirrors the marketing site colour scheme:
 *   Primary navy : #003366  (hsl 210 100% 20%)
 *   Green        : #339966  (hsl 140 50% 40%)
 *   Amber        : #f59e0b
 *   Dark         : #0f172a → #1e293b
 *   Background   : #f8fafc (slate-50)
 *   Border       : #e2e8f0 (slate-200)
 *   Text         : #0f172a (slate-900)
 *   Muted text   : #64748b (slate-500)
 *
 * Table of contents
 * -----------------
 *  1.  CSS custom properties
 *  2.  Base / typography
 *  3.  Sidebar layout
 *  4.  Sidebar navigation
 *  5.  Sidebar footer
 *  6.  Main content & content wrapper
 *  7.  Topbar
 *  8.  Breadcrumbs
 *  9.  Flash messages
 * 10.  Cards & stat cards
 * 11.  Page headers
 * 12.  Form sections
 * 13.  DataTables overrides
 * 14.  Status & risk badges
 * 15.  Tab styles
 * 16.  Table utilities
 * 17.  Notification dropdown
 * 18.  Auth layout
 * 19.  Portal layout
 * 20.  PDF layout (screen fallback)
 * 21.  Global search autocomplete
 * 22.  Mobile off-canvas + overlay
 * 23.  Print styles
 */


/* ================================================================
   1. CSS Custom Properties
================================================================ */

:root {
    /* Brand colours */
    --msl-navy:          #003366;
    --msl-navy-dark:     #002244;
    --msl-navy-light:    #004488;
    --msl-green:         #339966;
    --msl-green-light:   #44bb77;
    --msl-amber:         #f59e0b;
    --msl-amber-light:   #fbbf24;

    /* Dark surfaces */
    --msl-dark-950:      #0a0f1a;
    --msl-dark-900:      #0f172a;
    --msl-dark-800:      #1e293b;
    --msl-dark-700:      #334155;
    --msl-dark-600:      #475569;

    /* Light surfaces */
    --msl-bg:            #f8fafc;
    --msl-bg-white:      #ffffff;
    --msl-border:        #e2e8f0;
    --msl-border-hover:  #cbd5e1;

    /* Text */
    --msl-text:          #0f172a;
    --msl-text-muted:    #64748b;
    --msl-text-light:    #94a3b8;

    /* Sidebar */
    --sidebar-width:       260px;
    --sidebar-bg:          #0f172a;
    --sidebar-bg-hover:    rgba(255, 255, 255, 0.07);
    --sidebar-bg-active:   rgba(255, 255, 255, 0.12);
    --sidebar-border:      rgba(255, 255, 255, 0.08);
    --sidebar-text:        rgba(255, 255, 255, 0.65);
    --sidebar-text-hover:  rgba(255, 255, 255, 0.9);
    --sidebar-text-active: #ffffff;
    --sidebar-accent:      #f59e0b;
    --sidebar-section:     rgba(255, 255, 255, 0.35);
    --sidebar-header-h:    64px;
    --sidebar-footer-h:    72px;

    /* Topbar */
    --topbar-h:            56px;
    --topbar-bg:           #ffffff;
    --topbar-border:       #e2e8f0;

    /* Misc */
    --radius:              0.5rem;
    --radius-sm:           0.375rem;
    --radius-lg:           0.75rem;
    --shadow-sm:           0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow:              0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-md:           0 10px 15px rgba(0, 0, 0, 0.06), 0 4px 6px rgba(0, 0, 0, 0.04);
    --shadow-lg:           0 20px 25px rgba(0, 0, 0, 0.08), 0 8px 10px rgba(0, 0, 0, 0.04);

    /* Transition */
    --t-fast:  0.15s ease;
    --t-base:  0.25s ease;
    --t-slow:  0.35s ease;
}


/* ================================================================
   2. Base / Typography
================================================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: var(--msl-bg);
    color: var(--msl-text);
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6,
.font-display {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--msl-text);
}

/* Application h1–h4 use Inter (display only for hero titles) */
.app-body h1,
.app-body h2,
.app-body h3,
.app-body h4 {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    letter-spacing: -0.01em;
}

a {
    color: var(--msl-navy);
    text-decoration: none;
    transition: color var(--t-fast);
}

a:hover {
    color: var(--msl-navy-light);
}


/* ================================================================
   3. Sidebar Layout
================================================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform var(--t-slow);
    overflow: hidden;

    /* Subtle right border */
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

/* Sidebar header / brand */
.sidebar-header {
    flex-shrink: 0;
    height: var(--sidebar-header-h);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    overflow: hidden;
}

.sidebar-brand-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    background: var(--msl-amber);
    color: var(--msl-dark-900);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-brand-name {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.9375rem;
    color: #ffffff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-brand-sub {
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--sidebar-section);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 1;
    margin-top: 1px;
}

/* Scrollable nav area */
.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0 1rem;

    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.sidebar-close-btn {
    color: var(--sidebar-text);
    border: none;
    background: none;
    padding: 0.25rem;
    line-height: 1;
    font-size: 0.875rem;
    transition: color var(--t-fast);
}

.sidebar-close-btn:hover {
    color: #ffffff;
}


/* ================================================================
   4. Sidebar Navigation
================================================================ */

.sidebar-nav {
    padding: 0;
    list-style: none;
    margin: 0;
}

/* Section headers */
.nav-section-header {
    padding: 1rem 1rem 0.375rem;
    pointer-events: none;
}

.nav-section-header span {
    display: block;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--sidebar-section);
    line-height: 1;
}

.nav-section-header--admin span {
    color: rgba(245, 158, 11, 0.5);
}

/* Nav items */
.sidebar-nav .nav-item {
    padding: 0 0.5rem;
    margin-bottom: 1px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5625rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8375rem;
    font-weight: 500;
    color: var(--sidebar-text);
    border-left: 3px solid transparent;
    transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast);
    text-decoration: none;
    line-height: 1.35;
    position: relative;
}

.sidebar-nav .nav-link:hover {
    background-color: var(--sidebar-bg-hover);
    color: var(--sidebar-text-hover);
}

.sidebar-nav .nav-link.active {
    background-color: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-accent);
    font-weight: 600;
}

.sidebar-icon {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.8rem;
    opacity: 0.8;
}

.sidebar-nav .nav-link:hover .sidebar-icon,
.sidebar-nav .nav-link.active .sidebar-icon {
    opacity: 1;
}

/* Badge counts on nav items */
.sidebar-badge {
    margin-left: auto;
    background: var(--msl-amber);
    color: var(--msl-dark-900);
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.15em 0.45em;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

.sidebar-badge--danger {
    background: #ef4444;
    color: #ffffff;
}


/* ================================================================
   5. Sidebar Footer
================================================================ */

.sidebar-footer {
    flex-shrink: 0;
    height: var(--sidebar-footer-h);
    padding: 0 0.75rem;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    overflow: hidden;
    width: 100%;
}

.sidebar-user-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--msl-navy-light), var(--msl-navy));
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.sidebar-user-info {
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sidebar-user-email {
    font-size: 0.6875rem;
    color: var(--sidebar-section);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}


/* ================================================================
   6. Main Content & Content Wrapper
================================================================ */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background-color: var(--msl-bg);
    display: flex;
    flex-direction: column;
    transition: margin-left var(--t-slow);
}

.content-wrapper {
    flex: 1;
    padding-bottom: 2rem;
}


/* ================================================================
   7. Topbar
================================================================ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-h);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    padding: 0 1.25rem;
}

.topbar-inner {
    height: 100%;
}

.topbar-page-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--msl-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

/* Topbar icon buttons */
.topbar-toggle-btn,
.topbar-icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--msl-text-muted);
    background: transparent;
    border: 1px solid transparent;
    transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.topbar-toggle-btn:hover,
.topbar-icon-btn:hover {
    background: var(--msl-bg);
    border-color: var(--msl-border);
    color: var(--msl-text);
}

/* Notification badge */
.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.5625rem;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    line-height: 16px;
    border-radius: 8px;
}

/* User button */
.topbar-user-btn {
    height: 36px;
    padding: 0 0.625rem;
    border-radius: var(--radius-sm);
    color: var(--msl-text);
    background: transparent;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color var(--t-fast), border-color var(--t-fast);
}

.topbar-user-btn:hover,
.topbar-user-btn:focus {
    background: var(--msl-bg);
    border-color: var(--msl-border);
    color: var(--msl-text);
}

.topbar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--msl-navy), var(--msl-navy-light));
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.topbar-user-name {
    font-size: 0.8375rem;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Global search field */
.global-search-wrap {
    position: relative;
    width: 100%;
    max-width: 380px;
}

.global-search-form .form-control {
    background: var(--msl-bg);
    border: 1px solid var(--msl-border);
    border-left: none;
    font-size: 0.8375rem;
    color: var(--msl-text);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.global-search-form .input-group-text {
    background: var(--msl-bg);
    border: 1px solid var(--msl-border);
    border-right: none;
}

.global-search-form .form-control:focus {
    background: #ffffff;
    border-color: var(--msl-navy);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.08);
    outline: none;
}

.global-search-form .form-control:focus + .input-group-text,
.global-search-form .input-group:focus-within .input-group-text {
    border-color: var(--msl-navy);
    background: #ffffff;
}

/* Mobile search bar */
.topbar-mobile-search {
    background: var(--topbar-bg);
    border-top: 1px solid var(--msl-border);
}


/* ================================================================
   8. Breadcrumbs
================================================================ */

.app-breadcrumb {
    padding: 0 0 0.25rem;
}

.breadcrumb {
    font-size: 0.8125rem;
    background: transparent;
    padding: 0;
    margin: 0;
    --bs-breadcrumb-divider: '›';
}

.breadcrumb-link {
    color: var(--msl-text-muted);
    text-decoration: none;
    transition: color var(--t-fast);
}

.breadcrumb-link:hover {
    color: var(--msl-navy);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--msl-text);
    font-weight: 500;
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--msl-text-light);
}


/* ================================================================
   9. Flash Messages
================================================================ */

.flash-container {
    padding-top: 0.75rem;
}

.flash-alert {
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 0.875rem;
    animation: flashIn 0.2s ease both;
}

@keyframes flashIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* ================================================================
   10. Cards & Stat Cards
================================================================ */

.card {
    border: 1px solid var(--msl-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--msl-bg-white);
    transition: box-shadow var(--t-base), border-color var(--t-base);
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    background: var(--msl-bg-white);
    border-bottom: 1px solid var(--msl-border);
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 0.875rem 1.25rem;
}

.card-header.bg-white {
    background: var(--msl-bg-white) !important;
}

/* Stat card — KPI / dashboard widgets */
.stat-card {
    border: 1px solid var(--msl-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: var(--msl-bg-white);
    transition: box-shadow var(--t-base), transform var(--t-base);
    overflow: hidden;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card .card-body {
    padding: 1.25rem;
}

.stat-card .stat-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--msl-text-muted);
    margin-bottom: 0.375rem;
    line-height: 1;
}

.stat-card .stat-value {
    font-family: 'Inter', sans-serif;
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--msl-text);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.stat-card .stat-trend {
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.375rem;
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
}

/* Icon colour variants */
.stat-icon-navy    { background: rgba(0, 51, 102, 0.1);  color: var(--msl-navy); }
.stat-icon-green   { background: rgba(51, 153, 102, 0.1); color: var(--msl-green); }
.stat-icon-amber   { background: rgba(245, 158, 11, 0.1); color: var(--msl-amber); }
.stat-icon-red     { background: rgba(239, 68, 68, 0.1);  color: #ef4444; }
.stat-icon-purple  { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.stat-icon-cyan    { background: rgba(6, 182, 212, 0.1);  color: #06b6d4; }

/* Trend colours */
.stat-trend-up   { color: #16a34a; }
.stat-trend-down { color: #dc2626; }
.stat-trend-flat { color: var(--msl-text-muted); }


/* ================================================================
   11. Page Headers
================================================================ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-family: 'Inter', sans-serif;
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--msl-text);
    margin: 0;
    letter-spacing: -0.02em;
}

.page-header h1 i {
    color: var(--msl-navy);
    opacity: 0.85;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Bootstrap primary button — navy brand colour */
.btn-primary {
    background-color: var(--msl-navy);
    border-color: var(--msl-navy);
    color: #ffffff;
    font-weight: 500;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--msl-navy-dark);
    border-color: var(--msl-navy-dark);
    color: #ffffff;
}

.btn-primary:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.25);
}

/* Green accent button */
.btn-success {
    background-color: var(--msl-green);
    border-color: var(--msl-green);
    color: #ffffff;
    font-weight: 500;
}

.btn-success:hover {
    background-color: #2a7a52;
    border-color: #2a7a52;
    color: #ffffff;
}

/* Amber accent */
.btn-warning {
    background-color: var(--msl-amber);
    border-color: var(--msl-amber);
    color: var(--msl-dark-900);
    font-weight: 500;
}

.btn-warning:hover {
    background-color: #d97706;
    border-color: #d97706;
    color: var(--msl-dark-900);
}


/* ================================================================
   12. Form Sections
================================================================ */

.form-section {
    background: var(--msl-bg-white);
    border: 1px solid var(--msl-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.form-section h5 {
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--msl-text);
    margin-bottom: 1rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid var(--msl-border);
}

.form-section h5 i {
    color: var(--msl-navy);
    margin-right: 0.375rem;
    opacity: 0.8;
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--msl-dark-700);
    margin-bottom: 0.375rem;
}

.form-control,
.form-select {
    border-color: var(--msl-border);
    color: var(--msl-text);
    font-size: 0.875rem;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--msl-navy);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
}

.form-control::placeholder {
    color: var(--msl-text-light);
}

/* Autosave indicator */
.autosave-indicator {
    font-size: 0.75rem;
    color: var(--msl-green);
    font-weight: 500;
    display: none;
}


/* ================================================================
   13. DataTables Overrides
================================================================ */

/* Wrapper layout */
.dataTables_wrapper {
    font-size: 0.875rem;
}

.dataTables_wrapper .dataTables_filter {
    float: right;
}

.dataTables_wrapper .dataTables_filter label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--msl-text-muted);
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--msl-border);
    border-radius: var(--radius-sm);
    padding: 0.3125rem 0.625rem;
    font-size: 0.8125rem;
    color: var(--msl-text);
    transition: border-color var(--t-fast);
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--msl-navy);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.08);
}

/* Pagination */
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--msl-navy);
    border-color: var(--msl-navy);
    color: #ffffff !important;
    border-radius: var(--radius-sm);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--msl-bg);
    border-color: var(--msl-border);
    color: var(--msl-text) !important;
    border-radius: var(--radius-sm);
}

/* Table row styles */
table.dataTable {
    border-collapse: collapse !important;
    font-size: 0.8375rem;
}

table.dataTable thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--msl-border) !important;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--msl-text-muted);
    padding: 0.625rem 0.875rem;
    white-space: nowrap;
}

table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
    cursor: pointer;
    user-select: none;
}

table.dataTable tbody tr {
    border-bottom: 1px solid var(--msl-border);
    transition: background-color var(--t-fast);
}

table.dataTable tbody tr:hover {
    background-color: #f0f6ff !important;
    cursor: pointer;
}

table.dataTable tbody tr:last-child {
    border-bottom: none;
}

table.dataTable td {
    padding: 0.625rem 0.875rem;
    vertical-align: middle;
    color: var(--msl-text);
}

/* Actions column — always last, no wrapping */
table.dataTable td.actions,
table.dataTable th.actions {
    white-space: nowrap;
    width: 1%;
    text-align: right;
}

/* Processing indicator */
.dataTables_processing {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid var(--msl-border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-md) !important;
    padding: 0.75rem 1.5rem !important;
    font-size: 0.8125rem;
    color: var(--msl-text-muted);
}

/* Info / length */
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length {
    font-size: 0.8rem;
    color: var(--msl-text-muted);
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--msl-border);
    border-radius: var(--radius-sm);
    padding: 0.2rem 1.5rem 0.2rem 0.4rem;
    font-size: 0.8rem;
}


/* ================================================================
   14. Status & Risk Badges
================================================================ */

/* Base reset for all .badge */
.badge {
    font-weight: 500;
    font-size: 0.6875rem;
    letter-spacing: 0.02em;
    padding: 0.3em 0.65em;
    border-radius: 4px;
    line-height: 1.4;
}

/* Semantic status badges */
.badge-status-prospective,
.badge-status-draft,
.badge-status-inactive   { background: #f1f5f9; color: #475569; }

.badge-status-onboarding,
.badge-status-new,
.badge-status-submitted  { background: #dbeafe; color: #1e40af; }

.badge-status-approved,
.badge-status-active,
.badge-status-completed,
.badge-status-resolved   { background: #dcfce7; color: #15803d; }

.badge-status-pending,
.badge-status-in_progress,
.badge-status-review     { background: #fef9c3; color: #854d0e; }

.badge-status-suspended,
.badge-status-on_hold    { background: #ffedd5; color: #c2410c; }

.badge-status-terminated,
.badge-status-expired,
.badge-status-rejected,
.badge-status-overdue    { background: #fee2e2; color: #b91c1c; }

.badge-status-closed     { background: #f1f5f9; color: #64748b; }

/* Risk level badges */
.badge-risk-low      { background: #dcfce7; color: #15803d; }
.badge-risk-medium   { background: #fef9c3; color: #854d0e; }
.badge-risk-high     { background: #fee2e2; color: #b91c1c; }
.badge-risk-critical { background: #4b0000; color: #fca5a5; }

/* Tier labels */
.badge-tier-1 { background: rgba(0, 51, 102, 0.1);  color: var(--msl-navy); font-weight: 600; }
.badge-tier-2 { background: rgba(51, 153, 102, 0.1); color: #166534; font-weight: 600; }
.badge-tier-3 { background: #f1f5f9; color: #475569; font-weight: 600; }


/* ================================================================
   15. Tab Styles (Tabbed detail pages)
================================================================ */

.detail-tabs {
    border-bottom: 1px solid var(--msl-border);
    gap: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.detail-tabs::-webkit-scrollbar {
    display: none;
}

.detail-tabs .nav-link {
    color: var(--msl-text-muted);
    font-size: 0.8375rem;
    font-weight: 500;
    padding: 0.625rem 1rem;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    white-space: nowrap;
    transition: color var(--t-fast), border-color var(--t-fast);
}

.detail-tabs .nav-link:hover {
    color: var(--msl-text);
    border-bottom-color: var(--msl-border-hover);
}

.detail-tabs .nav-link.active {
    color: var(--msl-navy);
    border-bottom-color: var(--msl-navy);
    background: transparent;
    font-weight: 600;
}

.tab-content {
    padding-top: 1.25rem;
}


/* ================================================================
   16. Table Utilities
================================================================ */

.table-responsive {
    border-radius: var(--radius);
    overflow-x: auto;
}

.table-hover > tbody > tr:hover > td,
.table-hover > tbody > tr:hover > th {
    background-color: #f0f6ff;
}

/* Compact table variant */
.table-compact td,
.table-compact th {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* Table with sticky header */
.table-sticky-head thead th {
    position: sticky;
    top: 0;
    background: var(--msl-bg-white);
    z-index: 1;
}

/* Clickable row indicator */
.table-clickable tbody tr {
    cursor: pointer;
}

.table-clickable tbody tr:active {
    background-color: #e0eeff !important;
}


/* ================================================================
   17. Notification Dropdown
================================================================ */

.notification-dropdown {
    width: 360px;
    padding: 0;
    border: 1px solid var(--msl-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.notification-header {
    background: var(--msl-bg-white);
    border-bottom: 1px solid var(--msl-border);
    font-size: 0.875rem;
}

.notification-header h6 {
    font-size: 0.9rem;
    font-weight: 600;
}

.notification-list {
    background: var(--msl-bg-white);
}

.notification-item {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none;
    transition: background-color var(--t-fast);
    font-size: 0.8125rem;
    color: var(--msl-text);
}

.notification-item:hover {
    background-color: var(--msl-bg);
    color: var(--msl-text);
}

.notification-item.unread {
    background-color: #f0f6ff;
    border-left: 3px solid var(--msl-navy);
}

.notification-item.unread:hover {
    background-color: #e5efff;
}

.notification-item .notif-title {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--msl-text);
    line-height: 1.35;
    margin-bottom: 0.125rem;
}

.notification-item .notif-time {
    font-size: 0.75rem;
    color: var(--msl-text-muted);
}

.notification-empty {
    padding: 1.5rem 1rem;
}

.notification-footer {
    background: var(--msl-bg);
    border-top: 1px solid var(--msl-border);
    font-size: 0.8125rem;
}


/* ================================================================
   18. Auth Layout
================================================================ */

.auth-body {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--msl-dark-900) 0%, var(--msl-dark-800) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
}

/* Subtle background pattern */
.auth-bg-pattern {
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.025'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.auth-wrapper {
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
}

.auth-logo-wrap {
    margin-bottom: 1.75rem;
}

.auth-logo-link {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.auth-logo-mark {
    width: 52px;
    height: 52px;
    background: var(--msl-amber);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--msl-dark-900);
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.auth-app-name {
    display: block;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.auth-app-tagline {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
    letter-spacing: 0.03em;
}

.auth-card {
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.35) !important;
    background: #ffffff;
}

.auth-card h2 {
    font-family: 'Inter', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--msl-text);
    margin-bottom: 0.25rem;
}

.auth-card .auth-subtitle {
    font-size: 0.875rem;
    color: var(--msl-text-muted);
    margin-bottom: 1.5rem;
}

.auth-footer {
    font-size: 0.8125rem;
}

.auth-footer a:hover {
    color: #ffffff;
}


/* ================================================================
   19. Portal Layout
================================================================ */

.portal-body {
    background: var(--msl-bg);
    padding-top: 0;
}

.portal-navbar {
    background: var(--msl-dark-900);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0 0;
    position: sticky;
    top: 0;
    z-index: 1030;
    height: 60px;
}

.portal-navbar .container-fluid {
    height: 100%;
    align-items: center;
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    margin-right: 1.5rem;
}

.portal-brand-icon {
    width: 32px;
    height: 32px;
    background: var(--msl-amber);
    color: var(--msl-dark-900);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.portal-brand-name {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.portal-brand-label {
    display: block;
    font-size: 0.625rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.portal-nav-link {
    color: rgba(255, 255, 255, 0.65) !important;
    font-size: 0.8375rem;
    font-weight: 500;
    padding: 0.5rem 0.875rem !important;
    border-radius: var(--radius-sm);
    transition: color var(--t-fast), background-color var(--t-fast);
}

.portal-nav-link:hover,
.portal-nav-link.active {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.08);
}

.portal-user-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8375rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    transition: background-color var(--t-fast);
}

.portal-user-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}

.portal-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--msl-green);
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.portal-content {
    min-height: calc(100vh - 60px - 56px);
    padding-top: 0;
}

.portal-footer {
    background: var(--msl-bg-white);
    border-top: 1px solid var(--msl-border);
    padding: 1rem 0;
    font-size: 0.8125rem;
}

.portal-footer-brand {
    font-weight: 600;
    color: var(--msl-text);
}

.portal-footer-links a {
    font-size: 0.8125rem;
    text-decoration: none;
    transition: color var(--t-fast);
}

.portal-footer-links a:hover {
    color: var(--msl-navy);
}


/* ================================================================
   20. Global Search Autocomplete
================================================================ */

.global-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--msl-bg-white);
    border: 1px solid var(--msl-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1050;
    overflow: hidden;
    max-height: 400px;
    overflow-y: auto;
}

.search-result-group {
    border-bottom: 1px solid var(--msl-border);
    padding-bottom: 0.25rem;
    margin-bottom: 0.25rem;
}

.search-result-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.search-result-group-label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--msl-text-muted);
    padding: 0.5rem 0.875rem 0.25rem;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.875rem;
    text-decoration: none;
    color: var(--msl-text);
    font-size: 0.8375rem;
    transition: background-color var(--t-fast);
}

.search-result-item:hover,
.search-result-item.focused {
    background: var(--msl-bg);
    color: var(--msl-text);
}

.search-result-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--msl-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--msl-navy);
    flex-shrink: 0;
}

.search-result-label {
    font-weight: 500;
    line-height: 1.3;
}

.search-result-sub {
    font-size: 0.75rem;
    color: var(--msl-text-muted);
    line-height: 1.3;
}

.search-empty {
    padding: 1.25rem;
    text-align: center;
    font-size: 0.8375rem;
    color: var(--msl-text-muted);
}


/* ================================================================
   21. Mobile Off-Canvas & Overlay
================================================================ */

/* Sidebar overlay backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1039;
    backdrop-filter: blur(2px);
    animation: overlayIn 0.2s ease;
}

@keyframes overlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Responsive breakpoints */
@media (max-width: 991.98px) {

    /* Sidebar slides off-canvas by default */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    /* Show state (toggled by sidebarToggle) */
    .sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    /* Show overlay when sidebar is open */
    .sidebar.show ~ .sidebar-overlay,
    #wrapper.sidebar-open .sidebar-overlay {
        display: block;
    }

    /* Main content fills full width on mobile */
    .main-content {
        margin-left: 0 !important;
    }

    /* Topbar search hidden on xs */
    .topbar-search {
        display: none !important;
    }

    /* Page headers stack on mobile */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper.container-fluid {
        padding-left: 0.875rem;
        padding-right: 0.875rem;
    }

    .form-section {
        padding: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }
}


/* ================================================================
   22. Print Styles
================================================================ */

@media print {

    /* Hide all chrome */
    .sidebar,
    .sidebar-overlay,
    .topbar,
    .app-breadcrumb,
    .flash-container,
    .page-header-actions,
    .btn-group,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_paginate,
    .dataTables_wrapper .dataTables_info,
    .notification-dropdown,
    #ajaxModal,
    #ajaxModalXl,
    #ajaxModalSm {
        display: none !important;
    }

    /* Full-width content */
    .main-content {
        margin-left: 0 !important;
    }

    .content-wrapper {
        padding: 0;
    }

    /* Expose card borders */
    .card {
        border: 1px solid #dee2e6 !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    /* Stat values readable on white paper */
    .stat-card .stat-value {
        color: #000 !important;
    }

    /* Tables print cleanly */
    table.dataTable thead th {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Ensure links print their text not the URL */
    a[href]::after {
        content: none !important;
    }

    body {
        font-size: 11pt;
        line-height: 1.4;
    }

    @page {
        margin: 15mm 20mm;
    }
}


/* ================================================================
   23. Misc Utilities
================================================================ */

/* Page loading bar */
#nprogress .bar {
    background: var(--msl-amber) !important;
    height: 2px !important;
}

#nprogress .peg {
    box-shadow: 0 0 10px var(--msl-amber), 0 0 5px var(--msl-amber) !important;
}

/* Toastr overrides */
.toast-top-right { top: 70px !important; right: 16px !important; }

#toast-container > .toast {
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-md) !important;
    opacity: 0.97 !important;
    font-size: 0.875rem;
}

#toast-container > .toast-success {
    background-color: #166534 !important;
}

#toast-container > .toast-error {
    background-color: #b91c1c !important;
}

#toast-container > .toast-warning {
    background-color: #92400e !important;
}

#toast-container > .toast-info {
    background-color: var(--msl-navy) !important;
}

/* SweetAlert2 overrides */
.swal2-popup {
    border-radius: var(--radius-lg) !important;
    font-family: 'Inter', sans-serif !important;
}

.swal2-confirm {
    background-color: var(--msl-navy) !important;
    border-color: var(--msl-navy) !important;
}

/* Select2 Bootstrap 5 theme colour fixes */
.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--msl-border) !important;
    font-size: 0.875rem;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--msl-navy) !important;
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1) !important;
}

.select2-container--bootstrap-5 .select2-dropdown {
    border-color: var(--msl-border) !important;
    box-shadow: var(--shadow-md) !important;
    border-radius: var(--radius) !important;
    font-size: 0.875rem;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: rgba(0, 51, 102, 0.08) !important;
    color: var(--msl-navy) !important;
}

.select2-container--bootstrap-5 .select2-results__option--selected {
    background-color: var(--msl-navy) !important;
    color: #ffffff !important;
}

/* Flatpickr colour overrides */
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: var(--msl-navy) !important;
    border-color: var(--msl-navy) !important;
}

.flatpickr-day.today {
    border-color: var(--msl-amber) !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
