:root {
    --primary-color: #0052cc;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --brand-blue: #0052cc;
    --brand-tan: #C4A35A;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0052cc 0%, #0066ff 100%);
}

.login-card {
    background: white;
    border-radius: 15px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header i {
    font-size: 48px;
    color: var(--primary-color);
}

.login-header h2 {
    margin-top: 15px;
    color: #333;
}

.login-header p {
    color: var(--secondary-color);
}

/* Navbar Styling */
.navbar .nav-link {
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 5px;
    margin: 0 2px;
}

.navbar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.navbar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Dashboard Stats */
.stat-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card .card-body {
    padding: 20px;
}

.stat-icon {
    font-size: 32px;
    opacity: 0.8;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
}

.stat-label {
    color: var(--secondary-color);
    font-size: 14px;
}

/* Status Badges */
.badge-draft { background-color: #6c757d; }
.badge-pending-manager { background-color: #0dcaf0; }
.badge-pending-dept { background-color: #6f42c1; }
.badge-pending-draft-po { background-color: #e83e8c; }
.badge-pending-hod { background-color: #fd7e14; }
.badge-pending-macl-finance { background-color: #17a2b8; }
.badge-pending-finance { background-color: #20c997; }
.badge-pending-budget-revision { background-color: #ffc107; color: #000; }
.badge-pending-procurement { background-color: #0d6efd; }
.badge-po-issued { background-color: #6610f2; }
.badge-pending-proc-hod { background-color: #d63384; }
.badge-pending-md { background-color: #343a40; }
.badge-po-approved { background-color: #198754; }
.badge-pending-logistics { background-color: #f0ad4e; color: #000; }
.badge-picked-up { background-color: #17a2b8; }
.badge-pending-vessel { background-color: #6610f2; }
.badge-in-transit { background-color: #0dcaf0; color: #000; }
.badge-delivered { background-color: #20c997; }
.badge-goods-received { background-color: #20c997; }
.badge-completed { background-color: #198754; }
.badge-rejected { background-color: #dc3545; }

/* Priority Badges */
.priority-low { color: #6c757d; }
.priority-normal { color: #0d6efd; }
.priority-high { color: #fd7e14; }
.priority-urgent { color: #dc3545; font-weight: bold; }

/* Table Styles */
.table th {
    background-color: #f8f9fa;
    font-weight: 600;
    white-space: nowrap;
    color: #212529;
}

.table td {
    color: #212529;
}

.table-hover tbody tr {
    cursor: pointer;
}

.table-hover tbody tr:hover {
    background-color: #e9ecef;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    background-color: #fff;
}

.card-body {
    background-color: #fff;
    color: #212529;
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    color: #212529;
}

/* PR Detail */
.pr-detail-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.pr-detail-header h3 {
    margin: 0;
}

.pr-detail-header .pr-number {
    font-size: 14px;
    opacity: 0.8;
}

/* ── Workflow Timeline (FaisaMobile style) ─────────────────── */
.wf-timeline {
    padding: 8px 0 4px;
}

.wf-item {
    display: flex;
    align-items: flex-start;
    padding: 0 12px 0 8px;
    min-height: 64px;
}

/* Left column: date + time */
.wf-left {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 52px;
    padding-top: 10px;
    flex-shrink: 0;
}

.wf-date {
    font-size: 11px;
    font-weight: 700;
    color: #6c757d;
    line-height: 1.2;
    white-space: nowrap;
}

.wf-time {
    font-size: 11px;
    color: #adb5bd;
    white-space: nowrap;
}

/* Centre column: avatar + connecting line */
.wf-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 10px;
    flex-shrink: 0;
}

.wf-dot {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    z-index: 1;
}

.wf-dot.wf-primary   { background-color: #0d6efd; }
.wf-dot.wf-success   { background-color: #198754; }
.wf-dot.wf-danger    { background-color: #dc3545; }
.wf-dot.wf-info      { background-color: #0dcaf0; color: #000; }
.wf-dot.wf-warning   { background-color: #ffc107; color: #000; }
.wf-dot.wf-secondary { background-color: #6c757d; }

.wf-line {
    width: 2px;
    background-color: #e9ecef;
    flex: 1;
    min-height: 20px;
    margin-top: 2px;
}

.wf-item:last-child .wf-line {
    display: none;
}

/* Right column: card */
.wf-right {
    flex: 1;
    padding-bottom: 16px;
    padding-top: 6px;
}

.wf-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.wf-title {
    font-size: 13px;
    font-weight: 700;
    color: #212529;
    line-height: 1.3;
}

.wf-subtitle {
    font-size: 12px;
    color: #6c757d;
    margin-top: 2px;
}

.wf-comment {
    font-size: 11px;
    color: #495057;
    font-style: italic;
    margin-top: 4px;
    background: #e9ecef;
    border-radius: 6px;
    padding: 3px 8px;
}

/* Notifications Dropdown */
.notification-dropdown {
    width: 350px;
    max-height: 400px;
    overflow-y: auto;
}

.notification-dropdown .dropdown-item {
    white-space: normal;
    padding: 0;
    border-bottom: 1px solid #e9ecef;
    background: transparent !important;
}

.notification-dropdown .dropdown-item:hover {
    background-color: transparent !important;
}

.notification-dropdown .notification-title {
    font-weight: 600;
    font-size: 14px;
}

.notification-dropdown .notification-message {
    font-size: 12px;
    color: var(--secondary-color);
}

.notification-dropdown .notification-time {
    font-size: 11px;
    color: #adb5bd;
}

.notification-dropdown .notification-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 15px;
    cursor: default;
}

.notification-dropdown .notification-item:hover {
    background-color: #f8f9fa;
}

.notification-dropdown .notification-content {
    flex: 1;
    text-decoration: none;
    color: inherit;
}

.notification-dropdown .notification-content:hover {
    text-decoration: none;
}

.notification-dropdown .notification-read-link {
    font-size: 12px;
    color: #0d6efd;
    text-decoration: none;
    margin-left: 10px;
    white-space: nowrap;
}

.notification-dropdown .notification-read-link:hover {
    text-decoration: underline;
}

/* Action Buttons */
.action-buttons .btn {
    padding: 5px 10px;
    font-size: 14px;
}

/* Line Items Table */
#lineItemsTable input,
#lineItemsTable textarea {
    font-size: 14px;
}

#lineItemsTable .line-total {
    font-weight: 600;
}

/* PR Form Modal - Force proper scrolling */
#prModal.modal {
    overflow-y: auto !important;
}

#prModal .modal-dialog {
    max-height: calc(100vh - 3.5rem) !important;
    margin: 1.75rem auto !important;
}

#prModal .modal-content {
    max-height: calc(100vh - 3.5rem) !important;
    overflow: hidden !important;
}

#prModal .modal-body {
    max-height: calc(100vh - 3.5rem - 140px) !important;
    overflow-y: auto !important;
    padding: 16px;
}

#prModal .modal-header {
    border-bottom: 1px solid #dee2e6;
    padding: 12px 16px;
    flex-shrink: 0;
}

#prModal .modal-footer {
    border-top: 1px solid #dee2e6;
    padding: 12px 16px;
    background: #f8f9fa;
    flex-shrink: 0;
}

#prModal .modal-header h5 {
    font-size: 1rem;
}

#prModal .modal-header small {
    font-size: 0.75rem;
}

#prModal .form-section {
    background: #fafbfc;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

#prModal .section-header {
    margin-bottom: 10px !important;
}

#prModal .section-icon {
    width: 22px !important;
    height: 22px !important;
    flex-shrink: 0;
}

#prModal .section-icon i {
    font-size: 11px !important;
}

#prModal .section-header h6 {
    font-size: 0.8rem;
}

#prModal .form-control,
#prModal .form-select {
    border-radius: 6px;
    border-color: #dee2e6;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    padding: 0.375rem 0.625rem;
}

#prModal .form-control:focus,
#prModal .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(93, 64, 55, 0.1);
}

#prModal .form-control-lg {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
}

#prModal .form-label {
    font-size: 0.75rem;
    color: #495057;
    margin-bottom: 0.25rem;
}

#prModal .row.g-3 {
    --bs-gutter-y: 0.5rem;
    --bs-gutter-x: 0.75rem;
}

#prModal .table {
    margin-bottom: 0;
    font-size: 0.8rem;
}

#prModal .table thead th {
    background-color: #f1f3f4;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #5f6368;
    padding: 8px 6px;
}

#prModal .table tbody td {
    padding: 6px;
    vertical-align: middle;
}

#prModal .table .form-control-sm {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}

/* Quantity field - accommodate larger numbers with decimals */
#prModal .table input[name="quantity"] {
    min-width: 90px;
    text-align: right;
    padding-right: 0.25rem;
}

#prModal .modal-footer .btn {
    padding: 0.375rem 1rem;
    font-size: 0.875rem;
}

#prModal #noItemsMessage {
    padding: 20px !important;
}

#prModal #noItemsMessage i {
    font-size: 1.5rem !important;
}

#prModal #noItemsMessage p {
    font-size: 0.8rem;
}

/* Mobile Line Item Cards */
.line-item-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.line-item-card .card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.line-item-card .item-number-badge {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
}

.line-item-card .mobile-delete-row {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.line-item-card .item-number {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    font-size: 0.7rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.line-item-card .mobile-field {
    margin-bottom: 8px;
}

.line-item-card .mobile-field label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
    display: block;
}

.line-item-card .mobile-field-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-bottom: 0;
}

.line-item-card .mobile-field-row .mobile-field {
    flex: 1;
    min-width: 0;
}

.line-item-card .mobile-field .form-control {
    font-size: 0.85rem;
    padding: 0.35rem 0.5rem;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

/* Item Dropdown */
.item-dropdown-container {
    position: relative;
}

.item-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    max-height: 250px;
    overflow-y: auto;
    margin-top: 2px;
    min-width: 300px;
    max-width: 100%;
}

/* Mobile dropdown adjustments */
@media (max-width: 768px) {
    .item-dropdown {
        min-width: 100%;
        max-width: calc(100vw - 48px);
        position: fixed;
        left: 12px !important;
        right: 12px !important;
        width: calc(100vw - 24px);
    }
}

.item-dropdown table {
    margin-bottom: 0;
    font-size: 0.85rem;
}

.item-dropdown table thead th {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #dee2e6;
}

.item-dropdown table tbody tr {
    cursor: pointer;
}

.item-dropdown table tbody tr:hover {
    background-color: #e9ecef;
}

.item-dropdown table tbody td {
    padding: 0.4rem 0.5rem;
    vertical-align: middle;
}

.item-dropdown table tbody td code {
    font-size: 0.8rem;
    color: #0d6efd;
}

/* Fix overflow for parent containers - only in PR modal */
#lineItemsTable td,
.line-item-card {
    overflow: visible !important;
}

/* Delegation User Dropdown */
#delegatorDropdown,
#delegateDropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

#delegatorDropdown .dropdown-item,
#delegateDropdown .dropdown-item {
    border-bottom: 1px solid #f0f0f0;
}

#delegatorDropdown .dropdown-item:last-child,
#delegateDropdown .dropdown-item:last-child {
    border-bottom: none;
}

#delegatorDropdown .dropdown-item:hover,
#delegateDropdown .dropdown-item:hover {
    background-color: #f8f9fa;
}

