*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --primary-color: #4f46e5;
    --primary-indigo: #6366f1;
    --primary-indigo-hover: #4f46e5;
    --secondary-color: #6366f1;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background-color: #f8fafc;
    --background-gradient: linear-gradient(135deg, #f0f4ff 0%, #e8ecf8 50%, #f0f4ff 100%);
    --text-color: #111827;
    --text-primary: #1e293b;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --sidebar-bg: #0f172a;
    --sidebar-text: rgba(255, 255, 255, 0.92);
    --glass-border: rgba(255, 255, 255, 0.5);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

body {
    background: var(--background-gradient);
    min-height: 100vh;
    margin: 0;
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    color: var(--text-primary);
}

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

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    height: 100vh;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.main-content {
    flex: 1;
    width: calc(100vw - 260px);
    max-width: calc(100vw - 260px);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.layout-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
    flex: 1;
    /* Consistent padding for all dashboard pages */
}

@media (max-width: 768px) {
    .layout-container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Glassmorphism Utilities */
.glass-panel {
    background: white;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 2rem;
}

.dashboard-card {
    background: white;
    border-radius: 20px;
    padding: 1.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.5);
    position: relative;
    z-index: 1;
}

.stat-card {
    background: white;
    border-radius: 20px;
    padding: 1.75rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* Typography */
h1,
h2,
h3 {
    margin: 0;
    font-weight: 700;
    color: #111827;
}

/* Sidebar Elements */
.logo-container {
    padding: 2rem 1.5rem;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-dept {
    padding: 1.5rem 1rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.65);
    margin-bottom: 1rem;
}

.nav-section {
    padding: 0 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.nav-section::-webkit-scrollbar {
    display: none;
}

.nav-label {
    padding: 0.75rem 0.75rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
    color: var(--sidebar-text);
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.sidebar-link.active {
    background: var(--primary-indigo);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Sign Out: clear contrast on dark sidebar */
.sidebar-signout {
    background: rgba(255, 255, 255, 0.12) !important;
    color: rgba(255, 255, 255, 0.95) !important;
    font-weight: 600;
    border-radius: 12px;
    margin: 0 0.5rem;
    width: calc(100% - 1rem) !important;
}
.sidebar-signout:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
}
.sidebar-signout i {
    opacity: 0.95;
}

.nav-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    background: #ef4444;
    border-radius: 9px;
    vertical-align: middle;
}

/* Buttons */
.btn {
    background: var(--primary-indigo);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
}

.btn:hover {
    background: var(--primary-indigo-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px -1px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: white;
    border: 1.5px solid var(--primary-indigo);
    color: var(--primary-indigo);
    font-weight: 600;
}

.btn-secondary:hover {
    background: white;
    border-color: var(--primary-indigo);
    color: var(--primary-indigo);
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: left;
    padding: 1rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #6b7280;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e5e7eb;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
    color: #374151;
}

tr:hover td {
    background: #f9fafb;
}

.spiceworks-table {
    background: transparent;
}

.spiceworks-table thead {
    background: #ffffff;
}

/* Ticket Toolbar */
.ticket-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    gap: 1rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 1000 !important;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toolbar-center {
    flex: 1;
    max-width: 500px;
}

.ticket-title-link:hover {
    color: var(--primary-indigo) !important;
}

.search-form {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0.25rem 0.75rem;
    transition: all 0.2s;
}

.search-form:focus-within {
    border-color: var(--primary-indigo);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.search-form input {
    border: none;
    background: transparent;
    padding: 0.5rem;
    width: 100%;
    outline: none;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.search-form button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-btn {
    background: white;
    border: 1px solid #e5e7eb;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-content {
    display: none;
    position: absolute;
    background: white;
    min-width: 160px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 10;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    margin-top: 4px;
}

.dropdown.active .dropdown-content {
    display: block;
}

.dropdown-content a {
    color: #374151;
    padding: 0.75rem 1rem;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
}

.dropdown-content a:hover {
    background: #f9fafb;
    border-radius: 8px;
}

/* User avatar dropdown (top-right on dashboards) – ensure it appears above cards/tickets */
.user-avatar-dropdown {
    position: relative;
    z-index: 9999 !important;
}

.user-avatar-dropdown-menu {
    z-index: 10000 !important;
}

.user-avatar-dropdown-item:hover {
    background: #f3f4f6 !important;
}

/* Badges & Indicators */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-open {
    background: #dcfce7;
    color: #15803d;
}

.status-pending {
    background: #fef9c3;
    color: #854d0e;
}

.status-closed {
    background: #f1f5f9;
    color: #475569;
}

.priority-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.priority-critical {
    color: #dc2626;
}

.priority-high {
    color: #ea580c;
}

.priority-medium {
    color: #ca8a04;
}

.priority-low {
    color: #16a34a;
}

.user-avatar-sm {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #0f172a;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    overflow: hidden;
}

/* Stat Cards Grid - original solid look */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    width: 100%;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.75rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: #111827;
    line-height: 1;
    margin-bottom: 0.75rem;
}

.stat-meta {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Dialogue Box / Modal (Glass) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
}

.close-modal {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #6B7280;
    font-size: 1.25rem;
}

/* Form inputs in Glass Modal */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: var(--text-primary);
    transition: all 0.2s;
}

.form-input:focus {
    background: white;
    border-color: var(--primary-indigo);
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}


/* Inline Assignee Dropdown */
.assignee-cell {
    position: relative;
    cursor: pointer;
}

.assignee-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 280px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 1000;
    padding: 1.25rem;
    margin-top: 0.5rem;
}

.assignee-dropdown.active {
    display: block;
    animation: dropdownFadeIn 0.2s ease-out;
}

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

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

.assignee-dropdown label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.assignee-dropdown select,
.assignee-dropdown input {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    outline: none;
    box-sizing: border-box;
}

.assignee-dropdown select:focus,
.assignee-dropdown input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.assignee-dropdown .btn-group {
    display: flex;
    gap: 0.5rem;
}

.assignee-dropdown .btn-group button {
    flex: 1;
    padding: 0.6rem;
    font-size: 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.assignee-dropdown .btn-save {
    background: #6366f1;
    color: white;
    border: none;
}

.assignee-dropdown .btn-save:hover {
    background: #4f46e5;
}

.assignee-dropdown .btn-cancel {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.assignee-dropdown .btn-cancel:hover {
    background: #e2e8f0;
}

/* Ticket management: assignee section – larger font */
.assignee-cell-name {
    font-size: 0.95rem;
    color: #475569;
    font-weight: 500;
}

.assignee-cell .assignee-cell-avatar {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    min-height: 26px !important;
    flex-shrink: 0 !important;
    font-size: 0.8rem !important;
    overflow: hidden;
}

.assignee-cell .assignee-assign-btn {
    font-size: 0.9rem !important;
    padding: 0.4rem 0.85rem !important;
}

/* Dashboard assignee dropdown – same design as ticket detail */
.assignee-dropdown-detail-style {
    width: 280px;
    padding: 0.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.assignee-dropdown-detail-style .assignee-dropdown-header {
    font-size: 0.75rem;
    color: #94a3b8;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.assignee-dropdown-detail-style .assignee-dropdown-btn {
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.75rem;
    background: none;
    border: none;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.assignee-dropdown-detail-style .assignee-dropdown-btn-primary {
    color: #6366f1;
}

.assignee-dropdown-detail-style .assignee-dropdown-btn-primary:hover {
    background: #f3f4f6;
}

.assignee-dropdown-detail-style .assignee-dropdown-btn-danger {
    color: #ef4444;
}

.assignee-dropdown-detail-style .assignee-dropdown-btn-danger:hover {
    background: #fee2e2;
}

/* PDF export button - full red box in Customer Log and Customer Details */
.btn-export-pdf,
a.btn-danger[href*="export=print"] {
    background: #ef4444 !important;
    background-color: #ef4444 !important;
    color: #ffffff !important;
    border: 1px solid #ef4444 !important;
    box-shadow: none !important;
    outline: none !important;
}
.btn-export-pdf:hover,
a.btn-danger[href*="export=print"]:hover {
    background: #dc2626 !important;
    background-color: #dc2626 !important;
    border: 1px solid #dc2626 !important;
    color: #ffffff !important;
    box-shadow: none !important;
    outline: none !important;
}
.btn-export-pdf:focus,
a.btn-danger[href*="export=print"]:focus {
    background: #ef4444 !important;
    background-color: #ef4444 !important;
    border: 1px solid #ef4444 !important;
    color: #ffffff !important;
    outline: none !important;
}

/* Ensure PDF export buttons stay solid red inside dashboard header (override blue gradient header button rule) */
.dashboard-page .dashboard-header .btn-export-pdf,
.dashboard-page .dashboard-header a.btn-export-pdf {
    background: #ef4444 !important;
    border: 1px solid #ef4444 !important;
    box-shadow: none !important;
}
.dashboard-page .dashboard-header .btn-export-pdf:hover,
.dashboard-page .dashboard-header a.btn-export-pdf:hover {
    background: #dc2626 !important;
    border: 1px solid #dc2626 !important;
    box-shadow: none !important;
}

.assignee-dropdown-detail-style .assignee-dropdown-field {
    margin: 0.5rem 0.75rem;
}

.assignee-dropdown-detail-style .assignee-dropdown-field label {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.3rem;
    display: block;
    font-weight: 600;
}

.assignee-dropdown-detail-style .assignee-dropdown-input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.assignee-dropdown-detail-style .assignee-dropdown-input:focus {
    border-color: #6366f1;
}

.assignee-dropdown-detail-style .assignee-dropdown-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 0.5rem 0;
}

.assignee-dropdown-detail-style .assignee-dropdown-employees {
    max-height: 220px;
    overflow-y: auto;
    overscroll-behavior: contain; /* Prevents background scrolling when reaching the end of the list */
    padding-right: 4px; /* Give space for scrollbar */
}

/* Custom scrollbar for the dropdown to make it obvious it's scrollable */
.assignee-dropdown-detail-style .assignee-dropdown-employees::-webkit-scrollbar {
    width: 6px;
}
.assignee-dropdown-detail-style .assignee-dropdown-employees::-webkit-scrollbar-track {
    background: transparent;
}
.assignee-dropdown-detail-style .assignee-dropdown-employees::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}
.assignee-dropdown-detail-style .assignee-dropdown-employees::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

.assignee-dropdown-detail-style .assignee-dropdown-emp-btn {
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.75rem;
    background: none;
    border: none;
    color: #334155;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.assignee-dropdown-detail-style .assignee-dropdown-emp-btn:hover {
    background: #f3f4f6;
}

.assignee-dropdown-detail-style .assignee-dropdown-emp-avatar {
    width: 24px;
    height: 24px;
    min-width: 24px;
    background: #e2e8f0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #64748b;
}

.assignee-dropdown-detail-style .assignee-dropdown-check {
    margin-left: auto;
    color: #10b981;
}

.assignee-dropdown-detail-style .assignee-dropdown-actions {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f1f5f9;
}

.assignee-dropdown-detail-style .assignee-dropdown-cancel {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.assignee-dropdown-detail-style .assignee-dropdown-cancel:hover {
    background: #e2e8f0;
}

/* ========== DASHBOARD ONLY: Premium Glassmorphism (blue) ========== */
.dashboard-page {
    position: relative;
    min-height: 100vh;
    margin: -2.5rem -2rem 0;
    padding: 2.5rem 2rem 3rem;
    background: #eef2ff;
    background-image:
        radial-gradient(ellipse 120% 70% at 5% 0%, rgba(99, 102, 241, 0.22), transparent 50%),
        radial-gradient(ellipse 80% 55% at 98% 5%, rgba(139, 92, 246, 0.18), transparent 48%),
        radial-gradient(ellipse 70% 50% at 50% 105%, rgba(59, 130, 246, 0.15), transparent 45%),
        linear-gradient(175deg, #fafbff 0%, #f1f5f9 40%, #e2e8f0 100%);
    border-radius: 0;
}

.dashboard-page .dashboard-header {
    position: relative;
    z-index: 100;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 22px;
    padding: 1.35rem 1.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.5) inset, 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.dashboard-page .dashboard-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.dashboard-page .dashboard-header .btn,
.dashboard-page .dashboard-header a.btn {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.95), rgba(79, 70, 229, 0.95)) !important;
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    color: white !important;
}

.dashboard-page .dashboard-header .btn:hover,
.dashboard-page .dashboard-header a.btn:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.dashboard-page .stats-grid {
    gap: 1.75rem;
    margin-bottom: 2.5rem;
}

/* Keep five KPI cards on one aligned row for dashboard headers. */
.dashboard-page .stats-grid.stats-grid-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 1200px) {
    .dashboard-page .stats-grid.stats-grid-5 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .dashboard-page .stats-grid.stats-grid-5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .dashboard-page .stats-grid.stats-grid-5 {
        grid-template-columns: 1fr;
    }
}

.dashboard-page .stat-card {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 100%;
}

.dashboard-page .stat-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.6), inset 0 1px 0 rgba(255, 255, 255, 1);
    border-color: rgba(255, 255, 255, 0.9);
}

.dashboard-page .stat-label {
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.dashboard-page .stat-value {
    font-size: 3.05rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.04em;
    line-height: 1.1;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.dashboard-page .stat-meta {
    font-weight: 600;
    font-size: 0.85rem;
}

/* Five KPI cards: compact fixed bands so digits line up; no forced stretch (taller dead space) */
.dashboard-page .stats-grid.stats-grid-5 > .stat-card {
    display: grid;
    grid-template-rows: 2.8rem 3.45rem auto;
    row-gap: 0.25rem;
    column-gap: 0;
    align-content: start;
    min-height: unset;
    height: auto;
    padding: 1.375rem 1.5rem;
}

.dashboard-page .stats-grid.stats-grid-5 > .stat-card .stat-label {
    height: 2.8rem;
    min-height: 0;
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    line-height: 1.3;
    box-sizing: border-box;
    align-self: stretch;
    text-align: center;
}

.dashboard-page .stats-grid.stats-grid-5 > .stat-card .stat-value {
    /* Same clamp for every card → digits stay aligned; shrinks on narrow viewports so 6+ digits fit */
    font-size: clamp(1.5rem, 1.7vw + 1.05rem, 3.05rem);
    letter-spacing: -0.045em;
    height: 3.45rem;
    margin: 0;
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex: unset;
    white-space: nowrap;
    /* Large figures sit low in the font box; nudge up for better balance with label + meta */
    transform: translateY(-0.28rem);
}

.dashboard-page .stats-grid.stats-grid-5 > .stat-card .stat-meta {
    margin: 0;
    align-self: stretch;
    padding-top: 0;
    width: 100%;
    text-align: center;
}

.dashboard-page .dashboard-card {
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 26px;
    padding: 2rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    overflow: visible;
}

/* Theme consistency: any .glass-panel inside dashboard-page uses same glass as .dashboard-card */
.dashboard-page .glass-panel {
    background: rgba(255, 255, 255, 0.45) !important;
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid rgba(255, 255, 255, 0.6) !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.dashboard-page .dashboard-card h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.dashboard-page .ticket-toolbar {
    flex-wrap: wrap;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.55) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.toolbar-btn-refresh:hover .toolbar-refresh-icon {
    display: inline-block;
    animation: toolbar-refresh-spin 0.6s ease;
}

@keyframes toolbar-refresh-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.dashboard-page .ticket-toolbar .search-form,
.dashboard-page .ticket-toolbar .dropdown-btn {
    background: rgba(255, 255, 255, 0.7) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
    border-radius: 14px !important;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.dashboard-page .ticket-toolbar .search-form:focus-within,
.dashboard-page .ticket-toolbar .dropdown-btn:hover {
    background: rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(255, 255, 255, 1) !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 1);
}

.dashboard-page .ticket-toolbar .btn {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.95), rgba(79, 70, 229, 0.95)) !important;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.dashboard-page .ticket-toolbar .btn:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.dashboard-page #search-results {
    border-top: 1px solid rgba(255, 255, 255, 0.4) !important;
    padding-top: 1rem !important;
    margin-top: 0.5rem;
}

.dashboard-page .spiceworks-table {
    border-radius: 16px;
    overflow: hidden;
}

.dashboard-page .spiceworks-table thead {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 2px 0 rgba(255, 255, 255, 0.3) inset;
}

.dashboard-page .spiceworks-table thead th {
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #475569;
    padding: 1rem 1rem;
}

.dashboard-page .spiceworks-table tbody tr {
    transition: background 0.2s ease;
}

.dashboard-page .spiceworks-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.25);
}

.dashboard-page .spiceworks-table tbody td {
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.dashboard-page .empty-state-box {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 2.5rem;
    color: #64748b;
    font-weight: 500;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* ========== CHATBOT TRAINING (CEO/Admin) – Premium glassmorphism ========== */
.dashboard-page.chatbot-training-page,
.chatbot-training-page {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* Force premium background even if .dashboard-page is not applied */
    background: #eef2ff;
    background-image:
        radial-gradient(ellipse 120% 70% at 5% 0%, rgba(99, 102, 241, 0.28), transparent 50%),
        radial-gradient(ellipse 80% 55% at 98% 5%, rgba(139, 92, 246, 0.22), transparent 48%),
        radial-gradient(ellipse 70% 50% at 50% 105%, rgba(59, 130, 246, 0.18), transparent 45%),
        linear-gradient(175deg, #fafbff 0%, #f1f5f9 38%, #e2e8f0 100%);
    margin: -2.5rem -2rem 0;
    padding: 2.5rem 2rem 3rem;
    border-radius: 0;
    min-height: 100%;
    position: relative;
}
.dashboard-page.chatbot-training-page .ct-header,
.chatbot-training-page .ct-header {
    margin-bottom: 2rem;
}
.dashboard-page.chatbot-training-page .ct-header .dashboard-header,
.chatbot-training-page .ct-header .dashboard-header {
    display: block;
    padding: 1.5rem 2rem;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 22px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}
.dashboard-page.chatbot-training-page .ct-header h1,
.chatbot-training-page .ct-header h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}
.dashboard-page.chatbot-training-page .ct-header-subtitle,
.chatbot-training-page .ct-header-subtitle {
    color: #64748b;
    font-size: 0.9375rem;
    line-height: 1.55;
    margin: 0.5rem 0 0 0;
    max-width: 36rem;
}

/* Cards – strong frosted glass */
.dashboard-page.chatbot-training-page .ct-card,
.chatbot-training-page .ct-card {
    margin-bottom: 2rem;
    padding: 2rem 2.25rem;
    background: rgba(255, 255, 255, 0.4) !important;
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid rgba(255, 255, 255, 0.75) !important;
    border-radius: 24px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}
.dashboard-page.chatbot-training-page .ct-card-title,
.chatbot-training-page .ct-card-title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin: 0 0 1.5rem 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}
.dashboard-page.chatbot-training-page .ct-card-title i,
.chatbot-training-page .ct-card-title i {
    color: var(--primary-indigo);
    font-size: 1.1rem;
}

/* Form – arranged layout (single column for clarity) */
.dashboard-page.chatbot-training-page .ct-form-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.dashboard-page.chatbot-training-page .ct-form-group {
    margin-bottom: 0;
}
.dashboard-page.chatbot-training-page .ct-form-group.ct-form-full {
    width: 100%;
}
.dashboard-page.chatbot-training-page .ct-label {
    display: block;
    font-weight: 600;
    color: #334155;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}
.dashboard-page.chatbot-training-page .ct-input,
.dashboard-page.chatbot-training-page .ct-textarea,
.chatbot-training-page .ct-input,
.chatbot-training-page .ct-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 14px;
    font-size: 0.9375rem;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    box-sizing: border-box;
}
.dashboard-page.chatbot-training-page .ct-input:focus,
.dashboard-page.chatbot-training-page .ct-textarea:focus,
.chatbot-training-page .ct-input:focus,
.chatbot-training-page .ct-textarea:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 1);
    background: rgba(255, 255, 255, 0.75);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25), inset 0 1px 0 rgba(255, 255, 255, 1);
}
.dashboard-page.chatbot-training-page .ct-textarea,
.chatbot-training-page .ct-textarea {
    resize: vertical;
    min-height: 120px;
}

