/* Regal Diaper Invoice System - Custom Styles */

:root {
    --primary-color: #2563EB;
    --secondary-color: #0F172A;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;
    --light-bg: #F8FAFC;
    --border-color: #E2E8F0;
    /* Unified Table System Tokens */
    --table-header-bg: #f8fafc;
    --table-header-color: #475569;
    --table-line: #e2e8f0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    color: var(--secondary-color);
    overflow-x: hidden;
}

/* Sidebar Layout */
.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    background-color: var(--light-bg);
}

/* Sidebar Container */
.sidebar {
    width: 260px;
    min-width: 260px;
    height: 100vh;
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 50%, #1d4ed8 100%);
    color: white;
    box-shadow: 4px 0 20px rgba(15, 23, 42, 0.15);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
    will-change: transform;
}

/* Sidebar Header */
.sidebar-header {
    flex-shrink: 0;
    height: 64px;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(15, 23, 42, 0.2);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: white;
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.sidebar-brand i {
    font-size: 1.35rem;
    color: #60a5fa;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}

.sidebar-brand:hover {
    color: white;
}

.sidebar-header .sidebar-toggle {
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.25rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    line-height: 1;
    border: none;
    background: transparent;
    transition: all 0.2s ease;
}

.sidebar-header .sidebar-toggle:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

/* Sidebar Menu */
.sidebar-menu {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0.65rem 1rem 0.65rem;
    margin: 0;
    list-style: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
    -webkit-overflow-scrolling: touch;
}

.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}
.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 4px;
}
.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.sidebar-menu li {
    margin: 0.18rem 0;
}

/* Sidebar Links */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.sidebar-link i {
    width: 20px;
    font-size: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.75);
    transition: color 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    transform: translateX(2px);
}

.sidebar-link:hover i {
    color: #93c5fd;
}

.sidebar-link.active {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.sidebar-link.active i {
    color: #93c5fd;
}

.sidebar-divider {
    padding: 0.85rem 0.85rem 0.35rem 0.85rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 700;
    letter-spacing: 0.8px;
}

/* Sidebar Footer - Unified Single Row with User Info, Date/Time & Logout */
.sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(15, 23, 42, 0.32);
    backdrop-filter: blur(10px);
}

.sidebar-user-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
}

.sidebar-avatar-wrapper {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-avatar-wrapper .topbar-status-dot {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 9px;
    height: 9px;
    background-color: #22c55e;
    border: 2px solid #1e3a8a;
    border-radius: 50%;
}

.sidebar-user-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.825rem;
    font-weight: 700;
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.2px;
    line-height: 1.25;
}

.sidebar-user-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    line-height: 1.15;
}

.sidebar-user-role {
    font-size: 0.68rem;
    color: #93c5fd;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-user-datetime {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.72);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.sidebar-datetime-sep {
    opacity: 0.5;
    font-size: 0.6rem;
}

.sidebar-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 9px;
    background: rgba(239, 68, 68, 0.16);
    color: #fca5a5;
    text-decoration: none;
    border: 1px solid rgba(239, 68, 68, 0.32);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    cursor: pointer;
}

.sidebar-logout-btn i {
    font-size: 1.1rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.sidebar-logout-btn:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.45);
    transform: translateY(-1px);
}

.sidebar-logout-btn:hover i {
    transform: translateX(1px);
}

