/* ============================================
   Adept Intranet &mdash; Custom Theme (Bootstrap 5 overrides)
   Adept brand: dark background, magenta accent, cyan highlight
   ============================================ */

html,
body {
    height: 100%;
    overflow: hidden;
    width: 100%;
    position: relative;
}

/* Prevent iOS Safari from auto-adjusting font sizes on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

:root {
    --ai-primary: #e91e8c;
    --ai-primary-rgb: 233, 30, 140;
    --ai-primary-dark: #c4177a;
    --ai-primary-light: rgba(233, 30, 140, 0.12);
    --ai-secondary: #00d4c8;
    --ai-secondary-light: rgba(0, 212, 200, 0.12);
    --ai-danger: #ff4757;
    --ai-warning: #ffa502;
    --ai-info: #00d4c8;
    --ai-dark: #1a1a1a;
    --ai-darker: #111111;
    --ai-body-bg: #0e0e0e;
    --ai-card-bg: #1e1e1e;
    --ai-sidebar-width: 240px;
    --ai-navbar-height: 56px;
    --ai-text: #e8e8e8;
    --ai-border: rgba(255, 255, 255, 0.08);
    /* Semi-transparent white for refined dark mode borders */
    --ai-radius: 8px;
    --ai-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --ai-transition: all 0.2s ease;
    --ai-text-muted: #abb5cf;
    /* Brightened for better dark mode visibility */

    /* Placeholder Color (Dark) */
    --ai-placeholder: rgba(255, 255, 255, 0.35);

    /* Filter Bar Defaults (Dark) */
    --ai-filter-bg: #252525;
    --ai-filter-bar-bg: linear-gradient(180deg, #26282c 0%, #1a1c1e 100%);
    --ai-filter-border-top: rgba(255, 255, 255, 0.03);
    --ai-filter-border: #3a3a3a;
    --ai-filter-input-bg: rgba(255, 255, 255, 0.05);
    --ai-filter-input-border: rgba(255, 255, 255, 0.1);
    --ai-filter-text: #ffffff;
    --ai-filter-icon: #777777;

    /* Form Input Variables (Dark) */
    --ai-input-bg: #252525;
    --ai-select-bg: #2d2d2d;

    /* Select icon (White) */
    --ai-select-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");

    /* Calendar Range Colors (Solid equivalents to prevent overlap artifacts) */
    --ai-calendar-range-text: #ffffff;

    /* Scrollbar Variables (Dark) */
    --ai-scrollbar-thumb: rgba(255, 255, 255, 0.35);
    --ai-scrollbar-hover: rgba(255, 255, 255, 0.55);
}

:root.light-mode {
    --ai-filter-bg: #ffffff;
    --ai-filter-bar-bg: linear-gradient(180deg, #f1f3f5 0%, #e2e8f0 100%);
    --ai-filter-border-top: rgba(0, 0, 0, 0.05);
    --ai-filter-border: #cbd5e1;
    --ai-filter-input-bg: rgba(255, 255, 255, 0.65);
    --ai-filter-input-border: rgba(0, 0, 0, 0.08);
    --ai-filter-text: #1f2937;
    --ai-filter-icon: #94a3b8;

    --ai-input-bg: #f9f9fb;
    --ai-select-bg: #ffffff;

    /* Placeholder Color (Light) */
    --ai-placeholder: rgba(0, 0, 0, 0.35);

    /* Select icon (Dark Gray) */
    --ai-select-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    --ai-text: #212529;
    /* Dark text for light mode */
    --ai-text-muted: #64748b;
    /* Standard slate for light mode readability */
    --ai-border: #dee2e6;
    /* Standard Bootstrap border for light mode */

    /* Calendar Range Colors (Light mode solid equivalents) */
    --ai-calendar-range-bg: #fce4f1;
    --ai-calendar-range-text: var(--ai-primary);

    /* Flatpickr Variables */
    --ai-calendar-bg: #ffffff;
    --ai-calendar-text: #212529;
    --ai-calendar-border: #dee2e6;
    --ai-calendar-hover: #f1f1f1;

    /* Scrollbar Variables (Light) */
    --ai-scrollbar-thumb: rgba(0, 0, 0, 0.25);
    --ai-scrollbar-hover: rgba(0, 0, 0, 0.45);

    --ai-switch-bg: #e2e8f0;
    --ai-card-bg: #ffffff;
    --ai-body-bg: #f8f9fa;
}

/* -- Form Switches (Dark Mode) ---------------------------------------------- */
.form-check-input {
    background-color: var(--ai-input-bg);
    border-color: var(--ai-border);
}

.form-switch .form-check-input {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba(255, 255, 255, 0.45)'/%3e%3c/svg%3e");
    background-color: #333;
    border-color: rgba(255, 255, 255, 0.1);
}

.form-check-input:checked {
    background-color: var(--ai-primary) !important;
    border-color: var(--ai-primary) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e") !important;
}

.form-check-input:focus {
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 0.25rem rgba(var(--ai-primary-rgb), 0.15);
}

:root.light-mode .form-switch .form-check-input {
    background-color: var(--ai-switch-bg);
    border-color: #cbd5e1;
}

:root {
    /* Flatpickr Variables (Dark) */
    --ai-calendar-bg: #2d2d2d;
    --ai-calendar-text: #ffffff;
    --ai-calendar-border: #3d3d3d;
    --ai-calendar-hover: #3a3a3a;
}

/* Custom Flatpickr Theme */
.flatpickr-calendar {
    background: var(--ai-calendar-bg) !important;
    border: 1px solid var(--ai-calendar-border) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
    color: var(--ai-calendar-text) !important;
    border-radius: 12px !important;
}

.flatpickr-day {
    color: var(--ai-calendar-text) !important;
    border-radius: 8px !important;
}

.flatpickr-day.today {
    border-color: var(--ai-primary) !important;
}

.flatpickr-day:hover {
    background: var(--ai-calendar-hover) !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--ai-primary) !important;
    border-color: var(--ai-primary) !important;
    color: #fff !important;
    box-shadow: none !important;
    z-index: 2;
}

.flatpickr-day.startRange {
    border-radius: 50% 0 0 50% !important;
    box-shadow: 5px 0 0 var(--ai-primary) !important;
}

.flatpickr-day.endRange {
    border-radius: 0 50% 50% 0 !important;
    box-shadow: -5px 0 0 var(--ai-primary) !important;
}

.flatpickr-day.startRange.endRange {
    border-radius: 50% !important;
    box-shadow: none !important;
}

.flatpickr-day.inRange {
    background: var(--ai-calendar-range-bg) !important;
    box-shadow: -5px 0 0 var(--ai-calendar-range-bg), 5px 0 0 var(--ai-calendar-range-bg) !important;
    color: var(--ai-calendar-range-text) !important;
    border-radius: 0 !important;
    border-color: transparent !important;
}

/* -- Date Dropdown System --------------------------------------------------- */
.ai-date-dropdown {
    position: relative;
    display: inline-block;
    width: 100%;
}

.ai-date-dropdown-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%), #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 50px !important;
    color: var(--ai-text);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0 16px;
    height: 38px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
}

.ai-date-dropdown-btn:hover {
    border-color: var(--ai-primary);
}

.ai-date-dropdown.open .ai-date-dropdown-btn {
    border-color: var(--ai-primary) !important;
    box-shadow: 0 0 0 1px var(--ai-primary), 0 0 0 3px var(--ai-primary-light) !important;
}

.ai-date-dropdown.ai-filter-active .ai-date-dropdown-btn {
    /* Subtle highlight instead of full pink outline if requested, but user said remove it */
    border-color: var(--ai-border) !important;
    box-shadow: none !important;
}

.ai-date-dropdown-btn .ai-select-chevron {
    transition: transform 0.2s ease;
    width: 12px;
    height: 12px;
    opacity: 0.5;
    margin-left: auto;
}

.ai-date-dropdown.open .ai-date-dropdown-btn .ai-select-chevron {
    transform: rotate(180deg);
}

.ai-date-dropdown-btn i {
    font-size: 1rem;
    color: var(--ai-text-muted);
}

.ai-date-dropdown-btn span {
    flex-grow: 1;
    text-align: left;
    margin-left: 8px;
}

/* -- Date Presets Panel -- */
.ai-date-presets-panel {
    background: var(--ai-calendar-bg);
    /* Match date dropdown color */
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    padding: 4px 0;
    display: none;
    animation: aiSelectFadeIn 0.15s ease;
    overflow: hidden;
}

.ai-date-dropdown.open .ai-date-presets-panel:not(.hidden) {
    display: block;
}

.ai-date-presets-panel.hidden {
    display: none !important;
}

.ai-date-preset-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ai-text);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.ai-date-preset-item:hover {
    background-color: rgba(233, 30, 140, 0.08);
    color: var(--ai-primary);
}

:root.light-mode .ai-date-preset-item {
    color: #334155;
}

:root.light-mode .ai-date-preset-item:hover {
    background-color: rgba(233, 30, 140, 0.06);
    color: var(--ai-primary);
}

/* -- Premium Bootstrap Dropdown skin -- */
.ai-dropdown {
    padding: 6px 0 !important;
    border: 1px solid var(--ai-border) !important;
    background: var(--ai-calendar-bg) !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    border-radius: 14px !important;
    z-index: 2000 !important;
    overflow: hidden !important;
}

.ai-dropdown .dropdown-item {
    padding: 8px 16px !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    color: var(--ai-text) !important;
    transition: all 0.15s ease !important;
}

.ai-dropdown .dropdown-item:hover {
    background-color: rgba(233, 30, 140, 0.05) !important;
    color: var(--ai-primary) !important;
}

.ai-dropdown .dropdown-item.active,
.ai-dropdown .dropdown-item:active {
    background-color: rgba(233, 30, 140, 0.12) !important;
    color: var(--ai-primary) !important;
}

:root.light-mode .ai-dropdown .dropdown-item {
    color: #475569 !important;
}

:root.light-mode .ai-dropdown .dropdown-item.active,
:root.light-mode .ai-dropdown .dropdown-item:active {
    background-color: rgba(233, 30, 140, 0.1) !important;
    color: var(--ai-primary) !important;
}

@keyframes ai-dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

:root.light-mode .ai-date-dropdown-btn {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #64748b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* Hidden input for Flatpickr trigger */
.ai-datepicker-hidden {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 0;
    border: none;
    opacity: 0;
    pointer-events: none;
}

/* Avatar Picker for Forms */
.ai-avatar-picker {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border: 3px solid var(--ai-border);
    transition: var(--ai-transition);
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-avatar-picker .ai-avatar {
    width: 100% !important;
    height: 100% !important;
}

.ai-avatar-picker:hover {
    border-color: var(--ai-primary);
    transform: scale(1.02);
}

.ai-avatar-picker-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(var(--ai-primary-rgb), 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    transform: translateY(10px);
}

.ai-avatar-picker:hover .ai-avatar-picker-overlay {
    opacity: 1;
    transform: translateY(0);
}

.ai-avatar-picker-overlay i {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.ai-avatar-picker-overlay span {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-avatar-upload-group {
    width: 120px;
}

.ai-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    text-align: center;
    user-select: none;
}


.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-weekday {
    color: var(--ai-calendar-text) !important;
    fill: var(--ai-calendar-text) !important;
}

/* Form inputs that are replaced by inline calendars should not be absolute 
   to ensure the parent container flow and layout are calculated correctly. */
input.ai-datepicker,
input.ai-date-range-inline,
input.ai-date-inline {
    display: block !important;
    height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    margin: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
}

.flatpickr-innerContainer {
    border-top: 1px solid var(--ai-calendar-border);
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: var(--ai-primary) !important;
}

/* Fix broken/stacked arrows */
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    display: flex !important;
    align-items: center;
    justify-content: center;
    height: 34px !important;
}

/* Ensure inline calendar fits container and looks premium */
.flatpickr-calendar.inline {
    position: relative !important;
    display: block !important;
    width: 256px !important;
    /* Standard compact width */
    margin: 8px 0 4px 0 !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08) !important;
    background: var(--ai-calendar-bg) !important;
    border: 1px solid var(--ai-border) !important;
    font-size: 14px !important;
}

/* Extra Compact Calendar for dense forms */
.ai-calendar-small .flatpickr-calendar.inline {
    width: 220px !important;
    font-size: 12px !important;
}

.ai-calendar-small .dayContainer {
    width: 220px !important;
    min-width: 220px !important;
    max-width: 220px !important;
}

.ai-calendar-small .flatpickr-day {
    max-width: 31px !important;
    height: 31px !important;
    line-height: 31px !important;
}

.ai-calendar-small .flatpickr-month {
    height: 28px !important;
}

/* Full-width fluid inline calendar for form column layouts */
.ai-calendar-form .flatpickr-calendar.inline {
    width: 100% !important;
    font-size: 13px !important;
}

.ai-calendar-form .flatpickr-rContainer {
    width: 100% !important;
}

.ai-calendar-form .flatpickr-days,
.ai-calendar-form .dayContainer {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
}

.ai-calendar-form .flatpickr-day {
    max-width: calc(100% / 7) !important;
    flex-basis: calc(100% / 7) !important;
    height: 34px !important;
    line-height: 34px !important;
}

.ai-calendar-form .flatpickr-month {
    height: 30px !important;
}

.flatpickr-days,
.flatpickr-days .dayContainer {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
}

.form-label+.flatpickr-calendar.inline {
    margin: 8px 0 16px 0 !important;
    /* Left aligned by default */
}





/* ---- Base ---- */
* {
    box-sizing: border-box;
}

::placeholder {
    color: var(--ai-placeholder) !important;
    opacity: 1 !important;
}

html,
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--ai-body-bg);
    color: var(--ai-text);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Remove tap highlight and add fast-tap on all interactive elements */
a,
button,
[role="button"],
input,
select,
textarea,
label,
.btn,
.nav-link,
.dropdown-item,
.dropdown-toggle {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Suppress all transitions during theme switch */
.no-transition,
.no-transition * {
    transition: none !important;
}

/* -- View Transitions &mdash; Circular Reveal for Theme Toggle ------------------- */
::view-transition-old(root),
::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
}

::view-transition-old(root) {
    z-index: 1;
}

::view-transition-new(root) {
    z-index: 9999;
    animation: vt-reveal 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* When going from dark → light, the OLD layer should be on top instead */
html.light-mode::view-transition-old(root) {
    z-index: 9999;
    animation: vt-reveal 0.7s cubic-bezier(0.4, 0, 0.2, 1) reverse forwards;
}

html.light-mode::view-transition-new(root) {
    z-index: 1;
    animation: none;
}

@keyframes vt-reveal {
    from {
        clip-path: circle(0% at var(--vt-x, 50%) var(--vt-y, 50%));
    }
    to {
        clip-path: circle(150% at var(--vt-x, 50%) var(--vt-y, 50%));
    }
}

.text-accent {
    color: var(--ai-primary) !important;
}

/* ---- Top Navbar ---- */
.ai-navbar {
    background: rgba(20, 20, 20, 0.85);
    /* Semi-transparent for blur, close to body bg */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    height: var(--ai-navbar-height);
    padding: 0 20px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    border: none;
    border-bottom: 1px solid var(--ai-border);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    z-index: 11000;
    left: 0;
    width: 100%;
}

:root.light-mode .ai-navbar {
    background: #ffffff !important;
}

.ai-brand {
    color: #fff !important;
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none !important;
}

.ai-brand img {
    height: 36px;
    width: auto;
}

.ai-brand .logo-light { display: none; }
.ai-brand .logo-dark { display: block; }

:root.light-mode .ai-brand .logo-light { display: block; }
:root.light-mode .ai-brand .logo-dark { display: none; }

.ai-brand i {
    color: var(--ai-primary);
    font-size: 1.4rem;
}

.ai-sidebar-toggle {
    color: #fff;
    font-size: 1.3rem;
    border: none;
    padding: 4px 8px;
}

.ai-search-outer {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 32px;
}

.ai-search-wrap {
    position: relative;
}

/* -- Clear Buttons &mdash; Unified System ------------------------------------------ */

/* 1. Header search: X button outside the pill */
.ai-btn-clear-outer {
    display: none;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    color: var(--ai-text-muted);
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
    flex-shrink: 0;
}

.ai-btn-clear-outer.visible {
    display: flex;
}

.ai-btn-clear-outer:hover {
    color: #fff;
    background: var(--ai-primary);
    border-color: var(--ai-primary);
    transform: rotate(90deg);
}

.ai-btn-clear-outer i {
    font-size: 0.72rem;
}

/* Light mode header clear button */
:root.light-mode .ai-btn-clear-outer {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.12);
    color: #888;
}

:root.light-mode .ai-btn-clear-outer:hover {
    background: var(--ai-primary);
    border-color: var(--ai-primary);
    color: #fff;
}

/* Light mode table clear &mdash; same flat style just darker text */
:root.light-mode .ai-btn-clear,
:root.light-mode .btn-clear {
    color: #bbb !important;
}

:root.light-mode .ai-btn-clear:hover,
:root.light-mode .btn-clear:hover {
    color: var(--ai-primary) !important;
}

/* 3. Clear Filters button &mdash; beside the Filters dropdown */
.ai-btn-clear-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--ai-border);
    color: var(--ai-text-muted);
    cursor: pointer;
    transition: all 0.18s ease;
    text-decoration: none;
    flex-shrink: 0;
}

/* 4. Reset Button &mdash; inside table header filter row */
.ai-btn-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--ai-input-bg);
    border: 1px solid var(--ai-border);
    border-radius: 50px;
    color: var(--ai-text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.ai-btn-reset:hover {
    background: var(--ai-primary-light);
    border-color: var(--ai-primary);
    color: var(--ai-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(233, 30, 140, 0.15);
}

:root.light-mode .ai-btn-reset {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #64748b;
}

:root.light-mode .ai-btn-reset:hover {
    background: var(--ai-primary-light);
    border-color: var(--ai-primary);
    color: var(--ai-primary);
}

.ai-btn-clear-filter:hover {
    background: rgba(233, 30, 140, 0.1);
    border-color: var(--ai-primary);
    color: var(--ai-primary);
    transform: rotate(90deg);
}

.ai-btn-clear-filter i {
    font-size: 0.8rem;
}

:root.light-mode .ai-btn-clear-filter {
    border-color: #dee2e6;
    color: #6c757d;
}

:root.light-mode .ai-btn-clear-filter:hover {
    background: rgba(233, 30, 140, 0.08);
    border-color: var(--ai-primary);
    color: var(--ai-primary);
}

.ai-search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ai-text-muted);
    font-size: 0.85rem;
}

.ai-search-wrap .form-control {
    background: #1a1a1a;
    border: 1px solid var(--ai-border);
    color: #fff;
    padding: 6px 12px 6px 34px;
    border-radius: 20px;
    width: 220px;
    font-size: 0.85rem;
    transition: width 0.2s ease, box-shadow 0.2s ease;
}

.ai-search-wrap .form-control:focus {
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 1px var(--ai-primary), 0 0 0 4px var(--ai-primary-light);
    width: 280px;
}

/* Standardized Clear Search Button */
.ai-btn-clear,
.btn-clear {
    position: absolute !important;
    right: 10px !important;
    /* Standardized offset */
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 10;
    padding: 0 4px !important;
    color: var(--ai-text-muted) !important;
    opacity: 0 !important;
    visibility: hidden;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    background: transparent !important;
    border: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}

.ai-btn-clear.visible,
.btn-clear.visible {
    opacity: 0.8 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.ai-btn-clear:hover,
.btn-clear:hover {
    opacity: 1 !important;
    color: var(--ai-primary) !important;
}

/* Ensure search inputs have enough padding for the clear button */
.ai-search-wrap .form-control,
.input-group .form-control[name="search"] {
    padding-right: 2.5rem !important;
    /* ~40px clearance */
}

/* Ensure parents are always relative for proper button containment */
.ai-search-wrap,
.ai-filter-form .input-group {
    position: relative !important;
}

.ai-btn-clear i,
.btn-clear i {
    font-size: 0.8rem;
    /* Slightly larger for visibility */
}


.ai-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 1.15rem;
    padding: 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    cursor: pointer;
}

.ai-nav-icon:hover {
    color: #fff;
    background: rgba(var(--ai-primary-rgb), 0.15);
    border-color: var(--ai-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--ai-primary-rgb), 0.2);
}

:root.light-mode .ai-nav-icon {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.15);
    /* Significantly darker for visibility */
    color: rgba(0, 0, 0, 0.6);
}

:root.light-mode .ai-nav-icon:hover {
    background: rgba(var(--ai-primary-rgb), 0.08);
    border-color: var(--ai-primary);
    color: var(--ai-primary);
    box-shadow: 0 4px 12px rgba(var(--ai-primary-rgb), 0.15);
}

.ai-nav-icon:active {
    transform: translateY(0);
}


/* ---- Action Buttons (Table Rows) ---- */
.btn-action-qb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(44, 160, 28, 0.3);
    background: transparent;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-action-qb:hover {
    background: rgba(44, 160, 28, 0.1);
    border-color: #2ca01c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 160, 28, 0.2);
}

.btn-action-edit,
.btn-action-delete,
.btn-action-restore,
.btn-action-archive {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.btn-action-edit:hover,
.btn-action-delete:hover,
.btn-action-restore:hover,
.btn-action-archive:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
}




.ai-badge-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 7px;
    height: 7px;
    background: var(--ai-primary);
    border-radius: 50%;
    border: 1.5px solid var(--ai-darker);
}

.ai-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff !important;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    padding: 6px 12px;
    border-radius: 10px;
    transition: var(--ai-transition);
}

.ai-user-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.ai-user-btn:focus {
    box-shadow: none !important;
}

.ai-user-btn::after {
    border-top-color: rgba(255, 255, 255, 0.4);
}

.ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ai-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.ai-dropdown {
    background: var(--ai-card-bg);
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 6px 0;
    outline: none !important;
}

:root.light-mode .ai-dropdown,
:root.light-mode .dropdown-menu,
:root.light-mode .ai-layout-panel {
    background: #ffffff !important;
    background-color: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.ai-dropdown .dropdown-item {
    font-size: 0.85rem;
    padding: 8px 16px;
    color: var(--ai-text);
    outline: none !important;
    box-shadow: none !important;
}

.ai-dropdown .dropdown-item:hover,
.ai-dropdown .dropdown-item:focus {
    background: var(--ai-primary-light);
    color: var(--ai-primary);
    outline: none !important;
}

.ai-dropdown .dropdown-divider {
    border-color: var(--ai-border);
}

.ai-dropdown .dropdown-header {
    color: var(--ai-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

/* Premium Icon Boxes */
.ai-icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ai-icon-box.size-32 {
    width: 32px;
    height: 32px;
}
.bg-primary-light { background: rgba(59, 130, 246, 0.15) !important; }
.bg-success-light { background: rgba(44, 160, 28, 0.15) !important; }
.text-primary { color: #3b82f6 !important; }
.text-success { color: #2ca01c !important; }

@keyframes ai-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.ai-qb-loading {
    animation: ai-spin 1s linear infinite !important;
    pointer-events: none;
    opacity: 0.7;
}

/* Fix row stacking for dropdowns */
tr:focus-within,
tr.ai-row-selected {
    z-index: 5 !important;
    position: relative;
}

/* position:relative without z-index avoids creating a stacking context,
   which would trap sticky column cells and let scrolled content paint over them */
tr:hover {
    position: relative;
}

tr:has(.show),
tr.ai-row-open {
    z-index: 2000 !important; /* Ensure it stays above other rows (100) and sidebar (1040) */
    position: relative;
}

.dropdown.show {
    z-index: 2100 !important;
}

.dropdown-menu.show {
    z-index: 2200 !important;
}

/* Improve QB button spacing and alignment */
.btn-action-qb {
    width: 32px !important;
    height: 32px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    background: transparent !important;
    border: 1px solid rgba(44, 160, 28, 0.25) !important;
    border-radius: 8px !important;
    transition: all 0.2s ease !important;
}

.btn-action-qb:hover, 
.btn-action-qb.show {
    background: rgba(44, 160, 28, 0.08) !important;
    border-color: #2ca01c !important;
}

.btn-action-qb img {
    margin: 0 !important;
    display: block;
}

.no-caret::after {
    display: none !important;
}

/* Global fix for blue select/focus state in nav/dropdowns */
.ai-nav-icon:focus,
.dropdown-item:focus,
.btn:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Brand-consistent active state (replaces Bootstrap blue) */
.dropdown-item:active,
.dropdown-item.active {
    background-color: var(--ai-primary-light) !important;
    color: var(--ai-primary) !important;
}

.hover-bg:hover {
    background-color: var(--ai-primary-light) !important;
}


/* ---- Sidebar ---- */
.ai-sidebar {
    position: fixed;
    top: var(--ai-navbar-height);
    left: 0;
    width: var(--ai-sidebar-width);
    height: calc(100vh - var(--ai-navbar-height));
    background: var(--ai-primary);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.3s ease;
    border-right: none;
    overflow: visible !important;
}

.ai-sidebar-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px; /* Symmetric padding for vertical centering */
    margin: 18px 10px 4px; /* Margin for pill-style effect */
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none !important;
    position: relative;
    user-select: none;
    border-radius: 10px; /* Rounded corners for the hover pill */
}

.ai-sidebar-group-label:hover {
    color: #fff !important;
    background: rgba(0, 0, 0, 0.15); /* Darker pill on hover */
    padding-left: 24px; /* Keep the subtle shift */
}

/* Section Divider: Refined to work with the pill layout */
.ai-sidebar-group-label:not(:first-of-type)::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 10px;
    right: 10px;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.ai-sidebar-group-label i {
    font-size: 0.75rem;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.8;
}

.ai-sidebar-group-label[aria-expanded="true"] i {
    transform: rotate(180deg);
}

:root.light-mode .ai-sidebar-group-label {
    color: rgba(255, 255, 255, 0.75); /* Keep it light on the pink background */
}

:root.light-mode .ai-sidebar-group-label:hover {
    color: #fff !important;
    background: rgba(0, 0, 0, 0.15);
}

.ai-sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    min-height: 0;
    /* Ensure flex child can scroll */
}

.ai-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    font-weight: 500;
    border-left: 4px solid transparent;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.ai-nav-icon-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.ai-sidebar .nav-link i {
    font-size: 1.05rem;
    color: #fff;
    transition: all 0.25s ease;
}

.ai-sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border-left-color: rgba(255, 255, 255, 0.5);
    padding-left: 24px;
}

.ai-sidebar .nav-link:hover .ai-nav-icon-badge {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.ai-sidebar .nav-link.active {
    color: #fff;
    background: rgba(0, 0, 0, 0.12);
    border-left-color: #fff;
    font-weight: 700;
}

.ai-sidebar .nav-link.active .ai-nav-icon-badge {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* -- Sidebar Collapsible Sub-Navigation -------------------------------- */
.ai-sidebar .ai-nav-toggle {
    position: relative;
}

.ai-sidebar .ai-nav-chevron {
    margin-left: auto;
    font-size: 0.7rem;
    opacity: 0.6;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-sidebar .ai-nav-toggle[aria-expanded="true"] .ai-nav-chevron {
    transform: rotate(180deg);
}

.ai-sidebar .ai-nav-children {
    padding: 4px 0 6px 0;
}

.ai-sidebar .ai-nav-child {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 20px 7px 52px !important;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.82rem;
    font-weight: 500;
    border-left: 4px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.ai-sidebar .ai-nav-child i {
    font-size: 0.85rem;
    opacity: 0.7;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.ai-sidebar .ai-nav-child:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
    padding-left: 56px !important;
}

.ai-sidebar .ai-nav-child:hover i {
    opacity: 1;
}

.ai-sidebar .ai-nav-child.active {
    color: #fff;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.1);
    border-left-color: rgba(255, 255, 255, 0.7);
}

.ai-sidebar .ai-nav-child.active i {
    opacity: 1;
}

/* Collapse animation */
.ai-sidebar .collapse {
    transition: none;
}

.ai-sidebar .collapsing {
    transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
}

/* ---- Content Wrapper & Sticky Footer ---- */
.ai-content-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--ai-navbar-height));
    margin-left: var(--ai-sidebar-width);
    margin-top: var(--ai-navbar-height);
    transition: margin-left 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--ai-scrollbar-thumb) transparent;
}

/* Premium Scrollbar for Content Wrapper */
.ai-content-wrapper::-webkit-scrollbar {
    width: 6px;
}

.ai-content-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.ai-content-wrapper::-webkit-scrollbar-thumb {
    background: var(--ai-scrollbar-thumb);
    border-radius: 10px;
}

.ai-content-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--ai-scrollbar-hover);
}