/* Upload zone – frosted glass */
.dashboard-page.chatbot-training-page .ct-upload-zone,
.chatbot-training-page .ct-upload-zone {
    border: 2px dashed rgba(99, 102, 241, 0.55);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 2rem;
    text-align: center;
    transition: all 0.25s ease;
    margin-top: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.dashboard-page.chatbot-training-page .ct-upload-zone:hover,
.dashboard-page.chatbot-training-page .ct-upload-zone.has-file,
.chatbot-training-page .ct-upload-zone:hover,
.chatbot-training-page .ct-upload-zone.has-file {
    border-color: var(--primary-indigo);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.dashboard-page.chatbot-training-page .ct-upload-zone label,
.chatbot-training-page .ct-upload-zone label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}
.dashboard-page.chatbot-training-page .ct-upload-icon,
.chatbot-training-page .ct-upload-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: rgba(99, 102, 241, 0.18);
    color: var(--primary-indigo);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.dashboard-page.chatbot-training-page .ct-upload-text,
.chatbot-training-page .ct-upload-text {
    font-weight: 600;
    color: #334155;
    font-size: 0.9375rem;
}
.dashboard-page.chatbot-training-page .ct-upload-hint,
.chatbot-training-page .ct-upload-hint {
    color: #64748b;
    font-size: 0.8125rem;
}
.dashboard-page.chatbot-training-page .ct-file-name,
.chatbot-training-page .ct-file-name {
    font-size: 0.8125rem;
    color: var(--primary-indigo);
    font-weight: 600;
    display: none;
}
.dashboard-page.chatbot-training-page .ct-file-name.show,
.chatbot-training-page .ct-file-name.show {
    display: block;
    margin-top: 0.25rem;
}
.dashboard-page.chatbot-training-page .ct-upload-zone input[type="file"],
.chatbot-training-page .ct-upload-zone input[type="file"] {
    position: absolute;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}

/* Form actions */
.dashboard-page.chatbot-training-page .ct-form-actions,
.chatbot-training-page .ct-form-actions {
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.5);
}
/* Primary CTA – solid gradient, never outline */
.dashboard-page.chatbot-training-page .ct-btn-submit,
.chatbot-training-page .ct-btn-submit {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
    color: #fff !important;
    padding: 0.875rem 1.75rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: box-shadow 0.2s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    -webkit-appearance: none;
    appearance: none;
}
.dashboard-page.chatbot-training-page .ct-btn-submit:hover,
.chatbot-training-page .ct-btn-submit:hover {
    background: linear-gradient(135deg, #5558e3 0%, #4338ca 100%) !important;
    color: #fff !important;
    box-shadow: 0 8px 28px rgba(99, 102, 241, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

/* Knowledge base table card – frosted glass */
.dashboard-page.chatbot-training-page .ct-table-card,
.chatbot-training-page .ct-table-card {
    padding-bottom: 0;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.4) !important;
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid rgba(255, 255, 255, 0.75) !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}
.dashboard-page.chatbot-training-page .ct-table-card .ct-card-title {
    margin-bottom: 1rem;
}
.dashboard-page.chatbot-training-page .ct-table-scroll {
    min-height: 280px;
    max-height: calc(100vh - 380px);
    overflow-y: auto;
    overflow-x: auto;
    margin: 0 -2.25rem -2rem;
    border-radius: 0 0 26px 26px;
    -webkit-overflow-scrolling: touch;
}
.dashboard-page.chatbot-training-page .ct-table-scroll .spiceworks-table {
    margin: 0;
    border-radius: 0;
}
.dashboard-page.chatbot-training-page .ct-table-scroll .spiceworks-table thead th {
    padding: 1rem 2rem;
}
.dashboard-page.chatbot-training-page .ct-table-scroll .spiceworks-table tbody td {
    padding: 1rem 2rem;
    vertical-align: top;
}
.dashboard-page.chatbot-training-page .ct-cell-title {
    font-weight: 600;
    color: #1e293b;
    max-width: 180px;
    word-wrap: break-word;
}
.dashboard-page.chatbot-training-page .ct-cell-preview {
    color: #475569;
    max-width: 400px;
    min-width: 200px;
    line-height: 1.5;
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    max-height: 8em;
    overflow-y: auto;
}
.dashboard-page.chatbot-training-page .ct-cell-date {
    color: #94a3b8;
    font-size: 0.875rem;
}
.dashboard-page.chatbot-training-page .ct-btn-delete {
    color: #dc2626;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}
.dashboard-page.chatbot-training-page .ct-btn-delete:hover {
    color: #b91c1c;
}
.dashboard-page.chatbot-training-page .ct-empty-state {
    padding: 3rem 2rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.9375rem;
    line-height: 1.5;
}
.dashboard-page.chatbot-training-page .ct-th-action {
    width: 90px;
}

@media (max-width: 768px) {
    .dashboard-page {
        margin: -1.5rem -1.5rem 0;
        padding: 1.5rem 1.5rem 2rem;
    }
}

/* ==========================
   Mobile-only layout layer
   Desktop UI remains unchanged
   ========================== */
.mobile-sidebar-toggle,
.mobile-sidebar-overlay {
    display: none;
}

@media (max-width: 980px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100dvh;
        width: min(82vw, 300px);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1200;
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.25);
    }

    .main-content {
        width: 100%;
        max-width: 100%;
    }

    .layout-container {
        padding: 4.5rem 1rem 1.25rem;
    }

    .mobile-sidebar-toggle {
        position: fixed;
        top: 12px;
        left: 12px;
        width: 42px;
        height: 42px;
        border-radius: 10px;
        border: 1px solid #dbe3f3;
        background: rgba(255, 255, 255, 0.96);
        color: #0f172a;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 1rem;
        z-index: 1210;
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.15);
    }

    .mobile-sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(2, 6, 23, 0.5);
        z-index: 1190;
    }

    body.mobile-sidebar-open {
        overflow: hidden;
    }

    body.mobile-sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.mobile-sidebar-open .mobile-sidebar-overlay {
        display: block;
    }

    .dashboard-page {
        margin: -1.25rem -1rem 0;
        padding: 1.25rem 1rem 1.5rem;
    }

    .dashboard-page .dashboard-header {
        padding: 1rem;
        border-radius: 16px;
    }

    .dashboard-page .dashboard-header h1 {
        font-size: 1.3rem;
    }

    .stats-grid,
    .dashboard-page .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.9rem !important;
    }

    .stat-card,
    .dashboard-page .stat-card,
    .dashboard-card {
        border-radius: 14px;
        padding: 1rem;
    }

    .ticket-toolbar {
        padding: 0.75rem;
    }

    .toolbar-left,
    .toolbar-right,
    .toolbar-center {
        width: 100%;
        max-width: 100%;
    }

    .search-form {
        width: 100%;
    }

    th,
    td {
        padding: 0.6rem 0.5rem;
        font-size: 0.8rem;
    }

    #chatbot-widget {
        right: 14px !important;
        bottom: 14px !important;
    }
    #chatbot-panel {
        width: min(94vw, 380px) !important;
        max-width: 94vw !important;
        height: min(72dvh, 500px) !important;
    }
    #team-chat-launcher {
        right: 14px !important;
        bottom: 86px !important;
    }

    /* ===== Global mobile layer: keeps desktop unchanged ===== */
    .dashboard-page {
        margin: -1rem -1rem 0 !important;
        padding: 1rem 1rem 1.25rem !important;
    }

    .layout-container {
        padding: 4.5rem 1rem 1.25rem !important;
        max-width: 100% !important;
    }

    .dashboard-header {
        padding: 1rem !important;
        border-radius: 14px !important;
    }

    .dashboard-header h1 {
        font-size: 1.25rem !important;
        line-height: 1.35 !important;
        word-break: break-word;
    }

    .dashboard-header p {
        font-size: 0.85rem !important;
        line-height: 1.4 !important;
    }

    .stats-grid,
    .dashboard-page .stats-grid,
    [style*="grid-template-columns: repeat(5"],
    [style*="grid-template-columns: repeat(4"],
    [style*="grid-template-columns: repeat(3"],
    [style*="grid-template-columns: repeat(2"] {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    .dashboard-card,
    .stat-card,
    .glass-panel {
        padding: 1rem !important;
        border-radius: 14px !important;
    }

    .ticket-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.6rem !important;
        padding: 0.75rem !important;
    }
    .toolbar-left,
    .toolbar-right,
    .toolbar-center {
        width: 100% !important;
        max-width: 100% !important;
    }

    .search-form {
        width: 100% !important;
    }

    .btn,
    .btn-secondary {
        min-height: 40px;
    }

    /* Table usability on phone: horizontal scroll instead of clipped columns */
    .dashboard-card > div[style*="overflow-x: auto"],
    .dashboard-page div[style*="overflow-x: auto"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 680px;
    }
    th,
    td {
        font-size: 0.8rem !important;
        padding: 0.55rem 0.5rem !important;
        white-space: nowrap;
    }

    /* Forms and filter bars */
    form[method="GET"][style*="display: flex"],
    form[style*="display: flex"] {
        flex-wrap: wrap !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }

    input[type="text"],
    input[type="search"],
    input[type="date"],
    input[type="time"],
    input[type="email"],
    select,
    textarea {
        max-width: 100% !important;
        font-size: 16px !important; /* prevent mobile zoom */
    }

    /* Dropdown panels / popovers / assignment menus */
    .dropdown-content,
    .assignee-dropdown,
    #assignDropdown {
        max-width: 95vw !important;
        width: 100% !important;
        left: 0 !important;
        right: auto !important;
    }

    /* Modal readability on mobile */
    .modal-content {
        max-width: 94vw !important;
        max-height: 84dvh !important;
        padding: 1rem !important;
        border-radius: 14px !important;
    }

    /* Chat widgets should not block controls */
    #chatbot-widget {
        right: 12px !important;
        bottom: 12px !important;
        z-index: 950 !important;
    }
    #chatbot-panel {
        width: min(94vw, 380px) !important;
        max-width: 94vw !important;
        height: min(72dvh, 500px) !important;
    }
    #team-chat-launcher {
        right: 12px !important;
        bottom: 84px !important;
        z-index: 951 !important;
    }

    /* Ticket detail: mobile usability overrides only */
    .ticket-detail-shell {
        padding-bottom: 1rem !important;
    }
    .ticket-detail-header-card {
        padding: 1rem !important;
    }
    .ticket-detail-header-row {
        flex-direction: column !important;
        gap: 0.75rem !important;
        margin-bottom: 0.9rem !important;
    }
    .ticket-detail-header-row h1 {
        font-size: 1.25rem !important;
        line-height: 1.35 !important;
        word-break: break-word;
    }
    .ticket-detail-status-row {
        width: 100%;
        justify-content: flex-start !important;
    }
    .ticket-detail-meta-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
        margin-top: 0.85rem !important;
        padding-top: 0.85rem !important;
    }

    .ticket-detail-body-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    .ticket-detail-main-col,
    .ticket-sidebar-col {
        min-width: 0 !important;
    }
    .ticket-detail-main-col {
        order: 1;
    }
    .ticket-sidebar-col {
        order: 2;
    }

    .ticket-tab-btn {
        white-space: nowrap;
        font-size: 0.88rem !important;
        padding: 0.65rem 0.75rem !important;
    }
    .ticket-detail-tabs-row {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 0.5rem 0.6rem 0 !important;
        gap: 0.35rem !important;
    }
    .ticket-detail-tabs-body {
        padding: 0.9rem !important;
    }
    .ticket-detail-description-row,
    .ticket-detail-reply-head,
    .ticket-detail-reply-actions {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.65rem !important;
    }

    /* Ticket detail cards/controls are mostly inline-styled; override only on mobile */
    .ticket-detail-main-col .dashboard-card,
    .ticket-sidebar-col .dashboard-card {
        padding: 1rem !important;
        border-radius: 14px !important;
    }

    #replyForm .form-input,
    #replyForm textarea,
    #replyForm input[type="text"] {
        font-size: 16px !important; /* prevent iOS zoom on focus */
    }

    #assignDropdown {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    #pending-remark-modal > div {
        max-width: 94vw !important;
    }
}

