/* -------------------------- */
/* ------ BASE & RESET ------ */
/* -------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-primary: #F7F9FC;      
    --bg-secondary: #FFFFFF;     
    --bg-tertiary: #EFF3F8;      
    --bg-interactive-hover: #E4E9F2; 
    --bg-overlay: rgba(30, 40, 60, 0.7); 
    --bg-info-light: rgba(14, 165, 233, 0.08);
    --bg-warning-light: rgba(245, 158, 11, 0.08);
    --bg-success-light: rgba(16, 185, 129, 0.08);
    --bg-danger-light: rgba(239, 68, 68, 0.08);

    --text-primary: #1F2937;     
    --text-secondary: #6B7280;   
    --text-placeholder: #9CA3AF;
    --text-on-accent: #FFFFFF;
    --text-on-dark: #FFFFFF; 
    --text-info: #075985;    
    --text-warning: #713F12;
    --text-success: #065F46; 
    --text-danger: #991B1B;  

    --border-primary: #D1D5DB;   
    --border-secondary: #E5E7EB; 
    --border-interactive: #CBD5E1; 
    --border-focus: #3B82F6;     

    --accent-primary: #2563EB;   
    --accent-primary-hover: #1D4ED8;
    --accent-primary-active: #1E40AF;
    --accent-primary-light: rgba(59, 130, 246, 0.12); 

    --accent-secondary: #10B981; 
    --accent-secondary-hover: #059669;
    --accent-secondary-active: #047857; 

    --accent-danger: #EF4444;   
    --accent-danger-hover: #DC2626;
    --accent-danger-active: #B91C1C;

    --accent-warning: #F59E0B;   
    --accent-warning-hover: #D97706;
    --accent-warning-active: #B45309;

    --accent-info: #0EA5E9;      
    --accent-info-hover: #0284C7;
    --accent-info-active: #0369A1;

    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-monospace: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    --font-size-base: 1rem; 
    --font-size-sm: 0.875rem; 
    --font-size-lg: 1.125rem; 
    --line-height-base: 1.65;
    --line-height-tight: 1.35;

    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 4px -2px rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 20px -5px rgba(0, 0, 0, 0.08), 0 4px 8px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 30px -10px rgba(0, 0, 0, 0.1), 0 8px 12px -6px rgba(0, 0, 0, 0.05);
    --shadow-focus: 0 0 0 4px color-mix(in srgb, var(--border-focus) 20%, transparent);

    --radius-xs: 0.125rem; 
    --radius-sm: 0.25rem;  
    --radius-md: 0.5rem;   
    --radius-lg: 0.75rem;  
    --radius-xl: 1rem;     
    --radius-full: 9999px;

    --header-height: 72px;
    --nav-width-expanded: 290px;
    --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-std: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --content-padding: 28px;
    --content-padding-mobile: 16px;

    /* RGB Values for opacity control */
    --bg-primary-rgb: 247, 249, 252;
    --bg-secondary-rgb: 255, 255, 255;
    --text-primary-rgb: 31, 41, 55;
    --accent-primary-rgb: 37, 99, 235;
    --accent-success-rgb: 16, 185, 129;
    --accent-danger-rgb: 239, 68, 68;
    --accent-warning-rgb: 245, 158, 11;
}