/* ---- Main Content ---- */
.ai-main {
    flex: 1 0 auto;
    padding: 28px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
}


.ai-main-fill {
    height: 100%;
}



/* Ensure the last element in the main content area has no bottom margin to maintain consistent spacing with the footer */
.ai-main>.ai-card:last-child,
.ai-main>form:last-child>.ai-card:last-child,
.ai-main>.row:last-child,
.ai-main>.row:last-child>.col-12>.ai-card:last-child,
#table-card,
#audit-log-card {
    margin-bottom: 0 !important;
}

/* ---- Footer ---- */
.ai-footer {
    flex-shrink: 0;
    padding: 16px 28px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    font-size: 0.8rem;
    color: var(--ai-text-muted);
    border-top: 1px solid var(--ai-border);
    background: var(--ai-dark);
}

/* ---- Page Header ---- */
.ai-page-header {
    margin-bottom: 28px;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(var(--ai-primary-rgb), 0.12);
    position: relative;
    animation: aiEntrance 0.4s ease-out both;
}

.ai-page-header.text-center::after {
    left: 50%;
    transform: translateX(-50%);
    width: clamp(96px, 14vw, 140px);
}

.ai-page-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: clamp(72px, 12vw, 120px);
    height: 3px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--ai-primary) 0%, rgba(var(--ai-primary-rgb), 0.35) 55%, transparent 100%);
}

@keyframes pageHeaderFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-page-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 2px;
    letter-spacing: -0.02em;
}

.ai-page-header p {
    color: var(--ai-text-muted);
    font-size: 0.88rem;
    margin-bottom: 0;
    letter-spacing: 0.01em;
}

/* ---- Cards ---- */
.ai-card {
    background: var(--ai-card-bg);
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius);
    box-shadow: none !important;
    margin-bottom: 24px;
    /* Default for dashboard/grid items */
    max-width: 100%;
    display: flex;
    flex-direction: column;
    animation: aiEntrance 0.4s ease-out both;
}

.ai-card-body {
    flex: 1;
    padding: 1.25rem;
    padding-bottom: 0;
    /* Allow dropdowns to bleed out */
    overflow: visible !important;
    display: flex;
    flex-direction: column;
}

.ai-card-body.p-0 {
    padding: 0 !important;
    overflow: visible !important;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-card-body.p-0.ai-table-loaded {
    opacity: 1;
}

/* Subtle spinner during initialization */
.ai-card-body.p-0:not(.ai-table-loaded)::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid var(--ai-primary-light);
    border-top-color: var(--ai-primary);
    border-radius: 50%;
    animation: ai-spin 0.8s linear infinite;
    z-index: 100;
}

@keyframes ai-spin {
    to { transform: rotate(360deg); }
}

/* Dashboard Card Animations */
.ai-dashboard-card {
    opacity: 0;
    transform: translateY(30px);
    animation: aiDashboardSlideUp 0.7s cubic-bezier(0.2, 1, 0.2, 1) forwards;
}

@keyframes aiDashboardSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dashboard Stat Card Animations */
.ai-stat-card-animate {
    opacity: 0;
    transform: translateX(-20px);
    animation: aiDashboardFadeInLeft 0.6s cubic-bezier(0.2, 1, 0.2, 1) forwards;
}

@keyframes aiDashboardFadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Container Fade-out Effect */
.ai-card-fade-bottom {
    position: relative;
}

.ai-card-fade-bottom>.ai-card-body {
    overflow: auto !important;
}

.ai-card-fade-bottom::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: linear-gradient(to bottom, rgba(30, 32, 40, 0) 0%, var(--ai-card-bg) 70%);
    pointer-events: none;
    z-index: 999;
    border-bottom-left-radius: var(--ai-radius);
    border-bottom-right-radius: var(--ai-radius);
}

:root.light-mode .ai-card-fade-bottom::after {
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, #ffffff 70%);
}

.ai-card-body>*:last-child {
    margin-bottom: 0;
}

/* Remove bottom margin for main content cards on module pages */
.ai-main>.ai-card:not(.mb-4):not(.mb-5) {
    margin-bottom: 0;
}

/* Table specific overrides */
.ai-table {
    margin-bottom: 0 !important;
    width: 100% !important;
    min-width: 100% !important;
    border-collapse: separate;
    border-spacing: 0;
}

/* Header cells – consistent, readable style */
.ai-table thead th {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
    white-space: nowrap;
    padding: 11px 14px;
    vertical-align: middle;
}

/* Body cells – comfortable density */
.ai-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
    font-size: 0.875rem;
    line-height: 1.45;
}

.table-responsive {
    margin-bottom: 0 !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    position: relative;
    /* Initialise the scroll-shadow custom property */
    --sticky-shadow-opacity: 0;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--ai-border) transparent;
}

/* ---- Admin Special Card ---- */
.ai-admin-card {
    background: var(--ai-card-bg);
    border: 1px solid var(--ai-primary);
    border-radius: var(--ai-radius);
    margin-bottom: 24px;
}

.ai-admin-card .ai-card-header h5 i {
    color: var(--ai-primary) !important;
}

.ai-admin-table-wrap {
    background: var(--ai-input-bg);
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius);
    overflow: hidden;
    padding-bottom: 12px;
}

.ai-admin-table th {
    color: var(--ai-primary) !important;
    border-bottom: 2px solid rgba(255, 255, 255, 0.10) !important;
    border-right: 1px solid var(--ai-border) !important;
    background: rgba(0, 0, 0, 0.15) !important;
    border-radius: 0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

:root.light-mode .ai-admin-table th {
    background-color: #f8f9fa !important;
    border-bottom: 2px solid rgba(0, 0, 0, 0.14) !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.09);
}

.ai-admin-table td {
    border-bottom: 1px solid var(--ai-border) !important;
    border-right: 1px solid var(--ai-border) !important;
}

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

/* Custom Checkbox for Permissions Matrix */
.ai-admin-table .form-check-input {
    width: 1.35em;
    height: 1.35em;
    cursor: pointer;
    border: 2px solid #444 !important;
    background-color: rgba(255, 255, 255, 0.03) !important;
    transition: all 0.2s ease;
}

.ai-admin-table .form-check-input:hover {
    border-color: var(--ai-primary) !important;
    background-color: rgba(233, 30, 140, 0.05) !important;
}

.ai-admin-table .form-check-input:checked {
    background-color: var(--ai-primary) !important;
    border-color: var(--ai-primary) !important;
}

.ai-admin-table .form-check-input:focus {
    box-shadow: 0 0 0 3px var(--ai-primary-light) !important;
}

/* Light Mode Overrides for Admin Card */
:root.light-mode .ai-admin-card {
    border-color: rgba(233, 30, 140, 0.4);
    box-shadow: 0 4px 20px rgba(233, 30, 140, 0.05);
}

:root.light-mode .text-accent {
    color: var(--ai-primary) !important;
}

:root.light-mode .ai-admin-table .form-check-input {
    border-color: #ccc !important;
    background-color: #fff !important;
}

:root.light-mode .ai-admin-table .form-check-input:hover {
    border-color: var(--ai-primary) !important;
}

:root.light-mode .ai-admin-table .form-check-input:checked {
    background-color: var(--ai-primary) !important;
    border-color: var(--ai-primary) !important;
}

/* ---- Wizard Steps ---- */
.ai-wizard-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 20px 24px 12px;
    margin-bottom: 8px;
    position: relative;
}

.ai-wizard-indicator .wizard-step-item {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
    position: relative;
}

.ai-wizard-indicator .wizard-step-item:last-child {
    flex: 0 0 auto;
}

.ai-wizard-indicator .wizard-step-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    border: 2px solid var(--ai-border);
    background: var(--ai-card-bg);
    color: var(--ai-text-muted);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.ai-wizard-indicator .wizard-step-item.active .wizard-step-circle {
    background: linear-gradient(135deg, var(--ai-primary), #ff6bb3);
    border-color: var(--ai-primary);
    color: #fff;
    box-shadow: 0 4px 16px rgba(233, 30, 140, 0.35);
    transform: scale(1.08);
}

.ai-wizard-indicator .wizard-step-item.completed .wizard-step-circle {
    background: var(--ai-secondary);
    border-color: var(--ai-secondary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 212, 200, 0.25);
}

.ai-wizard-indicator .wizard-step-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ai-text-muted);
    white-space: nowrap;
    transition: color 0.3s ease;
}

.ai-wizard-indicator .wizard-step-item.active .wizard-step-label {
    color: var(--ai-primary);
}

.ai-wizard-indicator .wizard-step-item.completed .wizard-step-label {
    color: var(--ai-secondary);
}

.ai-wizard-indicator .wizard-step-line {
    flex: 1;
    height: 2px;
    background: var(--ai-border);
    margin: 0 12px;
    position: relative;
    transition: background 0.4s ease;
}

.ai-wizard-indicator .wizard-step-item.completed .wizard-step-line {
    background: linear-gradient(90deg, var(--ai-secondary), var(--ai-primary));
}

/* Wizard Step Content Containers */
.ai-wizard-body {
    position: relative;
    overflow-x: hidden;
    overflow-y: visible;
    min-height: 200px;
}

.ai-wizard-step {
    width: 100%;
    padding: 0 4px;
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-wizard-step.step-hidden {
    display: none;
}

.ai-wizard-step.slide-out-left {
    animation: wizardSlideOutLeft 0.3s ease forwards;
}

.ai-wizard-step.slide-in-right {
    animation: wizardSlideInRight 0.35s ease forwards;
}

.ai-wizard-step.slide-out-right {
    animation: wizardSlideOutRight 0.3s ease forwards;
}

.ai-wizard-step.slide-in-left {
    animation: wizardSlideInLeft 0.35s ease forwards;
}

@keyframes wizardSlideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(-40px);
    }
}

@keyframes wizardSlideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes wizardSlideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

@keyframes wizardSlideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Wizard Action Bar */
.ai-wizard-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 8px;
    margin-top: 12px;
    border-top: 1px solid var(--ai-border);
    gap: 12px;
}

.ai-wizard-actions .btn {
    min-width: 130px;
}

/* Light Mode */
:root.light-mode .ai-wizard-indicator .wizard-step-circle {
    background: #fff;
    border-color: #ddd;
}

:root.light-mode .ai-wizard-indicator .wizard-step-item.active .wizard-step-circle {
    background: linear-gradient(135deg, var(--ai-primary), #ff6bb3);
    border-color: var(--ai-primary);
    color: #fff;
}

:root.light-mode .ai-wizard-indicator .wizard-step-item.completed .wizard-step-circle {
    background: var(--ai-secondary);
    border-color: var(--ai-secondary);
    color: #fff;
}

/* Role Management Modal Overrides */
.ai-role-modal .modal-content {
    background: var(--ai-card-bg);
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius);
}

.ai-role-modal .modal-content {
    border: none;
    overflow: hidden;
    position: relative;
    border-radius: 12px;
}

.ai-role-modal .modal-content::before { display: none; }

.ai-modal-icon-badge {
    width: 42px;
    height: 42px;
    background: rgba(233, 30, 140, 0.1);
    color: var(--ai-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

:root.light-mode .ai-modal-icon-badge {
    background: rgba(233, 30, 140, 0.05);
}

.ai-role-modal .modal-header {
    background: linear-gradient(135deg, #e91e63 0%, #c2185b 100%);
    border-bottom: none;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.ai-role-modal .modal-header .modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    font-family: 'Inter', sans-serif;
}

.ai-role-modal .modal-header .ai-modal-icon-badge {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1rem;
}

.ai-role-modal .modal-body {
    padding: 24px;
}

.ai-role-modal .modal-footer {
    border-top: 1px solid var(--ai-border);
    padding: 12px 24px;
}

.ai-role-modal .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    margin-left: auto;
}

:root.light-mode .ai-role-modal .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Role list inside modal */
.ai-role-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: 1px solid var(--ai-border);
    border-radius: 8px;
    margin-bottom: 8px;
    background: var(--ai-input-bg);
    transition: all 0.2s ease;
    cursor: pointer;
}

.ai-role-list-item:hover {
    border-color: var(--ai-primary);
    background: rgba(233, 30, 140, 0.04);
}

.ai-role-list-item.editing {
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 3px var(--ai-primary-light);
}

.ai-role-list-item.active {
    border-color: var(--ai-primary);
    background: rgba(233, 30, 140, 0.08);
    box-shadow: inset 3px 0 0 var(--ai-primary);
}

.ai-role-list-item.active .role-name {
    color: var(--ai-primary);
}

.ai-role-list-item .role-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ai-text);
}

.ai-role-list-item .role-desc {
    font-size: 0.75rem;
    color: var(--ai-text-muted);
    margin-top: 2px;
}

.ai-role-list-item .role-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Mobile Responsive */
@media (max-width: 576px) {
    .ai-wizard-indicator {
        padding: 16px 12px 8px;
    }

    .ai-wizard-indicator .wizard-step-circle {
        width: 32px;
        height: 32px;
        font-size: 0.7rem;
    }

    .ai-wizard-indicator .wizard-step-label {
        font-size: 0.6rem;
    }

    .ai-wizard-indicator .wizard-step-line {
        margin: 0 8px;
    }

    .ai-wizard-actions {
        flex-direction: column;
    }

    .ai-wizard-actions .btn {
        width: 100%;
    }
}

/* Minimize Button Styling */
.ai-card-minimize {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--ai-text-muted);
    transition: var(--ai-transition);
    border: none;
    background: transparent;
    cursor: pointer;
    margin-left: auto;
}

.ai-card-minimize:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--ai-primary);
}

:root.light-mode .ai-card-minimize:hover {
    background: rgba(0, 0, 0, 0.05);
}

.ai-card-header>.btn-ai-outline {
    margin-left: 10px;
}

/* Ensure header content has proper alignment */
.ai-card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--ai-border);
    display: flex;
    align-items: center;
    position: relative !important;
    z-index: 250 !important;
}

.ai-card-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--ai-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-card-header h5 {
    display: grid !important;
    grid-template-columns: auto 1fr;
    column-gap: 12px;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

.ai-card-header h5 i {
    grid-row: 1 / 3;
    margin-right: 0 !important;
    font-size: 1.1rem;
    color: var(--ai-text-muted);
    /* Softer icon color */
    opacity: 0.8;
}

.ai-record-count {
    grid-column: 2;
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--ai-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 1px;
}

/* ---- Password Visibility Toggle ---- */
.ai-password-group {
    position: relative;
}

.ai-password-group .ai-password-toggle {
    position: absolute !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 10;
    padding: 0 12px !important;
    border: none !important;
    background: transparent !important;
    color: var(--ai-text-muted);
    line-height: 1;
}

.ai-password-group .ai-password-toggle:hover {
    color: var(--ai-primary);
}

.ai-card-body.p-0 {
    padding: 0 !important;
}

/* ---- Browser Autofill Custom Styling ---- */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
textarea:-webkit-autofill:active,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus,
select:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--ai-input-bg) inset !important;
    -webkit-text-fill-color: var(--ai-text) !important;
    caret-color: var(--ai-text) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Firefox Autofill */
input:autofill,
textarea:autofill,
select:autofill {
    background-color: var(--ai-input-bg) !important;
    /* Standard property for Firefox */
    color: var(--ai-text) !important;
    box-shadow: 0 0 0 1000px var(--ai-input-bg) inset !important;
}

/* ---- Form controls (dark) ---- */
.ai-card .form-label {
    color: var(--ai-text-muted);
    white-space: nowrap;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 6px;
}

.ai-card .form-control {
    background: var(--ai-input-bg);
    border: 1px solid var(--ai-border);
    color: var(--ai-text);
    font-size: 0.85rem;
    border-radius: 50px;
    padding: 8px 16px;
    width: 100%;
    min-height: 38px;
    height: auto;
    transition: all 0.2s ease;
}

.ai-card .input-group .form-control {
    width: 1%;
    /* Allow flexbox to handle width in input-groups */
    flex: 1 1 auto;
}

.input-group-text {
    border: 1px solid var(--ai-border);
    transition: all 0.2s ease;
}

.ai-card .form-select {
    background: var(--ai-select-bg);
    /* Use variable for select bg */
    border: 1px solid #3a3a3a;
    color: var(--ai-text);
    font-size: 0.85rem;
    border-radius: 50px;
    padding: 8px 16px;
    width: 100%;
    min-height: 38px;
    height: auto;
    transition: all 0.2s ease;
}

.ai-card .form-control::placeholder {
    color: rgba(255, 255, 255, 0.55);
}

.ai-card .form-control:focus,
.ai-card .form-select:focus {
    background: #2a2a2a;
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 3px var(--ai-primary-light), 0 0 12px rgba(233, 30, 140, 0.1);
    color: #fff;
    outline: none;
}

textarea.form-control,
.ai-card textarea.form-control {
    height: auto !important;
    border-radius: 12px !important;
    padding: 12px !important;
    resize: none !important;
    overflow-y: auto !important;
}

.ai-card .row.g-3>[class*='col'] {
    min-width: 0;
}

.form-select,
.ai-card .form-select,
.form-select-sm {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-color: var(--ai-select-bg) !important;
    background-image: var(--ai-select-icon) !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 14px 12px !important;
    border: 1px solid #3a3a3a !important;
    color: var(--ai-text) !important;
    padding-right: 36px !important;
    position: relative;
    color-scheme: dark;
}

/* Custom dropdown arrow via wrapper (Retired - Handled by .form-select now) */
.form-select-wrap {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* No longer needed but kept for structural compatibility if used without .form-select */
.form-select-wrap::after {
    display: none;
}

input[type='date']::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

input[type='date'],
input[type='number'],
select {
    color-scheme: dark;
}


/* Standardized Table Filter Row (Above Table Headers) */
.ai-table-filters {
    display: flex;
    padding: 1.25rem 1.5rem;
    background: var(--ai-filter-bar-bg);
    border-top: 1px solid var(--ai-filter-border-top);
    border-bottom: 1px solid var(--ai-border);
    position: relative;
    z-index: 200;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ai-table-filters form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
}

.ai-table-filters .ms-auto {
    display: flex;
    align-items: center;
}

.ai-filter-row {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: flex-end !important;
    gap: 0.75rem 1.25rem !important;
}

.ai-filter-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 0 auto;
    min-width: 180px;
    max-width: 300px;
}

.ai-filter-col .ts-wrapper,
.ai-filter-col .ai-filter-input,
.ai-filter-col .ai-select,
.ai-table-filters .ai-select {
    width: 100% !important;
}

.ai-filter-col .ai-select .ai-select-btn,
.ai-table-filters .ai-select .ai-select-btn,
.ai-filter-col .ai-date-dropdown-btn {
    width: 100% !important;
    justify-content: space-between !important;
}

.ai-filter-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ai-text-muted);
    opacity: 0.85;
    margin-bottom: 2px;
}

label.ai-filter-label {
    padding-left: 16px;
}

.ai-filter-input.form-select,
.ai-filter-input.form-control {
    min-height: 38px !important;
    height: 38px !important;
    font-size: 0.8rem !important;
    padding: 0 36px 0 16px !important;
    border-radius: 50px !important;
    /* Pill shape to avoid square edges */
    background-color: var(--ai-filter-input-bg) !important;
    border: 1px solid var(--ai-filter-input-border) !important;
    box-shadow: none !important;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
    backdrop-filter: blur(4px);
}

.ai-filter-input:focus,
.ai-filter-input.ai-filter-active {
    border-color: var(--ai-primary) !important;
    background-color: var(--ai-filter-bg) !important;
    box-shadow: 0 0 0 1px var(--ai-primary), 0 0 0 3px var(--ai-primary-light) !important;
    z-index: 201;
}

.ai-filter-input.ai-filter-active {
    background-color: rgba(var(--ai-primary-rgb), 0.05) !important;
}

/* Ensure source selects are completely hidden */
.ai-table-filters select.ai-filter-input,
.ai-filter-row select.ai-filter-input {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    position: absolute !important;
}

.ai-filter-input.form-control {
    padding-right: 12px !important;
}

.btn-ai-clear {
    width: 38px;
    height: 38px;
    border-radius: 50px;
    border: 1px solid var(--ai-border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 100%), var(--ai-input-bg) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ai-text-muted);
    transition: all 0.2s ease;
    text-decoration: none !important;
    padding: 0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), inset 0 1px 0 0 rgba(255, 255, 255, 0.05) !important;
}

.btn-ai-clear:hover {
    background: rgba(255, 71, 87, 0.08) !important;
    color: var(--ai-danger) !important;
    border-color: var(--ai-danger) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.1);
}

.btn-ai-clear i {
    font-size: 1.2rem;
    margin: 0 !important;
    line-height: 1;
}

:root.light-mode .btn-ai-clear {
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05), inset 0 1px 0 #fff !important;
}

/* Specific Filter Bar Styles (Responsive & Theme Adaptive) */


.ai-filter-form .input-group {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    background: var(--ai-filter-bg);
    border: 1px solid var(--ai-filter-border);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-filter-form .input-group:focus-within {
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 3px var(--ai-primary-light);
}

.ai-filter-form .input-group-text {
    background: transparent !important;
    border: none !important;
    color: var(--ai-filter-icon) !important;
    padding-left: 10px;
}

.ai-filter-form .form-control {
    background: transparent !important;
    border: none !important;
    color: var(--ai-filter-text) !important;
    font-size: 0.8rem;
    padding: 7px 10px 7px 0;
    width: auto !important;
    flex: 1 1 auto !important;
    box-shadow: none !important;
}

.ai-filter-form .form-control:focus {
    box-shadow: none !important;
}

/* Standalone Selects (No Wrapper) in Filter Bars */
.ai-filter-form .form-select,
.ai-filter-form select:not(.flatpickr-monthDropdown-months) {
    width: auto !important;
    flex: 0 1 auto !important;
    background-color: var(--ai-filter-bg) !important;
    background-image: var(--ai-select-icon) !important;
    border: 1px solid var(--ai-filter-border) !important;
    color: var(--ai-filter-text) !important;
    border-radius: 6px;
    font-size: 0.8rem;
    padding: 6px 32px 6px 10px !important;
    min-height: 33px;
    /* Match input-group-sm height */
}

/* Fix for legacy form-select-wrap (Can be removed once all PHP is cleaned) */
.ai-filter-form .form-select-wrap {
    width: auto !important;
    flex: 0 1 auto !important;
}

.ai-filter-form .form-select-wrap select {
    width: 100% !important;
    background-color: var(--ai-filter-bg) !important;
    background-image: var(--ai-select-icon) !important;
    border: 1px solid var(--ai-filter-border) !important;
    color: var(--ai-filter-text) !important;
    border-radius: 6px;
    font-size: 0.8rem;
    padding: 7px 32px 7px 10px !important;
    min-height: 33px;
}

.ai-filter-form .form-select-wrap::after {
    color: var(--ai-filter-icon);
}

/* ---- Tables ---- */
/* ---- Tables & Overflow Aesthetics ---- */
.table-responsive {
    margin-bottom: 0 !important;
    position: relative;
    overflow-x: auto;
    /* Premium Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--ai-primary) rgba(0, 0, 0, 0.05);
}

/* Custom Scrollbar for Webkit */
.table-responsive::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #e2e8f0; /* Default subtle */
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
    transition: background 0.2s;
}

.table-responsive:hover::-webkit-scrollbar-thumb {
    background: var(--ai-primary);
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--ai-text-muted);
}

/* Scroll Edge Shadows (Ambient Indicators) 
   Uses background-attachment: local/scroll trick to show shadows only when content is hidden.
*/
.table-responsive {
    margin-bottom: 0 !important;
    position: relative;
    overflow-x: auto;
    overflow-y: visible !important;
    /* Premium Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--ai-border) transparent;
    background: transparent !important;
}

:root.light-mode .table-responsive {
    background: transparent !important;
}

.ai-table,
.table {
    margin-bottom: 0;
    font-size: 0.85rem;
    --bs-table-bg: transparent;
    --bs-table-color: var(--ai-text);
    --bs-table-border-color: var(--ai-border);
    --bs-table-accent-bg: transparent;
    --bs-table-striped-color: var(--ai-text);
    --bs-table-active-color: var(--ai-text);
    --bs-table-hover-color: var(--ai-text);
    --bs-table-accent-bg: transparent;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
    --bs-table-hover-color: var(--ai-text);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    color: var(--ai-text);
    background: transparent;
    border-collapse: separate;
    /* Required for sticky borders */
    border-spacing: 0;
}

.ai-table thead th {
    background: #282828;
    /* Solid color to prevent transparency on scroll */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ai-text-muted);
    border-top: 0 !important;
    border-bottom: 2px solid rgba(255, 255, 255, 0.10);
    border-right: 1px solid var(--ai-border);
    padding: 12px 32px 12px 16px;
    white-space: nowrap;
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

:root.light-mode .ai-table thead th {
    background: #f1f3f5 !important;
    background-color: #f1f3f5 !important;
    --bs-table-bg: #f1f3f5 !important;
    color: #334155 !important;
    /* Slightly darker text for better legibility */
    border-bottom: 2px solid rgba(0, 0, 0, 0.14) !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.09);
}

.ai-col-actions,
.ai-table thead th.ai-col-actions,
.ai-table tbody td.ai-col-actions {
    width: 1% !important;
    white-space: nowrap !important;
    padding: 0 !important;
    min-width: 0 !important;
    text-align: left !important;
}

.ai-col-actions > div,
.ai-col-actions .d-flex {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: fit-content !important;
    padding: 12px 16px !important;
}

.ai-col-actions .form-check-input {
    margin: 0 !important;
}

/* Specific Grey Header for Application Change Log (Audit Log) */
:root.light-mode .ai-table-audit thead th {
    background: #f1f3f5 !important;
    background-color: #f1f3f5 !important;
    --bs-table-bg: #f1f3f5 !important;
}

/* Sticky First Column - position & background (shadow handled in resizing section) */
.ai-table th.ai-col-sticky,
.ai-table td.ai-col-sticky,
.ai-table th.ai-col-company,
.ai-table td.ai-col-company {
    position: -webkit-sticky !important;
    position: sticky !important;
    left: 0 !important;
    z-index: 150 !important;
    background-color: var(--ai-card-bg) !important;
    border-right: 1px solid var(--ai-border) !important;
}

.ai-table thead th.ai-col-sticky,
.ai-table thead th.ai-col-company,
:root.light-mode .ai-table thead th.ai-col-sticky,
:root.light-mode .ai-table thead th.ai-col-company {
    z-index: 160 !important;
    background: var(--ai-primary) !important;
    color: #ffffff !important;
    font-weight: 800;
}

/* Light Mode Sticky Solids */
:root.light-mode .ai-table td.ai-col-sticky,
:root.light-mode .ai-table td.ai-col-company {
    background-color: #ffffff !important;
}

/* Active Edit Row Support - Highlight Entire Row */
.ai-table tbody tr.table-active td {
    background-color: #2d2d2d !important;
}

.ai-table tbody tr.table-active td.ai-col-sticky,
.ai-table tbody tr.table-active td.ai-col-company {
    background-color: #2d2d2d !important;
    z-index: 151 !important;
}

:root.light-mode .ai-table tbody tr.table-active td {
    background-color: #e9ecef !important;
}

:root.light-mode .ai-table tbody tr.table-active td.ai-col-sticky,
:root.light-mode .ai-table tbody tr.table-active td.ai-col-company {
    background-color: #e9ecef !important;
    z-index: 151 !important;
}

/* Bulk Selection Row Highlight &mdash; Sticky Column Override */
.ai-table tbody tr.ai-row-selected td.ai-col-sticky,
.ai-table tbody tr.ai-row-selected td.ai-col-company {
    background-color: #2d2028 !important;
    z-index: 151 !important;
}

:root.light-mode .ai-table tbody tr.ai-row-selected td.ai-col-sticky,
:root.light-mode .ai-table tbody tr.ai-row-selected td.ai-col-company {
    background-color: #fdf2f7 !important;
    z-index: 151 !important;
}



.ai-table th {
    position: relative;
}

.ai-table td {
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-table tr.ai-filter-row th {
    overflow: visible;
    /* Filters need to show dropdowns */
}

.ai-table .ai-filter-input,
.ai-table .ai-select,
.ai-table .ai-date-filter-wrap {
    max-width: 100% !important;
    min-width: 0 !important;
}

/* Sticky Footer (Connects the sticky column from bottom) */
.ai-table tfoot {
    position: -webkit-sticky;
    position: sticky;
    bottom: 0;
    z-index: 25;
}

.ai-table tfoot td {
    background: var(--ai-card-bg);
    border-top: 2px solid var(--ai-border);
    padding: 12px 16px;
    font-weight: 600;
    color: var(--ai-text-muted);
    border-bottom: none;
}

.ai-table tfoot td.ai-col-sticky,
.ai-table tfoot td.ai-col-company {
    position: -webkit-sticky !important;
    position: sticky !important;
    left: 0 !important;
    z-index: 30 !important;
    background: var(--ai-card-bg) !important;
    border-top: 2px solid var(--ai-primary) !important;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.25);
}