.sidebar-logout-btn:active {
    transform: translateY(0);
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Content Area */
.content {
    flex: 1;
    margin-left: 260px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    width: calc(100% - 260px);
    max-width: calc(100% - 260px);
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Top Bar */
.topbar {
    background: #ffffff;
    min-height: 64px;
    height: 64px;
    padding: 0 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
    border-bottom: 1px solid var(--border-color);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.topbar .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: #475569;
    font-size: 1.45rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s ease;
}

.topbar .sidebar-toggle:hover {
    color: var(--primary-color);
    background: #eff6ff;
    border-color: #bfdbfe;
}

.topbar-title {
    min-width: 0;
}

.topbar-title h5 {
    color: var(--secondary-color);
    font-weight: 700;
    font-size: 1.15rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   Header Global Quick Search Bar & Dropdown Results
   ========================================================================== */

.topbar-search-container {
    flex: 1;
    max-width: 520px;
    margin: 0 1.25rem;
    position: relative;
    z-index: 1030;
}

.topbar-search-bar {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    padding: 0.35rem 0.85rem 0.35rem 2.45rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.topbar-search-bar:focus-within {
    background: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12), 0 2px 4px rgba(0, 0, 0, 0.04);
}

.topbar-search-icon {
    position: absolute;
    left: 0.85rem;
    font-size: 0.95rem;
    color: #94a3b8;
    pointer-events: none;
    transition: color 0.15s ease;
}

.topbar-search-bar:focus-within .topbar-search-icon {
    color: #2563eb;
}

.topbar-search-input {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.875rem;
    color: #1e293b;
    padding: 0;
    font-weight: 500;
}

.topbar-search-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.topbar-search-clear {
    background: transparent;
    border: none;
    padding: 0 0.25rem;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    display: flex;
    align-items: center;
    transition: color 0.15s ease;
}

.topbar-search-clear:hover {
    color: #ef4444;
}

.topbar-search-kbd {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    line-height: 1.2;
    margin-left: 0.5rem;
    white-space: nowrap;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

/* Global Search Dropdown Palette */
.global-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 12px 30px -4px rgba(15, 23, 42, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    z-index: 1050;
    max-height: 480px;
    display: flex;
    flex-direction: column;
    animation: searchDropdownFadeIn 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes searchDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.global-search-header {
    padding: 0.6rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
}

.global-search-list {
    overflow-y: auto;
    max-height: 380px;
    padding: 0.25rem 0;
}

.global-search-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 1rem;
    text-decoration: none !important;
    color: #1e293b;
    transition: all 0.15s ease;
    border-bottom: 1px solid #f8fafc;
    cursor: pointer;
}

.global-search-item:last-child {
    border-bottom: none;
}

.global-search-item:hover,
.global-search-item.active {
    background-color: #eff6ff;
    color: #1d4ed8;
}

.global-search-item-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    background: #f1f5f9;
    color: #475569;
    transition: all 0.15s ease;
}

.global-search-item:hover .global-search-item-icon,
.global-search-item.active .global-search-item-icon {
    background: #dbeafe;
    color: #2563eb;
}

.global-search-item-content {
    flex: 1;
    min-width: 0;
}

.global-search-item-title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-search-item-subtitle {
    font-size: 0.775rem;
    color: #64748b;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.global-search-item:hover .global-search-item-subtitle,
.global-search-item.active .global-search-item-subtitle {
    color: #3b82f6;
}

.global-search-item-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Mobile Responsiveness for Header Search */
@media (max-width: 991px) {
    .topbar-search-container {
        max-width: 360px;
        margin: 0 0.75rem;
    }
}

@media (max-width: 767px) {
    .topbar-search-container {
        max-width: none;
        margin: 0 0.5rem;
    }
    .topbar-search-input {
        font-size: 0.8125rem;
    }
    .global-search-dropdown {
        position: fixed;
        top: 60px;
        left: 0.75rem;
        right: 0.75rem;
        max-height: 75vh;
    }
}

/* Topbar User Profile & Avatar Styles */
.topbar-user {
    flex-shrink: 0;
}

.topbar-user-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.25rem 0.8rem 0.25rem 0.35rem;
    border-radius: 9999px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: none;
    outline: none !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-decoration: none;
}

.topbar-user-btn:hover,
.topbar-user-btn:focus,
.topbar-user-btn[aria-expanded="true"] {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.topbar-user-btn:after {
    display: none !important; /* Hide default bootstrap caret */
}

.topbar-chevron {
    font-size: 0.75rem;
    color: #64748b;
    transition: transform 0.2s ease;
}

.topbar-user-btn[aria-expanded="true"] .topbar-chevron {
    transform: rotate(180deg);
}

.topbar-avatar-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Online Status Dot */
.topbar-status-dot {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 9px;
    height: 9px;
    background: #10b981;
    border: 1.5px solid #ffffff;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.topbar-status-dot.large {
    width: 12px;
    height: 12px;
    bottom: 2px;
    right: 2px;
    border-width: 2px;
}

/* Dropdown styling */
.topbar-user-dropdown {
    min-width: 270px;
    border-radius: 14px !important;
    border: 1px solid rgba(226, 232, 240, 0.9) !important;
    box-shadow: 0 14px 28px -4px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05) !important;
    padding: 0.5rem 0 !important;
    margin-top: 0.6rem !important;
    overflow: hidden;
    animation: fadeInDropdown 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInDropdown {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.topbar-dropdown-header {
    padding: 0.9rem 1.15rem 0.85rem;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
}

.topbar-user-dropdown .dropdown-item {
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
    padding: 0.65rem 1.15rem;
    transition: all 0.15s ease;
}

.topbar-user-dropdown .dropdown-item:hover {
    background-color: #f1f5f9;
    color: #0f172a;
    padding-left: 1.35rem;
}

.topbar-user-dropdown .dropdown-item.text-danger:hover {
    background-color: #fee2e2;
    color: #b91c1c !important;
}

/* Avatar general components */
.user-avatar-img,
.user-avatar-initials {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* ==========================================================================
   Warehouse Color & Badge System (Global across whole project)
   ========================================================================== */
.warehouse-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.55rem;
    font-size: 0.775rem;
    font-weight: 600;
    border-radius: 6px;
    letter-spacing: 0.2px;
    white-space: nowrap;
    line-height: 1.25;
    transition: all 0.15s ease;
}

.warehouse-badge i {
    font-size: 0.75rem;
    opacity: 0.85;
}

/* Specific warehouse themes */
.warehouse-badge-1,
.warehouse-badge-main,
.warehouse-color-1 {
    background-color: #eef2ff !important;
    color: #4338ca !important;
    border: 1px solid #c7d2fe !important;
}

.warehouse-badge-2,
.warehouse-badge-north,
.warehouse-color-2 {
    background-color: #ecfdf5 !important;
    color: #047857 !important;
    border: 1px solid #a7f3d0 !important;
}

.warehouse-badge-3,
.warehouse-badge-south,
.warehouse-color-3 {
    background-color: #fffbeb !important;
    color: #b45309 !important;
    border: 1px solid #fde68a !important;
}

.warehouse-badge-4,
.warehouse-badge-east,
.warehouse-color-4 {
    background-color: #fff1f2 !important;
    color: #be123c !important;
    border: 1px solid #fecdd3 !important;
}

.warehouse-badge-5,
.warehouse-badge-west,
.warehouse-color-5 {
    background-color: #ecfeff !important;
    color: #0e7490 !important;
    border: 1px solid #a5f3fc !important;
}

/* Text-only warehouse highlights */
.warehouse-text {
    font-weight: 600;
    letter-spacing: 0.2px;
}
.warehouse-text-1, .warehouse-text-main { color: #4338ca !important; }
.warehouse-text-2, .warehouse-text-north { color: #047857 !important; }
.warehouse-text-3 { color: #b45309 !important; }
.warehouse-text-4 { color: #be123c !important; }
.warehouse-text-5 { color: #0e7490 !important; }

/* Profile page specific styles */
.profile-avatar-card {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    padding: 1.75rem 1.25rem;
    text-align: center;
}

.profile-avatar-preview-box {
    position: relative;
    display: inline-block;
    margin-bottom: 1rem;
}

.profile-avatar-preview-box img,
.profile-avatar-preview-box .user-avatar-initials {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

.profile-avatar-upload-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color, #2563eb);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
}

.profile-avatar-upload-badge:hover {
    transform: scale(1.1);
    background: #1d4ed8;
}

/* ==========================================================================
   Table & DataTables Unified Enhancement Suite (Clean, Modern & Fully Responsive)
   ========================================================================== */

/* Outer wrapper for tables: rounded, single clean subtle border, no overflow clipping */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background-color: #ffffff;
    margin-bottom: 1.25rem;
    position: relative;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

.card-body > .table-responsive:last-child {
    margin-bottom: 0;
}

/* Base table reset: strictly avoid double borders */
.table,
table.dataTable {
    width: 100% !important;
    margin-bottom: 0 !important;
    color: #1e293b;
    vertical-align: middle;
    border-collapse: separate !important;
    border-spacing: 0;
    background-color: transparent !important;
    border: none !important;
}

/* Kill all Bootstrap box-shadow accent borders that cause doubled lines */
.table > :not(caption) > * > * {
    background-color: transparent;
    box-shadow: none !important;
}

/* Pre-initialization height stability: renders exactly 25 rows on first paint to avoid jump */
.data-table:not(.dataTable) tbody tr:nth-child(n+26),
#audit-log-table:not(.dataTable) tbody tr:nth-child(n+26),
#backupsTable:not(.dataTable) tbody tr:nth-child(n+26) {
    display: none;
}

/* Headers: clean, modern slate header across all pages with single divider */
.table thead th,
table.dataTable thead th,
table.dataTable thead td {
    background-color: #f8fafc !important;
    color: #475569 !important;
    font-weight: 700 !important;
    font-size: 0.76rem !important;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    white-space: nowrap;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 0.75rem 1.6rem 0.75rem 0.95rem !important;
    vertical-align: middle;
}

/* DataTables sorting icon alignment without layout jump */
table.dataTable thead .sorting,
table.dataTable thead .sorting_asc,
table.dataTable thead .sorting_desc {
    padding-right: 1.6rem !important;
}

/* Body rows: smooth hover and clean single horizontal row divider */
.table tbody tr,
table.dataTable tbody tr {
    transition: background-color 0.15s ease;
    background-color: #ffffff;
}

.table-hover tbody tr:hover,
.table-hover tbody tr:hover > td,
table.dataTable.table-hover > tbody > tr:hover,
table.dataTable.table-hover > tbody > tr:hover > td {
    background-color: #f8fafc !important;
}

/* Body cells: single clean line, no vertical line clutter */
.table tbody td,
table.dataTable tbody td {
    vertical-align: middle;
    font-size: 0.875rem;
    color: #1e293b;
    padding: 0.75rem 0.95rem;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid #f1f5f9 !important;
}

/* Last row has no bottom border so it blends with container */
.table tbody tr:last-child td,
table.dataTable tbody tr:last-child td {
    border-bottom: none !important;
}

/* Table Footer: clean summary styling */
.table tfoot td,
.table tfoot th,
table.dataTable tfoot td,
table.dataTable tfoot th {
    background-color: #f8fafc !important;
    color: #0f172a !important;
    font-weight: 700;
    padding: 0.8rem 0.95rem !important;
    border-top: 1px solid #e2e8f0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    vertical-align: middle;
}

/* Striped variant */
.table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: #fafbfc;
}

/* Compact tables */
.table.table-sm tbody td,
table.dataTable.table-sm tbody td {
    padding: 0.45rem 0.65rem !important;
    font-size: 0.8125rem;
}

.table.table-sm thead th,
table.dataTable.table-sm thead th {
    padding: 0.6rem 0.65rem !important;
    font-size: 0.72rem !important;
}

/* Borderless tables (e.g. key-value cards, layout helpers) */
.table-borderless,
.table-borderless > :not(caption) > * > *,
.table-borderless td,
.table-borderless th {
    border: none !important;
}

/* Key-value profile tables (e.g. customer view card) */
.table-info {
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0;
}

.table-info th {
    border-top: none !important;
    border-left: none !important;
    border-right: 1px solid #e2e8f0 !important;
    border-bottom: 1px solid #f1f5f9 !important;
    padding: 0.65rem 0.85rem !important;
    vertical-align: middle;
    background: #f8fafc !important;
    font-weight: 600;
    color: #475569 !important;
    font-size: 0.85rem;
}

.table-info td {
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid #f1f5f9 !important;
    padding: 0.65rem 0.85rem !important;
    vertical-align: middle;
    background: #ffffff !important;
    color: #1e293b;
    font-size: 0.875rem;
}

.table-info tr:last-child th,
.table-info tr:last-child td {
    border-bottom: none !important;
}

/* Empty state when table has no data */
.table-empty-state {
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1.5rem;
}

.table-empty-state .bi {
    opacity: 0.6;
}

.table-empty-state p {
    font-size: 0.95rem;
}

/* Numeric & currency values always align right and never split */
.table .text-end,
.table td.text-end,
.table th.text-end {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.table .text-center,
.table td.text-center,
.table th.text-center {
    text-align: center !important;
}

/* Badges never wrap onto multiple lines */
.table .badge {
    white-space: nowrap;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* Action column stays compact and neat */
.table .action-buttons,
.table td:last-child {
    white-space: nowrap;
}

/* Kill native DataTables bottom border that duplicates the table container border */
table.dataTable.no-footer {
    border-bottom: none !important;
}

/* Slim modern scrollbar */
.table-responsive::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 9999px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* DataTables Styling */
.dataTables_wrapper {
    padding: 0.25rem 0;
    width: 100%;
}

/* Dedicated Top Controls Header Bar */
.dt-top-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
    width: 100%;
}

/* Dedicated Bottom Controls Footer Bar */
.dt-bottom-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.85rem;
    width: 100%;
}

.dt-table-container {
    width: 100%;
    margin-bottom: 0;
}

/* Table Header Controls: Length Dropdown & Live Filter */
.dataTables_wrapper .row:first-child {
    margin-bottom: 0.85rem;
    align-items: center;
}

.dataTables_wrapper .dataTables_length {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 0;
}

.dataTables_wrapper .dataTables_length label {
    display: inline-flex;
    align-items: center;
    margin-bottom: 0;
}

.dataTables_wrapper .dataTables_length select {
    display: inline-block;
    width: auto;
    padding: 0.35rem 1.85rem 0.35rem 0.65rem;
    font-size: 0.85rem;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    margin: 0 0.4rem;
    background-color: #ffffff;
    cursor: pointer;
}

.dataTables_wrapper .dataTables_filter {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 0;
}

.dataTables_wrapper .dataTables_filter label {
    display: inline-flex;
    align-items: center;
    margin-bottom: 0;
}

.dataTables_wrapper .dataTables_filter input {
    display: inline-block;
    width: 220px;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    margin-left: 0.4rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background-color: #ffffff;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary-color, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Table Footer Controls: Info Counts & Pagination */
.dataTables_wrapper .row:last-child {
    margin-top: 0.85rem;
    align-items: center;
}

.dataTables_wrapper .dataTables_info {
    font-size: 0.8125rem;
    color: #64748b;
    padding-top: 0;
    margin-bottom: 0;
}

.dataTables_wrapper .dataTables_paginate {
    display: flex;
    justify-content: flex-end;
    padding-top: 0;
    margin-bottom: 0;
}

.dataTables_wrapper .dataTables_paginate .pagination {
    margin: 0;
    gap: 3px;
}

.dataTables_wrapper .dataTables_paginate .page-link {
    border-radius: 6px !important;
    font-size: 0.8125rem;
    padding: 0.35rem 0.65rem;
    color: #475569;
    border-color: #e2e8f0;
    transition: all 0.15s ease;
}

.dataTables_wrapper .dataTables_paginate .page-link:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: #0f172a;
}

.dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
    background-color: var(--primary-color, #2563eb);
    border-color: var(--primary-color, #2563eb);
    color: #ffffff;
    font-weight: 600;
}

/* Mobile & Tablet Responsive Media Queries for Tables */
@media (max-width: 991px) {
    /* Responsive table min-widths so columns don't compress into unreadable vertical slivers */
    .table-responsive > .table,
    .table-responsive > .data-table,
    .table-responsive > #audit-log-table,
    .table-responsive > #backupsTable {
        min-width: 720px;
    }

    #invoice-items {
        min-width: 680px;
    }
}

@media (max-width: 768px) {
    /* DataTables controls stack cleanly on mobile */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        width: 100% !important;
        text-align: left !important;
        margin-bottom: 0.65rem;
    }

    .dataTables_wrapper .dataTables_filter {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 0.3rem;
    }

    .dataTables_wrapper .dataTables_info {
        float: none !important;
        width: 100% !important;
        text-align: center !important;
        padding-top: 0.5rem;
    }

    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        width: 100% !important;
        display: flex;
        justify-content: center;
        padding-top: 0.5rem;
    }

    .dataTables_wrapper .dataTables_paginate .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Table action buttons touch spacing */
    .table td .btn-sm {
        padding: 0.32rem 0.55rem;
        font-size: 0.8rem;
    }

    .card-header.d-flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    .card-header.d-flex > a,
    .card-header.d-flex > button {
        align-self: flex-start;
    }
}

@media (max-width: 576px) {
    .table > :not(caption) > * > * {
        padding: 0.65rem 0.65rem;
        font-size: 0.8125rem;
    }

    .table-responsive > .table {
        min-width: 640px;
    }

    .table-responsive > #audit-log-table {
        min-width: 720px;
    }
}

/* App Footer */
.app-footer {
    background: #f1f5f9;
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    margin-top: auto;
}

.app-footer-inner {
    font-size: 0.8125rem;
    color: #64748b;
    text-align: center;
}

.app-footer-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.app-footer-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.app-footer-sep {
    margin: 0 0.5rem;
    color: #cbd5e1;
}

/* Content Body */
.content-body {
    flex: 1;
    padding: 1.5rem;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Create Invoice: reduce left/right padding for wider form */
.content-body:has(#invoiceForm) {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* Dashboard Chart & List Equal Height Cards (strictly scoped to dashboard page) */
.dashboard-page .dashboard-chart-card,
.dashboard-page .dashboard-list-card {
    min-height: 400px;
}

@media (max-width: 991px) {
    .dashboard-page .dashboard-chart-card,
    .dashboard-page .dashboard-list-card {
        min-height: auto;
    }
}

/* Desktop Collapsible Sidebar */
@media (min-width: 992px) {
    .sidebar {
        transform: translateX(0);
    }
    
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }
    
    body.sidebar-collapsed .content {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    .sidebar-header .sidebar-toggle {
        display: none !important;
    }
}

/* Mobile & Tablet Responsive Layout */
@media (max-width: 991.98px) {
    body.sidebar-open {
        overflow: hidden;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        max-width: 85vw;
        box-shadow: 8px 0 32px rgba(15, 23, 42, 0.35);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .topbar {
        padding: 0 1rem;
        height: 56px;
        min-height: 56px;
    }
    
    .topbar-left {
        gap: 0.5rem;
    }
    
    .topbar .sidebar-toggle {
        width: 38px;
        height: 38px;
        font-size: 1.35rem;
    }
    
    .topbar-title h5 {
        font-size: 1.05rem;
    }
    
    .content-body {
        padding: 1rem 0.75rem;
    }
    
    /* Responsive Cards */
    .card {
        margin-bottom: 1rem;
        border-radius: 10px;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Stat Cards */
    .stat-card {
        margin-bottom: 0.75rem;
    }
}

/* Small Smartphone Responsive Layout (< 576px) */
@media (max-width: 575.98px) {
    .content-body {
        padding: 0.75rem 0.5rem;
    }
    
    .topbar {
        padding: 0 0.75rem;
    }
    
    .topbar-title h5 {
        font-size: 0.95rem;
        max-width: 180px;
    }
    
    .card-body {
        padding: 0.85rem;
    }
    
    /* Responsive buttons and actions */
    .d-flex.gap-2:not(.no-wrap-mobile) {
        flex-wrap: wrap;
    }
    
    /* Form controls touch target */
    .form-control, .form-select, .btn {
        min-height: 40px;
    }
    
    .btn-sm {
        min-height: 32px;
    }
}

/* Navigation */
.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Compact invoice form card body */
.card-body > form#invoiceForm {
    padding: 0;
}

.card-body:has(#invoiceForm) {
    padding: 0.75rem 0.5rem;
}

.card-header {
    background-color: white;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    padding: 1rem 1.5rem;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #1D4ED8;
    border-color: #1D4ED8;
}


/* Invoice create/edit: customer ledger balance strip */
.invoice-customer-balance-panel {
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    background: #f8fafc;
}
.invoice-customer-balance-panel--debit {
    border-color: rgba(220, 53, 69, 0.35);
    background: #fff8f8;
}
.invoice-customer-balance-panel--credit {
    border-color: rgba(25, 135, 84, 0.35);
    background: #f4fbf7;
}
.invoice-customer-balance-panel--settled {
    border-color: #dee2e6;
    background: #f8f9fa;
}

/* Invoice top row: balance strip aligns with date input height */
.invoice-customer-balance-panel--inline {
    min-height: calc(1.5em + 0.75rem + 2px);
    box-sizing: border-box;
}

.invoice-form-top-row .invoice-customer-balance-panel--inline.d-none {
    min-height: 0;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

@media (max-width: 767.98px) {
    .invoice-form-top-row .col-6.col-md-3 {
        width: 50%;
    }
}

/* Customer view card: compact empty states (several blocks; avoid tall 220px stacks) */
.invoices-products-card .invoices-section .table-empty-state,
.invoices-products-card .returns-section .table-empty-state,
.invoices-products-card .product-wise-section .table-empty-state,
.invoices-products-card .product-wise-returns-section .table-empty-state {
    min-height: auto;
    padding: 1.35rem 1.5rem;
}

.invoices-products-card .invoices-section .table-empty-state .bi.fs-3,
.invoices-products-card .returns-section .table-empty-state .bi.fs-3,
.invoices-products-card .product-wise-section .table-empty-state .bi.fs-3,
.invoices-products-card .product-wise-returns-section .table-empty-state .bi.fs-3 {
    opacity: 0.55;
}

/* Recent Invoices card: compact height (no empty space below table), table at top */
.recent-invoices-card {
    min-height: auto !important;
    flex: 0 0 auto !important;
}

.recent-invoices-card .card-body {
    flex: none;
}

.recent-invoices-card .card-body .table-responsive {
    flex: none;
    align-self: flex-start;
}

.recent-invoices-card .recent-invoices-table {
    table-layout: auto;
    width: 100%;
}

/* Recent Invoices: tighter table padding, same header styling as project tables */
.recent-invoices-card .recent-invoices-table thead th,
.recent-invoices-card .recent-invoices-table tbody td {
    padding: 0.55rem 0.75rem;
    font-size: 0.825rem;
    vertical-align: middle;
}

.recent-invoices-card .recent-invoices-table thead th {
    font-size: 0.76rem;
    background: var(--table-header-bg);
    color: var(--table-header-color);
    font-weight: 700;
    border-bottom: 1px solid var(--table-line);
}

.recent-invoices-card .customer-recent-invoices-table .customer-invoice-actions-cell,
.recent-invoices-card .customer-recent-returns-table .customer-return-actions-cell {
    white-space: nowrap;
    text-align: center;
    width: 60px;
}

/* Product-wise quantity & sale card: fix flex/layout, column widths, header */
.product-wise-card .card-body .table-responsive {
    flex: none;
    display: block;
}
.product-wise-card .card-body .table,
.product-wise-card .product-wise-table {
    flex: none;
    width: 100%;
    table-layout: fixed;
}
.product-wise-card .product-wise-table thead th {
    background: var(--table-header-bg);
    color: var(--table-header-color);
    font-weight: 600;
    padding: 0.6rem 0.65rem;
    font-size: 0.85rem;
}
.product-wise-card .product-wise-table tbody td,
.product-wise-card .product-wise-table tfoot td {
    padding: 0.6rem 0.65rem;
    vertical-align: middle;
}
.product-wise-card .product-wise-table thead th:nth-child(1),
.product-wise-card .product-wise-table tbody td:nth-child(1) { width: 6%; }   /* # */
.product-wise-card .product-wise-table thead th:nth-child(2),
.product-wise-card .product-wise-table tbody td:nth-child(2) { width: 48%; }   /* Product */
.product-wise-card .product-wise-table thead th:nth-child(3),
.product-wise-card .product-wise-table tbody td:nth-child(3) { width: 18%; }   /* Total qty */
.product-wise-card .product-wise-table thead th:nth-child(4),
.product-wise-card .product-wise-table tbody td:nth-child(4) { width: 28%; }   /* Total amount */

/* Forms */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
}

/* Form Container */
.col-lg-12.col-xl-11 {
    max-width: 1400px;
}

@media (min-width: 1400px) {
    .col-lg-12.col-xl-11 {
        max-width: 1600px;
    }
}

/* Invoice Items Table */
.invoice-items-table {
    margin-top: 1rem;
}

.invoice-items-table .form-control {
    border: 1px solid var(--border-color);
}

/* Sticky Save Button (Mobile) */
.sticky-save-btn {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 1rem;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

@media (min-width: 768px) {
    .sticky-save-btn {
        position: static;
        box-shadow: none;
        padding: 0;
    }
}

/* Dashboard Cards */
.stat-card {
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s;
    min-height: auto !important;
    height: auto !important;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-card .card-body {
    min-height: auto !important;
    height: auto !important;
    flex: none !important;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-card .stat-label {
    color: #64748B;
    font-size: 0.875rem;
    text-transform: uppercase;
    margin-top: 0.5rem;
}

/* Report summary cards: same-size boxes (Financial Summary, Sales report) */
.report-summary-cards .card,
.report-summary-cards .stat-card {
    min-height: 140px !important;
    height: 140px !important;
}
.report-summary-cards .stat-card .card-body {
    min-height: 140px !important;
    flex: 1 1 auto !important;
}
.report-summary-cards .card .card-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 140px !important;
    padding: 0.75rem !important;
}
/* Slightly smaller value in report cards so long amounts fit in one line where possible */
.report-summary-cards .stat-value,
.report-summary-cards .fs-5.fw-bold {
    font-size: 1.15rem !important;
    line-height: 1.3;
}
.report-summary-cards .stat-label,
.report-summary-cards .small.text-muted {
    font-size: 0.8rem !important;
    margin-top: 0.25rem;
}

/* Summary report: all cards in one row */
.report-summary-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.report-summary-row > .report-summary-col {
    flex: 1 1 0 !important;
    min-width: 0;
    max-width: none;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.report-summary-cards .card .card-body .small.text-muted {
    font-weight: 500;
    margin-bottom: 0.5rem;
    margin-top: 0;
    line-height: 1.2;
    white-space: nowrap;
}

.report-summary-cards .card .card-body .fs-5.fw-bold {
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Responsive: allow wrapping on smaller screens */
@media (max-width: 1400px) {
    .report-summary-row {
        flex-wrap: wrap !important;
    }
    .report-summary-row > .report-summary-col {
        flex: 0 0 auto !important;
        width: calc(33.333% - 1rem);
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 992px) {
    .report-summary-row > .report-summary-col {
        width: calc(50% - 1rem);
    }
}

@media (max-width: 768px) {
    .report-summary-row > .report-summary-col {
        width: 100%;
    }
}

/* Summary report table - horizontal layout (one row) */
.report-summary-table {
    width: 100%;
    margin: 0 auto;
    table-layout: fixed;
}

.report-summary-table thead th {
    background-color: var(--table-header-bg);
    color: var(--table-header-color);
    font-weight: 600;
    border: 1px solid var(--table-line);
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
    white-space: nowrap;
    vertical-align: middle;
}

.report-summary-table thead th.table-success {
    background-color: #198754;
    color: white;
}

.report-summary-table thead th.table-danger {
    background-color: #dc3545;
    color: white;
}

.report-summary-table tbody td {
    padding: 1rem 0.5rem;
    vertical-align: middle;
    border: 1px solid var(--table-line);
    font-size: 1rem;
    word-break: break-word;
}

.report-summary-table tbody tr:hover {
    background-color: #f0f0f5;
}

.report-summary-table tbody td.table-success {
    background-color: #d1e7dd;
}

.report-summary-table tbody tr:hover td.table-success {
    background-color: #b8dfc8;
}

.report-summary-table tbody td.table-danger {
    background-color: #f8d7da;
}

.report-summary-table tbody tr:hover td.table-danger {
    background-color: #f5c2c7;
}

.report-summary-table tbody td strong {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Responsive: allow horizontal scroll on smaller screens */
@media (max-width: 1200px) {
    .report-summary-table {
        min-width: 900px;
    }
    .report-summary-table thead th,
    .report-summary-table tbody td {
        padding: 0.75rem 0.375rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .report-summary-table {
        min-width: 800px;
    }
    .report-summary-table thead th {
        font-size: 0.8rem;
        padding: 0.5rem 0.25rem;
    }
    .report-summary-table tbody td {
        font-size: 0.85rem;
        padding: 0.75rem 0.25rem;
    }
    .report-summary-table tbody td strong {
        font-size: 0.95rem;
    }
}

/* Sales report table spacing */
.report-sales-table {
    table-layout: auto;
    min-width: 1000px;
    width: 100%;
    margin: 0;
}
.report-sales-table th,
.report-sales-table td {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    vertical-align: middle;
    font-size: 0.875rem;
}
.report-sales-table .invoice-col {
    min-width: 100px;
    max-width: 120px;
    white-space: nowrap;
}
.report-sales-table .date-col {
    min-width: 90px;
    max-width: 100px;
    white-space: nowrap;
}
.report-sales-table .customer-col {
    min-width: 150px;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.report-sales-table .product-col {
    min-width: 140px;
    white-space: normal;
    word-break: break-word;
}
.report-sales-table .qty-col,
.report-sales-table .unit-col {
    min-width: 60px;
    max-width: 80px;
    white-space: nowrap;
}
.report-sales-table .amount-col {
    min-width: 85px;
    max-width: 100px;
    white-space: nowrap;
}
.report-sales-table .actions-col {
    min-width: 60px;
    max-width: 70px;
    white-space: nowrap;
}

/* Sales report table wrapper: only the table scrolls, controls stay fixed */
.report-sales-table-wrapper {
    display: block !important;
    flex: 0 0 auto !important;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* DataTables wrapper - controls stay outside, only table area scrolls */
#DataTables_Table_0_wrapper {
    width: 100%;
    position: relative;
    overflow: visible !important;
}

/* DataTables controls rows - keep them fixed, don't scroll */
#DataTables_Table_0_wrapper > .row:first-child {
    position: relative !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0.5rem 0 !important;
    overflow: visible !important;
}

#DataTables_Table_0_wrapper > .row:last-child {
    position: relative !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0.5rem 0 !important;
    overflow: visible !important;
}

/* Only the table-responsive wrapper inside DataTables should scroll */
#DataTables_Table_0_wrapper .report-sales-table-wrapper {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
    margin: 0;
}

/* Ensure DataTables doesn't add its own scroll to wrapper */
#DataTables_Table_0_wrapper .dataTables_scroll {
    overflow: visible !important;
}

#DataTables_Table_0_wrapper .dataTables_scrollHead,
#DataTables_Table_0_wrapper .dataTables_scrollBody {
    overflow: visible !important;
}

/* Ensure controls are positioned correctly */
#DataTables_Table_0_length,
#DataTables_Table_0_filter,
#DataTables_Table_0_info,
#DataTables_Table_0_paginate {
    position: relative !important;
    overflow: visible !important;
}

/* Ensure reports page and card-body don't overflow */
.reports .card-body,
.reports.index .card-body,
div[class*="reports"] .card-body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Ensure card doesn't overflow */
.card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure col-md-12 and other columns don't overflow */
[class*="col-"] {
    box-sizing: border-box;
    max-width: 100%;
}

/* Ensure main content area doesn't overflow */
.main-content {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Responsive adjustments for sales report table */
@media (max-width: 1200px) {
    .report-sales-table {
        min-width: 900px;
    }
    .report-sales-table .customer-col {
        min-width: 120px;
        max-width: 150px;
    }
    .report-sales-table .amount-col {
        min-width: 75px;
        max-width: 90px;
    }
}

@media (max-width: 768px) {
    .report-sales-table {
        min-width: 800px;
    }
    .report-sales-table th,
    .report-sales-table td {
        padding-left: 0.375rem;
        padding-right: 0.375rem;
        font-size: 0.8125rem;
    }
    .report-sales-table .invoice-col {
        min-width: 90px;
    }
    .report-sales-table .date-col {
        min-width: 80px;
    }
    .report-sales-table .customer-col {
        min-width: 100px;
        max-width: 120px;
    }
    .report-sales-table .qty-col,
    .report-sales-table .unit-col {
        min-width: 50px;
    }
    .report-sales-table .amount-col {
        min-width: 70px;
        max-width: 85px;
    }
}

/* Badges */
.badge {
    padding: 0.5em 0.75em;
    font-weight: 500;
}

/* Bill To | Invoice Details */
.invoice-details-card .invoice-bill-proforma-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.25rem;
    table-layout: fixed;
}
.invoice-details-card .invoice-bill-proforma-table td {
    vertical-align: top;
    padding: 0;
}
.invoice-details-card .invoice-bill-to-cell,
.invoice-details-card .invoice-proforma-cell {
    width: 50%;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    padding: 12px 14px !important;
}
.invoice-details-card .invoice-bill-to-cell {
    border-right: none;
    text-align: left;
}
.invoice-details-card .invoice-proforma-cell {
    text-align: left;
}
.invoice-details-card .invoice-meta-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary-color);
    margin-bottom: 6px;
}
.invoice-details-card .invoice-party-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--secondary-color);
}
.invoice-details-card .invoice-meta-kv {
    width: 100%;
    border-collapse: collapse;
}
.invoice-details-card .invoice-meta-kv td {
    padding: 2px 0;
    font-size: 0.9rem;
    border: none !important;
    background: transparent !important;
}
.invoice-details-card .invoice-meta-kv td:first-child {
    width: 38%;
    color: #64748b;
}
.invoice-details-card .invoice-corp {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 2px;
    color: var(--secondary-color);
}
.invoice-details-card .invoice-brand {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--secondary-color);
}
.invoice-details-card .invoice-company-meta {
    font-size: 0.85rem;
    color: #64748b;
}
.invoice-details-card .invoice-company {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--primary-color);
}
.invoice-details-card .invoice-doc-title {
    text-align: center;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin: 0 0 14px;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    color: var(--secondary-color);
}
.invoice-details-card .invoice-items-print-table thead th {
    background: var(--table-header-bg) !important;
    color: var(--table-header-color) !important;
    font-weight: 700;
    border-color: var(--table-line) !important;
}
.invoice-details-card .invoice-items-print-table tbody td,
.invoice-details-card .invoice-items-print-table tfoot td {
    border-color: var(--table-line) !important;
}
.invoice-details-card .invoice-items-print-table tbody tr {
    background: #ffffff;
}
.invoice-details-card .invoice-net-amount-row,
.invoice-details-card .invoice-net-amount-row td {
    background: #e3f2fd !important;
}
.invoice-details-card .invoice-balance-due-row,
.invoice-details-card .invoice-balance-due-row td {
    background: var(--light-bg) !important;
    font-weight: 700;
}
.invoice-details-card .invoice-notes {
    padding: 10px 12px;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
}
.invoice-details-card .invoice-signs {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 36px;
    color: #64748b;
    font-size: 0.8rem;
}
.invoice-details-card .invoice-signs > div {
    flex: 1;
    text-align: center;
    border-top: 1px solid #94a3b8;
    padding-top: 6px;
}

/* Invoice PDF Styles – A4 like Download PDF; print matches PDF layout */
@media print {
    @page {
        size: A4;
        margin: 12mm 8mm 14mm 8mm;
    }
    body {
        background: white;
        margin: 0 !important;
        padding: 0 !important;
    }
    .no-print {
        display: none !important;
    }
    #sidebar,
    .sidebar-overlay,
    .topbar,
    .app-footer {
        display: none !important;
    }
    .content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .content-body {
        padding: 0 !important;
    }
    .invoice-details-card {
        box-shadow: none !important;
        border: none !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .invoice-details-card .card-body {
        padding: 0.25rem !important;
    }
    .invoice-details-card .invoice-company {
        border-bottom: 1px solid #2563EB !important;
    }
    .invoice-details-card .invoice-bill-to-cell,
    .invoice-details-card .invoice-proforma-cell {
        background: #F8FAFC !important;
        border-color: #E2E8F0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .invoice-details-card .invoice-footer {
        border-top: 1px solid #E2E8F0 !important;
    }
    .invoice-details-card .invoice-items-print-table thead th {
        background: #5a4fd6 !important;
        color: #fff !important;
        border-color: #E2E8F0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .invoice-details-card .invoice-items-print-table tbody tr td,
    .invoice-details-card .invoice-items-print-table tbody tr:nth-child(even) td {
        background: #eff6ff !important;
        border-color: #E2E8F0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .invoice-details-card .invoice-net-amount-row,
    .invoice-details-card .invoice-net-amount-row td {
        background: #e3f2fd !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .invoice-details-card .invoice-balance-due-row,
    .invoice-details-card .invoice-balance-due-row td {
        background: #F8FAFC !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .invoice-details-card .badge.bg-success,
    .invoice-details-card .text-success {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .payment-receipt-card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
    .payment-receipt-body { padding: 0.5rem 0 !important; }
    .payment-receipt-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Payment receipt (screen) */
.payment-receipt-card { max-width: 480px; }
.payment-receipt-table { font-size: 0.95rem; }
.payment-receipt-table th { width: 38%; }

/* Mobile Responsive */
@media (max-width: 768px) {
    .content-body {
        padding: 1rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
    
    .topbar {
        padding: 0.75rem 1rem;
    }
    
    .topbar-title h5 {
        font-size: 1rem;
    }
}

/* Loading Spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Alert Styles */
.alert {
    border: none;
    border-left: 4px solid;
}

.alert-success {
    border-left-color: var(--success-color);
}

.alert-danger {
    border-left-color: var(--danger-color);
}

.alert-warning {
    border-left-color: var(--warning-color);
}

/* ========== App Notifications (top-right, professional) ========== */
@keyframes toastSlideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.app-notifications {
    position: fixed;
    top: 4rem;
    right: 1.25rem;
    left: auto;
    z-index: 1060;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 380px;
    pointer-events: none;
}
.app-notifications .app-toast {
    pointer-events: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    padding: 0.9rem 1rem 0.9rem 1.1rem;
    border-left-width: 4px;
    font-size: 0.9rem;
    line-height: 1.45;
    animation: toastSlideInRight 0.35s ease-out;
    animation-fill-mode: both;
}
.app-notifications .app-toast.alert-success {
    border-left-color: var(--success-color);
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
}
.app-notifications .app-toast.alert-danger {
    border-left-color: var(--danger-color);
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
}
.app-notifications .app-toast .btn-close {
    padding: 0.35rem;
    font-size: 0.75rem;
    opacity: 0.6;
}
.app-notifications .app-toast .btn-close:hover {
    opacity: 1;
}
@media (max-width: 575px) {
    .app-notifications {
        top: 0.75rem;
        right: 0.75rem;
        left: 0.75rem;
        max-width: none;
    }
}

/* Ledger Table */
.ledger-debit {
    color: var(--danger-color);
    font-weight: 600;
}

.ledger-credit {
    color: var(--success-color);
    font-weight: 600;
}

.ledger-balance {
    font-weight: 700;
    color: var(--secondary-color);
}

/* Top Labels (Mobile) */
.top-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748B;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

/* Action Buttons */
.action-buttons .btn {
    margin: 0.25rem;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
    margin: 1rem 0;
    flex: 1;
    min-height: 250px;
}

@media (max-width: 768px) {
    .chart-container {
        height: 250px;
        min-height: 200px;
    }
}

/* Dashboard Page */
.dashboard-page .row > [class*="col-"] {
    display: flex;
    flex-direction: column;
}

.dashboard-page .row > [class*="col-"] > .card {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.dashboard-page .card {
    min-height: auto !important;
    height: auto !important;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s, transform 0.2s;
}

/* Let h-100 work: override height:auto so paired cards in a row match height */
.dashboard-page .card.h-100 {
    height: 100% !important;
}

.dashboard-page .card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Dashboard Stat Cards - uniform size and height */
.dashboard-stat-card {
    border: none !important;
    border-left: none !important;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    min-height: 120px;
}

.dashboard-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.dashboard-stat-card .card-body {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem !important;
    flex: 1;
    min-height: 120px;
}

.dashboard-stat-card .stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.dashboard-stat-card .stat-content {
    flex: 0 1 auto;
    min-width: 0;
    text-align: center;
}

.dashboard-stat-card .stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    display: block;
    white-space: nowrap;
}

.dashboard-stat-card .stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
    letter-spacing: 0.5px;
    margin: 0.25rem 0 0 0;
    opacity: 0.85;
    display: block;
}

.dashboard-stat-sales {
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    color: #1D4ED8;
}

.dashboard-stat-sales .stat-icon {
    background: rgba(37, 99, 235, 0.15);
    color: #2563EB;
}

.dashboard-stat-sales .stat-value { color: #1D4ED8; }

.dashboard-stat-outstanding {
    background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
    color: #B91C1C;
}

.dashboard-stat-outstanding .stat-icon {
    background: rgba(239, 68, 68, 0.15);
    color: #EF4444;
}

.dashboard-stat-outstanding .stat-value { color: #B91C1C; }

.dashboard-stat-customers {
    background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
    color: #047857;
}

.dashboard-stat-customers .stat-icon {
    background: rgba(16, 185, 129, 0.15);
    color: #10B981;
}

.dashboard-stat-customers .stat-value { color: #047857; }

.dashboard-stat-invoices {
    background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
    color: #B45309;
}

.dashboard-stat-invoices .stat-icon {
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
}

.dashboard-stat-invoices .stat-value { color: #B45309; }

.dashboard-stat-recovery {
    background: linear-gradient(135deg, #ECFDF5 0%, #A7F3D0 100%);
    color: #047857;
}
.dashboard-stat-recovery .stat-icon {
    background: rgba(16, 185, 129, 0.2);
    color: #059669;
}
.dashboard-stat-recovery .stat-value { color: #047857; }

.dashboard-stat-returns {
    background: linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 100%);
    color: #C2410C;
}
.dashboard-stat-returns .stat-icon {
    background: rgba(234, 88, 12, 0.15);
    color: #EA580C;
}
.dashboard-stat-returns .stat-value { color: #C2410C; }
.dashboard-stat-returns .stat-sub { color: #9A3412 !important; }
.dashboard-stat-returns .stat-content a { color: #9A3412; }
.dashboard-stat-returns .stat-content a:hover { color: #C2410C; text-decoration: underline; }

/* Dashboard Chart Cards */
.dashboard-chart-card .card-header {
    font-size: 0.95rem;
    padding: 1rem 1.25rem;
}

.dashboard-chart-card .card-header i {
    margin-right: 0.5rem;
    opacity: 0.8;
}

.dashboard-chart-card .card-body {
    padding: 1rem 1.25rem !important;
}

.dashboard-chart-card .chart-container {
    margin: 0;
    flex: none;
}

.dashboard-chart-card .chart-trend {
    height: 300px;
    min-height: 280px;
}

.dashboard-chart-card .chart-bar {
    height: 300px;
    min-height: 280px;
}

.dashboard-chart-card .chart-doughnut {
    height: 300px;
    min-height: 260px;
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
}

/* Dashboard List Cards - uniform height when in a row (with h-100) */
.dashboard-list-card {
    min-height: 360px;
}

/* Override .dashboard-page .card { min-height: auto !important } so list cards keep 360px */
.dashboard-page .card.dashboard-list-card {
    min-height: 360px !important;
}

.dashboard-list-card .card-header {
    padding: 1rem 1.25rem;
    font-size: 0.95rem;
}

.dashboard-list-card .card-header i {
    margin-right: 0.5rem;
    opacity: 0.8;
}

.dashboard-list-card .card-body {
    padding: 1rem 1.25rem !important;
    flex: 1 1 auto !important;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.dashboard-list-card .card-body .table-responsive,
.dashboard-list-card .card-body .list-group {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.dashboard-list-card .card-body .dashboard-empty {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dashboard-list-card .list-group-item {
    padding: 0.75rem 0;
}

.dashboard-list-card .table thead th {
    background: var(--table-header-bg);
    color: var(--table-header-color);
    font-size: 0.85rem;
    font-weight: 700;
}

.dashboard-empty {
    padding: 1.5rem;
    text-align: center;
}

@media (max-width: 768px) {
    .dashboard-stat-card .stat-value {
        font-size: 1.15rem;
    }
    
    .dashboard-stat-card,
    .dashboard-stat-card .card-body {
        min-height: 100px;
    }
    
    .dashboard-chart-card .chart-trend,
    .dashboard-chart-card .chart-bar {
        height: 260px;
        min-height: 240px;
    }
    
    .dashboard-chart-card .chart-doughnut {
        height: 260px;
        min-height: 220px;
    }
    
    .dashboard-page .card.dashboard-list-card {
        min-height: 280px !important;
    }
}

/* Dashboard List Groups */
.card-body .list-group {
    flex: 1;
}

/* Invoice view: card and card-body size to content, prevent unnecessary stretch */
.invoice-details-card.card {
    height: auto;
}
.invoice-details-card .card-body {
    flex: none;
    height: auto;
    min-height: 0;
}
.invoice-details-card .proforma-title h4 {
    letter-spacing: 0.08em;
    color: var(--secondary-color);
}
.invoice-details-card .invoice-company {
    border-bottom-color: #2563EB;
}
.invoice-details-card .card-body .table-responsive {
    height: auto;
}
.invoice-details-card .card-body .table {
    height: auto;
}
/* Invoice footer: Created by | computer-generated | Generated on – one row, left | center | right (like PDF) */
.invoice-details-card .invoice-footer-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.invoice-details-card .invoice-footer-table td {
    vertical-align: top;
    padding: 0.15rem 0.5rem 0 0;
}
.invoice-details-card .invoice-footer-table td:last-child {
    padding: 0.15rem 0 0 0.5rem;
}
.invoice-details-card .invoice-footer-created {
    width: 28%;
    text-align: left;
}
.invoice-details-card .invoice-footer-legal {
    width: 44%;
    text-align: center;
    padding: 0.15rem 0.5rem 0 0.5rem !important;
}
.invoice-details-card .invoice-footer-generated {
    width: 28%;
    text-align: right;
}
.invoice-details-card .table thead th,
.invoice-details-card .table tbody td,
.invoice-details-card .table tfoot td {
    padding: 0.45rem 0.65rem;
}
.invoice-details-card .invoice-items-print-table tbody tr {
    background: #eff6ff;
}
.invoice-details-card .table tbody td {
    vertical-align: middle;
}

/* Net Amount row: light blue like PDF #e3f2fd */
.invoice-details-card .invoice-net-amount-row,
.invoice-details-card .invoice-net-amount-row td {
    background: #e3f2fd !important;
}

/* Total Products/Quantity row: remove column (vertical) lines from empty cells */
.invoice-details-card .invoice-total-summary-row td.invoice-total-empty {
    border-left: none;
    border-right: none;
}

/* Invoice Items card: use content height, don't stretch */
form#invoiceForm .card.mb-3,
form#returnForm .card.mb-3 {
    height: auto;
    flex: none;
    display: block;
}

form#invoiceForm .card.mb-3 .card-body,
form#returnForm .card.mb-3 .card-body {
    flex: none;
    height: auto;
    display: block;
    min-height: 0;
}

form#invoiceForm .card.mb-3 .table-responsive,
form#returnForm .card.mb-3 .table-responsive {
    flex: none;
    display: block;
}

form#invoiceForm .card.mb-3 .table,
form#returnForm .card.mb-3 .table,
#invoice-items {
    flex: none;
    height: auto;
    table-layout: auto;
}

#invoice-items tbody tr.invoice-item-row {
    height: auto;
}

#invoice-items tbody tr.invoice-item-row td {
    vertical-align: middle !important;
    height: auto;
    padding: 0.5rem;
}

#invoice-items tbody tr.invoice-item-row td .form-control,
#invoice-items tbody tr.invoice-item-row td .form-select {
    height: calc(1.5em + 0.75rem + 2px);
    min-height: 38px;
    width: 100%;
    box-sizing: border-box;
}

/* Compact Invoice Form */
form#invoiceForm,
form#returnForm {
    padding: 0;
}

/* Reduce main card body padding for invoice form */
div.card-body > form#invoiceForm,
div.card-body > form#returnForm {
    padding: 0;
}

form#invoiceForm .row.mb-3,
form#returnForm .row.mb-3 {
    margin-bottom: 1rem !important;
}

/* Customer Select2: full width and min-width for placeholder/selection */
form#invoiceForm .invoice-customer-select-wrap .select2-container {
    width: 100% !important;
    min-width: 280px;
}

form#invoiceForm .card.mb-3,
form#returnForm .card.mb-3 {
    margin-bottom: 1rem !important;
}

form#invoiceForm .card.mb-3 .card-header,
form#returnForm .card.mb-3 .card-header {
    padding: 0.5rem 1rem;
}

form#invoiceForm .card.mb-3 .card-header h6,
form#returnForm .card.mb-3 .card-header h6 {
    font-size: 0.9rem;
    margin-bottom: 0;
}

form#invoiceForm .card.mb-3 .card-body,
form#returnForm .card.mb-3 .card-body {
    padding: 0.75rem 0.5rem;
}

form#invoiceForm .mb-2,
form#returnForm .mb-2 {
    margin-bottom: 0.5rem !important;
}

form#invoiceForm .mb-3,
form#returnForm .mb-3 {
    margin-bottom: 0.75rem !important;
}

form#invoiceForm .form-label,
form#returnForm .form-label {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

form#invoiceForm textarea[name="notes"],
form#returnForm textarea[name="notes"] {
    min-height: 60px;
    max-height: 80px;
}

form#invoiceForm .card .card-body,
form#returnForm .card .card-body {
    padding: 0.75rem;
}

form#invoiceForm .card .card-body .mb-2,
form#returnForm .card .card-body .mb-2 {
    margin-bottom: 0.5rem !important;
}

form#invoiceForm .card .card-body .mb-0,
form#returnForm .card .card-body .mb-0 {
    margin-bottom: 0;
}

form#invoiceForm #net_amount_display,
form#returnForm #net_amount_display {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Invoice Amount & Payment Summary – POS-style */
.invoice-summary-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

form#invoiceForm .invoice-summary-card .card-body,
form#returnForm .invoice-summary-card .card-body {
    padding-left: 0;
    padding-right: 0;
}