.dark-theme {
    --bg-primary: #111827;
    --bg-secondary: #1F2937;
    --bg-tertiary: #374151; 
    --bg-interactive-hover: #4B5563;
    --bg-overlay: rgba(10, 15, 25, 0.75);
    --bg-info-light: rgba(56, 189, 248, 0.1);
    --bg-warning-light: rgba(251, 191, 36, 0.1);
    --bg-success-light: rgba(52, 211, 153, 0.1);
    --bg-danger-light: rgba(248, 113, 113, 0.1);

    --text-primary: #F3F4F6; 
    --text-secondary: #9CA3AF;
    --text-placeholder: #6B7280;
    --text-info: #7DD3FC;
    --text-warning: #FCD34D;
    --text-success: #6EE7B7;
    --text-danger: #FDA4AF;

    --border-primary: #4B5563;
    --border-secondary: #374151; 
    --border-interactive: #525E71;
    --border-focus: #60A5FA;

    --accent-primary: #60A5FA;
    --accent-primary-hover: #3B82F6;
    --accent-primary-active: #2563EB;
    --accent-primary-light: rgba(96, 165, 250, 0.15);

    --accent-secondary: #34D399; 
    --accent-secondary-hover: #10B981;
    --accent-secondary-active: #059669; 

    --accent-danger: #F87171; 
    --accent-warning: #FBBF24; 
    --accent-info: #38BDF8;   

    --shadow-focus: 0 0 0 4px color-mix(in srgb, var(--border-focus) 25%, transparent);

    /* RGB Values for opacity control */
    --bg-primary-rgb: 17, 24, 39;
    --bg-secondary-rgb: 31, 41, 55;
    --text-primary-rgb: 243, 244, 246;
    --accent-primary-rgb: 96, 165, 250;
    --accent-success-rgb: 52, 211, 153;
    --accent-danger-rgb: 248, 113, 113;
    --accent-warning-rgb: 251, 191, 36;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: var(--line-height-base);
    transition: background-color var(--transition-std), color var(--transition-std);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body.no-scroll {
    overflow: hidden;
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}


/* ---------------------------------- */
/* ------ LAYOUT & APP SHELL ------ */
/* ---------------------------------- */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

.main-content {
    flex-grow: 1;
    padding-top: calc(var(--header-height) + var(--content-padding));
    padding-left: var(--content-padding);
    padding-right: var(--content-padding);
    padding-bottom: calc(var(--content-padding) + 40px); 
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* -------------------------------- */
/* ------ LOGIN & VISIBILITY ------ */
/* -------------------------------- */

#loginScreenContainer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    width: 100%;
}

.login-container {
    max-width: 450px;
    width: 100%;
    margin: 32px;
    padding: 32px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.login-container h2 {
    text-align: center;
    margin-bottom: 12px;
    font-size: 1.8rem;
}
.login-container p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
}
.login-container .note {
    font-size: var(--font-size-sm);
    color: var(--text-placeholder);
    margin-top: 16px;
    text-align: center;
}

.hidden {
    display: none !important;
}


/* -------------------------- */
/* ------ FOCUS STATES ------ */
/* -------------------------- */

*:focus:not(:focus-visible) { outline: none; }
*:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 3px;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-md);
}
.input-field:focus-visible, .select-field:focus-visible, .btn:focus-visible, .chip:focus-visible, .sku-tab:focus-visible, .shipment-tab:focus-visible {
    outline: 3px solid var(--border-focus) !important; 
    outline-offset: 2px !important;
    box-shadow: var(--shadow-focus) !important;
}
.input-field:focus, .select-field:focus { 
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}

/* -------------------------------- */
/* ------ HEADER & INDICATOR ------ */
/* -------------------------------- */

.app-header {
    display: flex; align-items: center;
    padding: 0 var(--content-padding);
    height: var(--header-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.app-title-text {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-right: auto;
    letter-spacing: -0.025em;
    line-height: var(--line-height-tight);
}
.header-actions-container { display: flex; align-items: center; gap: 12px; }

/* Header Actions Styles */
.header-actions-container .btn-icon {
    margin-left: 0.5rem;
}

/* Header Button Styles */
.header-btn {
    width: 44px;
    height: 44px;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.theme-toggle-btn, .header-btn {
    width: 44px; height: 44px;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    display: inline-flex; align-items: center; justify-content: center;
    transition: background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
.theme-toggle-btn:hover, .header-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    transform: scale(1.05);
}
.theme-toggle-btn svg, .header-btn svg {
    width: 22px; height: 22px;
    transition: transform 0.2s ease-in-out;
    stroke: currentColor; 
    fill: none; 
}
.theme-toggle-btn:hover svg { transform: rotate(10deg) scale(1.1); }

#themeToggleBtnLight { display: inline-flex; } #themeToggleBtnDark { display: none; }
.dark-theme #themeToggleBtnLight { display: none; } .dark-theme #themeToggleBtnDark { display: inline-flex; }

/* --- Advanced Sync Indicator Styles --- */
.network-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    cursor: pointer;
    position: relative;
}
.network-status svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
    fill: none;
    stroke: currentColor;
}
.network-status.synced {
    background-color: var(--bg-success-light);
    color: var(--text-success);
    border-color: color-mix(in srgb, var(--accent-secondary) 20%, transparent);
}
.network-status.pending {
    background-color: var(--bg-warning-light);
    color: var(--text-warning);
    border-color: color-mix(in srgb, var(--accent-warning) 30%, transparent);
}
.network-status.syncing {
    background-color: var(--accent-primary-light);
    color: var(--accent-primary);
    border-color: color-mix(in srgb, var(--accent-primary) 30%, transparent);
}
.network-status.offline {
    background-color: var(--bg-danger-light);
    color: var(--text-danger);
    border-color: color-mix(in srgb, var(--accent-danger) 30%, transparent);
}

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.network-status .icon-spin { animation: spin 1.2s linear infinite; }

@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.6; } 100% { opacity: 1; } }
.network-status .icon-pulse { animation: pulse 2s ease-in-out infinite; }