:root.light-mode .ai-table tfoot td {
    background: #ffffff !important;
}

.ai-table-status-bar {
    background: rgba(var(--ai-primary-rgb), 0.03);
    border-top: 1px solid var(--ai-border);
    border-bottom-left-radius: var(--ai-card-border-radius);
    border-bottom-right-radius: var(--ai-card-border-radius);
    margin-top: -1px;
    /* Overlap table border */
    position: relative !important;
    z-index: 5 !important;
}

.ai-pagination-sticky-wrapper nav {
    padding-bottom: 0 !important;
}

.ai-collapse-btn {
    background: transparent;
    border: none;
    color: inherit;
    padding: 0;
    margin-left: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    transition: transform 0.3s ease;
}

.ai-table th.ai-col-company .ai-th-company-inner,
.ai-th-sticky-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    /* min-width: 0 is required so the flex container can shrink below its intrinsic
       content size. Without this, flex children force the <th> wider than its
       max-width, breaking the saved column width. */
    min-width: 0;
    overflow: hidden;
}

/* Allow each flex child to shrink independently so the container never
   forces the column wider than its set width. */
.ai-table th.ai-col-company .ai-th-company-inner > *,
.ai-th-sticky-inner > * {
    min-width: 0;
    flex-shrink: 1;
}

/* Sticky thead: min-width:0 + overflow:hidden on .ai-th-sticky-inner was clipping the
   A–Z / Z–A pill next to “Client” when the column width is tight. */
.ai-table thead th.ai-col-sticky .ai-th-sticky-inner > *:first-child {
    flex-shrink: 0;
    min-width: min-content;
}
.ai-table thead th.ai-col-sticky:has(.ai-sort-label:not(:empty)),
.ai-table thead th.ai-col-company:has(.ai-sort-label:not(:empty)),
.ai-table thead th.ai-col-client:has(.ai-sort-label:not(:empty)) {
    overflow: visible;
}
.ai-table thead th.ai-col-sticky .ai-th-sticky-inner:has(.ai-sort-label:not(:empty)) {
    overflow: visible;
}
/* Fallback for browsers without :has() support */
.ai-table thead th.ai-col-sticky.ai-sort-asc,
.ai-table thead th.ai-col-sticky.ai-sort-desc,
.ai-table thead th.ai-col-sticky.ai-sort-active,
.ai-table thead th.ai-col-company.ai-sort-asc,
.ai-table thead th.ai-col-company.ai-sort-desc,
.ai-table thead th.ai-col-company.ai-sort-active {
    overflow: visible;
}
.ai-table thead th.ai-col-sticky.ai-sort-asc .ai-th-sticky-inner,
.ai-table thead th.ai-col-sticky.ai-sort-desc .ai-th-sticky-inner,
.ai-table thead th.ai-col-sticky.ai-sort-active .ai-th-sticky-inner,
.ai-table thead th.ai-col-company.ai-sort-asc .ai-th-sticky-inner,
.ai-table thead th.ai-col-company.ai-sort-desc .ai-th-sticky-inner,
.ai-table thead th.ai-col-company.ai-sort-active .ai-th-sticky-inner {
    overflow: visible;
}

/* Ambient shadow divider for sticky column */
.ai-table .ai-col-sticky::after,
.ai-table .ai-col-company::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 6px;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.2), transparent);
    z-index: 21;
    pointer-events: none;
}

:root.light-mode .ai-table .ai-col-sticky::after,
:root.light-mode .ai-table .ai-col-company::after {
    background: linear-gradient(to left, rgba(0, 0, 0, 0.05), transparent);
}

.ai-table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--ai-border);
    border-right: 1px solid var(--ai-border);
    color: var(--ai-text);
    white-space: nowrap;
    transition: background-color 0.12s ease;
}

/* Row hover — solid opaque colour applied identically to every cell.
   Using one fixed colour (instead of rgba over a possibly-transparent base)
   guarantees the sticky column matches the rest of the row pixel-for-pixel. */

/* --- Dark mode hover ---------------------------------------------------- */
/* #2b2b2b = card-bg #1e1e1e blended with 6% white (precomputed) */
.ai-table tbody tr:hover:not(.ai-row-selected) td,
.ai-table tbody tr:hover:not(.ai-row-selected) td.ai-col-sticky,
.ai-table tbody tr:hover:not(.ai-row-selected) td.ai-col-company {
    background-color: #2b2b2b !important;
    background-image: none !important;
    z-index: 151 !important;
}

/* Selected-row hover (slightly richer pink) */
.ai-table tbody tr.ai-row-selected:hover td,
.ai-table tbody tr.ai-row-selected:hover td.ai-col-sticky,
.ai-table tbody tr.ai-row-selected:hover td.ai-col-company {
    background-color: #3a2530 !important;
    background-image: none !important;
    z-index: 151 !important;
}

/* --- Light mode hover --------------------------------------------------- */
/* #f1f3f5 = pure white blended with ~5% neutral grey (precomputed) */
:root.light-mode .ai-table tbody tr:hover:not(.ai-row-selected) td,
:root.light-mode .ai-table tbody tr:hover:not(.ai-row-selected) td.ai-col-sticky,
:root.light-mode .ai-table tbody tr:hover:not(.ai-row-selected) td.ai-col-company {
    background-color: #f1f3f5 !important;
    background-image: none !important;
    z-index: 151 !important;
}

:root.light-mode .ai-table tbody tr.ai-row-selected:hover td,
:root.light-mode .ai-table tbody tr.ai-row-selected:hover td.ai-col-sticky,
:root.light-mode .ai-table tbody tr.ai-row-selected:hover td.ai-col-company {
    background-color: #fbe6f1 !important;
    background-image: none !important;
    z-index: 151 !important;
}

.ai-table tbody tr:last-child td {
    border-bottom: none;
}

/* Column Visibility Toggling (Instant JS Support) */
.ai-col-hidden {
    display: none !important;
}


/* ---- Dashboard Card Filters ---- */

/* Pill Toggle Group (Chart Range, Date Range) */
.dash-filter-pills {
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 100%), var(--ai-input-bg);
    border: 1px solid var(--ai-border);
    border-radius: 50px;
    padding: 3px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18), inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
}

.dash-pill {
    padding: 4px 14px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--ai-text-muted);
    background: transparent;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.dash-pill:hover {
    color: var(--ai-text);
    background: rgba(255, 255, 255, 0.06);
}

.dash-pill.active {
    color: #fff;
    background: var(--ai-primary);
    box-shadow: 0 2px 8px rgba(233, 30, 140, 0.3);
}

:root.light-mode .ai-select-btn {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #64748b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

:root.light-mode .dash-pill:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #334155;
}

:root.light-mode .dash-pill.active {
    background: var(--ai-primary);
    color: #fff;
}

/* Compact Select Dropdown (Card Header Filters) */
.dash-filter-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%), #1e1e1e;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23999' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 10px 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 50px !important;
    color: var(--ai-text);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0 34px 0 16px;
    height: 38px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 36px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
}

.dash-filter-select:hover {
    border-color: var(--ai-primary);
    background-color: rgba(233, 30, 140, 0.04);
}

.dash-filter-select:focus {
    outline: none;
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.12);
}

.dash-filter-select option {
    background: var(--ai-card-bg);
    color: var(--ai-text);
}

:root.light-mode .dash-filter-select {
    background: #ffffff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23555' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px 10px;
    border-color: #cbd5e1;
    color: #334155;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

:root.light-mode .dash-filter-select:hover {
    background-color: rgba(233, 30, 140, 0.03);
}

:root.light-mode .dash-filter-select option {
    background: #fff;
    color: #212529;
}

/* Dashboard card header: compact TomSelect sizing */
.dash-header-filters .ts-wrapper {
    flex: 1 1 auto;
    min-width: 90px;
    max-width: 160px;
    height: auto !important;
    overflow: visible !important;
}
.dash-header-filters .ts-wrapper.single .ts-control {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 0 34px 0 16px !important;
    line-height: 36px !important;
    border-radius: 50px !important;
}
.dash-header-filters .ts-wrapper.single .ts-control > input,
.dash-header-filters .ts-wrapper.single .ts-control .item {
    font-size: 0.72rem !important;
    font-weight: 600 !important;
}
:root.light-mode .dash-header-filters .ts-wrapper.single .ts-control {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #64748b !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05), inset 0 1px 2px rgba(0, 0, 0, 0.02) !important;
}

/* Fix TomSelect dropdowns for dash-filter-select to allow text wrapping and correct dimensions */
.dash-header-filters .ts-dropdown {
    padding: 0 !important;
    border-radius: 6px !important; /* Reset the 50px pill shape */
    width: max-content !important;
    min-width: 100% !important;
    max-width: 320px !important;
    white-space: normal !important;
    text-overflow: clip !important;
    overflow: hidden !important; /* Keep borders clean */
    right: 0 !important;
    left: auto !important;
}
.dash-header-filters .ts-dropdown .option {
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.4 !important;
    padding: 8px 12px !important;
}

/* Header filters wrapper — always wraps, never overflows card */
.dash-clear-filters {
    appearance: none;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(220, 53, 69, 0.2);
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(220, 53, 69, 0.1) 0%, rgba(220, 53, 69, 0.05) 100%);
    color: #dc3545;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    font-size: 0.75rem;
}
.dash-clear-filters:hover {
    background: linear-gradient(180deg, #dc3545 0%, #b02a37 100%);
    border-color: #dc3545;
    color: #fff;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(-2px) scale(1.1);
}
.dash-clear-filters:active {
    transform: translateY(0) scale(0.95);
}
:root.light-mode .dash-clear-filters {
    background: linear-gradient(180deg, rgba(220, 53, 69, 0.08) 0%, rgba(220, 53, 69, 0.04) 100%);
}
:root.light-mode .dash-clear-filters:hover {
    background: linear-gradient(180deg, #dc3545 0%, #b02a37 100%);
    color: #fff;
}

/* Header filters wrapper — always wraps, never overflows card */
.dash-header-filters {
    flex-shrink: 1;
    min-width: 0;
    flex-wrap: wrap;
    width: 100%;
}


/* Responsive: stack filters on small viewports */
@media (max-width: 576px) {
    .dash-filter-pills {
        order: 10;
    }

    .dash-filter-select {
        max-width: 120px;
        font-size: 0.68rem;
        padding: 4px 22px 4px 8px;
    }

    .dash-pill {
        padding: 3px 10px;
        font-size: 0.65rem;
    }

    .dash-header-filters {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ---- Dashboard Lists & Status ---- */
.project-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px currentColor;
}

.bg-success .project-dot,
.bg-success.project-dot,
.bg-active .project-dot {
    background-color: #10b981;
    color: rgba(16, 185, 129, 0.6);
}

.bg-warning .project-dot,
.bg-warning.project-dot {
    background-color: #f59e0b;
    color: rgba(245, 158, 11, 0.6);
}

.bg-primary .project-dot,
.bg-primary.project-dot,
.bg-info .project-dot {
    background-color: #3b82f6;
    color: rgba(59, 130, 246, 0.6);
}

.ai-list-item {
    transition: var(--ai-transition);
}

.ai-list-item:hover {
    background: rgba(255, 255, 255, 0.03) !important;
}

:root.light-mode .ai-list-item:hover {
    background: rgba(0, 0, 0, 0.02) !important;
}

.renewal-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ---- Badges ---- */
.ai-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ai-badge.active {
    background: rgba(16, 185, 129, 0.22);
    color: #10b981;
}

.ai-badge.inactive {
    background: rgba(255, 71, 87, 0.18);
    color: var(--ai-danger);
}

.ai-badge.warning {
    background: rgba(255, 165, 2, 0.18);
    color: var(--ai-warning);
}

.ai-badge.info {
    background: rgba(99, 102, 241, 0.22);
    color: #818cf8;
}

.ai-badge.danger {
    background: rgba(255, 71, 87, 0.18);
    color: var(--ai-danger);
}

.ai-badge.success {
    background: rgba(16, 185, 129, 0.22);
    color: #10b981;
}

.ai-badge.archive {
    background: rgba(255, 165, 2, 0.18);
    color: var(--ai-warning);
}

/* ---- Buttons ---- */
.btn-ai {
    background: linear-gradient(135deg, #ff2e9b 0%, #d41474 100%);
    color: #fff;
    border: none;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 8px 24px;
    border-radius: 50px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-ai:focus,
.btn-ai.show {
    background: linear-gradient(135deg, #ff2e9b 0%, #d41474 100%);
    color: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.3);
}

.btn-ai:hover {
    background: linear-gradient(135deg, #ff4bad 0%, #e61981 100%);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: none;
}

.btn-ai:active {
    transform: translateY(0) !important;
    box-shadow: none !important;
}

.btn-ai-outline {
    background: #ffffff;
    color: #2d3748;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 8px 24px;
    border-radius: 50px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

:root:not(.light-mode) .btn-ai-outline {
    background: rgba(255, 255, 255, 0.05);
    color: #e8e8e8;
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-sm.btn-ai,
.btn-sm.btn-ai-outline {
    padding: 4px 14px;
    font-size: 0.76rem;
}

.btn-ai-outline:focus,
.btn-ai-outline.show {
    background: #ffffff;
    color: #2d3748;
    border-color: #cbd5e0;
}

:root:not(.light-mode) .btn-ai-outline:focus,
:root:not(.light-mode) .btn-ai-outline.show {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.btn-ai-outline:hover,
.btn-ai-outline:active {
    background: #f8fafc;
    color: #1a202c;
    border-color: #cbd5e0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

:root:not(.light-mode) .btn-ai-outline:hover,
:root:not(.light-mode) .btn-ai-outline:active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
}

/* ---- QuickBooks Button ---- */
.btn-qb {
    background: #2ca01c;
    color: #fff;
    border: 1px solid #2ca01c;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 6px;
    transition: var(--ai-transition);
}

.btn-qb:focus,
.btn-qb.show {
    background: #2ca01c;
    color: #fff;
}

.btn-qb:hover {
    background: #238316;
    border-color: #238316;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 160, 28, 0.3);
}

.btn-qb:active {
    background: #1e7012 !important;
    border-color: #1e7012 !important;
    color: #fff !important;
    transform: translateY(0) !important;
    box-shadow: none !important;
}

/* ---- Table Action Buttons ---- */
.btn-action-edit,
.btn-action-delete,
.btn-action-restore {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 0.85rem;
    border-radius: 6px;
    background: transparent;
    transition: var(--ai-transition);
}

.btn-action-edit {
    border: 1px solid var(--ai-secondary);
    color: var(--ai-secondary);
}

.btn-action-edit:hover {
    background: var(--ai-secondary);
    color: #fff;
}

.btn-action-delete {
    border: 1px solid var(--ai-warning);
    color: var(--ai-warning);
}

.btn-action-delete:hover {
    background: var(--ai-warning);
    color: #fff;
}

/* Permanent delete (red) override &mdash; only for archived records */
.btn-action-delete.ai-action-danger {
    border-color: var(--ai-danger);
    color: var(--ai-danger);
}

.btn-action-delete.ai-action-danger:hover {
    background: var(--ai-danger);
    color: #fff;
}

.btn-action-restore {
    border: 1px solid var(--ai-success, #10b981);
    color: var(--ai-success, #10b981);
}

.btn-action-restore:hover {
    background: var(--ai-success, #10b981);
    color: #fff;
}

/* Archive toggle button in table headers */
.btn-archive-toggle {
    padding: 5px 10px;
    font-size: 0.78rem;
    border-radius: 6px;
    transition: var(--ai-transition);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.btn-archive-toggle.active {
    background: #52525b !important;
    border-color: #52525b !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(82, 82, 91, 0.3);
}

.btn-archive-toggle:not(.active) {
    background: transparent;
    border: 1px solid var(--ai-border);
    color: var(--ai-text-muted);
}

.btn-archive-toggle:not(.active):hover {
    border-color: #52525b;
    color: #52525b;
    background: rgba(82, 82, 91, 0.1);
}

:root.light-mode .btn-archive-toggle.active {
    background: #94a3b8 !important;
    border-color: #94a3b8 !important;
    box-shadow: 0 2px 8px rgba(148, 163, 184, 0.3);
}

:root.light-mode .btn-archive-toggle:not(.active):hover {
    border-color: #94a3b8;
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.1);
}

/* ---- Premium Alerts ---- */
.ai-alert {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 24px;
    border: 1px solid transparent;
    border-left-width: 4px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: ai-alert-entrance 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ai-alert i {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.ai-alert-danger {
    background: rgba(255, 71, 87, 0.1);
    border-color: rgba(255, 71, 87, 0.2);
    border-left-color: var(--ai-danger);
    color: #ff6b81;
    /* Brighter red for visibility */
}

:root.light-mode .ai-alert-danger {
    background: #fff5f5;
    border-color: #fee2e2;
    border-left-color: var(--ai-danger);
    color: #dc2626;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.05);
}

.ai-alert-info {
    background: rgba(0, 212, 200, 0.1);
    border-color: rgba(0, 212, 200, 0.2);
    border-left-color: var(--ai-secondary);
    color: var(--ai-secondary);
}

:root.light-mode .ai-alert-info {
    background: #f0fdfa;
    border-color: #ccfbf1;
    border-left-color: var(--ai-secondary);
    color: #0d9488;
}

@keyframes ai-alert-entrance {
    0% {
        opacity: 0;
        transform: translateY(-8px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Optional: Add a subtle shake for danger specifically */
.ai-alert-danger {
    animation: ai-alert-entrance 0.4s ease-out forwards, ai-shake 0.4s ease-in-out 0.1s;
}

@keyframes ai-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    50% {
        transform: translateX(4px);
    }

    75% {
        transform: translateX(-2px);
    }
}

/* ---- Login Page Upgrade (Premium Glassmorphism) ---- */
.ai-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #050505;
    position: relative;
    overflow-y: auto; /* Allow vertical scroll if content overflows on small screens */
    overflow-x: hidden;
    padding: 18px;
}

/* Multi-colored Animated Orb Background */
.login-bg-orbs {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
}

.login-bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.18;
    z-index: 1;
}

.login-bg-orb-1 {
    width: 600px;
    height: 600px;
    background: var(--ai-primary);
    top: -200px;
    left: -100px;
    animation: drift-orb-1 25s infinite alternate ease-in-out;
}

.login-bg-orb-2 {
    width: 500px;
    height: 500px;
    background: var(--ai-secondary);
    bottom: -150px;
    right: -100px;
    animation: drift-orb-2 30s infinite alternate ease-in-out;
}

.login-bg-orb-3 {
    width: 400px;
    height: 400px;
    background: #a855f7;
    top: 30%;
    right: 10%;
    opacity: 0.1;
    animation: drift-orb-3 20s infinite alternate ease-in-out;
}

.login-bg-orb-4 {
    width: 300px;
    height: 300px;
    background: var(--ai-primary);
    bottom: 10%;
    left: 10%;
    opacity: 0.08;
}

@media (prefers-reduced-motion: reduce) {

    .login-bg-orb-1,
    .login-bg-orb-2,
    .login-bg-orb-3 {
        animation: none !important;
    }

    .ai-login-card {
        animation: none !important;
    }
}

@keyframes drift-orb-1 {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(120px, 80px) scale(1.1);
    }
}

@keyframes drift-orb-2 {
    from {
        transform: translate(0, 0) scale(1.1);
    }

    to {
        transform: translate(-100px, -60px) scale(0.9);
    }
}

@keyframes drift-orb-3 {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(-40px, 80px);
    }
}

.ai-login-card {
    background: rgba(40, 40, 40, 0.4);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow:
        0 30px 60px -12px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    padding: clamp(22px, 3.5vw, 44px) clamp(18px, 4vw, 46px);
    width: 100%;
    max-width: 656px;

    position: relative;
    z-index: 10;
    animation: card-entrance 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes card-entrance {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ai-login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--ai-primary), transparent);
    border-radius: 20px 20px 0 0;
    opacity: 0.8;
}

.ai-login-card .ai-brand {
    justify-content: center;
    margin-bottom: 0;
}

.ai-login-card .ai-brand img {
    height: 62px;
    width: auto;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.25));
}

.ai-login-card .form-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ai-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    display: block;
    opacity: 0.8;
}

.ai-login-card .form-control {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    padding: 10px 14px;
    font-size: 0.95rem;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.ai-login-card .form-control:focus {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: var(--ai-primary) !important;
    box-shadow: 0 0 0 4px rgba(233, 30, 140, 0.2), 0 0 20px rgba(233, 30, 140, 0.15) !important;
    outline: none;
}

.ai-login-card .ai-password-group {
    position: relative;
}

.ai-login-card .ai-password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    color: rgba(255, 255, 255, 0.4);
    border: none;
    background: transparent;
    padding: 8px;
    transition: color 0.2s ease;
}

.ai-login-card .ai-password-toggle:hover {
    color: var(--ai-primary);
}

@media (min-width: 576px) {
    .ai-login-fields-row {
        --bs-gutter-x: 1.35rem;
    }

    .ai-login-card .ai-brand img {
        height: 74px;
    }
}

.ai-login-card .ai-login-fields-row .form-control,
.ai-login-card .ai-login-fields-row .ai-password-input {
    min-height: 44px;
}

.ai-login-card .btn-ai {
    margin-top: 8px;
    font-size: 1rem;
    font-weight: 700;
    padding: 14px;
    border-radius: 12px;
    background: var(--ai-primary);
    box-shadow: 0 4px 15px rgba(233, 30, 140, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ai-login-card .btn-ai:hover {
    transform: translateY(-2px);
    background: var(--ai-primary-dark);
    box-shadow: 0 8px 25px rgba(233, 30, 140, 0.45);
}

/* Theme Switching Support */
:root.light-mode .ai-login-card {
    background: rgba(255, 255, 255, 0.75);
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.1);
}

:root.light-mode .ai-login-card .form-control {
    background: rgba(0, 0, 0, 0.03) !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
    color: #1a1a1a !important;
}

:root.light-mode .ai-login-card .form-label {
    color: #475569;
}

:root.light-mode .ai-login-card .ai-password-toggle {
    color: rgba(0, 0, 0, 0.3);
}

:root.light-mode .ai-login-card .form-control:focus {
    background: rgba(0, 0, 0, 0.01) !important;
    box-shadow: 0 0 0 4px rgba(233, 30, 140, 0.15), 0 0 20px rgba(233, 30, 140, 0.05) !important;
}

.ai-login-main {
    position: relative;
    z-index: 10;
    width: 100%;
    display: flex;
    justify-content: center;
}

.ai-login-subtitle {
    font-size: 0.88rem;
    margin-top: 12px;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.02em;
    line-height: 1.45;
}

:root.light-mode .ai-login-subtitle {
    color: var(--ai-text-muted);
}

.ai-login-forgot-link {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--ai-primary);
    text-decoration: none;
}

.ai-login-forgot-link:hover {
    color: var(--ai-primary-dark, #c2185b);
    text-decoration: underline;
}

.ai-login-password-label-row {
    margin-bottom: 8px;
}

.ai-login-password-label-row .btn-link.ai-login-forgot-link {
    color: var(--ai-primary) !important;
}

.ai-login-password-label-row .btn-link.ai-login-forgot-link:hover {
    color: var(--ai-primary-dark, #c2185b) !important;
}

.ai-login-forgot-link--inline {
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Forgot password modal (login page) */
.ai-login-forgot-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.ai-login-forgot-overlay.show {
    opacity: 1;
    visibility: visible;
}

.ai-login-forgot-modal {
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    overflow: hidden;
    background: rgba(38, 38, 38, 0.96);
    border: none;
    box-shadow: 0 28px 64px rgba(0, 0, 0, 0.55);
    transform: translateY(14px) scale(0.98);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-login-forgot-overlay.show .ai-login-forgot-modal {
    transform: translateY(0) scale(1);
}

.ai-login-forgot-modal-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #e91e63 0%, #c2185b 100%);
    color: #fff;
    border: none;
    outline: none;
    flex-shrink: 0;
}

.ai-login-forgot-header-text {
    flex: 1;
    min-width: 0;
}

.ai-login-forgot-modal-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
    font-family: 'Inter', sans-serif;
}

.ai-login-forgot-modal-header .ai-modal-subtitle {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    margin-top: 1px;
}

.ai-login-forgot-modal-header .ai-modal-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-login-forgot-modal-header .ai-modal-icon i {
    font-size: 1rem;
    color: #fff;
}

.ai-login-forgot-modal-header .ai-record-close:focus-visible {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.45);
    outline: none;
}

.ai-login-forgot-modal-body {
    padding: 18px 18px 20px;
}

.ai-login-forgot-intro {
    line-height: 1.45;
}

.ai-login-forgot-modal .form-control {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    padding: 10px 14px;
    font-size: 0.95rem;
    border-radius: 10px;
}

.ai-login-forgot-modal .form-control:focus {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: var(--ai-primary) !important;
    box-shadow: 0 0 0 4px rgba(233, 30, 140, 0.2) !important;
    outline: none;
}

.ai-login-forgot-modal .form-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(255, 255, 255, 0.72);
    margin-bottom: 8px;
}

.ai-login-forgot-modal .alert-success {
    background: rgba(44, 160, 28, 0.18);
    border: 1px solid rgba(44, 160, 28, 0.35);
    color: #c8f5d0;
}

.ai-login-forgot-modal .alert-danger {
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 70, 0.4);
    color: #ffc9d1;
}

:root.light-mode .ai-login-forgot-modal {
    background: rgba(255, 255, 255, 0.98);
    border: none;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
}

:root.light-mode .ai-login-forgot-modal .form-label {
    color: #475569;
}

:root.light-mode .ai-login-forgot-modal .form-control {
    background: rgba(0, 0, 0, 0.03) !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
    color: #1a1a1a !important;
}

:root.light-mode .ai-login-forgot-modal .form-control:focus {
    background: rgba(0, 0, 0, 0.01) !important;
    box-shadow: 0 0 0 4px rgba(233, 30, 140, 0.12) !important;
}

:root.light-mode .ai-login-forgot-modal .alert-success {
    background: rgba(44, 160, 28, 0.1);
    border-color: rgba(44, 160, 28, 0.25);
    color: #1e6b2e;
}

:root.light-mode .ai-login-forgot-modal .alert-danger {
    background: rgba(220, 53, 69, 0.08);
    border-color: rgba(220, 53, 70, 0.3);
    color: #842029;
}

.ai-login-theme-btn {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(30, 30, 30, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: rgba(255, 255, 255, 0.82);
    font-size: 1.15rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.ai-login-theme-btn:hover {
    color: var(--ai-primary);
    border-color: rgba(233, 30, 140, 0.45);
    background: rgba(40, 40, 40, 0.75);
}

.ai-login-theme-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.45);
}

:root.light-mode .ai-login-theme-btn {
    border-color: rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.82);
    color: rgba(33, 37, 41, 0.85);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

:root.light-mode .ai-login-theme-btn:hover {
    background: #fff;
    color: var(--ai-primary);
}


/* ---- Empty State ---- */
.ai-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 20px;
    color: var(--ai-text-muted);
    min-height: 200px;
    height: 100%;
    flex: 1;
}

.ai-empty i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.25;
    display: block;
}

.ai-empty p {
    font-size: 0.95rem;
    font-weight: 500;
    margin: 0;
}

/* ---- Global Premium Scrollbars ---- */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--ai-scrollbar-thumb);
    border: 1px solid transparent;
    background-clip: content-box;
    border-radius: 4px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ai-scrollbar-hover);
    border: 0;
}

/* Grab to Scroll Cursor Style */
.ai-card-body[style*="overflow-x: auto"],
.ai-card-body[style*="overflow: auto"],
.ai-list,
.table-responsive {
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
    /* Prevent text selection during drag */
}

.ai-card-body:active,
.ai-list:active,
.table-responsive:active {
    cursor: grabbing;
}

/* Firefox Support */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--ai-scrollbar-thumb) transparent;
}

/* ---- Sidebar Scrollbar (prevent layout gap) ---- */
.ai-sidebar-nav::-webkit-scrollbar-track {
    background: transparent !important;
}

.ai-sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: var(--ai-border) transparent;
}

