/* Main Layout Structure */
#wrapper {
    display: flex;
    width: 100%;
}

#content-wrapper {
    background-color: #f4f7f6;
    width: 100%;
    overflow-x: hidden;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#content-wrapper.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

@media (max-width: 991.98px) {
    #content-wrapper {
        margin-left: 0;
    }

    #content-wrapper.sidebar-collapsed {
        margin-left: 0;
    }
}

/* Sidebar Styling */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    height: 100vh;
    position: fixed;
    z-index: 1000;
    transition: all 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

/* Custom Scrollbar for Sidebar (Webkit) */
#sidebar::-webkit-scrollbar {
    width: 6px;
}

#sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

#sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
    overflow: hidden;
}

.sidebar-heading {
    padding: 1.5rem 1rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-heading i {
    font-size: 1.5rem;
    margin-right: 0.75rem;
}

#sidebar.collapsed .sidebar-heading span {
    display: none;
}

#sidebar.collapsed .sidebar-heading {
    justify-content: center;
    padding: 1.5rem 0;
}

#sidebar.collapsed .sidebar-heading i {
    margin-right: 0;
}

#sidebar .list-group-item {
    background-color: transparent;
    border: none;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
    font-weight: 500;
}

#sidebar .list-group-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

#sidebar .list-group-item.active {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
}

#sidebar .list-group-item i {
    width: 25px;
    font-size: 1.1rem;
    margin-right: 1rem;
    text-align: center;
}

#sidebar.collapsed .list-group-item span {
    display: none;
}

#sidebar.collapsed .list-group-item {
    justify-content: center;
    padding: 1rem 0;
}

#sidebar.collapsed .list-group-item i {
    margin-right: 0;
}

/* Sidebar Submenus */
.list-group-item[data-bs-toggle="collapse"] {
    position: relative;
    cursor: pointer;
}

.list-group-item[data-bs-toggle="collapse"]::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 1.5rem;
    transition: transform 0.3s ease;
}

.list-group-item[aria-expanded="true"]::after {
    transform: rotate(180deg);
}

.sidebar-submenu {
    background-color: rgba(0, 0, 0, 0.15);
    padding-left: 1rem;
    border-left: 3px solid rgba(255, 255, 255, 0.05);
    margin-left: 1.5rem;
}

.sidebar-submenu .list-group-item {
    font-size: 0.85rem;
    padding: 0.6rem 1rem 0.6rem 1.5rem;
    color: rgba(255, 255, 255, 0.5);
    border-radius: 0 !important;
}

.sidebar-submenu .list-group-item:hover {
    color: #ffffff;
    background-color: transparent;
}

.sidebar-submenu .list-group-item.active {
    color: #ffffff !important;
    background-color: transparent !important;
    box-shadow: none !important;
    font-weight: 700;
}

.sidebar-submenu .list-group-item i {
    font-size: 0.85rem !important;
    width: 20px !important;
    margin-right: 0.5rem !important;
}

/* Hide arrow and submenus when collapsed */
#sidebar.collapsed .list-group-item[data-bs-toggle="collapse"]::after,
#sidebar.collapsed .sidebar-submenu {
    display: none !important;
}

/* Mobile Toggle Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

@media (max-width: 991.98px) {
    #sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
    }

    #sidebar.show {
        margin-left: 0;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* Header Styles */
.top-navbar {
    height: var(--navbar-height);
    background: #ffffff;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--dark-color);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: background 0.2s;
}

.sidebar-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Global Styles */
:root {
    --primary-color: #4361ee;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --info-color: #36b9cc;
    --warning-color: #f6c23e;
    --danger-color: #e74a3b;
    --light-color: #f8f9fc;
    --dark-color: #3f4254;
    --sidebar-bg: #1e1e2d;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --navbar-height: 60px;
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --card-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.05);
    --primary-soft: rgba(67, 97, 238, 0.1);
    --success-soft: rgba(28, 200, 138, 0.1);
    --info-soft: rgba(54, 185, 204, 0.1);
    --warning-soft: rgba(246, 194, 62, 0.1);
    --danger-soft: rgba(231, 74, 59, 0.1);
}

