/* =======================================================
   KAMMEWT TASK MANAGEMENT SYSTEM
   Main Professional Stylesheet
   Color Palette:
     Primary:    #102A8A
     Dark:       #0B1220
     Background: #F5F7FA
     White:      #FFFFFF
     Success:    #198754
     Warning:    #FFC107
     Danger:     #DC3545
   ======================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700&display=swap');
@import url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css');

:root {
    --primary-color: #102A8A;
    --primary-hover: #0c206b;
    --primary-light: #e8ecf8;
    --dark-color: #0B1220;
    --dark-surface: #131c31;
    --bg-color: #F5F7FA;
    --white: #FFFFFF;
    --border-color: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --sidebar-width: 260px;
    --header-height: 70px;
    --success-color: #198754;
    --warning-color: #f59e0b;
    --danger-color: #DC3545;
    --card-shadow: 0 4px 16px rgba(11, 18, 32, 0.05);
    --hover-shadow: 0 8px 24px rgba(16, 42, 138, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-speed: 0.25s;
}

* {
    box-sizing: border-box;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img, video, iframe, canvas, svg {
    max-width: 100%;
    height: auto;
}

h1, h2, h3, h4, h5, h6, .brand-font {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--dark-color);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-speed);
}
a:hover {
    color: var(--primary-hover);
}

/* =======================================================
   LOGIN PAGE STYLES
   ======================================================= */
.login-body {
    background: linear-gradient(135deg, #0B1220 0%, #102A8A 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    width: 100%;
    max-width: 460px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-header {
    background: linear-gradient(135deg, #0B1220 0%, #102A8A 100%);
    padding: 32px 28px;
    text-align: center;
    color: var(--white);
}

.login-header .logo-badge {
    width: 88px;
    height: 88px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 14px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    padding: 0;
}

.login-header .logo-badge img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px;
    display: block;
}


.login-header h2 {
    color: var(--white);
    font-size: 1.5rem;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.login-header p {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
    margin-bottom: 0;
}

.login-body-content {
    padding: 32px 28px;
}

.demo-credentials-box {
    background-color: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-top: 20px;
    font-size: 0.8rem;
}

/* =======================================================
   APP LAYOUT (SIDEBAR + HEADER + MAIN)
   ======================================================= */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--dark-color);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: transform var(--transition-speed) ease-in-out, width var(--transition-speed);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background-color: rgba(0, 0, 0, 0.2);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--white);
    text-decoration: none;
}

.sidebar-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--white);
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.sidebar-brand .brand-icon img.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sidebar-brand .brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--white);
    line-height: 1.1;
}

.sidebar-brand .brand-subtitle {
    font-size: 0.68rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
}

.sidebar-menu-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 18px 12px;
}

.sidebar-heading {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, 0.4);
    padding: 10px 14px 6px;
    font-weight: 600;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
}

.sidebar-nav-item {
    margin-bottom: 4px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-speed);
}

.sidebar-nav-link i {
    font-size: 1.15rem;
    margin-right: 12px;
    width: 22px;
    text-align: center;
}

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

.sidebar-nav-link.active {
    color: var(--white);
    background-color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(16, 42, 138, 0.35);
}

.sidebar-nav-link .badge {
    margin-left: auto;
    font-size: 0.72rem;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background-color: rgba(0, 0, 0, 0.2);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    margin: -8px -10px;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-speed), transform var(--transition-speed);
    cursor: pointer;
}

.sidebar-user:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-user:hover .bi-gear-fill {
    color: var(--white) !important;
    transform: rotate(45deg);
    transition: transform 0.3s ease, color 0.3s ease;
}

.user-avatar {
    width: 38px;
    height: 38px;
    background: var(--primary-light);
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.user-info {
    overflow: hidden;
    line-height: 1.2;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--white);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role-badge {
    display: inline-block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
    margin-top: 3px;
}

/* Main Content Area */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--bg-color);
    transition: margin-left var(--transition-speed);
}

