* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: linear-gradient(-45deg, #0B0F19, #1A1F35, #2D1A35, #0B0F19);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: #ffffff;
    height: 100vh;
    /* Locked to screen height */
    overflow: hidden;
    /* Prevent page-wide scrolling */
    display: flex;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Sidebar Architecture (Retains Dark Theme) */
.sidebar {
    width: 280px;
    height: 100vh;
    /* Natively fill screen depth */
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding: 3rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    will-change: width, padding;
}

.sidebar.minimized {
    width: 80px;
    padding: 3rem 0.5rem;
}

.sidebar.minimized .sidebar-brand {
    max-width: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

.sidebar.minimized .sidebar-header {
    justify-content: center !important;
    padding-left: 0 !important;
    margin-bottom: 2.5rem;
}

.sidebar.minimized .nav-text {
    max-width: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}

.sidebar.minimized .nav-btn {
    justify-content: center;
    padding: 1rem 0;
    gap: 0;
}

.sidebar.minimized .nav-btn:hover {
    transform: scale(1.05);
}

.sidebar.minimized .toggle-sidebar-btn {
    margin: 0 auto;
    display: block;
}

.sidebar.minimized .user-profile-container {
    padding: 1rem 0;
}

.sidebar-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ff7b00;
    margin-bottom: 2.5rem;
    padding-left: 1rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, margin 0.3s ease, padding 0.3s ease;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    display: inline-block;
}

/* Interactive Sidebar Buttons */
.nav-btn {
    background: transparent;
    color: #A0AEC0;
    border: none;
    padding: 1rem 1.2rem;
    font-size: 1.05rem;
    font-weight: 500;
    text-align: left;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-btn i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.nav-text {
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, margin 0.3s ease;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    display: inline-block;
    opacity: 1;
}

.nav-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(6px);
}

.nav-btn.active {
    color: #ffffff;
    background: rgba(0, 242, 254, 0.15);
    border-left: 4px solid #ff7b00;
    border-radius: 4px 12px 12px 4px;
}

/* Main Screen Area (Light Mode) */
.main-content {
    flex: 1;
    background-color: #f8f9fa;
    color: #2D3748;
    padding: 0;
    /* Removed padding to allow internal scroll logic to control spacing */
    overflow: hidden;
    /* Lockdown the main container */
    position: relative;
    box-shadow: inset 12px 0 20px -12px rgba(0, 0, 0, 0.3);
}

/* JS Tab Hiding/Showing Logic */
.tab-content {
    display: none;
    height: 100vh;
    flex-direction: column;
    animation: fadeIn 0.4s ease forwards;
}

.tab-content.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h2 {
    font-size: 2.5rem;
    margin-bottom: 0;
    padding: 2.5rem 2.5rem 1rem 2.5rem;
    /* Precise spacing for the frozen header */
    flex-shrink: 0;
    /* Prevent the title from collapsing */

    background: linear-gradient(to right, #2b6cb0 0%, #4299e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
    letter-spacing: -1px;
}

/* Elevated Light Data Panels */
.glass-panel {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 20px 20px 0 0;
    margin: 0 1.5rem;
    flex: 1;
    /* Natively take up all remaining vertical geometry */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Lockdown the outer panel */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06), 0 2px 10px rgba(0, 0, 0, 0.03);
}

/* Explicit Custom Tracking Geometry */
#tracking .table-wrapper {
    /* Removed the legacy flip trick to ensure native sticky headers function correctly */
}

#tracking table.data-table {
    /* Removed the legacy flip trick */
}

/* Backend Data Tables (Inverted for Light Mode) */
.table-wrapper {
    width: 100%;
    flex: 1;
    overflow: auto;
    /* Handles both X and Y natively in the same coordinate space */
    border-radius: 12px;
}

/* 🎨 PREMIUM CUSTOM SCROLLBARS */
.table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
    border: 2px solid #f1f1f1;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

table.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.92rem;
    text-align: left;
}

/* Distinct Solid Header */
table.data-table thead tr {
    background-color: #EDF2F7;
    color: #4A5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.82rem;
    font-weight: 800;
}

table.data-table th {
    padding: 14px 20px;
    border-bottom: 2px solid #8ca3bd;
    border-top: 1px solid #E2E8F0;
    text-align: left !important;

    /* 🧊 FREEZE MECHANIC: Sticky Headers */
    position: sticky;
    top: 0;
    background-color: #EDF2F7;
    /* Solid color required to mask scrolling content beneath */
    z-index: 10;
}

table.data-table td {
    padding: 12px 20px;
    border-bottom: 1px solid #EDF2F7;
    color: #2D3748;
    font-weight: 500;
    line-height: 1.5;
    text-align: left !important;
    /* Force strict top-to-bottom structural alignment natively */
}

/* Explicit vertical column delimiters separating internal data geometry */
table.data-table th:not(:last-child),
table.data-table td:not(:last-child) {
    border-right: 1px solid #caddf0;
}

/* Zebra Striping geometry specifically aiding horizontal eye-tracking across wide screens */
table.data-table tbody tr:nth-child(even) {
    background-color: #F8FAFC;
}

/* Base Transition state */
table.data-table tbody tr {
    transition: all 0.2s ease;
}


/* Mathematical highlighting forcing the very first Index/Identifier column into sharp focus */
#doichieu table.data-table th:first-child,
#doichieu table.data-table td:first-child {
    width: 40px;
    text-align: center !important;
    padding: 0 10px !important;
}

table.data-table tbody td:nth-child(2) {
    font-weight: 700;
    color: #2B6CB0;
}