.invoice-summary-card .card-header {
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--secondary-color);
}

/* Invoice summary – one row, equal-width fields */
.invoice-summary-one-row {
    display: flex;
    flex-wrap: wrap;
    --bs-gutter-x: 0.4rem;
    --bs-gutter-y: 0.4rem;
}

/* Equal flex for all summary columns from md up; min-width so none collapse to 59px */
@media (min-width: 768px) {
    .invoice-summary-one-row .invoice-summary-col {
        flex: 1 1 0;
        min-width: 90px;
    }
}

.invoice-summary-one-row .summary-field {
    min-width: 0;
}

.invoice-summary-one-row .summary-field .form-label {
    font-size: 0.75rem;
    color: #64748B;
    margin-bottom: 0.2rem;
    font-weight: 500;
}

.invoice-summary-one-row .summary-field .form-control,
.invoice-summary-one-row .summary-field .form-select {
    font-size: 0.875rem;
    padding: 0.35rem 0.5rem;
}

.invoice-summary-one-row .summary-field .summary-value {
    background: #F8FAFC;
    font-weight: 500;
}

.invoice-summary-one-row .summary-net-field .form-label {
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 0.2rem;
}

/* Net Amount value: same height/padding as other summary inputs, with highlight */
.invoice-summary-one-row .summary-net-field .summary-net-value {
    display: flex;
    align-items: center;
    padding: 0.35rem 0.5rem;
    min-height: 2rem;
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    border-radius: 6px;
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.summary-net-value,
#net_amount_display {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1D4ED8;
    letter-spacing: 0.02em;
}