/* Header Navbar */
.app-header {
    height: var(--header-height);
    background-color: var(--white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle-btn {
    background: transparent;
    border: none;
    font-size: 1.35rem;
    color: var(--text-main);
    cursor: pointer;
    display: none;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}
.sidebar-toggle-btn:hover {
    background-color: var(--bg-color);
}

.header-search {
    position: relative;
    width: 320px;
}

.header-search input {
    width: 100%;
    padding: 8px 14px 8px 36px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    font-size: 0.85rem;
    transition: all var(--transition-speed);
}
.header-search input:focus {
    background-color: var(--white);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 42, 138, 0.1);
    outline: none;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 18px;
}

.header-btn {
    position: relative;
    background: transparent;
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    font-size: 1.15rem;
    transition: all var(--transition-speed);
    text-decoration: none;
}
.header-btn:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.header-btn .notification-pill {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: var(--danger-color);
    color: var(--white);
    font-size: 0.68rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--white);
}

/* Page Content Body */
.page-content {
    flex: 1;
    padding: 28px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 1.6rem;
    margin: 0;
    font-weight: 700;
    color: var(--dark-color);
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 4px;
    margin-bottom: 0;
}

/* =======================================================
   CARDS & KPI STATS
   ======================================================= */
.card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--hover-shadow);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    color: var(--dark-color);
}

.card-body {
    padding: 20px;
}

/* KPI Stat Cards */
.kpi-card-link {
    display: block;
    text-decoration: none !important;
    color: inherit !important;
    height: 100%;
    cursor: pointer;
}

.kpi-card-link:hover {
    text-decoration: none !important;
    color: inherit !important;
}

.kpi-card {
    position: relative;
    overflow: hidden;
    padding: 22px 20px;
    border-radius: var(--radius-md);
    background: var(--white);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    cursor: pointer;
}

.kpi-card:hover,
.kpi-card-link:hover .kpi-card {
    transform: translateY(-4px);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.09);
    border-color: rgba(26, 86, 219, 0.3);
}

/* Back Navigation Buttons */
.back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 15px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--white);
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all var(--transition-speed);
    white-space: nowrap;
}

.back-btn:hover {
    background: #f8fafc;
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateX(-3px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.back-btn i {
    font-size: 0.95rem;
    transition: transform var(--transition-speed);
}

.back-btn:hover i {
    transform: translateX(-2px);
}

.header-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--white);
    color: var(--text-dark);
    transition: all var(--transition-speed);
}

.header-back-btn:hover {
    background: #f8fafc;
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateX(-2px);
}

.kpi-card-link:hover .kpi-icon-bubble {
    transform: scale(1.08);
}

.kpi-info h6 {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.kpi-info .kpi-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--dark-color);
    line-height: 1;
    font-family: 'Outfit', sans-serif;
}

.kpi-icon-bubble {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
}

.bubble-primary { background: rgba(16, 42, 138, 0.1); color: var(--primary-color); }
.bubble-success { background: rgba(25, 135, 84, 0.1); color: var(--success-color); }
.bubble-warning { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.bubble-danger  { background: rgba(220, 53, 69, 0.1); color: var(--danger-color); }
.bubble-info    { background: rgba(14, 165, 233, 0.1); color: #0284c7; }
.bubble-dark    { background: rgba(11, 18, 32, 0.08); color: var(--dark-color); }

/* =======================================================
   TABLES & RAILWAY WORK REFERENCE TABLE
   ======================================================= */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.custom-table {
    width: 100%;
    margin-bottom: 0;
    vertical-align: middle;
    border-collapse: separate;
    border-spacing: 0;
}

.custom-table th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.custom-table td {
    padding: 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.88rem;
    color: var(--text-main);
    background-color: var(--white);
}

.custom-table tr:hover td {
    background-color: #f8fafc;
}

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

/* Railway Reference Table Aesthetic */
.rail-table-header {
    background: linear-gradient(135deg, var(--dark-color) 0%, var(--primary-color) 100%) !important;
    color: var(--white) !important;
    font-weight: 700;
}

/* Progress bar inside tables */
.table-progress {
    height: 7px;
    border-radius: 4px;
    background-color: #e2e8f0;
    overflow: hidden;
    width: 90px;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

/* Badges */
.badge-status {
    font-size: 0.74rem;
    font-weight: 600;
    padding: 5px 9px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
}

/* =======================================================
   FILTER BAR & SEARCH CONTROLS
   ======================================================= */
.filter-card {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    font-size: 0.88rem;
    transition: all var(--transition-speed);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 42, 138, 0.12);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--white);
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    transition: all var(--transition-speed);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
    border-radius: var(--radius-sm);
}
.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: var(--white);
}