/* ---- Light Mode ---- */
:root.light-mode {
    --ai-dark: #f0f0f0;
    --ai-darker: #ffffff;
    --ai-body-bg: #f8f9fa;
    --ai-card-bg: #ffffff;
    --ai-text: #212529;
    --ai-text-muted: #6c757d;
    --ai-border: #dee2e6;
}

:root.light-mode body.ai-login-page {
    background: linear-gradient(135deg, #e9ecef 0%, #f4f6f9 50%, #dee2e6 100%);
}

:root.light-mode .ai-card,
:root.light-mode .ai-stat-card,
:root.light-mode .ai-login-card {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06);
}

:root.light-mode .ai-card .form-control,
:root.light-mode .ai-login-card .form-control,
:root.light-mode .ai-search-wrap .form-control {
    background: var(--ai-input-bg);
    border: 1px solid #eef2f6;
    color: var(--ai-text);
}

:root.light-mode .ai-card .form-select {
    background: var(--ai-select-bg);
    border: 1px solid var(--ai-border);
    color: var(--ai-text);
}

:root.light-mode .ai-card .form-control:focus,
:root.light-mode .ai-card .form-select:focus,
:root.light-mode .ai-login-card .form-control:focus,
:root.light-mode .ai-search-wrap .form-control:focus {
    background: #ffffff;
    border-color: var(--ai-primary);
    color: var(--ai-text);
    box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.2);
}

:root.light-mode .ai-login-card .form-control::placeholder {
    color: #6c757d;
}

:root.light-mode .ai-login-page {
    background: #f0f2f5;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(233, 30, 140, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 212, 200, 0.03) 0%, transparent 55%);
}

:root.light-mode .ai-brand {
    color: var(--ai-text) !important;
}

:root.light-mode .ai-table thead th {
    background: rgba(0, 0, 0, 0.03);
    color: #495057;
    border-bottom: 2px solid rgba(0, 0, 0, 0.14) !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.09);
}

:root.light-mode .ai-navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--ai-border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

:root.light-mode .ai-nav-icon,
:root.light-mode .ai-user-btn {
    color: var(--ai-text) !important;
}

:root.light-mode .ai-sidebar-toggle {
    color: var(--ai-text);
}

:root.light-mode .form-select,
:root.light-mode .ai-card .form-select {
    background-color: #ffffff !important;
    border-color: var(--ai-border) !important;
    color: var(--ai-text) !important;
}

:root.light-mode input[type='date']::-webkit-calendar-picker-indicator {
    filter: none;
}

:root.light-mode input[type='date'],
:root.light-mode input[type='number'],
:root.light-mode select,
:root.light-mode textarea {
    color-scheme: light;
}

:root.light-mode .ai-page-header {
    border-bottom-color: rgba(var(--ai-primary-rgb), 0.18);
}

:root.light-mode .ai-page-header h1 {
    color: var(--ai-text);
}

:root.light-mode .ai-stat-card .stat-value {
    color: var(--ai-text);
}

:root.light-mode .ai-card-header h5 {
    color: var(--ai-text);
}

:root.light-mode .form-control::placeholder,
:root.light-mode .ai-search-wrap .form-control::placeholder {
    color: rgba(0, 0, 0, 0.45) !important;
}

/* ---- Responsive ---- */

/* Card header filter form &mdash; fill remaining space in row layout */
.ai-card-header .ai-filter-form {
    flex: 1 1 auto;
    justify-content: flex-end;
}

/* Cards & tables never overflow the viewport */
.ai-card {
    overflow: visible;
}

@media (max-width: 991.98px) {

    /* Sidebar collapses */
    .ai-sidebar {
        transform: translateX(-100%);
    }

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

    .ai-content-wrapper {
        margin-left: 0;
    }

    /* Reduce padding on smaller screens */
    .ai-main {
        padding: 20px 16px;
    }

    .ai-card-header {
        padding: 14px 16px;
    }

    .ai-card-body {
        padding: 16px;
    }

    /* Filter Form: Stack components on small screens */
    .ai-card-header .ai-filter-form {
        display: grid !important;
        grid-template-columns: 1fr auto;
        gap: 8px;
        width: 100%;
        align-items: center;
    }

    .ai-card-header .ai-filter-form .input-group {
        grid-column: 1;
        width: 100% !important;
        min-width: 0;
    }

    .ai-card-header .ai-filter-form .btn-archive-toggle {
        grid-column: 2;
        width: auto !important;
    }

    .ai-card-header .ai-filter-form .ts-wrapper,
    .ai-card-header .ai-filter-form>select,
    .ai-card-header .ai-filter-form>.form-select,
    .ai-card-header .ai-filter-form .ai-filter-dropdown,
    .ai-card-header .ai-filter-form>a.btn:not(.btn-archive-toggle),
    .ai-card-header .ai-filter-form>a.ai-btn-clear-filter {
        grid-column: 1 / -1;
        width: 100% !important;
        min-width: 0 !important;
    }

    .ai-card-header .ai-filter-form .ai-filter-dropdown .dropdown-toggle {
        width: 100% !important;
    }

    /* Tables: horizontal scroll, smaller text */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ai-table thead th,
    .ai-table tbody td {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    /* Fix fixed-width calendar/date-picker containers that overflow narrow screens */
    [style*="width: 310px"] {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Remove right-alignment from date-picker columns so they stretch full width */
    .col-lg-3.d-flex.flex-column.align-items-end,
    .col-lg-4.d-flex.flex-column.align-items-end {
        align-items: stretch !important;
    }

    /* Dropdown filter menus: prevent viewport overflow on very narrow screens */
    .ai-filter-form .dropdown-menu {
        max-width: calc(100vw - 20px) !important;
    }
}

/* Extra-small screens (576px and below) */
@media (max-width: 575.98px) {
    .ai-main {
        padding: 14px 10px;
    }

    .ai-page-header {
        margin-bottom: 20px;
    }

    .ai-page-header h1 {
        font-size: 1.25rem;
    }

    .ai-page-header p {
        font-size: 0.82rem;
    }

    .ai-card-header {
        padding: 12px;
        flex-wrap: wrap;
        row-gap: 10px;
    }

    /* Simple card headers (justify-content-between): allow title and right item to wrap */
    .ai-card-header.d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 8px;
    }

    .ai-card-body {
        padding: 12px;
    }

    .ai-table thead th,
    .ai-table tbody td {
        padding: 8px 10px;
        font-size: 0.75rem;
    }

    /* Record modal &mdash; slide up from bottom */
    .ai-record-overlay {
        padding: 16px;
        align-items: center;
    }

    .ai-record-modal {
        max-width: 100% !important;
        max-height: 92vh;
        border-radius: 14px;
    }

    /* Login card */
    .ai-login-card {
        padding: 22px 17px;
        margin: 0 6px;
    }

    .ai-login-card .ai-brand img {
        height: 64px;
    }

    /* Stat cards */
    .ai-stat-card {
        padding: 1rem 1.125rem;
        gap: 1rem;
    }

    .stat-value {
        font-size: 1.6rem;
    }
}

.ai-email-link {
    color: var(--ai-primary) !important;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.ai-email-link:hover {
    opacity: 0.85;
    text-decoration: underline !important;
}

/* ---- Login Success Loader ---- */
.login-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--ai-primary);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1200px;
    flex-direction: column;
    gap: 32px;
}

.login-loader-overlay.easing-out {
    animation: fadeOutOverlay 0.9s ease-in forwards !important;
}

@keyframes fadeOutOverlay {
    0% {
        opacity: 1;
    }

    70% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.loader-circles {
    --loader-size: 110px;
    position: relative;
    width: var(--loader-size);
    height: var(--loader-size);
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
    animation: scaleInCircles 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    will-change: transform;
}

@media (max-width: 767.98px) {
    .loader-circles {
        --loader-size: 150px;
    }

    .loader-text {
        font-size: 1.6rem !important;
    }
}

.loader-circles.easing-out {
    animation: scaleOutCircles 0.9s cubic-bezier(0.36, 0, 0.66, -0.56) forwards !important;
}

@keyframes scaleInCircles {
    0% {
        transform: scale(0.4) rotateX(-30deg);
        opacity: 0;
    }

    100% {
        transform: scale(1) rotateX(0);
        opacity: 1;
    }
}

@keyframes scaleOutCircles {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    70% {
        transform: scale(1.5) rotateX(15deg);
        opacity: 0.8;
    }

    100% {
        transform: scale(2.2) rotateX(25deg);
        opacity: 0;
    }
}

.loader-circle {
    position: absolute;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-sizing: border-box;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2), inset 0 0 10px rgba(255, 255, 255, 0.1);
    will-change: transform;
}

.loader-text {
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    opacity: 0;
    animation: fadeInText 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.3s;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.loader-text.easing-out {
    animation: fadeOutText 0.6s ease-in forwards !important;
}

@keyframes fadeInText {
    0% {
        opacity: 0;
        transform: translateY(15px);
        filter: blur(4px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

@keyframes fadeOutText {
    0% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
}

.loader-circle.outer {
    width: 100%;
    height: 100%;
    border-width: 3px;
    animation: orbitOuter 3s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.loader-circle.middle {
    width: 70%;
    height: 70%;
    border-width: 2px;
    border-color: rgba(255, 255, 255, 0.7);
    animation: orbitMiddle 2s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.loader-circle.inner {
    width: 35%;
    height: 35%;
    border-width: 2px;
    border-color: rgba(255, 255, 255, 0.5);
    animation: orbitInner 1.2s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

@keyframes orbitOuter {
    0% {
        transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
    }

    100% {
        transform: rotateX(360deg) rotateY(180deg) rotateZ(360deg);
    }
}

@keyframes orbitMiddle {
    0% {
        transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
    }

    100% {
        transform: rotateX(-180deg) rotateY(360deg) rotateZ(-180deg);
    }
}

@keyframes orbitInner {
    0% {
        transform: rotateX(0deg) rotateY(0deg);
    }

    100% {
        transform: rotateX(360deg) rotateY(-360deg);
    }
}

/* Base wrapper &mdash; kill all extra spacing from .form-select inheritance */
.ts-wrapper,
.ts-wrapper.form-select,
.ts-wrapper.form-select-sm,
.ai-card .ts-wrapper.form-select,
.ai-filter-form .ts-wrapper.form-select,
.ai-filter-form .ts-wrapper.form-select-sm {
    min-height: 0 !important;
    border: none !important;
    background: none !important;
    background-color: transparent !important;
    background-image: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.ts-wrapper.single .ts-control {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%), #1e1e1e !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    color: var(--ai-text) !important;
    border-radius: 50px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 0 rgba(255, 255, 255, 0.05) !important;
    transition: var(--ai-transition);
    display: flex !important;
    align-items: center !important;
    padding: 0 34px 0 16px !important;
    min-height: 38px !important;
    height: 38px !important;
    line-height: 36px !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
}

:root.light-mode .ts-wrapper.single .ts-control {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
}

:root.light-mode .ts-wrapper.single .ts-control .item,
:root.light-mode .ts-wrapper.single .ts-control input {
    color: #64748b !important;
}

.ts-wrapper.single .ts-control>input {
    display: inline-block !important;
    vertical-align: middle !important;
    color: var(--ai-text) !important;
    font-size: 0.8rem !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1.4 !important;
}

/* Hide the search cursor only when a value is selected and the control isn't open */
.ts-wrapper.single.has-items:not(.dropdown-active) .ts-control>input {
    opacity: 0 !important;
    width: 0 !important;
    max-width: 0 !important;
    position: absolute !important;
}

/* When open, hide the item so the search input takes the full line (no stacked "extra line") */
.ts-wrapper.single.dropdown-active .ts-control .item {
    display: none !important;
}
.ts-wrapper.single.dropdown-active .ts-control>input {
    opacity: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    position: static !important;
}

.ts-wrapper.single .ts-control .item {
    display: inline-block !important;
    vertical-align: middle !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.4 !important;
    color: var(--ai-text) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
}

/* Hide built-in caret — SVG chevron is injected via JS */
.ts-wrapper.single .ts-control::after {
    display: none !important;
}

/* Injected SVG chevron for Tom Select (matches .ai-select-chevron) */
.ts-chevron {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    pointer-events: none;
    line-height: 1;
    flex-shrink: 0;
}

.ts-chevron .ai-select-chevron {
    width: 14px;
    height: 14px;
    opacity: 0.5;
    transition: transform 0.2s ease;
}

.ts-wrapper.single.dropdown-active .ts-chevron .ai-select-chevron {
    transform: rotate(180deg);
}

.ts-wrapper.single .ts-control.focus,
.ts-wrapper.single.focus .ts-control {
    border-color: var(--ai-primary) !important;
    box-shadow: 0 0 0 3px var(--ai-primary-light) !important;
}

/* Dropdown panel — unified with .ai-select-panel */
.ts-dropdown {
    background: var(--ai-calendar-bg) !important;
    border: 1px solid var(--ai-border) !important;
    border-radius: 14px !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    color: var(--ai-text) !important;
    margin-top: 4px !important;
    z-index: 2000 !important;
    padding: 6px 0 !important;
    overflow: hidden !important;
    animation: aiSelectFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.ts-dropdown .ts-dropdown-content {
    max-height: 300px !important;
    overflow-y: auto !important;
}

:root.light-mode .ts-dropdown {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
}

.ts-dropdown .option {
    padding: 8px 16px !important;
    cursor: pointer !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    color: var(--ai-text) !important;
    transition: background-color 0.15s, color 0.15s !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    line-height: 1.4 !important;
}

.ts-dropdown .option:hover,
.ts-dropdown .option.active {
    background-color: rgba(233, 30, 140, 0.08) !important;
    color: var(--ai-primary) !important;
}

.ts-dropdown .option.selected {
    background-color: rgba(233, 30, 140, 0.12) !important;
    color: var(--ai-primary) !important;
    font-weight: 700 !important;
}

:root.light-mode .ts-dropdown .option {
    color: #334155 !important;
}

:root.light-mode .ts-dropdown .option:hover,
:root.light-mode .ts-dropdown .option.active {
    background-color: rgba(233, 30, 140, 0.06) !important;
    color: var(--ai-primary) !important;
}

:root.light-mode .ts-dropdown .option.selected {
    background-color: rgba(233, 30, 140, 0.1) !important;
    color: var(--ai-primary) !important;
}

.ts-dropdown .optgroup-header {
    background: var(--ai-calendar-bg) !important;
    color: var(--ai-text-muted) !important;
    font-size: 0.7rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    padding: 8px 16px 4px !important;
}

/* Conflicting .ai-filter-form .ts-wrapper overrides removed to standardize with .ai-filter-input */

/* ---- Compact Filters Inside Dropdown Menu ---- */
.ai-filter-form .ai-filter-dropdown .dropdown-menu .mb-3 {
    margin-bottom: 10px !important;
}

.ai-filter-form .ai-filter-dropdown .dropdown-menu .form-label {
    font-size: 0.7rem !important;
    margin-bottom: 4px !important;
}

.ai-filter-form .ai-filter-dropdown .ts-wrapper.single .ts-control,
.ai-filter-form .ai-filter-dropdown .input-group-text,
.ai-filter-form .ai-filter-dropdown .form-control {
    height: 28px !important;
    min-height: 28px !important;
    max-height: 28px !important;
    font-size: 0.75rem !important;
    line-height: 26px !important;
}

.ai-filter-form .ai-filter-dropdown .ts-wrapper.single .ts-control {
    padding: 0 30px 0 10px !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
}

.ai-filter-form .ai-filter-dropdown .input-group-text {
    padding: 0 8px !important;
}

.ai-filter-form .ai-filter-dropdown .form-control {
    padding: 0 10px !important;
}

.ai-filter-form .ai-filter-dropdown .ts-wrapper.single .ts-control>input,
.ai-filter-form .ai-filter-dropdown .ts-wrapper.single .ts-control .item {
    height: 26px !important;
    line-height: 26px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* ---- Fluid Inline Calendar for Filter Dropdown ---- */
.ai-filter-form .ai-filter-dropdown .ai-compact-calendar {
    width: 100%;
}

.ai-filter-form .ai-filter-dropdown .ai-compact-calendar .form-label {
    margin-bottom: 4px !important;
}

.ai-filter-form .ai-filter-dropdown .ai-compact-calendar .flatpickr-calendar.inline {
    width: 100% !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    border: 1px solid var(--ai-border);
    margin-top: 0 !important;
}

/* Force internal flatpickr containers to stretch */
.ai-filter-form .ai-filter-dropdown .ai-compact-calendar .flatpickr-innerContainer,
.ai-filter-form .ai-filter-dropdown .ai-compact-calendar .flatpickr-rContainer,
.ai-filter-form .ai-filter-dropdown .ai-compact-calendar .flatpickr-days,
.ai-filter-form .ai-filter-dropdown .ai-compact-calendar .dayContainer {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
}

/* Re-proportion the days to fit evenly (100% / 7 = 14.28%) */
.ai-filter-form .ai-filter-dropdown .ai-compact-calendar .flatpickr-day {
    max-width: 14.28% !important;
    flex-basis: 14.28% !important;
    height: 30px !important;
    line-height: 30px !important;
}

.ai-filter-form .ai-filter-dropdown .dropdown-menu {
    overflow: visible !important;
    background-color: var(--ai-card-bg);
    border: 1px solid var(--ai-border) !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.03);
    padding-bottom: 8px !important;
}

.ai-filter-form .ai-filter-dropdown .ai-compact-calendar {
    padding-bottom: 0 !important;
}

.ai-filter-form .ai-filter-dropdown .ts-dropdown .ts-dropdown-content {
    max-height: 180px !important;
    overflow-y: auto !important;
}

.ai-filter-toggle {
    color: var(--ai-text-muted) !important;
    transition: var(--ai-transition);
    text-decoration: none !important;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
}

.ai-filter-toggle:hover,
.ai-filter-toggle:not(.collapsed) {
    color: #fff !important;
}

:root.light-mode .ai-filter-toggle {
    color: #64748b !important;
}

:root.light-mode .ai-filter-toggle:hover,
:root.light-mode .ai-filter-toggle:not(.collapsed) {
    color: var(--ai-primary) !important;
}

.ai-filter-toggle .ai-toggle-icons {
    color: #fff !important;
    /* Force high visibility in dark */
    opacity: 0.95;
    font-size: 0.75rem;
}

:root.light-mode .ai-filter-toggle .ai-toggle-icons {
    color: var(--ai-text-muted) !important;
    opacity: 0.8;
}

.ai-filter-toggle:not(.collapsed) .ai-toggle-icons {
    color: var(--ai-primary) !important;
    opacity: 1;
}

.ai-filter-toggle.collapsed .collapse-icon {
    display: none;
}

.ai-filter-toggle.collapsed .expand-icon {
    display: inline-block;
}

.ai-filter-toggle:not(.collapsed) .collapse-icon {
    display: inline-block;
}

.ai-filter-toggle:not(.collapsed) .expand-icon {
    display: none;
}

/* Instant collapse within filter dropdowns to prevent content cropping */
.ai-filter-dropdown .collapsing {
    transition: none !important;
    height: auto !important;
    overflow: visible !important;
}

/* Light mode overrides */
:root.light-mode .ts-wrapper.single .ts-control {
    background: var(--ai-filter-bg) !important;
    border-color: var(--ai-filter-border) !important;
    color: var(--ai-filter-text) !important;
}

:root.light-mode .ts-wrapper.single .ts-control>input {
    color: var(--ai-filter-text) !important;
}

:root.light-mode .ts-dropdown {
    background: var(--ai-filter-bg) !important;
    border-color: var(--ai-filter-border) !important;
    color: var(--ai-filter-text) !important;
}

/* ---- Record Detail Modal ---- */
.ai-record-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: 20px;
}

.ai-record-overlay.show {
    opacity: 1;
    visibility: visible;
}

.ai-record-modal {
    background: var(--ai-card-bg);
    border: none;
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    width: 100%;
    max-width: 700px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.ai-record-overlay.show .ai-record-modal {
    transform: translateY(0) scale(1);
}

.ai-record-modal::before { display: none; }

/* Confirm / password dialogs keep a card-bg header (no gradient) */
.ai-confirm-modal .ai-record-modal-header {
    background: var(--ai-card-bg) !important;
    border-radius: 14px 14px 0 0;
    padding-bottom: 0;
}
.ai-confirm-modal .ai-record-modal-header h5 {
    color: var(--ai-text) !important;
}
:root.light-mode .ai-confirm-modal .ai-record-modal-header {
    background: #ffffff !important;
}

/* Restore colored icon backgrounds for confirm dialogs */
.ai-confirm-modal .ai-modal-icon-danger {
    background: linear-gradient(135deg, rgba(255, 71, 87, 0.15), rgba(255, 71, 87, 0.05));
    color: var(--ai-danger);
}
.ai-confirm-modal .ai-modal-icon-warning {
    background: linear-gradient(135deg, rgba(255, 165, 2, 0.15), rgba(255, 165, 2, 0.05));
    color: var(--ai-warning);
}
.ai-confirm-modal .ai-modal-icon-info {
    background: linear-gradient(135deg, rgba(0, 212, 200, 0.15), rgba(0, 212, 200, 0.05));
    color: var(--ai-info);
}
.ai-confirm-modal .ai-modal-icon-success {
    background: linear-gradient(135deg, rgba(44, 160, 28, 0.15), rgba(44, 160, 28, 0.05));
    color: #2ca01c;
}
.ai-confirm-modal .ai-modal-icon-primary {
    background: linear-gradient(135deg, rgba(233, 30, 140, 0.15), rgba(233, 30, 140, 0.05));
    color: var(--ai-primary);
}
.ai-confirm-modal .ai-modal-icon-lg {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: unset;
}
.ai-confirm-modal .ai-modal-icon-lg i {
    font-size: 1.6rem;
}

.ai-record-modal-scroll {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* Ultra-thin custom scrollbar */
.ai-record-modal-scroll::-webkit-scrollbar {
    width: 4px;
}

.ai-record-modal-scroll::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}

.ai-record-modal-scroll::-webkit-scrollbar-thumb {
    background: rgba(233, 30, 140, 0.35);
    border-radius: 4px;
}

.ai-record-modal-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(233, 30, 140, 0.55);
}

/* Firefox scrollbar */
.ai-record-modal-scroll {
    scrollbar-width: thin;
    scrollbar-color: rgba(233, 30, 140, 0.35) transparent;
}

.ai-record-modal-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #e91e63 0%, #c2185b 100%);
    flex-shrink: 0;
    border-radius: 14px 14px 0 0;
}

.ai-record-modal-header h4 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
    font-family: 'Inter', sans-serif;
}

.ai-record-modal-header .ai-modal-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-record-modal-header .ai-modal-icon-lg {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-record-modal-header .ai-modal-icon i,
.ai-record-modal-header .ai-modal-icon-lg i {
    font-size: 1rem;
    color: #fff;
}

.ai-record-modal-header .ai-modal-subtitle {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    margin-top: 1px;
    opacity: 1;
}

.ai-record-modal-header .ai-record-close,
.ai-login-forgot-modal-header .ai-record-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-left: auto;
    padding: 0;
}

.ai-record-modal-header .ai-record-close:hover,
.ai-login-forgot-modal-header .ai-record-close:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
}

.ai-record-modal-body {
    padding: 4px 24px 24px;
}

.ai-record-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
}

.ai-record-detail-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--ai-border);
}

.ai-record-detail-item:last-child {
    border-bottom: none;
}



.ai-record-detail-item.col-left {
    padding-right: 16px;
    padding-left: 0;
    border-left: none;
}

.ai-record-detail-item.col-right {
    padding-left: 16px;
    padding-right: 0;
    border-left: 1px solid var(--ai-border);
}

.ai-record-detail-item.full-width {
    grid-column: 1 / -1;
    padding-left: 0;
    padding-right: 0;
    border-left: none;
}

.ai-record-detail-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ai-text-muted);
    margin-bottom: 4px;
}

.ai-record-detail-value {
    font-size: 0.88rem;
    color: var(--ai-text);
    word-break: break-word;
    line-height: 1.5;
}

.ai-record-detail-value a {
    color: var(--ai-primary);
    text-decoration: none;
}

.ai-record-detail-value a:hover {
    text-decoration: underline;
}

/* Client modal — projects + wiki (unified list panel) */
.ai-client-modal-projects-wrap {
    max-height: min(58vh, 28rem);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0;
    margin: 0;
    border-radius: 10px;
    border: 1px solid var(--ai-border);
    background: var(--ai-card-bg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    scrollbar-width: thin;
    scrollbar-color: rgba(233, 30, 140, 0.3) transparent;
}

.ai-client-modal-projects-wrap::-webkit-scrollbar {
    width: 5px;
}

.ai-client-modal-projects-wrap::-webkit-scrollbar-thumb {
    background: rgba(233, 30, 140, 0.35);
    border-radius: 5px;
}

.ai-client-modal-projects-wrap::-webkit-scrollbar-thumb:hover {
    background: rgba(233, 30, 140, 0.5);
}

:root.light-mode .ai-client-modal-projects-wrap {
    background: #fafafa;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ai-client-modal-projects-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin: 0;
    padding: 7px 12px;
    background: rgba(0, 0, 0, 0.04);
    border-bottom: 1px solid var(--ai-border);
}

:root.light-mode .ai-client-modal-projects-toolbar {
    background: rgba(0, 0, 0, 0.03);
}

.ai-client-modal-projects-total {
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--ai-text-muted);
}

.ai-client-modal-projects {
    display: flex;
    flex-direction: column;
    gap: 0;
    font-size: 11px;
    line-height: 1.35;
    padding: 4px 0;
}

.ai-client-modal-project {
    border: none;
    border-radius: 0;
    background: transparent;
    overflow: visible;
    border-bottom: 1px solid var(--ai-border);
}

.ai-client-modal-project:last-child {
    border-bottom: none;
}

.ai-client-modal-project-summary {
    cursor: pointer;
    list-style: none;
    padding: 8px 12px 8px 10px;
    margin: 0 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}

.ai-client-modal-project-summary:hover {
    background: rgba(233, 30, 140, 0.07);
}

:root.light-mode .ai-client-modal-project-summary:hover {
    background: rgba(233, 30, 140, 0.09);
}

.ai-client-modal-project[open] > .ai-client-modal-project-summary {
    background: rgba(233, 30, 140, 0.06);
}

:root.light-mode .ai-client-modal-project[open] > .ai-client-modal-project-summary {
    background: rgba(233, 30, 140, 0.08);
}

.ai-client-modal-project-summary::-webkit-details-marker {
    display: none;
}

.ai-client-modal-project-caret {
    flex-shrink: 0;
    font-size: 0.62rem;
    line-height: 1;
    color: var(--ai-primary);
    opacity: 0.85;
    transition: transform 0.18s ease, color 0.15s ease;
}

.ai-client-modal-project[open] .ai-client-modal-project-caret {
    transform: rotate(-180deg);
}

.ai-client-modal-project-titles {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px 12px;
    flex-wrap: wrap;
}

.ai-client-modal-project-name-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
}

.ai-client-modal-project-name {
    color: var(--ai-text) !important;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.2;
}

.ai-client-modal-project-badge {
    font-size: 7.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.32px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(108, 117, 125, 0.18);
    color: var(--ai-text-muted);
}

.ai-client-modal-project-meta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.ai-client-modal-project-status {
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--ai-text-muted);
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.06);
}

:root.light-mode .ai-client-modal-project-status {
    background: rgba(0, 0, 0, 0.055);
}

.ai-client-modal-project-count {
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    color: var(--ai-primary);
    opacity: 0.95;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(233, 30, 140, 0.1);
}

.ai-client-modal-project-panel {
    padding: 0 14px 10px 34px;
    margin: 0 4px 6px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 0 0 8px 8px;
    border-left: 2px solid rgba(233, 30, 140, 0.35);
}

:root.light-mode .ai-client-modal-project-panel {
    background: rgba(0, 0, 0, 0.025);
}

.ai-client-modal-project-empty {
    color: var(--ai-text-muted);
    font-size: 10px;
    padding: 6px 0 4px;
    line-height: 1.3;
}

.ai-client-modal-project-wiki-scroll {
    max-height: 7rem;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 6px 2px 2px;
    margin: 0;
    min-height: 0;
    background: transparent;
    scrollbar-width: thin;
    scrollbar-color: rgba(233, 30, 140, 0.28) transparent;
}

.ai-client-modal-project-wiki-scroll::-webkit-scrollbar {
    width: 4px;
}

.ai-client-modal-project-wiki-scroll::-webkit-scrollbar-thumb {
    background: rgba(233, 30, 140, 0.35);
    border-radius: 4px;
}