/* Remaining Amount: red when paid exceeds net (overpaid) */
#remaining_amount_display.remaining-overpaid {
    color: var(--danger-color) !important;
    font-weight: 600;
}

@media (max-width: 576px) {
    .invoice-summary-one-row .summary-field .form-label {
        font-size: 0.7rem;
    }
    
    .summary-net-value,
    #net_amount_display {
        font-size: 1rem;
    }
}

form#invoiceForm .table thead th,
form#returnForm .table thead th {
    padding: 0.5rem;
    font-size: 0.8rem;
}

form#invoiceForm .table tbody td,
form#returnForm .table tbody td {
    padding: 0.5rem;
}

form#invoiceForm .mt-4,
form#returnForm .mt-4 {
    margin-top: 1rem !important;
}

/* Create Invoice – mobile responsive */
@media (max-width: 991px) {
    form#invoiceForm .card.mb-3 .card-header,
    form#returnForm .card.mb-3 .card-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    form#invoiceForm .card.mb-3 .card-header .btn,
    form#returnForm .card.mb-3 .card-header .btn {
        flex: 1 1 auto;
        min-width: 0;
    }
}

@media (max-width: 768px) {
    form#invoiceForm .row.g-2,
    form#returnForm .row.g-2 {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }
    
    form#invoiceForm .invoice-summary-card .summary-field .form-label,
    form#returnForm .invoice-summary-card .summary-field .form-label {
        font-size: 0.7rem;
    }
    
    form#invoiceForm .invoice-summary-card .form-control,
    form#invoiceForm .invoice-summary-card .form-select,
    form#returnForm .invoice-summary-card .form-control,
    form#returnForm .invoice-summary-card .form-select {
        font-size: 0.875rem;
        padding: 0.35rem 0.5rem;
    }
    
    form#invoiceForm #net_amount_display,
    form#returnForm #net_amount_display {
        font-size: 1.1rem;
    }
    
    form#invoiceForm .invoice-form-actions .btn,
    form#returnForm .invoice-form-actions .btn {
        width: 100%;
    }
    
    form#invoiceForm .invoice-form-actions,
    form#returnForm .invoice-form-actions {
        margin-top: 1rem !important;
    }
}