/* Box sizing for all elements */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Soft background utilities */
.bg-primary-soft {
    background-color: var(--primary-soft) !important;
    color: var(--primary-color) !important;
}

.bg-success-soft {
    background-color: var(--success-soft) !important;
    color: var(--success-color) !important;
}

.bg-info-soft {
    background-color: var(--info-soft) !important;
    color: var(--info-color) !important;
}

.bg-warning-soft {
    background-color: var(--warning-soft) !important;
    color: var(--warning-color) !important;
}

.bg-danger-soft {
    background-color: var(--danger-soft) !important;
    color: var(--danger-color) !important;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 0.5rem;
}

.breadcrumb-item.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* Targeted transitions ONLY on interactive elements - NOT global */
.btn,
.list-group-item,
.card,
.form-control,
.form-select,
.menu-item,
.sidebar-toggle,
.nav-link,
.dropdown-item {
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Sidebar get its own transition for smooth open/close */
#sidebar,
#content-wrapper {
    transition: margin-left 0.3s ease, width 0.3s ease;
}

body {
    background: #f4f7f6;
    font-family: 'Ubuntu', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    color: var(--dark-color);
    overflow-x: hidden !important;
    /* Ensure NO horizontal scroll on body */
    overflow-y: auto;
    width: 100%;
    position: relative;
}

/* Main container - single consolidated definition */
.container-fluid {
    padding: 15px 20px;
    max-width: 100%;
    overflow-x: hidden;
    width: 100%;
}


/* Card Styles */
.card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 12px;
    background: white;
    overflow: hidden;
}

/* Lift effect ONLY on interactive cards (menu items, stat cards) */
.menu-item:hover,
.card.card-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.card-header {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-bottom: 1px solid #e3e6f0;
    padding: 18px 24px;
    font-weight: 700;
    border-radius: 16px 16px 0 0;
}

.card-body {
    padding: 28px;
}

/* Page Headers */
.d-sm-flex.align-items-center {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e3e6f0;
}

.h3 {
    color: var(--dark-color);
    font-weight: 700;
}

/* Dashboard Menu Styles */
.dashboard-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    padding: 10px 0;
}

.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
    /* More compact padding */
    background-color: #ffffff;
    color: var(--dark-color);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    min-height: 100px;
    /* Reduced min-height for better fit */
    border: 1px solid #e2e8f0;
    position: relative;
    overflow: hidden;
}

.menu-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.menu-item:hover::before {
    transform: scaleX(1);
}

.menu-item:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    color: #054064;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
}

.menu-item i {
    font-size: 2.8rem;
    margin-bottom: 14px;
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-8px);
    }
}

.menu-item span {
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
}

/* Colored Icons */
.icon-blue {
    color: #3b82f6;
}

.icon-purple {
    color: #8b5cf6;
}

.icon-green {
    color: #10b981;
}

.icon-teal {
    color: #14b8a6;
}

.icon-success {
    color: #22c55e;
}

.icon-orange {
    color: #f97316;
}

.icon-pink {
    color: #ec4899;
}

.icon-indigo {
    color: #6366f1;
}

.icon-cyan {
    color: #06b6d4;
}

.icon-violet {
    color: #a855f7;
}

.icon-gray {
    color: #6b7280;
}

.icon-red {
    color: #ef4444;
}

/* Stat Cards */
.border-left-primary {
    border-left: 5px solid var(--primary-color) !important;
    border-radius: 16px;
}

.border-left-success {
    border-left: 5px solid var(--success-color) !important;
    border-radius: 16px;
}

.border-left-warning {
    border-left: 5px solid var(--warning-color) !important;
    border-radius: 16px;
}

.border-left-info {
    border-left: 5px solid var(--info-color) !important;
    border-radius: 16px;
}

.border-left-danger {
    border-left: 5px solid var(--danger-color) !important;
    border-radius: 16px;
}