.ai-client-modal-project-wiki-list {
    list-style: disc;
    padding-left: 0.95rem;
    margin: 0;
}

.ai-client-modal-project-wiki-li {
    margin-bottom: 3px;
    line-height: 1.35;
}

.ai-client-modal-project-wiki-li:last-child {
    margin-bottom: 0;
}

.ai-record-detail-value .ai-client-modal-wiki-link {
    font-size: 10.5px;
    font-weight: 500;
}

.ai-client-modal-wiki-link:not(a) {
    color: var(--ai-text);
}

.ai-client-modal-wiki-archived {
    font-size: 7px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    color: var(--ai-text-muted);
    opacity: 0.85;
    margin-left: 2px;
}

/* Client record modal — tax block (taxable + code ref) */
.ai-client-modal-tax-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem 1.25rem;
    align-items: start;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--ai-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

:root.light-mode .ai-client-modal-tax-wrap {
    background: rgba(0, 0, 0, 0.02);
}

@media (max-width: 420px) {
    .ai-client-modal-tax-wrap {
        grid-template-columns: 1fr;
    }
}

.ai-client-modal-tax-col {
    min-width: 0;
    padding-left: 10px;
    border-left: 2px solid rgba(233, 30, 140, 0.45);
    margin-left: 0;
}

.ai-client-modal-tax-col:first-child {
    padding-left: 0;
    border-left: none;
}

.ai-client-modal-tax-sublabel {
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.55px;
    color: var(--ai-text-muted);
    margin-bottom: 4px;
    line-height: 1.2;
    opacity: 0.92;
}

.ai-record-modal-actions {
    padding: 12px 24px 20px;
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--ai-border);
    flex-shrink: 0;
}

.ai-record-modal .form-control {
    background-color: var(--ai-input-bg) !important;
    border: 1px solid var(--ai-border) !important;
    color: var(--ai-text) !important;
    border-radius: 10px !important;
    font-size: 0.95rem;
    padding: 11px 14px;
    height: auto;
    transition: var(--ai-transition);
}

.ai-record-modal .form-control:focus {
    background-color: var(--ai-input-bg) !important;
    border-color: var(--ai-primary) !important;
    box-shadow: 0 0 0 4px rgba(233, 30, 140, 0.2) !important;
    color: var(--ai-text) !important;
}

.ai-record-modal .form-control::placeholder {
    color: var(--ai-text-muted);
    opacity: 0.5;
}

.ai-record-modal .form-label {
    color: var(--ai-text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.ai-record-modal .ai-password-toggle {
    color: var(--ai-text-muted) !important;
    opacity: 0.6;
    transition: var(--ai-transition);
}

.ai-record-modal .ai-password-toggle:hover {
    color: var(--ai-primary) !important;
    opacity: 1;
}

/* Modal Backdrop Blur Effect & Layering */
.modal-backdrop {
    z-index: 12000 !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    /* Fixed base color to prevent black flash on close */
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal-backdrop.show {
    opacity: 1 !important;
}

.modal {
    z-index: 12010 !important;
}

.ai-confirm-overlay {
    z-index: 12050 !important;
}

/* Dropdowns that are positioned inside a modal or custom overlay must sit
   above the modal stack. Applies to Bootstrap dropdown-menus, .ai-dropdown
   skins, and Tom Select menus that remain in-DOM (not body-appended). */
.modal .dropdown-menu.show,
.modal .ai-dropdown,
.ai-record-overlay .dropdown-menu.show,
.ai-record-overlay .ai-dropdown {
    z-index: 13000 !important;
}

/* AI Modal Smooth Transition Override */
.modal.fade .modal-dialog {
    transform: none !important;
    transition: none !important;
}

.modal.show .ai-record-modal {
    transform: translateY(0) scale(1);
}

/* Standardized AI Modals (Zinc Theme) */
.ai-modal-content {
    background: var(--ai-card-bg);
    border: none;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.ai-modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ff7eb3, var(--ai-primary));
    z-index: 10;
}

.ai-modal-header {
    background: rgba(255, 255, 255, 0.02);
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--ai-border);
}

.ai-modal-header h5 {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.3px;
}

.ai-modal-body {
    padding: 1.5rem;
}

.ai-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--ai-border);
    background: rgba(255, 255, 255, 0.01);
}

/* Fix Bootstrap Close Button in Dark Mode */
.ai-modal-header .btn-close {
    opacity: 0.7;
    transition: var(--ai-transition);
}

.ai-modal-header .btn-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}

.ai-record-modal-actions .btn-ai-outline {
    color: var(--ai-text-muted);
    border-color: var(--ai-border);
}

.ai-record-modal-actions .btn-ai-outline:hover,
.ai-record-modal-actions .btn-ai-outline:active {
    background: transparent;
    color: var(--ai-text);
    border-color: var(--ai-text-muted);
}

/* Neutral Cancel Buttons in Forms */
form a.btn-ai-outline {
    color: var(--ai-text-muted);
    border-color: var(--ai-border);
}

form a.btn-ai-outline:hover,
form a.btn-ai-outline:active {
    background: transparent;
    color: var(--ai-text);
    border-color: var(--ai-text-muted);
}

/* Clickable Table Rows */
.ai-table tbody tr.ai-clickable-row {
    cursor: pointer;
    transition: background 0.15s ease;
}

.ai-table tbody tr.ai-clickable-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* ---- Light Mode: Record Modal ---- */
:root.light-mode .ai-record-modal {
    background: #ffffff;
    border: none;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15);
}

:root.light-mode .ai-record-modal-header h4 {
    color: #fff;
}

:root.light-mode .ai-record-detail-value {
    color: #212529;
}

:root.light-mode .ai-record-overlay {
    background: rgba(0, 0, 0, 0.4);
}

/* ---- Toast Notifications ---- */
.ai-toast-container {
    position: fixed;
    top: calc(var(--ai-navbar-height) + 16px);
    right: 20px;
    z-index: 13000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 400px;
    width: 100%;
}

.ai-toast {
    pointer-events: auto;
    display: flex;
    align-items: stretch;
    background: var(--ai-card-bg);
    border: 1px solid var(--ai-border);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04);
    overflow: hidden;
    position: relative;
    transform: translateX(120%);
    opacity: 0;
    animation: aiToastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    min-width: 320px;
}

.ai-toast.ai-toast-out {
    animation: aiToastOut 0.35s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes aiToastIn {
    from {
        transform: translateX(120%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes aiToastOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(120%);
        opacity: 0;
    }
}

.ai-toast-accent {
    width: 4px;
    flex-shrink: 0;
    border-radius: 10px 0 0 10px;
}

.ai-toast-content {
    flex: 1;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ai-toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    line-height: 1;
}

.ai-toast-text {
    flex: 1;
    min-width: 0;
}

.ai-toast-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 2px;
    opacity: 0.7;
}

.ai-toast-message {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ai-text);
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-toast-close {
    background: transparent;
    border: none;
    color: var(--ai-text-muted);
    padding: 14px 14px 14px 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: color 0.15s ease;
    flex-shrink: 0;
    line-height: 1;
    display: flex;
    align-items: center;
}

.ai-toast-close:hover {
    color: var(--ai-danger);
}

.ai-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    border-radius: 0 0 10px 10px;
    animation: aiToastProgress linear forwards;
}

.ai-toast.ai-toast-pinned .ai-toast-progress {
    display: none;
}

.ai-toast.ai-toast-expanded {
    min-height: auto;
}

.ai-toast.ai-toast-expanded .ai-toast-message {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
}

@keyframes aiToastProgress {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

/* Light mode toast */
:root.light-mode .ai-toast {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

:root.light-mode .ai-toast-message {
    color: #1e293b;
}

/* ============================================
   Seamless AJAX &mdash; Row Highlight & Table Transitions
   ============================================ */

/* Highlight pulse animation for new/edited rows (Outline Style) */
@keyframes aiRowOutlineMiddle {
    0% {
        box-shadow: inset 0 2px 0 0 rgba(233, 30, 140, 1), inset 0 -2px 0 0 rgba(233, 30, 140, 1);
    }

    50% {
        box-shadow: inset 0 2px 0 0 rgba(233, 30, 140, 0.4), inset 0 -2px 0 0 rgba(233, 30, 140, 0.4);
    }

    100% {
        box-shadow: inset 0 2px 0 0 rgba(233, 30, 140, 1), inset 0 -2px 0 0 rgba(233, 30, 140, 1);
    }
}

@keyframes aiRowOutlineFirst {
    0% {
        box-shadow: inset 0 2px 0 0 rgba(233, 30, 140, 1), inset 0 -2px 0 0 rgba(233, 30, 140, 1), inset 2px 0 0 0 rgba(233, 30, 140, 1);
    }

    50% {
        box-shadow: inset 0 2px 0 0 rgba(233, 30, 140, 0.4), inset 0 -2px 0 0 rgba(233, 30, 140, 0.4), inset 2px 0 0 0 rgba(233, 30, 140, 0.4);
    }

    100% {
        box-shadow: inset 0 2px 0 0 rgba(233, 30, 140, 1), inset 0 -2px 0 0 rgba(233, 30, 140, 1), inset 2px 0 0 0 rgba(233, 30, 140, 1);
    }
}

@keyframes aiRowOutlineLast {
    0% {
        box-shadow: inset 0 2px 0 0 rgba(233, 30, 140, 1), inset 0 -2px 0 0 rgba(233, 30, 140, 1), inset -2px 0 0 0 rgba(233, 30, 140, 1);
    }

    50% {
        box-shadow: inset 0 2px 0 0 rgba(233, 30, 140, 0.4), inset 0 -2px 0 0 rgba(233, 30, 140, 0.4), inset -2px 0 0 0 rgba(233, 30, 140, 0.4);
    }

    100% {
        box-shadow: inset 0 2px 0 0 rgba(233, 30, 140, 1), inset 0 -2px 0 0 rgba(233, 30, 140, 1), inset -2px 0 0 0 rgba(233, 30, 140, 1);
    }
}

.ai-row-highlight td {
    animation: aiRowOutlineMiddle 0.8s ease-in-out infinite !important;
}

.ai-row-highlight td:first-child:not(.ai-col-sticky):not(.ai-col-company) {
    animation: aiRowOutlineFirst 0.8s ease-in-out infinite !important;
}

.ai-row-highlight td.ai-col-sticky::before,
.ai-row-highlight td.ai-col-company::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 25;
    animation: aiRowOutlineFirst 0.8s ease-in-out infinite !important;
}

.ai-row-highlight td:last-child {
    animation: aiRowOutlineLast 0.8s ease-in-out infinite !important;
}

/* Table content fade during AJAX refresh */
.ai-table-loading {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.2s ease;
}



/* Submit button loading state */
.btn-ai-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.75;
}

.btn-ai-loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: aiSpinner 0.6s linear infinite;
}

@keyframes aiSpinner {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Smooth delete row collapse */
.ai-row-deleting td {
    transition: all 0.35s ease;
    opacity: 0;
    transform: translateX(20px);
}

.ai-row-deleted {
    display: none !important;
}

/* ============================================
   Dashboard & Chart Enhancements
   ============================================ */

.ai-stat-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem 1.75rem;
    background: var(--ai-card-bg);
    border: 1px solid var(--ai-border);
    border-radius: 1.25rem;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease, border-color 0.28s ease;
    position: relative;
    overflow: hidden;
    color: var(--ai-text);
    text-decoration: none !important;
}

.ai-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.ai-stat-card::after {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    opacity: 0.06;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.ai-stat-card:hover {
    transform: translateY(-4px);
    color: var(--ai-text);
}

.ai-stat-card:hover::before {
    opacity: 1;
}

.ai-stat-card:hover::after {
    opacity: 0.10;
}

.ai-stat-card .stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.75rem;
    height: 3.75rem;
    font-size: 1.6rem;
    border-radius: 1rem;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.ai-stat-card:hover .stat-icon {
    transform: scale(1.08) rotate(-4deg);
}

/* primary */
.ai-stat-card.primary {
    border-top: 3px solid var(--ai-primary);
    box-shadow: 0 4px 20px rgba(233, 30, 140, 0.08);
}

.ai-stat-card.primary::before {
    background: linear-gradient(135deg, rgba(233, 30, 140, 0.04), transparent);
}

.ai-stat-card.primary::after {
    background: var(--ai-primary);
}

.ai-stat-card.primary .stat-icon {
    background: linear-gradient(135deg, rgba(233, 30, 140, 0.15), rgba(233, 30, 140, 0.06));
    color: var(--ai-primary);
}

.ai-stat-card.primary:hover {
    box-shadow: 0 12px 28px -8px rgba(233, 30, 140, 0.25);
    border-color: rgba(233, 30, 140, 0.35);
}

/* info */
.ai-stat-card.info {
    border-top: 3px solid #38bdf8;
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.06);
}

.ai-stat-card.info::before {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.04), transparent);
}

.ai-stat-card.info::after {
    background: #38bdf8;
}

.ai-stat-card.info .stat-icon {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(56, 189, 248, 0.06));
    color: #38bdf8;
}

.ai-stat-card.info:hover {
    box-shadow: 0 12px 28px -8px rgba(56, 189, 248, 0.25);
    border-color: rgba(56, 189, 248, 0.35);
}

/* warning */
.ai-stat-card.warning {
    border-top: 3px solid #fbbf24;
    box-shadow: 0 4px 20px rgba(251, 191, 36, 0.06);
}

.ai-stat-card.warning::before {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.04), transparent);
}

.ai-stat-card.warning::after {
    background: #fbbf24;
}

.ai-stat-card.warning .stat-icon {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(251, 191, 36, 0.06));
    color: #fbbf24;
}

.ai-stat-card.warning:hover {
    box-shadow: 0 12px 28px -8px rgba(251, 191, 36, 0.25);
    border-color: rgba(251, 191, 36, 0.35);
}

/* danger */
.ai-stat-card.danger {
    border-top: 3px solid #ef4444;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.06);
}

.ai-stat-card.danger::before {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.04), transparent);
}

.ai-stat-card.danger::after {
    background: #ef4444;
}

.ai-stat-card.danger .stat-icon {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.06));
    color: #ef4444;
}

.ai-stat-card.danger:hover {
    box-shadow: 0 12px 28px -8px rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.35);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--ai-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* ---- Dashboard (index) header & motion ---- */
.ai-dashboard-page-header h1 {
    font-size: clamp(1.5rem, 2.5vw, 1.85rem);
    font-weight: 800;
}

.ai-dashboard-intro {
    font-size: 0.93rem;
    line-height: 1.55;
    max-width: 42rem;
}

#hoursTrendChartContainer {
    position: relative;
}

@media (prefers-reduced-motion: reduce) {
    .ai-dashboard-card,
    .ai-stat-card-animate {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .ai-stat-card,
    .ai-stat-card .stat-icon {
        transition-duration: 0.01ms !important;
    }

    .ai-stat-card:hover {
        transform: none;
    }

    .ai-stat-card:hover .stat-icon {
        transform: none;
    }
}

/* Dashboard: renewals, access log & audit readability */
.dash-renewal-card {
    gap: 0.25rem;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.dash-renewal-card:hover {
    background-color: rgba(var(--ai-primary-rgb), 0.06);
    box-shadow: inset 4px 0 0 var(--ai-primary);
}

:root.light-mode .dash-renewal-card:hover {
    background-color: rgba(var(--ai-primary-rgb), 0.07);
}

.dash-renewal-interval {
    width: 5.625rem;
    min-width: 5.625rem;
    max-width: 5.625rem;
    flex-shrink: 0;
    text-align: center;
}

.dash-renewal-interval-icon {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: rgba(var(--ai-primary-rgb), 0.1);
    font-size: 1.25rem;
    flex-shrink: 0;
}

.dash-renewal-interval-label {
    display: block;
    width: 100%;
    font-size: 0.61rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
    color: var(--ai-text-muted);
    line-height: 1.25;
    word-break: break-word;
}

.dash-renewal-domain {
    font-size: 0.93rem;
    color: var(--ai-text);
}

.dash-renewal-aside {
    min-width: 108px;
    max-width: 150px;
}

.dash-login-entry {
    border-radius: 0;
}

.dash-login-name {
    font-size: 0.92rem;
    font-weight: 650;
    color: var(--ai-text);
}

.dash-login-ip {
    font-size: 0.72rem;
    line-height: 1.3;
}

.dash-login-tz {
    font-weight: 600;
    opacity: 0.75;
}

.dash-tz-pill {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 0.35rem 0.67rem !important;
    background: rgba(var(--ai-primary-rgb), 0.14);
    color: var(--ai-primary-dark, var(--ai-primary));
}

:root.light-mode .dash-tz-pill {
    background: rgba(var(--ai-primary-rgb), 0.16);
    color: var(--ai-primary-dark);
}

.dash-audit-table {
    font-size: 0.86rem;
}

.dash-audit-table thead th {
    vertical-align: middle;
    padding-top: 0.72rem !important;
    padding-bottom: 0.72rem !important;
}

.dash-audit-table tbody td {
    vertical-align: top !important;
    padding-top: 0.82rem !important;
    padding-bottom: 0.82rem !important;
}

.dash-audit-col-user {
    width: 16%;
    min-width: 128px;
}

.dash-audit-col-target {
    width: 16%;
    min-width: 110px;
}

.dash-audit-col-activity {
    min-width: 200px;
}

.dash-audit-col-when {
    width: 124px;
    min-width: 104px;
}

.dash-resource-pill {
    display: inline-block;
    padding: 0.12rem 0.52rem;
    border-radius: 7px;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(var(--ai-primary-rgb), 0.12);
    color: var(--ai-primary-dark, var(--ai-primary));
}

:root.light-mode .dash-resource-pill {
    background: rgba(var(--ai-primary-rgb), 0.14);
}

.dash-record-title {
    margin-top: 0.22rem;
}

.dash-audit-summary {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--ai-text);
}

.dash-audit-preview {
    margin-top: 0.28rem;
    line-height: 1.4;
}

.dash-audit-when-time {
    font-size: 1rem;
    color: var(--ai-primary);
}

.dash-audit-when-tz {
    margin-left: 0.35rem;
    font-weight: 700;
}

.dash-audit-ip {
    margin-top: 0.35rem;
    font-size: 0.71rem;
    word-break: break-all;
}

.dash-audit-row:hover td {
    background-color: rgba(var(--ai-primary-rgb), 0.04) !important;
}

:root.light-mode .dash-audit-row:hover td {
    background-color: rgba(var(--ai-primary-rgb), 0.06) !important;
}

@media (max-width: 767.98px) {
    .dash-audit-uname {
        max-width: 7rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .dash-renewal-aside {
        min-width: 92px;
        max-width: 108px;
    }
}

.project-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.ai-list {
    margin-bottom: 0 !important;
}

.ai-list-item {
    transition: background 0.2s ease;
}

.ai-list-item:hover {
    background: var(--ai-primary-light);
}

.bg-ai-glass {
    background: rgba(233, 30, 140, 0.08);
    /* More transparent for blur */
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
}

.text-ai-primary {
    color: var(--ai-primary) !important;
}

.border-ai-glass {
    border-color: var(--ai-border) !important;
}

:root.light-mode .bg-ai-glass {
    background: rgba(233, 30, 140, 0.04);
}

:root.light-mode .border-ai-glass {
    border-color: var(--ai-border) !important;
}

.ai-date-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 14px;
    border-radius: 50px;
    border: 1px solid rgba(233, 30, 140, 0.25) !important;
    background: rgba(233, 30, 140, 0.08) !important;
    color: var(--ai-primary) !important;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    transition: var(--ai-transition);
    letter-spacing: 0.2px;
}

.ai-date-badge i {
    font-size: 0.85rem;
    margin-right: 8px;
    color: var(--ai-primary);
    opacity: 0.9;
}

.ai-date-badge:hover {
    background: rgba(233, 30, 140, 0.12) !important;
    border-color: rgba(233, 30, 140, 0.45) !important;
}

.ai-date-column-icon {
    width: 28px;
    height: 28px;
    background: #fff7ed;
    color: #f97316;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

:root:not(.light-mode) .ai-date-column-icon {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
}

.renewal-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

:root.light-mode .ai-stat-card {
    background: #ffffff;
}

:root.light-mode .ai-stat-card.primary {
    box-shadow: 0 4px 20px rgba(233, 30, 140, 0.10);
}

:root.light-mode .ai-stat-card.info {
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.10);
}

:root.light-mode .ai-stat-card.warning {
    box-shadow: 0 4px 20px rgba(251, 191, 36, 0.10);
}

:root.light-mode .ai-stat-card.danger {
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.10);
}

:root.light-mode .stat-value {
    color: #1e293b;
}

:root.light-mode .ai-list-item:hover {
    background: var(--ai-primary-light);
}

/* ============================================
   Mobile Sidebar Backdrop
   ============================================ */
.ai-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1039;
    /* just below sidebar z-index: 1040 */
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.ai-sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* ============================================
   Responsive: ≤480px &mdash; Toast & Dropdown fixes
   ============================================ */
@media (max-width: 479.98px) {

    /* Toast: prevent horizontal overflow */
    .ai-toast-container {
        right: 0;
        left: 0;
        max-width: 100%;
        padding: 0 8px;
    }

    .ai-toast {
        min-width: 0 !important;
        width: 100%;
    }

    /* Notification dropdown: clamp to viewport */
    .dropdown-menu[aria-labelledby="notifDropdown"] {
        width: calc(100vw - 16px) !important;
        max-width: 340px;
    }
}

/* ============================================
   Responsive: 320px minimum (≤399px)
   ============================================ */
@media (max-width: 399.98px) {

    /* Navbar */
    .ai-navbar {
        padding: 0 6px !important;
    }

    .ai-brand img {
        height: 26px !important;
        flex-shrink: 0;
    }

    .ai-date-badge {
        font-size: 0.65rem !important;
        padding: 3px 6px !important;
        letter-spacing: 0;
    }

    .ai-date-badge .bi-calendar3 {
        display: none;
        /* Hide calendar icon at 320px to save space */
    }

    .ai-nav-icon {
        font-size: 1rem !important;
        padding: 4px 4px !important;
    }

    /* Keep navbar items from wrapping or overflowing */
    .ai-navbar .container-fluid {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Login page */
    .ai-login-page {
        padding: 13px;
    }

    .ai-login-card {
        padding: 20px 14px;
        border-radius: 10px;
        margin: 0 !important;
    }

    .ai-login-card .ai-brand img {
        height: 60px !important;
    }

    /* Main content */
    .ai-main {
        padding: 10px 8px !important;
    }

    /* Footer */
    .ai-footer {
        padding: 12px 8px;
        font-size: 0.7rem;
    }

    .ai-footer .d-flex {
        flex-direction: column;
        gap: 2px;
        align-items: center !important;
        justify-content: center !important;
        text-align: center;
    }

    /* Page header */
    .ai-page-header h1 {
        font-size: 1.1rem !important;
    }

    .ai-page-header p {
        font-size: 0.78rem;
    }

    /* Cards &mdash; smallest breakpoint refinements */
    .ai-card-header {
        padding: 12px 10px !important;
        row-gap: 8px !important;
        column-gap: 10px !important;
        flex-wrap: wrap !important;
    }

    .ai-card-header.d-flex .btn-ai-outline,
    .ai-card-header.d-flex .btn-ai,
    .ai-card-header.d-flex .btn-sm {
        font-size: 0.72rem !important;
        padding: 5px 8px !important;
    }

    .ai-card-body {
        padding: 10px !important;
    }

    /* Stat cards */
    .ai-stat-card {
        gap: 0.85rem;
        padding: 0.9rem 1rem !important;
        border-radius: 0.85rem !important;
    }

    .ai-stat-card .stat-icon {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1.2rem;
        border-radius: 0.75rem;
    }

    .stat-value {
        font-size: 1.5rem !important;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    /* Tables */
    .ai-table thead th,
    .ai-table tbody td {
        padding: 6px 8px !important;
        font-size: 0.7rem !important;
    }

    /* Buttons */
    .btn-ai,
    .btn-ai-outline {
        padding: 7px 12px;
        font-size: 0.8rem;
    }

    .btn-sm.btn-ai,
    .btn-sm.btn-ai-outline {
        padding: 3px 8px;
        font-size: 0.72rem;
    }

    /* Record detail modal &mdash; bottom sheet on very small screens */
    .ai-record-overlay {
        padding: 16px;
        align-items: center;
    }

    .ai-record-modal {
        max-width: 100% !important;
        max-height: 94vh;
        border-radius: 14px;
    }

    .ai-record-detail-grid {
        grid-template-columns: 1fr;
    }

    .ai-record-detail-item:nth-child(even) {
        padding-left: 0;
        border-left: none;
    }

    .ai-record-modal-header {
        padding: 16px 16px 12px;
    }

    .ai-record-modal-body {
        padding: 4px 16px 16px;
    }

    .ai-record-modal-actions {
        padding: 10px 16px 16px;
    }

    /* Alerts */
    .ai-alert {
        padding: 10px 14px;
        font-size: 0.82rem;
        gap: 10px;
    }

    /* Nav icon: reduce size so bar never overflows at 320px */
    .ai-nav-icon {
        width: 34px !important;
        height: 34px !important;
    }

    /* Date badge inner text: override inline font-size for tighter fit */
    .ai-date-badge .d-md-none {
        font-size: 0.65rem !important;
    }

    /* Login card form inputs: force 16px to prevent iOS auto-zoom */
    .ai-login-card .form-control {
        font-size: 16px !important;
    }

    /* Weekly hours table: ensure horizontal scroll, no shrinking */
    .ai-bulk-table {
        min-width: 480px;
    }

    /* Filter inputs: minimum touch target height */
    .ai-filter-input,
    .ai-select-btn,
    .ai-date-dropdown-btn {
        min-height: 38px !important;
    }

    /* Sidebar user dropdown: ensure it doesn't bleed off screen */
    .ai-sidebar .dropdown-menu {
        max-width: calc(100vw - 16px) !important;
    }
}

/* -- Pagination Styles ------------------------------------------------------- */
.ai-pagination {
    --bs-pagination-focus-box-shadow: 0 0 0 0.25rem var(--ai-primary-light);
}

.ai-pagination .page-item .page-link {
    background-color: var(--ai-input-bg);
    border: 1px solid var(--ai-border);
    color: var(--ai-text);
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: none;
}

.ai-pagination .page-item:not(.active):not(.disabled) .page-link:hover,
.ai-pagination .page-item:not(.active):not(.disabled) .page-link:focus {
    background-color: var(--ai-primary-light) !important;
    border-color: var(--ai-primary) !important;
    color: var(--ai-primary) !important;
    transform: translateY(-1px);
}

.ai-pagination .page-link .bi-chevron-left {
    margin-right: 0.35rem;
}

.ai-pagination .page-link .bi-chevron-right {
    margin-left: 0.35rem;
}

.ai-pagination .page-item.active .page-link {
    background-color: var(--ai-primary) !important;
    border-color: var(--ai-primary) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 10px rgba(233, 30, 140, 0.4);
}

.ai-pagination .page-item.disabled .page-link {
    background-color: transparent !important;
    border-color: transparent !important;
    color: var(--ai-text-muted);
    opacity: 0.6;
}

:root.light-mode .ai-pagination .page-item .page-link {
    background-color: #ffffff;
    border-color: #dee2e6;
    color: #495057;
}

:root.light-mode .ai-pagination .page-item:not(.active):not(.disabled) .page-link:hover,
:root.light-mode .ai-pagination .page-item:not(.active):not(.disabled) .page-link:focus {
    background-color: rgba(233, 30, 140, 0.08) !important;
    border-color: var(--ai-primary) !important;
    color: var(--ai-primary) !important;
}

:root.light-mode .ai-pagination .page-item.active .page-link {
    background-color: var(--ai-primary) !important;
    border-color: var(--ai-primary) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 10px rgba(233, 30, 140, 0.25);
}

:root.light-mode .ai-pagination .page-item.disabled .page-link {
    background-color: transparent !important;
    border-color: transparent !important;
    color: #adb5bd;
}

/* -- Muted Text Visibility ------------------------------------------------- */
.text-muted {
    color: var(--ai-text-muted) !important;
}

.small.text-muted,
small.text-muted {
    opacity: 0.85;
}

/* Sticky Pagination Container */
.ai-pagination-sticky-wrapper {
    position: -webkit-sticky;
    position: sticky;
    left: 0;
    width: 100%;
    z-index: 10;
}

@media (max-width: 768px) {
    .ai-pagination {
        gap: 8px !important;
        /* Increased gap for better spacing */
        justify-content: center !important;
        flex-wrap: wrap !important;
    }

    .ai-pagination .page-link:not(.rounded-pill) {
        padding: 0 !important;
        width: 32px !important;
        height: 32px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0.85rem !important;
    }

    .ai-pagination .page-link.rounded-pill {
        width: auto !important;
        min-width: 44px;
        height: 32px !important;
        padding: 0 14px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0.85rem !important;
    }
}

@media (max-width: 399.98px) {
    .ai-pagination {
        gap: 2px !important;
    }

    .ai-pagination-text {
        display: none;
    }

    .ai-pagination .page-link {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.75rem !important;
    }
}

/* -- Table Search Bar ------------------------------------------------------- */
.ai-table-search {
    width: 100%;
    max-width: min(500px, 100%);
    height: 38px !important;
    border-radius: 50px !important;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%), #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    position: relative;
}

.ai-table-search:focus-within {
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 1px var(--ai-primary), 0 0 0 4px rgba(233, 30, 140, 0.15), 0 12px 32px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

:root.light-mode .ai-table-search {
    background: #ffffff !important;
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

:root.light-mode .ai-table-search:focus-within {
    border-color: var(--ai-primary) !important;
    box-shadow: 0 0 0 1px var(--ai-primary), 0 0 0 4px rgba(233, 30, 140, 0.1), 0 15px 35px rgba(0, 0, 0, 0.12);
}

.ai-search-icon {
    color: var(--ai-text-muted);
    padding-left: 22px;
    font-size: 1.15rem;
    pointer-events: none;
    flex-shrink: 0;
}

.ai-search-input {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    color: var(--ai-text);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0 16px;
    flex: 1;
    min-width: 0;
    height: 38px;
    line-height: 38px;
    box-shadow: none !important;
    white-space: nowrap;
    overflow: hidden;
}
:root.light-mode .ai-search-input {
    color: #64748b;
}

@media (max-width: 768px) {
    .ai-search-input {
        font-size: 16px !important;
        /* Prevent iOS auto-zoom */
    }
}

.ai-search-clear {
    background: transparent !important;
    border: none !important;
    color: var(--ai-text-muted) !important;
    padding-right: 20px !important;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ai-search-clear.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ai-search-clear:hover {
    color: var(--ai-primary) !important;
    transform: scale(1.15);
}

/* -- Layout & Action Buttons ------------------------------------------------ */
.ai-layout-btn,
.ai-sync-btn {
    border-radius: 50px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 100%), var(--ai-card-bg);
    border: 1px solid var(--ai-border) !important;
    color: var(--ai-text-muted);
    font-weight: 600;
    font-size: 13px;
    padding: 8px 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18), inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-layout-btn:hover,
.ai-sync-btn:hover {
    border-color: var(--ai-primary) !important;
    color: var(--ai-text);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
}

:root.light-mode .ai-layout-btn,
:root.light-mode .ai-sync-btn {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0) 100%), #ffffff !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

@media (max-width: 768px) {

    .ai-layout-btn,
    .ai-sync-btn {
        height: 39px !important;
        min-height: 39px !important;
        padding: 0 1.25rem !important;
        justify-content: center;
        z-index: 10002 !important;
        /* Stay above backdrop */
        display: flex !important;
        align-items: center !important;
        font-size: 14px !important;
    }
}

.ai-layout-btn:hover,
.ai-sync-btn:hover,
.ai-layout-btn:focus,
.ai-sync-btn:focus,
.ai-layout-btn.active {
    border-color: var(--ai-primary) !important;
    color: var(--ai-primary);
    box-shadow: 0 0 0 1px var(--ai-primary), 0 4px 15px rgba(233, 30, 140, 0.15) !important;
    transform: translateY(-1.5px);
}

.ai-layout-btn .bi-columns-gap,
.ai-layout-btn .bi-archive,
.ai-layout-btn .bi-archive-fill {
    color: var(--ai-primary);
}

/* -- Layout Dropdown Panel -------------------------------------------------- */
.ai-layout-panel {
    min-width: 270px;
    border-radius: 12px;
    z-index: 10001 !important;
    max-height: 450px;
    overflow-y: auto;
    padding: 1.25rem !important;
    background: var(--ai-card-bg);
    /* Solid opaque background */
    border: 1px solid var(--ai-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Fix row negative margins to prevent horizontal scroll without clipping padding */
.ai-layout-panel .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
}
.ai-layout-panel .row > [class*="col-"]:first-child {
    padding-left: 0 !important;
}
.ai-layout-panel .row > [class*="col-"]:last-child {
    padding-right: 0 !important;
}

:root.light-mode .ai-layout-panel {
    background: #ffffff !important;
    background-color: #ffffff !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: none !important;
}

.ai-layout-panel .form-check-label {
    color: var(--ai-text);
}

.ai-layout-panel .form-check-input {
    background-color: var(--ai-input-bg);
    border-color: var(--ai-border);
}

.ai-layout-panel .form-check-input:checked {
    background-color: var(--ai-primary);
    border-color: var(--ai-primary);
}

.ai-switch-subtle .form-check-input:checked {
    background-color: var(--ai-text-muted) !important;
    border-color: var(--ai-text-muted) !important;
    filter: grayscale(1) opacity(0.8);
}

.ai-switch-subtle .form-check-label {
    opacity: 0.8;
}

/* Layout dropdown: secondary-row switches match primary brand (Created / Modified, etc.) */
.ai-layout-panel .ai-switch-subtle .form-check-input:checked {
    background-color: var(--ai-primary) !important;
    border-color: var(--ai-primary) !important;
    filter: none !important;
}

.ai-layout-panel .ai-switch-subtle .form-check-input:focus {
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--ai-primary-rgb), 0.22);
}

.ai-layout-panel .ai-switch-subtle .form-check-label {
    opacity: 1 !important;
    color: var(--ai-text) !important;
}

/* -- Premium Form Controls -------------------------------------------------- */
.form-control,
.form-select {
    background-color: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 12px !important;
    color: var(--ai-text) !important;
    padding: 0.6rem 1rem !important;
    line-height: 1.2 !important;
    font-size: 0.85rem !important;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06), inset 0 1px 2px rgba(0, 0, 0, 0.02) !important;
}