@media (max-width: 576px) {
    form#invoiceForm .invoice-summary-card .summary-field .form-control,
    form#invoiceForm .invoice-summary-card .summary-field .form-select {
        font-size: 0.8125rem;
    }
    
    #invoice-items {
        font-size: 0.8125rem;
        min-width: 480px;
    }
    
    #invoice-items tbody tr.invoice-item-row td {
        padding: 0.35rem;
    }
    
    #invoice-items tbody tr.invoice-item-row td .form-control,
    #invoice-items tbody tr.invoice-item-row td .form-select {
        min-height: 34px;
        height: 34px;
        font-size: 0.8125rem;
    }
    
    form#invoiceForm .card.mb-3 .card-body {
        padding: 0.5rem;
    }
    
    form#invoiceForm .table-responsive {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Empty State */
.empty-state {
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state i {
    display: block;
    font-size: 3rem;
    color: #ccc;
    margin: 0 auto 1.5rem;
    opacity: 0.6;
}

.empty-state p {
    font-size: 1.1rem;
    color: #64748B;
    margin: 0;
}

/* DataTables Empty State */
.dataTables_empty {
    text-align: center !important;
    padding: 4rem 2rem !important;
    font-size: 1.1rem;
    color: #64748B;
    height: 270px;
}



/* ========== Payments Page ========== */
.payment-page .payment-receive-card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-radius: 12px;
    overflow: hidden;
}