@media (max-width: 640px) {
    .ticket-detail-body-grid {
        gap: 0.85rem !important;
    }

    .ticket-detail-main-col .dashboard-card,
    .ticket-sidebar-col .dashboard-card {
        padding: 0.85rem !important;
    }
    .ticket-detail-reply-card {
        padding: 0.85rem !important;
    }

    /* Keep tab row usable on narrow screens */
    .ticket-detail-main-col .dashboard-card > div[style*="display: flex"][style*="border-bottom"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-left: 0.65rem !important;
        padding-right: 0.65rem !important;
    }

    /* Attachments become single column for readability */
    .attachment-card-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    /* Full-width primary action buttons in sidebar/reply areas */
    .ticket-sidebar-col .btn,
    #replyForm .btn {
        width: 100%;
    }
    .ticket-sidebar-col [style*="max-height: 340px"] {
        max-height: 240px !important;
    }

    .layout-container {
        padding: 4.25rem 0.75rem 1rem !important;
    }
    .dashboard-page {
        margin: -0.75rem -0.75rem 0 !important;
        padding: 0.75rem 0.75rem 1rem !important;
    }
    .dashboard-header {
        padding: 0.85rem !important;
    }
    .dashboard-header h1 {
        font-size: 1.1rem !important;
    }
    .dashboard-card,
    .stat-card,
    .glass-panel {
        padding: 0.85rem !important;
        border-radius: 12px !important;
    }
    .btn,
    .btn-secondary {
        width: 100%;
    }
    table {
        min-width: 620px;
    }
}