.form-control:focus,
.form-select:focus {
    background-color: transparent !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: var(--ai-text) !important;
    outline: none !important;
    box-shadow: none !important;
    transform: none !important;
}

textarea.form-control {
    min-height: 100px !important;
}

:root.light-mode .form-control,
:root.light-mode .form-select {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #475569 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03), inset 0 1px 2px rgba(0, 0, 0, 0.01) !important;
}

:root.light-mode .form-control:focus,
:root.light-mode .form-select:focus {
    background-color: #ffffff !important;
    border-color: var(--ai-primary) !important;
}

/* -- Premium Badge Icons ------------------------------------------------------- */
/* -- Premium Badge Icons (Status & Currency) ------------------------------- */
.ai-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px !important;
    border-radius: 50px !important;
    font-size: 0.7rem !important;
    font-weight: 800 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 72px;
    /* standard width for currency and status */
    height: 26px !important;
    line-height: normal;
    border: 1px solid transparent;
}

.ai-badge svg,
.ai-badge i {
    margin-right: 5px;
    flex-shrink: 0;
}

.ai-badge.info {
    background: rgba(108, 92, 231, 0.1) !important;
    color: #6c5ce7 !important;
    border-color: rgba(108, 92, 231, 0.2) !important;
}

.ai-badge.success {
    background: rgba(44, 160, 28, 0.1) !important;
    color: #2ca01c !important;
    border-color: rgba(44, 160, 28, 0.2) !important;
}

.ai-badge.warning {
    background: rgba(251, 191, 36, 0.1) !important;
    color: #fbbf24 !important;
    border-color: rgba(251, 191, 36, 0.2) !important;
}

button.ai-badge-icon.ai-header-submit {
    outline: none;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}

button.ai-badge-icon.ai-header-submit i {
    transition: color 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}

button.ai-badge-icon.ai-header-submit:hover {
    background: var(--ai-primary) !important;
    color: #fff !important;
    border-color: var(--ai-primary) !important;
    box-shadow: 0 6px 14px rgba(233, 30, 140, 0.25) !important;
    transform: scale(1.05);
}

button.ai-badge-icon.ai-header-submit:hover i {
    color: #fff !important;
}

.ai-badge-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    /* Make them circular like the image */
    font-size: 1.15rem;
    flex-shrink: 0;
    position: relative;
    /* For badges */
    background: rgba(255, 255, 255, 0.08) !important;
    /* Standardized light grey background */
    color: var(--ai-text-muted) !important;
    /* Neutral icon color */
    border: 1px solid var(--ai-border);
}

:root.light-mode .ai-badge-icon {
    background: #f1f5f9 !important;
    color: #64748b !important;
    border-color: #e2e8f0;
}

/* Icon Badges */
.ai-icon-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--ai-primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--ai-card-bg);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    z-index: 2;
    animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

:root.light-mode .ai-icon-badge {
    border-color: #fff;
}

@keyframes badgePop {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

/* Default Dark Mode Styles */
.ai-badge-primary {
    background: rgba(233, 30, 140, 0.25);
    color: #ff7bc1;
    /* Brighter pink for excellent dark mode contrast */
}

.ai-badge-secondary {
    background: rgba(0, 212, 200, 0.15);
    color: var(--ai-secondary);
}

.ai-badge-gray {
    background: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
}

/* Light Mode Styles */
:root.light-mode .ai-badge-primary {
    background: #fdf2f8;
    /* Soft solid pink */
    color: var(--ai-primary);
}

:root.light-mode .ai-badge-secondary {
    background: #f0fdfa;
    /* Soft solid teal */
    color: #0d9488;
}

:root.light-mode .ai-badge-gray {
    background: #f1f5f9;
    /* Soft solid slate */
    color: #64748b;
}

/* -- Filter Row (in-table column filters) ----------------------------------- */
.ai-filter-row th {
    padding: 0.85rem 0.6rem !important;
    background: var(--ai-card-bg) !important;
    border-bottom: 2px solid var(--ai-border) !important;
    vertical-align: middle;
}

:root.light-mode .ai-filter-row th {
    background: #fdfdfe !important;
}

@media (max-width: 768px) {
    .ai-filter-row th {
        background: transparent !important;
        border-bottom: none !important;
        padding: 0.5rem 6px !important;
        min-width: 140px !important;
        /* Standardize filter cell widths on mobile */
    }

    :root.light-mode .ai-filter-row th {
        background: transparent !important;
    }
}

.ai-filter-input {
    background-color: var(--ai-input-bg) !important;
    border: 1px solid var(--ai-border) !important;
    border-radius: 50px;
    color: var(--ai-text) !important;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.6rem !important;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    width: 100%;
    min-width: 110px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06), inset 0 1px 2px rgba(0, 0, 0, 0.02);
    height: 38px !important;
    line-height: normal;
}

:root.light-mode .ai-filter-input {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04), inset 0 1px 2px rgba(0, 0, 0, 0.01);
}

/* -- Currency Selection Pills ----------------------------------------------- */
.ai-curr-pill {
    border-color: var(--ai-border) !important;
    background-color: var(--ai-input-bg);
    color: var(--ai-text);
}

:root.light-mode .ai-curr-pill {
    border-color: #cbd5e1 !important;
    background-color: #ffffff;
}

.ai-curr-checkbox input:checked+.ai-curr-pill,
.ai-curr-checkbox input:checked~.ai-curr-pill {
    border-color: var(--active-color) !important;
    color: var(--active-color);
    background-color: transparent;
}

.ai-curr-pill-mobile {
    width: 44px;
    height: 44px;
    padding: 0 !important;
}

.ai-filter-input:focus,
select.form-select.ai-filter-input:focus,
.ts-wrapper.ai-filter-input.focus .ts-control,
.ts-wrapper.ai-filter-input.dropdown-active .ts-control,
.ai-filter-active+.ts-wrapper .ts-control {
    border-color: var(--ai-primary) !important;
    outline: none !important;
    box-shadow: 0 0 0 1px var(--ai-primary), 0 0 0 3px var(--ai-primary-light) !important;
    transform: none !important;
    caret-color: var(--ai-primary) !important;
    /* Brand-colored cursor on iOS */
}

/* -- Searchable Table Filter Dropdowns (ai-filter-search) ------------------ */
.ts-wrapper.ai-filter-search {
    width: 100%;
    height: auto !important;
    min-width: 110px;
}

.ts-wrapper.ai-filter-search.single .ts-control {
    background-color: var(--ai-input-bg) !important;
    border: 1px solid var(--ai-border) !important;
    border-radius: 50px !important;
    color: var(--ai-text) !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 0 2rem 0 0.85rem !important;
    line-height: 36px !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06), inset 0 1px 2px rgba(0, 0, 0, 0.02);
    display: flex !important;
    align-items: center !important;
}

.ts-wrapper.ai-filter-search.single .ts-control>input {
    color: var(--ai-text) !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    height: 36px !important;
    line-height: 36px !important;
    padding: 0 !important;
    margin: 0 !important;
}

.ts-wrapper.ai-filter-search.single .ts-control .item {
    color: var(--ai-text) !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    line-height: 36px !important;
    margin: 0 !important;
    padding: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.ts-wrapper.ai-filter-search.focus .ts-control,
.ts-wrapper.ai-filter-search.dropdown-active .ts-control {
    border-color: var(--ai-primary) !important;
    outline: none !important;
    box-shadow: 0 0 0 1px var(--ai-primary), 0 0 0 3px var(--ai-primary-light) !important;
}

:root.light-mode .ts-wrapper.ai-filter-search.single .ts-control {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04), inset 0 1px 2px rgba(0, 0, 0, 0.01);
}

/* -- Compact Date Filter Button (filter row) -------------------------------- */
.ai-date-filter-wrap {
    position: relative;
    width: 100%;
}

.ai-filter-cal-btn {
    display: flex !important;
    align-items: center !important;
    gap: 5px;
    cursor: pointer !important;
    white-space: nowrap;
    overflow: hidden;
    text-align: left;
}

.ai-filter-cal-btn .ai-cal-icon {
    font-size: 0.8rem;
    color: var(--ai-text-muted);
    flex-shrink: 0;
}

.ai-filter-cal-btn .ai-cal-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.ai-filter-cal-btn .ai-cal-clear {
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: color 0.15s;
    margin-left: 2px;
    line-height: 1;
}

.ai-filter-cal-btn .ai-cal-clear:hover {
    color: var(--ai-danger) !important;
}

.ai-filter-cal-btn.ai-cal-active {
    border-color: var(--ai-primary) !important;
    color: var(--ai-primary) !important;
    background: var(--ai-primary-light) !important;
}

.ai-filter-cal-btn.ai-cal-active .ai-cal-icon {
    color: var(--ai-primary) !important;
}

:root.light-mode .ai-filter-cal-btn.ai-cal-active {
    background: rgba(233, 30, 140, 0.06) !important;
}

/* -- Custom Vanilla Dropdown (filter-row selects) --------------------------- */
.ai-select {
    position: relative;
    display: inline-block;
    width: auto;
}
.ai-select.open {
    z-index: 2000 !important;
}

.ai-select-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
    min-width: 90px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%), #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 50px !important;
    color: var(--ai-text);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0 14px 0 16px;
    min-height: 38px !important;
    height: 38px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
    white-space: nowrap;
    user-select: none;
    text-align: left;
}

/* Expand to fill parent when wrapper has explicit width class */
.ai-select.w-100 .ai-select-btn,
.ai-select.flex-grow-1 .ai-select-btn {
    width: 100%;
}

.ai-select-btn span {
    text-align: left;
    display: inline-block;
    flex: 0 0 auto;
    white-space: nowrap;
}

.ai-select-btn:hover {
    border-color: var(--ai-primary) !important;
    background: rgba(var(--ai-primary-rgb), 0.04) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(var(--ai-primary-rgb), 0.1) !important;
}

.ai-select.open .ai-select-btn,
.ai-select.ai-filter-active .ai-select-btn {
    border-color: var(--ai-primary) !important;
    box-shadow: 0 0 0 1px var(--ai-primary), 0 0 0 3px var(--ai-primary-light) !important;
}

.ai-select-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    opacity: 0.5;
}

.ai-select.open .ai-select-chevron {
    transform: rotate(180deg);
}

/* Elevate parent containers when a dropdown is open */
th.ai-dropdown-open,
.ai-filter-col.ai-dropdown-open {
    z-index: 1000 !important;
    position: relative !important;
}

.ts-wrapper.dropdown-active {
    z-index: 1000 !important;
}

:root.light-mode .ai-select-btn {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #64748b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* Dropdown panel */
.ai-select-panel {
    display: none;
    min-width: 100%;
    background-color: var(--ai-calendar-bg);
    border: 1px solid var(--ai-border);
    border-radius: 14px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    overflow: hidden;
    padding: 6px 0;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    animation: aiSelectFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-select.open .ai-select-panel {
    display: block;
}

@keyframes aiSelectFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

:root.light-mode .ai-select-panel {
    background-color: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Options */
.ai-select-option {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ai-text);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.4;
}

.ai-select-option:hover {
    background-color: rgba(233, 30, 140, 0.08);
    color: var(--ai-primary);
}

.ai-select-option.selected {
    background-color: rgba(233, 30, 140, 0.12);
    color: var(--ai-primary);
    font-weight: 700;
}

:root.light-mode .ai-select-option {
    color: #334155;
}

:root.light-mode .ai-select-option:hover {
    background-color: rgba(233, 30, 140, 0.06);
    color: var(--ai-primary);
}

:root.light-mode .ai-select-option.selected {
    background-color: rgba(233, 30, 140, 0.1);
    color: var(--ai-primary);
}

/* Compact variant for sort-only dropdowns inside flex forms */
.ai-select-compact {
    width: auto !important;
    flex: 0 0 auto !important;
}

.ai-select-compact .ai-select-btn {
    min-width: 70px;
    width: auto;
}

/* Hide the native select when replaced */
.ai-filter-row select.ai-filter-input {
    display: none !important;
}

/* -- Custom Dropdown Integration (TomSelect) overrides -- */
.ts-wrapper.ai-filter-input {
    padding: 0 !important;
    min-height: 38px;
    height: auto !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

.ts-wrapper.ai-filter-input .ts-control {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 100%), var(--ai-input-bg) !important;
    border: 1px solid var(--ai-border) !important;
    border-radius: 50px !important;
    color: var(--ai-text) !important;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0 2.2rem 0 0.8rem !important;
    width: 100%;
    min-width: 110px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), inset 0 1px 0 0 rgba(255, 255, 255, 0.05) !important;
    min-height: 38px !important;
    height: 38px !important;
    max-height: 38px !important;
    line-height: 36px !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    transition: border-color 0.2s;
    position: relative;
    z-index: 1;
}

.ts-wrapper.ai-filter-input .ts-control .item {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    display: block !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

/* Ensure the input doesn't push the content or grow the pill unnecessarily WHEN an item is selected */
.ts-wrapper.ai-filter-input.has-items .ts-control>input {
    position: absolute !important;
    opacity: 0 !important;
    width: 0 !important;
    min-width: 0 !important;
}

/* Allow input to be visible for placeholder text when NO item is selected */
.ts-wrapper.ai-filter-input:not(.has-items) .ts-control>input {
    position: relative !important;
    opacity: 1 !important;
    width: 100% !important;
}

.ts-wrapper.ai-filter-input .ts-control>input::placeholder {
    color: var(--ai-text-muted) !important;
    opacity: 0.7 !important;
}

/* Allow search input to be visible but NOT grow the pill beyond the current item's width */
.ts-wrapper.ai-filter-input.ai-filter-search.dropdown-active .ts-control>input {
    position: absolute !important;
    left: 0.8rem !important;
    right: 2.2rem !important;
    opacity: 1 !important;
    width: auto !important;
    display: block !important;
}

/* Hide the selected item text when searching to avoid overlap with the input, but keep its space to maintain width */
.ts-wrapper.ai-filter-input.ai-filter-search.dropdown-active.ts-focus .ts-control .item {
    display: block !important;
    color: transparent !important;
}

:root.light-mode .ts-wrapper.ai-filter-input .ts-control {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
}

/* .ts-wrapper.ai-filter-input .ts-dropdown inherits all styles from the
   unified .ts-dropdown block above. Only add overrides that are truly unique. */
.ts-wrapper.ai-filter-input .ts-dropdown {
    margin-top: 5px;
}

/* -- Mobile Filter Refinements ---------------------------------------------- */
@media (max-width: 768px) {

    /* Prevent auto-zoom on focus by ensuring font-size is at least 16px for ALL inputs */
    .ts-wrapper.ai-filter-input .ts-control,
    .ts-wrapper.ai-filter-input .ts-control input,
    .ai-filter-input {
        font-size: 16px !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        height: 39px !important;
        min-height: 39px !important;
        -webkit-appearance: none;
        appearance: none;
    }

    .form-control,
    .form-select,
    .ai-login-card .form-control,
    .ai-search-input,
    textarea {
        font-size: 16px !important;
        /* Prevent iOS Safari from auto-zooming on input focus */
        -webkit-appearance: none;
        appearance: none;
    }

    /* Fix vertical alignment for TomSelect */
    .ts-wrapper.ai-filter-input .ts-control {
        display: flex !important;
        align-items: center !important;
        padding-left: 0.85rem !important;
    }

    /* Ensure action badges (Project count pills) match height */
    .ai-badge-outline-pill {
        height: 26px !important;
        display: inline-flex !important;
        align-items: center !important;
        padding: 0 10px !important;
    }


    /* Filter Dropdowns: Open underneath (desktop-style) instead of screen-centered */
    .ts-wrapper.ai-filter-input .ts-dropdown {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        transform: none !important;
        width: 100% !important;
        min-width: 180px !important;
        max-height: 300px !important;
        margin-top: 5px !important;
        z-index: 10001 !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
        display: none;
    }

    /* Layout Dropdown: Open underneath but keep centered horizontally */
    .ai-layout-container .dropdown-menu {
        position: absolute !important;
        top: calc(100% + 10px) !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 92vw !important;
        max-width: 340px !important;
        max-height: 70vh !important;
        z-index: 10001 !important;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5) !important;
        display: none;
    }

    .ts-wrapper.ai-filter-input.dropdown-active .ts-dropdown,
    .ai-layout-container.dropdown-open .dropdown-menu,
    .ai-layout-container .dropdown.show .dropdown-menu {
        display: block !important;
    }

    /* Transparent Mobile Backdrop */
    .ai-mobile-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: transparent !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        z-index: 1025;
    }

    /* Show backdrop when a dropdown is active */
    body.dropdown-open .ai-mobile-backdrop {
        display: block;
    }

    /* Ensure the centering works for the specific Layout container */
    .ai-layout-container .dropdown-menu {
        border-radius: 12px !important;
        border: 1px solid var(--ai-border) !important;
        background-color: var(--ai-card-bg) !important;
        padding: 1rem !important;
        right: auto !important;
        bottom: auto !important;
    }
}

/* ======================================================
   Clients Table &mdash; Scoped scroll, design & responsive
   ====================================================== */

/* 1. Contain the table inside the card &mdash; table-responsive is the sole scroll container */
#table-card {
    overflow: visible;
    /* Clip content to rounded card corners, stop table spilling out */
}

#table-card .ai-card-body.p-0 {
    overflow: hidden !important;
    /* Let table-responsive handle all horizontal scroll */
}

#table-card .table-responsive {
    overflow-x: auto !important;
    scrollbar-width: none !important;
    /* Hide native &mdash; use custom below */
    -ms-overflow-style: none !important;
    /* Remove the scroll-edge gradient &mdash; it fades the tfoot row to white as you scroll */
    background: var(--ai-card-bg) !important;
}

#table-card .table-responsive::-webkit-scrollbar {
    height: 8px;
}

#table-card .table-responsive::-webkit-scrollbar-track {
    background: transparent;
}

#table-card .table-responsive::-webkit-scrollbar-thumb {
    background: rgba(var(--ai-primary-rgb), 0.3);
    border-radius: 4px;
}

#table-card .table-responsive::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--ai-primary-rgb), 0.5);
}

/* Status bar and scrollbar strip sit outside the scroll pane &mdash; keep them full width */
#table-card .clients-scrollbar-outer,
#table-card .ai-table-status-bar {
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

#table-card .ai-table-status-bar {
    position: -webkit-sticky;
    position: sticky;
    left: 0;
    width: 100%;
    box-sizing: border-box;
}



/* Identifying Icon Badges (Table context) */
.ai-table-icon-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--ai-primary-rgb), 0.1);
    color: var(--ai-primary);
    font-size: 1rem;
    flex-shrink: 0;
    transition: var(--ai-transition);
}

.ai-table-icon-badge.secondary {
    background: rgba(var(--ai-secondary-rgb), 0.1);
    color: var(--ai-secondary);
}

.ai-table-icon-badge.warning {
    background: rgba(255, 165, 2, 0.1);
    color: var(--ai-warning);
}

/* Pink Header Badge Logic */
.ai-th-badge-pink {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}

:root.light-mode .ai-th-badge-pink {
    background: rgba(var(--ai-primary-rgb), 0.1);
    color: var(--ai-primary);
}

/* Body column cell sizing & clipping */
.ai-table td.ai-col-company,
.ai-table td.ai-col-client,
.ai-table td.ai-col-name,
.ai-table td.ai-col-contact,
.ai-table td.ai-col-address,
.ai-table td.ai-col-currencies,
.ai-table td.ai-col-projects,
.ai-table td.ai-col-date {
    max-width: 260px;
    min-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 1400px) {

    .ai-table td.ai-col-company,
    .ai-table td.ai-col-client,
    .ai-table td.ai-col-name,
    .ai-table td.ai-col-project,
    .ai-table td.ai-col-user,
    .ai-table td.ai-col-title,
    .ai-table td.ai-col-contact,
    .ai-table td.ai-col-address,
    .ai-table td.ai-col-currencies,
    .ai-table td.ai-col-projects {
        min-width: 200px !important;
        max-width: 420px !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.ai-table tbody td.ai-col-company strong,
.ai-table tbody td.ai-col-client strong,
.ai-table tbody td.ai-col-client .ai-client-name,
.ai-table tbody td.ov-td-name .ai-client-name,
.ai-table tbody td.ai-col-name strong,
.ai-table tbody td.ai-col-project strong,
.ai-table tbody td.ai-col-project .ai-client-name,
.ai-table tbody td.ai-col-user strong,
.ai-table tbody td.ai-col-user .ai-client-name,
.ai-table tbody td.ai-col-title strong,
.ai-table tbody td.ai-col-title .ai-client-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
}

/* 4. Filter row sticky column &mdash; must NOT inherit the pink header */
#table-card .ai-table thead tr.ai-filter-row th.ai-col-company,
#table-card .ai-table thead tr.ai-filter-row th.ai-col-client,
#table-card .ai-table thead tr.ai-filter-row th.ai-col-name,
#table-card .ai-table thead tr.ai-filter-row th.ai-col-date,
#table-card .ai-table thead tr.ai-filter-row th.ai-col-user,
#table-card .ai-table thead tr.ai-filter-row th.ai-col-project,
#table-card .ai-table thead tr.ai-filter-row th.ai-col-title {
    background: var(--ai-card-bg) !important;
    color: var(--ai-text) !important;
    border-top: 1px solid var(--ai-border) !important;
}

:root.light-mode #table-card .ai-table thead tr.ai-filter-row th.ai-col-company,
:root.light-mode #table-card .ai-table thead tr.ai-filter-row th.ai-col-client,
:root.light-mode #table-card .ai-table thead tr.ai-filter-row th.ai-col-name,
:root.light-mode #table-card .ai-table thead tr.ai-filter-row th.ai-col-date,
:root.light-mode #table-card .ai-table thead tr.ai-filter-row th.ai-col-user,
:root.light-mode #table-card .ai-table thead tr.ai-filter-row th.ai-col-project,
:root.light-mode #table-card .ai-table thead tr.ai-filter-row th.ai-col-title {
    background: #ffffff !important;
    color: var(--ai-text) !important;
    border-top: 1px solid var(--ai-border) !important;
}

/* 5. Custom scrollbar - card background, standard thumb */
.ai-custom-scroll-outer,
.clients-scrollbar-outer {
    box-sizing: border-box;
    background: var(--ai-card-bg);
    border-bottom: 1px solid var(--ai-border);
    z-index: 50;
}

.ai-custom-scroll-track,
.clients-scrollbar-track {
    overflow-x: auto;
    overflow-y: hidden;
    height: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.25) rgba(255,255,255,0.05);
}