.payment-page .payment-receive-card .card-body {
    padding: 0.75rem 1.25rem 1rem;
}

.payment-page .payment-receive-card .card-body .form-label {
    font-size: 0.875rem;
    margin-bottom: 0.2rem;
}

.payment-page .payment-receive-card .card-body .form-control:not(.form-control-sm),
.payment-page .payment-receive-card .card-body .form-select:not(.form-select-sm) {
    padding: 0.35rem 0.65rem;
    font-size: 0.9rem;
}

/* Select2 customer dropdown: match form-control height (like Payment Amount, Date, etc.) */
.payment-page .payment-receive-card .select2-container .select2-selection--single {
    min-height: 2.25rem !important;
    height: auto !important;
    padding: 0.35rem 2rem 0.35rem 0.65rem !important;
    font-size: 0.9rem;
}

.payment-page .payment-receive-card .select2-container .select2-selection__rendered {
    font-size: 0.9rem;
    line-height: 1.4;
    padding: 0;
}

/* Customer section: more compact like a single input row */
.payment-page .payment-receive-card .payment-section:first-of-type {
    padding: 0.5rem 0;
}

.payment-page .payment-receive-card .payment-section:first-of-type .payment-section-title {
    margin-bottom: 0.35rem;
}

.payment-page .payment-receive-card .card-body .payment-details-grid textarea {
    min-height: 2.25rem;
    resize: vertical;
}