/* Sync Popover */
.sync-popover {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    right: 16px;
    width: 320px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-primary);
    z-index: 9998;
    overflow: hidden;
    transform-origin: top right;
    animation: dropdownSlideIn 0.2s ease-out;
    display: flex;
    flex-direction: column;
}
.sync-popover.hidden { display: none; }

@keyframes dropdownSlideIn {
    from { opacity: 0; transform: scale(0.95) translateY(-5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-secondary);
    background-color: var(--bg-tertiary);
}
.popover-header h4 { margin: 0; font-size: 1rem; font-weight: 600; }
.popover-header .btn-very-small { margin: 0; }
.popover-header .btn-very-small .spinner { width: 12px; height: 12px; }

.sync-queue-list {
    list-style: none; padding: 8px; margin: 0;
    max-height: 300px; overflow-y: auto; flex-grow: 1;
}
.sync-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px; border-radius: var(--radius-sm);
}
.sync-item:not(:last-child) { border-bottom: 1px solid var(--border-tertiary); }
.sync-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.sync-item .item-name {
    flex-grow: 1; font-size: var(--font-size-sm);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sync-item .item-status {
    font-size: 0.8rem; font-weight: 500;
    color: var(--text-secondary);
}
.sync-item .item-status.failed {
    color: var(--text-danger); font-weight: 600; cursor: help;
}
.sync-item .status-syncing { color: var(--accent-primary); }
.sync-item .status-pending { color: var(--text-placeholder); }
.sync-item .status-failed { color: var(--accent-danger); }

.sync-queue-list .empty-queue {
    text-align: center; padding: 24px 12px;
    font-size: var(--font-size-sm); color: var(--text-secondary);
}
.sync-queue-list .failed-divider {
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
    color: var(--text-placeholder); padding: 12px 10px 4px;
    border-top: 1px dashed var(--border-secondary); margin-top: 8px;
}

.popover-footer {
    padding: 8px 16px; font-size: 0.75rem;
    color: var(--text-secondary); text-align: center;
    border-top: 1px solid var(--border-secondary);
    background-color: var(--bg-tertiary);
}


/* ----------------------------- */
/* ------ SIDE NAVIGATION ------ */
/* ----------------------------- */

.nav-toggle-btn {
    margin-right: 20px;
    border: none;
    color: var(--text-secondary);
    width: 48px; height: 48px; 
    border-radius: var(--radius-md);
    display: inline-flex; align-items: center; justify-content: center;
    transition: color var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
}
.nav-toggle-btn:hover {
    color: var(--accent-primary);
    background-color: var(--bg-tertiary);
    transform: scale(1.05);
}
.nav-toggle-btn svg { width: 24px; height: 24px; stroke-width: 2.5; stroke: currentColor; }

.side-navigation {
    position: fixed; top: var(--header-height); left: 0;
    width: var(--nav-width-expanded);
    height: calc(100vh - var(--header-height));
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    padding: 24px 0;
    transform: translateX(-100%);
    transition: transform var(--transition-std);
    z-index: 990;
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; gap: 6px;
    overflow-y: auto;
}
.side-navigation.open { transform: translateX(0); }

.nav-overlay {
    position: fixed; top: var(--header-height); left: 0; right: 0; bottom: 0;
    background-color: var(--bg-overlay);
    backdrop-filter: blur(6px); 
    z-index: 980;
    opacity: 0; pointer-events: none;
    transition: opacity var(--transition-std);
}
.nav-overlay.active { opacity: 1; pointer-events: auto; }

.nav-item {
    display: flex; align-items: center; gap: 16px;
    padding: 14px var(--content-padding);
    font-size: 1.05rem; 
    font-weight: 500;
    color: var(--text-secondary);
    border: none; background: none; width: 100%; text-align: left; cursor: pointer;
    border-left: 4px solid transparent;
    position: relative; 
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.nav-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateX(4px); 
}
.nav-item.active {
    color: var(--accent-primary);
    font-weight: 600;
    border-left-color: var(--accent-primary);
    background-color: var(--accent-primary-light);
}
.nav-item svg {
    width: 22px; height: 22px;
    stroke: currentColor;
    fill: none; 
    opacity: 0.8;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    flex-shrink: 0;
}
.nav-item:hover svg { opacity: 1; transform: scale(1.05); }
.nav-item.active svg { opacity: 1; }

.nav-dropdown summary {
    list-style: none;
    position: relative;
}
.nav-dropdown summary::-webkit-details-marker {
    display: none;
}

.nav-dropdown > summary::after {
    content: '›';
    position: absolute;
    right: var(--content-padding);
    top: 50%;
    transform: translateY(-50%) rotate(0deg); /* Start pointing right */
    font-size: 1.5em;
    transition: transform var(--transition-std);
}
.nav-dropdown[open] > summary::after {
    transform: translateY(-50%) rotate(90deg); /* Point down when open */
}

.nav-dropdown-items {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.35s cubic-bezier(0.2, 0, 0, 1);
    background-color: color-mix(in srgb, var(--bg-tertiary) 50%, transparent);
    padding-left: 24px;
}
.nav-dropdown[open] > .nav-dropdown-items {
    max-height: 20rem; /* A large enough value to not clip content */
}

.nav-sub-item {
    font-size: 0.95rem;
    padding-top: 12px;
    padding-bottom: 12px;
    padding-left: calc(var(--content-padding) + 10px);
    border: none !important;
    background: none !important;
    margin: 0 !important;
}
.nav-sub-item:hover {
    background-color: var(--bg-interactive-hover) !important;
}
.nav-sub-item.active {
    background-color: var(--accent-primary-light) !important;
    font-weight: 500;
}


/* -------------------------- */
/* ------ SCREEN LAYOUT ------ */
/* -------------------------- */

.screen {
    display: none;
    animation: screenFadeIn 0.4s var(--transition-std);
}
.screen.active-screen { display: block; }
@keyframes screenFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 32px;
    padding-bottom: 24px; border-bottom: 1px solid var(--border-secondary);
    flex-wrap: wrap; gap: 20px;
}
.screen-header h2 {
    font-size: 2rem; 
    font-weight: 700; letter-spacing: -0.03em;
    color: var(--text-primary);
    line-height: var(--line-height-tight);
}
.screen-header-actions { display: flex; gap: 14px; flex-shrink: 0; flex-wrap: wrap; }