:root.light-mode .ai-custom-scroll-track,
:root.light-mode .clients-scrollbar-track {
    scrollbar-color: rgba(0,0,0,0.3) rgba(0,0,0,0.06);
}

.ai-custom-scroll-track::-webkit-scrollbar,
.clients-scrollbar-track::-webkit-scrollbar {
    height: 10px;
}

.ai-custom-scroll-track::-webkit-scrollbar-track,
.clients-scrollbar-track::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
}

:root.light-mode .ai-custom-scroll-track::-webkit-scrollbar-track,
:root.light-mode .clients-scrollbar-track::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.06);
}

.ai-custom-scroll-track::-webkit-scrollbar-thumb,
.clients-scrollbar-track::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.25);
    border-radius: 10px;
}

:root.light-mode .ai-custom-scroll-track::-webkit-scrollbar-thumb,
:root.light-mode .clients-scrollbar-track::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.3);
}

.ai-custom-scroll-track::-webkit-scrollbar-thumb:hover,
.clients-scrollbar-track::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.45);
}

:root.light-mode .ai-custom-scroll-track::-webkit-scrollbar-thumb:hover,
:root.light-mode .clients-scrollbar-track::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.5);
}

.ai-custom-scroll-spacer,
.clients-scrollbar-spacer {
    height: 1px;
    background: transparent;
}

/* Sorting Header Styles */
.ai-table thead th.ai-sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.ai-table thead th.ai-sortable:hover {
    background: rgba(var(--ai-primary-rgb), 0.1) !important;
}

.ai-sort-indicator {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    vertical-align: middle;
    opacity: 0.3;
    transition: opacity 0.2s ease;
}

.ai-sortable:hover .ai-sort-indicator {
    opacity: 0.6;
}

.ai-sortable.active .ai-sort-indicator {
    opacity: 1;
    color: var(--ai-primary);
}

.ai-sort-indicator i {
    font-size: 0.7rem;
    line-height: 0.6;
}

.ai-sort-indicator i.bi-caret-up-fill {
    margin-bottom: -2px;
}

.ai-sort-indicator i.bi-caret-down-fill {
    margin-top: -2px;
}

/* Table responsiveness overrides for custom scrollbar */
.table-responsive {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

.table-responsive::-webkit-scrollbar {
    display: none !important;
}

/* ======================================================
   Clients Table &mdash; Responsive ≤768px
   ====================================================== */
@media (max-width: 767.98px) {

    /* Card header: tighten spacing */
    #table-card .ai-card-header {
        padding: 10px 12px !important;
        gap: 10px !important;
    }

    /* Title row: allow wrap if needed */
    #table-card .ai-card-header>div:first-child {
        min-width: 0 !important;
        flex-wrap: wrap;
    }

    /* Search: full width */
    #table-card .ai-table-search {
        max-width: 100%;
    }

    /* Status bar: tighter padding */
    #table-card .ai-table-status-bar {
        padding: 8px 12px !important;
        gap: 4px;
    }

    /* Actions column: tighten */
    #clients-table td:last-child .d-flex {
        gap: 2px !important;
    }

    #clients-table .btn-sm {
        padding: 3px 6px !important;
    }
}

/* ======================================================
   Clients Table &mdash; Responsive ≤480px
   ====================================================== */
@media (max-width: 479.98px) {

    /* Card header: stack title + search + layout vertically */
    #table-card .ai-card-header {
        padding: 8px 10px !important;
        gap: 8px !important;
    }

    /* Sync button: icon only */
    #table-card .ai-sync-btn span {
        display: none;
    }

    /* Record count under title */
    #table-card .ai-record-count {
        font-size: 0.65rem;
    }

    /* Table cells */
    #clients-table thead th,
    #clients-table tbody td {
        padding: 8px 10px !important;
        font-size: 0.78rem !important;
    }

    /* Company column: slightly narrower */
    #clients-table .ai-col-company {
        min-width: 130px !important;
        max-width: 150px !important;
    }

    /* Filter row selects */
    /* Filter row selects - removed overrides to maintain global parity */

    /* Status bar: stack, center everything */
    #table-card .ai-table-status-bar {
        flex-direction: column !important;
        align-items: center !important;
        padding: 8px 10px !important;
        gap: 6px !important;
        text-align: center;
    }

    #table-card .ai-table-status-bar>div {
        margin-top: 0 !important;
    }
}

/* ======================================================
   Clients Table &mdash; Responsive ≤399px (320px target)
   ====================================================== */
@media (max-width: 399.98px) {

    /* Card header: ultra compact */
    #table-card .ai-card-header {
        padding: 6px 8px !important;
        gap: 6px !important;
    }

    /* Title: tighten */
    #table-card .ai-card-header h5 {
        font-size: 0.9rem !important;
    }

    /* Badge icon: shrink */
    #table-card .ai-badge-icon {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.85rem !important;
        margin-right: 8px !important;
    }

    /* Search: minimal padding */
    #table-card .ai-search-input {
        font-size: 0.8rem !important;
        padding: 7px 10px 7px 36px !important;
    }

    /* Layout button: no longer hiding label as it stacks in its own row */
    /* Table: smallest comfortable cells */
    #clients-table thead th,
    #clients-table tbody td {
        padding: 6px 8px !important;
        font-size: 0.72rem !important;
    }

    /* Company column: minimal to leave more room for actions */
    #clients-table .ai-col-company {
        min-width: 100px !important;
        max-width: 120px !important;
    }

    /* Action buttons: icon only, tiny, and perfectly centered */
    #clients-table .btn-sm,
    #clients-table button[title*="QuickBooks"] {
        width: 26px !important;
        height: 26px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0.72rem !important;
        flex-shrink: 0;
    }

    #clients-table button[title*="QuickBooks"] img {
        width: 16px !important;
        height: 16px !important;
    }

    /* Refine Layout button internal alignment */
    .ai-layout-btn {
        gap: 6px !important;
        padding: 0 12px !important;
    }

    /* Pagination: compact */
    #table-card .ai-pagination .page-link {
        min-width: 28px !important;
        height: 28px !important;
        font-size: 0.72rem !important;
        padding: 0 6px !important;
    }

    /* Showing X of Y: smaller */
    #table-card .ai-table-status-bar span {
        font-size: 0.72rem !important;
    }

    /* Tfoot "Bottom of list": smaller text */
    #clients-table tfoot small {
        font-size: 0.58rem !important;
    }

    /* Scrollbar: thinner on small screens */
    .clients-scrollbar-track {
        height: 5px !important;
    }

    .clients-scrollbar-track::-webkit-scrollbar {
        height: 5px !important;
    }
}

/* ==========================================================================
   Hybrid Textarea (from footer.php)
   ========================================================================== */
.ai-textarea-hybrid-wrap {
    position: relative;
    width: 100%;
}

.ai-textarea-hybrid {
    height: 140px;
    overflow-y: auto;
    transition: height 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    resize: none !important;
    padding-right: 35px !important;
}

.ai-textarea-hybrid-wrap.expanded .ai-textarea-hybrid {
    overflow: hidden !important;
}

.ai-textarea-expand-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(var(--ai-primary-rgb), 0.1);
    border: 1px solid rgba(var(--ai-primary-rgb), 0.2);
    color: var(--ai-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    z-index: 5;
    transition: all 0.2s ease;
}

.ai-textarea-expand-btn:hover {
    background: var(--ai-primary);
    color: #fff;
}

/* ==========================================================================
   TinyMCE / Wiki Editor (from wiki.php)
   ========================================================================== */
.tox {
    --tox-primary-color: var(--ai-primary) !important;
    --tox-primary-color-hover: var(--ai-primary-dark) !important;
    --tox-button-background-color: var(--ai-primary) !important;
    --tox-button-background-color-hover: var(--ai-primary-dark) !important;
    --tox-tbtn-bg-hover: rgba(var(--ai-primary-rgb), 0.1) !important;
    --tox-tbtn-color-hover: var(--ai-primary) !important;
    --tox-color-info: var(--ai-primary) !important;
    --tox-color-secondary: var(--ai-primary) !important;
}

/* overflow: visible so toolbar dropdown menus can escape the container */
.tox-tinymce {
    border: 1px solid var(--ai-border) !important;
    border-radius: 10px !important;
    overflow: visible !important;
    background: var(--ai-card-bg) !important;
    position: relative !important;
}

.tox.tox-tinymce-aux {
    position: absolute !important;
    z-index: 12000 !important;
}

#wiki-form-container {
    position: relative !important;
}

/* Wiki sidebar meta card: skip nested .ai-card entrance (avoid double ease / stagger on left column) */
#wiki-form-container #mainAddEditForm > .col-lg-3 > .ai-card {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}

/* Wiki project Tom Select — dropdown is position:fixed on body; scope by .ts-option-stack only */
.ts-dropdown .ts-option-stack {
    display: block;
}

.ts-dropdown .ts-option-title {
    display: block;
    font-weight: 700;
    line-height: 1.25;
}

.ts-dropdown .ts-option-sub {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--ai-text-muted);
    margin-top: 4px;
    line-height: 1.3;
}

.ts-dropdown .option:hover .ts-option-sub,
.ts-dropdown .option.active .ts-option-sub {
    color: var(--ai-primary);
    opacity: 0.92;
}

:root.light-mode .ts-dropdown .ts-option-sub {
    color: #64748b;
}

:root.light-mode .ts-dropdown .option:hover .ts-option-sub,
:root.light-mode .ts-dropdown .option.active .ts-option-sub {
    color: var(--ai-primary);
}

.tox .tox-editor-header {
    border-radius: 10px 10px 0 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
}

.tox .tox-toolbar-overlord,
.tox .tox-toolbar__primary,
.tox .tox-toolbar__overflow {
    background: var(--ai-input-bg) !important;
    border-bottom: 1px solid var(--ai-border) !important;
}

.tox .tox-statusbar {
    border-top: 1px solid var(--ai-border) !important;
    border-radius: 0 0 10px 10px !important;
    overflow: hidden !important;
    background: var(--ai-input-bg) !important;
}

.tox .tox-statusbar__path-item,
.tox .tox-statusbar__wordcount {
    color: var(--ai-text-muted) !important;
}

.tox .tox-tbtn {
    color: var(--ai-text) !important;
}

.tox .tox-tbtn--disabled,
.tox .tox-tbtn--disabled svg {
    color: var(--ai-text-muted) !important;
    fill: var(--ai-text-muted) !important;
    opacity: 0.5;
}

.tox .tox-tbtn svg {
    fill: var(--ai-text) !important;
}

.tox .tox-tbtn:hover {
    background: rgba(var(--ai-primary-rgb), 0.1) !important;
    color: var(--ai-primary) !important;
}

.tox .tox-tbtn--enabled,
.tox .tox-tbtn--enabled:hover {
    background: rgba(var(--ai-primary-rgb), 0.15) !important;
    color: var(--ai-primary) !important;
}

.tox .tox-tbtn--enabled svg,
.tox .tox-tbtn:hover svg {
    fill: var(--ai-primary) !important;
}

/* Style the font-family / font-size select buttons in the toolbar */
.tox .tox-tbtn--select {
    border: 1px solid var(--ai-border) !important;
    border-radius: 6px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    margin: 0 2px !important;
}

:root.light-mode .tox .tox-tbtn--select {
    background: rgba(0, 0, 0, 0.04) !important;
}

.tox .tox-tbtn__select-label {
    color: var(--ai-text) !important;
    font-size: 0.8rem !important;
}

.tox .tox-edit-area__iframe {
    border-radius: 0 0 10px 10px !important;
}

/* ── Toolbar dropdown menus (font family, font size, etc.) ── */
.tox-menu,
.tox-tiered-menu {
    background-color: var(--ai-card-bg) !important;
    border: 1px solid var(--ai-border) !important;
    border-radius: 10px !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04) !important;
    max-height: 400px !important;
    overflow-y: auto !important;
    scrollbar-width: thin !important;
    z-index: 3000 !important;
    /* no animation — transform-based entry causes page shake */
    animation: none !important;
}

:root.light-mode .tox-menu,
:root.light-mode .tox-tiered-menu {
    background-color: #fff !important;
    border-color: #dee2e6 !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12) !important;
}

.tox-menu .tox-collection__item,
.tox-tiered-menu .tox-collection__item {
    color: var(--ai-text) !important;
    border-radius: 6px !important;
    margin: 1px 4px !important;
    transition: background 0.12s !important;
}

.tox-menu .tox-collection__item:hover,
.tox-menu .tox-collection__item--active,
.tox-tiered-menu .tox-collection__item:hover,
.tox-tiered-menu .tox-collection__item--active {
    background-color: rgba(var(--ai-primary-rgb), 0.1) !important;
    color: var(--ai-primary) !important;
}

.tox-menu .tox-collection__item-label,
.tox-tiered-menu .tox-collection__item-label {
    color: inherit !important;
}

/* ── TinyMCE Dialogs — match app modal backdrop ── */
.tox-dialog-wrap {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 12000 !important;
}

.tox-dialog-wrap__backdrop {
    background-color: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
}

.tox-dialog {
    background-color: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 14px !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25) !important;
    overflow: hidden !important;
    position: relative !important;
    animation: toxModalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
    max-width: min(92vw, 400px) !important;
    width: 400px !important;
}

:root.light-mode .tox-dialog {
    background-color: #ffffff !important;
    border-color: #dee2e6 !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15) !important;
}

@keyframes toxModalIn {
    from {
        transform: translateY(16px) scale(0.97);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Remove old accent bar — header gradient replaces it */
.tox-dialog::before { display: none !important; }

/* ── Dialog header — gradient style ── */
.tox-dialog__header {
    background: linear-gradient(135deg, #e91e63 0%, #c2185b 100%) !important;
    border-bottom: none !important;
    color: #fff !important;
    padding: 14px 18px !important;
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

:root.light-mode .tox-dialog__header {
    background: linear-gradient(135deg, #e91e63 0%, #c2185b 100%) !important;
    border-bottom: none !important;
}

/* Icon circle before the title */
.tox-dialog__header::before {
    content: '\F3E0';
    font-family: "bootstrap-icons" !important;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.95rem;
}

.tox-dialog__title {
    color: #fff !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    margin: 0 !important;
    line-height: 1.3 !important;
    flex: 1;
}

:root.light-mode .tox-dialog__title {
    color: #fff !important;
}

/* Close button — white style on gradient */
.tox-dialog .tox-dialog__header .tox-button[aria-label="Close"],
.tox-dialog .tox-dialog__header .tox-button--icon,
.tox-dialog .tox-dialog__close {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    color: #fff !important;
    transition: all 0.2s !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    min-width: unset !important;
    transform: none !important;
}

.tox-dialog .tox-dialog__header .tox-button[aria-label="Close"]:hover,
.tox-dialog .tox-dialog__header .tox-button--icon:hover,
.tox-dialog .tox-dialog__close:hover {
    background: rgba(255, 255, 255, 0.22) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    color: #fff !important;
    transform: none !important;
}


/* ── Dialog body & content ── */
.tox-dialog__content-js,
.tox-dialog__body {
    background-color: #ffffff !important;
    color: #212529 !important;
    display: flex !important;
    flex: 1 !important;
    min-height: 0 !important;
}

:root.light-mode .tox-dialog__content-js,
:root.light-mode .tox-dialog__body {
    background-color: #ffffff !important;
    color: #212529 !important;
}

.tox-dialog__body-content {
    background-color: #ffffff !important;
    padding: 20px !important;
    flex: 1 !important;
    overflow-y: auto !important;
}

:root.light-mode .tox-dialog__body-content {
    background-color: #ffffff !important;
}

/* ── Dialog sidebar nav (emoji categories, image tabs) ── */
.tox-dialog__body-nav {
    background-color: #ffffff !important;
    border-right: 1px solid #f1f3f5 !important;
    padding: 10px 6px !important;
    min-width: 130px !important;
    display: flex !important;
    flex-direction: column !important;
}

:root.light-mode .tox-dialog__body-nav {
    background-color: #ffffff !important;
    border-color: #f1f3f5 !important;
}

.tox-dialog__body-nav-item {
    color: var(--ai-text-muted) !important;
    font-size: 0.7rem !important;
    text-transform: uppercase !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px !important;
    padding: 8px 10px !important;
    border-radius: 6px !important;
    border-bottom: none !important;
    cursor: pointer !important;
    transition: background 0.15s, color 0.15s !important;
    width: 100% !important;
}

.tox-dialog__body-nav-item:hover {
    background: rgba(var(--ai-primary-rgb), 0.08) !important;
    color: var(--ai-primary) !important;
}

.tox-dialog__body-nav-item--active {
    color: var(--ai-primary) !important;
    background: rgba(var(--ai-primary-rgb), 0.12) !important;
    border-bottom: none !important;
}

:root.light-mode .tox-dialog__body-nav-item {
    color: #6c757d !important;
}

/* ── Emoji grid ── */
.tox-collection--grid {
    background-color: #ffffff !important;
    padding: 6px !important;
}

:root.light-mode .tox-collection--grid {
    background-color: #fff !important;
}

.tox-collection--grid .tox-collection__item {
    border-radius: 6px !important;
    transition: background 0.12s, transform 0.12s !important;
}

.tox-collection--grid .tox-collection__item:hover {
    background-color: rgba(var(--ai-primary-rgb), 0.1) !important;
    transform: scale(1.15) !important;
}

/* ── Category list (emoji picker left panel) ── */
.tox-collection--list {
    background-color: transparent !important;
}

.tox-collection--list .tox-collection__item {
    color: var(--ai-text-muted) !important;
    font-size: 0.7rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    font-weight: 700 !important;
    border-radius: 6px !important;
    padding: 7px 10px !important;
    transition: background 0.12s, color 0.12s !important;
    background: transparent !important;
}

.tox-collection--list .tox-collection__item:hover {
    background-color: rgba(var(--ai-primary-rgb), 0.08) !important;
    color: var(--ai-primary) !important;
}

.tox-collection--list .tox-collection__item--active,
.tox-collection--list .tox-collection__item--enabled {
    color: var(--ai-primary) !important;
    background-color: rgba(var(--ai-primary-rgb), 0.12) !important;
}

:root.light-mode .tox-collection--list .tox-collection__item {
    color: #6c757d !important;
}

/* ── Dialog footer ── */
.tox-dialog__footer {
    background-color: #ffffff !important;
    border-top: 1px solid #f1f3f5 !important;
    padding: 12px 20px !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 8px !important;
}

:root.light-mode .tox-dialog__footer {
    background-color: #ffffff !important;
    border-color: #f1f3f5 !important;
}

/* ── Dialog buttons ── */
.tox-button {
    background-color: var(--ai-primary) !important;
    border: none !important;
    border-radius: 50px !important;
    padding: 7px 20px !important;
    font-weight: 700 !important;
    font-size: 0.85rem !important;
    color: #fff !important;
    transition: all 0.2s ease !important;
}

.tox-button:hover {
    background-color: var(--ai-primary-dark) !important;
    border-color: var(--ai-primary-dark) !important;
    transform: translateY(-1px);
}

.tox-button--secondary {
    background-color: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    color: #475569 !important;
    border-radius: 50px !important;
    padding: 7px 20px !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    transition: var(--ai-transition) !important;
}

.tox-button--secondary:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--ai-text) !important;
    border-color: var(--ai-text-muted) !important;
}

:root.light-mode .tox-button--secondary:hover {
    background-color: rgba(0, 0, 0, 0.04) !important;
}

/* ── Form fields inside dialogs ── */
.tox-textfield,
.tox-textarea,
.tox-selectfield select,
.tox-listboxfield .tox-listbox {
    background-color: var(--ai-input-bg) !important;
    border: 1px solid var(--ai-border) !important;
    border-radius: 8px !important;
    color: var(--ai-text) !important;
    padding: 8px 12px !important;
    transition: border-color 0.15s, box-shadow 0.15s !important;
}

.tox-textfield:focus,
.tox-textarea:focus,
.tox-selectfield select:focus {
    border-color: var(--ai-primary) !important;
    box-shadow: 0 0 0 3px rgba(var(--ai-primary-rgb), 0.15) !important;
    outline: none !important;
}

:root.light-mode .tox-textfield,
:root.light-mode .tox-textarea,
:root.light-mode .tox-selectfield select,
:root.light-mode .tox-listboxfield .tox-listbox {
    background-color: #fff !important;
    border-color: #dee2e6 !important;
    color: #212529 !important;
}

.tox-label {
    color: var(--ai-text-muted) !important;
    font-size: 0.72rem !important;
    text-transform: uppercase !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 4px !important;
}

:root.light-mode .tox-label {
    color: #6c757d !important;
}

/* Browse / upload button in image dialog */
.tox-browse-url {
    background-color: var(--ai-primary) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 8px 14px !important;
    transition: background 0.2s !important;
}

.tox-browse-url:hover {
    background-color: var(--ai-primary-dark) !important;
}

/* Lock-aspect-ratio button */
.tox-lock-btn {
    background-color: rgba(var(--ai-primary-rgb), 0.1) !important;
    border: 1px solid rgba(var(--ai-primary-rgb), 0.25) !important;
    border-radius: 8px !important;
    color: var(--ai-primary) !important;
}

.tox-lock-btn svg {
    fill: var(--ai-primary) !important;
}

/* Form group spacing */
.tox-form__group {
    margin-bottom: 14px !important;
}

/* Wiki Content Styles */
.wiki-content img[style*="float: left"],
.wiki-content .image-align-left {
    float: left;
    margin: 0 1.5em 1em 0;
}

.wiki-content img[style*="float: right"],
.wiki-content .image-align-right {
    float: right;
    margin: 0 0 1em 1.5em;
}

.wiki-content img[style*="margin: 0px auto"],
.wiki-content .image-align-center {
    display: block;
    margin: 1em auto;
}

.wiki-content::after {
    content: '';
    display: table;
    clear: both;
}

.wiki-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.wiki-content td,
.wiki-content th {
    border: 1px solid var(--ai-border);
    padding: 8px 12px;
    vertical-align: top;
}

.wiki-content th {
    background: #252525;
    /* Solid dark background */
    font-weight: 600;
}

:root.light-mode .wiki-content th {
    background: #f1f5f9;
    /* Solid light background */
}

.wiki-content pre {
    background: var(--ai-input-bg);
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    padding: 1.5rem;
    overflow-x: auto;
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.9rem;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.1);
}

.wiki-content blockquote {
    border-left: 4px solid var(--ai-primary);
    margin: 2rem 0;
    padding: 1.5rem 2rem;
    color: var(--ai-text);
    background: rgba(var(--ai-primary-rgb), 0.03);
    border-radius: 0 16px 16px 0;
    font-style: italic;
    font-size: 1.1rem;
}

.wiki-content table {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--ai-border);
}

.wiki-content th {
    background: rgba(var(--ai-primary-rgb), 0.05) !important;
    color: var(--ai-primary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    padding: 12px 16px !important;
}


.wiki-content h1,
.wiki-content h2,
.wiki-content h3,
.wiki-content h4 {
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    font-weight: 700;
    color: var(--ai-text);
    letter-spacing: -0.02em;
}

.wiki-content h1 { font-size: 2.25rem; border-bottom: 1px solid var(--ai-border); padding-bottom: 0.5rem; }
.wiki-content h2 { font-size: 1.75rem; }
.wiki-content h3 { font-size: 1.4rem; }
.wiki-content h4 { font-size: 1.2rem; }

.wiki-content p {
    margin-bottom: 1.25rem;
}

.wiki-content ul, 
.wiki-content ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.wiki-content li {
    margin-bottom: 0.5rem;
}

/* Wiki Card - Paper Sheet Style */
.wiki-view-card {
    flex: 0 0 auto;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto 3rem auto !important;
    background: #ffffff !important;
    color: #111 !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    border-radius: 4px !important;
}

.wiki-view-card .ai-card-header {
    background: #ffffff !important;
    border-bottom: 2px solid var(--ai-primary) !important;
    padding: 3rem 4rem !important;
    position: relative;
    z-index: 10;
}

.wiki-view-card .ai-card-header h1,
.wiki-view-card .ai-card-header div,
.wiki-view-card .ai-card-header span,
.wiki-view-card .ai-card-header i {
    color: #111 !important;
}

.wiki-view-card .ai-card-body {
    flex: 1;
    background: #ffffff !important;
    padding: 3rem 4rem !important; /* Matches header padding for alignment */
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Align to the left */
}


.wiki-content-inner {
    max-width: 900px;
    width: 100%;
}

.wiki-view-card .ql-editor {
    color: #222 !important;
}

@media (max-width: 1199.98px) {
    .wiki-view-card {
        max-width: 95%;
    }
}



:root.light-mode .wiki-view-card .ai-card-body {
    background: #ffffff;
}

.wiki-content h1, .wiki-content h2, .wiki-content h3 {
    color: var(--ai-primary);
}


/* ── TinyMCE — In-container Fullscreen Mode ── */

/* Override TinyMCE's default fullscreen (viewport takeover) to stay in-card */
.wiki-editor-fullscreen .tox-fullscreen {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: 100% !important;
    height: 500px !important;
    z-index: auto !important;
}

/* Prevent body-level fullscreen class from hiding overflow */
body.tox-fullscreen {
    overflow: auto !important;
}

/* Keep columns on one line so the left panel doesn't stack above */
.wiki-editor-fullscreen #mainAddEditForm {
    flex-wrap: nowrap !important;
}

.wiki-editor-fullscreen #mainAddEditForm > .col-lg-3 {
    max-width: 0 !important;
    min-width: 0 !important;
    flex: 0 0 0% !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    pointer-events: none;
}

/* Hide inner card border/spacing immediately */
.wiki-editor-fullscreen #mainAddEditForm > .col-lg-3 > * {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.wiki-editor-fullscreen #mainAddEditForm > .col-lg-9 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    min-width: 0 !important;
}

/* ==========================================================================
   Maintenance Hours - Weekly Entry Form (from maintenance_hours.php)
   ========================================================================== */
.ai-period-input-wrap {
    position: relative;
}

.ai-period-input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ai-primary);
    font-size: 0.95rem;
    pointer-events: none;
    z-index: 2;
}

.ai-period-input {
    padding-left: 36px !important;
    border-radius: 10px !important;
    background: var(--ai-bg) !important;
    border-color: var(--ai-border) !important;
    cursor: pointer !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
}

.ai-period-input:focus,
.ai-period-input.active {
    border-color: var(--ai-primary) !important;
    box-shadow: 0 0 0 3px rgba(var(--ai-primary-rgb), 0.12) !important;
}

/* -- Weekly Log &mdash; Responsive column sizing ------------------------------------ */
/* Col order: 1=Day, 2=Project, 3=Service, 4=Hours, 5=Description, 6=Actions */
@media (max-width: 991.98px) {
    .ai-bulk-table {
        table-layout: auto !important;
    }

    /* Col 2: Client & Service */
    .ai-bulk-table th:nth-child(2) {
        width: 380px !important;
        min-width: 350px !important;
    }

    /* Hours */
    .ai-bulk-table th:nth-child(3) {
        width: 100px !important;
    }

    /* Col 4: Description */
    .ai-bulk-table th:nth-child(4) {
        min-width: 200px !important;
    }
}

@media (max-width: 767.98px) {
    /* Day */
    .ai-bulk-table th:nth-child(1) {
        width: 60px !important;
    }

    /* Client & Service */
    .ai-bulk-table th:nth-child(2) {
        width: 320px !important;
        min-width: 300px !important;
    }

    /* Hours */
    .ai-bulk-table th:nth-child(3) {
        width: 90px !important;
    }

    /* Description */
    .ai-bulk-table th:nth-child(4) {
        min-width: 150px !important;
    }

    /* Actions */
    .ai-bulk-table th:nth-child(5) {
        width: 40px !important;
    }

    /* Day badge: tighter */
    .weekly-day-num {
        font-size: 1.15rem;
    }
}

/* Weekly Log &mdash; Table horizontal scroll logic */
.ai-bulk-table {
    min-width: 1200px !important;
    /* Increased from 1100px to accommodate wider columns */
    table-layout: fixed !important;
}

/* Specific column widths to fit long names */
/* Day (Col 1) */
.ai-bulk-table th:nth-child(1) {
    width: 65px !important;
}

/* Client & Service (Col 2) */
.ai-bulk-table th:nth-child(2) {
    width: 550px !important;
}

/* Hours (Col 3) */
.ai-bulk-table th:nth-child(3) {
    width: 110px !important;
}

/* Description (Col 4) will take the remaining space */
.ai-bulk-table th:nth-child(4) {
    width: auto !important;
}

/* Actions (Col 5) */
.ai-bulk-table th:nth-child(5) {
    width: 50px !important;
}