/* =======================================================
   MESSAGING & CHAT SYSTEM
   ======================================================= */
.chat-container {
    display: flex;
    height: calc(100vh - 200px);
    min-height: 520px;
    background: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.chat-contacts {
    width: 300px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background-color: #fafbfc;
}

.chat-contacts-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    padding: 0;
    margin: 0;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background-color var(--transition-speed);
    text-decoration: none;
    color: var(--text-main);
}
.contact-item:hover {
    background-color: #f1f5f9;
}
.contact-item.active {
    background-color: var(--primary-light);
    border-left: 4px solid var(--primary-color);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--white);
}

.chat-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fafbfc;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background-color: #f8fafc;
}

.message-bubble {
    max-width: 68%;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.45;
    position: relative;
    word-break: break-word;
}

.message-bubble.incoming {
    align-self: flex-start;
    background-color: var(--white);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 2px;
}

.message-bubble.outgoing {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: var(--white);
    border-bottom-right-radius: 2px;
}

.message-time {
    font-size: 0.68rem;
    opacity: 0.75;
    margin-top: 4px;
    text-align: right;
}

.chat-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--white);
}

/* =======================================================
   EMPTY STATES
   ======================================================= */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 3.2rem;
    color: #cbd5e1;
    margin-bottom: 14px;
    display: inline-block;
}
.empty-state h5 {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 6px;
}

/* =======================================================
   FOOTER
   ======================================================= */
.app-footer {
    padding: 18px 28px;
    background-color: var(--white);
    border-top: 1px solid var(--border-color);
    font-size: 0.82rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* =======================================================
   RESPONSIVE DESIGN (DESKTOP, TABLET & MOBILE)
   ======================================================= */
/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(11, 18, 32, 0.6);
    backdrop-filter: blur(3px);
    z-index: 1035;
    display: none;
    opacity: 0;
    transition: opacity var(--transition-speed);
}

.sidebar-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--white);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background-color var(--transition-speed);
}
.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Nav tabs / Nav pills responsive horizontal scroll */
.nav-pills, .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    padding-bottom: 4px;
}
.nav-pills::-webkit-scrollbar, .nav-tabs::-webkit-scrollbar {
    height: 4px;
}
.nav-pills .nav-link, .nav-tabs .nav-link {
    white-space: nowrap;
    flex-shrink: 0;
}

/* =======================================================
   REPORTS TABLE — VERTICAL + HORIZONTAL SCROLLING
   ======================================================= */
.reports-scroll-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 560px;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}
.reports-scroll-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background-color: #f8fafc;
    box-shadow: 0 2px 0 var(--border-color);
}

/* =======================================================
   DESKTOP & WIDE SCREENS (>= 1200px)
   ======================================================= */
@media (min-width: 1200px) {
    .page-content {
        padding: 32px;
    }
}

/* =======================================================
   LAPTOP & MEDIUM SCREENS (992px to 1199.98px)
   ======================================================= */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .page-content {
        padding: 24px;
    }
    .app-header {
        padding: 0 20px;
    }
    .kpi-card {
        padding: 18px 16px;
    }
    .kpi-info .kpi-value {
        font-size: 1.6rem;
    }
}