/* ------------------------------------ */
/* ------ BUTTONS & INTERACTIVE ------ */
/* ------------------------------------ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.6em;
    font-family: var(--font-primary); font-weight: 500;
    padding: 0.875rem 1.625rem;
    border-radius: var(--radius-md); border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-base);
    line-height: 1.5;
    text-decoration: none; white-space: nowrap;
    min-height: 48px;
    box-shadow: var(--shadow-sm);
    user-select: none;
}
.btn:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-md);
    filter: brightness(1.05);
}
.btn:active:not(:disabled) {
    transform: translateY(0px) scale(0.98);
    box-shadow: var(--shadow-xs);
    filter: brightness(0.95);
}
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background-color: var(--bg-tertiary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-interactive) !important;
    box-shadow: none !important; transform: none !important; filter: none !important;
}
.btn svg {
    width: 1.15em; height: 1.15em;
    vertical-align: middle;
    stroke: currentColor;
    fill: none;
}
.btn-primary svg, .btn-danger svg, .btn-success svg {
    stroke: var(--text-on-accent);
}
.btn-secondary svg { stroke: var(--text-primary); }

.btn-primary { background-color: var(--accent-primary); color: var(--text-on-accent); border-color: var(--accent-primary); }
.btn-primary:hover:not(:disabled) { background-color: var(--accent-primary-hover); border-color: var(--accent-primary-hover); }
.btn-primary:active:not(:disabled) { background-color: var(--accent-primary-active); border-color: var(--accent-primary-active); }

.btn-secondary { background-color: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-interactive); }
.btn-secondary:hover:not(:disabled) { background-color: var(--bg-tertiary); border-color: color-mix(in srgb, var(--border-interactive) 70%, var(--text-primary)); }
.btn-secondary:active:not(:disabled) { background-color: var(--bg-interactive-hover); }

.btn-danger { background-color: var(--accent-danger); color: var(--text-on-accent); border-color: var(--accent-danger); }
.btn-danger:hover:not(:disabled) { background-color: var(--accent-danger-hover); border-color: var(--accent-danger-hover); }
.btn-danger:active:not(:disabled) { background-color: var(--accent-danger-active); border-color: var(--accent-danger-active); }

.btn-success { background-color: var(--accent-secondary); color: var(--text-on-accent); border-color: var(--accent-secondary); }
.btn-success:hover:not(:disabled) { background-color: var(--accent-secondary-hover); border-color: var(--accent-secondary-hover); }
.btn-success:active:not(:disabled) { background-color: var(--accent-secondary-active); border-color: var(--accent-secondary-active); }

.btn-icon {
    background: none; border: none; padding: 0;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    width: 48px; height: 48px;
    min-width: 48px; min-height: 48px;
    box-shadow: none;
    display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover:not(:disabled) { background-color: var(--bg-tertiary); color: var(--text-primary); transform: scale(1.05); box-shadow: none; }
.btn-icon svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; }

.btn-small { padding: 0.625rem 1.25rem; font-size: var(--font-size-sm); min-height: 40px; }
.btn-xlarge { padding: 1rem 2rem; font-size: var(--font-size-lg); min-height: 56px; border-radius: var(--radius-lg); }
.btn-very-small {
    padding: 0.375rem 0.75rem; font-size: 0.8rem;
    min-height: 30px; border: 1px solid var(--border-secondary);
    margin-left: 10px; vertical-align: middle;
    background-color: var(--bg-tertiary); color: var(--text-secondary);
}
.btn-very-small:hover:not(:disabled) { background-color: var(--bg-interactive-hover); color: var(--text-primary); }
.btn-very-small svg { width: 14px; height: 14px; margin-right: 5px; stroke: currentColor; fill: none; }
.btn-icon-text svg { margin-right: 8px; stroke: currentColor; fill: none; }

.btn-file-upload { position: relative; overflow: hidden; }
.btn-file-upload input[type="file"] {
    position: absolute; top: 0; right: 0;
    min-width: 100%; min-height: 100%;
    font-size: 100px; text-align: right;
    opacity: 0; outline: none; background: white;
    cursor: inherit; display: block;
}
.btn-link {
    background: none; border: none; box-shadow: none;
    color: var(--accent-primary);
    padding: 0.25em 0.5em;
    min-height: auto;
    text-decoration: underline;
}
.btn-link:hover {
    color: var(--accent-primary-hover);
    background-color: var(--accent-primary-light);
    transform: none; filter: none; box-shadow: none;
}
.btn-link.btn-link-danger { color: var(--accent-danger); }
.btn-link.btn-link-danger:hover { color: var(--accent-danger-hover); background-color: var(--bg-danger-light); }


/* -------------------------- */
/* ------ FORM & INPUTS ------ */
/* -------------------------- */