/* Static Header/Footer & Scrolling Content Logic */
.ai-log-form-card .ai-card-body {
    /* Do NOT use overflow-x: hidden — it creates a stacking context that
       clips fixed-positioned dropdown panels (TomSelect, ai-select-panel). */
    overflow-x: visible !important;
    position: relative;
}

.ai-log-form-card .table-responsive {
    overflow-x: auto !important;
    /* Only scroll the table */
    width: 100%;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0;
}

@media (max-width: 1099.98px) {

    /* Ensure the container handles the overflow of the 1100px table */
    #weekly-entry-view .table-responsive {
        overflow-x: auto !important;
        background: transparent !important;
    }
}

@media (max-width: 575.98px) {

    /* Stack footer elements on mobile to prevent button squeezing */
    .ai-log-form-card .mt-3.pt-2.border-top {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px;
        text-align: center;
        padding-top: 20px !important;
    }

    .ai-log-form-card .mt-3.pt-2.border-top .btn-ai {
        width: 100% !important;
        justify-content: center;
        padding: 12px !important;
        white-space: nowrap;
    }
}

.weekly-nav-bar {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 10px 20px;
    box-shadow: none !important;
    margin-bottom: 1rem !important;
}

.weekly-nav-btn {
    color: var(--ai-text-muted) !important;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    transition: all 0.3s;
    border-radius: 20px;
}

.weekly-nav-btn:hover {
    color: var(--ai-primary) !important;
    background: rgba(var(--ai-primary-rgb), 0.1);
    transform: translateX(2px);
}

.weekly-nav-btn:first-child:hover {
    transform: translateX(-2px);
}

.ai-bulk-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    table-layout: fixed !important;
    border-top: 1px solid var(--ai-border);
}

.ai-bulk-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #282828;
    border-bottom: 1px solid var(--ai-border);
    padding: 15px !important;
    color: var(--ai-text-muted);
    text-transform: uppercase;
    font-size: 0.65rem !important;
    letter-spacing: 1.5px;
    font-weight: 800;
}

:root.light-mode .ai-bulk-table thead th {
    background: #ffffff !important;
}

.weekly-day-row {
    background: transparent;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--ai-border);
}

@keyframes aiRowIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.weekly-day-row:hover {
    background: rgba(255, 255, 255, 0.02) !important;
}

.weekly-day-row td {
    border: none !important;
    padding: 14px 10px !important;
    overflow: visible !important;
    vertical-align: middle !important;
}


.weekly-day-badge {
    display: flex;
    flex-direction: column;
    line-height: 1;
    min-width: 45px;
}

.weekly-day-name {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--ai-primary);
    margin-bottom: 4px;
    opacity: 0.9;
}

.weekly-day-num {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--ai-text);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.weekly-project,
.weekly-service,
.weekly-hours,
.weekly-desc {
    background: var(--ai-input-bg) !important;
    border: 1px solid var(--ai-border) !important;
    color: var(--ai-text) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 42px !important;
    height: auto !important;
    /* Allow vertical growth */
    border-radius: 50px !important;
    font-weight: 600;
    padding: 8px 14px !important;
    /* Switched to vertical padding for wrapping */
    line-height: 1.4 !important;
    /* Flexible line height */
    white-space: normal !important;
    /* Allow text to wrap */
}

/* Removed conflicting light-mode override */

.weekly-desc.ai-textarea-hybrid {
    padding: 10px 40px 10px 14px !important;
    min-height: 44px !important;
    line-height: 1.4 !important;
    resize: none;
    background: var(--ai-input-bg);
    overflow: hidden !important;
    transition: height 0.1s ease-out;
}

.ai-textarea-hybrid-wrap.expanded .weekly-desc.ai-textarea-hybrid {
    min-height: 100px !important;
}

.ai-textarea-hybrid-wrap .ai-textarea-expand-btn {
    top: 8px !important;
    right: 8px !important;
    color: var(--ai-primary) !important;
    background: rgba(var(--ai-primary-rgb), 0.1);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
}

.ai-textarea-hybrid-wrap .ai-textarea-expand-btn:hover {
    background: var(--ai-primary);
    color: white !important;
}

.weekly-hours {
    width: 100% !important;
    padding-right: 5px !important;
    font-weight: 800;
    text-align: center;
}

.weekly-desc {
    font-size: 0.9rem;
}

.weekly-project:focus,
.weekly-service:focus,
.weekly-hours:focus,
.weekly-desc:focus,
.ai-select-btn:focus {
    border-color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: none !important;
    background: var(--ai-select-bg) !important;
}

.dropdown-menu.ai-dropdown {
    background-color: var(--ai-calendar-bg) !important;
}

.ai-select.ai-select-sm .ai-select-btn {
    height: auto;
    min-height: 38px;
    border-radius: 50px;
    background: var(--ai-input-bg);
    font-size: 0.85rem;
    padding: 8px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    white-space: normal;
}

.ai-select.ai-select-sm .ai-select-btn:hover {
    background: rgba(var(--ai-primary-rgb), 0.04) !important;
    border-color: var(--ai-primary) !important;
    box-shadow: 0 2px 10px rgba(var(--ai-primary-rgb), 0.1) !important;
}

.ai-select-panel {
    background: var(--ai-select-bg);
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ai-select-panel.show {
    opacity: 1;
    transform: translateY(0);
}

.ai-select-option {
    color: var(--ai-text);
    padding: 10px 15px;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-select-option:hover {
    background: rgba(var(--ai-primary-rgb), 0.1);
    color: var(--ai-primary);
}

.ai-select-option.selected {
    background: var(--ai-primary);
    color: white;
}

.weekly-add-btn,
.weekly-remove-btn {
    font-size: 1.4rem !important;
    opacity: 0.6;
    transition: all 0.2s;
    color: var(--ai-primary) !important;
}

.weekly-add-btn:hover,
.weekly-remove-btn:hover {
    opacity: 1;
    transform: scale(1.15);
}

.weekly-remove-btn {
    color: var(--ai-danger) !important;
}

.ai-btn-group-pill {
    background: var(--ai-input-bg);
    padding: 5px;
    border-radius: 50px;
    border: 1px solid var(--ai-border);
    display: inline-flex;
    box-shadow: none !important;
}

.ai-btn-group-pill .btn {
    border-radius: 50px;
    border: none;
    color: var(--ai-text-muted);
    font-weight: 700;
    padding: 8px 28px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-btn-group-pill .btn-check:checked+.btn {
    background: var(--ai-primary) !important;
    color: white !important;
    box-shadow: none !important;
    transform: scale(1.05);
}

#single-entry-view,
#weekly-entry-view {}

@keyframes aiEntrance {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes aiViewIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Hours Overview - FullCalendar Theme (from hours_overview.php)
   ========================================================================== */
.overview-filter-group {
    min-width: 160px;
}

.overview-filter-group .form-select {
    font-size: 0.85rem;
    border-radius: 10px;
    background: var(--ai-input-bg);
    border: 1px solid var(--ai-border);
    color: var(--ai-text);
    padding: 6px 12px;
    height: 38px;
}

#hours-calendar {
    --fc-border-color: var(--ai-border);
    --fc-page-bg-color: transparent;
    --fc-neutral-bg-color: rgba(var(--ai-primary-rgb), 0.03);
    --fc-today-bg-color: rgba(var(--ai-primary-rgb), 0.06);
    --fc-event-border-color: transparent;
    --fc-small-font-size: 0.78rem;
    --fc-neutral-text-color: var(--ai-text-muted);
    transition: opacity 0.3s ease;
}

#hours-calendar.ov-loading {
    opacity: 0.5;
    pointer-events: none;
}

.fc .fc-toolbar {
    margin-bottom: 1.5rem !important;
    gap: 12px;
    flex-wrap: wrap;
}

.fc .fc-toolbar-title {
    font-size: 1.3rem !important;
    font-weight: 800 !important;
    color: var(--ai-text) !important;
    letter-spacing: -0.3px;
}

.fc .fc-button {
    background: var(--ai-input-bg) !important;
    border: 1px solid var(--ai-border) !important;
    color: var(--ai-text) !important;
    font-weight: 600 !important;
    font-size: 0.82rem !important;
    padding: 6px 14px !important;
    border-radius: 10px !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: none !important;
    text-transform: none !important;
}

.fc .fc-button:hover {
    background: rgba(var(--ai-primary-rgb), 0.1) !important;
    border-color: var(--ai-primary) !important;
    color: var(--ai-primary) !important;
    transform: translateY(-1px);
}

.fc .fc-button-active,
.fc .fc-button.fc-button-active {
    background: var(--ai-primary) !important;
    border-color: var(--ai-primary) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(var(--ai-primary-rgb), 0.35) !important;
}

.fc .fc-button-group>.fc-button {
    border-radius: 0 !important;
}

.fc .fc-button-group>.fc-button:first-child {
    border-radius: 10px 0 0 10px !important;
}

.fc .fc-button-group>.fc-button:last-child {
    border-radius: 0 10px 10px 0 !important;
}

.fc .fc-today-button {
    border-radius: 10px !important;
}

.fc .fc-prev-button,
.fc .fc-next-button {
    width: 36px !important;
    padding: 6px !important;
}

.fc .fc-col-header-cell {
    background: rgba(var(--ai-primary-rgb), 0.04) !important;
    border-color: var(--ai-border) !important;
    padding: 10px 0 !important;
}

.fc .fc-col-header-cell-cushion {
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    font-size: 0.7rem !important;
    color: var(--ai-text-muted) !important;
    text-decoration: none !important;
}

.fc .fc-daygrid-day {
    transition: background 0.2s ease;
}

.fc .fc-daygrid-day:hover {
    background: rgba(var(--ai-primary-rgb), 0.04) !important;
}

.fc .fc-daygrid-day-number {
    font-weight: 700 !important;
    font-size: 0.85rem !important;
    color: var(--ai-text) !important;
    padding: 8px 10px !important;
    text-decoration: none !important;
}

.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
    background: var(--ai-primary) !important;
    color: #fff !important;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4px !important;
    padding: 0 !important;
    font-size: 0.8rem !important;
}

.fc .fc-event {
    border-radius: 6px !important;
    padding: 2px 6px !important;
    margin-bottom: 2px !important;
    border: none !important;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    font-size: 0.78rem !important;
}

.fc .fc-event:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
    z-index: 10 !important;
}

.ov-event-content {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    white-space: nowrap;
    padding: 1px 2px;
    line-height: 1.4;
}

.ov-event-hours {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    padding: 0 4px;
    font-weight: 800;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.ov-event-user {
    font-weight: 700;
    font-size: 0.72rem;
    opacity: 0.95;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ov-event-project {
    font-weight: 500;
    font-size: 0.68rem;
    opacity: 0.7;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fc .fc-daygrid-more-link {
    color: var(--ai-primary) !important;
    font-weight: 700 !important;
    font-size: 0.75rem !important;
    margin-top: 2px;
}

.fc .fc-daygrid-more-link:hover {
    text-decoration: none !important;
    background: rgba(var(--ai-primary-rgb), 0.1) !important;
    border-radius: 4px;
}

.fc .fc-popover {
    background: var(--ai-card-bg) !important;
    border: 1px solid var(--ai-border) !important;
    border-radius: 12px !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4) !important;
    overflow: hidden;
}

.fc .fc-popover-header {
    background: rgba(var(--ai-primary-rgb), 0.08) !important;
    color: var(--ai-text) !important;
    font-weight: 700 !important;
    padding: 10px 14px !important;
}

.fc .fc-popover-body {
    padding: 8px !important;
}

.fc .fc-timegrid-slot {
    height: 48px !important;
    border-color: var(--ai-border) !important;
}

.fc .fc-timegrid-slot-label-cushion {
    font-size: 0.72rem !important;
    font-weight: 600 !important;
    color: var(--ai-text-muted) !important;
}

.fc .fc-timegrid-event {
    border-radius: 6px !important;
    padding: 4px 6px !important;
}

.fc .fc-list {
    border-radius: 12px !important;
    overflow: hidden;
}

.fc .fc-list-table th {
    background: rgba(var(--ai-primary-rgb), 0.06) !important;
    color: var(--ai-text) !important;
    font-weight: 700 !important;
}

.fc .fc-list-event:hover td {
    background: rgba(var(--ai-primary-rgb), 0.04) !important;
}

.fc .fc-list-event-dot {
    border-radius: 50% !important;
}

.fc .fc-list-event-title a,
.fc .fc-list-event-time {
    color: var(--ai-text) !important;
    text-decoration: none !important;
}

.fc td,
.fc th {
    border-color: var(--ai-border) !important;
}

.fc .fc-scrollgrid {
    border-color: var(--ai-border) !important;
    border-radius: 12px !important;
    overflow: hidden;
}

:root.light-mode #hours-calendar {
    --fc-today-bg-color: rgba(var(--ai-primary-rgb), 0.04);
    --fc-neutral-bg-color: rgba(0, 0, 0, 0.02);
}

:root.light-mode .fc .fc-button {
    background: #ffffff !important;
    border-color: #dee2e6 !important;
    color: #374151 !important;
}

:root.light-mode .fc .fc-button:hover {
    background: rgba(var(--ai-primary-rgb), 0.06) !important;
    border-color: var(--ai-primary) !important;
    color: var(--ai-primary) !important;
}

:root.light-mode .fc .fc-button-active {
    background: var(--ai-primary) !important;
    border-color: var(--ai-primary) !important;
    color: #fff !important;
}

:root.light-mode .fc .fc-col-header-cell {
    background: rgba(0, 0, 0, 0.03) !important;
}

:root.light-mode .fc .fc-popover {
    background: #fff !important;
    border-color: #dee2e6 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

:root.light-mode .fc .fc-list-table th {
    background: rgba(0, 0, 0, 0.04) !important;
}

:root.light-mode .overview-filter-group .form-select {
    background: #ffffff;
    border-color: #dee2e6;
}

:root.light-mode .ov-event-hours {
    background: rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
    .fc .fc-toolbar {
        flex-direction: column;
        gap: 8px;
    }

    .fc .fc-toolbar-title {
        font-size: 1.1rem !important;
    }

    .fc .fc-button {
        font-size: 0.75rem !important;
        padding: 5px 10px !important;
    }

    .overview-filter-group {
        min-width: 100%;
    }

    .ov-event-project {
        display: none;
    }

    .ov-event-user {
        max-width: 60px;
    }
}

/* ==========================================================================
   Extra-small screen refinements &mdash; ≤480px
   Maintenance Hours, Login, Wiki at sub-480 widths
   ========================================================================== */
@media (max-width: 479.98px) {

    /* Weekly nav bar: tighter on small phones */
    .weekly-nav-bar {
        padding: 8px 12px;
        border-radius: 30px;
    }

    .weekly-nav-btn {
        font-size: 0.72rem;
        letter-spacing: 0.8px;
        padding: 4px 8px !important;
    }

    /* Entry toggle pill: shrink padding */
    .ai-btn-group-pill .btn {
        padding: 6px 16px;
        font-size: 0.72rem;
    }

    /* Profile page: avatar smaller */
    .ai-avatar-upload-group {
        width: 90px;
    }

    .ai-avatar-picker {
        width: 80px;
        height: 80px;
    }

    /* Wiki content: reduce table padding */
    .wiki-content td,
    .wiki-content th {
        padding: 6px 8px;
        font-size: 0.82rem;
    }

    /* TinyMCE toolbar: allow wrapping */
    .tox .tox-toolbar__group {
        flex-wrap: wrap !important;
    }

    /* Hours calendar toolbar: smaller title */
    .fc .fc-toolbar-title {
        font-size: 0.95rem !important;
    }
}

/* ==========================================================================
   320px minimum &mdash; prevent any horizontal overflow, tighten final edge cases
   ========================================================================== */
@media (max-width: 359.98px) {

    /* Ensure page header action buttons wrap cleanly */
    .ai-page-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Sidebar width: never clip at 320px */
    :root {
        --ai-sidebar-width: 220px;
    }

    /* Login card: reduce card top/bottom padding further */
    .ai-login-card {
        padding: 20px 14px !important;
    }

    /* Weekly nav bar: stack vertically on tiny screens */
    .weekly-nav-bar {
        flex-direction: column;
        align-items: center;
        gap: 6px;
        border-radius: 14px;
        padding: 10px 12px;
    }

    /* Stat cards: even more compact */
    .ai-stat-card {
        flex-direction: column;
        text-align: center;
        padding: 0.75rem !important;
    }

    .ai-stat-card .stat-icon {
        margin: 0 auto;
    }

    /* Remove box shadow on cards to save paint complexity */
    .ai-card,
    .ai-admin-card {
        box-shadow: none !important;
    }
}

/* -- Animations --------------------------------------------------------------- */
.ai-spin {
    animation: ai-spin 1s infinite linear;
    display: inline-block;
}

@keyframes ai-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* -- QuickBooks Sync Button --------------------------------------------------- */
.ai-btn-qb-sync {
    background: rgba(44, 160, 28, 0.12) !important;
    border: 1px solid rgba(44, 160, 28, 0.25) !important;
    color: #44cf32 !important;
    /* Brighter, more vibrant green for dark mode visibility */
    border-radius: 50px !important;
    padding: 3px 10px !important;
    font-size: 0.65rem !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.6px !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    box-shadow: none !important;
}

.ai-btn-qb-sync:hover {
    background: rgba(44, 160, 28, 0.2) !important;
    border-color: rgba(44, 160, 28, 0.4) !important;
    color: #55ef41 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 160, 28, 0.15) !important;
}

.ai-btn-qb-sync:active {
    transform: translateY(0);
}

.ai-btn-qb-sync .qb-logo-mini {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: transparent !important;
    padding: 0;
}

:root.light-mode .ai-btn-qb-sync {
    background: rgba(44, 160, 28, 0.1) !important;
    color: #2ca01c !important;
    border-color: rgba(44, 160, 28, 0.2) !important;
}

:root.light-mode .ai-btn-qb-sync:hover {
    background: rgba(44, 160, 28, 0.15) !important;
    color: #238016 !important;
}

/* ==========================================================================
   Bulk Operations &mdash; shared across all table pages
   ========================================================================== */
.btn-bulk {
    border-radius: 8px;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: transparent;
    white-space: nowrap;
}

.btn-bulk-archive {
    border: 1px solid var(--ai-warning);
    color: var(--ai-warning);
}

.btn-bulk-archive:hover {
    background: var(--ai-warning);
    color: #fff !important;
}

.btn-bulk-restore {
    border: 1px solid #10b981;
    color: #10b981;
}

.btn-bulk-restore:hover {
    background: #10b981;
    color: #fff !important;
}

.btn-bulk-delete {
    border: 1px solid var(--ai-danger);
    color: var(--ai-danger);
}

.btn-bulk-delete:hover {
    background: var(--ai-danger);
    color: #fff !important;
}

.ai-row-selected {
    background-color: rgba(var(--ai-primary-rgb, 190, 18, 93), 0.05) !important;
}

.bulk-row-cb:checked {
    background-color: var(--ai-primary) !important;
    border-color: var(--ai-primary) !important;
}

.ai-row-removing {
    transition: opacity 0.35s ease, transform 0.35s ease;
    opacity: 0 !important;
    transform: translateX(30px) !important;
    pointer-events: none;
}

.ai-bulk-bar {
    background: rgba(128, 128, 128, 0.08);
    border-bottom: 1px solid var(--ai-border);
    font-size: 0.85rem;
}

/* QB loading state */
.btn-action-qb {
    position: relative;
    overflow: hidden;
}

.btn-action-qb.ai-qb-loading {
    pointer-events: none;
}

.btn-action-qb.ai-qb-loading img {
    opacity: 0.3;
}

.btn-action-qb.ai-qb-loading::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border: 2px solid transparent;
    border-top-color: #2ca01c;
    border-right-color: #2ca01c;
    border-radius: 50%;
    animation: ai-qb-spin 0.6s linear infinite;
}

@keyframes ai-qb-spin {
    to {
        transform: rotate(360deg);
    }
}

.ai-syncing {
    pointer-events: none;
    opacity: 0.85;
}

.ai-syncing span {
    display: inline-block;
    animation: ai-pulse-text 1.2s ease-in-out infinite;
}

@keyframes ai-pulse-text {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* Bulk bar responsive stacking */
@media (max-width: 575.98px) {
    .ai-bulk-bar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        padding: 0.5rem 1rem !important;
    }

    .ai-bulk-bar .ms-auto {
        margin-left: 0 !important;
        flex-wrap: wrap;
    }
}
/* -- Locked Out Status Badge -- */
.ai-badge.locked-out {
    background: rgba(255, 165, 2, 0.14);
    color: #ffa502;
}

.form-select, .form-control {
    color-scheme: dark;
}

:root.light-mode .form-select, :root.light-mode .form-control {
    color-scheme: light;
}

.form-select:focus, .form-control:focus {
    border-color: var(--ai-primary) !important;
    box-shadow: 0 0 0 0.15rem rgba(var(--ai-primary-rgb), 0.1) !important;
}

/* -- High-Density Table Cells ---------------------------------------------- */
.ai-table-cell-limit {
    /* Limit removed to prevent cropping of important info */
    position: relative;
}

.ai-cell-more-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ai-primary);
    background: rgba(var(--ai-primary-rgb), 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 8px;
    cursor: pointer;
    border: 1px solid rgba(var(--ai-primary-rgb), 0.2);
    transition: var(--ai-transition);
}

.ai-cell-more-badge:hover {
    background: rgba(var(--ai-primary-rgb), 0.2);
    transform: translateY(-1px);
}

/* Column hover effects removed to restrict sorting to label clicks */

/* Smooth width transition when sort badge expands/contracts a column */
.ai-table thead th[data-sort-col] {
    transition: width 0.25s ease, min-width 0.25s ease, max-width 0.25s ease;
}


.ai-sort-label {
    display: none;
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: 8px;
    padding: 2px 10px;
    background: var(--ai-primary);
    color: #fff !important;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 6px rgba(var(--ai-primary-rgb), 0.3);
    white-space: nowrap;
    vertical-align: middle;
}

.ai-sort-active .ai-sort-label,
.ai-sort-asc .ai-sort-label,
.ai-sort-desc .ai-sort-label {
    display: inline-flex;
}

.ai-table thead th.ai-sort-active .ai-sort-col-label::after,
.ai-table thead th.ai-sort-asc .ai-sort-col-label::after,
.ai-table thead th.ai-sort-desc .ai-sort-col-label::after {
    display: none !important;
}

.ai-table thead th.ai-sort-asc .ai-sort-label::before {
    content: '\F148';
    font-family: "bootstrap-icons";
    font-size: 0.75rem;
}

.ai-table thead th.ai-sort-desc .ai-sort-label::before {
    content: '\F128';
    font-family: "bootstrap-icons";
    font-size: 0.75rem;
}

.ai-table thead th.ai-col-sticky .ai-sort-label,
.ai-table thead th.ai-col-company .ai-sort-label {
    background: rgba(0, 0, 0, 0.15) !important;
    box-shadow: none;
}

/* Make sort arrows always visible but dimmed when inactive */
.ai-table thead th[data-sort-col] .ai-sort-col-label::after {
    content: '\F143'; /* bi-arrow-down-up for neutral sort */
    font-family: "bootstrap-icons";
    display: inline-block;
    margin-left: 8px;
    font-weight: 900;
    font-size: 0.85rem;
    opacity: 0.25;
    color: inherit;
    vertical-align: middle;
    transition: opacity 0.2s ease;
}

.ai-table thead th[data-sort-col]:hover .ai-sort-col-label::after {
    opacity: 0.5;
}

/* -- Table Column Resizing ------------------------------------------------- */
.ai-table thead th {
    position: relative;
    /* Clip inner content but not the absolutely-positioned resizer handle */
    overflow: hidden;
}

/* Resizer – wider invisible hit area, thin visible bar */
.ai-resizer {
    position: absolute;
    top: 0;
    right: -1px;       /* overlap the cell border so there is no gap */
    width: 14px;       /* generous hit target */
    height: 100%;
    cursor: col-resize;
    user-select: none;
    touch-action: none; /* required for pointer-capture drag on touch */
    z-index: 1001;
    display: flex;
    justify-content: center;
    align-items: stretch;
}

/* Visible bar – thin, subtle, centred inside the hit area */
.ai-resizer::after {
    content: '';
    align-self: center;
    width: 3px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.18);
    border-radius: 3px;
    transition: background-color 0.18s ease, height 0.18s ease, width 0.18s ease, opacity 0.18s ease;
    opacity: 0.7;
}

:root.light-mode .ai-resizer::after {
    background-color: rgba(0, 0, 0, 0.22);
}

/* Pink sticky-column header – slightly more visible by default */
.ai-table thead th.ai-col-sticky .ai-resizer::after,
.ai-table thead th.ai-col-company .ai-resizer::after {
    background-color: rgba(255, 255, 255, 0.55);
    opacity: 1;
}

/* Hover / active states */
.ai-resizer:hover::after,
.ai-resizer.resizing::after {
    background-color: var(--ai-primary);
    width: 3px;
    height: 24px;
    opacity: 1;
    box-shadow: 0 0 8px rgba(var(--ai-primary-rgb), 0.5);
}

.ai-table thead th.ai-col-sticky .ai-resizer:hover::after,
.ai-table thead th.ai-col-sticky .ai-resizer.resizing::after,
.ai-table thead th.ai-col-company .ai-resizer:hover::after,
.ai-table thead th.ai-col-company .ai-resizer.resizing::after {
    background-color: #ffffff !important;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.45);
}

/* Tooltip hint on resizer hover */
.ai-resizer[title] {
    pointer-events: all;
}

/* During drag – lock cursor & kill transitions globally; keep resizer interactive */
.ai-table.resizing,
body.ai-col-resizing {
    cursor: col-resize !important;
    user-select: none !important;
}

.ai-table.resizing *,
body.ai-col-resizing * {
    transition: none !important;
    pointer-events: none !important;
}

.ai-table.resizing .ai-resizer,
body.ai-col-resizing .ai-resizer {
    pointer-events: all !important;
}

/* -- Sticky column – scroll-driven shadow ---------------------------------- */
/* JS sets --sticky-shadow-opacity (0 → 1) on .table-responsive as the user
   scrolls right, so the depth shadow only appears when content is hidden. */
.ai-table th.ai-col-sticky,
.ai-table td.ai-col-sticky,
.ai-table th.ai-col-company,
.ai-table td.ai-col-company {
    /* Compose two shadows: a wide soft one and a tight hard one */
    box-shadow:
        6px 0 20px rgba(0, 0, 0, calc(var(--sticky-shadow-opacity, 0) * 0.22)),
        2px 0  6px rgba(0, 0, 0, calc(var(--sticky-shadow-opacity, 0) * 0.14)) !important;
    /* Keep background-color in the transition list so the hover fade matches
       non-sticky cells (which inherit transition from .ai-table tbody td). */
    transition: background-color 0.12s ease, box-shadow 0.08s linear;
}

:root.light-mode .ai-table th.ai-col-sticky,
:root.light-mode .ai-table td.ai-col-sticky,
:root.light-mode .ai-table th.ai-col-company,
:root.light-mode .ai-table td.ai-col-company {
    box-shadow:
        6px 0 20px rgba(0, 0, 0, calc(var(--sticky-shadow-opacity, 0) * 0.14)),
        2px 0  6px rgba(0, 0, 0, calc(var(--sticky-shadow-opacity, 0) * 0.09)) !important;
}

/* -- Actions Column -------------------------------------------------------- */
.ai-table th:last-child,
.ai-table td:last-child {
    width: 1%;
    white-space: nowrap;
}

/* Ensure action buttons in the last column stay compact */
.ai-table td:last-child .d-flex {
    justify-content: flex-end;
    gap: 8px !important;
}

/* ── Global Modal Close Button ─────────────────────────────────────────────── */
.ov-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    color: #fff;
    transition: all 0.2s;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}
.ov-modal-close:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
}
.ov-modal-close i {
    font-size: 1.1rem;
    line-height: 1;
}

/* ── Consistent Modal Header ────────────────────────────────────────────────── */
.ai-modal-gradient-header {
    background: linear-gradient(135deg, #e91e63 0%, #c2185b 100%);
    border-bottom: none !important;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #fff;
}
.ai-modal-gradient-header .ai-modal-icon-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 1.05rem;
}
.ai-modal-gradient-header .modal-title,
.ai-modal-gradient-header h5 {
    color: #fff !important;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    margin: 0;
    font-size: 1rem;
}
.ai-modal-gradient-header .ai-modal-subtitle-text,
.ai-role-modal .modal-header .ai-modal-subtitle-text {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 1px;
}

