:root {
    --sidebar-width: 280px;
    --sidebar-bg: #101827;
    --sidebar-text: #d1d5db;
    --sidebar-muted: #7c8798;
    --content-bg: #f4f6f9;
    --border-color: #e5e7eb;
}

* { box-sizing: border-box; }

html {
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    background: var(--content-bg);
    color: #111827;
}

a { color: inherit; }

.auth-body {
    background:
        radial-gradient(circle at top left, rgba(13, 110, 253, 0.20), transparent 32rem),
        linear-gradient(135deg, #eef4ff 0%, #f8fafc 45%, #eef2ff 100%);
}

.auth-wrapper {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.auth-card {
    width: min(100%, 520px);
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 22px;
    padding: 32px;
    position: relative;
    z-index: 1;
}

.auth-body::after {
    content: none !important;
    display: none !important;
}

.auth-brand {
    display: flex;
    gap: 14px;
    align-items: center;
}

.auth-logo,
.sidebar-logo {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    color: #ffffff;
    background: #0d6efd;
}

.auth-brand h1 {
    font-size: 20px;
    margin: 0;
}

.auth-brand p {
    margin: 0;
    color: #6b7280;
    font-size: 13px;
}

.demo-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    min-height: 100vh;
    position: sticky;
    top: 0;
    transition: margin-left 0.2s ease;
}

.sidebar-brand {
    height: 72px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 22px;
    color: #ffffff;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-nav {
    padding: 16px 12px 24px;
}

.sidebar-section {
    margin: 18px 12px 8px;
    color: var(--sidebar-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .08em;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    margin-bottom: 4px;
    color: var(--sidebar-text);
    border-radius: 12px;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.10);
    color: #ffffff;
}

.sidebar-nav a i {
    width: 20px;
    text-align: center;
}

.disabled-link {
    opacity: .76;
    cursor: not-allowed;
}

.muted { color: var(--sidebar-muted); }

.app-main {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    height: 72px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-circle,
.profile-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #e7f1ff;
    color: #0d6efd;
    font-weight: 700;
}

.avatar-circle {
    width: 32px;
    height: 32px;
}

.profile-avatar {
    width: 84px;
    height: 84px;
    font-size: 32px;
}

.app-content {
    padding: 24px;
}

.stat-card {
    min-height: 112px;
    border-radius: 18px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
}

.stat-icon {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: #eef2ff;
}

.stat-value {
    font-size: 28px;
    line-height: 1;
    font-weight: 800;
}

.stat-label {
    color: #6b7280;
    font-size: 13px;
    margin-top: 6px;
}

.stat-primary .stat-icon { background: #e7f1ff; color: #0d6efd; }
.stat-info .stat-icon { background: #e6faff; color: #087990; }
.stat-warning .stat-icon { background: #fff6db; color: #b58100; }
.stat-success .stat-icon { background: #eaf7ee; color: #198754; }
.stat-danger .stat-icon { background: #fdecec; color: #dc3545; }
.stat-secondary .stat-icon { background: #f1f3f5; color: #6c757d; }

.card {
    border-radius: 18px;
    border-color: var(--border-color);
}

.chart-card {
    border: 0;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
}

.chart-card .card-body {
    height: 340px;
}

.chart-card h2 {
    margin-bottom: 16px;
}

.chart-card canvas {
    max-height: 270px;
}

.empty-chart {
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border-color);
    border-radius: 14px;
    background: #f8fafc;
}

.empty-icon {
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    color: #94a3b8;
    background: #f1f5f9;
    font-size: 28px;
}

.notification-dropdown {
    width: min(92vw, 380px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.notification-list {
    max-height: 360px;
    overflow: auto;
}

.notification-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
}

.notification-item.unread {
    background: #f0f7ff;
}

.notification-link {
    text-decoration: none;
}

.profile-card {
    position: sticky;
    top: 96px;
}

.sidebar-collapsed .app-sidebar {
    margin-left: calc(var(--sidebar-width) * -1);
}

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        z-index: 1050;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    body.app-body:not(.sidebar-collapsed) .app-sidebar {
        transform: translateX(0);
    }

    body.app-body:not(.sidebar-collapsed)::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 1040;
    }

    .app-content {
        padding: 18px;
    }

    .app-topbar {
        padding: 0 16px;
    }

    .auth-card {
        padding: 24px;
    }
}

.ticket-meta {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px 12px;
    margin: 0;
    font-size: 14px;
}

.ticket-meta dt {
    color: #6b7280;
    font-weight: 600;
}

.ticket-meta dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.ticket-description {
    line-height: 1.7;
    white-space: normal;
}

.ticket-sticky {
    position: sticky;
    top: 96px;
}

.conversation-list {
    position: relative;
    display: grid;
    gap: 16px;
}

.conversation-item {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 12px;
}

.conversation-marker {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e7f1ff;
    color: #0d6efd;
}

.conversation-card {
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 14px;
    background: #fff;
}

.conversation-item.internal .conversation-marker {
    background: #fff6db;
    color: #b58100;
}

.conversation-item.internal .conversation-card {
    background: #fffdf4;
    border-color: #ffe8a1;
}

.conversation-item.system .conversation-marker {
    background: #eaf7ee;
    color: #198754;
}

.small-history {
    display: grid;
    gap: 12px;
}

.small-history-item {
    border-left: 3px solid #e5e7eb;
    padding-left: 12px;
    font-size: 13px;
}

.ticket-subject-cell {
    display: inline-block;
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

@media (max-width: 991.98px) {
    .ticket-sticky {
        position: static;
    }
    .ticket-meta {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

.article-content {
    line-height: 1.75;
}
.article-content h2,
.article-content h3,
.article-content h4 {
    margin-top: 1.25rem;
}
.article-content pre {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    overflow: auto;
}
.knowledge-card {
    transition: transform .15s ease, box-shadow .15s ease;
}
.knowledge-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08) !important;
}
.rating-stars {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 4px;
}
.rating-stars input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.rating-stars label {
    cursor: pointer;
    font-size: 1.45rem;
    color: #d1d5db;
}
.rating-stars input:checked ~ label,
.rating-stars label:hover,
.rating-stars label:hover ~ label {
    color: #f59f00;
}

/* Stage 15 mobile/PWA and new feature polish */
.pwa-install-button {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1080;
    border-radius: 999px;
    box-shadow: 0 12px 28px rgba(13, 110, 253, .25);
}

.ai-suggestion-box {
    border-radius: 16px;
}

.qr-preview canvas,
.qr-preview img {
    max-width: 100%;
    height: auto;
}

@media (max-width: 991.98px) {
    .app-shell { display: block; }
    .app-sidebar {
        position: fixed;
        z-index: 1040;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        overflow-y: auto;
    }
    body.app-body:not(.sidebar-collapsed) .app-sidebar { transform: translateX(0); }
    body.app-body.sidebar-collapsed .app-sidebar { transform: translateX(-100%); }
    .app-main { min-height: 100vh; }
    .app-topbar { padding: 0 12px; }
    .app-content { padding: 16px 12px 80px; }
    .topbar-actions .dropdown-toggle span.d-none { display: none !important; }
    .table-responsive { border-radius: 12px; }
}

@media (max-width: 575.98px) {
    h1.h3, .h3 { font-size: 1.35rem; }
    h1.h4, .h4 { font-size: 1.2rem; }
    .btn { white-space: normal; }
    .stat-card { min-height: auto; padding: 14px; }
    .stat-value { font-size: 22px; }
    .card-body { padding: 1rem; }
    .notification-dropdown { width: min(94vw, 360px); }
}


/* Hotfix v1.1.4: mobile login/backdrop safety */
@media (max-width: 991.98px) {
    body.auth-body {
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .auth-wrapper {
        align-items: flex-start;
        padding: max(18px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
    }

    .auth-card {
        width: 100%;
        max-width: 520px;
        margin: 0 auto;
    }

    .auth-brand {
        align-items: flex-start;
    }

    .auth-brand h1 {
        font-size: 18px;
        line-height: 1.25;
    }

    .demo-box .table-responsive {
        max-height: 220px;
        overflow: auto;
    }
}

@media (max-width: 575.98px) {
    .auth-card {
        border-radius: 18px;
        padding: 20px 16px;
    }

    .auth-logo {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        flex: 0 0 40px;
    }

    .auth-form .input-group-text,
    .auth-form .form-control,
    .auth-form .btn {
        min-height: 44px;
    }
}


/* Hotfix v1.1.5: absolute auth-page overlay killer for Android mobile browsers.
   This protects login from stale sidebar/PWA/backdrop CSS cached by service worker or browser. */
body.auth-body.sidebar-collapsed::before,
body.auth-body.sidebar-collapsed::after,
body.auth-body.no-sidebar-overlay::before,
body.auth-body.no-sidebar-overlay::after,
body.auth-body::before,
body.auth-body::after {
    content: none !important;
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

body.auth-body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    min-height: 100vh;
    min-height: 100dvh;
}

body.auth-body .auth-wrapper {
    position: relative;
    z-index: 2147483600 !important;
    isolation: isolate;
}

body.auth-body .auth-card {
    position: relative;
    z-index: 2147483601 !important;
    pointer-events: auto !important;
}

body.auth-body .auth-card,
body.auth-body .auth-card * {
    pointer-events: auto !important;
}

body.auth-body .modal-backdrop,
body.auth-body .offcanvas-backdrop,
body.auth-body .swal2-container,
body.auth-body .pwa-install-button,
body.auth-body .app-sidebar {
    display: none !important;
    pointer-events: none !important;
}

@media (max-width: 575.98px) {
    .auth-form .d-flex.justify-content-between.align-items-center.mb-4 {
        align-items: flex-start !important;
        gap: 8px;
    }
    .auth-form .form-check-label,
    .auth-form .small {
        font-size: .875rem;
        line-height: 1.25;
    }
}

/* Hotfix v1.1.6: True responsive application shell for mobile/tablet.
   - Uses a real clickable backdrop instead of body::after pseudo overlay.
   - Sidebar closes after a menu item is tapped.
   - Content, topbar, filters, tables, and DataTables adapt to small screens. */
body.app-body::before,
body.app-body::after {
    content: none !important;
    display: none !important;
    pointer-events: none !important;
}

.sidebar-backdrop {
    display: none;
}

.sidebar-close-btn {
    display: none;
}

.app-topbar .page-title-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.responsive-card-table {
    width: 100%;
}

.table-responsive,
.dataTables_wrapper,
.dt-container {
    max-width: 100%;
}

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

.table {
    vertical-align: middle;
}

.card,
.stat-card,
.auth-card {
    overflow-wrap: anywhere;
}

@media (min-width: 992px) {
    body.app-body.sidebar-collapsed .app-sidebar {
        margin-left: calc(var(--sidebar-width) * -1);
    }

    body.app-body.sidebar-collapsed .app-main {
        width: 100%;
    }
}

@media (max-width: 991.98px) {
    html,
    body.app-body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    body.app-body {
        min-height: 100dvh;
        background: var(--content-bg);
    }

    body.app-body.mobile-sidebar-open {
        overflow: hidden;
        touch-action: none;
    }

    .app-shell {
        display: block !important;
        min-height: 100dvh;
        width: 100%;
    }

    .app-sidebar {
        width: min(86vw, var(--sidebar-width));
        max-width: 320px;
        height: 100dvh;
        min-height: 100dvh;
        position: fixed !important;
        inset: 0 auto 0 0;
        z-index: 1060 !important;
        margin-left: 0 !important;
        transform: translate3d(-105%, 0, 0) !important;
        transition: transform .22s ease;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        box-shadow: 0 24px 64px rgba(15, 23, 42, .35);
    }

    body.app-body:not(.sidebar-collapsed) .app-sidebar,
    body.app-body.mobile-sidebar-open .app-sidebar {
        transform: translate3d(0, 0, 0) !important;
    }

    body.app-body.sidebar-collapsed .app-sidebar:not(.force-open) {
        transform: translate3d(-105%, 0, 0) !important;
    }

    .sidebar-brand {
        height: 64px;
        padding: 0 14px 0 18px;
        justify-content: space-between;
        position: sticky;
        top: 0;
        background: var(--sidebar-bg);
        z-index: 2;
    }

    .sidebar-close-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border: 0;
        border-radius: 12px;
        color: #ffffff;
        background: rgba(255,255,255,.10);
    }

    .sidebar-close-btn:active {
        transform: scale(.98);
    }

    .sidebar-nav {
        padding: 12px 10px max(22px, env(safe-area-inset-bottom));
    }

    .sidebar-nav a {
        min-height: 44px;
        padding: 11px 12px;
        font-size: 14px;
        touch-action: manipulation;
    }

    .sidebar-section {
        margin: 16px 10px 8px;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1050;
        background: rgba(15, 23, 42, .48);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity .18s ease, visibility .18s ease;
    }

    body.app-body:not(.sidebar-collapsed) .sidebar-backdrop,
    body.app-body.mobile-sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .app-main {
        width: 100% !important;
        min-width: 0;
        min-height: 100dvh;
    }

    .app-topbar {
        height: auto;
        min-height: 60px;
        padding: 8px 12px !important;
        gap: 8px;
        z-index: 1030;
    }

    .app-topbar > .d-flex:first-child {
        min-width: 0;
        flex: 1 1 auto;
    }

    .app-topbar .btn {
        min-width: 40px;
        min-height: 40px;
    }

    .topbar-actions {
        gap: 6px;
        flex: 0 0 auto;
    }

    .topbar-actions .btn {
        padding-left: .6rem;
        padding-right: .6rem;
    }

    .notification-dropdown {
        width: min(94vw, 360px) !important;
        max-width: calc(100vw - 16px);
    }

    .app-content {
        width: 100%;
        padding: 14px 10px max(80px, env(safe-area-inset-bottom)) !important;
    }

    .app-content > .d-flex,
    .card-header.d-flex,
    .card-body > .d-flex,
    .page-header,
    .filter-toolbar {
        flex-wrap: wrap;
        gap: .75rem !important;
    }

    .app-content > .d-flex > *,
    .card-header.d-flex > *,
    .filter-toolbar > * {
        min-width: 0;
    }

    .app-content .btn,
    .app-content .form-control,
    .app-content .form-select,
    .app-content .input-group-text {
        min-height: 42px;
    }

    .row.g-3,
    .row.g-4 {
        --bs-gutter-x: .75rem;
        --bs-gutter-y: .75rem;
    }

    .card {
        border-radius: 14px;
    }

    .card-body {
        padding: .95rem;
    }

    .stat-card {
        min-height: auto;
        padding: 14px;
        border-radius: 14px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        flex: 0 0 40px;
    }

    .stat-value {
        font-size: 22px;
    }

    .chart-card .card-body {
        height: auto;
        min-height: 280px;
    }

    .chart-card canvas {
        max-height: 240px;
    }

    .table-responsive {
        margin-bottom: .5rem;
        border: 1px solid var(--border-color);
        border-radius: 12px;
    }

    .table-responsive > .table {
        min-width: 720px;
        margin-bottom: 0;
    }

    .dt-container .row,
    .dataTables_wrapper .row {
        row-gap: .75rem;
    }

    .dt-container .dt-search,
    .dt-container .dt-length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        text-align: left !important;
    }

    .dt-container .dt-search input,
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 100%;
        margin-left: 0 !important;
        margin-top: .35rem;
    }

    .dt-container .dt-paging,
    .dataTables_wrapper .dataTables_paginate {
        overflow-x: auto;
        white-space: nowrap;
        width: 100%;
        padding-bottom: .25rem;
    }

    .ticket-subject-cell {
        max-width: 220px;
    }

    .ticket-sticky,
    .profile-card {
        position: static !important;
    }
}

@media (max-width: 575.98px) {
    :root {
        --sidebar-width: 280px;
    }

    .app-sidebar {
        width: min(82vw, 280px);
    }

    .sidebar-brand {
        font-size: 15px;
    }

    .sidebar-logo {
        width: 36px;
        height: 36px;
        border-radius: 11px;
    }

    .app-topbar .page-title-text {
        max-width: 46vw;
        font-size: .95rem;
    }

    .app-content h1,
    .app-content .h1 {
        font-size: 1.45rem;
    }

    .app-content h2,
    .app-content .h2,
    .app-content .h3 {
        font-size: 1.2rem;
    }

    .btn-group,
    .btn-toolbar {
        flex-wrap: wrap;
    }

    .btn-group > .btn,
    .btn-toolbar > .btn,
    .app-content .btn:not(.dropdown-toggle):not(.btn-close) {
        white-space: normal;
    }

    .form-check-inline {
        display: block;
        margin-right: 0;
        margin-bottom: .35rem;
    }

    .input-group {
        flex-wrap: nowrap;
    }

    .modal-dialog {
        margin: .5rem;
    }

    .dropdown-menu {
        max-width: calc(100vw - 16px);
    }
}


/* Hotfix v1.1.7: Responsive tables for mobile devices.
   Problem fixed: table columns became very narrow and text was displayed vertically on phones.
   Strategy:
   - Phones: convert DataTables/Bootstrap tables into readable card rows using data-label.
   - Tablets: keep normal table but force horizontal scrolling and no one-letter wrapping.
   - Desktop: keep existing table layout. */
.table-scroll-hint {
    display: none;
    color: #64748b;
    font-size: .825rem;
    margin-bottom: .5rem;
}

.table-responsive,
.dataTables_wrapper,
.dt-container {
    width: 100%;
    max-width: 100%;
}

.table-responsive table,
.dataTables_wrapper table,
.dt-container table {
    max-width: 100%;
}

.table th,
.table td {
    overflow-wrap: break-word;
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .table-responsive {
        overflow-x: auto !important;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        border: 1px solid var(--border-color);
        border-radius: 12px;
    }

    .table-responsive table,
    .dataTables_wrapper table,
    .dt-container table,
    table.datatable-simple,
    table#ticketsTable {
        min-width: 860px !important;
        width: max-content !important;
        max-width: none !important;
    }

    .table-responsive th,
    .table-responsive td,
    .dataTables_wrapper th,
    .dataTables_wrapper td,
    .dt-container th,
    .dt-container td {
        white-space: nowrap !important;
        vertical-align: middle;
    }

    .table-responsive td .small,
    .dataTables_wrapper td .small,
    .dt-container td .small {
        white-space: normal !important;
    }

    .table-scroll-hint {
        display: block;
    }
}

@media (max-width: 767.98px) {
    .table-scroll-hint {
        display: none !important;
    }

    .table-responsive {
        overflow: visible !important;
        border: 0 !important;
        border-radius: 0 !important;
    }

    .table-responsive > .table,
    .table-responsive table,
    .dataTables_wrapper table,
    .dt-container table,
    table.datatable-simple,
    table#ticketsTable {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    table.datatable-simple,
    table#ticketsTable,
    .table.mobile-card-table {
        border-collapse: separate !important;
        border-spacing: 0 .85rem !important;
        background: transparent !important;
    }

    table.datatable-simple thead,
    table#ticketsTable thead,
    .table.mobile-card-table thead,
    .dataTables_scrollHead {
        display: none !important;
    }

    table.datatable-simple tbody,
    table#ticketsTable tbody,
    .table.mobile-card-table tbody {
        display: block !important;
        width: 100% !important;
    }

    table.datatable-simple tr,
    table#ticketsTable tr,
    .table.mobile-card-table tr {
        display: block !important;
        width: 100% !important;
        margin-bottom: .85rem;
        background: #ffffff;
        border: 1px solid var(--border-color);
        border-radius: 15px;
        box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
        overflow: hidden;
    }

    table.datatable-simple td,
    table#ticketsTable td,
    .table.mobile-card-table td {
        display: grid !important;
        grid-template-columns: minmax(108px, 38%) minmax(0, 1fr);
        gap: .7rem;
        align-items: start;
        width: 100% !important;
        max-width: 100% !important;
        padding: .72rem .85rem !important;
        border: 0 !important;
        border-bottom: 1px solid #eef2f7 !important;
        white-space: normal !important;
        word-break: normal !important;
        overflow-wrap: anywhere !important;
        text-align: left !important;
        line-height: 1.35;
    }

    table.datatable-simple td:last-child,
    table#ticketsTable td:last-child,
    .table.mobile-card-table td:last-child {
        border-bottom: 0 !important;
    }

    table.datatable-simple td::before,
    table#ticketsTable td::before,
    .table.mobile-card-table td::before {
        content: attr(data-label);
        color: #64748b;
        font-size: .74rem;
        font-weight: 800;
        letter-spacing: .035em;
        text-transform: uppercase;
        line-height: 1.25;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    table.datatable-simple td[data-label=""]::before,
    table#ticketsTable td[data-label=""]::before,
    .table.mobile-card-table td[data-label=""]::before {
        content: none;
    }

    table.datatable-simple td[colspan],
    table#ticketsTable td[colspan],
    .table.mobile-card-table td[colspan] {
        display: block !important;
        text-align: center !important;
    }

    table.datatable-simple td[colspan]::before,
    table#ticketsTable td[colspan]::before,
    .table.mobile-card-table td[colspan]::before {
        content: none !important;
    }

    table.datatable-simple td.text-end,
    table#ticketsTable td.text-end,
    .table.mobile-card-table td.text-end {
        text-align: left !important;
    }

    table.datatable-simple td .btn-group,
    table#ticketsTable td .btn-group,
    .table.mobile-card-table td .btn-group {
        display: flex !important;
        flex-wrap: wrap;
        gap: .35rem;
        justify-content: flex-start;
    }

    table.datatable-simple td .btn,
    table#ticketsTable td .btn,
    .table.mobile-card-table td .btn {
        min-height: 36px;
        border-radius: .55rem !important;
        margin: 0 !important;
    }

    table.datatable-simple td form.d-inline,
    table#ticketsTable td form.d-inline,
    .table.mobile-card-table td form.d-inline {
        display: inline-flex !important;
    }

    .dataTables_wrapper,
    .dt-container {
        overflow: visible !important;
    }

    .dataTables_wrapper .row,
    .dt-container .row,
    .dt-layout-row {
        display: block !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .dataTables_wrapper .row > *,
    .dt-container .row > *,
    .dt-layout-row > * {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-bottom: .75rem;
        text-align: left !important;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dt-container .dt-length,
    .dt-container .dt-search {
        display: block !important;
        width: 100% !important;
        text-align: left !important;
    }

    .dataTables_wrapper .dataTables_length label,
    .dataTables_wrapper .dataTables_filter label,
    .dt-container .dt-length label,
    .dt-container .dt-search label {
        display: block !important;
        width: 100% !important;
    }

    .dataTables_wrapper .dataTables_length select,
    .dt-container .dt-length select {
        width: auto !important;
        display: inline-block !important;
        margin: 0 .35rem !important;
    }

    .dataTables_wrapper .dataTables_filter input,
    .dt-container .dt-search input {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: .4rem 0 0 0 !important;
    }

    .dataTables_wrapper .dataTables_info,
    .dt-container .dt-info {
        font-size: .85rem;
    }

    .dataTables_wrapper .dataTables_paginate,
    .dt-container .dt-paging {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding-bottom: .25rem;
    }

    .dataTables_scroll,
    .dataTables_scrollBody {
        overflow: visible !important;
        border: 0 !important;
        width: 100% !important;
    }

    .ticket-subject-cell {
        display: block;
        max-width: 100%;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }
}


/* Hotfix v1.3.5: searchable combo box for all Bootstrap selects */
.hd-searchable-select-native {
    position: absolute !important;
    opacity: 0 !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    pointer-events: none !important;
}

.hd-searchable-select {
    position: relative;
    width: 100%;
}

.hd-searchable-select-control {
    width: 100%;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .375rem .75rem;
    border: 1px solid #dee2e6;
    border-radius: .375rem;
    background: #fff;
    color: #212529;
    font-size: 1rem;
    line-height: 1.5;
    text-align: left;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.hd-searchable-select-control:hover {
    border-color: #b6c2d1;
}

.hd-searchable-select-control:focus,
.hd-searchable-select.is-open .hd-searchable-select-control {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 .25rem rgba(13, 110, 253, .25);
}

.hd-searchable-select.is-invalid .hd-searchable-select-control {
    border-color: #dc3545;
}

.hd-searchable-select.is-invalid .hd-searchable-select-control:focus,
.hd-searchable-select.is-invalid.is-open .hd-searchable-select-control {
    box-shadow: 0 0 0 .25rem rgba(220, 53, 69, .25);
}

.hd-searchable-select.is-disabled .hd-searchable-select-control,
.hd-searchable-select-control:disabled {
    background-color: #e9ecef;
    opacity: 1;
    cursor: not-allowed;
}

.hd-searchable-select-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hd-searchable-select-icon {
    flex: 0 0 auto;
    font-size: .75rem;
    color: #64748b;
    transition: transform .15s ease-in-out;
}

.hd-searchable-select.is-open .hd-searchable-select-icon {
    transform: rotate(180deg);
}

.hd-searchable-select-menu {
    position: absolute;
    z-index: 1085;
    top: calc(100% + .25rem);
    left: 0;
    right: 0;
    max-height: 320px;
    overflow: hidden;
    border: 1px solid #dee2e6;
    border-radius: .65rem;
    background: #fff;
}

.hd-searchable-select-search-wrap {
    padding: .55rem;
    border-bottom: 1px solid #eef2f7;
    background: #f8fafc;
}

.hd-searchable-select-list {
    max-height: 252px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: .35rem;
}

.hd-searchable-select-option {
    width: 100%;
    display: block;
    padding: .52rem .65rem;
    border: 0;
    border-radius: .45rem;
    background: transparent;
    color: #212529;
    text-align: left;
    line-height: 1.35;
    cursor: pointer;
}

.hd-searchable-select-option:hover,
.hd-searchable-select-option:focus {
    background: #eef6ff;
    outline: 0;
}

.hd-searchable-select-option.is-selected {
    background: #0d6efd;
    color: #fff;
    font-weight: 600;
}

.hd-searchable-select-option.is-placeholder {
    color: #64748b;
}

.hd-searchable-select-option:disabled {
    color: #94a3b8;
    cursor: not-allowed;
    background: transparent;
}

.hd-searchable-select-empty {
    padding: .8rem .65rem;
    text-align: center;
}

.input-group > .hd-searchable-select {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

@media (max-width: 575.98px) {
    .hd-searchable-select-control {
        min-height: 44px;
        font-size: .95rem;
    }

    .hd-searchable-select-menu {
        max-height: 60vh;
        border-radius: .8rem;
    }

    .hd-searchable-select-list {
        max-height: calc(60vh - 62px);
    }
}

/* Hotfix v1.3.9: Maintenance photo upload */
.maintenance-photo-thumb img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    background: #f8fafc;
}
@media (max-width: 575.98px) {
    .maintenance-photo-thumb img {
        height: 96px;
    }
}