.payment-page .payment-receive-card .card-body form .border-top {
    margin-top: 0.75rem !important;
    padding-top: 0.75rem !important;
}

.payment-page .payment-receive-card .card-header {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: #ffffff;
    padding: 1rem 1.25rem;
    border: none;
}

.payment-page .payment-receive-card .card-header h5 {
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: #ffffff;
}

.payment-page .payment-receive-card .card-header .payment-subtitle {
    font-size: 0.9rem;
    opacity: 0.95;
    color: rgba(255, 255, 255, 0.9);
}

.payment-page .payment-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--table-line);
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.payment-page .payment-steps .step {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.payment-page .payment-steps .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--primary-color, #2563eb);
    color: #ffffff;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
}

.payment-page .payment-section {
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border-color);
}

.payment-page .payment-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.payment-page .payment-section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.payment-page .payment-section-title i {
    color: var(--primary-color, #2563eb);
}

.payment-page #invoices-section,
.payment-page .invoices-display-box {
    background: #fafafa;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    margin-bottom: 0.75rem;
}

.payment-page #invoices-section .payment-section-title,
.payment-page .invoices-display-box .payment-section-title {
    margin-bottom: 0.5rem;
}

.payment-page .invoices-display-box > p.text-muted {
    margin-bottom: 0.35rem;
}

.payment-page .invoices-display-box .invoices-empty-msg {
    padding: 1rem 1.25rem;
    text-align: center;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #64748b;
}

.payment-page .invoices-display-box .invoices-empty-msg i {
    font-size: 2rem;
    color: #94a3b8;
    display: block;
    margin-bottom: 0.5rem;
}

.payment-page #invoices-section > p.text-muted {
    margin-bottom: 0.35rem;
}