.input-field, .select-field, textarea.input-field {
    display: block; width: 100%;
    padding: 0.875rem 1.125rem;
    font-size: var(--font-size-base);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-interactive);
    border-radius: var(--radius-md); color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
    min-height: 48px;
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
}
.input-field::placeholder { color: var(--text-placeholder); }
.input-field:hover, .select-field:hover, textarea.input-field:hover {
    border-color: color-mix(in srgb, var(--border-interactive) 70%, var(--text-primary));
}
.input-field:disabled, .select-field:disabled, textarea.input-field:disabled {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed; opacity: 0.65;
    border-color: var(--border-secondary);
}
textarea.input-field { min-height: 112px; resize: vertical; line-height: 1.6; }

.select-field {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 1rem center; background-size: 1.25rem 1.25rem;
    padding-right: 3.5rem;
}
.dark-theme .select-field {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
.select-field-small { padding: 0.625rem 0.875rem; font-size: var(--font-size-sm); min-height: 40px; background-position: right 0.875rem center; padding-right: 2.75rem; }


.controls-group {
    display: flex; flex-wrap: wrap; gap: 18px;
    margin-bottom: 32px;
    background-color: var(--bg-secondary);
    padding: 28px; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md); align-items: flex-end;
}
.controls-group > * { flex-grow: 1; min-width: 180px; }
.controls-group .form-field { margin-bottom: 0; }
.controls-group .btn { flex-grow: 0; flex-shrink: 0; }

.form-field { margin-bottom: 1.5rem; }
.form-field label {
    display: block; font-size: var(--font-size-sm);
    font-weight: 500; margin-bottom: 0.5rem;
    color: var(--text-secondary);
}
.form-field-inline { display: flex; align-items: center; gap: 10px; margin-bottom: 1.5rem; }
.form-field-inline label { margin-bottom: 0; }
.form-field-inline .select-field, .form-field-inline .input-field { width: auto; flex-grow: 1;}
.form-field-inline input[type="checkbox"] { width: auto; margin-right: 0.5em; }

/* FIX: New more robust form grid that automatically collapses */
.form-grid-2col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.sku-search-field { position: relative; flex-grow: 2 !important; }
.input-adornment {
    position: absolute; right: 1.125rem; top: 50%;
    transform: translateY(-50%); color: var(--text-placeholder);
    pointer-events: none; line-height: 0;
}
.input-adornment svg { width: 20px; height: 20px; stroke: currentColor; fill:none; }