#prModal .table-responsive {
    overflow: visible !important;
}

#prModal .modal-body {
    overflow: visible;
}

#prModal .card-body {
    overflow: visible;
}

/* ============================================
   HORIZONTAL SCROLLING FOR LIST TABLES
   ============================================ */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

/* Custom scrollbar for webkit browsers */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Ensure tables have minimum width for proper column display */
.table-responsive > table {
    min-width: 700px;
}

/* Visual indicator for scrollable tables on mobile */
@media (max-width: 767.98px) {
    .table-responsive {
        position: relative;
        margin-left: -12px;
        margin-right: -12px;
        padding-left: 12px;
        padding-right: 12px;
    }
    
    /* Scroll shadow indicator */
    .table-responsive::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 8px;
        width: 30px;
        background: linear-gradient(to right, transparent, rgba(0,0,0,0.05));
        pointer-events: none;
        opacity: 1;
        transition: opacity 0.3s;
    }
    
    /* Table cells shouldn't wrap on mobile for horizontal scroll */
    .table-responsive table th,
    .table-responsive table td {
        white-space: nowrap;
    }
    
    /* Make certain columns more compact */
    .table-responsive table .btn-sm {
        padding: 4px 8px;
        font-size: 12px;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .stat-card .card-body {
        padding: 15px;
    }
    
    .stat-value {
        font-size: 22px;
    }
    
    .table-responsive {
        font-size: 14px;
    }
    
    /* PR Form Modal Mobile - Full screen with proper scrolling */
    #prModal .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        min-height: 100% !important;
    }
    
    #prModal .modal-content {
        border-radius: 0 !important;
        height: 100% !important;
        min-height: 100% !important;
        max-height: 100vh !important;
        display: flex !important;
        flex-direction: column !important;
        border: none !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    #prModal .modal-header {
        flex-shrink: 0;
        padding: 10px 12px;
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--primary-color);
    }
    
    #prModal .modal-body {
        padding: 12px;
        flex: 1 1 auto;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    #prModal .modal-body > form,
    #prModal .modal-body form {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    #prModal .form-section {
        padding: 10px;
        margin-bottom: 10px !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    #prModal .modal-footer {
        flex-shrink: 0;
        padding: 10px 12px;
        border-top: 1px solid #dee2e6;
        background: #fff;
        position: sticky;
        bottom: 0;
        z-index: 10;
    }
    
    #prModal .modal-footer .btn {
        flex: 1;
        min-width: 100px;
        padding: 10px 16px;
    }
    
    /* Ensure row content fits on mobile */
    #prModal .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
    }
    
    #prModal .row > [class*="col"] {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }
    
    /* Basic Information - stack on mobile */
    #prModal .col-12.col-md-8,
    #prModal .col-12.col-md-4 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Input group fix */
    #prModal .input-group {
        flex-wrap: nowrap;
        max-width: 100%;
    }
    
    #prModal .input-group .form-control {
        min-width: 0;
    }
    
    /* Line item cards mobile */
    #prModal .line-item-card {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    #prModal .line-item-card .form-control,
    #prModal .line-item-card .form-select,
    #prModal .line-item-card input,
    #prModal .line-item-card textarea {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Force hide desktop table view on mobile */
    #prModal .d-none.d-md-block,
    #lineItemsDesktop,
    #lineItemsDesktop * {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        left: -9999px !important;
    }
    
    /* Hide all tables in prModal on mobile */
    #prModal table.table,
    #prModal .table-responsive,
    #prModal thead,
    #prModal tbody#lineItemsTable {
        display: none !important;
    }
    
    /* Force show mobile card view */
    #prModal .d-md-none,
    #lineItemsCards {
        display: block !important;
        visibility: visible !important;
        position: relative !important;
        left: auto !important;
        width: 100% !important;
        height: auto !important;
    }
}