.payment-page #invoices-table {
    font-size: 0.9rem;
    border-radius: 8px;
    overflow: hidden;
}

.payment-page #invoices-table thead th {
    background: var(--table-header-bg);
    color: var(--table-header-color);
    font-weight: 600;
    padding: 0.65rem 0.75rem;
    border-bottom: 2px solid var(--table-line);
    white-space: nowrap;
}

.payment-page #invoices-table tbody td {
    padding: 0.6rem 0.75rem;
    vertical-align: middle;
}

.payment-page #invoices-table .allocate-inp {
    max-width: 100px;
    display: inline-block;
}

.payment-page .btn-pay-full {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    background: #0d9488;
    color: #fff !important;
    border-radius: 6px;
    text-decoration: none !important;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.payment-page .btn-pay-full:hover {
    background: #0f766e;
    color: #fff !important;
}

.payment-page .alloc-total-box {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #047857;
}

.payment-page .alloc-total-box #alloc-total {
    font-size: 1rem;
}

.payment-page #invoices-empty {
    padding: 1rem 1.25rem;
    text-align: center;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #64748b;
}

.payment-page #invoices-empty i {
    font-size: 2rem;
    color: #94a3b8;
    display: block;
    margin-bottom: 0.5rem;
}

.payment-page #invoices-loading {
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

.payment-page #invoices-loading.loading-visible {
    display: flex !important;
}

.payment-page .payment-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.payment-page .payment-details-grid .field-notes {
    grid-column: 1 / -1;
}

.payment-page .btn-record-payment {
    padding: 0.65rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(13, 148, 136, 0.3);
}

.payment-page .btn-record-payment:hover {
    box-shadow: 0 4px 8px rgba(13, 148, 136, 0.35);
}

/* Recent Payments card */
.payment-page .payment-recent-card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-radius: 12px;
    overflow: hidden;
}

.payment-page .payment-recent-card .card-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--secondary-color);
}

.payment-page .payment-recent-card .table {
    font-size: 0.9rem;
}

.payment-page .payment-recent-card .table thead th {
    background: var(--table-header-bg);
    color: var(--table-header-color);
    font-weight: 600;
    padding: 0.65rem 0.75rem;
    border-bottom: 2px solid var(--table-line);
}

/* All Payments list card */
.payment-page .payment-list-card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-radius: 12px;
    overflow: hidden;
}

.payment-page .payment-list-card .card-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--secondary-color);
}

.payment-page .payment-list-card .card-header .badge.bg-teal {
    background-color: var(--primary-light, #eff6ff);
    color: var(--primary-color, #2563eb);
    font-weight: 600;
}

.payment-page .payment-list-table {
    font-size: 0.9rem;
}

.payment-page .payment-list-table thead th {
    background: var(--table-header-bg);
    color: var(--table-header-color);
    font-weight: 600;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--table-line);
    white-space: nowrap;
}

.payment-page .payment-list-table tbody td {
    padding: 0.6rem 0.75rem;
    vertical-align: middle;
}

.payment-page .payment-list-table .invoices-cell,
.payment-page .payment-list-table .notes-cell {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

.payment-list-table td.cell-return-payment {
    background-color: #eff6ff !important;
    color: #1e3a8a;
}
.payment-list-table tbody tr:hover td.cell-return-payment {
    background-color: #dbeafe !important;
}
.payment-list-table td.cell-return-amount {
    background-color: #fef3c7 !important;
    color: #92400e;
}
.payment-list-table tbody tr:hover td.cell-return-amount {
    background-color: #fde68a !important;
}
.payment-list-table td.cell-refunded {
    background-color: #d1fae5 !important;
    color: #065f46;
}
.payment-list-table tbody tr:hover td.cell-refunded {
    background-color: #a7f3d0 !important;
}

.payment-page .payment-list-empty {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: #64748b;
}

.payment-page .payment-list-empty i {
    font-size: 2.5rem;
    color: #94a3b8;
    display: block;
    margin-bottom: 0.75rem;
}

.payment-page .payment-list-empty p {
    font-size: 1rem;
    margin: 0;
}

.payment-page .spin {
    animation: payment-spin 0.8s linear infinite;
}

@keyframes payment-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Customers list: harmonious modern row tints — debit / credit / settled */
.table.table-customers-list tbody tr.customer-row-debit > td {
    background-color: #fef2f2 !important;
}

.table.table-customers-list tbody tr.customer-row-debit:hover > td {
    background-color: #fee2e2 !important;
}

.table.table-customers-list tbody tr.customer-row-credit > td {
    background-color: #f0fdf4 !important;
}

.table.table-customers-list tbody tr.customer-row-credit:hover > td {
    background-color: #dcfce7 !important;
}

.table.table-customers-list tbody tr.customer-row-settled > td {
    background-color: #f8fafc !important;
}

.table.table-customers-list tbody tr.customer-row-settled:hover > td {
    background-color: #f1f5f9 !important;
}

/* Newly created customer: blue edge + slightly stronger tint */
.table.table-customers-list tbody tr.customer-row-new > td {
    box-shadow: inset 4px 0 0 0 #2563eb;
}

.table.table-customers-list tbody tr.customer-row-new.customer-row-debit > td {
    background-color: #fee2e2 !important;
}

.table.table-customers-list tbody tr.customer-row-new.customer-row-debit:hover > td {
    background-color: #fecaca !important;
}

.table.table-customers-list tbody tr.customer-row-new.customer-row-credit > td {
    background-color: #dcfce7 !important;
}

.table.table-customers-list tbody tr.customer-row-new.customer-row-credit:hover > td {
    background-color: #bbf7d0 !important;
}

.table.table-customers-list tbody tr.customer-row-new.customer-row-settled > td {
    background-color: #eff6ff !important;
}

.table.table-customers-list tbody tr.customer-row-new.customer-row-settled:hover > td {
    background-color: #dbeafe !important;
}

/* Password View/Hide Toggle Button */
.toggle-password-btn {
    border-color: #dee2e6;
    color: #64748b;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.toggle-password-btn:hover,
.toggle-password-btn:focus {
    color: #2563eb;
    background-color: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: none;
}

.input-group:focus-within .toggle-password-btn {
    border-color: #86b7fe;
}

/* 3-Dot Action Button & Dropdown Menu */
.action-3dot-btn {
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 3px 6px;
    margin: 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
    transition: color 0.15s ease, transform 0.15s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.action-3dot-btn:hover,
.action-3dot-btn:focus,
.action-3dot-btn:active,
.action-3dot-btn[aria-expanded="true"] {
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    color: #1e293b;
    transform: scale(1.15);
}

.action-3dot-btn i {
    pointer-events: none;
    line-height: 1;
}

.table td .dropdown {
    display: inline-block;
    vertical-align: middle;
}

.table td .dropdown-menu {
    border-radius: 12px;
    box-shadow: 0 12px 32px -4px rgba(15, 23, 42, 0.18), 0 4px 12px -2px rgba(15, 23, 42, 0.08);
    border: 1px solid #e2e8f0;
    padding: 0.4rem;
    font-size: 0.85rem;
    min-width: 185px;
    z-index: 1080 !important;
    animation: dropdownFadeIn 0.12s ease-out;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.table td .dropdown-item {
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 500;
    color: #334155;
    transition: all 0.12s ease;
}

.table td .dropdown-item i {
    font-size: 1.05rem;
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
}

.table td .dropdown-item:hover,
.table td .dropdown-item:focus {
    background-color: #f1f5f9;
    color: #0f172a;
}

.table td .dropdown-item.text-danger {
    color: #dc2626 !important;
}

.table td .dropdown-item.text-danger:hover,
.table td .dropdown-item.text-danger:focus {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
}

.table td .dropdown-divider {
    margin: 0.35rem 0;
    border-color: #f1f5f9;
}