/* -------------------- */
/* ------ MODAL ------ */
/* -------------------- */

.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-overlay);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    padding: var(--content-padding);
    transition: opacity var(--transition-std);
}
.modal-overlay.hidden { display: none; opacity: 0; }
.modal-overlay:not(.hidden) { opacity: 1; }

.modal-dialog {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: modalSlideIn 0.3s var(--transition-std);
    transition: max-width var(--transition-std);
}

.modal-dialog.modal-wide {
    max-width: 95vw;
    max-height: 95vh;
}
@media (min-width: 1200px) {
    .modal-dialog.modal-wide {
        max-width: 1100px;
    }
}

@keyframes modalSlideIn {
    from { opacity: 0.6; transform: scale(0.95) translateY(15px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px var(--content-padding);
    border-bottom: 1px solid var(--border-secondary);
    flex-shrink: 0;
}
.modal-title {
    font-size: 1.25rem; font-weight: 700;
    color: var(--text-primary); line-height: var(--line-height-tight);
}
.modal-close-btn {
    width: 44px; height: 44px;
    color: var(--text-secondary);
    background: none; border: none;
    border-radius: var(--radius-md);
    display: inline-flex; align-items: center; justify-content: center;
    transition: background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
.modal-close-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    transform: rotate(90deg);
}
.modal-close-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }

.modal-content {
    padding: 24px var(--content-padding);
    font-size: var(--font-size-base);
    overflow-y: auto;
    flex-grow: 1;
}
.modal-content .form-field:last-child { margin-bottom: 0; }

.modal-prompt { margin-bottom: 1.25rem; white-space: pre-wrap; line-height: 1.7; }
.modal-prompt:last-child { margin-bottom: 0; }
.modal-prompt-divider {
    text-align: center; color: var(--text-secondary);
    font-size: var(--font-size-sm); margin: 16px 0;
    position: relative;
}
.modal-prompt-divider::before, .modal-prompt-divider::after {
    content: ''; height: 1px; background-color: var(--border-secondary);
    position: absolute; top: 50%; width: calc(50% - 30px);
}
.modal-prompt-divider::before { left: 0; }
.modal-prompt-divider::after { right: 0; }

#modalInput { margin-top: 8px; }
#modalCustomContent .form-field label { font-size: var(--font-size-base); }
.modal-error-message {
    background-color: var(--bg-danger-light);
    color: var(--text-danger);
    border: 1px solid color-mix(in srgb, var(--accent-danger) 30%, transparent);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-top: 16px;
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.modal-actions {
    display: flex; justify-content: flex-end; gap: 12px;
    padding: 20px var(--content-padding);
    border-top: 1px solid var(--border-secondary);
    background-color: var(--bg-primary);
    flex-shrink: 0;
}
.modal-actions .btn { font-weight: 600; }
#palletBuildInfoModalImagesContainer {
    max-height: calc(70vh - 150px); overflow: auto;
    overflow-y: auto;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
#palletBuildInfoModalImagesContainer img {
    max-width: 100%;
    height: auto;
    max-height: 400px;
    display: block;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
/* -------------------------------- /
/ ------ UTILITY & HELPERS ------- /
/ -------------------------------- */
.centered-text { text-align: center; }
.error-message {
    color: var(--accent-danger);
    background-color: var(--bg-danger-light);
    padding: 1em;
    border-radius: var(--radius-md);
    border: 1px solid var(--accent-danger);
}
/* ----------------------- /
/ ------ SCROLLBAR ------ /
/ ----------------------- */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--text-secondary) 35%, transparent);
    border-radius: var(--radius-full);
    border: 3px solid var(--bg-primary);
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--text-secondary) 55%, transparent);
}
.dark-theme ::-webkit-scrollbar-track { background: var(--bg-primary); }
.dark-theme ::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--text-secondary) 25%, transparent);
    border-color: var(--bg-primary);
}
.dark-theme ::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--text-secondary) 45%, transparent);
}
/* -------------------------- /
/ ------ MEDIA QUERIES ----- /
/ -------------------------- */
@media (max-width: 1024px) {
    .screen-header h2 { font-size: 1.875rem; }
    .controls-group {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}
@media (max-width: 768px) {
    :root {
        --content-padding: 24px;
        --header-height: 60px;
        --font-size-base: 1rem;
    }
    .app-title-text { font-size: 1.5rem; }
    .screen-header h2 { font-size: 1.75rem; }
    .controls-group { padding: 24px; }
    .modal-dialog { max-width: calc(100vw - 40px); }
}
@media (max-width: 480px) {
    :root {
        --content-padding: 20px;
        --header-height: 60px;
        --font-size-base: 0.95rem;
    }
    .app-title-text { font-size: 1.15rem; }
    .header-actions-container { gap: 6px; }
    .nav-toggle-btn, .theme-toggle-btn, .header-btn { width: 40px; height: 40px; }
    .nav-toggle-btn svg, .theme-toggle-btn svg, .header-btn svg { width: 20px; height: 20px;}
    .screen-header { flex-direction: column; align-items: flex-start; gap: 16px; }
    .screen-header h2 { font-size: 1.35rem; }
    .screen-header-actions { width: 100%; justify-content: flex-start; }
    .screen-header-actions .btn { flex-grow: 1; font-size: 0.9rem; padding: 0.75rem 1rem; }
    .btn { padding: 0.8rem 1.1rem; font-size: 0.9rem; min-height: 42px; }
    .btn-small { padding: 0.55rem 0.9rem; font-size: 0.8rem; min-height: 36px; }
    .btn-xlarge { font-size: 1rem; }
    .controls-group {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    .modal-dialog { max-width: calc(100vw - 24px); }
    .modal-header, .modal-content, .modal-actions { padding-left: 16px; padding-right: 16px; }
}
/* ----------------------- /
/ ------ FOOTER ------- /
/ ----------------------- */
.insane-protection-footer {
    --footer-accent-glow: var(--accent-danger);
    --footer-text-glow: color-mix(in srgb, var(--footer-accent-glow) 60%, #fff 40%);
    --footer-dark-bg: #0a0d14;
    --footer-metal-sheen: linear-gradient(145deg, #555, #222, #555);
    background-color: var(--footer-dark-bg);
    color: #b0c4de;
    text-align: center;
    padding: 2.5rem var(--content-padding) 2rem;
    font-family: 'Arial Black', 'Impact', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.075em;
    position: relative;
    overflow: hidden;
    margin-top: auto;
    flex-shrink: 0;
    border-top: 5px solid;
    border-image-slice: 1;
    border-image-source: linear-gradient(to left, var(--footer-accent-glow), #4a5568, var(--footer-accent-glow));
    box-shadow: 0 -6px 20px -5px rgba(0,0,0,0.6),
                inset 0 4px 10px -2px rgba(0,0,0,0.5);
}
.insane-protection-footer::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        linear-gradient(45deg, rgba(255,255,255,0.02) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.02) 50%, rgba(255,255,255,0.02) 75%, transparent 75%, transparent),
        linear-gradient(-45deg, rgba(255,255,255,0.01) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.01) 50%, rgba(255,255,255,0.01) 75%, transparent 75%, transparent);
    background-size: 60px 60px;
    opacity: 0.5;
    z-index: 0;
    animation: subtlePatternScroll 120s linear infinite;
}
@keyframes subtlePatternScroll {
    from { background-position: 0 0; }
    to { background-position: 1200px 600px; }
}
.footer-seal-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px dashed color-mix(in srgb, var(--footer-accent-glow) 40%, transparent);
    position: relative;
    z-index: 1;
}
.seal-icon {
    font-size: 3rem;
    font-weight: bold;
    color: var(--footer-text-glow);
    line-height: 1;
    text-shadow: 0 0 10px var(--footer-accent-glow), 0 0 20px var(--footer-accent-glow);
    animation: pulseGlow 3s infinite ease-in-out;
}
.seal-text {
    text-align: left;
}
.seal-year {
    display: block;
    font-size: 1.2rem;
    color: #d1d5db;
    font-weight: normal;
    letter-spacing: 0.1em;
}
.seal-name {
    font-size: 1.8rem;
    font-weight: 900;
    color: #ffffff;
    line-height: 1.1;
    display: block;
    text-shadow: 0 0 5px var(--footer-text-glow), 1px 1px 2px #000;
}
@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); text-shadow: 0 0 15px var(--footer-accent-glow), 0 0 30px var(--footer-accent-glow); }
}
.footer-legal-notice {
    position: relative;
    z-index: 1;
}
.protection-heading {
    font-size: 1.1rem;
    color: var(--footer-text-glow);
    margin-bottom: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    padding: 0.5em;
    background: color-mix(in srgb, var(--footer-accent-glow) 15%, transparent);
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--footer-accent-glow) 50%, transparent);
}
.protection-icon {
    font-size: 1.3em;
    line-height: 1;
    filter: drop-shadow(0 0 3px var(--footer-accent-glow));
}
.legal-text {
    font-size: 0.85rem;
    font-family: 'Consolas', 'Menlo', monospace;
    line-height: 1.8;
    color: #a0b0c0;
    margin-bottom: 1rem;
    max-width: 650px;
    margin-left: auto; margin-right: auto;
    font-style: normal;
    text-transform: none;
    letter-spacing: normal;
}
.warning-text {
    font-size: 0.9rem;
    font-family: 'Impact', 'Arial Black', sans-serif;
    line-height: 1.6;
    color: var(--accent-danger);
    margin: 0;
    max-width: 650px;
    margin-left: auto; margin-right: auto;
    text-shadow: 1px 1px 1px #000;
    font-weight: bold;
}