/* Forms */
.form-label {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 8px;
}

.form-control,
.form-select {
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    padding: 12px 16px;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(78, 115, 223, 0.1);
    transform: translateY(-1px);
}

/* Buttons */
.btn {
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.btn-primary {
    background: linear-gradient(135deg, #4e73df 0%, #3b5fc7 100%);
    border-color: var(--primary-color);
    padding: 12px 28px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #3b5fc7 0%, #2e59d9 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(78, 115, 223, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #1cc88a 0%, #17a673 100%);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(28, 200, 138, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #e74a3b 0%, #d63426 100%);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(231, 74, 59, 0.3);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
    border-radius: 10px;
}

/* Navbar */
.navbar {
    padding: 15px 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 0.5rem !important;
    background-color: #054064 !important;
    border-radius: 0 !important;
}

.navbar-brand {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff !important;
    transition: all 0.3s ease;
}

.navbar-brand:hover {
    color: #e0e0e0 !important;
    transform: scale(1.05);
}

.navbar-dark .navbar-nav .nav-link {
    color: #ffffff !important;
    transition: all 0.3s ease;
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: #e0e0e0 !important;
    transform: translateY(-2px);
}

.btn-outline-primary {
    color: #ffffff;
    border-color: #ffffff;
    border-radius: 10px;
}

.btn-outline-primary:hover {
    background-color: #ffffff;
    border-color: #ffffff;
    color: #054064;
    transform: translateY(-2px);
}

.btn-outline-danger {
    color: #ffffff;
    border-color: #dc3545;
    background-color: #dc3545;
    border-radius: 10px;
}

.btn-outline-danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
    transform: translateY(-2px);
}

/* Tables */
.table-responsive {
    margin-top: 10px;
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-bottom: 2px solid #e3e6f0;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: var(--dark-color);
    padding: 16px;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
}

.table-hover tbody tr {
    transition: all 0.2s ease;
}

.table-hover tbody tr:hover {
    background-color: #f8fafc;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Alerts */
.alert {
    border-radius: 12px;
    border: none;
    padding: 16px 22px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: slideIn 0.3s ease;
}

.dropdown-item i {
    font-size: 0.85rem;
    width: 18px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Badges */
.badge {
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: 600;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

/* Motion Particles */
.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    animation: float-particle linear infinite;
    bottom: -100px;
}

.particle:nth-child(1) {
    width: 80px;
    height: 80px;
    left: 10%;
    animation-duration: 20s;
    animation-delay: 0s;
}

.particle:nth-child(2) {
    width: 60px;
    height: 60px;
    left: 20%;
    animation-duration: 25s;
    animation-delay: 2s;
}

.particle:nth-child(3) {
    width: 100px;
    height: 100px;
    left: 30%;
    animation-duration: 18s;
    animation-delay: 4s;
}

.particle:nth-child(4) {
    width: 40px;
    height: 40px;
    left: 40%;
    animation-duration: 22s;
    animation-delay: 1s;
}

.particle:nth-child(5) {
    width: 70px;
    height: 70px;
    left: 50%;
    animation-duration: 28s;
    animation-delay: 3s;
}

.particle:nth-child(6) {
    width: 50px;
    height: 50px;
    left: 60%;
    animation-duration: 24s;
    animation-delay: 5s;
}

.particle:nth-child(7) {
    width: 90px;
    height: 90px;
    left: 70%;
    animation-duration: 19s;
    animation-delay: 2s;
}

.particle:nth-child(8) {
    width: 35px;
    height: 35px;
    left: 80%;
    animation-duration: 26s;
    animation-delay: 4s;
}

.particle:nth-child(9) {
    width: 65px;
    height: 65px;
    left: 90%;
    animation-duration: 21s;
    animation-delay: 1s;
}

.particle:nth-child(10) {
    width: 45px;
    height: 45px;
    left: 5%;
    animation-duration: 23s;
    animation-delay: 6s;
}

@keyframes float-particle {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    margin: 20px;
    border-radius: 20px;
    background: white;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.5s ease;
    position: relative;
    z-index: 1;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Utility Classes */
.text-gray-800 {
    color: #5a5c69 !important;
}

.text-gray-300 {
    color: #dddfeb !important;
}

.shadow-sm {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

.shadow {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
}

/* Chart Area */
.chart-area {
    position: relative;
    height: 300px;
    padding: 10px;
}

/* ============================================
   COMPACT RESPONSIVE DESIGN
   Optimized for all screen sizes with scrollbars
   ============================================ */

/* Global Compact Styles */
/* Note: .container-fluid is defined above in Global Styles */

.card {
    margin-bottom: 12px;
}

.card-header {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.card-body {
    padding: 12px;
}

/* Targeted transitions for interactive elements */
.btn,
.list-group-item,
.card,
.form-control,
.form-select,
.menu-item,
.sidebar-toggle,
.nav-link,
.dropdown-item,
.navbar-brand {
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.3s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.menu-item {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, background 0.2s ease, color 0.2s ease;
}

/* Compact Form Elements */
.form-control,
.form-select {
    padding: 6px 10px;
    font-size: 14px;
    min-height: 36px;
}

.form-label {
    font-size: 0.8rem;
    margin-bottom: 4px;
}

/* Compact Buttons */
.btn {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 0.75rem;
}

/* Compact Tables */
.table thead th,
.table tbody td {
    padding: 6px 8px;
    font-size: 0.8rem;
}

/* Table Responsive with Scrollbar - no hard height cap */
.table-responsive {
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    border: 1px solid #e3e6f0;
}

/* Custom Scrollbar */
.table-responsive::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.card-body::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.card-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.card-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.card-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Compact Dashboard Menu */
.dashboard-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    padding: 5px 0;
}

.menu-item {
    padding: 12px 8px;
    min-height: 80px;
    border-radius: 10px;
}

.menu-item i {
    font-size: 1.5rem;
    margin-bottom: 6px;
}

.menu-item span {
    font-size: 0.7rem;
}

/* Compact Typography */
h1,
.h1 {
    font-size: 1.25rem;
}

h2,
.h2 {
    font-size: 1.1rem;
}

h3,
.h3 {
    font-size: 1rem;
}

h4,
.h4 {
    font-size: 0.9rem;
}

h5,
.h5 {
    font-size: 0.85rem;
}

h6,
.h6 {
    font-size: 0.8rem;
}

p,
.p {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

/* Compact Navbar */
.navbar {
    padding: 4px 20px;
    min-height: 40px;
}

.navbar-brand {
    font-size: 0.9rem;
}

.navbar-brand img {
    height: auto;
    max-height: 60px;
}

/* Extra Small Devices (iPhone SE, older phones) - up to 375px */
@media (max-width: 375px) {
    .container-fluid {
        padding: 6px 8px;
    }

    .dashboard-menu {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .menu-item {
        padding: 10px 4px;
        min-height: 70px;
    }

    .menu-item i {
        font-size: 1.3rem;
        margin-bottom: 4px;
    }

    .menu-item span {
        font-size: 0.65rem;
    }

    .card-header {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .card-body {
        padding: 10px;
    }

    .table thead th,
    .table tbody td {
        padding: 4px 6px;
        font-size: 0.75rem;
    }

    .btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
}

/* Small Devices (iPhone 6/7/8/X/11/12/13/14, Android phones) - 376px to 576px */
@media (min-width: 376px) and (max-width: 576px) {
    .container-fluid {
        padding: 8px 10px;
    }

    .dashboard-menu {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .menu-item {
        padding: 12px 6px;
        min-height: 75px;
    }

    .menu-item i {
        font-size: 1.4rem;
    }

    .menu-item span {
        font-size: 0.7rem;
    }

    .form-control,
    .form-select {
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }
}

/* Medium Devices (Large phones, small tablets) - 577px to 767px */
@media (min-width: 577px) and (max-width: 767px) {
    .dashboard-menu {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }

    .menu-item {
        padding: 14px 8px;
        min-height: 85px;
    }

    .menu-item i {
        font-size: 1.6rem;
    }
}

/* Tablets (iPad Mini, iPad, iPad Air portrait) - 768px to 991px */
@media (min-width: 768px) and (max-width: 991px) {
    .container-fluid {
        padding: 12px 16px;
    }

    .dashboard-menu {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }

    .menu-item {
        padding: 16px 10px;
        min-height: 90px;
    }

    .menu-item i {
        font-size: 1.8rem;
    }

    .menu-item span {
        font-size: 0.8rem;
    }

    .card-header {
        padding: 10px 14px;
    }

    .card-body {
        padding: 14px;
    }
}

/* Large Tablets (iPad Pro 11", iPad Air landscape) - 992px to 1199px */
@media (min-width: 992px) and (max-width: 1199px) {
    .container-fluid {
        padding: 16px 20px;
    }

    .dashboard-menu {
        grid-template-columns: repeat(5, 1fr);
        gap: 12px;
    }

    .menu-item {
        padding: 18px 12px;
        min-height: 95px;
    }
}

/* Extra Large Devices (Desktops, iPad Pro 12.9" landscape) - 1200px and up */
@media (min-width: 1200px) {
    .container-fluid {
        padding: 16px 24px;
    }

    .dashboard-menu {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 12px;
    }
}

/* iOS Specific Fixes */
@supports (-webkit-touch-callout: none) {

    /* CSS specific to iOS devices */
    .form-control,
    .form-select,
    input,
    textarea,
    select {
        -webkit-appearance: none;
        appearance: none;
        border-radius: 12px;
    }

    .btn {
        -webkit-appearance: none;
        appearance: none;
    }

    /* Fix for iOS momentum scrolling */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
}

/* Touch Target Optimization - Compact but accessible */
@media (pointer: coarse) {

    .btn,
    .nav-link,
    .navbar-toggler,
    .form-check-input,
    .page-link,
    .dropdown-item,
    .menu-item {
        min-height: 40px;
        min-width: 40px;
    }

    .navbar-nav .nav-link {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .btn-sm {
        min-height: 32px;
        min-width: 32px;
    }

    .form-control,
    .form-select {
        min-height: 40px;
    }

    /* Increase spacing between touch targets */
    .table tbody td .btn {
        margin: 1px;
    }
}

/* Table Responsive Enhancements - no hard height caps */
.table-responsive {
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid #e3e6f0;
    border-radius: 8px;
    background: white;
}

.table-responsive .table {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .table-responsive {
        max-height: none;
        /* Removed restrictive height cap */
        font-size: 0.75rem;
    }

    .table-responsive .table {
        min-width: 500px;
        /* Forces horizontal scroll */
    }

    .table thead th,
    .table tbody td {
        padding: 4px 6px;
        white-space: nowrap;
    }
}

/* Navbar Mobile Optimization - Compact */
@media (max-width: 991px) {
    .navbar {
        padding: 6px 10px;
        min-height: 45px;
    }

    .navbar-collapse {
        background: rgba(5, 64, 100, 0.98);
        margin: 6px -10px -6px;
        padding: 10px;
        border-radius: 0 0 8px 8px;
        max-height: 70vh;
        overflow-y: auto;
    }

    .navbar-nav {
        padding: 5px 0;
    }

    .navbar-nav .nav-item {
        margin: 3px 0;
    }

    .navbar-nav .nav-link,
    .navbar-nav .btn {
        width: 100%;
        text-align: left;
        margin: 3px 0 !important;
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .navbar-toggler {
        padding: 6px 10px;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-radius: 6px;
    }
}

/* Form Mobile Optimization - Compact */
@media (max-width: 768px) {
    .form-label {
        font-size: 0.75rem;
        margin-bottom: 3px;
    }

    .form-control,
    .form-select {
        font-size: 16px;
        /* Critical: Prevents iOS zoom on input focus */
        padding: 8px 10px;
        min-height: 38px;
    }

    /* Stack form buttons on mobile */
    .form-actions {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .form-actions .btn {
        width: 100%;
        padding: 8px;
    }

    /* Reduce card padding on mobile */
    .card {
        margin-bottom: 10px;
    }

    .card-header {
        padding: 8px 12px;
    }

    .card-body {
        padding: 10px;
    }
}

/* Landscape Mode Optimization - Compact */
@media (max-height: 500px) and (orientation: landscape) {
    .navbar {
        padding: 5px 10px;
        min-height: 40px;
    }

    .dashboard-menu {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }

    .menu-item {
        padding: 10px 8px;
        min-height: 70px;
    }

    .menu-item i {
        font-size: 1.4rem;
        margin-bottom: 4px;
    }

    .table-responsive {
        max-height: 40vh;
    }
}

/* High DPI / Retina Display Optimization */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    .card,
    .btn,
    .form-control,
    .form-select,
    .menu-item {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Dark Mode Support (optional, for future) */
@media (prefers-color-scheme: dark) {
    /* Placeholder for dark mode styles */
}

/* Reduced Motion (Accessibility) */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   COMPACT COMPONENT STYLES
   ============================================ */

/* Compact Modals */
.modal-header {
    padding: 10px 15px;
}

.modal-body {
    padding: 15px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 10px 15px;
}

.modal-title {
    font-size: 1rem;
}

/* Modal fullscreen on small screens */
@media (max-width: 576px) {
    .modal-fullscreen-sm-down {
        padding: 0 !important;
    }

    .modal-fullscreen-sm-down .modal-dialog {
        width: 100%;
        max-width: none;
        height: 100%;
        margin: 0;
    }

    .modal-fullscreen-sm-down .modal-content {
        height: 100%;
        border: 0;
        border-radius: 0;
    }

    .modal-fullscreen-sm-down .modal-body {
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
}

/* Compact Alerts */
.alert {
    padding: 10px 15px;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

/* Compact Badges */
.badge {
    padding: 4px 8px;
    font-size: 0.75rem;
}

/* Compact Pagination */
.pagination {
    margin-bottom: 0;
}

.page-link {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Compact Input Groups */
.input-group-text {
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* Compact List Groups */
.list-group-item {
    padding: 8px 12px;
    font-size: 0.85rem;
}

/* Compact Dropdowns */
.dropdown-menu {
    font-size: 0.85rem;
    max-height: 50vh;
    overflow-y: auto;
}

.dropdown-item {
    padding: 6px 12px;
}

/* Compact Tooltips and Popovers */
.tooltip {
    font-size: 0.75rem;
}

.popover {
    font-size: 0.85rem;
    max-width: 250px;
}

.popover-header {
    padding: 8px 12px;
    font-size: 0.9rem;
}

.popover-body {
    padding: 10px 12px;
}

/* Compact Progress Bars */
.progress {
    height: 0.75rem;
}

/* Compact Spinners */
.spinner-border,
.spinner-grow {
    width: 1.5rem;
    height: 1.5rem;
}

.spinner-border-sm,
.spinner-grow-sm {
    width: 1rem;
    height: 1rem;
}

/* Compact Close Button */
.btn-close {
    width: 0.75em;
    height: 0.75em;
    padding: 0.25em;
}

/* Compact Cards with Scrollable Content */
.card-scrollable {
    max-height: 300px;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .card-scrollable {
        max-height: 250px;
    }
}

/* Compact Stat Cards */
.border-left-primary,
.border-left-success,
.border-left-warning,
.border-left-info,
.border-left-danger {
    border-left-width: 3px !important;
}

/* Compact Charts */
.chart-container {
    position: relative;
    height: 200px;
    width: 100%;
}

@media (max-width: 768px) {
    .chart-container {
        height: 150px;
    }
}

/* Ensure all scrollable areas have visible scrollbars */
.scrollable {
    overflow: auto;
    max-height: 300px;
}

.scrollable-x {
    overflow-x: auto;
    white-space: nowrap;
}

.scrollable-y {
    overflow-y: auto;
    max-height: 300px;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Loading Animation */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Print Optimization */
@media print {

    .navbar,
    .d-print-none,
    .btn,
    .alert,
    form,
    #sidebar {
        display: none !important;
    }

    /* Show print-only card headers */
    .card-header.d-none.d-print-block {
        display: block !important;
        padding: 10px 0 !important;
        margin-bottom: 10px !important;
        border-bottom: 2px solid #dee2e6 !important;
        page-break-after: avoid !important;
    }

    body {
        background: white !important;
        margin: 0;
        padding: 0;
    }

    .container-fluid {
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .card {
        box-shadow: none !important;
        border: none !important;
        margin-bottom: 0 !important;
    }

    /* Allow page break inside cards with tables */
    .card#printable-content {
        page-break-inside: auto !important;
    }

    .card#printable-content .card-body {
        page-break-inside: auto !important;
    }

    /* Prevent page break in non-printable cards */
    .card:not(#printable-content) {
        page-break-inside: avoid !important;
    }

    .card-body {
        padding: 0 !important;
    }

    /* Hide non-print card headers */
    .card-header:not(.d-print-block) {
        display: none !important;
    }

    /* Show print-only card headers */
    .card-header.d-none.d-print-block {
        display: block !important;
        padding: 10px 0 !important;
        margin-bottom: 10px !important;
        border-bottom: 2px solid #dee2e6 !important;
        page-break-after: avoid !important;
    }

    .table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 9pt !important;
    }

    .table th,
    .table td {
        padding: 4px 6px !important;
        border: 1px solid #dee2e6 !important;
    }

    .table thead th {
        background: #f8f9fc !important;
        color: black !important;
        font-size: 8pt !important;
        page-break-after: avoid !important;
    }

    /* Prevent page break inside table rows */
    .table tbody tr {
        page-break-inside: avoid !important;
    }

    /* Ensure table header repeats on each page */
    .table thead {
        display: table-header-group !important;
    }

    .table tfoot {
        display: table-footer-group !important;
    }

    /* Adjust spacing for print header */
    .report-header-print {
        margin-bottom: 15px !important;
        page-break-after: avoid !important;
    }
}

/* ============================================
   ADDITIONAL MOBILE OPTIMIZATIONS
   ============================================ */

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    .container-fluid {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }

    .navbar {
        padding-top: max(4px, env(safe-area-inset-top));
    }
}

/* Prevent text size adjustment on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Improve touch response */
button,
a,
input,
select,
textarea {
    touch-action: manipulation;
}

/* Disable pull-to-refresh on mobile */
body {
    overscroll-behavior-y: none;
}

/* Smooth scrolling for overflow containers */
.table-responsive,
.card-scrollable,
.modal-body {
    overscroll-behavior: contain;
}

/* Better focus states for touch devices */
@media (hover: none) {

    .btn:focus,
    .form-control:focus,
    .form-select:focus {
        outline: none;
        box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.3);
    }
}

/* Loading skeleton animation */
@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

/* Sticky table headers */
.table-sticky thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

/* Floating action button for mobile */
.fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

@media (min-width: 992px) {
    .fab {
        display: none;
    }
}

/* Bottom navigation for mobile */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

@media (max-width: 991px) {
    .bottom-nav {
        display: flex;
        justify-content: space-around;
        padding: 8px 0;
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 4px 12px;
        color: #6b7280;
        text-decoration: none;
        font-size: 0.7rem;
    }

    .bottom-nav-item i {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }

    .bottom-nav-item.active {
        color: var(--primary-color);
    }

    /* Add padding to main content for bottom nav */
    #main-content {
        padding-bottom: 70px;
    }
}

/* Image optimization */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Prevent layout shift for known dimensions */
img[width][height] {
    aspect-ratio: attr(width) / attr(height);
    height: auto;
}