@media (max-width: 576px) {
    #prModal .modal-header small {
        display: none;
    }
    
    #prModal .modal-header h5 {
        font-size: 0.9rem;
    }
    
    #prModal .form-control,
    #prModal .form-select {
        font-size: 16px; /* Prevent iOS zoom */
    }
    
    /* Smaller screens - tighter padding */
    #prModal .modal-body {
        padding: 10px;
    }
    
    #prModal .form-section {
        padding: 8px;
        margin-bottom: 8px !important;
    }
    
    #prModal .section-header h6 {
        font-size: 0.75rem;
    }
    
    #prModal .form-label {
        font-size: 0.7rem;
    }
    
    /* Row layout improvements for very small screens */
    #prModal .row.g-2 {
        --bs-gutter-y: 0.4rem;
        --bs-gutter-x: 0.5rem;
    }
    
    /* Priority and date fields - stack on very small screens */
    #prModal .col-6.col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    /* Line item cards mobile styling */
    .line-item-card {
        padding: 8px;
        margin-bottom: 6px;
    }
    
    .line-item-card .mobile-field label {
        font-size: 0.65rem;
    }
    
    .line-item-card .form-control,
    .line-item-card .form-select {
        font-size: 14px;
        padding: 6px 8px;
    }
}

/* Page Transitions */
.page {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Info Cards on Detail Page */
.info-card {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.info-card-label {
    font-size: 12px;
    color: var(--secondary-color);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.info-card-value {
    font-size: 16px;
    font-weight: 500;
}

/* Modal Form Select Styling */
.modal .form-select,
.modal .form-control {
    background-color: #fff;
    color: #212529;
}

.modal .form-select option {
    background-color: #fff;
    color: #212529;
}

.modal .bg-light .form-select,
.modal .bg-light .form-control {
    background-color: #fff;
}

/* ============================================
   MOBILE-FIRST RESPONSIVE IMPROVEMENTS
   ============================================ */

/* General Mobile Improvements */
@media (max-width: 991.98px) {
    /* Navbar mobile improvements */
    .navbar-collapse {
        background: rgba(93, 64, 55, 0.98);
        padding: 15px;
        margin-top: 10px;
        border-radius: 8px;
    }
    
    .navbar .nav-link {
        padding: 12px 15px !important;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .navbar .nav-link:last-child {
        border-bottom: none;
    }
    
    /* Dropdown menus */
    .navbar .dropdown-menu {
        background: rgba(255,255,255,0.1);
        border: none;
        margin-left: 15px;
    }
    
    .navbar .dropdown-item {
        color: rgba(255,255,255,0.9);
        padding: 10px 15px;
    }
    
    .navbar .dropdown-item:hover {
        background: rgba(255,255,255,0.15);
    }
}

@media (max-width: 767.98px) {
    /* Container padding */
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    /* Page title */
    h2.mb-4 {
        font-size: 1.5rem;
        margin-bottom: 1rem !important;
    }
    
    /* Dashboard stats - 2 column grid */
    .row .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .stat-card {
        margin-bottom: 12px;
    }
    
    .stat-card .card-body {
        padding: 12px;
    }
    
    .stat-icon {
        font-size: 24px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    /* Tables - horizontal scrolling */
    .table-responsive {
        margin: 0 -12px;
        padding: 0 12px;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-responsive > table {
        min-width: 800px;
    }
    
    .table {
        font-size: 13px;
    }
    
    .table th, .table td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    
    /* Cards */
    .card {
        margin-bottom: 12px;
    }
    
    .card-header {
        padding: 10px 12px;
    }
    
    .card-body {
        padding: 12px;
    }
    
    /* Buttons */
    .btn {
        padding: 8px 12px;
    }
    
    .btn-sm {
        padding: 6px 10px;
        font-size: 13px;
    }
    
    /* Filter section */
    .filter-section .row {
        gap: 8px 0;
    }
    
    .filter-section .col-md-3,
    .filter-section .col-md-2 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    /* Page header with New button */
    .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    /* Badge sizes */
    .badge {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    /* Login page mobile */
    .login-card {
        padding: 25px 20px;
        margin: 15px;
        max-width: calc(100% - 30px);
    }
    
    .login-header img {
        height: 50px !important;
    }
    
    .login-header h4 {
        font-size: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    /* Extra small screens */
    .row .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    /* Stack action buttons */
    .btn-group-sm {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .btn-group-sm .btn {
        width: 100%;
    }
    
    /* Table compact mode */
    .table th, .table td {
        padding: 6px 4px;
        font-size: 12px;
    }
    
    /* Form inputs - prevent zoom on iOS */
    .form-control, .form-select {
        font-size: 16px;
    }
    
    /* Modal improvements */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-header {
        padding: 12px;
    }
    
    .modal-body {
        padding: 12px;
    }
    
    .modal-footer {
        padding: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 45%;
    }
    
    /* User info in navbar */
    #userName {
        font-size: 14px;
    }
    
    #userRole, #userLocation {
        font-size: 11px;
    }
    
    /* Notification dropdown */
    .notification-dropdown {
        width: calc(100vw - 30px) !important;
        max-width: 350px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .btn-sm {
        min-height: 38px;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .dropdown-item {
        padding: 12px 16px;
    }
    
    .form-check-input {
        width: 20px;
        height: 20px;
    }
    
    /* Table rows touchable */
    .table tbody tr {
        cursor: pointer;
    }
    
    .table tbody tr:active {
        background-color: rgba(0,0,0,0.05);
    }
}

/* Landscape phone orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .login-container {
        padding: 20px;
    }
    
    .login-card {
        padding: 20px;
    }
    
    .login-header {
        margin-bottom: 15px;
    }
    
    .login-header img {
        height: 40px !important;
    }
    
    #prModal .modal-body {
        max-height: calc(100vh - 100px) !important;
    }
}

/* Safe area for notched phones (iPhone X+) */
@supports (padding: max(0px)) {
    .navbar {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
    
    .modal-content {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .login-container {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Utility classes */
.cursor-pointer {
    cursor: pointer;
}