.warning-text strong {
    color: #ffdddd;
    font-weight: 900;
    filter: drop-shadow(0 0 4px var(--accent-danger));
}
.dark-theme .insane-protection-footer {
    --footer-accent-glow: var(--accent-danger-hover);
    --footer-text-glow: color-mix(in srgb, var(--footer-accent-glow) 70%, #fff 30%);
}
.dark-theme .seal-name {
    color: #ffffff;
}
.dark-theme .protection-heading {
    color: var(--footer-text-glow);
}
.dark-theme .warning-text {
    color: var(--accent-danger-hover);
}
.copyright-notice .seal-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
    font-family: monospace;
    font-size: 0.9rem;
}
.copyright-notice .seal-year {
    display: block;
}
.copyright-notice .seal-name {
    display: block;
}
.seal-icon {
    display: inline-block;
    font-size: 1.5rem;
    vertical-align: top;
    margin-right: 0.2rem;
}


/* Spinner for buttons */
.spinner {
    display: inline-block;
    width: 1.25em;
    height: 1.25em;
    border: 3px solid rgba(0, 0, 0, 0.2);
    border-right-color: var(--text-primary);
    border-radius: 50%;
    animation: spinner-spin 0.75s linear infinite;
    vertical-align: middle;
}
.btn .spinner {
    width: 1em;
    height: 1em;
    border-width: 2px;
    border-color: rgba(255, 255, 255, 0.5);
    border-right-color: #fff;
}
.btn-secondary .spinner {
    border-color: rgba(0,0,0,0.2);
    border-right-color: var(--text-primary);
}
.modal-content .spinner {
    width: 48px;
    height: 48px;
    border-width: 5px;
    margin: 40px auto;
    display: block;
}