/* Ensure subsequent columns don't bleed visually */
table.data-table tbody td:not(:first-child) {
    color: #4A5568;
}

/* 🔘 MASTER-DETAIL UI: Expand Buttons */
.expand-btn {
    background: transparent;
    border: none;
    color: #4facfe;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.expand-btn:hover {
    background: rgba(79, 172, 254, 0.1);
    transform: scale(1.1);
}

.expand-btn.active {
    color: #ff7b00;
}

/* Details Row Interior Formatting */
.details-row>td {
    padding: 0 !important;
    /* ONLY target the outer container, preventing bleed into the nested tables */
}

table.details-table {
    margin-bottom: 0.5rem;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    table-layout: fixed;
    /* Rigid geometric locking for perfect vertical alignment */
    width: 100%;
}

/* Force perfect geometric vertical alignment across all sub-tables */
table.details-table th:nth-child(1),
table.details-table td:nth-child(1) {
    width: 50%;
}

table.details-table th:nth-child(2),
table.details-table td:nth-child(2) {
    width: 30%;
}

table.details-table th:nth-child(3),
table.details-table td:nth-child(3) {
    width: 20%;
}

table.details-table th {
    background: #ffdac1 !important;
    position: static;
    /* Override sticky for sub-tables */
    padding: 8px 12px !important;
    /* Restore interior cell padding */
    font-size: 0.75rem;
    text-align: left !important;
}

table.details-table td {
    padding: 8px 12px !important;
    /* Restore interior cell padding */
    font-size: 0.85rem;
    text-align: left !important;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

.error {
    color: #C53030;
    padding: 1.5rem;
    background: #FFF5F5;
    border-left: 4px solid #F56565;
    border-radius: 4px;
    font-family: monospace;
}

/* Search Bar Geometric Layout */
.header-with-search {
    display: flex;
    justify-content: flex-start;
    /* Instantly binds elements logically to the root Left side */
    align-items: center;
    gap: 1.5rem;
    /* Binds Search and Date securely directly next to the Title */
    flex-wrap: wrap;
    padding: 0 2.5rem 1.5rem 2.5rem;
    /* Refined spacing */
}

.header-with-search h2 {
    margin-bottom: 0;
}

.search-bar {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #ffffff;
    color: #2D3748;
    width: 320px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.search-bar:focus {
    outline: none;
    border-color: #ff7b00;
    box-shadow: 0 4px 20px rgba(255, 123, 0, 0.15);
}

/* Date Filtering Matrix styling */
.date-filters {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: #ffffff;
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

.date-filters label {
    font-size: 0.85rem;
    color: #4A5568;
    font-weight: 700;
    text-transform: uppercase;
}

.date-input {
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
    color: #2D3748;
    background: transparent;
    cursor: pointer;
}

/* User Profile Geometry */
.user-profile-container {
    position: relative;
    padding: 1rem;
    display: flex;
    justify-content: center;
}

.user-avatar {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.avatar-circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff7b00 0%, #ffae00 100%);
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 1.2rem;
    box-shadow: 0 4px 15px rgba(255, 123, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.user-avatar:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 0 20px rgba(255, 123, 0, 0.4);
}

.profile-dropdown {
    position: absolute;
    bottom: 70px;
    left: 20px;
    width: 220px;
    background: rgba(11, 15, 25, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.2rem;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 1000;
    transform-origin: bottom left;
    animation: menuAppear 0.3s ease-out;
}

@keyframes menuAppear {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.profile-dropdown.active {
    display: block;
}

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 0.8rem;
}

.user-name {
    color: #A0AEC0;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
}

.user-handle {
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 600;
}

.profile-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 0.8rem 0;
}

.logout-link {
    text-decoration: none;
}

.logout-item {
    padding: 0.8rem;
    border-radius: 10px;
    background: rgba(245, 101, 101, 0.1);
    color: #F56565;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.profile-item {
    padding: 0.8rem;
    border-radius: 10px;
    color: #A0AEC0;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0.5rem;
}

.profile-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

/* 🛡️ Modal Architecture */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    /* Controlled by JS */
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-backdrop.active {
    display: flex;
}

.modal-box {
    background: #ffffff;
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.2);
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    color: #2D3748;
    font-size: 1.4rem;
}

.close-modal {
    font-size: 2rem;
    color: #A0AEC0;
    cursor: pointer;
}

.pw-input-group {
    margin-bottom: 1.2rem;
}

.pw-input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: #718096;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.pw-input-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
    font-size: 1rem;
    outline: none;
}

.pw-input-group input:focus {
    border-color: #ff7b00;
}

.save-pw-btn {
    width: 100%;
    padding: 1rem;
    background: #2D3748;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 1rem;
    transition: all 0.2s ease;
}

.save-pw-btn:hover {
    background: #1A202C;
    transform: translateY(-2px);
}

.pw-message {
    padding: 0.8rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
}

.pw-message.error {
    background: #FFF5F5;
    color: #C53030;
    border: 1px solid #FEB2B2;
}

.pw-message.success {
    background: #F0FFF4;
    color: #2F855A;
    border: 1px solid #9AE6B4;
}

/* SKU Dropdown Checkbox list */
.sku-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
    color: #4A5568;
    font-size: 0.9rem;
    user-select: none;
}
.sku-checkbox-item:hover {
    background: #EDF2F7;
}
.sku-checkbox-item input[type="checkbox"] {
    cursor: pointer;
    accent-color: #ff7b00;
    width: 16px;
    height: 16px;
}