/* =======================================================
   TABLET & SMALLER DEVICES (<= 991.98px)
   ======================================================= */
@media (max-width: 991.98px) {
    :root {
        --sidebar-width: 270px;
        --header-height: 64px;
    }
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 35px rgba(0, 0, 0, 0.35);
        z-index: 1045;
        width: min(280px, 85vw);
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
    .app-main {
        margin-left: 0 !important;
        width: 100%;
        max-width: 100vw;
    }
    .app-header {
        padding: 0 16px;
        height: var(--header-height);
    }
    .sidebar-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        font-size: 1.45rem;
    }
    .header-search {
        width: 200px;
    }
    .chat-container {
        flex-direction: column;
        height: calc(100vh - 140px);
        min-height: 480px;
    }
    .chat-contacts {
        width: 100%;
        height: 170px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .page-content {
        padding: 20px 16px;
    }
    /* Card headers wrap on tablet */
    .card-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    /* Reports vertical scroll: shorter on tablet */
    .reports-scroll-wrap {
        max-height: 420px;
    }
}

/* =======================================================
   MOBILE DEVICES (<= 767.98px)
   ======================================================= */
@media (max-width: 767.98px) {
    :root {
        --header-height: 60px;
    }

    /* Typography */
    .page-title {
        font-size: 1.3rem;
        line-height: 1.25;
    }
    .page-subtitle {
        font-size: 0.8rem;
    }

    /* Page headers: stack vertically */
    .page-header,
    .d-flex.justify-content-between.align-items-center.mb-4,
    .d-flex.justify-content-between.align-items-md-center.gap-3.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }

    /* Button groups in page headers: full width, wrap */
    .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex.gap-2,
    .d-flex.justify-content-between.align-items-md-center.gap-3.mb-4 > .d-flex.gap-2,
    .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex.gap-3,
    .page-header > .d-flex.gap-2,
    .page-header > .d-flex.gap-3 {
        width: 100%;
        flex-wrap: wrap;
    }

    /* Buttons inside header groups */
    .page-header > .d-flex > .btn,
    .page-header > .d-flex > a.btn,
    .page-header > .d-flex > .btn-group,
    .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex.gap-2 > .btn,
    .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex.gap-2 > a.btn,
    .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex.gap-2 > .btn-group {
        flex: 1 1 auto;
        text-align: center;
        justify-content: center;
        display: inline-flex;
    }

    /* Btn groups mobile */
    .btn-group {
        width: 100%;
    }
    .btn-group > .btn:first-child {
        flex: 1;
    }

    /* KPI Cards */
    .kpi-card {
        padding: 14px 12px;
    }
    .kpi-info .kpi-value {
        font-size: 1.4rem;
    }
    .kpi-icon-bubble {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
        border-radius: 10px;
    }

    /* Cards */
    .card {
        margin-bottom: 16px;
        border-radius: var(--radius-sm);
    }
    .card-header {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .card-header h5,
    .card-header .card-header-title {
        font-size: 0.95rem;
    }
    .card-body {
        padding: 14px;
    }

    /* Filter cards */
    .filter-card {
        padding: 12px 14px;
        margin-bottom: 16px;
    }
    .filter-card form .row > [class*="col-"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
    .filter-card form .d-flex {
        width: 100%;
    }

    /* Tables */
    .table-responsive {
        border-radius: var(--radius-sm);
        margin: 0;
        -webkit-overflow-scrolling: touch;
    }
    .custom-table th,
    .custom-table td {
        padding: 9px 11px;
        font-size: 0.81rem;
    }

    /* Reports vertical scroll: shorter on mobile */
    .reports-scroll-wrap {
        max-height: 360px;
    }

    /* Dashboard inner filter bar — 2-col grid */
    .card-body.border-bottom .row > [class*="col-"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
    .card-body.border-bottom .row > .col-md-2:last-child,
    .card-body.border-bottom .row > .col-sm-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Footer */
    .app-footer {
        flex-direction: column;
        gap: 6px;
        text-align: center;
        padding: 12px 14px;
    }

    /* Prevent iOS auto-zoom on inputs */
    .form-control,
    .form-select,
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Modals */
    .modal-dialog {
        margin: 6px auto;
        max-width: calc(100% - 12px);
    }
    .modal-header {
        padding: 14px 16px;
    }
    .modal-body {
        padding: 14px !important;
    }
    .modal-footer {
        padding: 10px 14px !important;
        flex-direction: column-reverse;
        gap: 8px;
    }
    .modal-footer > * {
        width: 100%;
        margin: 0 !important;
        text-align: center;
        display: inline-flex;
        justify-content: center;
        align-items: center;
    }
}

/* =======================================================
   EXTRA SMALL PHONES (<= 575.98px)
   ======================================================= */
@media (max-width: 575.98px) {
    .header-search {
        display: none;
    }
    .page-content {
        padding: 10px;
    }
    .app-header {
        padding: 0 10px;
    }
    .header-right {
        gap: 8px;
    }

    /* Dropdown menus: full width */
    .dropdown-menu {
        max-width: calc(100vw - 20px) !important;
        right: 0 !important;
        left: auto !important;
    }

    /* KPI Cards: smaller */
    .kpi-card {
        padding: 10px 9px;
    }
    .kpi-info h6 {
        font-size: 0.66rem;
        letter-spacing: 0.4px;
    }
    .kpi-info .kpi-value {
        font-size: 1.2rem;
    }
    .kpi-icon-bubble {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    /* Buttons smaller */
    .btn {
        font-size: 0.82rem;
        padding: 7px 11px;
    }
    .badge {
        font-size: 0.68rem;
    }

    /* Login page */
    .login-body {
        padding: 10px;
    }
    .login-header {
        padding: 20px 16px;
    }
    .login-body-content {
        padding: 20px 16px;
    }

    /* Page header buttons: stack fully on tiny phones */
    .page-header > .d-flex {
        flex-direction: column;
        width: 100%;
    }
    .page-header > .d-flex > .btn,
    .page-header > .d-flex > a.btn,
    .page-header > .d-flex > .btn-group {
        width: 100%;
    }

    /* Filter bar: 1 column */
    .filter-card form .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .card-body.border-bottom .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* =======================================================
   PRINT STYLESHEET FOR REPORTS
   ======================================================= */
@media print {
    .app-sidebar,
    .app-header,
    .app-footer,
    .filter-card,
    .btn,
    .sidebar-overlay,
    .no-print {
        display: none !important;
    }
    .app-main {
        margin-left: 0 !important;
        background: var(--white) !important;
        width: 100% !important;
    }
    .page-content {
        padding: 0 !important;
    }
    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }
    body {
        background: #fff !important;
        color: #000 !important;
    }
    /* Remove max-height on print so all rows show */
    .table-responsive,
    .reports-scroll-wrap {
        max-height: none !important;
        overflow: visible !important;
    }
}

/* =======================================================
   CUSTOM ALWAYS-VISIBLE MODAL SCROLLBAR
   ======================================================= */
.modal-dialog-scrollable .modal-body {
    overflow-y: scroll !important;
    scrollbar-width: thin !important;
    scrollbar-color: #102a8a #f1f5f9 !important;
}

.modal-dialog-scrollable .modal-body::-webkit-scrollbar {
    width: 10px !important;
    display: block !important;
}

.modal-dialog-scrollable .modal-body::-webkit-scrollbar-track {
    background: #f1f5f9 !important;
    border-left: 1px solid #e2e8f0 !important;
    border-radius: 0 4px 4px 0 !important;
}

.modal-dialog-scrollable .modal-body::-webkit-scrollbar-thumb {
    background: #102a8a !important;
    border-radius: 6px !important;
    border: 2px solid #f1f5f9 !important;
}

.modal-dialog-scrollable .modal-body::-webkit-scrollbar-thumb:hover {
    background: #0d216b !important;
}