@keyframes spinner-spin {
    to { transform: rotate(360deg); }
}

/* ------------------------------------ */
/* ------ ULTRA POLISH ADDITIONS ------ */
/* ------------------------------------ */

/* Global Loader for Server Sync */
.global-loader-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(var(--bg-primary-rgb), 0.7);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}
.global-loader-overlay.hidden {
    display: none;
}
.global-loader-overlay .spinner {
    width: 60px;
    height: 60px;
    border-width: 6px;
    border-color: rgba(var(--text-primary-rgb), 0.2);
    border-right-color: var(--accent-primary);
}


/* ⭐️ NEW: Hold-to-Confirm Button */
.btn-hold-to-confirm {
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
    will-change: transform;
    -webkit-tap-highlight-color: transparent; /* Disable flash on mobile */
}
.btn-hold-to-confirm .hold-progress {
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    width: 0%;
    background-color: rgba(var(--accent-danger-rgb, 239, 68, 68), 0.3);
    z-index: 1;
    border-radius: inherit;
}
.btn-hold-to-confirm.is-holding .hold-progress {
    width: 100%;
    transition: width 1.5s linear; /* The hold duration */
}
.btn-hold-to-confirm .btn-text {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
}


/* Toast Notifications */
.toast-notification-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
}
.toast-notification {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 14px 22px;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-primary);
    font-size: var(--font-size-base);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toast-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast-notification.success { background-color: var(--bg-success-light); color: var(--text-success); border-color: var(--accent-secondary); }
.toast-notification.error { background-color: var(--bg-danger-light); color: var(--text-danger); border-color: var(--accent-danger); }
.toast-notification.info { background-color: var(--bg-info-light); color: var(--text-info); border-color: var(--accent-info); }
.toast-notification.hiding { animation: toast-out 0.4s ease-out forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(20px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(20px); } }

/* Flash Animation for Unlocking Packing UI */
.flash-unlock {
    animation: flash-unlock-anim 0.8s ease-out;
}
@keyframes flash-unlock-anim {
    0% { box-shadow: var(--shadow-md); }
    50% { box-shadow: 0 0 15px 3px var(--accent-secondary), var(--shadow-lg); }
    100% { box-shadow: var(--shadow-md); }
}

/* Smart Template Apply Button */
.smart-template-suggestion {
    margin-top: 12px;
}